How to use the base64url function in base64url

To help you get started, we’ve selected a few base64url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / nextjs-auth0 / src / handlers / login.ts View on Github external
return async (req: IncomingMessage, res: ServerResponse, options: LoginOptions = {}): Promise => {
    if (!res) {
      throw new Error('Response is not available');
    }

    const { state = base64url(randomBytes(48)), ...authParams } = (options && options.authParams) || {};

    // Create the authorization url.
    const client = await clientProvider();
    const authorizationUrl = client.authorizationUrl({
      redirect_uri: settings.redirectUri,
      scope: settings.scope,
      response_type: 'code',
      audience: settings.audience,
      state,
      auth0Client: telemetry(),
      ...authParams
    });

    // Set the necessary cookies
    setCookies(req, res, [
      {
github ambrosus / ambrosus-nop / src / models / atlas_mode_model.js View on Github external
async createSetModeToken(mode, accessPeriod, from = Date.now()) {
    const idData = {
      mode,
      createdBy: this.account.address,
      validUntil: Math.floor(from / 1000) + accessPeriod
    };
    return base64url(this.serializeForHashing({
      signature: this.account.sign(this.serializeForHashing(idData)).signature,
      idData
    }));
  }
github creatorsdaily / client.creatorsdaily.com / components / Autofill.js View on Github external
useDebounce(() => {
    if (!link) return
    const key = base64url(link)
    setLoading(true)
    lastKey += 1;
    ((currentKey) => {
      axios.get(`https://json.xyz/${key}`).then(({ data }) => {
        if (currentKey !== lastKey) return
        setLoading(false)
        setClosed(false)
        setInfo(data)
        onData(data)
      }).catch(() => {
        if (currentKey !== lastKey) return
        setLoading(false)
        setClosed(true)
      })
    })(lastKey)
  }, 800, [link])
github opencollective / opencollective-api / server / lib / utils.js View on Github external
export const generateURLSafeToken = size => base64url(crypto.randomBytes(size));
github sourcecred / sourcecred / src / plugins / discourse / mockSnapshotFetcher.js View on Github external
async function snapshotFetch(url: string | Request | URL): Promise {
  const snapshotDir = "src/plugins/discourse/snapshots";
  const filename = base64url(url);
  const file = path.join(snapshotDir, filename);
  if (await fs.exists(file)) {
    const contents = await fs.readFile(file);
    return new Response(contents, {status: 200});
  } else {
    throw new Error(`couldn't load snapshot for ${file}`);
  }
}
export const snapshotFetcher = () => new Fetcher(options, snapshotFetch, 0);
github wellcometrust / wellcomecollection.org / catalogue / webapp / components / Auth / Auth.js View on Github external
function createLoginUrlWithVerifier() {
  const verifier = base64url(uuidv4());
  const challenge = base64url(
    crypto
      .createHash('sha256')
      .update(verifier)
      .digest()
  );

  const loginUrl = `${authDomain}/oauth2/authorize?${new URLSearchParams({
    ...authParams,
    redirect_uri: getRedirectUrl(),
    code_challenge: challenge,
    code_challenge_method: 'S256',
  }).toString()}`;

  return { loginUrl, verifier };
}
github wellcometrust / wellcomecollection.org / catalogue / webapp / components / Auth / Auth.js View on Github external
function createLoginUrlWithVerifier() {
  const verifier = base64url(uuidv4());
  const challenge = base64url(
    crypto
      .createHash('sha256')
      .update(verifier)
      .digest()
  );

  const loginUrl = `${authDomain}/oauth2/authorize?${new URLSearchParams({
    ...authParams,
    redirect_uri: getRedirectUrl(),
    code_challenge: challenge,
    code_challenge_method: 'S256',
  }).toString()}`;

  return { loginUrl, verifier };
}

base64url

For encoding to/from base64urls

MIT
Latest version published 5 years ago

Package Health Score

74 / 100
Full package analysis