Get started with jose CDN

MIT licensed

Jose: Easy JS encryption/decryption for Web Crypto APIs JWS, JWE standards.

Tags:
  • compact
  • decode
  • decrypt
  • detached
  • ec
  • ecdsa
  • eddsa
  • electron
  • embedded
  • encrypt
  • flattened
  • general
  • jose
  • json web token
  • jsonwebtoken
  • jwa
  • jwe
  • jwk
  • jwks
  • jws
  • jwt
  • oct
  • payload
  • pem
  • pkcs8
  • rsa
  • sign
  • signature
  • spki
  • validate
  • verify
  • webcrypto
  • x509

Stable version

Copied!

How to start using jose CDN


const jose = await import('https://cdn.cdnhub.io/jose/5.2.3/index.js');

const secret = 'my-secret-key'; // Replace this with your actual secret key

async function createJwtForUser(user) {
  const payload = { sub: user.id, name: user.name }; // Replace with your actual user data

  const key = await jose.JWK.asKey(secret, 'symmetric'); // Create a key from the secret

  const jwt = await jose.JWT.create(payload, key).sign(); // Create and sign the JWT

  return jwt;
}

(async () => {
  const jose = await import('https://cdn.cdnhub.io/jose/5.2.3/index.js');
  const user = { id: '123', name: 'jose' };

  try {
    const jwt = await createJwtForUser(user);
    console.log('JWT:', jwt);
  } catch (error) {
    console.error('Error creating JWT:', error);
  }
})();
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions