Skip to content

Commit

Permalink
docs: add various exported symbol descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Feb 23, 2025
1 parent adcad33 commit f52c2ff
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/jwe/general/encrypt/interfaces/Recipient.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Used to build General JWE object's individual recipients.

## Methods

### addRecipient()
Expand Down
2 changes: 2 additions & 0 deletions docs/jws/general/sign/interfaces/Signature.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Used to build General JWS object's individual signatures.

## Methods

### addSignature()
Expand Down
2 changes: 2 additions & 0 deletions docs/jwt/unsecured/interfaces/UnsecuredResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Result of decoding an Unsecured JWT.

## Type Parameters

| Type Parameter | Default type |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Asymmetric key pair generation function options.

## Properties

### crv?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Asymmetric key pair generation function result.

## Properties

### privateKey
Expand Down
2 changes: 2 additions & 0 deletions docs/key/generate_secret/interfaces/GenerateSecretOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Secret generation function options.

## Properties

### extractable?
Expand Down
2 changes: 2 additions & 0 deletions docs/key/import/interfaces/KeyImportOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Key Import Function options.

## Properties

### extractable?
Expand Down
2 changes: 1 addition & 1 deletion docs/types/interfaces/FlattenedJWE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Flattened JWE definition.
Flattened JWE JSON Serialization Syntax token.

## Properties

Expand Down
4 changes: 2 additions & 2 deletions docs/types/interfaces/FlattenedJWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

Flattened JWS definition. Payload is returned as an empty string when JWS Unencoded Payload
([RFC7797](https://www.rfc-editor.org/rfc/rfc7797)) is used.
Flattened JWS JSON Serialization Syntax token. Payload is returned as an empty string when JWS
Unencoded Payload ([RFC7797](https://www.rfc-editor.org/rfc/rfc7797)) is used.

## Properties

Expand Down
2 changes: 2 additions & 0 deletions docs/types/interfaces/GeneralJWE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

General JWE JSON Serialization Syntax token.

## Properties

### ciphertext
Expand Down
4 changes: 2 additions & 2 deletions docs/types/interfaces/GeneralJWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

General JWS definition. Payload is returned as an empty string when JWS Unencoded Payload
([RFC7797](https://www.rfc-editor.org/rfc/rfc7797)) is used.
General JWS JSON Serialization Syntax token. Payload is returned as an empty string when JWS
Unencoded Payload ([RFC7797](https://www.rfc-editor.org/rfc/rfc7797)) is used.

## Properties

Expand Down
2 changes: 2 additions & 0 deletions docs/types/interfaces/ResolvedKey.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by [becoming a sponsor](https://github.com/sponsors/panva).

When key resolver functions are used this becomes part of successful resolves

## Properties

### key
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@ export type {
VerifyOptions,
} from './types.d.ts'

/**
* In prior releases this indicated whether a Node.js-specific build was loaded, this is now fixed
* to `"WebCryptoAPI"`
*
* @deprecated
*/
export const cryptoRuntime = 'WebCryptoAPI'
1 change: 1 addition & 0 deletions src/jwe/general/encrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import validateCrit from '../../lib/validate_crit.js'
import normalizeKey from '../../lib/normalize_key.js'
import checkKeyType from '../../lib/check_key_type.js'

/** Used to build General JWE object's individual recipients. */
export interface Recipient {
/**
* Sets the JWE Per-Recipient Unprotected Header on the Recipient object.
Expand Down
1 change: 1 addition & 0 deletions src/jws/general/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type * as types from '../../types.d.ts'
import { FlattenedSign } from '../flattened/sign.js'
import { JWSInvalid } from '../../util/errors.js'

/** Used to build General JWS object's individual signatures. */
export interface Signature {
/**
* Sets the JWS Protected Header on the Signature object.
Expand Down
1 change: 1 addition & 0 deletions src/jwt/unsecured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { JWTInvalid } from '../util/errors.js'
import jwtPayload from '../lib/jwt_claims_set.js'
import { ProduceJWT } from './produce.js'

/** Result of decoding an Unsecured JWT. */
export interface UnsecuredResult<PayloadType = types.JWTPayload> {
payload: PayloadType & types.JWTPayload
header: types.JWSHeaderParameters
Expand Down
2 changes: 2 additions & 0 deletions src/key/generate_key_pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { JOSENotSupported } from '../util/errors.js'

import type * as types from '../types.d.ts'

/** Asymmetric key pair generation function result. */
export interface GenerateKeyPairResult {
/** The generated Private Key. */
privateKey: types.CryptoKey
Expand All @@ -16,6 +17,7 @@ export interface GenerateKeyPairResult {
publicKey: types.CryptoKey
}

/** Asymmetric key pair generation function options. */
export interface GenerateKeyPairOptions {
/**
* The EC "crv" (Curve) or OKP "crv" (Subtype of Key Pair) value to generate. The curve must be
Expand Down
1 change: 1 addition & 0 deletions src/key/generate_secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { JOSENotSupported } from '../util/errors.js'

import type * as types from '../types.d.ts'

/** Secret generation function options. */
export interface GenerateSecretOptions {
/** The value to use as {@link !SubtleCrypto.generateKey} `extractable` argument. Default is false. */
extractable?: boolean
Expand Down
1 change: 1 addition & 0 deletions src/key/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { JOSENotSupported } from '../util/errors.js'
import isObject from '../lib/is_object.js'
import type * as types from '../types.d.ts'

/** Key Import Function options. */
export interface KeyImportOptions {
/**
* The value to use as {@link !SubtleCrypto.importKey} `extractable` argument. Default is false for
Expand Down
2 changes: 2 additions & 0 deletions src/lib/base64url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function encodeBase64(input: Uint8Array): string {
return btoa(arr.join(''))
}

/** Encodes an input using Base64URL with no padding. */
export function encode(input: Uint8Array | string): string {
let unencoded = input
if (typeof unencoded === 'string') {
Expand Down Expand Up @@ -46,6 +47,7 @@ export function decodeBase64(encoded: string): Uint8Array {
return bytes
}

/** Decodes a Base64URL encoded input. */
export function decode(input: Uint8Array | string): Uint8Array {
// @ts-ignore
if (Uint8Array.fromBase64) {
Expand Down
12 changes: 7 additions & 5 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ export interface GeneralJWSInput {
}

/**
* Flattened JWS definition. Payload is returned as an empty string when JWS Unencoded Payload
* ({@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}) is used.
* Flattened JWS JSON Serialization Syntax token. Payload is returned as an empty string when JWS
* Unencoded Payload ({@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}) is used.
*/
export interface FlattenedJWS extends Partial<FlattenedJWSInput> {
payload: string
signature: string
}

/**
* General JWS definition. Payload is returned as an empty string when JWS Unencoded Payload
* ({@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}) is used.
* General JWS JSON Serialization Syntax token. Payload is returned as an empty string when JWS
* Unencoded Payload ({@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}) is used.
*/
export interface GeneralJWS {
payload: string
Expand Down Expand Up @@ -307,7 +307,7 @@ export interface JWEKeyManagementHeaderParameters {
epk?: CryptoKey | KeyObject
}

/** Flattened JWE definition. */
/** Flattened JWE JSON Serialization Syntax token. */
export interface FlattenedJWE {
/**
* The "aad" member MUST be present and contain the value BASE64URL(JWE AAD)) when the JWE AAD
Expand Down Expand Up @@ -361,6 +361,7 @@ export interface FlattenedJWE {
unprotected?: JWEHeaderParameters
}

/** General JWE JSON Serialization Syntax token. */
export interface GeneralJWE extends Omit<FlattenedJWE, 'encrypted_key' | 'header'> {
recipients: Pick<FlattenedJWE, 'encrypted_key' | 'header'>[]
}
Expand Down Expand Up @@ -647,6 +648,7 @@ export interface JWTDecryptResult<PayloadType = JWTPayload> {
protectedHeader: CompactJWEHeaderParameters
}

/** When key resolver functions are used this becomes part of successful resolves */
export interface ResolvedKey {
/** Key resolved from the key resolver function. */
key: CryptoKey | Uint8Array
Expand Down

0 comments on commit f52c2ff

Please sign in to comment.