micro509/jose
Optional JOSE surface: compact JWE plus signed compact JWS and JWT (RS256/384/512, ES256/384), JWK Sets, and opt-in remote JWKS resolution. Importing this entrypoint performs no network access.
Start with verifyJwt for tokens, createJwksKeyResolver for a local JWK Set, and createRemoteJwksKeyResolver to read keys from a trusted URL.
Functions
base64UrlDecode— Decodes canonical unpadded base64url, or returnsundefinedfor invalid/noncanonical input. Empty input yields empty bytes.base64UrlEncode— Encodes bytes as canonical unpadded base64url; does not encode text.decryptCompactJwe— Decrypts with explicit application allowlists, bounded parsing and the supplied private key.encryptCompactJwe— Encrypts one compact JWE for the limited RSA-OAEP-512/A256GCM profile (RFC 7516 §5.1).createJwksKeyResolver— Creates a key resolver over a fixed JWK Set.importJwkEntry— Imports a selected entry as a verify-only key foralgorithm. The default remains RS256;parseJwks— Parses a JWK Set document.selectJwk— Selects the one key of a set that can verifyselector.validateJwks— Validates already parsed, plain JSON data and owns a detached deep snapshot of it.parseCompactJws— Parses a compact JWS without checking its signature.signCompactJws— Signs a compact JWS with an existing privateCryptoKey.verifyCompactJws— Verifies a compact JWS.decodeJwtUnverified— Decodes a JWT without checking its signature. Every field of the result is unauthenticated.signJwt— Signs a JWT. The header carriestyp: "JWT"unlessheader.typsays otherwise.verifyJwt— Verifies a JWT: the signature andtokenTypepolicy asverifyCompactJwsappliescreateRemoteJwksKeyResolver— Creates a key resolver that reads a JWK Set from one trusted URL.
Types
JsonObject— A parsed JSON object.JsonValue— A parsed JSON value. Objects are plain records whose members are all own data properties.JoseErrorCode— Every code a JOSE API reports.JoseErrorDetails— Structured context for a failure. Holds names and short identifiers only, never tokenJoseErrorResult— A flattened failed result carrying aJoseFailure.JoseFailure— Failure payload of the JOSE APIs.JoseResult— Success-or-failure result of a JOSE API.JweErrorCode— Failures for the compact JWE profile.JwsParseErrorCode— Reasons a compact serialization is refused before any signature is checked.JwsPolicyErrorCode— Reasons a well-formed token is refused by the verification policy or its signature.JwtClaimsErrorCode— Reasons a signature-verified token fails the claims policy.KeyResolutionErrorCode— Reasons a signing key cannot be resolved for a token.VerifyJwsErrorCode— Failure codes ofverifyCompactJws.VerifyJwtErrorCode— Failure codes ofverifyJwt.DecryptedJwe— Authenticated plaintext. Encryption does not establish sender identity: anyone with the public key can encrypt.DecryptJweOptions— Input policy fordecryptCompactJwe; neither allowlist is inferred from the token.EncryptJweInput— Input toencryptCompactJwe.JweAlgorithm— Implemented key-management algorithm; SHA-512 and MGF1-SHA-512 with empty OAEP label.JweEncryption— Implemented content encryption: 256-bit AES-GCM, 96-bit IV, 128-bit tag.JweHeader— A compact JWE protected header, with every noncritical member retained.EcJwkEntry— An EC public key entry, with its curve and uncompressed affine coordinates.JwkEntry— One key of a JWK Set.JwkEntryBase— Members shared by every parsed entry.JwkMetadata— Members every JWK entry carries beside its key material.JwkSelector— WhatselectJwkmatches against.Jwks— A parsed JWK Set.JwksLimits— Bounds applied while parsing a JWK Set.ParseJwksErrorCode— CodesparseJwksreturns.RsaJwkEntry— An RSA public key entry.SupportedJwkEntry— Public key entries whose type this module can select.UnsupportedJwkEntry— An entry this module never selects: aktyother thanRSAorEC, or an entry with missing orJoseLimits— Size and structure bounds enforced before any expensive parsing.JwsAlgorithm— Signature algorithms this module signs and verifies.JwsHeader— A protected header. Every member the token carried stays reachable throughmembers.JwsHeaderInput— Header memberssignCompactJwssets besidealg.JwsKeyRequest— What a key resolver is asked for. The header is unauthenticated.JwsKeyResolver— Supplies the verification key for a token.SignJoseErrorCode— CodessignCompactJwsandsignJwtthrow.SignJwsInput— Input forsignCompactJws.TokenTypePolicy— Expectation for thetypheader (RFC 7515 §4.1.9, RFC 8725 §3.11).Unchecked— Marks a policy dimension as deliberately not checked.UnverifiedJws— A parsed token whose signature has not been checked. Nothing in it is trustworthy untilVerifiedJws— A token whose signature verified under the caller's algorithm and key policy.VerifyJwsOptions— Options forverifyCompactJws.FutureIssuedAtPolicy— Whether aniatlater than the clock is accepted.JwtClaimsPolicy— Claims policy forverifyJwt. Application authorization stays with the caller.RegisteredClaims— The RFC 7519 §4.1 registered claims, each checked against its defined type.SignJwtInput— Input forsignJwt.UnverifiedJwt— A decoded JWT whose signature has not been checked.VerifiedJwt— A JWT whose signature and claims both passed the caller's policy.VerifyJwtOptions— Options forverifyJwt.JwksRequestInit— The requestJwksTransportmust issue.JwksTransport— Performs one HTTP request.fetchsatisfies this type. Supply another to route through a proxy,RemoteJwksConfig— Configuration ofcreateRemoteJwksKeyResolver.RemoteJwksConfigErrorCode— CodescreateRemoteJwksKeyResolverthrows for unusable configuration.RemoteJwksRedirectPolicy— Redirect handling for a remote JWK Set. By default redirects are refused.
Variables
DEFAULT_JWKS_LIMITS— The limits applied when a caller supplies none.DEFAULT_JOSE_LIMITS— The limits applied when a caller supplies none.JWS_ALGORITHMS— EveryJwsAlgorithm.MIN_JWS_RSA_MODULUS_BITS— Smallest RSA modulus accepted by any implemented RSA JWS algorithm (RFC 7518 §3.3).MIN_RS256_MODULUS_BITS— Smallest RSA modulus RS256 accepts (RFC 7518 §3.3).MAX_CLOCK_TOLERANCE_SECONDS— Largest clock toleranceJwtClaimsPolicy.clockToleranceSecondsaccepts.