### Install Dependencies Source: https://github.com/oslo-project/jwt/blob/main/CONTRIBUTING.md Installs project dependencies using PNPM. This is the first step to set up the development environment. ```shell pnpm i ``` -------------------------------- ### Install @oslojs/jwt Source: https://github.com/oslo-project/jwt/blob/main/README.md Installs the @oslojs/jwt package using npm. ```bash npm i @oslojs/jwt ``` -------------------------------- ### Install @oslojs/jwt Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/index.md Installs the @oslojs/jwt package using npm, the Node Package Manager. This is the standard way to add the library to your JavaScript or TypeScript project. ```bash npm i @oslojs/jwt ``` -------------------------------- ### Create JWT Token Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/guides/create-tokens.md Encodes a header object, payload object, and a signature into a JWT token. Requires the `joseAlgorithmHS256`, `createJWTSignatureMessage`, and `encodeJWT` functions from `@oslojs/jwt`. The example demonstrates creating a token with an expiration date and a name. ```ts import { joseAlgorithmHS256, createJWTSignatureMessage, encodeJWT } from "@oslojs/jwt"; const headerJSON = JSON.stringify({ alg: joseAlgorithmHS256, typ: "JWT" }); const payloadJSON = JSON.stringify({ exp: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 30, name: "John Doe" }); const signatureBuffer = await crypto.subtle.sign("HMAC", key, createJWTSignatureMessage(headerJSON, payloadJSON)); const jwt = encodeJWT(headerJSON, payloadJSON, new Uint8Array(signatureBuffer)); ``` -------------------------------- ### Get JWT Issuer Claim Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/issuer.md Retrieves the 'iss' (issuer) registered claim from JWT. This function expects the claim to exist and be a string, otherwise it throws an error. It is part of the JWTRegisteredClaims functionality. ```typescript function issuer(): string; // Returns the "iss" parameter value. Throws an Error if the parameter doesn't exist or the value isn't a string. ``` -------------------------------- ### Get Issued At Claim as Date Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/issuedAt.md Retrieves the 'iat' (issued at) claim from JWTRegisteredClaims and returns it as a Date object. This function validates that the 'iat' claim exists and is a positive integer, throwing an error otherwise. ```typescript function issuedAt(): Date; ``` -------------------------------- ### Get JWT Audiences Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/audiences.md Returns the 'aud' parameter value from JWT registered claims. This function expects the 'aud' parameter to be an array of strings. It throws an error if the parameter is missing or not a string array. It can also return an empty array if the 'aud' parameter is present but empty. ```typescript function audiences(): string[] ``` -------------------------------- ### Run Tests and Build Source: https://github.com/oslo-project/jwt/blob/main/CONTRIBUTING.md Executes the project's test suite and builds the package. Essential for verifying code changes and preparing for deployment. ```shell pnpm test pnpm build ``` -------------------------------- ### Create Changesets Source: https://github.com/oslo-project/jwt/blob/main/CONTRIBUTING.md Generates a changeset for tracking changes in the project. Use 'minor' for new features and 'patch' for bug fixes. A summary of the change should be written in the created markdown file. ```shell pnpm auri add minor pnpm auri add patch ``` ```markdown Fix: Handle negative numbers in `sqrt()` Feat: Add `greet()` ``` -------------------------------- ### JWT Module Reference Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/index.md Provides an overview of the JWT module and its main functionalities. This serves as the entry point for understanding the JWT library's capabilities. ```APIDOC Module: @oslojs/jwt Description: A JavaScript library for working with JSON Web Tokens (JWT). Main Reference: /reference/main - Provides detailed API documentation for the core functionalities of the JWT module. ``` -------------------------------- ### JWTRegisteredClaims Constructor and Methods Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/index.md Provides an overview of the JWTRegisteredClaims class, including its constructor for initializing with a payload and a comprehensive list of methods for accessing and verifying standard JWT claims like audience, expiration, issuer, etc. ```APIDOC JWTRegisteredClaims: constructor(payload: object): this Parameters: - payload: JSON-decoded JWT payload object Methods: audiences(): Returns the audiences claim. expiration(): Returns the expiration time claim. hasAudiences(): Checks if the audiences claim is present. hasExpiration(): Checks if the expiration time claim is present. hasIssuedAt(): Checks if the issued at claim is present. hasIssuer(): Checks if the issuer claim is present. hasJWTId(): Checks if the JWT ID claim is present. hasNotBefore(): Checks if the not before claim is present. hasSubject(): Checks if the subject claim is present. issuedAt(): Returns the issued at claim. issuer(): Returns the issuer claim. jwtId(): Returns the JWT ID claim. notBefore(): Returns the not before claim. subject(): Returns the subject claim. verifyExpiration(): Verifies the expiration time claim. verifyNotBefore(): Verifies the not before claim. ``` -------------------------------- ### JOSE Algorithms Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/index.md Specifies the supported JOSE (JSON Object Signing and Encryption) algorithms for JWT signing. ```APIDOC joseAlgorithmES256: Elliptic Curve Digital Signature Algorithm using P-256 and SHA-256 joseAlgorithmHS256: HMAC using SHA-256 joseAlgorithmRS256: RSA Signature with SHA-256 ``` -------------------------------- ### JWSRegisteredHeaders.x509CertificateSHA1Thumbprint() Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/x509CertificateSHA1Thumbprint.md Returns the `x5t` parameter value as a byte array. Throws an `Error` if the parameter doesn't exist or the value isn't a base64url encoded string. ```typescript function x509CertificateSHA1Thumbprint(): Uint8Array; ``` -------------------------------- ### Parse and Verify JWT Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/index.md Parses a JWT string into its header, payload, and signature components. It then validates the registered headers and claims, including checking the algorithm, expiration time, and not-before time. This snippet demonstrates runtime-agnostic JWT handling. ```typescript import { parseJWT, JWSRegisteredHeaders, JWTRegisteredClaims, joseAlgorithmHS256 } from "@oslojs/jwt"; const [header, payload, signature] = parseJWT(jwt); const headerParameters = new JWSRegisteredHeaders(header); if (headerParameters.algorithm() !== joseAlgorithmHS256) { throw new Error("Unsupported algorithm"); } const claims = new JWTRegisteredClaims(payload); if (!claims.verifyExpiration()) { throw new Error("Expired token"); } if (claims.hasNotBefore() && !claims.verifyNotBefore()) { throw new Error("Invalid token"); } ``` -------------------------------- ### Check for Algorithm Parameter Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasAlgorithm.md Determines if the 'alg' parameter is present in the JWS registered headers. It only checks for existence, not for the validity of the algorithm's value. ```ts function hasAlgorithm(): boolean; ``` -------------------------------- ### JWSRegisteredHeaders.x509CertificateChain() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/x509CertificateChain.md Defines the `x509CertificateChain` function which returns the `x5c` parameter value as an array of byte arrays. It includes error handling for missing or invalid parameter values. ```ts function x509CertificateChain(): Uint8Array[]; ``` -------------------------------- ### JWSRegisteredHeaders.algorithm() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/algorithm.md Returns the value of the 'alg' parameter from JWT headers. This function will throw an error if the parameter is missing or its value is not a string. ```ts function algorithm(): string; ``` -------------------------------- ### JWSRegisteredHeaders.jwkSetURL() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/jwtSetURL.md Defines the jwkSetURL function which returns the 'jku' parameter value as a string. It throws an error if the parameter is missing or not a string. ```ts function jwkSetURL(): string; ``` -------------------------------- ### JWSRegisteredHeaders Methods Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/index.md Provides access to various registered JWS header parameters as defined in RFC 7515. These methods allow retrieval and checking for the presence of parameters like algorithm, key ID, JWK, certificate information, and more. ```APIDOC JWSRegisteredHeaders: constructor(header: object): this header: JSON-decoded JWS header object algorithm(): string | undefined Returns the 'alg' header parameter. critical(): string[] | undefined Returns the 'crit' header parameter. hasAlgorithm(): boolean Checks if the 'alg' header parameter is present. hasCritical(): boolean Checks if the 'crit' header parameter is present. hasJWK(): boolean Checks if the 'jwk' header parameter is present. hasJWKSetURL(): boolean Checks if the 'jku' header parameter is present. hasKeyId(): boolean Checks if the 'kid' header parameter is present. hasType(): boolean Checks if the 'typ' header parameter is present. hasX509CertificateChain(): boolean Checks if the 'x5c' header parameter is present. hasX509CertificateSHA1Thumbprint(): boolean Checks if the 'x5t' header parameter is present. hasX509CertificateSHA256Thumbprint(): boolean Checks if the 'x5t#S256' header parameter is present. hasX509URL(): boolean Checks if the 'x5u' header parameter is present. jwk(): object | undefined Returns the 'jwk' header parameter. jwkSetURL(): string | undefined Returns the 'jku' header parameter. keyId(): string | undefined Returns the 'kid' header parameter. type(): string | undefined Returns the 'typ' header parameter. x509CertificateChain(): string[] | undefined Returns the 'x5c' header parameter. x509CertificateSHA1Thumbprint(): string | undefined Returns the 'x5t' header parameter. x509CertificateSHA256Thumbprint(): string | undefined Returns the 'x5t#S256' header parameter. x509URL(): string | undefined Returns the 'x5u' header parameter. ``` -------------------------------- ### encodeJWT() Function Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/encodeJWT.md Encodes a header object, payload object, and signature into a JSON web token. This function takes the header, payload, and signature as input and returns the JWT as a string. ```ts function encodeJWT(header: object, payload: object, signature: Uint8Array): string; ``` -------------------------------- ### JWSRegisteredHeaders Constructor Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/index.md Initializes a new JWSRegisteredHeaders object with a given header object. The header object should be JSON-decoded. ```ts function constructor(header: object): this; ``` -------------------------------- ### JWT Encoding and Decoding Functions Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/index.md Provides functions for encoding and decoding JSON Web Tokens (JWTs). These functions are essential for securely transmitting information between parties as a JSON object. ```APIDOC decodeJWT() Decodes a JWT. Parameters: - token: The JWT string to decode. - options: Optional decoding options. Returns: - The decoded JWT payload and header. encodeJWT(payload: object, privateKey: string, options?: object) Encodes a JWT. Parameters: - payload: The data to include in the JWT payload. - privateKey: The private key used for signing the JWT. - options: Optional encoding options, such as algorithm and expiration. Returns: - The encoded JWT string. parseJWT(token: string, options?: object) Parses a JWT without verification. Parameters: - token: The JWT string to parse. - options: Optional parsing options. Returns: - The parsed JWT payload and header. ``` -------------------------------- ### Check for X509 URL Header Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasX509URL.md Determines if the 'x5u' header parameter is present in the JWSRegisteredHeaders object. It only checks for the presence of the parameter and does not validate its content. ```ts function hasX509URL(): hasX509URL; ``` -------------------------------- ### JWSRegisteredHeaders.keyId() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/keyId.md Returns the 'kid' parameter value from JWSRegisteredHeaders. It throws an Error if the parameter is missing or not a string. ```ts function keyId(): string; ``` -------------------------------- ### JWS Registered Headers Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/index.md Defines the standard registered header parameters for JSON Web Signatures (JWS), as specified by RFC 7515. ```APIDOC JWSRegisteredHeaders: alg: Algorithm Header Parameter jku: JWK Set URL Header Parameter kid: Key ID Header Parameter x5u: X.509 URL Header Parameter x5c: X.509 Certificate Chain Header Parameter x5t: X.509 Certificate SHA-1 Thumbprint Header Parameter x5t#S256: X.509 Certificate SHA-256 Thumbprint Header Parameter typ: Type Header Parameter cty: Content Type Header Parameter crit: Critical Header Parameter(s) ``` -------------------------------- ### JWT Registered Claims Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/index.md Defines the standard registered claims that can be included in a JWT payload, as specified by RFC 7519. ```APIDOC JWTRegisteredClaims: iss: Issuer claim sub: Subject claim aud: Audience claim exp: Expiration Time claim nbf: Not Before claim iat: Issued At claim jti: JWT ID claim ``` -------------------------------- ### JWSRegisteredHeaders.x509URL() Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/x509URL.md Returns the value of the 'x5u' parameter from JWS registered headers. It throws an Error if the parameter does not exist or if its value is not a string. Note that this method does not perform validation to check if the value is a well-formed URI. ```typescript function x509URL(): string; ``` -------------------------------- ### Verify JWT Token Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/guides/verify-tokens.md Parses a JWT token, verifies its signature using HMAC SHA256, and validates expiration and not-before claims. Requires the JWT string and a crypto key. ```ts import { parseJWT, JWSRegisteredHeaders, JWTRegisteredClaims } from "@oslojs/jwt"; const [header, payload, signature, signatureMessage] = parseJWT(jwt); const headerParameters = new JWSRegisteredHeaders(header); if (headerParameters.algorithm() !== joseAlgorithmHS256) { throw new Error("Unsupported algorithm"); } const validSignature = await crypto.subtle.verify("HMAC", key, signature, signatureMessage); if (!validSignature) { throw new Error("Invalid signature"); } const claims = new JWTRegisteredClaims(payload); if (claims.hasExpiration() && !claims.verifyExpiration()) { throw new Error("Expired token"); } if (claims.hasNotBefore() && !claims.verifyNotBefore()) { throw new Error("Invalid token"); } ``` -------------------------------- ### Parse and Validate JWT Source: https://github.com/oslo-project/jwt/blob/main/README.md Parses a JWT string, extracts header, payload, and signature. It then validates the JWT header to ensure a supported algorithm (HS256) is used and verifies the JWT claims, including expiration and not-before dates. ```typescript import { parseJWT, JWSRegisteredHeaders, JWTRegisteredClaims, joseAlgorithmHS256 } from "@oslojs/jwt"; const [header, payload, signature] = parseJWT(jwt); const headerParameters = new JWSRegisteredHeaders(header); if (headerParameters.algorithm() !== joseAlgorithmHS256) { throw new Error("Unsupported algorithm"); } const claims = new JWTRegisteredClaims(payload); if (!claims.verifyExpiration()) { throw new Error("Expired token"); } if (claims.hasNotBefore() && !claims.verifyNotBefore()) { throw new Error("Invalid token"); } ``` -------------------------------- ### parseJWT() Function Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/parseJWT.md Defines the parseJWT function, which takes a JWT string as input and returns its header, payload, and signature. It throws an error for malformed tokens but does not validate claims or signatures. ```ts function parseJWT(jwt: string): [header: object, payload: header, signature: Uint8Array]; // Parameters: // jwt: The JSON web token string to parse. ``` -------------------------------- ### JWTRegisteredClaims.notBefore() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/notBefore.md Defines the `notBefore` function which returns the 'nbf' claim as a Date object. It handles potential errors if the claim is missing or invalid. ```ts function notBefore(): Date; ``` -------------------------------- ### JWSRegisteredHeaders.jwk() Method Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/jwk.md Returns the value of the 'jwk' parameter from JWSRegisteredHeaders. It validates that the parameter exists and its value is a string, otherwise it throws an error. ```ts function jwk(): string; ``` -------------------------------- ### Check for 'typ' parameter existence Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasType.md This TypeScript function checks if the 'typ' parameter is present within the JWSRegisteredHeaders object. It returns a boolean indicating existence and does not validate the value of the 'typ' parameter. ```ts function hasType(): boolean; ``` -------------------------------- ### JWSRegisteredHeaders.x509CertificateSHA256Thumbprint() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/x509CertificateSHA256Thumbprint.md This TypeScript function, `x509CertificateSHA256Thumbprint()`, is part of the JWSRegisteredHeaders class. It is designed to retrieve the `x5t#S256` parameter from a JWS header and return it as a `Uint8Array`. The function will throw an error if the `x5t#S256` parameter is missing or if its value is not a valid base64url encoded string. This method is crucial for applications that need to access cryptographic information embedded within JSON Web Signatures. ```typescript function x509CertificateSHA256Thumbprint(): Uint8Array; ``` -------------------------------- ### Verify Not Before Time Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/verifyNotBefore.md Checks if the current time is after or equal to the JWT's 'not-before' timestamp. It requires the 'nbf' claim to be present and be a positive integer. Returns true if the condition is met, otherwise throws an error. ```ts function verifyNotBefore(): boolean; ``` -------------------------------- ### JWSRegisteredHeaders.type() Function Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/type.md Retrieves the 'typ' parameter from JWSRegisteredHeaders. This function returns the value of the 'typ' parameter as a string. It will throw an Error if the parameter is missing or if its value is not a string. ```ts function type(): string; ``` -------------------------------- ### Check for X509 Certificate SHA1 Thumbprint Header Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasX509CertificateSHA1Thumbprint.md This function checks for the existence of the 'x5t' parameter within the JWT registered headers. It returns a boolean value indicating presence but does not perform validation on the parameter's content. This is useful for quickly determining if X.509 certificate thumbprint information is included in the JWT. ```typescript function hasX509CertificateSHA1Thumbprint(): boolean { // Implementation details would go here to check for the 'x5t' parameter // For example: // return this.has('x5t'); return true; // Placeholder for actual implementation } ``` -------------------------------- ### JWTRegisteredClaims.subject() Function Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/subject.md This function retrieves the 'sub' (subject) claim from a JWT. It is designed to throw an error if the 'sub' parameter is missing or if its value is not a string, ensuring data integrity. ```ts function subject(): string; ``` -------------------------------- ### HS256 JOSE Algorithm ID Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/joseAlgorithmHS256.md Defines the JOSE algorithm ID for HS256, which is registered on IANA. This is a constant string value. ```ts const joseAlgorithmHS256 = "HS256"; ``` -------------------------------- ### Check for Not Before Claim Existence Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/hasNotBefore.md This TypeScript function checks if the 'nbf' (not before) registered claim is present in a JWT. It returns a boolean indicating presence but does not validate the claim's value. ```ts function hasNotBefore(): boolean; ``` -------------------------------- ### Check for JWK Set URL Parameter Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasJWKSetURL.md Determines if the 'jku' (JWK Set URL) parameter is present in the JWSRegisteredHeaders object. This method only verifies the existence of the parameter and does not validate its content. ```ts function hasJWKSetURL(): boolean; ``` -------------------------------- ### Check for X.509 Certificate SHA-256 Thumbprint Header Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasX509CertificateSHA256Thumbprint.md This TypeScript function checks if the 'x5t#S256' parameter is present in the JWT registered headers. It does not validate the format or content of the parameter's value. ```typescript function hasX509CertificateSHA256Thumbprint(): boolean; // Returns true if the x5t#S256 parameter exists. ``` -------------------------------- ### JWTExpirationClaim Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/expiration.md Retrieves the JWT expiration claim and converts it into a JavaScript Date object. This function expects the 'exp' claim to be present and to be a positive integer. If these conditions are not met, it will throw an error. ```ts function expiration(): Date; ``` -------------------------------- ### decodeJWT() Function Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/decodeJWT.md Parses and returns the payload of a JWT token. This function does not validate the token's header, signature, or payload claims like expiration. It takes a JWT string as input and returns the decoded payload as an object. ```ts function decodeJWT(jwt: string): object; ``` -------------------------------- ### ES256 JOSE Algorithm ID Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/joseAlgorithmES256.md Defines the JOSE algorithm ID for ES256, which is registered on IANA. This constant is used to specify the Elliptic Curve Digital Signature Algorithm with SHA-256. ```ts const joseAlgorithmES256 = "ES256"; ``` -------------------------------- ### Check for X.509 Certificate Chain Header Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasX509CertificateChain.md This function checks if the 'x5c' parameter is present in the JWT registered headers. It does not validate the content or format of the 'x5c' value. ```ts function hasType(): hasX509CertificateChain; ``` -------------------------------- ### RS256 JOSE Algorithm ID Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/joseAlgorithmRS256.md Defines the JOSE algorithm ID for RS256, which is registered on IANA. This constant is used to specify the signing algorithm in JOSE (JSON Object Signing and Encryption) operations. ```typescript const joseAlgorithmRS256 = "RS256"; ``` -------------------------------- ### Check for Key ID in JWS Registered Headers Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasKeyId.md This function returns true if the 'kid' parameter is present in the JWS registered headers. It does not validate the value of the 'kid' parameter. ```ts function hasKeyId(): boolean; ``` -------------------------------- ### JWTRegisteredClaims.verifyExpiration() Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/verifyExpiration.md Verifies if the current time is before the JWT's expiration time. It returns true if the JWT has not expired. An error is thrown if the 'exp' parameter is missing or not a positive integer. ```ts function verifyExpiration(): boolean; ``` -------------------------------- ### Check for JWK Parameter Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasJWK.md Determines if the 'jwk' parameter is present in the JWSRegisteredHeaders object. This method only verifies the existence of the parameter and not its validity. ```ts function hasJWK(): boolean; ``` -------------------------------- ### JWTRegisteredClaims.jwtId() Function Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/jwtId.md This TypeScript function, `jwtId()`, is part of the JWTRegisteredClaims class. It is designed to retrieve the value of the 'jti' (JWT ID) claim from a JSON Web Token. The function is expected to return a string representing the JWT ID. It includes error handling to throw an error if the 'jti' parameter is missing or if its value is not a string. ```ts function jwtId(): string; ``` -------------------------------- ### JWSRegisteredHeaders.critical() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/critical.md Returns the 'crit' parameter value from JWT headers. Throws an Error if the parameter doesn't exist, the value isn't an array of strings, or the value is an empty array. ```ts function critical(): string[] ``` -------------------------------- ### Check for Subject Claim Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/hasSubject.md Determines if the 'sub' parameter is present in the JWT registered claims. This method only verifies the existence of the parameter and not its validity. ```ts function hasSubject(): boolean; ``` -------------------------------- ### Check for Issued At Claim Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/hasIssuedAt.md This TypeScript function checks if the 'iat' (issued at) claim is present in the JWT registered claims. It returns a boolean value indicating the presence of the claim, but does not validate the claim's value. ```ts function hasIssuedAt(): boolean; ``` -------------------------------- ### JWTRegisteredClaims.hasAudiences() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/hasAudiences.md This TypeScript function, `hasAudiences()`, returns a boolean value indicating whether the 'alg' parameter is present in the JWT registered claims. It does not validate the value of the parameter. ```ts function hasAudiences(): boolean; ``` -------------------------------- ### Check for Expiration Claim Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/hasExpiration.md This function checks if the 'exp' (expiration time) registered claim is present in the JWT. It returns a boolean indicating presence but does not validate the actual expiration time. ```ts function hasExpiration(): boolean; ``` -------------------------------- ### Check for Issuer Claim Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/hasIssuer.md This TypeScript function checks if the 'iss' (issuer) registered claim exists within the JWT claims. It returns a boolean value indicating presence but does not validate the claim's content. ```ts function hasIssuer(): boolean; ``` -------------------------------- ### JWSRegisteredHeaders.hasCritical() Definition Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWSRegisteredHeaders/hasCritical.md Defines the hasCritical function which returns a boolean indicating the presence of the 'crit' parameter. It does not validate the parameter's value. ```ts function hasCritical(): boolean; ``` -------------------------------- ### Check for JWT ID (jti) Claim Source: https://github.com/oslo-project/jwt/blob/main/docs/pages/reference/main/JWTRegisteredClaims/hasJWTId.md This TypeScript function checks if the 'jti' (JWT ID) registered claim is present in the JWT. It returns a boolean value indicating presence but does not validate the claim's content. ```ts function hasJWTId(): boolean; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.