How to use the base64url.toBase64 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 OfficeDev / microsoft-teams-sample-auth-node / src / apis / OpenIdMetadata.ts View on Github external
private findKey(keyId: string): IOpenIdMetadataKey {
        if (!this.keys) {
            return null;
        }

        for (let i = 0; i < this.keys.length; i++) {
            if (this.keys[i].kid === keyId) {
                let key = this.keys[i];

                if (!key.n || !key.e) {
                    // Return null for non-RSA keys
                    return null;
                }

                let modulus = base64url.toBase64(key.n);
                let exponent = key.e;

                return { key: getPem(modulus, exponent), endorsements: key.endorsements } as IOpenIdMetadataKey;
            }
        }

        return null;
    }
}
github OfficeDev / microsoft-teams-sample-complete-node / src / utils / OpenIdMetadata.ts View on Github external
private findKey(keyId: string): IOpenIdMetadataKey {
        if (!this.keys) {
            return null;
        }

        for (let i = 0; i < this.keys.length; i++) {
            if (this.keys[i].kid === keyId) {
                let key = this.keys[i];

                if (!key.n || !key.e) {
                    // Return null for non-RSA keys
                    return null;
                }

                let modulus = base64url.toBase64(key.n);
                let exponent = key.e;

                return { key: getPem(modulus, exponent), endorsements: key.endorsements } as IOpenIdMetadataKey;
            }
        }

        return null;
    }
}
github microsoft / botbuilder-js / libraries / botframework-connector / src / auth / openIdMetadata.ts View on Github external
private findKey(keyId: string): IOpenIdMetadataKey | null {
        if (!this.keys) {
            return null;
        }

        for (const key of this.keys) {
            if (key.kid === keyId) {

                if (!key.n || !key.e) {
                    // Return null for non-RSA keys
                    return null;
                }

                const modulus: any = base64url.toBase64(key.n);
                const exponent: string = key.e;

                return { key: getPem(modulus, exponent), endorsements: key.endorsements } as IOpenIdMetadataKey;
            }
        }

        return null;
    }
}
github jsonwebtoken / jsonwebtoken.github.io / test / unit / editor / jwt.js View on Github external
it('considers Base64 (not URL) encoded tokens invalid', function() {
    const token = b64u.toBase64(tokens.hs256.token);

    jwt.isToken(token).should.be.false;
    return jwt.verify(token, tokens.hs256.secret).should.eventually.be.false;
  });
github anvilresearch / jose / src / algs / RSASSA-PKCS1-v1_5.js View on Github external
verify (input, signature, publicKey) {
    let {bitlength} = this
    let base64sig = base64url.toBase64(signature)
    let verifier = crypto.createVerify(`RSA-SHA${bitlength}`)
    verifier.update(input)
    return verifier.verify(publicKey, signature, 'base64')
  }
github microsoft / BotBuilder-V3 / Node / core / lib / bots / OpenIdMetadata.js View on Github external
OpenIdMetadata.prototype.findKey = function (keyId) {
        if (!this.keys) {
            return null;
        }
        for (var i = 0; i < this.keys.length; i++) {
            if (this.keys[i].kid == keyId) {
                var key = this.keys[i];
                if (!key.n || !key.e) {
                    return null;
                }
                var modulus = base64url.toBase64(key.n);
                var exponent = key.e;
                return { key: getPem(modulus, exponent), endorsements: key.endorsements };
            }
        }
        return null;
    };
    return OpenIdMetadata;
github solokeys / solo-desktop / util.js View on Github external
b64url2b64: function(b64url)
{
    return base64url.toBase64(b64url)
},
github decentralized-identity / did-jwt / src / VerifierAlgorithm.ts View on Github external
export function verifyEd25519(
  data: string,
  signature: string,
  authenticators: PublicKey[]
): PublicKey {
  const clear: Uint8Array = naclutil.decodeUTF8(data)
  const sig: Uint8Array = naclutil.decodeBase64(base64url.toBase64(signature))
  const signer: PublicKey = authenticators.find(({ publicKeyBase64 }) =>
    nacl.sign.detached.verify(
      clear,
      sig,
      naclutil.decodeBase64(publicKeyBase64)
    )
  )
  if (!signer) throw new Error('Signature invalid for JWT')
  return signer
}
github microsoft / BotBuilder-V3 / Node / calling / lib / bots / CallConnector.js View on Github external
CallConnector.prototype.getSecretForKey = function (keyId) {
        for (var i = 0; i < cachedKeys.length; i++) {
            if (cachedKeys[i].kid == keyId) {
                var jwt = cachedKeys[i];
                var modulus = base64url.toBase64(jwt.n);
                var exponent = jwt.e;
                return getPem(modulus, exponent);
            }
        }
        return null;
    };
    CallConnector.prototype.verifyBotFramework = function (req, res) {

base64url

For encoding to/from base64urls

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis