@odudu-io/oidc 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/LICENSE +202 -0
- package/README.md +51 -2
- package/dist/index.d.ts +167 -0
- package/dist/index.js +891 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapter/discovery.ts","../src/services/odudu-error.ts","../src/services/discovery-cache.ts","../src/repository/metadata.ts","../src/use-cases/discover.ts","../src/adapter/authorize.ts","../src/services/sign-in-request.ts","../src/repository/authorization-request.ts","../src/use-cases/begin-sign-in.ts","../src/adapter/token-exchange.ts","../src/adapter/client-authentication.ts","../src/adapter/client-assertion.ts","../src/services/client-credentials-request.ts","../src/adapter/token-failure.ts","../src/adapter/bounded-body.ts","../src/services/token-set.ts","../src/repository/code-exchange.ts","../src/services/callback.ts","../src/use-cases/complete-sign-in.ts","../src/adapter/refresh.ts","../src/services/refresh-request.ts","../src/services/single-flight.ts","../src/repository/refresh.ts","../src/use-cases/refresh.ts","../src/use-cases/request-audience.ts","../src/adapter/client-credentials.ts","../src/repository/client-credentials.ts","../src/use-cases/client-credentials.ts","../src/repository/client-assertion.ts","../src/use-cases/sign-client-assertion.ts","../src/services/token-renewer.ts","../src/use-cases/token-source.ts","../src/services/sign-out-request.ts","../src/use-cases/sign-out-url.ts"],"sourcesContent":["import * as oauth from 'oauth4webapi';\nimport { OduduError } from '#/services/odudu-error';\nimport type { Deps, ServerMetadata } from '#/types';\n\ntype CustomFetch = (\n url: string,\n options: oauth.CustomFetchOptions<string, RequestInit['body']>,\n) => Promise<Response>;\n\n// Hands the library's request to the caller's `fetch` member by member, which\n// keeps an absent body or signal absent rather than present and undefined.\nfunction throughFetch(fetcher: typeof fetch): CustomFetch {\n return (url, options) =>\n fetcher(url, {\n method: options.method,\n headers: options.headers,\n redirect: options.redirect,\n ...(options.body === undefined ? {} : { body: options.body }),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n });\n}\n\n// The longest any one request may take, headers and body together. A refresh\n// holds a lock in a shared session store for a bounded time because of it.\nexport const REQUEST_TIMEOUT_MS = 30_000;\n\n// The options every oauth4webapi request here takes.\nexport function requestOptions(deps: Deps): {\n signal: () => AbortSignal;\n [oauth.customFetch]?: CustomFetch;\n [oauth.allowInsecureRequests]?: boolean;\n} {\n return {\n signal: () => AbortSignal.timeout(REQUEST_TIMEOUT_MS),\n ...(deps.fetch === undefined ? {} : { [oauth.customFetch]: throughFetch(deps.fetch) }),\n ...(deps.allowInsecureRequests === true ? { [oauth.allowInsecureRequests]: true } : {}),\n };\n}\n\nexport async function fetchMetadata(issuer: string, deps: Deps): Promise<ServerMetadata> {\n try {\n const url = new URL(issuer);\n const response = await oauth.discoveryRequest(url, {\n algorithm: 'oidc',\n ...requestOptions(deps),\n });\n const metadata = await oauth.processDiscoveryResponse(url, response);\n // The library compares parsed addresses, which equates `https://id.example`\n // with `https://id.example/`; every later `iss` check compares the string.\n if (metadata.issuer !== issuer) throw new Error('the metadata spells the issuer differently');\n return metadata;\n } catch (cause) {\n throw new OduduError('discovery_failed', `could not read the metadata of ${issuer}`, { cause });\n }\n}\n","// Codes an authorization server answers with (RFC 6749, RFC 8707, OIDC Core\n// section 3.1.2.6).\nconst OAUTH_CODES = [\n 'invalid_request',\n 'invalid_client',\n 'invalid_grant',\n 'unauthorized_client',\n 'unsupported_grant_type',\n 'unsupported_response_type',\n 'invalid_scope',\n 'invalid_target',\n 'access_denied',\n 'server_error',\n 'temporarily_unavailable',\n 'login_required',\n 'consent_required',\n 'interaction_required',\n 'account_selection_required',\n] as const;\n\n// Codes the core raises on its own account.\ntype LocalCode =\n | 'invalid_options'\n | 'audience_not_granted'\n | 'discovery_failed'\n | 'invalid_state'\n | 'invalid_issuer'\n | 'invalid_callback'\n | 'invalid_id_token'\n | 'request_failed'\n | 'unrecognized_error';\n\nexport type OduduErrorCode = (typeof OAUTH_CODES)[number] | LocalCode;\n\nexport interface OduduErrorDetail {\n // The server's own `error` and `error_description`, when it sent them.\n error?: string;\n errorDescription?: string;\n cause?: unknown;\n}\n\nexport class OduduError extends Error {\n readonly code: OduduErrorCode;\n readonly error: string | undefined;\n readonly errorDescription: string | undefined;\n\n constructor(code: OduduErrorCode, message: string, detail: OduduErrorDetail = {}) {\n super(message, detail.cause === undefined ? undefined : { cause: detail.cause });\n this.name = 'OduduError';\n this.code = code;\n this.error = detail.error;\n this.errorDescription = detail.errorDescription;\n }\n}\n\nfunction isOauthCode(value: string): value is (typeof OAUTH_CODES)[number] {\n return (OAUTH_CODES as readonly string[]).includes(value);\n}\n\n// An error the server named, with the server's words kept and its code\n// narrowed to the closed set.\nexport function fromServerError(\n error: string,\n errorDescription: string | undefined,\n message: string,\n): OduduError {\n const code = isOauthCode(error) ? error : 'unrecognized_error';\n return new OduduError(code, message, {\n error,\n ...(errorDescription === undefined ? {} : { errorDescription }),\n });\n}\n","import type { ServerMetadata } from '#/types';\n\nexport const MAX_ISSUERS = 256;\nexport const TTL_MS = 60 * 60 * 1000;\n\ninterface Entry {\n expiresAt: number;\n metadata: Promise<ServerMetadata>;\n}\n\n// A bounded, expiring map of discovery results by key. A `Map` iterates in\n// insertion order, so the oldest entry is the first key. An entry holds the\n// request while it is in flight, so concurrent callers share one fetch.\nexport class DiscoveryCache {\n private readonly entries = new Map<string, Entry>();\n\n get(key: string, now: number): Promise<ServerMetadata> | undefined {\n const entry = this.entries.get(key);\n if (entry === undefined) return undefined;\n if (entry.expiresAt <= now) {\n this.entries.delete(key);\n return undefined;\n }\n return entry.metadata;\n }\n\n set(key: string, metadata: Promise<ServerMetadata>, now: number): void {\n this.entries.delete(key);\n this.entries.set(key, { expiresAt: now + TTL_MS, metadata });\n const oldest = this.entries.keys().next();\n if (this.entries.size > MAX_ISSUERS && oldest.done !== true) this.entries.delete(oldest.value);\n }\n\n // Forget a request that failed, if it is still the one held.\n drop(key: string, metadata: Promise<ServerMetadata>): void {\n if (this.entries.get(key)?.metadata === metadata) this.entries.delete(key);\n }\n}\n","import { fetchMetadata } from '#/adapter/discovery';\nimport { DiscoveryCache } from '#/services/discovery-cache';\nimport type { Deps, ServerMetadata } from '#/types';\n\nconst cache = new DiscoveryCache();\n\n// An issuer's metadata, from the cache while it is fresh and from the issuer\n// otherwise. A request that fails is not kept. The cache is shared by every\n// caller in the process. A result fetched with `allowInsecureRequests` is\n// kept apart, so a caller that did not ask for it never receives it; a result\n// fetched through a custom `fetch` is not, so callers that use different\n// `fetch` members for one issuer share what the first one read.\nexport function readMetadata(issuer: string, deps: Deps): Promise<ServerMetadata> {\n const key = `${deps.allowInsecureRequests === true ? 'insecure:' : ''}${issuer}`;\n const now = (deps.now ?? Date.now)();\n const cached = cache.get(key, now);\n if (cached !== undefined) return cached;\n const request = fetchMetadata(issuer, deps);\n cache.set(key, request, now);\n request.catch(() => {\n cache.drop(key, request);\n });\n return request;\n}\n","import { readMetadata } from '#/repository/metadata';\nimport type { Deps, ServerMetadata } from '#/types';\n\n// Reads an issuer's metadata, checks that it names the issuer asked for (RFC\n// 8414 section 3.3) and keeps it for an hour. The cache holds at most 256\n// issuers, so a process serving every tenant of a large deployment stays\n// bounded.\nexport function discover(issuer: string, deps: Deps = {}): Promise<ServerMetadata> {\n return readMetadata(issuer, deps);\n}\n","import * as oauth from 'oauth4webapi';\nimport { OduduError } from '#/services/odudu-error';\nimport type { ServerMetadata, SignInOptions } from '#/types';\n\nexport interface Secrets {\n state: string;\n nonce: string;\n codeVerifier: string;\n}\n\nexport function newSecrets(): Secrets {\n return {\n state: oauth.generateRandomState(),\n nonce: oauth.generateRandomNonce(),\n codeVerifier: oauth.generateRandomCodeVerifier(),\n };\n}\n\n// The authorization request. It sends no `login_hint`: Odudu ignores it.\nexport async function authorizationUrl(\n metadata: ServerMetadata,\n options: SignInOptions,\n secrets: Secrets,\n scope: string,\n resources: string[],\n silent: boolean,\n): Promise<string> {\n if (metadata.authorization_endpoint === undefined) {\n throw new OduduError('discovery_failed', 'the metadata names no authorization endpoint');\n }\n const url = new URL(metadata.authorization_endpoint);\n const params = url.searchParams;\n params.set('response_type', 'code');\n params.set('client_id', options.clientId);\n params.set('redirect_uri', options.redirectUri);\n params.set('scope', scope);\n params.set('code_challenge', await oauth.calculatePKCECodeChallenge(secrets.codeVerifier));\n params.set('code_challenge_method', 'S256');\n params.set('state', secrets.state);\n params.set('nonce', secrets.nonce);\n for (const resource of resources) params.append('resource', resource);\n if (options.prompt !== undefined) params.set('prompt', options.prompt);\n if (silent) params.set('prompt', 'none');\n if (options.action !== undefined) params.set('action', options.action);\n return url.href;\n}\n","import { OduduError } from '#/services/odudu-error';\nimport type { AudienceRequest, SignInOptions } from '#/types';\n\nconst ME_READ = 'me:read';\nconst ME_WRITE = 'me:write';\n\nexport function meResource(issuer: string): string {\n return `${issuer.replace(/\\/+$/u, '')}/me`;\n}\n\nexport function refuseConflictingOptions(options: SignInOptions): void {\n // The type forbids both; a caller without the types can still send both.\n const { prompt, action } = options as { prompt?: string; action?: string };\n if (prompt !== undefined && action !== undefined) {\n throw new OduduError(\n 'invalid_options',\n 'prompt and action cannot be combined: a sign-in starts at one or the other',\n );\n }\n}\n\n// `openid` is always asked for: without it there is no ID token to check.\nexport function scopeOf(options: SignInOptions): string {\n const scopes = new Set(['openid', ...options.scope.split(/\\s+/u).filter((s) => s !== '')]);\n if (options.meAccess !== undefined) scopes.add(ME_READ);\n if (options.meAccess === 'write') scopes.add(ME_WRITE);\n return [...scopes].join(' ');\n}\n\nexport function resourcesOf(options: SignInOptions): string[] {\n const resources = new Set(options.resource ?? []);\n if (options.meAccess !== undefined) resources.add(meResource(options.issuer));\n return [...resources];\n}\n\nexport function idTokenAlgOf(options: { idTokenAlg?: 'RS256' | 'ES256' }): 'RS256' | 'ES256' {\n return options.idTokenAlg ?? 'RS256';\n}\n\n// A request for one more audience is a sign-in for that audience alone. The\n// me audience needs its own scope, which meAccess adds.\nexport function audienceSignIn(request: AudienceRequest): SignInOptions {\n const { issuer, clientId, redirectUri, scope, resource, idTokenAlg } = request;\n return {\n issuer,\n clientId,\n redirectUri,\n scope,\n ...(idTokenAlg === undefined ? {} : { idTokenAlg }),\n resource: [resource],\n ...(resource === meResource(request.issuer) ? { meAccess: 'read' as const } : {}),\n };\n}\n","import { authorizationUrl, newSecrets } from '#/adapter/authorize';\nimport { idTokenAlgOf, resourcesOf, scopeOf } from '#/services/sign-in-request';\nimport type { Pending, ServerMetadata, SignInOptions } from '#/types';\n\nexport async function buildAuthorizationRequest(\n metadata: ServerMetadata,\n given: SignInOptions,\n silent = false,\n): Promise<{ url: string; pending: Pending }> {\n // The PKCE challenge is awaited, so the options are copied once, here, arrays included: the\n // address and the record then agree whatever the caller does meanwhile.\n const options = structuredClone(given);\n const secrets = newSecrets();\n const resources = resourcesOf(options);\n const url = await authorizationUrl(\n metadata,\n options,\n secrets,\n scopeOf(options),\n resources,\n silent,\n );\n return {\n url,\n pending: {\n issuer: options.issuer,\n clientId: options.clientId,\n redirectUri: options.redirectUri,\n ...secrets,\n resources,\n idTokenAlg: idTokenAlgOf(options),\n },\n };\n}\n","import { buildAuthorizationRequest } from '#/repository/authorization-request';\nimport { refuseConflictingOptions } from '#/services/sign-in-request';\nimport { discover } from '#/use-cases/discover';\nimport type { Deps, Pending, SignInOptions } from '#/types';\n\n// Starts a sign-in: the address to send the person to, and the record\n// completeSignIn needs when they come back. The core keeps nothing.\nexport async function beginSignIn(\n options: SignInOptions,\n deps: Deps = {},\n): Promise<{ url: string; pending: Pending }> {\n refuseConflictingOptions(options);\n return buildAuthorizationRequest(await discover(options.issuer, deps), options);\n}\n","import * as oauth from 'oauth4webapi';\nimport { clientAuthentication } from '#/adapter/client-authentication';\nimport { requestOptions } from '#/adapter/discovery';\nimport { tokenFailure } from '#/adapter/token-failure';\nimport { OduduError } from '#/services/odudu-error';\nimport type { ClientAuth, Deps, IdTokenClaims, Pending, ServerMetadata } from '#/types';\n\ninterface Exchanged {\n response: oauth.TokenEndpointResponse;\n claims: IdTokenClaims;\n}\n\n// Exchanges the code and checks the ID token the server returns: issuer,\n// audience, `azp`, expiry and nonce. Its signature is not checked: the token\n// comes straight from the token endpoint over TLS, which OIDC Core section\n// 3.1.3.7 accepts in place of a signature check.\nexport async function exchangeCode(\n metadata: ServerMetadata,\n params: URLSearchParams,\n pending: Pending,\n deps: Deps,\n auth?: ClientAuth,\n): Promise<Exchanged> {\n const client: oauth.Client = {\n client_id: pending.clientId,\n id_token_signed_response_alg: pending.idTokenAlg,\n };\n const options = requestOptions(deps);\n try {\n const response = await oauth.processAuthorizationCodeResponse(\n metadata,\n client,\n await oauth.authorizationCodeGrantRequest(\n metadata,\n client,\n clientAuthentication(auth, deps),\n // Only a value this library has validated is accepted for the exchange;\n // readCallback has already refused everything it would.\n oauth.validateAuthResponse(metadata, client, params, pending.state),\n pending.redirectUri,\n pending.codeVerifier,\n options,\n ),\n { expectedNonce: pending.nonce, requireIdToken: true, ...options },\n );\n const claims = oauth.getValidatedIdTokenClaims(response);\n if (claims === undefined)\n throw new OduduError('invalid_id_token', 'the response has no ID token');\n return { response, claims };\n } catch (cause) {\n throw cause instanceof OduduError\n ? cause\n : await tokenFailure(cause, 'the token endpoint refused the code');\n }\n}\n","import * as oauth from 'oauth4webapi';\nimport { signAssertion } from '#/adapter/client-assertion';\nimport { OduduError } from '#/services/odudu-error';\nimport { privateKeyOf } from '#/services/client-credentials-request';\nimport type { ClientAuth, Deps } from '#/types';\n\nconst ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';\n\n// How a request to the token endpoint proves the client. Without `auth` the\n// client is public and sends only its ID. A secret goes in the Authorization\n// header; a key signs an assertion for the token endpoint of the server the\n// request goes to.\nexport function clientAuthentication(auth: ClientAuth | undefined, deps: Deps): oauth.ClientAuth {\n if (auth === undefined) return oauth.None();\n const signing = privateKeyOf(auth);\n if (signing === undefined) return oauth.ClientSecretBasic(auth.secret ?? '');\n return async (metadata, client, body) => {\n const endpoint = metadata.token_endpoint;\n if (endpoint === undefined) {\n throw new OduduError('discovery_failed', 'the metadata names no token endpoint');\n }\n const now = Math.floor((deps.now ?? Date.now)() / 1000);\n body.set('client_id', client.client_id);\n body.set('client_assertion_type', ASSERTION_TYPE);\n body.set('client_assertion', await signAssertion(signing, client.client_id, endpoint, now));\n };\n}\n","import { importJWK, SignJWT } from 'jose';\nimport type { PrivateKeyJwk } from '#/types';\nimport { OduduError } from '#/services/odudu-error';\nimport { assertionAlgorithm, assertionClaims } from '#/services/client-credentials-request';\n\nexport interface AssertionKey {\n key: PrivateKeyJwk;\n kid?: string;\n alg?: string;\n}\n\n// Signs the JWT a client presents in place of a secret (RFC 7523, OIDC Core\n// section 9). It runs on WebCrypto, so it works in a browser, Node and an\n// edge runtime.\nexport async function signAssertion(\n signing: AssertionKey,\n clientId: string,\n tokenEndpoint: string,\n nowSeconds: number,\n): Promise<string> {\n const alg = assertionAlgorithm(signing.key, signing.alg);\n try {\n const key = await importJWK({ ...signing.key }, alg);\n return await new SignJWT(\n assertionClaims(clientId, tokenEndpoint, crypto.randomUUID(), nowSeconds),\n )\n .setProtectedHeader({ alg, ...(signing.kid === undefined ? {} : { kid: signing.kid }) })\n .sign(key);\n } catch (cause) {\n throw new OduduError('invalid_options', 'the private key cannot sign with that algorithm', {\n cause,\n });\n }\n}\n","import type { TokenEndpointResponse } from 'oauth4webapi';\nimport type { AudienceToken, ClientAuth, ClientCredentialsOptions, PrivateKeyJwk } from '#/types';\nimport { OduduError } from '#/services/odudu-error';\n\n// The server accepts an assertion that expires at most 300 s ahead\n// (MAX_ASSERTION_LIFETIME_SECONDS in packages/protocol-oidc). 120 s leaves room\n// for a service clock that runs behind the server's; one more than that behind\n// gets `invalid_client`.\nconst ASSERTION_LIFETIME_SECONDS = 120;\n\n// What a token is assumed to live when the response omits `expires_in`.\nexport const DEFAULT_LIFETIME_SECONDS = 60;\n\nfunction lifetimeSeconds(expiresIn: number | undefined): number {\n return expiresIn !== undefined && Number.isFinite(expiresIn) && expiresIn > 0\n ? expiresIn\n : DEFAULT_LIFETIME_SECONDS;\n}\n\n// The body of a token response with an `expires_in` the library would refuse\n// (not a number, or negative) removed; zero and the rest are left to\n// `lifetimeSeconds`.\nexport function withUsableLifetime(body: unknown): unknown {\n if (typeof body !== 'object' || body === null || !('expires_in' in body)) return body;\n const { expires_in: expiresIn, ...rest } = body;\n const parsed = typeof expiresIn === 'number' ? expiresIn : parseFloat(String(expiresIn));\n return Number.isFinite(parsed) && parsed >= 0 ? body : rest;\n}\n\n// The types already rule these out; a JavaScript caller is held to them here.\nexport function checkedOptions(options: ClientCredentialsOptions): ClientCredentialsOptions {\n const auth: { secret?: unknown; privateKey?: { kty?: unknown } } = options.auth;\n if (options.issuer === '' || options.clientId === '') {\n throw new OduduError('invalid_options', 'the issuer and the client ID are required');\n }\n if (auth.secret !== undefined && auth.privateKey !== undefined) {\n throw new OduduError('invalid_options', 'auth takes a secret or a private key, not both');\n }\n if (typeof auth.secret === 'string' && auth.secret !== '') return options;\n if (typeof auth.privateKey?.kty === 'string') return options;\n throw new OduduError(\n 'invalid_options',\n 'auth needs a non-empty secret or a private key in JWK form',\n );\n}\n\nexport function grantParameters(options: ClientCredentialsOptions): URLSearchParams {\n const parameters = new URLSearchParams();\n if (options.scope !== undefined) parameters.set('scope', options.scope);\n if (options.resource !== undefined) parameters.set('resource', options.resource);\n return parameters;\n}\n\n// The algorithm a key signs with when the caller names none.\nexport function assertionAlgorithm(key: PrivateKeyJwk, alg: string | undefined): string {\n if (alg !== undefined) return alg;\n const byCurve: Record<string, string> = { 'P-256': 'ES256', 'P-384': 'ES384', 'P-521': 'ES512' };\n if (key.kty === 'RSA') return 'RS256';\n const fromCurve = key.kty === 'EC' && key.crv !== undefined ? byCurve[key.crv] : undefined;\n if (fromCurve === undefined) {\n throw new OduduError(\n 'invalid_options',\n 'cannot tell which algorithm this key signs with: pass auth.alg',\n );\n }\n return fromCurve;\n}\n\n// OIDC Core section 9: `iss` and `sub` are the client, `aud` is the token\n// endpoint, which is what the server compares it to.\nexport function assertionClaims(\n clientId: string,\n tokenEndpoint: string,\n jti: string,\n nowSeconds: number,\n): Record<string, string | number> {\n return {\n iss: clientId,\n sub: clientId,\n aud: tokenEndpoint,\n jti,\n iat: nowSeconds,\n exp: nowSeconds + ASSERTION_LIFETIME_SECONDS,\n };\n}\n\nexport function privateKeyOf(\n auth: ClientAuth,\n): { key: PrivateKeyJwk; kid?: string; alg?: string } | undefined {\n return auth.privateKey === undefined\n ? undefined\n : {\n key: auth.privateKey,\n ...(auth.kid === undefined ? {} : { kid: auth.kid }),\n ...(auth.alg === undefined ? {} : { alg: auth.alg }),\n };\n}\n\n// A response without a usable `expires_in` (missing, not a number, zero or\n// negative) is taken to live 60 s, so a token is never stale on arrival.\n// A response without `scope` grants what was asked for (RFC 6749 section 5.1).\nexport function audienceTokenOf(\n response: TokenEndpointResponse,\n requestedScope: string | undefined,\n now: number,\n): AudienceToken {\n return {\n accessToken: response.access_token,\n expiresAt: now + lifetimeSeconds(response.expires_in) * 1000,\n scope: response.scope ?? requestedScope ?? '',\n };\n}\n","import * as oauth from 'oauth4webapi';\nimport { ERROR_BODY_LIMIT, readBoundedText } from '#/adapter/bounded-body';\nimport { fromServerError, OduduError } from '#/services/odudu-error';\n\n// A server that refuses the client's authentication answers 401 with a\n// challenge and, as RFC 6749 section 5.2 asks, an OAuth error body. The\n// library raises the challenge before it reads the body, so the body is read\n// here, never past ERROR_BODY_LIMIT bytes. A challenge with no readable OAuth\n// error is not echoed.\nasync function challengeRefusal(\n cause: oauth.WWWAuthenticateChallengeError,\n refusal: string,\n): Promise<OduduError | undefined> {\n const text = await readBoundedText(cause.response, ERROR_BODY_LIMIT);\n if (text === undefined) return undefined;\n let body: unknown;\n try {\n body = JSON.parse(text);\n } catch {\n return undefined;\n }\n if (typeof body !== 'object' || body === null || !('error' in body)) return undefined;\n if (typeof body.error !== 'string') return undefined;\n const description = 'error_description' in body ? body.error_description : undefined;\n return fromServerError(\n body.error,\n typeof description === 'string' ? description : undefined,\n refusal,\n );\n}\n\n// The library raises OperationProcessingError for a response that is not an\n// OAuth answer at all (a gateway's 502 page, a 429 with no body, a body that\n// is not JSON) as well as for an ID token that fails its checks. Only the\n// second says anything about the person's tokens.\nfunction isUnusableResponse(cause: oauth.OperationProcessingError): boolean {\n return cause.code === oauth.RESPONSE_IS_NOT_CONFORM || cause.code === oauth.RESPONSE_IS_NOT_JSON;\n}\n\n// What a token endpoint request that did not succeed means for the caller.\nexport async function tokenFailure(cause: unknown, refusal: string): Promise<OduduError> {\n if (cause instanceof oauth.ResponseBodyError) {\n return fromServerError(cause.error, cause.error_description, refusal);\n }\n if (cause instanceof oauth.WWWAuthenticateChallengeError) {\n const named = await challengeRefusal(cause, refusal);\n if (named !== undefined) return named;\n }\n if (cause instanceof oauth.OperationProcessingError && !isUnusableResponse(cause)) {\n return new OduduError('invalid_id_token', `the response was refused: ${cause.message}`, {\n cause,\n });\n }\n return new OduduError('request_failed', 'the token request did not complete', { cause });\n}\n","type Chunk = { done: true; value?: undefined } | { done: false; value: Uint8Array };\n\n// An OAuth error body is a few hundred bytes.\nexport const ERROR_BODY_LIMIT = 8192;\n\n// The body as UTF-8 text, or undefined when it is longer than `limit` bytes,\n// is not valid UTF-8, was read already or cannot be read. A declared length\n// over the limit is refused unread; otherwise the stream is cancelled the\n// moment the bytes counted pass the limit, so a server that never stops\n// sending costs at most the limit.\nexport async function readBoundedText(\n response: Response,\n limit: number,\n): Promise<string | undefined> {\n try {\n const declared = Number(response.headers.get('content-length'));\n if (Number.isFinite(declared) && declared > limit) {\n await response.body?.cancel();\n return undefined;\n }\n if (response.bodyUsed) return undefined;\n const reader = response.body?.getReader();\n if (reader === undefined) return '';\n const decoder = new TextDecoder('utf-8', { fatal: true });\n let text = '';\n let size = 0;\n for (;;) {\n const { done, value } = (await reader.read()) as Chunk;\n if (done) return text + decoder.decode();\n size += value.byteLength;\n if (size > limit) {\n await reader.cancel();\n return undefined;\n }\n text += decoder.decode(value, { stream: true });\n }\n } catch {\n return undefined;\n }\n}\n","import type { IDToken, TokenEndpointResponse } from 'oauth4webapi';\nimport { DEFAULT_LIFETIME_SECONDS } from '#/services/client-credentials-request';\nimport { OduduError } from '#/services/odudu-error';\nimport type { Pending, TokenSet } from '#/types';\n\n// When the access token of a code or refresh response expires. A response\n// without a lifetime is refused: reading it as zero would hand out a token\n// that is already stale.\nexport function expiresAtOf(response: TokenEndpointResponse, now: number): number {\n if (response.expires_in === undefined) {\n throw new OduduError('request_failed', 'the token response carries no expires_in');\n }\n return now + response.expires_in * 1000;\n}\n\n// A refresh response without a lifetime is read as a short one, not refused:\n// refusing it would throw away the rotated refresh token that the same\n// response carries, and the caller would be left holding a spent one.\nexport function refreshExpiresAtOf(response: TokenEndpointResponse, now: number): number {\n return now + (response.expires_in ?? DEFAULT_LIFETIME_SECONDS) * 1000;\n}\n\n// One token comes back from the token endpoint; it is filed under every\n// audience the sign-in asked for, or under the issuer when it named none.\nexport function tokenSetOf(\n response: TokenEndpointResponse,\n claims: IDToken,\n pending: Pending,\n now: number,\n): TokenSet {\n const audiences = pending.resources.length === 0 ? [pending.issuer] : pending.resources;\n const entry = {\n accessToken: response.access_token,\n expiresAt: expiresAtOf(response, now),\n scope: response.scope ?? '',\n };\n return {\n byAudience: Object.fromEntries(audiences.map((audience) => [audience, { ...entry }])),\n idToken: response.id_token ?? '',\n ...(response.refresh_token === undefined ? {} : { refreshToken: response.refresh_token }),\n claims,\n issuer: pending.issuer,\n clientId: pending.clientId,\n };\n}\n","import { exchangeCode } from '#/adapter/token-exchange';\nimport { tokenSetOf } from '#/services/token-set';\nimport type { ClientAuth, Deps, Pending, ServerMetadata, TokenSet } from '#/types';\n\nexport async function exchangeForTokens(\n metadata: ServerMetadata,\n params: URLSearchParams,\n pending: Pending,\n deps: Deps,\n auth?: ClientAuth,\n): Promise<TokenSet> {\n // Read before the request: a slow answer must not lengthen the token's life.\n const requestedAt = (deps.now ?? Date.now)();\n const { response, claims } = await exchangeCode(metadata, params, pending, deps, auth);\n return tokenSetOf(response, claims, pending, requestedAt);\n}\n","import { fromServerError, OduduError } from '#/services/odudu-error';\n\nfunction parsedUrl(value: string, message: string): URL {\n try {\n return new URL(value);\n } catch (cause) {\n throw new OduduError('invalid_callback', message, { cause });\n }\n}\n\n// Reads an authorization response. The state and the issuer are compared\n// before anything else in it is believed: a response that names the wrong\n// issuer is the mix-up attack of RFC 9207, and that holds for an error\n// response as much as for one carrying a code.\nexport function readCallback(\n callbackUrl: string,\n expected: { state: string; issuer: string; redirectUri: string },\n): URLSearchParams {\n const url = parsedUrl(callbackUrl, 'the callback address is not a URL');\n const redirect = parsedUrl(expected.redirectUri, 'the redirect URI of this sign-in is not a URL');\n if (url.origin !== redirect.origin || url.pathname !== redirect.pathname) {\n throw new OduduError('invalid_callback', 'the response did not arrive at the redirect URI');\n }\n const params = url.searchParams;\n const state = params.get('state');\n if (state === null) {\n throw new OduduError('invalid_state', 'the response carries no state');\n }\n if (state !== expected.state) {\n throw new OduduError('invalid_state', 'the response state is not the one this sign-in sent');\n }\n const issuer = params.get('iss');\n if (issuer === null) {\n throw new OduduError('invalid_issuer', 'the response carries no iss parameter (RFC 9207)');\n }\n if (issuer !== expected.issuer) {\n throw new OduduError('invalid_issuer', 'the response iss is not the issuer this sign-in used');\n }\n const error = params.get('error');\n if (error !== null) {\n throw fromServerError(\n error,\n params.get('error_description') ?? undefined,\n 'the authorization server refused the request',\n );\n }\n if (!params.has('code')) {\n throw new OduduError('invalid_callback', 'the response carries no code');\n }\n return params;\n}\n","import { exchangeForTokens } from '#/repository/code-exchange';\nimport { readCallback } from '#/services/callback';\nimport { discover } from '#/use-cases/discover';\nimport type { CompleteSignInOptions, Deps, Pending, TokenSet } from '#/types';\n\n// Finishes a sign-in from the address Odudu redirected the person to: checks\n// the state and the issuer, exchanges the code and validates the ID token.\n// A confidential client passes `auth` to authenticate the exchange; without it\n// the client is public.\nexport async function completeSignIn(\n callbackUrl: string,\n pending: Pending,\n options: CompleteSignInOptions = {},\n deps: Deps = {},\n): Promise<TokenSet> {\n const params = readCallback(callbackUrl, pending);\n return exchangeForTokens(\n await discover(pending.issuer, deps),\n params,\n pending,\n deps,\n options.auth,\n );\n}\n","import * as oauth from 'oauth4webapi';\nimport { clientAuthentication } from '#/adapter/client-authentication';\nimport { requestOptions } from '#/adapter/discovery';\nimport { tokenFailure } from '#/adapter/token-failure';\nimport { OduduError } from '#/services/odudu-error';\nimport type { ClientAuth, Deps, IdTokenClaims, ServerMetadata } from '#/types';\n\ninterface Refreshed {\n response: oauth.TokenEndpointResponse;\n claims: IdTokenClaims | undefined;\n}\n\n// One refresh_token grant. `resource` goes to the token endpoint (RFC 8707\n// section 2.2) and the scope is left out, so the grant's own is kept. An ID\n// token the server repeats is checked like the one of the sign-in.\nexport async function refreshGrant(\n metadata: ServerMetadata,\n client: oauth.Client,\n refreshToken: string,\n resource: string | undefined,\n deps: Deps,\n auth?: ClientAuth,\n): Promise<Refreshed> {\n const options = requestOptions(deps);\n try {\n const response = await oauth.processRefreshTokenResponse(\n metadata,\n client,\n await oauth.refreshTokenGrantRequest(\n metadata,\n client,\n clientAuthentication(auth, deps),\n refreshToken,\n {\n ...(resource === undefined ? {} : { additionalParameters: { resource } }),\n ...options,\n },\n ),\n );\n return { response, claims: oauth.getValidatedIdTokenClaims(response) };\n } catch (cause) {\n if (cause instanceof oauth.ResponseBodyError && cause.error === 'invalid_target') {\n throw new OduduError(\n 'audience_not_granted',\n 'the grant does not carry this audience: use requestAudience to ask for it',\n { error: cause.error, ...detail(cause.error_description) },\n );\n }\n throw await tokenFailure(cause, 'the token endpoint refused the refresh token');\n }\n}\n\nfunction detail(description: string | undefined): { errorDescription?: string } {\n return description === undefined ? {} : { errorDescription: description };\n}\n","import type { IDToken, TokenEndpointResponse } from 'oauth4webapi';\nimport { OduduError } from '#/services/odudu-error';\nimport { refreshExpiresAtOf } from '#/services/token-set';\nimport type { TokenSet } from '#/types';\n\nexport function refreshTokenOf(tokens: TokenSet): string {\n if (tokens.refreshToken === undefined) {\n throw new OduduError(\n 'invalid_options',\n 'these tokens carry no refresh token: Odudu issues one to a client that has the refresh_token grant, so sign in again with such a client',\n );\n }\n return tokens.refreshToken;\n}\n\nconst UNKNOWN_OUTCOME =\n ' The outcome of that refresh is unknown, so this one was not sent: use the tokens the last successful refresh returned, or sign in again.';\n\n// Only a refusal the server makes before it spends the refresh token leaves\n// the token good. Any other failure (a lost connection, a 5xx, an ID token\n// that is refused after the server rotated) may have spent it.\nexport function isRefusedBeforeSpending(error: unknown): boolean {\n return error instanceof OduduError && error.code === 'audience_not_granted';\n}\n\n// What a call queued behind such a failure is rejected with: the same code,\n// and the words that say why nothing was sent.\nexport function abandoned(error: unknown): OduduError {\n if (error instanceof OduduError) {\n if (error.message.endsWith(UNKNOWN_OUTCOME)) return error;\n return new OduduError(error.code, `${error.message}${UNKNOWN_OUTCOME}`, {\n cause: error,\n ...(error.error === undefined ? {} : { error: error.error }),\n ...(error.errorDescription === undefined ? {} : { errorDescription: error.errorDescription }),\n });\n }\n return new OduduError('request_failed', `The refresh before this one failed.${UNKNOWN_OUTCOME}`, {\n cause: error,\n });\n}\n\n// A refresh for an audience the sign-in did not carry is refused here: the\n// server would refuse it too, and asking costs a request and a rotation.\nexport function checkResource(tokens: TokenSet, resource: string | undefined): void {\n if (resource !== undefined && !Object.hasOwn(tokens.byAudience, resource)) {\n throw new OduduError(\n 'audience_not_granted',\n 'the sign-in does not carry this audience: use requestAudience to ask for it',\n );\n }\n}\n\n// The `aud` a JWT access token names, or undefined for one that is opaque or\n// names no audience. The server puts every audience of the grant in one token,\n// and leaves out one a registration policy has since taken away.\nfunction audiencesNamedBy(accessToken: string): string[] | undefined {\n const payload = accessToken.split('.')[1];\n if (payload === undefined) return undefined;\n try {\n const bytes = Uint8Array.from(atob(payload.replaceAll('-', '+').replaceAll('_', '/')), (c) =>\n c.charCodeAt(0),\n );\n const claims: unknown = JSON.parse(new TextDecoder().decode(bytes));\n const aud =\n typeof claims === 'object' && claims !== null && 'aud' in claims ? claims.aud : undefined;\n const named = (Array.isArray(aud) ? aud : [aud]).filter((a) => typeof a === 'string');\n return named.length === 0 ? undefined : named;\n } catch {\n return undefined;\n }\n}\n\n// The audiences a refresh without `resource` keeps: those of the sign-in that\n// the new access token names, or all of them when it names none or cannot be\n// read. Best effort: an access token is opaque to a client, and this reads it\n// only because Odudu issues JWTs.\nfunction renewedAudiences(previous: TokenSet, accessToken: string): string[] {\n const held = Object.keys(previous.byAudience);\n const named = audiencesNamedBy(accessToken)?.filter((audience) => held.includes(audience));\n return named === undefined || named.length === 0 ? held : named;\n}\n\n// The tokens after a refresh. Without a `resource` the new access token covers\n// the audiences it names, so it replaces those entries and removes the others\n// (a later request for one is `audience_not_granted`); with one it replaces\n// that audience's entry and leaves the others. A refresh token the server did not rotate stays, and so do an ID\n// token and claims it did not repeat.\nexport function refreshedTokenSet(\n previous: TokenSet,\n response: TokenEndpointResponse,\n claims: IDToken | undefined,\n resource: string | undefined,\n now: number,\n): TokenSet {\n // OIDC Core section 12.2: a refreshed ID token names the same subject.\n if (claims !== undefined && claims.sub !== previous.claims.sub) {\n throw new OduduError('invalid_id_token', 'the refreshed ID token names another subject');\n }\n const accessToken = response.access_token;\n const expiresAt = refreshExpiresAtOf(response, now);\n const audiences = resource === undefined ? renewedAudiences(previous, accessToken) : [resource];\n const refreshToken = response.refresh_token ?? previous.refreshToken;\n return {\n byAudience: {\n ...(resource === undefined ? {} : previous.byAudience),\n ...Object.fromEntries(\n audiences.map((audience) => [\n audience,\n // A response without `scope` leaves the scope unchanged (RFC 6749 section 5.1).\n {\n accessToken,\n expiresAt,\n scope: response.scope ?? previous.byAudience[audience]?.scope ?? '',\n },\n ]),\n ),\n },\n idToken: response.id_token ?? previous.idToken,\n ...(refreshToken === undefined ? {} : { refreshToken }),\n claims: claims ?? previous.claims,\n issuer: previous.issuer,\n clientId: previous.clientId,\n };\n}\n","interface Flight<T> {\n tag: string;\n promise: Promise<T>;\n}\n\n// The operations that follow one another from a single starting key.\ninterface Chain<T> {\n keys: Set<string>;\n tail: Flight<T> | undefined;\n latest: T | undefined;\n pending: number;\n}\n\nexport interface SingleFlightRules<T> {\n successorKeys: (value: T) => string[];\n // Whether an operation that failed with this error certainly changed\n // nothing, so the next one may go ahead from the last good value.\n retryable: (error: unknown) => boolean;\n // The error a queued operation is rejected with when its predecessor failed\n // in a way that is not retryable.\n abandoned: (error: unknown) => Error;\n}\n\n// Runs the operations of a chain one at a time. A chain starts at its first\n// caller's key and takes in each key a settled operation names through\n// `successorKeys`, so a caller holding a produced value joins the same queue.\n// A caller whose tag matches the last operation queued shares its promise; any\n// other queues behind the tail, starting from the latest good value after a\n// retryable failure and rejected after any other. A chain is dropped when its\n// last operation settles, so the map is bounded by the operations in flight.\nexport class SingleFlight<T> {\n private readonly chains = new Map<string, Chain<T>>();\n private readonly rules: SingleFlightRules<T>;\n\n constructor(rules: SingleFlightRules<T>) {\n this.rules = rules;\n }\n\n run(key: string, tag: string, start: (latest: T | undefined) => Promise<T>): Promise<T> {\n const chain = this.chains.get(key) ?? this.open(key);\n if (chain.tail?.tag === tag) return chain.tail.promise;\n const turn =\n chain.tail?.promise.then(noop, (error: unknown) => {\n if (!this.rules.retryable(error)) throw this.rules.abandoned(error);\n }) ?? Promise.resolve();\n chain.pending += 1;\n const promise: Promise<T> = turn\n .then(() => start(chain.latest))\n .then((value) => {\n chain.latest = value;\n for (const successor of this.rules.successorKeys(value)) {\n chain.keys.add(successor);\n this.chains.set(successor, chain);\n }\n return value;\n })\n .finally(() => {\n chain.pending -= 1;\n if (chain.pending === 0) this.close(chain);\n });\n chain.tail = { tag, promise };\n return promise;\n }\n\n private open(key: string): Chain<T> {\n const chain: Chain<T> = {\n keys: new Set([key]),\n tail: undefined,\n latest: undefined,\n pending: 0,\n };\n this.chains.set(key, chain);\n return chain;\n }\n\n private close(chain: Chain<T>): void {\n for (const key of chain.keys) {\n if (this.chains.get(key) === chain) this.chains.delete(key);\n }\n }\n}\n\nfunction noop(): void {\n // A predecessor that succeeded only orders the queue.\n}\n","import { refreshGrant } from '#/adapter/refresh';\nimport {\n abandoned,\n isRefusedBeforeSpending,\n refreshedTokenSet,\n refreshTokenOf,\n} from '#/services/refresh-request';\nimport { idTokenAlgOf } from '#/services/sign-in-request';\nimport { SingleFlight } from '#/services/single-flight';\nimport type { Deps, RefreshOptions, ServerMetadata, TokenSet } from '#/types';\n\nconst flights = new SingleFlight<TokenSet>({\n successorKeys: (tokens) => (tokens.refreshToken === undefined ? [] : [tokens.refreshToken]),\n retryable: isRefusedBeforeSpending,\n abandoned,\n});\n\n// Renews the tokens. A rotating server refuses a refresh token it has already\n// seen, and revokes the grant when it does, so the refreshes of one grant run\n// one at a time: callers for the same audience share a request, and any other\n// caller runs after it with the newest tokens that came back, however old the\n// tokens it holds.\nexport function refreshTokens(\n metadata: ServerMetadata,\n tokens: TokenSet,\n options: RefreshOptions,\n deps: Deps,\n): Promise<TokenSet> {\n return flights.run(refreshTokenOf(tokens), options.resource ?? '', async (latest) => {\n const previous = latest ?? tokens;\n // Read before the request: a slow answer must not lengthen the token's life.\n const requestedAt = (deps.now ?? Date.now)();\n const { response, claims } = await refreshGrant(\n metadata,\n { client_id: previous.clientId, id_token_signed_response_alg: idTokenAlgOf(options) },\n refreshTokenOf(previous),\n options.resource,\n deps,\n options.auth,\n );\n return refreshedTokenSet(previous, response, claims, options.resource, requestedAt);\n });\n}\n","import { refreshTokens } from '#/repository/refresh';\nimport { checkResource } from '#/services/refresh-request';\nimport { discover } from '#/use-cases/discover';\nimport type { Deps, RefreshOptions, TokenSet } from '#/types';\n\n// Renews the access tokens of a sign-in; client and issuer come from `tokens`.\n// Calls with one refresh token and one resource share a request, and a call\n// naming another resource waits and continues with the rotated refresh token.\n// Keep the result, not `tokens`. Without `resource` only the audiences the new\n// access token names are kept (best effort: it is opaque to a client). A\n// `resource` the sign-in did not carry rejects with `audience_not_granted`.\nexport async function refresh(\n tokens: TokenSet,\n options: RefreshOptions = {},\n deps: Deps = {},\n): Promise<TokenSet> {\n checkResource(tokens, options.resource);\n const metadata = await discover(tokens.issuer, deps);\n return refreshTokens(metadata, tokens, options, deps);\n}\n","import { buildAuthorizationRequest } from '#/repository/authorization-request';\nimport { audienceSignIn } from '#/services/sign-in-request';\nimport { discover } from '#/use-cases/discover';\nimport type { AudienceRequest, Deps, Pending } from '#/types';\n\n// Starts a second authorization for one more audience, which a refresh cannot\n// add: the address to send the person to and the record completeSignIn needs.\n// Completing it yields a token set filed under that audience. With `silent`\n// the request carries `prompt=none`; whether that avoids every interactive\n// step has not been tested, so it is off unless asked for.\nexport async function requestAudience(\n request: AudienceRequest,\n deps: Deps = {},\n): Promise<{ url: string; pending: Pending }> {\n return buildAuthorizationRequest(\n await discover(request.issuer, deps),\n audienceSignIn(request),\n request.silent === true,\n );\n}\n","import * as oauth from 'oauth4webapi';\nimport { requestOptions } from '#/adapter/discovery';\nimport { clientAuthentication } from '#/adapter/client-authentication';\nimport { tokenFailure } from '#/adapter/token-failure';\nimport { OduduError } from '#/services/odudu-error';\nimport { withUsableLifetime } from '#/services/client-credentials-request';\nimport type { ClientAuth, Deps, ServerMetadata } from '#/types';\n\n// One client_credentials grant.\nexport async function clientCredentialsGrant(\n metadata: ServerMetadata,\n clientId: string,\n auth: ClientAuth,\n parameters: URLSearchParams,\n deps: Deps,\n): Promise<oauth.TokenEndpointResponse> {\n const client: oauth.Client = { client_id: clientId };\n try {\n const response = await oauth.clientCredentialsGrantRequest(\n metadata,\n client,\n clientAuthentication(auth, deps),\n parameters,\n requestOptions(deps),\n );\n return await oauth.processClientCredentialsResponse(\n metadata,\n client,\n await readableLifetime(response),\n );\n } catch (cause) {\n if (cause instanceof OduduError) throw cause;\n throw await clientTokenFailure(cause);\n }\n}\n\n// A refused client is named by the server's code; anything else did not complete.\nasync function clientTokenFailure(cause: unknown): Promise<OduduError> {\n const failure = await tokenFailure(cause, 'the token endpoint refused the client');\n return failure.code === 'invalid_id_token'\n ? new OduduError('request_failed', 'the token request did not complete', { cause })\n : failure;\n}\n\n// oauth4webapi refuses a response whose `expires_in` is not a non-negative\n// number. A service that gets one anyway is better served by the default\n// lifetime than by a failure, so the field is dropped before the library\n// reads the response.\nasync function readableLifetime(response: Response): Promise<Response> {\n if (!response.ok) return response;\n const body: unknown = await response\n .clone()\n .json()\n .catch(() => undefined);\n const usable = withUsableLifetime(body);\n return usable === body\n ? response\n : new Response(JSON.stringify(usable), { status: response.status, headers: response.headers });\n}\n","import { clientCredentialsGrant } from '#/adapter/client-credentials';\nimport {\n audienceTokenOf,\n checkedOptions,\n grantParameters,\n} from '#/services/client-credentials-request';\nimport type { AudienceToken, ClientCredentialsOptions, Deps, ServerMetadata } from '#/types';\n\nexport function checkOptions(options: ClientCredentialsOptions): ClientCredentialsOptions {\n return checkedOptions(options);\n}\n\nexport async function requestClientToken(\n metadata: ServerMetadata,\n options: ClientCredentialsOptions,\n deps: Deps,\n): Promise<AudienceToken> {\n // Read before the request: a slow answer must not lengthen the token's life.\n const requestedAt = (deps.now ?? Date.now)();\n const response = await clientCredentialsGrant(\n metadata,\n options.clientId,\n options.auth,\n grantParameters(options),\n deps,\n );\n return audienceTokenOf(response, options.scope, requestedAt);\n}\n","import { checkOptions, requestClientToken } from '#/repository/client-credentials';\nimport { discover } from '#/use-cases/discover';\nimport type { AudienceToken, ClientCredentialsOptions, Deps } from '#/types';\n\n// Signs in as the client itself (RFC 6749 section 4.4): a service with no\n// person behind it. Authenticates with a secret (`client_secret_basic`) or\n// with a private key (`private_key_jwt`).\nexport async function clientCredentials(\n options: ClientCredentialsOptions,\n deps: Deps = {},\n): Promise<AudienceToken> {\n const checked = checkOptions(options);\n return requestClientToken(await discover(checked.issuer, deps), checked, deps);\n}\n","import { signAssertion, type AssertionKey } from '#/adapter/client-assertion';\n\nexport function signClientAssertionFor(\n signing: AssertionKey,\n clientId: string,\n tokenEndpoint: string,\n nowSeconds: number,\n): Promise<string> {\n return signAssertion(signing, clientId, tokenEndpoint, nowSeconds);\n}\n","import { signClientAssertionFor } from '#/repository/client-assertion';\nimport { OduduError } from '#/services/odudu-error';\nimport type { PrivateKeyJwk } from '#/types';\n\nexport interface ClientAssertionOptions {\n clientId: string;\n // The token endpoint the assertion is presented to.\n audience: string;\n privateKey: PrivateKeyJwk;\n kid?: string;\n alg?: string;\n // Milliseconds since the epoch; the current time when omitted.\n now?: number;\n}\n\n// The `private_key_jwt` assertion for a client that makes its own token\n// request, for the caller whose request cannot go through `clientCredentials`.\nexport async function signClientAssertion(options: ClientAssertionOptions): Promise<string> {\n if (options.clientId === '' || options.audience === '') {\n throw new OduduError('invalid_options', 'the client ID and the audience are required');\n }\n return await signClientAssertionFor(\n {\n key: options.privateKey,\n ...(options.kid === undefined ? {} : { kid: options.kid }),\n ...(options.alg === undefined ? {} : { alg: options.alg }),\n },\n options.clientId,\n options.audience,\n Math.floor((options.now ?? Date.now()) / 1000),\n );\n}\n","import { OduduError } from '#/services/odudu-error';\nimport type { AudienceToken } from '#/types';\n\n// A negative skew would keep a token past its expiry, and an infinite or\n// missing one has no meaning.\nexport function checkSkew(skewMs: number): number {\n if (!Number.isFinite(skewMs) || skewMs < 0) {\n throw new OduduError('invalid_options', 'skewMs must be a finite number, zero or more');\n }\n return skewMs;\n}\n\n// Holds one token and gives it until `skewMs` before it expires, or until half\n// its lifetime is gone when that is sooner: a token shorter than the skew is\n// then renewed once per half-life, never on every call. Callers that\n// arrive while a renewal is out share it, whether it succeeds or fails; a\n// failure is not kept, so the next call asks again. There is no timer: a\n// token is renewed by the call that finds it stale.\nexport function tokenRenewer(\n fetchToken: () => Promise<AudienceToken>,\n now: () => number,\n skewMs: number,\n): () => Promise<string> {\n let held: { token: AudienceToken; renewAt: number } | undefined;\n let renewal: Promise<string> | undefined;\n return () => {\n if (held !== undefined && now() < held.renewAt) {\n return Promise.resolve(held.token.accessToken);\n }\n renewal ??= fetchToken()\n .then((token) => {\n const skew = Math.min(skewMs, Math.floor((token.expiresAt - now()) / 2));\n held = { token, renewAt: token.expiresAt - skew };\n return token.accessToken;\n })\n .finally(() => {\n renewal = undefined;\n });\n return renewal;\n };\n}\n","import { checkSkew, tokenRenewer } from '#/services/token-renewer';\nimport { clientCredentials } from '#/use-cases/client-credentials';\nimport type { Deps, TokenSourceOptions } from '#/types';\n\nconst DEFAULT_SKEW_MS = 30_000;\n\n// A function that returns a valid access token for the client, asking the\n// server again only when the one it holds is within `skewMs` of expiring.\n// Concurrent calls share one request. Call it before every request to the API.\nexport function createTokenSource(\n options: TokenSourceOptions,\n deps: Deps = {},\n): () => Promise<string> {\n const { skewMs = DEFAULT_SKEW_MS, ...grant } = options;\n return tokenRenewer(\n () => clientCredentials(grant, deps),\n deps.now ?? Date.now,\n checkSkew(skewMs),\n );\n}\n","import { OduduError } from '#/services/odudu-error';\nimport type { ServerMetadata, SignOutOptions } from '#/types';\n\n// The RP-initiated logout address (OIDC RP-Initiated Logout 1.0 section 2).\nexport function signOutAddress(\n metadata: ServerMetadata,\n options: SignOutOptions,\n allowInsecure: boolean,\n): string {\n if (metadata.end_session_endpoint === undefined) {\n throw new OduduError('discovery_failed', 'the metadata names no end_session_endpoint');\n }\n const url = new URL(metadata.end_session_endpoint);\n // The ID token goes in the query, so it never leaves over plain http.\n if (url.protocol !== 'https:' && !(allowInsecure && url.protocol === 'http:')) {\n throw new OduduError('discovery_failed', 'the end_session_endpoint is not an https address');\n }\n url.searchParams.set('id_token_hint', options.idToken);\n if (options.postLogoutRedirectUri !== undefined) {\n url.searchParams.set('post_logout_redirect_uri', options.postLogoutRedirectUri);\n }\n if (options.state !== undefined) url.searchParams.set('state', options.state);\n return url.href;\n}\n","import { signOutAddress } from '#/services/sign-out-request';\nimport { discover } from '#/use-cases/discover';\nimport type { Deps, SignOutOptions } from '#/types';\n\n// The address that ends the person's session (RP-Initiated Logout). Odudu asks\n// the person to confirm by default, so they land on a confirmation page and\n// are sent on to `postLogoutRedirectUri` only after they agree; a client\n// configured to skip the page signs them out at once. The redirect address\n// must be registered for the client, and the server honors `state` only\n// together with it.\nexport async function signOutUrl(options: SignOutOptions, deps: Deps = {}): Promise<string> {\n return signOutAddress(\n await discover(options.issuer, deps),\n options,\n deps.allowInsecureRequests === true,\n );\n}\n"],"mappings":";AAAA,YAAY,WAAW;;;ACEvB,IAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAuBO,IAAM,aAAN,cAAyB,MAAM;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAsB,SAAiBA,UAA2B,CAAC,GAAG;AAChF,UAAM,SAASA,QAAO,UAAU,SAAY,SAAY,EAAE,OAAOA,QAAO,MAAM,CAAC;AAC/E,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,QAAQA,QAAO;AACpB,SAAK,mBAAmBA,QAAO;AAAA,EACjC;AACF;AAEA,SAAS,YAAY,OAAsD;AACzE,SAAQ,YAAkC,SAAS,KAAK;AAC1D;AAIO,SAAS,gBACd,OACA,kBACA,SACY;AACZ,QAAM,OAAO,YAAY,KAAK,IAAI,QAAQ;AAC1C,SAAO,IAAI,WAAW,MAAM,SAAS;AAAA,IACnC;AAAA,IACA,GAAI,qBAAqB,SAAY,CAAC,IAAI,EAAE,iBAAiB;AAAA,EAC/D,CAAC;AACH;;;AD5DA,SAAS,aAAa,SAAoC;AACxD,SAAO,CAAC,KAAK,YACX,QAAQ,KAAK;AAAA,IACX,QAAQ,QAAQ;AAAA,IAChB,SAAS,QAAQ;AAAA,IACjB,UAAU,QAAQ;AAAA,IAClB,GAAI,QAAQ,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,QAAQ,KAAK;AAAA,IAC3D,GAAI,QAAQ,WAAW,SAAY,CAAC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yB,QAAW;AAC/C,UAAM,IAAI,WAAW,oBAAoB,4CAA4C;AAAA,EACvF;AACA,QAAM,MAAM,IAAI,IAAI,SAAS,oBAAoB;AAEjD,MAAI,IAAI,aAAa,YAAY,EAAE,iBAAiB,IAAI,aAAa,UAAU;AAC7E,UAAM,IAAI,WAAW,oBAAoB,kDAAkD;AAAA,EAC7F;AACA,MAAI,aAAa,IAAI,iBAAiB,QAAQ,OAAO;AACrD,MAAI,QAAQ,0BAA0B,QAAW;AAC/C,QAAI,aAAa,IAAI,4BAA4B,QAAQ,qBAAqB;AAAA,EAChF;AACA,MAAI,QAAQ,UAAU,OAAW,KAAI,aAAa,IAAI,SAAS,QAAQ,KAAK;AAC5E,SAAO,IAAI;AACb;;;ACbA,eAAsB,WAAW,SAAyB,OAAa,CAAC,GAAoB;AAC1F,SAAO;AAAA,IACL,MAAM,SAAS,QAAQ,QAAQ,IAAI;AAAA,IACnC;AAAA,IACA,KAAK,0BAA0B;AAAA,EACjC;AACF;","names":["detail","oauth","oauth","oauth","oauth","oauth","oauth"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odudu-io/oidc",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/wizzywit/odudu.git",
|
|
8
|
+
"directory": "sdks/oidc"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"imports": {
|
|
28
|
+
"#/*": "./src/*.ts"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"jose": "6.2.17",
|
|
32
|
+
"oauth4webapi": "3.8.8"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"tsup": "9.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
40
|
+
"test": "vitest run --config ../../vitest.config.ts --reporter=default --reporter=json --outputFile=trace-report.json"
|
|
41
|
+
}
|
|
6
42
|
}
|