@softistx/janus-social 0.0.0-stage → 0.7.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.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +356 -2
  3. package/dist/authorization-url.d.ts +21 -0
  4. package/dist/authorization-url.d.ts.map +1 -0
  5. package/dist/check-options.d.ts +22 -0
  6. package/dist/check-options.d.ts.map +1 -0
  7. package/dist/claims.d.ts +15 -0
  8. package/dist/claims.d.ts.map +1 -0
  9. package/dist/code-exchange.d.ts +79 -0
  10. package/dist/code-exchange.d.ts.map +1 -0
  11. package/dist/connections/abort.d.ts +8 -0
  12. package/dist/connections/abort.d.ts.map +1 -0
  13. package/dist/connections/at-hash.d.ts +24 -0
  14. package/dist/connections/at-hash.d.ts.map +1 -0
  15. package/dist/connections/body-limit.d.ts +15 -0
  16. package/dist/connections/body-limit.d.ts.map +1 -0
  17. package/dist/connections/build.d.ts +7 -0
  18. package/dist/connections/build.d.ts.map +1 -0
  19. package/dist/connections/check.d.ts +25 -0
  20. package/dist/connections/check.d.ts.map +1 -0
  21. package/dist/connections/claims.d.ts +16 -0
  22. package/dist/connections/claims.d.ts.map +1 -0
  23. package/dist/connections/discovery.d.ts +20 -0
  24. package/dist/connections/discovery.d.ts.map +1 -0
  25. package/dist/connections/domain.d.ts +15 -0
  26. package/dist/connections/domain.d.ts.map +1 -0
  27. package/dist/connections/guarded-fetch.d.ts +49 -0
  28. package/dist/connections/guarded-fetch.d.ts.map +1 -0
  29. package/dist/connections/id-token-steps.d.ts +15 -0
  30. package/dist/connections/id-token-steps.d.ts.map +1 -0
  31. package/dist/connections/id-token.d.ts +63 -0
  32. package/dist/connections/id-token.d.ts.map +1 -0
  33. package/dist/connections/index.d.ts +10 -0
  34. package/dist/connections/index.d.ts.map +1 -0
  35. package/dist/connections/ip.d.ts +14 -0
  36. package/dist/connections/ip.d.ts.map +1 -0
  37. package/dist/connections/issuer-cache.d.ts +40 -0
  38. package/dist/connections/issuer-cache.d.ts.map +1 -0
  39. package/dist/connections/issuer.d.ts +4 -0
  40. package/dist/connections/issuer.d.ts.map +1 -0
  41. package/dist/connections/key-flights.d.ts +16 -0
  42. package/dist/connections/key-flights.d.ts.map +1 -0
  43. package/dist/connections/memory.d.ts +10 -0
  44. package/dist/connections/memory.d.ts.map +1 -0
  45. package/dist/connections/oidc-connections.d.ts +63 -0
  46. package/dist/connections/oidc-connections.d.ts.map +1 -0
  47. package/dist/connections/provider.d.ts +25 -0
  48. package/dist/connections/provider.d.ts.map +1 -0
  49. package/dist/connections/server.d.ts +55 -0
  50. package/dist/connections/server.d.ts.map +1 -0
  51. package/dist/connections/types.d.ts +87 -0
  52. package/dist/connections/types.d.ts.map +1 -0
  53. package/dist/connections/url-policy.d.ts +30 -0
  54. package/dist/connections/url-policy.d.ts.map +1 -0
  55. package/dist/connections/wiring.d.ts +5 -0
  56. package/dist/connections/wiring.d.ts.map +1 -0
  57. package/dist/discovery.d.ts +11 -0
  58. package/dist/discovery.d.ts.map +1 -0
  59. package/dist/dpop.d.ts +18 -0
  60. package/dist/dpop.d.ts.map +1 -0
  61. package/dist/failure.d.ts +14 -0
  62. package/dist/failure.d.ts.map +1 -0
  63. package/dist/github-identity.d.ts +11 -0
  64. package/dist/github-identity.d.ts.map +1 -0
  65. package/dist/github.d.ts +11 -0
  66. package/dist/github.d.ts.map +1 -0
  67. package/dist/google.d.ts +11 -0
  68. package/dist/google.d.ts.map +1 -0
  69. package/dist/guard-error.d.ts +14 -0
  70. package/dist/guard-error.d.ts.map +1 -0
  71. package/dist/index.d.ts +23 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +1821 -0
  74. package/dist/index.js.map +51 -0
  75. package/dist/microsoft-tenant.d.ts +32 -0
  76. package/dist/microsoft-tenant.d.ts.map +1 -0
  77. package/dist/microsoft.d.ts +16 -0
  78. package/dist/microsoft.d.ts.map +1 -0
  79. package/dist/oauth2.d.ts +13 -0
  80. package/dist/oauth2.d.ts.map +1 -0
  81. package/dist/oidc-engine.d.ts +62 -0
  82. package/dist/oidc-engine.d.ts.map +1 -0
  83. package/dist/oidc-step-up.d.ts +15 -0
  84. package/dist/oidc-step-up.d.ts.map +1 -0
  85. package/dist/oidc.d.ts +11 -0
  86. package/dist/oidc.d.ts.map +1 -0
  87. package/dist/options.d.ts +108 -0
  88. package/dist/options.d.ts.map +1 -0
  89. package/dist/pushed-authorization.d.ts +23 -0
  90. package/dist/pushed-authorization.d.ts.map +1 -0
  91. package/dist/step-up.d.ts +50 -0
  92. package/dist/step-up.d.ts.map +1 -0
  93. package/dist/transport.d.ts +18 -0
  94. package/dist/transport.d.ts.map +1 -0
  95. package/docs/README.md +35 -0
  96. package/docs/guide/custom-providers.md +182 -0
  97. package/docs/guide/github.md +109 -0
  98. package/docs/guide/google.md +103 -0
  99. package/docs/guide/microsoft.md +158 -0
  100. package/docs/guide/oidc-connections.md +255 -0
  101. package/docs/guide/oidc-step-up.md +122 -0
  102. package/docs/guide/par-dpop.md +63 -0
  103. package/docs/roadmap.md +33 -0
  104. package/docs/troubleshooting.md +632 -0
  105. package/package.json +67 -5
@@ -0,0 +1,51 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/check-options.ts", "../src/step-up.ts", "../src/connections/build.ts", "../src/connections/domain.ts", "../src/connections/issuer.ts", "../src/connections/types.ts", "../src/connections/check.ts", "../src/connections/memory.ts", "../src/failure.ts", "../src/guard-error.ts", "../src/authorization-url.ts", "../src/code-exchange.ts", "../src/dpop.ts", "../src/pushed-authorization.ts", "../src/transport.ts", "../src/oidc-engine.ts", "../src/claims.ts", "../src/connections/claims.ts", "../src/connections/id-token.ts", "../src/connections/at-hash.ts", "../src/connections/id-token-steps.ts", "../src/connections/provider.ts", "../src/connections/server.ts", "../src/connections/abort.ts", "../src/connections/body-limit.ts", "../src/connections/discovery.ts", "../src/connections/ip.ts", "../src/connections/url-policy.ts", "../src/connections/guarded-fetch.ts", "../src/connections/issuer-cache.ts", "../src/connections/key-flights.ts", "../src/connections/wiring.ts", "../src/connections/oidc-connections.ts", "../src/github-identity.ts", "../src/oauth2.ts", "../src/github.ts", "../src/discovery.ts", "../src/google.ts", "../src/microsoft-tenant.ts", "../src/microsoft.ts", "../src/oidc.ts", "../src/oidc-step-up.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Wiring-time checks: a provider built from a bad option is a bare\n * `TypeError`, naming the option and never its value (a secret is in there).\n */\n\nimport type { OidcSecurityOptions, ProviderCredentials } from './options';\n\nconst LOOPBACK = new Set(['localhost', '127.0.0.1', '[::1]']);\n\n/** Throws unless `value` is a non-empty string. */\nexport function requireText(\n\twhere: string,\n\tname: string,\n\tvalue: unknown,\n): asserts value is string {\n\tif (typeof value !== 'string' || value.trim() === '') {\n\t\tthrow new TypeError(`${where}: \"${name}\" must be a non-empty string`);\n\t}\n}\n\n/** Throws unless `value` is an absolute `https` URL. */\nexport function requireHttps(where: string, name: string, value: unknown): URL {\n\trequireText(where, name, value);\n\tconst url = parse(value);\n\tif (url === null || url.protocol !== 'https:') {\n\t\tthrow new TypeError(`${where}: \"${name}\" must be an https URL`);\n\t}\n\treturn url;\n}\n\n/** Throws unless `redirectUri` is an `https` URL, or `http` on a loopback host. */\nexport function checkRedirectUri(where: string, redirectUri: unknown): void {\n\trequireText(where, 'redirectUri', redirectUri);\n\tconst url = parse(redirectUri);\n\tconst ok =\n\t\turl !== null &&\n\t\t(url.protocol === 'https:' ||\n\t\t\t(url.protocol === 'http:' && LOOPBACK.has(url.hostname)));\n\tif (!ok) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"redirectUri\" must be an https URL (http only on localhost)`,\n\t\t);\n\t}\n}\n\n/** Throws unless `fetch` is absent or a function. */\nexport function checkFetch(where: string, fetch: unknown): void {\n\tif (fetch !== undefined && typeof fetch !== 'function') {\n\t\tthrow new TypeError(`${where}: \"fetch\" must be a function`);\n\t}\n}\n\n/** Throws unless `timeout` is absent or a positive number. */\nexport function checkTimeout(where: string, timeout: unknown): void {\n\tif (\n\t\ttimeout !== undefined &&\n\t\t(typeof timeout !== 'number' || !Number.isFinite(timeout) || timeout <= 0)\n\t) {\n\t\tthrow new TypeError(`${where}: \"timeout\" must be a positive number`);\n\t}\n}\n\n/** Throws unless the credentials are text and the redirect URI, `fetch` and `timeout` are what they allow. */\nexport function checkCredentials(\n\twhere: string,\n\toptions: ProviderCredentials,\n): void {\n\trequireText(where, 'clientId', options.clientId);\n\trequireText(where, 'clientSecret', options.clientSecret);\n\tcheckRedirectUri(where, options.redirectUri);\n\tcheckFetch(where, options.fetch);\n\tcheckTimeout(where, options.timeout);\n}\n\n/** Throws unless `scopes` is an array of non-empty strings without spaces. */\nexport function checkScopes(where: string, scopes: unknown): string[] {\n\tif (\n\t\t!Array.isArray(scopes) ||\n\t\tscopes.some((s) => typeof s !== 'string' || s === '' || /\\s/.test(s))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"scopes\" must be an array of scope names with no spaces`,\n\t\t);\n\t}\n\treturn [...new Set(scopes as string[])];\n}\n\nfunction parse(text: string): URL | null {\n\ttry {\n\t\treturn new URL(text);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** Throws unless `pushedAuthorization` and `dpop` are what the options allow. */\nexport function checkSecurity(\n\twhere: string,\n\toptions: OidcSecurityOptions,\n): void {\n\tconst { pushedAuthorization, dpop } = options;\n\tif (\n\t\tpushedAuthorization !== undefined &&\n\t\tpushedAuthorization !== 'auto' &&\n\t\tpushedAuthorization !== 'always'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"pushedAuthorization\" must be 'auto' or 'always'`,\n\t\t);\n\t}\n\tif (dpop === undefined || dpop === true) return;\n\tconst algorithm = (dpop as { algorithm?: unknown } | null)?.algorithm;\n\tif (algorithm !== 'ES256' && algorithm !== 'EdDSA') {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"dpop\" must be true or { algorithm: 'ES256' | 'EdDSA' }`,\n\t\t);\n\t}\n}\n",
6
+ "/**\n * The step-up of an OpenID Connect preset: the fixed values `oidcStepUp()`\n * holds the ID token to, the request one flow adds, and the evidence the ID\n * token gives.\n */\n\nimport type { SocialStepUpRequest } from '@softistx/janus';\nimport type { IDToken } from 'oauth4webapi';\n\n/** Clock skew allowed between this server and the provider, in both directions (same as the core's `proveStepUp`). */\nconst TOLERANCE_MS = 60_000;\n\n/** The longest `acr` the core keeps. */\nconst MAX_ACR = 256;\n\n/** A fixed step-up: what a preset is configured to require on every sign-in. */\nexport interface FixedStepUp {\n\treadonly acrValues?: readonly string[];\n\treadonly maxAge?: number;\n}\n\n/** Throws unless `acrValues` is a non-empty array of tokens with no spaces, and `maxAge` a non-negative integer. */\nexport function checkStepUp(\n\twhere: string,\n\tacrValues: unknown,\n\tmaxAge: unknown,\n): void {\n\tif (\n\t\tacrValues !== undefined &&\n\t\t(!Array.isArray(acrValues) ||\n\t\t\tacrValues.length === 0 ||\n\t\t\tacrValues.some((v) => typeof v !== 'string' || v === '' || /\\s/.test(v)))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"acrValues\" must be a non-empty array of values with no spaces`,\n\t\t);\n\t}\n\tif (\n\t\tmaxAge !== undefined &&\n\t\t(typeof maxAge !== 'number' || !Number.isInteger(maxAge) || maxAge < 0)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"maxAge\" must be a non-negative integer (seconds)`,\n\t\t);\n\t}\n}\n\n/** The `acr_values` and `max_age` request parameters. */\nexport function stepUpParams({\n\tacrValues,\n\tmaxAge,\n}: {\n\treadonly acrValues?: readonly string[] | undefined;\n\treadonly maxAge?: number | undefined;\n}): Record<string, string> {\n\tconst params: Record<string, string> = {};\n\tif (acrValues !== undefined) params['acr_values'] = acrValues.join(' ');\n\tif (maxAge !== undefined) params['max_age'] = String(maxAge);\n\treturn params;\n}\n\n/**\n * The step-up a request effectively asks for: **both the preset's fixed values\n * and the flow's request must hold**, so the URL sends the `acr_values` they\n * share and the smaller `max_age`. Throws a `TypeError` when the two share no\n * `acr_values`, since no sign-in could satisfy both.\n */\nexport function combineStepUp(\n\tfixed: FixedStepUp,\n\trequest: SocialStepUpRequest | null,\n): { acrValues: readonly string[] | undefined; maxAge: number | undefined } {\n\tconst asked = request?.acrValues ?? undefined;\n\tlet acrValues: readonly string[] | undefined = fixed.acrValues ?? asked;\n\tif (fixed.acrValues !== undefined && asked !== undefined) {\n\t\tconst held = fixed.acrValues;\n\t\tacrValues = [...new Set(asked.filter((value) => held.includes(value)))];\n\t\tif (acrValues.length === 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'step-up: the flow asks for no authentication context class the provider is configured to accept',\n\t\t\t);\n\t\t}\n\t}\n\tconst wanted = request?.maxAge ?? undefined;\n\tconst maxAge =\n\t\tfixed.maxAge === undefined || wanted === undefined\n\t\t\t? (fixed.maxAge ?? wanted)\n\t\t\t: Math.min(fixed.maxAge, wanted);\n\treturn { acrValues, maxAge };\n}\n\n/**\n * The evidence an ID token gives the core: its `acr` (a non-empty string of at\n * most 256 characters) and `auth_time` (a finite number of seconds). A claim\n * that is missing or malformed is left out, and the core refuses the flow\n * that needed it.\n */\nexport function stepUpClaims(claims: IDToken): {\n\tacr?: string;\n\tauthTime?: Date;\n} {\n\tconst acr = claims['acr'];\n\tconst time = claims['auth_time'];\n\tconst authTime =\n\t\ttypeof time === 'number' && Number.isFinite(time)\n\t\t\t? new Date(time * 1000)\n\t\t\t: undefined;\n\treturn {\n\t\t...(typeof acr === 'string' && acr !== '' && acr.length <= MAX_ACR\n\t\t\t? { acr }\n\t\t\t: {}),\n\t\t...(authTime === undefined || Number.isNaN(authTime.getTime())\n\t\t\t? {}\n\t\t\t: { authTime }),\n\t};\n}\n\n/**\n * Whether the ID token proves the step-up: its `acr` is one of `acrValues`,\n * and its `auth_time` lies within `[now - maxAge - 60 s, now + 60 s]`\n * (`now` in epoch milliseconds), so `maxAge: 0` means roughly the last minute.\n * A missing claim fails; a request parameter alone proves nothing, since the\n * visitor can edit the URL. **The same rule as `proveStepUp` in\n * `@softistx/janus`** (AGENTS.md, \"Deliberate duplications\"): change one,\n * change both.\n */\nexport function holdsStepUp(\n\tclaims: IDToken,\n\tacrValues: readonly string[] | undefined,\n\tmaxAge: number | undefined,\n\tnow: number,\n): boolean {\n\tif (acrValues !== undefined) {\n\t\tconst acr = claims['acr'];\n\t\tif (typeof acr !== 'string' || !acrValues.includes(acr)) return false;\n\t}\n\tif (maxAge !== undefined) {\n\t\tconst authTime = claims['auth_time'];\n\t\tif (typeof authTime !== 'number' || !Number.isFinite(authTime)) {\n\t\t\treturn false;\n\t\t}\n\t\tconst at = authTime * 1000;\n\t\tif (at < now - maxAge * 1000 - TOLERANCE_MS) return false;\n\t\tif (at > now + TOLERANCE_MS) return false;\n\t}\n\treturn true;\n}\n",
7
+ "/** The frozen record `checkConnection` answers, built from validated fields only. */\n\nimport { isObject } from './check';\nimport type { EmailTrust, OidcConnection } from './types';\n\nexport const CLIENT_KEYS = [\n\t'id',\n\t'secret',\n\t'authentication',\n\t'idTokenSignedResponseAlg',\n];\nexport const CLAIM_KEYS = [\n\t'email',\n\t'emailVerified',\n\t'name',\n\t'picture',\n] as const;\n\n/** The validated fields only, in fresh objects: the caller's input is never frozen. */\nexport function build(\n\trecord: Record<string, unknown>,\n\tscopes: readonly string[],\n\tdomains: readonly string[],\n\temailTrust: EmailTrust,\n): OidcConnection {\n\tconst client = record['client'] as Record<string, unknown>;\n\tconst claims = record['claims'] as Record<string, unknown> | undefined;\n\tconst stepUp = record['stepUp'] as Record<string, unknown> | undefined;\n\tconst dpop = record['dpop'];\n\tconst out: Record<string, unknown> = {\n\t\tid: record['id'],\n\t\tissuer: record['issuer'],\n\t\tclient: pick(client, CLIENT_KEYS),\n\t\tscopes: [...scopes],\n\t\tdomains: [...domains],\n\t\temailTrust,\n\t};\n\tif (record['revision'] !== undefined) out['revision'] = record['revision'];\n\tif (claims !== undefined) out['claims'] = pick(claims, CLAIM_KEYS);\n\tif (stepUp !== undefined) {\n\t\tconst copy = pick(stepUp, ['acrValues', 'maxAge']);\n\t\tif (Array.isArray(copy['acrValues'])) {\n\t\t\tcopy['acrValues'] = [...(copy['acrValues'] as unknown[])];\n\t\t}\n\t\tout['stepUp'] = copy;\n\t}\n\tif (record['pushedAuthorization'] !== undefined) {\n\t\tout['pushedAuthorization'] = record['pushedAuthorization'];\n\t}\n\tif (dpop !== undefined) {\n\t\tout['dpop'] = isObject(dpop) ? { ...dpop } : dpop;\n\t}\n\treturn freeze(out as unknown as OidcConnection);\n}\n\nfunction pick(\n\tsource: Record<string, unknown>,\n\tkeys: readonly string[],\n): Record<string, unknown> {\n\tconst out: Record<string, unknown> = {};\n\tfor (const key of keys) {\n\t\tif (source[key] !== undefined) out[key] = source[key];\n\t}\n\treturn out;\n}\n\nfunction freeze<T>(value: T): T {\n\tif (typeof value === 'object' && value !== null && !Object.isFrozen(value)) {\n\t\tObject.freeze(value);\n\t\tfor (const inner of Object.values(value)) freeze(inner);\n\t}\n\treturn value;\n}\n",
8
+ "/** E-mail domains as connections store and look them up: lowercase, punycode. */\n\nimport { domainToASCII } from 'node:url';\n\nconst MAX_DOMAIN = 253;\nconst MAX_LABEL = 63;\n\nfunction wellFormed(domain: string): boolean {\n\tif (domain.length > MAX_DOMAIN || !domain.includes('.')) return false;\n\tconst labels = domain.split('.');\n\tfor (const label of labels) {\n\t\tif (label === '' || label.length > MAX_LABEL) return false;\n\t\tif (!/^[a-z0-9-]+$/.test(label)) return false;\n\t\tif (label.startsWith('-') || label.endsWith('-')) return false;\n\t}\n\t// An all-numeric last label is an IP literal, not a mail domain.\n\treturn !/^[0-9]+$/.test(labels[labels.length - 1] ?? '');\n}\n\n/**\n * The lowercase ASCII form of a domain, or `null` when it is not a plain\n * domain name (empty, an address, a URL, a wildcard, a single label, an empty\n * or over-long label, a label outside `a-z`, `0-9` and `-` or with an edge `-`, a `%`, an IP literal). One\n * trailing dot is dropped; two are refused.\n */\nexport function normalizeDomain(value: unknown): string | null {\n\tif (typeof value !== 'string') return null;\n\tconst trimmed = value.trim().toLowerCase();\n\tif (trimmed === '' || /[\\s@/:*?#%\\\\]/.test(trimmed)) return null;\n\tconst ascii = domainToASCII(trimmed).replace(/\\.$/, '');\n\treturn wellFormed(ascii) ? ascii : null;\n}\n\n/**\n * The normalised domain of an e-mail address, or `null`: it must hold no\n * whitespace, one `@`, a non-empty local part and a domain `normalizeDomain`\n * accepts. The one parser of `forEmail` and of the claim mapping.\n */\nexport function domainOfEmail(address: string): string | null {\n\tif (/\\s/.test(address)) return null;\n\tconst at = address.indexOf('@');\n\tif (at < 1 || at !== address.lastIndexOf('@')) return null;\n\treturn normalizeDomain(address.slice(at + 1));\n}\n",
9
+ "/** The issuer of a connection: an https URL held exactly as written. */\n\nimport { requireHttps } from '../check-options';\n\nconst WHERE = 'checkConnection';\n\n/** Pushes a problem unless `issuer` is an https URL with no query, fragment, credentials, empty, `.` or `..` segment, and a lowercase scheme and host. */\nexport function checkIssuer(problems: string[], issuer: unknown): void {\n\ttry {\n\t\tconst url = requireHttps(WHERE, 'issuer', issuer);\n\t\tif (url.search !== '' || url.hash !== '' || url.username !== '') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${WHERE}: \"issuer\" must have no query, fragment or credentials`,\n\t\t\t);\n\t\t}\n\t\tconst text = issuer as string;\n\t\tconst host = url.host;\n\t\tif (!text.startsWith(`https://${host}`)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${WHERE}: \"issuer\" must be written with a lowercase https scheme and host`,\n\t\t\t);\n\t\t}\n\t\t// The raw text: `URL` would already have resolved a `..` away.\n\t\tconst rest = text.slice('https://'.length);\n\t\tconst slash = rest.indexOf('/');\n\t\tconst segments = slash < 0 ? [] : rest.slice(slash).split('/').slice(1);\n\t\tconst last = segments.length - 1;\n\t\tconst bad = segments.some(\n\t\t\t(segment, index) =>\n\t\t\t\tsegment === '.' ||\n\t\t\t\tsegment === '..' ||\n\t\t\t\t(segment === '' && index !== last),\n\t\t);\n\t\tif (bad) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${WHERE}: \"issuer\" must have no empty, \".\" or \"..\" path segment`,\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tproblems.push(error instanceof Error ? error.message : String(error));\n\t}\n}\n",
10
+ "/** The record of an upstream OpenID Connect connection and the port that reads it. */\n\nimport type { OidcSecurityOptions } from '../options';\nimport type { FixedStepUp } from '../step-up';\n\n/**\n * The signature algorithms an ID token may be signed with: asymmetric only.\n * `none` and the `HS*` family are not here, so they cannot be written; the\n * check refuses them at runtime too, for a record read from a database.\n */\nexport const CONNECTION_ALGORITHMS = [\n\t'RS256',\n\t'RS384',\n\t'RS512',\n\t'PS256',\n\t'PS384',\n\t'PS512',\n\t'ES256',\n\t'ES384',\n\t'ES512',\n\t'EdDSA',\n] as const;\n\n/** One of {@link CONNECTION_ALGORITHMS}. */\nexport type ConnectionAlgorithm = (typeof CONNECTION_ALGORITHMS)[number];\n\n/**\n * Which e-mails of the identity provider count as proven:\n * - `'claimAndDomain'` (default): the `email_verified` claim is true and the\n * address is in one of the connection's `domains`;\n * - `'domain'`: the address is in one of `domains` (for providers that do not\n * send `email_verified`, such as Entra ID);\n * - `'claim'`: the claim alone. Opt-in; a tenant can then assert any address.\n */\nexport type EmailTrust = 'claimAndDomain' | 'domain' | 'claim';\n\n/** The names of the ID token claims that fill the identity. Absent keys keep the standard names. */\nexport interface ClaimNames {\n\treadonly email?: string;\n\treadonly emailVerified?: string;\n\treadonly name?: string;\n\treadonly picture?: string;\n}\n\n/** The client this application is registered as at the identity provider. */\nexport interface ConnectionClient {\n\t/** The client id. */\n\treadonly id: string;\n\t/** The client secret. Never logged, never put in an error. */\n\treadonly secret: string;\n\t/** How the secret reaches the token endpoint. Absent: the method the server lists (`'post'` when it does, else `'basic'`), as for the presets. */\n\treadonly authentication?: 'post' | 'basic';\n\t/**\n\t * The one algorithm the ID token must be signed with\n\t * (`id_token_signed_response_alg`). Absent: any of `RS256`, `PS256`,\n\t * `ES256` and `EdDSA`.\n\t */\n\treadonly idTokenSignedResponseAlg?: ConnectionAlgorithm;\n}\n\n/**\n * An upstream OpenID Connect connection: one tenant's identity provider,\n * stored by the application and read through a {@link ConnectionSource}.\n */\nexport interface OidcConnection extends OidcSecurityOptions {\n\t/**\n\t * The provider name: what the sign-in URL, the link records and the events\n\t * carry (`/^[a-z][a-z0-9-]{0,31}$/`). **Never changed while accounts are\n\t * linked**: a new issuer is a new id.\n\t */\n\treadonly id: string;\n\t/** The issuer URL (`https`), whose discovery document is read. **Never changed while accounts are linked.** */\n\treadonly issuer: string;\n\treadonly client: ConnectionClient;\n\t/** Scopes to ask for; `openid` is always added. `['openid', 'email', 'profile']` when absent. */\n\treadonly scopes?: readonly string[];\n\t/**\n\t * The e-mail domains this connection is the sign-in of, verified by the\n\t * application (not by the identity provider). Lowercased and converted to\n\t * punycode by the check. Unique across connections.\n\t */\n\treadonly domains: readonly string[];\n\t/** `'claimAndDomain'` when absent. */\n\treadonly emailTrust?: EmailTrust;\n\treadonly claims?: ClaimNames;\n\t/** Held on every sign-in through this connection. */\n\treadonly stepUp?: FixedStepUp;\n\t/**\n\t * For your own bookkeeping (a version of the stored row, say);\n\t * `janus-social` does not read it, since a record is read again on every\n\t * resolve. A non-empty string or a non-negative integer when given.\n\t */\n\treadonly revision?: string | number;\n}\n\n/**\n * Where the connections live: the application's own table, read-only here.\n * `null` is \"no such connection\"; a throw is a failure (the store is down) and\n * is never read as an absence.\n */\nexport interface ConnectionSource {\n\tfindConnection(id: string): Promise<OidcConnection | null>;\n\t/** The one connection that owns this e-mail domain, or `null`. */\n\tfindConnectionByDomain(domain: string): Promise<OidcConnection | null>;\n}\n",
11
+ "/**\n * `checkConnection`: the one gate a connection record passes, on the\n * application's admin write path and again when the memory source is built.\n */\n\nimport { checkScopes, checkSecurity, requireText } from '../check-options';\nimport { checkStepUp } from '../step-up';\nimport { build, CLAIM_KEYS, CLIENT_KEYS } from './build';\nimport { normalizeDomain } from './domain';\nimport { checkIssuer } from './issuer';\nimport {\n\tCONNECTION_ALGORITHMS,\n\ttype ConnectionAlgorithm,\n\ttype EmailTrust,\n\ttype OidcConnection,\n} from './types';\n\nconst WHERE = 'checkConnection';\nexport const PROVIDER_NAME = /^[a-z][a-z0-9-]{0,31}$/; // the core's pattern (resolve-social.ts)\nconst TRUSTS = ['claimAndDomain', 'domain', 'claim'] as const;\nconst RECORD_KEYS = [\n\t'id',\n\t'issuer',\n\t'client',\n\t'domains',\n\t'revision',\n\t'emailTrust',\n\t'scopes',\n\t'claims',\n\t'stepUp',\n\t'pushedAuthorization',\n\t'dpop',\n];\n/** The scopes of a connection that lists none. */\nexport const DEFAULT_SCOPES = ['openid', 'email', 'profile'];\n/** Claims the protocol itself defines: mapping one to the e-mail or the name would let a token's own fields speak for the visitor. */\nconst PROTOCOL_CLAIMS = [\n\t'sub',\n\t'iss',\n\t'aud',\n\t'azp',\n\t'nonce',\n\t'at_hash',\n\t'acr',\n\t'amr',\n\t'auth_time',\n];\n\n/** Runs a throwing check and keeps its message instead. */\nfunction collect(problems: string[], run: () => void): void {\n\ttry {\n\t\trun();\n\t} catch (error) {\n\t\tproblems.push(error instanceof Error ? error.message : String(error));\n\t}\n}\n\nexport const isObject = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nfunction refuseUnknown(\n\tproblems: string[],\n\tobject: Record<string, unknown>,\n\tallowed: readonly string[],\n\tprefix: string,\n): void {\n\tfor (const key of Object.keys(object)) {\n\t\tif (!allowed.includes(key)) {\n\t\t\tproblems.push(`${WHERE}: \"${prefix}${key}\" is not a known field`);\n\t\t}\n\t}\n}\n\nfunction checkClient(problems: string[], client: unknown): void {\n\tif (!isObject(client)) {\n\t\tproblems.push(`${WHERE}: \"client\" must be an object`);\n\t\treturn;\n\t}\n\trefuseUnknown(problems, client, CLIENT_KEYS, 'client.');\n\tcollect(problems, () => requireText(WHERE, 'client.id', client['id']));\n\tcollect(problems, () =>\n\t\trequireText(WHERE, 'client.secret', client['secret']),\n\t);\n\tconst auth = client['authentication'];\n\tif (auth !== undefined && auth !== 'post' && auth !== 'basic') {\n\t\tproblems.push(\n\t\t\t`${WHERE}: \"client.authentication\" must be 'post' or 'basic'`,\n\t\t);\n\t}\n\tconst alg = client['idTokenSignedResponseAlg'];\n\tif (\n\t\talg !== undefined &&\n\t\t!CONNECTION_ALGORITHMS.includes(alg as ConnectionAlgorithm)\n\t) {\n\t\tproblems.push(\n\t\t\t`${WHERE}: \"client.idTokenSignedResponseAlg\" must be one of ${CONNECTION_ALGORITHMS.join(', ')} (never none or HS*)`,\n\t\t);\n\t}\n}\n\nfunction checkDomains(\n\tproblems: string[],\n\tdomains: unknown,\n\ttrust: unknown,\n): readonly string[] {\n\tif (!Array.isArray(domains)) {\n\t\tproblems.push(`${WHERE}: \"domains\" must be an array of e-mail domains`);\n\t\treturn [];\n\t}\n\tconst before = problems.length;\n\tconst found: string[] = [];\n\tfor (const domain of domains) {\n\t\tconst ascii = normalizeDomain(domain);\n\t\tif (ascii === null) {\n\t\t\tproblems.push(\n\t\t\t\t`${WHERE}: \"domains\" holds a value that is not a domain name`,\n\t\t\t);\n\t\t} else if (!found.includes(ascii)) {\n\t\t\tfound.push(ascii);\n\t\t}\n\t}\n\tif (found.length === 0 && trust !== 'claim' && problems.length === before) {\n\t\tproblems.push(\n\t\t\t`${WHERE}: \"domains\" must not be empty unless emailTrust is 'claim'`,\n\t\t);\n\t}\n\treturn found;\n}\n\nfunction checkClaimNames(problems: string[], claims: unknown): void {\n\tif (claims === undefined) return;\n\tif (!isObject(claims)) {\n\t\tproblems.push(`${WHERE}: \"claims\" must be an object`);\n\t\treturn;\n\t}\n\tfor (const key of Object.keys(claims)) {\n\t\tif (!(CLAIM_KEYS as readonly string[]).includes(key)) {\n\t\t\tproblems.push(\n\t\t\t\t`${WHERE}: \"claims.${key}\" is not a claim that can be mapped`,\n\t\t\t);\n\t\t}\n\t}\n\tfor (const key of CLAIM_KEYS) {\n\t\tconst name = claims[key];\n\t\tif (name === undefined) continue;\n\t\tcollect(problems, () => requireText(WHERE, `claims.${key}`, name));\n\t\tif (typeof name === 'string' && PROTOCOL_CLAIMS.includes(name.trim())) {\n\t\t\tproblems.push(\n\t\t\t\t`${WHERE}: \"claims.${key}\" must not name a protocol claim (${PROTOCOL_CLAIMS.join(', ')})`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction checkStep(problems: string[], stepUp: unknown): void {\n\tif (stepUp === undefined) return;\n\tif (!isObject(stepUp)) {\n\t\tproblems.push(`${WHERE}: \"stepUp\" must be an object`);\n\t\treturn;\n\t}\n\tcollect(problems, () =>\n\t\tcheckStepUp(WHERE, stepUp['acrValues'], stepUp['maxAge']),\n\t);\n}\n\nfunction checkRevision(problems: string[], revision: unknown): void {\n\tif (revision === undefined) return;\n\tconst ok =\n\t\t(typeof revision === 'string' && revision !== '') ||\n\t\t(typeof revision === 'number' &&\n\t\t\tNumber.isInteger(revision) &&\n\t\t\trevision >= 0);\n\tif (!ok) {\n\t\tproblems.push(\n\t\t\t`${WHERE}: \"revision\" must be a non-empty string or a non-negative integer when given`,\n\t\t);\n\t}\n}\n\n/**\n * Validates a connection record and answers it frozen, with the defaults\n * written in (`scopes`, `emailTrust`) and the domains normalised. Throws one\n * `TypeError` listing every problem by field name, never a value (the\n * secret is in there). An unknown key, at the top or in `client`, is refused.\n * Call it before storing a record.\n *\n * The answer is built from the validated fields in fresh objects: the\n * caller's record is never frozen or kept. The issuer is stored and compared\n * exactly as given (the discovery check compares it byte for byte), so it\n * must be written with a lowercase `https` scheme and host and no empty, `.`\n * or `..` path segment. Its host (loopback, private ranges) is not policed\n * here but by the guarded fetch that reads its discovery document.\n */\nexport function checkConnection(record: unknown): OidcConnection {\n\tif (!isObject(record)) {\n\t\tthrow new TypeError(`${WHERE}: the record must be an object`);\n\t}\n\tconst problems: string[] = [];\n\tif (typeof record['id'] !== 'string' || !PROVIDER_NAME.test(record['id'])) {\n\t\tproblems.push(`${WHERE}: \"id\" must match ${PROVIDER_NAME}`);\n\t}\n\trefuseUnknown(problems, record, RECORD_KEYS, '');\n\tcheckIssuer(problems, record['issuer']);\n\tcheckClient(problems, record['client']);\n\tconst trust = record['emailTrust'] ?? 'claimAndDomain';\n\tif (!(TRUSTS as readonly unknown[]).includes(trust)) {\n\t\tproblems.push(\n\t\t\t`${WHERE}: \"emailTrust\" must be 'claimAndDomain', 'domain' or 'claim'`,\n\t\t);\n\t}\n\tconst domains = checkDomains(problems, record['domains'], trust);\n\tlet scopes: readonly string[] = DEFAULT_SCOPES;\n\tcollect(problems, () => {\n\t\tscopes = checkScopes(WHERE, record['scopes'] ?? DEFAULT_SCOPES);\n\t});\n\tcollect(problems, () => checkSecurity(WHERE, record));\n\tcheckClaimNames(problems, record['claims']);\n\tcheckStep(problems, record['stepUp']);\n\tcheckRevision(problems, record['revision']);\n\tif (problems.length > 0) throw new TypeError(problems.join('\\n'));\n\treturn build(record, scopes, domains, trust as EmailTrust);\n}\n",
12
+ "/** `createMemoryConnections`: a reference `ConnectionSource` over a list of records. */\n\nimport { checkConnection } from './check';\nimport { normalizeDomain } from './domain';\nimport type { ConnectionSource, OidcConnection } from './types';\n\n/**\n * A {@link ConnectionSource} over records held in memory, for specs and\n * examples; the application implements the port over its own table. Each\n * record goes through `checkConnection`, and a duplicate id or a domain two\n * records claim is refused at creation.\n */\nexport function createMemoryConnections(\n\trecords: readonly unknown[],\n): ConnectionSource {\n\tconst byId = new Map<string, OidcConnection>();\n\tconst byDomain = new Map<string, OidcConnection>();\n\tfor (const raw of records) {\n\t\tconst record = checkConnection(raw);\n\t\tif (byId.has(record.id)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`createMemoryConnections: duplicate id \"${record.id}\"`,\n\t\t\t);\n\t\t}\n\t\tbyId.set(record.id, record);\n\t\tfor (const domain of record.domains) {\n\t\t\tif (byDomain.has(domain)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`createMemoryConnections: the domain \"${domain}\" belongs to two connections`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tbyDomain.set(domain, record);\n\t\t}\n\t}\n\treturn {\n\t\tfindConnection: async (id) => byId.get(id) ?? null,\n\t\tfindConnectionByDomain: async (domain) => {\n\t\t\tconst ascii = normalizeDomain(domain);\n\t\t\treturn ascii === null ? null : (byDomain.get(ascii) ?? null);\n\t\t},\n\t};\n}\n",
13
+ "/**\n * Turns what oauth4webapi and `fetch` throw into the one error this package\n * throws: `SocialError('PROVIDER_ERROR')`, with a `reason` for the logs. The\n * original stays as `cause`; **a message never carries a URL, a token or what\n * the provider wrote**, since the core's callers may log it.\n */\n\nimport { SocialError } from '@softistx/janus';\nimport {\n\tAuthorizationResponseError,\n\tOperationProcessingError,\n\tResponseBodyError,\n\tUnsupportedOperationError,\n\tWWWAuthenticateChallengeError,\n} from 'oauth4webapi';\nimport { GuardError } from './guard-error';\n\ntype Reason = 'denied' | 'refused' | 'unreachable';\n\n/** A `PROVIDER_ERROR` that says only the step and the reason. */\nexport function providerError(\n\tstep: string,\n\treason: Reason,\n\tcause?: unknown,\n): SocialError {\n\tconst said =\n\t\treason === 'denied'\n\t\t\t? 'the visitor refused the authorization'\n\t\t\t: reason === 'unreachable'\n\t\t\t\t? 'the identity provider could not be reached'\n\t\t\t\t: 'the identity provider refused or answered something unusable';\n\treturn new SocialError('PROVIDER_ERROR', `${step}: ${said}`, {\n\t\treason,\n\t\t...(cause === undefined ? {} : { cause }),\n\t});\n}\n\n/** Runs one step of the exchange; whatever it throws leaves as `PROVIDER_ERROR`. */\nexport async function inStep<T>(\n\tstep: string,\n\trun: () => Promise<T> | T,\n): Promise<T> {\n\ttry {\n\t\treturn await run();\n\t} catch (failure) {\n\t\tthrow classify(step, failure);\n\t}\n}\n\n/**\n * What may be kept of an oauth4webapi error. **Never the error itself**: in\n * oauth4webapi 3 its `cause`, `response` and `body` hold the whole token\n * response (access, refresh and ID tokens), the ID token's claims or the\n * callback's parameters, authorization code included. Only the class name,\n * oauth4webapi's own `code` and the OAuth `error` string are kept.\n */\nfunction scrubbed(failure: Error): Record<string, string> {\n\tconst { code, error } = failure as { code?: unknown; error?: unknown };\n\treturn {\n\t\tname: failure.name,\n\t\t...(typeof code === 'string' ? { code } : {}),\n\t\t...(typeof error === 'string' && /^[\\x20-\\x7e]{1,64}$/.test(error)\n\t\t\t? { error }\n\t\t\t: {}),\n\t};\n}\n\nfunction classify(step: string, failure: unknown): SocialError {\n\tif (failure instanceof SocialError) return failure;\n\tif (failure instanceof GuardError) {\n\t\treturn providerError(\n\t\t\tstep,\n\t\t\tfailure.code === 'dns' || failure.code === 'server-error'\n\t\t\t\t? 'unreachable'\n\t\t\t\t: 'refused',\n\t\t\tscrubbed(failure),\n\t\t);\n\t}\n\tif (failure instanceof AuthorizationResponseError) {\n\t\treturn providerError(\n\t\t\tstep,\n\t\t\tfailure.error === 'access_denied' ? 'denied' : 'refused',\n\t\t\tscrubbed(failure),\n\t\t);\n\t}\n\tif (\n\t\tfailure instanceof ResponseBodyError ||\n\t\tfailure instanceof WWWAuthenticateChallengeError ||\n\t\tfailure instanceof UnsupportedOperationError ||\n\t\tfailure instanceof OperationProcessingError\n\t) {\n\t\treturn providerError(step, 'refused', scrubbed(failure));\n\t}\n\treturn providerError(\n\t\tstep,\n\t\treached(failure) ? 'refused' : 'unreachable',\n\t\tfailure instanceof Error ? scrubbed(failure) : undefined,\n\t);\n}\n\n/** Whether a failure is a refusal of an answer, rather than no answer: a network error or a timeout is the latter. */\nfunction reached(failure: unknown): boolean {\n\tif (failure instanceof TypeError) return false;\n\tif (failure instanceof DOMException) return false;\n\tconst cause = (failure as { cause?: unknown } | null)?.cause;\n\tif (cause instanceof TypeError || cause instanceof DOMException) return false;\n\treturn true;\n}\n",
14
+ "/** The one error the guarded transport throws. */\n\n/** Why the guard refused; also the `code` the failure mapping keeps. */\nexport type GuardCode =\n\t| 'url'\n\t| 'address'\n\t| 'dns'\n\t| 'redirect'\n\t| 'content-type'\n\t| 'server-error'\n\t| 'oversize';\n\n/**\n * A request or an answer the guard refused. The failure mapping reports it\n * as `PROVIDER_ERROR`: reason `unreachable` for `dns` and `server-error`, `refused` for the rest.\n * `code` is the only detail kept; the message is fixed text, never a URL, a\n * query string, an address, a header or a body.\n */\nexport class GuardError extends Error {\n\treadonly code: GuardCode;\n\n\tconstructor(code: GuardCode) {\n\t\tsuper(`the guarded transport refused the request (${code})`);\n\t\tthis.name = 'GuardError';\n\t\tthis.code = code;\n\t}\n}\n",
15
+ "/** The URL a visitor is sent to, shared by every provider. */\n\nimport type { SocialProvider } from '@softistx/janus';\nimport { calculatePKCECodeChallenge } from 'oauth4webapi';\nimport { providerError } from './failure';\n\n/** What the URL is made of beside the flow's three values. */\nexport interface AuthorizationRequest {\n\treadonly endpoint: string;\n\treadonly clientId: string;\n\treadonly redirectUri: string;\n\treadonly scopes: readonly string[];\n\t/** Parameters a provider adds (Google's `hd`). They never override the standard ones. */\n\treadonly extra?: Readonly<Record<string, string>>;\n}\n\n/** The flow's values, as the core derives and hands them. */\ntype FlowValues = Parameters<SocialProvider['authorizationUrl']>[0];\n\n/**\n * Builds the authorization URL: authorization code with PKCE `S256`, and a\n * `nonce` when `withNonce` (OpenID Connect providers). Query parameters the\n * endpoint already carries are kept.\n */\nexport async function authorizationUrl(\n\trequest: AuthorizationRequest,\n\tflow: FlowValues,\n\twithNonce: boolean,\n): Promise<URL> {\n\tconst url = new URL(request.endpoint);\n\tif (url.protocol !== 'https:')\n\t\tthrow providerError('authorization URL', 'refused');\n\tconst query = url.searchParams;\n\t// Only the query response mode is read back: the flow cookie is SameSite=Lax.\n\tquery.delete('response_mode');\n\t// `extra` includes the step-up parameters (`acr_values`, `max_age`), which\n\t// the engine sets over a preset's own `authorizationParams`.\n\tfor (const [name, value] of Object.entries(request.extra ?? {})) {\n\t\tquery.set(name, value);\n\t}\n\tquery.set('response_type', 'code');\n\tquery.set('client_id', request.clientId);\n\tquery.set('redirect_uri', request.redirectUri);\n\tquery.set('scope', request.scopes.join(' '));\n\tquery.set('state', flow.state);\n\tif (withNonce) query.set('nonce', flow.nonce);\n\tquery.set(\n\t\t'code_challenge',\n\t\tawait calculatePKCECodeChallenge(flow.codeVerifier),\n\t);\n\tquery.set('code_challenge_method', 'S256');\n\treturn url;\n}\n",
16
+ "/**\n * The authorization-code exchange, shared by every provider: check the\n * callback against the flow's `state`, redeem the code with the PKCE\n * verifier, and have oauth4webapi validate the answer (and, for OpenID\n * Connect, the ID token's `iss`, `aud`, `exp` and `nonce`).\n *\n * **For the presets the ID token's signature is not verified** — the code goes\n * to the token endpoint over TLS, and OpenID Connect Core §3.1.3.7 lets a\n * client trust the issuer that answered. oauth4webapi does not verify it\n * either, for this flow. An upstream connection sets `idToken`\n * (`connections/id-token-steps.ts`): then the signature is verified\n * after oauth4webapi's checks and before any claim is trusted.\n */\n\nimport * as oauth from 'oauth4webapi';\nimport { newHandle, withNonceRetry } from './dpop';\nimport { inStep, providerError } from './failure';\nimport type { DpopAlgorithm } from './options';\nimport type { transport } from './transport';\n\n/** What the exchange needs to know about the client and the server. */\nexport interface ExchangeSetup {\n\treadonly clientId: string;\n\treadonly auth: oauth.ClientAuth;\n\treadonly redirectUri: string;\n\treadonly http: ReturnType<typeof transport>;\n\t/** The server the callback and the code request are checked against. */\n\treadonly server: oauth.AuthorizationServer;\n\t/**\n\t * The server the token response is validated against, when it is known\n\t * only from that response (Microsoft's issuer carries the account's tenant).\n\t */\n\treadonly serverForTokens?: (\n\t\tanswer: Response,\n\t) => Promise<oauth.AuthorizationServer>;\n\t/** `true` for OpenID Connect: an ID token is required and its `nonce` checked. */\n\treadonly oidc: boolean;\n\t/** Sends a DPoP proof with the token request, signed by a key made for this exchange. */\n\treadonly dpop?: DpopAlgorithm;\n\t/**\n\t * An upstream connection's ID token handling. Absent for the presets,\n\t * which keep the unsigned-trust above. When set, all three members are\n\t * required, so a connection cannot skip the signature: `verifySignature`\n\t * always runs, right after oauth4webapi processed the token response and\n\t * before `checkIdToken` and before any claim is trusted.\n\t */\n\treadonly idToken?: IdTokenSteps;\n}\n\n/** The steps of a connection's ID token handling. */\nexport interface IdTokenSteps {\n\t/** What oauth4webapi is told about the client beyond its id. */\n\treadonly clientExtras: ClientExtras;\n\t/** Verifies the signature; `answer` is the response oauth4webapi processed. */\n\treadonly verifySignature: (\n\t\tanswer: Response,\n\t\ttokens: oauth.TokenEndpointResponse,\n\t) => Promise<void>;\n\t/** Checks the claims once the signature holds. A throw refuses the exchange. */\n\treadonly checkIdToken: (\n\t\ttokens: oauth.TokenEndpointResponse,\n\t\tclaims: oauth.IDToken,\n\t) => Promise<void> | void;\n}\n\n/** The client settings oauth4webapi reads from the client object. */\nexport interface ClientExtras {\n\t/** The one `alg` the ID token may carry (`id_token_signed_response_alg`). */\n\treadonly idTokenSignedResponseAlg?: string;\n\t/** Seconds of clock skew oauth4webapi allows on `exp` and `nbf` (its default is 30). */\n\treadonly clockTolerance?: number;\n}\n\n/** What the callback is checked against. */\nexport interface ExchangeFlow {\n\treadonly callback: URLSearchParams;\n\treadonly state: string;\n\treadonly nonce: string;\n\treadonly codeVerifier: string;\n}\n\n/** The validated token response, and the ID token's claims for OpenID Connect. */\nexport interface Redeemed {\n\treadonly tokens: oauth.TokenEndpointResponse;\n\treadonly claims: oauth.IDToken | undefined;\n}\n\n/** The client oauth4webapi is told about, from its id. */\nexport function clientOf(\n\tclientId: string,\n\textras: ClientExtras = {},\n): oauth.Client {\n\treturn {\n\t\tclient_id: clientId,\n\t\t...(extras.idTokenSignedResponseAlg === undefined\n\t\t\t? {}\n\t\t\t: { id_token_signed_response_alg: extras.idTokenSignedResponseAlg }),\n\t\t...(extras.clockTolerance === undefined\n\t\t\t? {}\n\t\t\t: { [oauth.clockTolerance]: extras.clockTolerance }),\n\t};\n}\n\n/**\n * The exchange's key pair. A runtime without the algorithm (Ed25519 on an old\n * engine) is a wiring problem, not an unreachable provider.\n */\nasync function newKey(algorithm: DpopAlgorithm): Promise<oauth.DPoPHandle> {\n\ttry {\n\t\treturn await newHandle(algorithm);\n\t} catch (failure) {\n\t\tthrow new TypeError(\n\t\t\t`this runtime cannot generate a \"${algorithm}\" DPoP key`,\n\t\t\t{ cause: failure },\n\t\t);\n\t}\n}\n\n/**\n * Redeems the callback's code. Every failure leaves as `PROVIDER_ERROR`,\n * except a runtime that cannot generate the DPoP key: a `TypeError` naming\n * the algorithm (the core wraps it as `PROVIDER_ERROR` with it as the cause).\n */\nexport async function redeem(\n\tsetup: ExchangeSetup,\n\tflow: ExchangeFlow,\n): Promise<Redeemed> {\n\tconst client = clientOf(setup.clientId, setup.idToken?.clientExtras);\n\tconst parameters = await inStep('the authorization response', () =>\n\t\toauth.validateAuthResponse(setup.server, client, flow.callback, flow.state),\n\t);\n\tconst algorithm = setup.dpop;\n\tconst handle = algorithm === undefined ? undefined : await newKey(algorithm);\n\tconst run = <T>(attempt: () => Promise<T>) =>\n\t\thandle === undefined ? attempt() : withNonceRetry(attempt);\n\tconst tokens = await inStep('the token response', () =>\n\t\trun(async () => {\n\t\t\tconst answer = await inStep('the token request', () =>\n\t\t\t\toauth.authorizationCodeGrantRequest(\n\t\t\t\t\tsetup.server,\n\t\t\t\t\tclient,\n\t\t\t\t\tsetup.auth,\n\t\t\t\t\tparameters,\n\t\t\t\t\tsetup.redirectUri,\n\t\t\t\t\tflow.codeVerifier,\n\t\t\t\t\t{ ...setup.http, ...(handle === undefined ? {} : { DPoP: handle }) },\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst server =\n\t\t\t\tsetup.serverForTokens === undefined\n\t\t\t\t\t? setup.server\n\t\t\t\t\t: await setup.serverForTokens(answer.clone());\n\t\t\tconst processed = await oauth.processAuthorizationCodeResponse(\n\t\t\t\tserver,\n\t\t\t\tclient,\n\t\t\t\tanswer,\n\t\t\t\t{\n\t\t\t\t\texpectedNonce: setup.oidc ? flow.nonce : oauth.expectNoNonce,\n\t\t\t\t\trequireIdToken: setup.oidc,\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (handle !== undefined && processed.token_type !== 'dpop') {\n\t\t\t\tthrow providerError('the token response', 'refused');\n\t\t\t}\n\t\t\tawait trusted(setup, answer, processed);\n\t\t\treturn processed;\n\t\t}),\n\t);\n\treturn { tokens, claims: oauth.getValidatedIdTokenClaims(tokens) };\n}\n\n/** Signature first, then the claims: a connection's steps, all required. */\nasync function trusted(\n\tsetup: ExchangeSetup,\n\tanswer: Response,\n\ttokens: oauth.TokenEndpointResponse,\n): Promise<void> {\n\tconst steps = setup.idToken;\n\tif (steps === undefined) return;\n\tawait inStep('the ID token', async () => {\n\t\tawait steps.verifySignature(answer, tokens);\n\t\tconst claims = oauth.getValidatedIdTokenClaims(tokens);\n\t\tif (claims === undefined) throw providerError('the ID token', 'refused');\n\t\tawait steps.checkIdToken(tokens, claims);\n\t});\n}\n",
17
+ "/**\n * DPoP (RFC 9449) for the code exchange: a fresh, non-extractable key pair per\n * exchange (the tokens are read once, for the ID token, so nothing persists),\n * and one retry when the server asks for its nonce.\n */\n\nimport * as oauth from 'oauth4webapi';\nimport type { DpopAlgorithm, OidcSecurityOptions } from './options';\n\n/** The algorithm `dpop` asks for, or `undefined` when DPoP is off. */\nexport function dpopAlgorithm(\n\tdpop: OidcSecurityOptions['dpop'],\n): DpopAlgorithm | undefined {\n\tif (dpop === undefined) return undefined;\n\treturn dpop === true ? 'ES256' : dpop.algorithm;\n}\n\n/** A DPoP handle on a key pair made now. */\nexport async function newHandle(\n\talgorithm: DpopAlgorithm,\n): Promise<oauth.DPoPHandle> {\n\tconst keyPair = await oauth.generateKeyPair(algorithm);\n\treturn oauth.DPoP({}, keyPair);\n}\n\n/**\n * Runs `attempt`, and once more when it fails with `use_dpop_nonce`: the\n * handle has kept the server's nonce from that answer, so the second proof\n * carries it. A second refusal propagates.\n */\nexport async function withNonceRetry<T>(attempt: () => Promise<T>): Promise<T> {\n\ttry {\n\t\treturn await attempt();\n\t} catch (failure) {\n\t\tif (!oauth.isDPoPNonceError(failure)) throw failure;\n\t\treturn attempt();\n\t}\n}\n",
18
+ "/**\n * Pushed authorization requests (RFC 9126): the parameters go to the server's\n * endpoint, authenticated like the token request, and the visitor is sent\n * with only `client_id` and the `request_uri` it answered.\n */\n\nimport * as oauth from 'oauth4webapi';\nimport { clientOf } from './code-exchange';\nimport { inStep, providerError } from './failure';\nimport type { transport } from './transport';\n\nconst STEP = 'the pushed authorization request';\n\n/** Whether this authorization request is pushed, or throws when it must be and cannot. */\nexport function shouldPush(\n\tserver: oauth.AuthorizationServer,\n\tmode: 'auto' | 'always',\n): boolean {\n\tconst endpoint = server.pushed_authorization_request_endpoint;\n\tconst required = server.require_pushed_authorization_requests === true;\n\tif (mode === 'auto' && !required) return false;\n\tif (endpoint === undefined) throw providerError(STEP, 'refused');\n\treturn true;\n}\n\n/** What a push needs beside the parameters. */\nexport interface PushSetup {\n\treadonly server: oauth.AuthorizationServer;\n\treadonly clientId: string;\n\treadonly auth: oauth.ClientAuth;\n\treadonly http: ReturnType<typeof transport>;\n}\n\n/**\n * Pushes `url`'s query and returns the URL the visitor is sent to. Every\n * failure leaves as `PROVIDER_ERROR` at the step \"the pushed authorization\n * request\", never carrying a parameter.\n */\nexport function push(\n\tsetup: PushSetup,\n\turl: URL,\n\tendpoint: string,\n): Promise<URL> {\n\tconst client = clientOf(setup.clientId);\n\tconst own = new URL(endpoint).searchParams;\n\tconst parameters = new URLSearchParams();\n\tfor (const [key, value] of url.searchParams) {\n\t\tif (!own.has(key) || own.get(key) !== value) parameters.append(key, value);\n\t}\n\treturn inStep(STEP, async () => {\n\t\tconst answer = await oauth.pushedAuthorizationRequest(\n\t\t\tsetup.server,\n\t\t\tclient,\n\t\t\tsetup.auth,\n\t\t\tparameters,\n\t\t\tsetup.http,\n\t\t);\n\t\tconst { request_uri } = await oauth.processPushedAuthorizationResponse(\n\t\t\tsetup.server,\n\t\t\tclient,\n\t\t\tanswer,\n\t\t);\n\t\t// RFC 6749 3.1: the endpoint's own query is kept.\n\t\tconst sent = new URL(endpoint);\n\t\t// Only the query response mode is read back: the flow cookie is SameSite=Lax.\n\t\tsent.searchParams.delete('response_mode');\n\t\tsent.searchParams.set('client_id', setup.clientId);\n\t\tsent.searchParams.set('request_uri', request_uri);\n\t\treturn sent;\n\t});\n}\n",
19
+ "/** How requests leave: the `fetch` in use, and the client authentication. */\n\nimport * as oauth from 'oauth4webapi';\nimport type { SocialFetch } from './options';\n\n/** Milliseconds a request to the identity provider may take when `timeout` is absent. */\nexport const DEFAULT_TIMEOUT = 10_000;\n\n/** The request options that route oauth4webapi through `fetch`, when it is not the global one. */\nexport function transport(\n\tfetchWith: SocialFetch | undefined,\n\ttimeout: number | undefined,\n): {\n\tsignal: () => AbortSignal;\n\t[oauth.customFetch]?: (url: string, options: object) => Promise<Response>;\n} {\n\tconst signal = () => AbortSignal.timeout(timeout ?? DEFAULT_TIMEOUT);\n\tif (fetchWith === undefined) return { signal };\n\treturn {\n\t\tsignal,\n\t\t[oauth.customFetch]: (url, options) =>\n\t\t\tfetchWith(url, options as RequestInit),\n\t};\n}\n\n/**\n * The `fetch` the provider hands to code of the application's (the identity\n * callback). Each call gets its own timeout, unless the caller passes a `signal`.\n */\nexport function fetcher(\n\tfetchWith: SocialFetch | undefined,\n\ttimeout: number | undefined,\n): SocialFetch {\n\tconst base: SocialFetch = fetchWith ?? ((input, init) => fetch(input, init));\n\treturn (input, init) =>\n\t\tbase(input, {\n\t\t\t...init,\n\t\t\tsignal: init?.signal ?? AbortSignal.timeout(timeout ?? DEFAULT_TIMEOUT),\n\t\t});\n}\n\n/** The client authentication for a secret, by the method the provider takes. */\nexport function clientAuth(\n\tsecret: string,\n\tmethod: 'post' | 'basic',\n): oauth.ClientAuth {\n\treturn method === 'basic'\n\t\t? oauth.ClientSecretBasic(secret)\n\t\t: oauth.ClientSecretPost(secret);\n}\n",
20
+ "/**\n * What `oidcProvider`, Google and Microsoft share: an OpenID Connect\n * `SocialProvider` that differs from the next only in where its server comes\n * from and how its claims read.\n */\n\nimport type { SocialIdentity, SocialProvider } from '@softistx/janus';\nimport type * as oauth from 'oauth4webapi';\nimport { authorizationUrl } from './authorization-url';\nimport { type IdTokenSteps, redeem } from './code-exchange';\nimport { dpopAlgorithm } from './dpop';\nimport { inStep, providerError } from './failure';\nimport type { OidcSecurityOptions, ProviderCredentials } from './options';\nimport { push, shouldPush } from './pushed-authorization';\nimport {\n\tcombineStepUp,\n\ttype FixedStepUp,\n\tstepUpClaims,\n\tstepUpParams,\n} from './step-up';\nimport { clientAuth, transport } from './transport';\n\n/**\n * What one exchange or authorization URL runs against: the server, the\n * transport to reach it and, for an upstream connection, the ID token steps.\n */\nexport interface EngineSession {\n\treadonly server: oauth.AuthorizationServer;\n\treadonly http: ReturnType<typeof transport>;\n\t/** Set for a connection: the signature check is then mandatory. Absent for the presets. */\n\treadonly idToken?: IdTokenSteps;\n}\n\n/** The server a preset reaches (read lazily) or the session a connection runs in, never both. */\nexport type EngineServer =\n\t| {\n\t\t\t/** The server, read lazily: discovery, or a fixed description. */\n\t\t\treadonly server: () => Promise<oauth.AuthorizationServer>;\n\t\t\treadonly session?: never;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * Looks up the whole session at once, so the server, its transport\n\t\t\t * and the signature check come from the same lookup.\n\t\t\t */\n\t\t\treadonly session: () => Promise<EngineSession>;\n\t\t\treadonly server?: never;\n\t };\n\n/** One OpenID Connect provider, as its preset describes it. */\nexport type OidcEngine = EngineServer & EngineBase;\n\ninterface EngineBase {\n\treadonly credentials: ProviderCredentials;\n\t/** `pushedAuthorization` and `dpop`, as the application gave them. */\n\treadonly security?: OidcSecurityOptions;\n\treadonly scopes: readonly string[];\n\t/** How the secret reaches the token endpoint; by default the method the server lists. */\n\treadonly authentication?: 'post' | 'basic';\n\t/** Parameters the authorization URL carries beside the standard ones. */\n\treadonly authorizationParams?: Readonly<Record<string, string>>;\n\t/** For a server whose issuer is known only from the token response. */\n\treadonly serverForTokens?: (\n\t\tserver: oauth.AuthorizationServer,\n\t\tanswer: Response,\n\t) => Promise<oauth.AuthorizationServer>;\n\t/** Step-up values every sign-in must meet (`oidcStepUp`); sent with each request and held by `identity`. */\n\treadonly fixedStepUp?: FixedStepUp;\n\t/**\n\t * Whether a flow's `stepUp` request is sent and the ID token's `acr` and\n\t * `auth_time` are reported on the identity: the provider's\n\t * `supportsStepUp`. `false` for a server that ignores `acr_values`.\n\t */\n\treadonly perRequestStepUp: boolean;\n\t/** The account the validated ID token's claims describe. */\n\treadonly identity: (claims: oauth.IDToken) => SocialIdentity;\n}\n\n/** The method the server takes for the secret: `post` when it lists it, else `basic`. */\nfunction methodOf(server: oauth.AuthorizationServer): 'post' | 'basic' {\n\tconst listed = server.token_endpoint_auth_methods_supported;\n\tif (listed === undefined) return 'basic';\n\treturn listed.includes('client_secret_post') ? 'post' : 'basic';\n}\n\n/** Builds the `SocialProvider` of an OpenID Connect engine. */\nexport function createOidcProvider(engine: OidcEngine): SocialProvider {\n\tconst { credentials } = engine;\n\tconst dpop = dpopAlgorithm(engine.security?.dpop);\n\tconst open = async (): Promise<EngineSession> =>\n\t\tengine.session === undefined\n\t\t\t? {\n\t\t\t\t\tserver: await engine.server(),\n\t\t\t\t\thttp: transport(credentials.fetch, credentials.timeout),\n\t\t\t\t}\n\t\t\t: engine.session();\n\tconst methodFor = (server: oauth.AuthorizationServer) =>\n\t\tengine.authentication ?? methodOf(server);\n\treturn {\n\t\tsupportsStepUp: engine.perRequestStepUp,\n\t\tasync authorizationUrl(flow) {\n\t\t\tconst { server, http } = await open();\n\t\t\tconst endpoint = server.authorization_endpoint;\n\t\t\tif (endpoint === undefined) {\n\t\t\t\tthrow providerError('authorization URL', 'refused');\n\t\t\t}\n\t\t\tconst stepUp = engine.perRequestStepUp\n\t\t\t\t? stepUpParams(combineStepUp(engine.fixedStepUp ?? {}, flow.stepUp))\n\t\t\t\t: {};\n\t\t\tconst extra = { ...engine.authorizationParams, ...stepUp };\n\t\t\tconst url = await authorizationUrl(\n\t\t\t\t{\n\t\t\t\t\tendpoint,\n\t\t\t\t\tclientId: credentials.clientId,\n\t\t\t\t\tredirectUri: credentials.redirectUri,\n\t\t\t\t\tscopes: engine.scopes,\n\t\t\t\t\t...(Object.keys(extra).length === 0 ? {} : { extra }),\n\t\t\t\t},\n\t\t\t\tflow,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tif (!shouldPush(server, engine.security?.pushedAuthorization ?? 'auto')) {\n\t\t\t\treturn url;\n\t\t\t}\n\t\t\treturn push(\n\t\t\t\t{\n\t\t\t\t\tserver,\n\t\t\t\t\tclientId: credentials.clientId,\n\t\t\t\t\tauth: clientAuth(credentials.clientSecret, methodFor(server)),\n\t\t\t\t\thttp,\n\t\t\t\t},\n\t\t\t\turl,\n\t\t\t\tendpoint,\n\t\t\t);\n\t\t},\n\t\tasync exchange(flow) {\n\t\t\tconst { server, http, idToken } = await open();\n\t\t\tconst { serverForTokens } = engine;\n\t\t\tconst { claims } = await redeem(\n\t\t\t\t{\n\t\t\t\t\tclientId: credentials.clientId,\n\t\t\t\t\tauth: clientAuth(credentials.clientSecret, methodFor(server)),\n\t\t\t\t\tredirectUri: credentials.redirectUri,\n\t\t\t\t\thttp,\n\t\t\t\t\tserver,\n\t\t\t\t\toidc: true,\n\t\t\t\t\t...(idToken === undefined ? {} : { idToken }),\n\t\t\t\t\t...(dpop === undefined ? {} : { dpop }),\n\t\t\t\t\t...(serverForTokens === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { serverForTokens: (answer) => serverForTokens(server, answer) }),\n\t\t\t\t},\n\t\t\t\tflow,\n\t\t\t);\n\t\t\tif (claims === undefined) throw providerError('the ID token', 'refused');\n\t\t\treturn inStep('the ID token', () => ({\n\t\t\t\t...engine.identity(claims),\n\t\t\t\t...(engine.perRequestStepUp ? stepUpClaims(claims) : {}),\n\t\t\t}));\n\t\t},\n\t};\n}\n",
21
+ "/** Reading an ID token's claims into the core's `SocialIdentity`. */\n\nimport type { SocialIdentity } from '@softistx/janus';\nimport type { IDToken } from 'oauth4webapi';\nimport { providerError } from './failure';\n\n/** A claim that is a non-empty string, or `undefined`. */\nexport function text(claims: IDToken, name: string): string | undefined {\n\tconst value = claims[name];\n\treturn typeof value === 'string' && value !== '' ? value : undefined;\n}\n\n/** Whether the provider says `true` — as a boolean, or as the string some providers send. */\nexport function isTrue(claims: IDToken, name: string): boolean {\n\tconst value = claims[name];\n\treturn value === true || value === 'true';\n}\n\n/**\n * The identity an OpenID Connect provider vouches for: `sub` is the account,\n * `email` counts only with `verified` true. **A missing `email` claim is\n * `email: null`, never a guess from another claim** (`preferred_username` is\n * the user's to edit).\n */\nexport function identityOf(\n\tclaims: IDToken,\n\tverified: boolean,\n\tstep: string,\n): SocialIdentity {\n\tconst accountId = text(claims, 'sub');\n\tif (accountId === undefined) {\n\t\tthrow providerError(step, 'refused');\n\t}\n\tconst email = text(claims, 'email') ?? null;\n\tconst name = text(claims, 'name');\n\tconst picture = text(claims, 'picture');\n\treturn {\n\t\taccountId,\n\t\temail,\n\t\temailVerified: email !== null && verified,\n\t\t...(name === undefined ? {} : { name }),\n\t\t...(picture === undefined ? {} : { picture }),\n\t};\n}\n",
22
+ "/** A connection's validated ID token claims, read into the core's `SocialIdentity` under its e-mail trust policy. */\n\nimport type { SocialIdentity } from '@softistx/janus';\nimport type { IDToken } from 'oauth4webapi';\nimport { isTrue, text } from '../claims';\nimport { providerError } from '../failure';\nimport { domainOfEmail } from './domain';\nimport type { OidcConnection } from './types';\n\n/** What the mapping reads of a connection record. */\nexport type ClaimPolicy = Pick<\n\tOidcConnection,\n\t'domains' | 'emailTrust' | 'claims'\n>;\n\n/** The canonical address (local part as sent, ASCII lowercase domain) of a well-formed one, or `null`. */\nfunction canonical(address: string): { email: string; domain: string } | null {\n\tconst domain = domainOfEmail(address);\n\treturn domain === null\n\t\t? null\n\t\t: {\n\t\t\t\temail: `${address.slice(0, address.indexOf('@'))}@${domain}`,\n\t\t\t\tdomain,\n\t\t\t};\n}\n\n/** Whether `domain` is one of the connection's own: an exact match, no subdomain. */\nfunction listed(domains: readonly string[], domain: string): boolean {\n\treturn domains.includes(domain);\n}\n\n/**\n * The identity the connection's identity provider vouches for. `sub` is the\n * account, always. `emailVerified` is true only when the connection's\n * `emailTrust` holds (`'claimAndDomain'` by default): a verified claim from a\n * domain the connection does not own never reaches the core as verified, so\n * the core refuses to link a local account by it. A malformed address is\n * `email: null`, never verified. A claim that is not a string is ignored.\n */\nexport function connectionIdentity(\n\tconnection: ClaimPolicy,\n\tclaims: IDToken,\n\tstep: string,\n): SocialIdentity {\n\tconst accountId = text(claims, 'sub');\n\tif (accountId === undefined) {\n\t\tthrow providerError(step, 'refused');\n\t}\n\tconst names = connection.claims ?? {};\n\tconst address = text(claims, names.email ?? 'email');\n\tconst parsed = address === undefined ? null : canonical(address);\n\tconst email = parsed === null ? null : parsed.email;\n\tconst domain = parsed === null ? null : parsed.domain;\n\tconst claimed = isTrue(claims, names.emailVerified ?? 'email_verified');\n\tconst owned = domain !== null && listed(connection.domains, domain);\n\tconst trust = connection.emailTrust ?? 'claimAndDomain';\n\tconst verified =\n\t\temail !== null &&\n\t\t(trust === 'claim'\n\t\t\t? claimed\n\t\t\t: trust === 'domain'\n\t\t\t\t? owned\n\t\t\t\t: claimed && owned);\n\tconst name = text(claims, names.name ?? 'name');\n\tconst picture = text(claims, names.picture ?? 'picture');\n\treturn {\n\t\taccountId,\n\t\temail,\n\t\temailVerified: verified,\n\t\t...(name === undefined ? {} : { name }),\n\t\t...(picture === undefined ? {} : { picture }),\n\t};\n}\n",
23
+ "/**\n * What a connection's ID token must prove, on top of oauth4webapi.\n *\n * **oauth4webapi 3.8.8 checks** (in `processAuthorizationCodeResponse`):\n * `iss` equals the discovered issuer; `aud` holds the client id; `azp` equals\n * the client id when `aud` has several members (and is then required);\n * `exp` is not past `now - tolerance`; `nbf` is not after `now + tolerance`;\n * `iat`, `sub`, `exp`, `aud`, `iss` and `nonce` are present; the nonce\n * matches; the `alg` is the client's `id_token_signed_response_alg`, else one\n * of the metadata's list, else `RS256`. Its signature step\n * (`validateApplicationLevelSignature`) refuses `HS*` and an unknown `alg`,\n * reads only keys of the issuer's JWKS, takes only an Ed25519 key for `EdDSA`,\n * and refuses an RSA key under 2048 bits.\n *\n * **This module adds**: the `alg` is one of the connection's accepted list\n * *before* any key is fetched, so the metadata cannot widen it: the pinned\n * algorithm, else the intersection of `RS256`, `PS256`, `ES256` and `EdDSA`\n * with what the metadata lists (`RS256` when it lists none); `iss` equals the\n * connection's issuer byte for byte; `azp`, when present, equals the client id\n * even with one audience; `iat` is at most 30 s in the future (the one clock\n * tolerance, shared with `exp` and `nbf`); `sub` is a non-empty string of 255\n * characters or fewer; `at_hash`, when present, matches the access token; and\n * a connection's fixed step-up is held by the token's `acr` and `auth_time`.\n * No claim is trusted before the signature holds: the checks run in that order.\n *\n * Every refusal is `PROVIDER_ERROR` with reason `refused`, its `cause`\n * naming the check (`{ check: 'iat' }`) and never a token, a claim or a key.\n * Two exceptions: an unmet step-up is `SOCIAL_STEP_UP_UNMET`, and a failure to\n * fetch the keys is `PROVIDER_ERROR` with reason `unreachable`.\n */\n\nimport { SocialError } from '@softistx/janus';\nimport type * as oauth from 'oauth4webapi';\nimport { providerError } from '../failure';\nimport { type FixedStepUp, holdsStepUp } from '../step-up';\nimport { atHashMatches } from './at-hash';\nimport { CONNECTION_ALGORITHMS, type ConnectionAlgorithm } from './types';\n\n/** Seconds of clock skew allowed on `exp`, `nbf` and `iat`: fixed, not a setting. */\nexport const CLOCK_TOLERANCE = 30;\n/** The algorithms a connection that pins none accepts. */\nexport const DEFAULT_ALGORITHMS: readonly ConnectionAlgorithm[] = [\n\t'RS256',\n\t'PS256',\n\t'ES256',\n\t'EdDSA',\n];\n\nconst MAX_SUB = 255;\n\n/** What the checks need to know about the connection. */\nexport interface IdTokenPolicy {\n\treadonly issuer: string;\n\treadonly clientId: string;\n\t/** `client.idTokenSignedResponseAlg`: the one algorithm, when pinned. */\n\treadonly algorithm?: ConnectionAlgorithm | undefined;\n\treadonly stepUp?: FixedStepUp | undefined;\n\t/** Epoch milliseconds; `Date.now()` when absent (oauth4webapi reads it too). */\n\treadonly now?: (() => number) | undefined;\n}\n\n/** The refusal of one check: `PROVIDER_ERROR`, `refused`, naming the check only. */\nexport function refused(check: string): SocialError {\n\treturn providerError('the ID token', 'refused', { check });\n}\n\n/** The algorithms the connection accepts: its pinned one, else {@link DEFAULT_ALGORITHMS}. */\nexport function algorithmsOf(\n\tpinned: ConnectionAlgorithm | undefined,\n): readonly ConnectionAlgorithm[] {\n\tif (pinned === undefined) return DEFAULT_ALGORITHMS;\n\tif (!CONNECTION_ALGORITHMS.includes(pinned)) {\n\t\tthrow new TypeError(\n\t\t\t'oidcConnections: \"client.idTokenSignedResponseAlg\" is not an accepted algorithm',\n\t\t);\n\t}\n\treturn [pinned];\n}\n\n/** The `alg` of an ID token's header, read without trusting anything else in it. */\nexport function headerAlgorithm(idToken: unknown): string {\n\tif (typeof idToken !== 'string') throw refused('alg');\n\ttry {\n\t\tconst header: unknown = JSON.parse(\n\t\t\tBuffer.from(idToken.split('.', 1)[0] ?? '', 'base64url').toString(),\n\t\t);\n\t\tconst alg = (header as { alg?: unknown } | null)?.alg;\n\t\tif (typeof alg === 'string') return alg;\n\t} catch {\n\t\t// refused below\n\t}\n\tthrow refused('alg');\n}\n\n/** Refuses an `alg` outside the list, before the signature step fetches a key. */\nexport function checkAlgorithm(\n\tidToken: unknown,\n\talgorithms: readonly ConnectionAlgorithm[],\n): string {\n\tconst alg = headerAlgorithm(idToken);\n\tif (!(algorithms as readonly string[]).includes(alg)) throw refused('alg');\n\treturn alg;\n}\n\n/** `iss`, `sub`, `azp` and `iat`: what oauth4webapi leaves open. */\nexport function checkClaims(\n\tclaims: oauth.IDToken,\n\tpolicy: IdTokenPolicy,\n\tnowSeconds: number,\n): void {\n\tif (claims.iss !== policy.issuer) throw refused('iss');\n\tconst { sub, azp, iat } = claims;\n\tif (typeof sub !== 'string' || sub === '' || sub.length > MAX_SUB) {\n\t\tthrow refused('sub');\n\t}\n\tif (azp !== undefined && azp !== policy.clientId) throw refused('azp');\n\tif (Array.isArray(claims.aud) && claims.aud.length > 1 && azp === undefined) {\n\t\tthrow refused('azp');\n\t}\n\tif (typeof iat !== 'number' || !Number.isFinite(iat)) throw refused('iat');\n\tif (iat > nowSeconds + CLOCK_TOLERANCE) throw refused('iat');\n}\n\n/** `at_hash`, when the token carries one; absent is accepted (the code flow makes it optional). */\nexport async function checkAtHash(\n\tclaims: oauth.IDToken,\n\talg: string,\n\taccessToken: string,\n): Promise<void> {\n\tconst claim = claims['at_hash'];\n\tif (claim === undefined) return;\n\tif (!(await atHashMatches(alg, claim, accessToken))) throw refused('at_hash');\n}\n\n/** The connection's fixed step-up, held by the token's own claims. */\nexport function requireStepUp(\n\tclaims: oauth.IDToken,\n\tstepUp: FixedStepUp | undefined,\n\tnowMs: number,\n): void {\n\tif (stepUp === undefined) return;\n\tif (!holdsStepUp(claims, stepUp.acrValues, stepUp.maxAge, nowMs)) {\n\t\tthrow new SocialError(\n\t\t\t'SOCIAL_STEP_UP_UNMET',\n\t\t\t'the ID token: the identity provider did not prove the step-up this provider requires',\n\t\t);\n\t}\n}\n",
24
+ "/**\n * The ID token's `at_hash` (OpenID Connect Core §3.1.3.6): the left half of\n * the hash of the access token's ASCII octets, base64url encoded. oauth4webapi\n * does not read it (no `at_hash` in its 3.8.8 source), so it is checked here.\n */\n\nimport { timingSafeEqual } from 'node:crypto';\n\ntype Hash = 'SHA-256' | 'SHA-384' | 'SHA-512';\n\n/**\n * The hash a signature algorithm names: the size in its name for `RS`, `PS`\n * and `ES`; SHA-512 for `EdDSA`, which is what the OpenID Foundation's EdDSA\n * profile says for Ed25519. Ed448 (SHAKE256) is not supported: oauth4webapi's\n * key selection only takes an `Ed25519` key for `EdDSA`, so an Ed448 token\n * never verifies. `undefined` for any other algorithm.\n */\nexport function atHashAlgorithm(alg: string): Hash | undefined {\n\tif (alg === 'EdDSA') return 'SHA-512';\n\tconst size = /^(?:RS|PS|ES)(256|384|512)$/.exec(alg)?.[1];\n\treturn size === undefined ? undefined : (`SHA-${size}` as Hash);\n}\n\n/** The `at_hash` of an access token for the algorithm the ID token was signed with. */\nexport async function atHashOf(\n\talg: string,\n\taccessToken: string,\n): Promise<string | undefined> {\n\tconst hash = atHashAlgorithm(alg);\n\t// The access token is ASCII (RFC 6749 §A.12); anything else cannot have been hashed that way.\n\tif (hash === undefined || !/^[\\x20-\\x7e]+$/.test(accessToken)) return;\n\tconst digest = await crypto.subtle.digest(\n\t\thash,\n\t\tnew TextEncoder().encode(accessToken),\n\t);\n\treturn Buffer.from(digest.slice(0, digest.byteLength / 2)).toString(\n\t\t'base64url',\n\t);\n}\n\n/**\n * Whether `claim` (the ID token's `at_hash`) is the hash of `accessToken`,\n * compared in constant time. A claim that is not a string, or an algorithm\n * with no hash, does not match.\n */\nexport async function atHashMatches(\n\talg: string,\n\tclaim: unknown,\n\taccessToken: string,\n): Promise<boolean> {\n\tif (typeof claim !== 'string') return false;\n\tconst expected = await atHashOf(alg, accessToken);\n\tif (expected === undefined) return false;\n\tconst given = Buffer.from(claim);\n\tconst wanted = Buffer.from(expected);\n\treturn given.length === wanted.length && timingSafeEqual(given, wanted);\n}\n",
25
+ "/** The steps a connection hands to the code exchange, built from its {@link IdTokenPolicy}. */\n\nimport type { IdTokenSteps } from '../code-exchange';\nimport {\n\talgorithmsOf,\n\tCLOCK_TOLERANCE,\n\tcheckAlgorithm,\n\tcheckAtHash,\n\tcheckClaims,\n\theaderAlgorithm,\n\ttype IdTokenPolicy,\n\trequireStepUp,\n} from './id-token';\n\n/**\n * The exchange's extra steps for a connection. `verifyKeys` is the connection\n * server's `verifySignature`. Throws a `TypeError` at wiring when the\n * pinned algorithm is not an accepted one.\n *\n * Order, in the exchange: oauth4webapi's checks (which read the claims, but\n * answer nothing), the `alg` against the accepted list, the signature, then\n * our claim checks: no claim is trusted, or handed on, before the signature\n * holds.\n */\nexport function idTokenSteps(\n\tpolicy: IdTokenPolicy,\n\tverifyKeys: (answer: Response) => Promise<void>,\n): IdTokenSteps {\n\tconst algorithms = algorithmsOf(policy.algorithm);\n\tconst now = policy.now ?? Date.now;\n\t/** The `alg` the signature step already read, by token response, so the header is parsed once. */\n\tconst read = new WeakMap<object, string>();\n\treturn {\n\t\tclientExtras: {\n\t\t\tclockTolerance: CLOCK_TOLERANCE,\n\t\t\t...(policy.algorithm === undefined\n\t\t\t\t? {}\n\t\t\t\t: { idTokenSignedResponseAlg: policy.algorithm }),\n\t\t},\n\t\tasync verifySignature(answer, tokens) {\n\t\t\tread.set(tokens, checkAlgorithm(tokens.id_token, algorithms));\n\t\t\tawait verifyKeys(answer);\n\t\t},\n\t\tasync checkIdToken(tokens, claims) {\n\t\t\tconst nowMs = now();\n\t\t\tcheckClaims(claims, policy, Math.floor(nowMs / 1000));\n\t\t\tawait checkAtHash(\n\t\t\t\tclaims,\n\t\t\t\tread.get(tokens) ?? headerAlgorithm(tokens.id_token),\n\t\t\t\ttokens.access_token,\n\t\t\t);\n\t\t\trequireStepUp(claims, policy.stepUp, nowMs);\n\t\t},\n\t};\n}\n",
26
+ "/** The `SocialProvider` of one connection record, on the same engine as the presets. */\n\nimport type { SocialProvider } from '@softistx/janus';\nimport { createOidcProvider } from '../oidc-engine';\nimport { DEFAULT_SCOPES } from './check';\nimport { connectionIdentity } from './claims';\nimport type { IdTokenPolicy } from './id-token';\nimport { idTokenSteps } from './id-token-steps';\nimport type { ConnectionServers } from './server';\nimport type { OidcConnection } from './types';\n\n/** What every provider of one facade shares. */\nexport interface ProviderWiring {\n\treadonly servers: ConnectionServers;\n\treadonly redirectUri: string;\n}\n\n/**\n * What the ID token must prove, read from a record that already passed\n * `checkConnection`. No `now`: oauth4webapi checks `exp` and `nbf` on the\n * system clock, and the claim checks must read that same clock; the facade's\n * `clock` option only drives the caches.\n */\nfunction policyOf(connection: OidcConnection): IdTokenPolicy {\n\treturn {\n\t\tissuer: connection.issuer,\n\t\tclientId: connection.client.id,\n\t\talgorithm: connection.client.idTokenSignedResponseAlg,\n\t\tstepUp: connection.stepUp,\n\t};\n}\n\n/**\n * Builds the provider of a record that passed `checkConnection` (call it\n * first: this trusts the record). Throws a `TypeError` when the ID token\n * steps cannot be wired from it, so the caller can refuse the record up\n * front rather than at request time.\n *\n * There is one way to build the exchange: the server, its transport and the\n * signature check all come from one `servers(connection)` lookup, since\n * oauth4webapi keys its key cache on that server object, and `idToken` is\n * always set, so the signature is always verified. The provider holds no\n * `fetch` of its own: every request goes through the guarded transport of\n * the server lookup. Claims go through\n * `connectionIdentity`, never a preset's mapping.\n */\nexport function connectionProvider(\n\tconnection: OidcConnection,\n\twiring: ProviderWiring,\n): SocialProvider {\n\tconst policy = policyOf(connection);\n\tidTokenSteps(policy, async () => {}); // wiring errors surface here, not on a request\n\tconst scopes = connection.scopes ?? DEFAULT_SCOPES;\n\treturn createOidcProvider({\n\t\tcredentials: {\n\t\t\tclientId: connection.client.id,\n\t\t\tclientSecret: connection.client.secret,\n\t\t\tredirectUri: wiring.redirectUri,\n\t\t},\n\t\tsecurity: connection,\n\t\tscopes: scopes.includes('openid') ? scopes : ['openid', ...scopes],\n\t\t...(connection.client.authentication === undefined\n\t\t\t? {}\n\t\t\t: { authentication: connection.client.authentication }),\n\t\tperRequestStepUp: true,\n\t\t...(connection.stepUp === undefined\n\t\t\t? {}\n\t\t\t: { fixedStepUp: connection.stepUp }),\n\t\tsession: async () => {\n\t\t\tconst found = await wiring.servers(connection);\n\t\t\treturn {\n\t\t\t\tserver: found.as,\n\t\t\t\thttp: found.http,\n\t\t\t\tidToken: idTokenSteps(policy, found.verifySignature),\n\t\t\t};\n\t\t},\n\t\tidentity: (claims) =>\n\t\t\tconnectionIdentity(connection, claims, 'the ID token'),\n\t});\n}\n",
27
+ "/**\n * The authorization server of a connection: its discovered metadata and the\n * way to check a signature against its keys, for the ID token checks.\n */\n\nimport { type Clock, systemClock } from '@softistx/janus';\nimport * as oauth from 'oauth4webapi';\nimport { inStep, providerError } from '../failure';\nimport type { SocialFetch } from '../options';\nimport { transport } from '../transport';\nimport { DEFAULT_MAX_BYTES, LARGE_MAX_BYTES } from './body-limit';\nimport { discoverIssuer } from './discovery';\nimport {\n\tGUARD_TIMEOUT,\n\ttype GuardedFetchOptions,\n\tguardedFetch,\n} from './guarded-fetch';\nimport { checkIssuer } from './issuer';\nimport { createIssuerCache, type IssuerCacheSetting } from './issuer-cache';\nimport { keyFlights } from './key-flights';\nimport type { OidcConnection } from './types';\nimport type { AllowUrl } from './url-policy';\n\nexport interface ServerOptions {\n\t/**\n\t * The `fetch` to call once a request passes the guard; the global one when\n\t * absent. It must honour `init.redirect` (the guard sends `'manual'`) and\n\t * `init.signal` (the guard's timeout), like the platform's.\n\t */\n\treadonly fetch?: SocialFetch;\n\t/** Milliseconds per request, body included. Default 10 000. */\n\treadonly timeout?: number;\n\t/** Narrows the URL policy; it can never widen it. */\n\treadonly allowUrl?: AllowUrl;\n\t/** Resolves a host to all its addresses; `node:dns` by default. */\n\treadonly resolveHost?: GuardedFetchOptions['resolveHost'];\n\treadonly cache?: IssuerCacheSetting;\n\t/** The time of the cache; the system clock when absent. */\n\treadonly clock?: Clock;\n}\n\n/** What a connection's issuer gave, valid until the metadata cache drops it. */\nexport interface ConnectionServer {\n\t/**\n\t * The discovered metadata, every endpoint already through the URL policy.\n\t * **The same object** until the metadata is refetched (1 h): oauth4webapi\n\t * keys its key cache on this object's identity, so always pass this one.\n\t */\n\treadonly as: oauth.AuthorizationServer;\n\t/**\n\t * Request options for oauth4webapi calls to this server's endpoints: the\n\t * guarded fetch (64 KiB cap) and the timeout.\n\t */\n\treadonly http: ReturnType<typeof transport>;\n\t/**\n\t * Checks the signature of the ID token in `ref` (the token response that\n\t * `processAuthorizationCodeResponse` returned) against the issuer's keys,\n\t * fetched through the guard (256 KiB cap). oauth4webapi keeps the key set\n\t * per `as`: an unknown `kid` refetches it only when the kept set is 60 s\n\t * old or more, and a set 300 s old or more is never used.\n\t */\n\tverifySignature(ref: Response): Promise<void>;\n}\n\n/** Looks up a connection's server: cached per issuer, one lookup in flight at a time. */\nexport type ConnectionServers = (\n\tconnection: Pick<OidcConnection, 'issuer'>,\n) => Promise<ConnectionServer>;\n\n/** What WebCrypto throws for a published key it cannot import or use. */\nfunction isMalformedKey(failure: unknown): boolean {\n\treturn (\n\t\tfailure instanceof DOMException &&\n\t\t(failure.name === 'DataError' ||\n\t\t\tfailure.name === 'NotSupportedError' ||\n\t\t\tfailure.name === 'OperationError')\n\t);\n}\n\n/** Margin added to the request timeout before a pending lookup stops being shared. */\nconst PENDING_MARGIN_MS = 5_000;\n\nexport function connectionServers(\n\toptions: ServerOptions = {},\n): ConnectionServers {\n\tconst guard = {\n\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t...(options.timeout === undefined ? {} : { timeout: options.timeout }),\n\t\t...(options.allowUrl === undefined ? {} : { allowUrl: options.allowUrl }),\n\t\t...(options.resolveHost === undefined\n\t\t\t? {}\n\t\t\t: { resolveHost: options.resolveHost }),\n\t};\n\tconst clock = options.clock ?? systemClock;\n\tconst flights = keyFlights(clock);\n\t// Metadata is capped at 64 KiB; the key set and userinfo, known once discovered, at 256 KiB.\n\tconst http = transport(guardedFetch(guard), options.timeout);\n\tconst cache = createIssuerCache<ConnectionServer>(clock, {\n\t\t...options.cache,\n\t\tpendingMs: (options.timeout ?? GUARD_TIMEOUT) + PENDING_MARGIN_MS,\n\t});\n\treturn ({ issuer }) => {\n\t\tconst problems: string[] = [];\n\t\tcheckIssuer(problems, issuer);\n\t\tif (problems.length > 0) {\n\t\t\treturn Promise.reject(providerError('discovery', 'refused'));\n\t\t}\n\t\treturn cache.get(issuer, async () => {\n\t\t\tconst as = await discoverIssuer(issuer, http, options.allowUrl);\n\t\t\t// The guard compares `url.href`, so the set holds hrefs, not the document's raw strings.\n\t\t\tconst large = new Set(\n\t\t\t\t[as.jwks_uri, as.userinfo_endpoint]\n\t\t\t\t\t.filter((value) => value !== undefined)\n\t\t\t\t\t.map((value) => new URL(value).href),\n\t\t\t);\n\t\t\tconst sized = guardedFetch({\n\t\t\t\t...guard,\n\t\t\t\tmaxBytes: (url) =>\n\t\t\t\t\tlarge.has(url.href) ? LARGE_MAX_BYTES : DEFAULT_MAX_BYTES,\n\t\t\t});\n\t\t\tconst sizedHttp = transport(sized, options.timeout);\n\t\t\tconst keys = transport(flights(sized), options.timeout);\n\t\t\treturn {\n\t\t\t\tas,\n\t\t\t\thttp: sizedHttp,\n\t\t\t\tverifySignature: (ref) =>\n\t\t\t\t\tinStep('the ID token signature', async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait oauth.validateApplicationLevelSignature(as, ref, keys);\n\t\t\t\t\t\t} catch (failure) {\n\t\t\t\t\t\t\t// A key the provider published that WebCrypto cannot import is its fault, not a network one.\n\t\t\t\t\t\t\tif (isMalformedKey(failure)) {\n\t\t\t\t\t\t\t\tthrow providerError('the ID token signature', 'refused');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow failure;\n\t\t\t\t\t\t}\n\t\t\t\t\t}),\n\t\t\t};\n\t\t});\n\t};\n}\n",
28
+ "/** Ends a wait when a signal stops, even if the thing waited on ignores it. */\n\n/**\n * Settles as `promise` does, or rejects with the signal's reason once it\n * aborts. A value that arrives after the abort is handed to `discard`, so a\n * late response's body can be cancelled instead of left open.\n */\nexport function untilAborted<T>(\n\tpromise: Promise<T>,\n\tsignal: AbortSignal,\n\tdiscard?: (late: T) => void,\n): Promise<T> {\n\treturn new Promise<T>((resolve, reject) => {\n\t\tif (signal.aborted) {\n\t\t\tif (discard !== undefined) promise.then(discard, () => undefined);\n\t\t\treturn reject(signal.reason);\n\t\t}\n\t\tconst stop = () => {\n\t\t\tif (discard !== undefined) promise.then(discard, () => undefined);\n\t\t\treject(signal.reason);\n\t\t};\n\t\tsignal.addEventListener('abort', stop, { once: true });\n\t\tpromise.then(resolve, reject).finally(() => {\n\t\t\tsignal.removeEventListener('abort', stop);\n\t\t});\n\t});\n}\n",
29
+ "/** What an answer may be: JSON, and no larger than a cap. */\n\nimport { GuardError } from '../guard-error';\nimport { untilAborted } from './abort';\n\n/** Bytes an answer may hold when the caller names no other cap. */\nexport const DEFAULT_MAX_BYTES = 64 * 1024;\n/** Bytes a key set or a userinfo answer may hold. */\nexport const LARGE_MAX_BYTES = 256 * 1024;\n\n/** `application/json`, or a structured `application/*+json` (`jwk-set+json`), parameters ignored. */\nexport function isJson(contentType: string | null): boolean {\n\tconst type = (contentType ?? '').split(';')[0]?.trim().toLowerCase() ?? '';\n\treturn /^application\\/(?:[a-z0-9.!#$&^_-]+\\+)?json$/.test(type);\n}\n\n/**\n * Reads the answer into memory, refusing past `max` bytes: `Content-Length`\n * first, then the count of the stream, which is cancelled at the first byte\n * over. Returns a new `Response` holding the buffered body, which the\n * caller (oauth4webapi) reads as usual. A stopped `signal` ends the read.\n */\nexport async function capped(\n\tresponse: Response,\n\tmax: number,\n\tsignal: AbortSignal,\n): Promise<Response> {\n\tconst declared = response.headers.get('content-length');\n\tif (declared !== null && Number(declared) > max) {\n\t\tawait response.body?.cancel().catch(() => undefined);\n\t\tthrow new GuardError('oversize');\n\t}\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\tconst reader = response.body?.getReader();\n\twhile (reader !== undefined) {\n\t\tconst { done, value } = await untilAborted(reader.read(), signal).catch(\n\t\t\tasync (stop: unknown) => {\n\t\t\t\tawait reader.cancel().catch(() => undefined);\n\t\t\t\tthrow stop;\n\t\t\t},\n\t\t);\n\t\tif (done) break;\n\t\ttotal += value.byteLength;\n\t\tif (total > max) {\n\t\t\tawait reader.cancel().catch(() => undefined);\n\t\t\tthrow new GuardError('oversize');\n\t\t}\n\t\tchunks.push(value);\n\t}\n\tconst body = new Uint8Array(total);\n\tlet offset = 0;\n\tfor (const chunk of chunks) {\n\t\tbody.set(chunk, offset);\n\t\toffset += chunk.byteLength;\n\t}\n\tconst headers = new Headers(response.headers);\n\theaders.delete('content-length');\n\theaders.delete('content-encoding');\n\tconst empty = total === 0 && [101, 204, 205, 304].includes(response.status);\n\treturn new Response(empty ? null : body, {\n\t\tstatus: response.status,\n\t\tstatusText: response.statusText,\n\t\theaders,\n\t});\n}\n",
30
+ "/** Discovery of a connection's issuer through the guarded transport. */\n\nimport * as oauth from 'oauth4webapi';\nimport { inStep, providerError } from '../failure';\nimport type { transport } from '../transport';\nimport { type AllowUrl, urlRefusal } from './url-policy';\n\n/** The metadata members that name an endpoint this server will call. */\nconst REQUIRED = [\n\t'authorization_endpoint',\n\t'token_endpoint',\n\t'jwks_uri',\n] as const;\n\n/**\n * Reads the issuer's discovery document and refuses it, as a\n * `PROVIDER_ERROR` with reason `refused`, unless:\n * - its `issuer` equals the configured one **byte for byte** (oauth4webapi\n * compares the parsed URLs, which would let `https://a.test` pass for\n * `https://a.test/`);\n * - the endpoints a sign-in needs (authorization, token, `jwks_uri`) are\n * there, and every endpoint it names (those, PAR and userinfo) passes the\n * URL policy, so a hostile document cannot aim the server at `http:`, a\n * private address or the metadata service;\n * - `none` is not among the ID token signature algorithms.\n *\n * The failure carries no URL and no part of the document.\n */\nexport function discoverIssuer(\n\tissuer: string,\n\thttp: ReturnType<typeof transport>,\n\tallowUrl: AllowUrl | undefined,\n): Promise<oauth.AuthorizationServer> {\n\treturn inStep('discovery', async () => {\n\t\tconst url = new URL(issuer);\n\t\tconst as = await oauth.processDiscoveryResponse(\n\t\t\turl,\n\t\t\tawait oauth.discoveryRequest(url, { algorithm: 'oidc', ...http }),\n\t\t);\n\t\tif (as.issuer !== issuer) throw providerError('discovery', 'refused');\n\t\tfor (const name of REQUIRED) {\n\t\t\tif (typeof as[name] !== 'string')\n\t\t\t\tthrow providerError('discovery', 'refused');\n\t\t}\n\t\tfor (const value of urlMembers(as)) {\n\t\t\tif (!allowed(value, allowUrl))\n\t\t\t\tthrow providerError('discovery', 'refused');\n\t\t}\n\t\tconst algs = as.id_token_signing_alg_values_supported;\n\t\tif (algs !== undefined && (!Array.isArray(algs) || algs.includes('none'))) {\n\t\t\tthrow providerError('discovery', 'refused');\n\t\t}\n\t\treturn as;\n\t});\n}\n\n/**\n * Every member that holds a URL the server or a visitor may be sent to: the\n * names ending in `_endpoint` or `_uri`, `check_session_iframe` and each\n * `mtls_endpoint_aliases` value. A value that is not a string is kept as is,\n * so `allowed` refuses it.\n */\nfunction urlMembers(as: oauth.AuthorizationServer): unknown[] {\n\tconst found: unknown[] = [];\n\tfor (const [name, value] of Object.entries(as)) {\n\t\tif (\n\t\t\tname.endsWith('_endpoint') ||\n\t\t\tname.endsWith('_uri') ||\n\t\t\tname === 'check_session_iframe'\n\t\t) {\n\t\t\tfound.push(value);\n\t\t} else if (name === 'mtls_endpoint_aliases') {\n\t\t\tif (typeof value !== 'object' || value === null) found.push(value);\n\t\t\telse found.push(...Object.values(value));\n\t\t}\n\t}\n\treturn found;\n}\n\nfunction allowed(value: unknown, allowUrl: AllowUrl | undefined): boolean {\n\tif (typeof value !== 'string') return false;\n\ttry {\n\t\treturn urlRefusal(new URL(value), allowUrl) === undefined;\n\t} catch {\n\t\treturn false;\n\t}\n}\n",
31
+ "/** Parsing and ranges of IP literals, no I/O. */\n\ntype V4 = readonly [number, number, number, number];\n\n/** A canonical dotted-decimal IPv4 address, or `undefined`. */\nexport function parseV4(text: string): V4 | undefined {\n\tconst parts = text.split('.');\n\tif (parts.length !== 4) return undefined;\n\tconst bytes: number[] = [];\n\tfor (const part of parts) {\n\t\tif (!/^(?:0|[1-9]\\d{0,2})$/.test(part)) return undefined;\n\t\tconst value = Number(part);\n\t\tif (value > 255) return undefined;\n\t\tbytes.push(value);\n\t}\n\treturn bytes as unknown as V4;\n}\n\n/** An IPv6 address (brackets and a dotted IPv4 tail allowed) as eight 16-bit groups, or `undefined`. */\nexport function parseV6(text: string): readonly number[] | undefined {\n\tlet source = text.replace(/^\\[|\\]$/g, '');\n\tif (!source.includes(':') || source.includes('%')) return undefined;\n\tconst tail = source.slice(source.lastIndexOf(':') + 1);\n\tif (tail.includes('.')) {\n\t\tconst v4 = parseV4(tail);\n\t\tif (v4 === undefined) return undefined;\n\t\tconst hex = (a: number, b: number) => ((a << 8) | b).toString(16);\n\t\tsource = `${source.slice(0, source.length - tail.length)}${hex(v4[0], v4[1])}:${hex(v4[2], v4[3])}`;\n\t}\n\tconst halves = source.split('::');\n\tif (halves.length > 2) return undefined;\n\tconst groups = (side: string) => (side === '' ? [] : side.split(':'));\n\tconst head = groups(halves[0] ?? '');\n\tconst rest = halves.length === 2 ? groups(halves[1] ?? '') : [];\n\tconst missing = 8 - head.length - rest.length;\n\tif (halves.length === 2 ? missing < 1 : missing !== 0) return undefined;\n\tconst all = [\n\t\t...head,\n\t\t...Array(halves.length === 2 ? missing : 0).fill('0'),\n\t\t...rest,\n\t];\n\tif (\n\t\tall.length !== 8 ||\n\t\t!all.every((group) => /^[0-9a-f]{1,4}$/i.test(group))\n\t) {\n\t\treturn undefined;\n\t}\n\treturn all.map((group) => Number.parseInt(group, 16));\n}\n\n/** Whether a public host may own this IPv4 address. */\nexport function publicV4([a, b, c]: V4): boolean {\n\tif (a === 0 || a === 10 || a === 127 || a >= 224) return false;\n\tif (a === 100 && b >= 64 && b <= 127) return false; // CGNAT 100.64/10\n\tif (a === 169 && b === 254) return false; // link-local, cloud metadata\n\tif (a === 172 && b >= 16 && b <= 31) return false;\n\tif (a === 192 && b === 168) return false;\n\tif (a === 192 && b === 88 && c === 99) return false; // 6to4 relay anycast\n\tif (a === 192 && b === 0 && (c === 0 || c === 2)) return false; // 192.0.0/24, TEST-NET-1\n\tif (a === 198 && (b === 18 || b === 19)) return false; // benchmarking\n\tif (a === 198 && b === 51 && c === 100) return false; // TEST-NET-2\n\tif (a === 203 && b === 0 && c === 113) return false; // TEST-NET-3\n\treturn true;\n}\n\nconst embedded = (high: number, low: number): V4 => [\n\thigh >> 8,\n\thigh & 0xff,\n\tlow >> 8,\n\tlow & 0xff,\n];\n\n/** Whether a public host may own this IPv6 address (eight groups). */\nexport function publicV6(g: readonly number[]): boolean {\n\tconst [g0, g1, g2, g3, g4, g5, g6, g7] = g as [\n\t\tnumber,\n\t\tnumber,\n\t\tnumber,\n\t\tnumber,\n\t\tnumber,\n\t\tnumber,\n\t\tnumber,\n\t\tnumber,\n\t];\n\t// ::, ::1 and the IPv4-compatible ::a.b.c.d\n\tif ([g0, g1, g2, g3, g4, g5].every((group) => group === 0)) return false;\n\t// IPv4-mapped ::ffff:a.b.c.d\n\tif ([g0, g1, g2, g3, g4].every((group) => group === 0) && g5 === 0xffff) {\n\t\treturn publicV4(embedded(g6, g7));\n\t}\n\t// SIIT ::ffff:0:a.b.c.d (::ffff:0:0/96)\n\tif (\n\t\t[g0, g1, g2, g3].every((group) => group === 0) &&\n\t\tg4 === 0xffff &&\n\t\tg5 === 0\n\t) {\n\t\treturn publicV4(embedded(g6, g7));\n\t}\n\tif (g0 === 0x3fff && g1 < 0x1000) return false; // documentation 3fff::/20\n\t// NAT64 64:ff9b::/96 carries its IPv4; 64:ff9b:1::/48 is local-use\n\tif (g0 === 0x64 && g1 === 0xff9b) {\n\t\tif (g2 === 0 && g3 === 0 && g4 === 0 && g5 === 0) {\n\t\t\treturn publicV4(embedded(g6, g7));\n\t\t}\n\t\treturn g2 !== 1;\n\t}\n\t// 6to4 2002::/16 carries its IPv4 in the next 32 bits\n\tif (g0 === 0x2002) return publicV4(embedded(g1, g2));\n\tif (g0 === 0x2001 && g1 === 0) return false; // Teredo\n\tif (g0 === 0x2001 && g1 === 0xdb8) return false; // documentation\n\tif (g0 === 0x2001 && g1 === 2 && g2 === 0) return false; // benchmarking 2001:2::/48\n\tif (g0 === 0x2001 && (g1 & 0xfff0) === 0x10) return false; // ORCHID 2001:10::/28\n\tif (g0 === 0x2001 && (g1 & 0xfff0) === 0x20) return false; // ORCHIDv2 2001:20::/28\n\tif (g0 === 0x100 && g1 === 0 && g2 === 0 && g3 === 0) return false; // discard\n\tif ((g0 & 0xfe00) === 0xfc00) return false; // ULA fc00::/7\n\tif ((g0 & 0xffc0) === 0xfe80) return false; // link-local fe80::/10\n\tif ((g0 & 0xffc0) === 0xfec0) return false; // site-local fec0::/10\n\tif (g0 >> 8 === 0xff) return false; // multicast\n\treturn true;\n}\n\n/** Whether an address given as text (either family) may belong to a public host. An unreadable one may not. */\nexport function publicAddress(text: string): boolean {\n\tconst v4 = parseV4(text);\n\tif (v4 !== undefined) return publicV4(v4);\n\tconst v6 = parseV6(text);\n\treturn v6 !== undefined && publicV6(v6);\n}\n",
32
+ "/**\n * What a URL the server calls on behalf of a tenant may be. Pure checks, no\n * I/O; the transport (`guarded-fetch.ts`) applies them before every request.\n *\n * The policy is the built-in one (https only, no credentials, no IP literal\n * of a loopback, private, link-local, metadata, CGNAT, ULA, unspecified,\n * multicast or reserved range, including those wrapped in IPv4-mapped,\n * NAT64 or 6to4 IPv6, no `localhost`, `*.localhost` or single-label host).\n * An application's `allowUrl` hook can only **narrow** it: it runs after the\n * built-in checks pass, and `true` never lifts a refusal.\n */\n\nimport { parseV4, parseV6, publicAddress, publicV4, publicV6 } from './ip';\n\n/** The application's extra check; `false` refuses. It cannot allow what the policy refused. */\nexport type AllowUrl = (url: URL) => boolean;\n\n/**\n * Why a URL is refused, or `undefined` when it passes. The reason is a fixed\n * word, never a part of the URL. The check reads `url.hostname`, which the\n * WHATWG parser has already canonicalised (`http://2130706433` is\n * `127.0.0.1`, `0x7f.1` too), so decimal, octal and hex forms are seen as\n * the dotted address they mean.\n */\nexport function urlRefusal(url: URL, allowUrl?: AllowUrl): string | undefined {\n\tif (url.protocol !== 'https:') return 'scheme';\n\tif (url.username !== '' || url.password !== '') return 'credentials';\n\tconst refused = hostRefusal(url.hostname);\n\tif (refused !== undefined) return refused;\n\treturn allowUrl !== undefined && allowUrl(url) !== true\n\t\t? 'allowUrl'\n\t\t: undefined;\n}\n\n/** The IP literal a hostname spells, as text, or `undefined` for a name. */\nexport function literalOf(hostname: string): string | undefined {\n\tconst host = hostname.toLowerCase();\n\tif (host.startsWith('[')) return host;\n\treturn parseV4(host) === undefined ? undefined : host;\n}\n\nfunction hostRefusal(hostname: string): string | undefined {\n\tconst host = hostname.toLowerCase().replace(/\\.$/, '');\n\tif (host === '' || host.endsWith('.')) return 'host';\n\tif (host.startsWith('[')) {\n\t\tconst groups = parseV6(host);\n\t\treturn groups !== undefined && publicV6(groups) ? undefined : 'address';\n\t}\n\tconst v4 = parseV4(host);\n\tif (v4 !== undefined) return publicV4(v4) ? undefined : 'address';\n\tif (/^[0-9.]+$/.test(host) || /(?:^|\\.)(?:0x[0-9a-f]*|\\d+)$/.test(host)) {\n\t\treturn 'host'; // a numeric form the parser did not canonicalise\n\t}\n\tif (host === 'localhost' || host.endsWith('.localhost')) return 'localhost';\n\treturn host.includes('.') ? undefined : 'single-label';\n}\n\n/**\n * Why a DNS answer is refused, or `undefined`. **Every** address must be\n * public: one private address among public ones refuses the answer, since\n * the connection may land on any of them. An empty answer is refused.\n */\nexport function addressesRefusal(\n\taddresses: readonly string[],\n): string | undefined {\n\tif (addresses.length === 0) return 'empty';\n\treturn addresses.every(publicAddress) ? undefined : 'address';\n}\n",
33
+ "/**\n * The `fetch` every request to a tenant-configured identity provider goes\n * through. Hand it to oauth4webapi as `[oauth.customFetch]`.\n *\n * Before each request the URL is checked (`urlRefusal`), its host resolved\n * and every address checked (`addressesRefusal`). The request goes out with\n * `redirect: 'manual'` and any 3xx (or opaque redirect) is refused, so a redirect never leads to\n * a host the policy did not see. The answer must be JSON and within the cap.\n * Every refusal is a `GuardError`, which the failure mapping reports as\n * `PROVIDER_ERROR` with reason `refused`, except a DNS failure (`dns`) and a\n * 5xx answer that is not JSON (`server-error`), which are `unreachable` like a\n * network error or a timeout.\n *\n * **Known limit, DNS rebinding.** We check what the host resolves to, then\n * `fetch` resolves it again to connect. A DNS server that answers a public\n * address to the check and a private one to the connection (TOCTOU) is not\n * stopped by this layer. Pinning the connection to the checked address needs\n * a runtime hook `fetch` does not offer; an egress firewall or proxy that\n * denies private ranges is the complete answer, and the application's own.\n */\n\nimport { lookup } from 'node:dns/promises';\nimport { GuardError } from '../guard-error';\nimport type { SocialFetch } from '../options';\nimport { untilAborted } from './abort';\nimport { capped, DEFAULT_MAX_BYTES, isJson } from './body-limit';\nimport {\n\ttype AllowUrl,\n\taddressesRefusal,\n\tliteralOf,\n\turlRefusal,\n} from './url-policy';\n\n/** Resolves a host to every address it has. Injected in specs; `node:dns` `lookup` by default. */\nexport type ResolveHost = (host: string) => Promise<readonly string[]>;\n\n/** Milliseconds a request may take, answer body included, when `timeout` is absent. */\nexport const GUARD_TIMEOUT = 10_000;\n\nexport interface GuardedFetchOptions {\n\t/** The `fetch` to call once a request passes; the global one when absent. */\n\treadonly fetch?: SocialFetch;\n\t/** Milliseconds per request, body included. Default 10 000. */\n\treadonly timeout?: number;\n\t/** Narrows the built-in URL policy; it can never widen it. */\n\treadonly allowUrl?: AllowUrl;\n\t/** Resolves a host to all its addresses. Default: `node:dns/promises` `lookup(host, { all: true })`. */\n\treadonly resolveHost?: ResolveHost;\n\t/**\n\t * The answer cap in bytes, or a function of the request URL so a caller\n\t * can give the key set and userinfo `LARGE_MAX_BYTES`. Default 64 KiB.\n\t */\n\treadonly maxBytes?: number | ((url: URL) => number);\n}\n\nconst dnsLookup: ResolveHost = async (host) =>\n\t(await lookup(host, { all: true })).map((entry) => entry.address);\n\n/**\n * A `fetch` that refuses what the policy refuses (see the module comment).\n * The `fetch` it wraps must honour `init.redirect` (the guard sends `'manual'`\n * and refuses any 3xx; a `fetch` that follows redirects anyway defeats the\n * check) and `init.signal` (the guard's timeout and the caller's abort).\n */\nexport function guardedFetch(options: GuardedFetchOptions = {}): SocialFetch {\n\tconst send: SocialFetch =\n\t\toptions.fetch ?? ((input, init) => fetch(input, init));\n\tconst resolveHost = options.resolveHost ?? dnsLookup;\n\treturn async (input, init) => {\n\t\tconst url = urlOf(input);\n\t\tif (urlRefusal(url, options.allowUrl) !== undefined)\n\t\t\tthrow new GuardError('url');\n\t\t// The timeout starts before the DNS step: a resolver that never answers ends it too.\n\t\tconst timeout = AbortSignal.timeout(options.timeout ?? GUARD_TIMEOUT);\n\t\tconst signals = [timeout];\n\t\tif (init?.signal) signals.push(init.signal);\n\t\tif (input instanceof Request) signals.push(input.signal);\n\t\tconst signal = AbortSignal.any(signals);\n\t\tsignal.throwIfAborted();\n\t\tawait checkAddresses(url, resolveHost, signal);\n\t\t// Raced: an injected fetch that ignores `signal` still ends at the timeout.\n\t\tconst response = await untilAborted(\n\t\t\tsend(input, { ...init, redirect: 'manual', signal }),\n\t\t\tsignal,\n\t\t\t(late) => void late.body?.cancel().catch(() => undefined),\n\t\t);\n\t\tif (\n\t\t\tresponse.type === 'opaqueredirect' ||\n\t\t\t(response.status >= 300 && response.status < 400)\n\t\t) {\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\tthrow new GuardError('redirect');\n\t\t}\n\t\tif (!isJson(response.headers.get('content-type'))) {\n\t\t\tawait response.body?.cancel().catch(() => undefined);\n\t\t\t// A server error page is the provider being down, not it answering something unusable.\n\t\t\tthrow new GuardError(\n\t\t\t\tresponse.status >= 500 ? 'server-error' : 'content-type',\n\t\t\t);\n\t\t}\n\t\tconst { maxBytes = DEFAULT_MAX_BYTES } = options;\n\t\tconst max = typeof maxBytes === 'number' ? maxBytes : maxBytes(url);\n\t\treturn capped(response, max, signal);\n\t};\n}\n\nfunction urlOf(input: string | URL | Request): URL {\n\ttry {\n\t\treturn new URL(\n\t\t\ttypeof input === 'string' || input instanceof URL ? input : input.url,\n\t\t);\n\t} catch {\n\t\tthrow new GuardError('url');\n\t}\n}\n\nasync function checkAddresses(\n\turl: URL,\n\tresolveHost: ResolveHost,\n\tsignal: AbortSignal,\n): Promise<void> {\n\t// An IP literal was checked as part of the URL; a name is resolved.\n\tif (literalOf(url.hostname) !== undefined) return;\n\tlet addresses: readonly string[];\n\ttry {\n\t\taddresses = await untilAborted(\n\t\t\tresolveHost(url.hostname.replace(/\\.$/, '')),\n\t\t\tsignal,\n\t\t);\n\t} catch {\n\t\t// A timeout or an abort is not a DNS answer: it ends as itself.\n\t\tsignal.throwIfAborted();\n\t\tthrow new GuardError('dns');\n\t}\n\tif (addressesRefusal(addresses) !== undefined)\n\t\tthrow new GuardError('address');\n}\n",
34
+ "/**\n * A per-issuer cache of what a lookup found: kept for a time, shared by\n * concurrent callers, and never poisoned by a failure.\n */\n\nimport type { Clock } from '@softistx/janus';\n\n/** How long a found value is kept: 1 hour. */\nexport const ISSUER_TTL_MS = 3_600_000;\n/** After a failure, how long a lookup fails fast without a network call: 30 seconds. */\nexport const FAILURE_COOLDOWN_MS = 30_000;\n/** Issuers kept by default. */\nexport const DEFAULT_MAX_ISSUERS = 500;\n/** Unused for this long, an issuer is dropped: 1 hour. */\nexport const DEFAULT_IDLE_MS = 3_600_000;\n\n/** The `cache` option of the connections. */\nexport interface IssuerCacheOptions {\n\t/** Issuers kept; the least recently used goes first. Default 500. */\n\treadonly max?: number;\n\t/** Milliseconds an issuer may go unused before it is dropped. Default 1 hour. */\n\treadonly idleMs?: number;\n\t/** A lookup still pending after this many milliseconds is not shared any more. */\n\treadonly pendingMs?: number;\n}\n\ninterface Entry<V> {\n\t/** The lookup in flight, then its outcome; concurrent callers share it. */\n\treadonly pending: Promise<V>;\n\tstate: 'pending' | 'found' | 'failed';\n\t/** When the lookup ended (found or failed), in clock milliseconds. */\n\tendedAt: number;\n\tusedAt: number;\n\tfailure?: unknown;\n}\n\n/** The `cache` option the application sets: `max` and `idleMs` only. */\nexport type IssuerCacheSetting = Pick<IssuerCacheOptions, 'max' | 'idleMs'>;\n\nexport interface IssuerCache<V> {\n\t/**\n\t * The value for `issuer`: the kept one, the lookup already in flight, or a\n\t * new `load()`. During the cooldown after a failure it throws that same\n\t * failure and calls nothing.\n\t */\n\tget(issuer: string, load: () => Promise<V>): Promise<V>;\n}\n\n/**\n * An LRU map with an idle limit and no timer: the order of a `Map` is the\n * recency, and an entry unused for `idleMs` is dropped on the next call.\n * The failure is kept 30 s (not the value, which a failure never is), so a\n * down provider is asked once per 30 s rather than once per sign-in.\n */\nexport function createIssuerCache<V>(\n\tclock: Clock,\n\toptions: IssuerCacheOptions = {},\n): IssuerCache<V> {\n\tconst max = options.max ?? DEFAULT_MAX_ISSUERS;\n\tconst idleMs = options.idleMs ?? DEFAULT_IDLE_MS;\n\tconst pendingMs = options.pendingMs ?? Number.POSITIVE_INFINITY;\n\tconst entries = new Map<string, Entry<V>>();\n\tconst now = (): number => clock.now().getTime();\n\n\tfunction start(issuer: string, load: () => Promise<V>, at: number): Entry<V> {\n\t\tconst entry: Entry<V> = {\n\t\t\tpending: Promise.resolve().then(load),\n\t\t\tstate: 'pending',\n\t\t\tendedAt: at,\n\t\t\tusedAt: at,\n\t\t};\n\t\tentry.pending.then(\n\t\t\t() => {\n\t\t\t\tentry.state = 'found';\n\t\t\t\tentry.endedAt = now();\n\t\t\t},\n\t\t\t(failure: unknown) => {\n\t\t\t\tentry.state = 'failed';\n\t\t\t\tentry.failure = failure;\n\t\t\t\tentry.endedAt = now();\n\t\t\t},\n\t\t);\n\t\tentries.delete(issuer);\n\t\tentries.set(issuer, entry);\n\t\tfor (const oldest of entries.keys()) {\n\t\t\tif (entries.size <= max) break;\n\t\t\tentries.delete(oldest);\n\t\t}\n\t\treturn entry;\n\t}\n\n\treturn {\n\t\tget(issuer, load) {\n\t\t\tconst at = now();\n\t\t\tfor (const [key, entry] of entries) {\n\t\t\t\tif (at - entry.usedAt >= idleMs) entries.delete(key);\n\t\t\t}\n\t\t\tconst entry = entries.get(issuer);\n\t\t\tif (entry !== undefined) {\n\t\t\t\tconst age = at - entry.endedAt;\n\t\t\t\tconst usable =\n\t\t\t\t\t(entry.state === 'pending' && age < pendingMs) ||\n\t\t\t\t\t(entry.state === 'found' && age < ISSUER_TTL_MS) ||\n\t\t\t\t\t(entry.state === 'failed' && age < FAILURE_COOLDOWN_MS);\n\t\t\t\tif (usable) {\n\t\t\t\t\tentry.usedAt = at;\n\t\t\t\t\tentries.delete(issuer);\n\t\t\t\t\tentries.set(issuer, entry);\n\t\t\t\t\treturn entry.state === 'failed'\n\t\t\t\t\t\t? Promise.reject(entry.failure)\n\t\t\t\t\t\t: entry.pending;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn start(issuer, load, at).pending;\n\t\t},\n\t};\n}\n",
35
+ "/**\n * Single flight and a short cooldown for the key set requests, which\n * oauth4webapi does not share between concurrent verifications.\n */\n\nimport type { Clock } from '@softistx/janus';\nimport type { SocialFetch } from '../options';\nimport { FAILURE_COOLDOWN_MS } from './issuer-cache';\n\ninterface Flight {\n\treadonly pending: Promise<Response>;\n\tfailure?: { readonly error: unknown; readonly at: number };\n}\n\n/**\n * Wraps a `fetch` so that concurrent requests for one URL make one request\n * (each caller gets a clone of the answer: the first caller's method, headers\n * and signal decide it, so use it for GETs only), and a request that failed\n * makes the next ones within 30 s fail the same way without a call. State is\n * per URL and shared by every wrapped `fetch`; a failed entry is dropped when\n * the next call finds it 30 s old.\n */\nexport function keyFlights(clock: Clock): (base: SocialFetch) => SocialFetch {\n\tconst flights = new Map<string, Flight>();\n\treturn (base) => async (input, init) => {\n\t\tconst url = String(\n\t\t\tinput instanceof Request\n\t\t\t\t? input.url\n\t\t\t\t: input instanceof URL\n\t\t\t\t\t? input.href\n\t\t\t\t\t: input,\n\t\t);\n\t\tconst at = clock.now().getTime();\n\t\tfor (const [key, flight] of flights) {\n\t\t\tif (\n\t\t\t\tflight.failure !== undefined &&\n\t\t\t\tat - flight.failure.at >= FAILURE_COOLDOWN_MS\n\t\t\t) {\n\t\t\t\tflights.delete(key);\n\t\t\t}\n\t\t}\n\t\tlet flight = flights.get(url);\n\t\tif (flight?.failure !== undefined) throw flight.failure.error;\n\t\tif (flight === undefined) {\n\t\t\tconst made: Flight = {\n\t\t\t\tpending: Promise.resolve().then(() => base(input, init)),\n\t\t\t};\n\t\t\tflight = made;\n\t\t\tflights.set(url, made);\n\t\t\tmade.pending.then(\n\t\t\t\t() => {\n\t\t\t\t\tif (flights.get(url) === made) flights.delete(url);\n\t\t\t\t},\n\t\t\t\t(error: unknown) => {\n\t\t\t\t\tmade.failure = { error, at: clock.now().getTime() };\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\treturn (await flight.pending).clone();\n\t};\n}\n",
36
+ "/** Wiring-time checks of the `oidcConnections` options: a bad one is a `TypeError` naming it, never its value. */\n\nimport { checkFetch, checkRedirectUri, checkTimeout } from '../check-options';\nimport { isObject } from './check';\nimport type { OidcConnectionsOptions } from './oidc-connections';\n\nconst WHERE = 'oidcConnections';\n\nfunction positive(name: string, value: unknown): void {\n\tif (value !== undefined && !(Number.isInteger(value) && Number(value) > 0)) {\n\t\tthrow new TypeError(`${WHERE}: \"cache.${name}\" must be a positive integer`);\n\t}\n}\n\n/** Throws a `TypeError` unless the options can wire a facade. */\nexport function checkOptions(\n\toptions: unknown,\n): asserts options is OidcConnectionsOptions {\n\tif (!isObject(options)) {\n\t\tthrow new TypeError(`${WHERE}: the options must be an object`);\n\t}\n\tconst source = options['source'];\n\tif (\n\t\t!isObject(source) ||\n\t\ttypeof source['findConnection'] !== 'function' ||\n\t\ttypeof source['findConnectionByDomain'] !== 'function'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${WHERE}: \"source\" must have findConnection and findConnectionByDomain`,\n\t\t);\n\t}\n\t// The credentials are the connections' own: only the shared options are checked here.\n\tcheckRedirectUri(WHERE, options['redirectUri']);\n\tcheckFetch(WHERE, options['fetch']);\n\tcheckTimeout(WHERE, options['timeout']);\n\tif (\n\t\toptions['allowUrl'] !== undefined &&\n\t\ttypeof options['allowUrl'] !== 'function'\n\t) {\n\t\tthrow new TypeError(`${WHERE}: \"allowUrl\" must be a function`);\n\t}\n\tconst cache = options['cache'];\n\tif (cache !== undefined) {\n\t\tif (!isObject(cache)) {\n\t\t\tthrow new TypeError(`${WHERE}: \"cache\" must be an object`);\n\t\t}\n\t\tpositive('max', cache['max']);\n\t\tpositive('idleMs', cache['idleMs']);\n\t}\n\tconst clock = options['clock'];\n\tif (\n\t\tclock !== undefined &&\n\t\t(!isObject(clock) || typeof clock['now'] !== 'function')\n\t) {\n\t\tthrow new TypeError(`${WHERE}: \"clock\" must have a now() method`);\n\t}\n}\n",
37
+ "/**\n * `oidcConnections`: the facade that turns the application's stored\n * connections into providers for the core's `social.resolveProvider`.\n */\n\nimport type { Clock, SocialProvider } from '@softistx/janus';\nimport { providerError } from '../failure';\nimport type { SocialFetch } from '../options';\nimport { checkConnection, isObject, PROVIDER_NAME } from './check';\nimport { domainOfEmail } from './domain';\nimport type { GuardedFetchOptions } from './guarded-fetch';\nimport type { IssuerCacheSetting } from './issuer-cache';\nimport { connectionProvider } from './provider';\nimport { connectionServers } from './server';\nimport type { ConnectionSource, OidcConnection } from './types';\nimport type { AllowUrl } from './url-policy';\nimport { checkOptions } from './wiring';\n\nexport interface OidcConnectionsOptions {\n\t/** Where the connections live: the application's own table. */\n\treadonly source: ConnectionSource;\n\t/**\n\t * The callback URL registered with every identity provider; the same for\n\t * all connections. `https`, or `http` on a loopback host.\n\t */\n\treadonly redirectUri: string;\n\t/**\n\t * The `fetch` to call once a request passes the URL guard; the global one\n\t * when absent. It must honour `init.redirect` (the guard sends `'manual'`\n\t * and refuses any 3xx) and `init.signal` (the guard's timeout).\n\t */\n\treadonly fetch?: SocialFetch;\n\t/** Milliseconds per request, body included. Default 10 000. */\n\treadonly timeout?: number;\n\t/** Narrows the URL policy (a host allow-list, say); it can never widen it. */\n\treadonly allowUrl?: AllowUrl;\n\t/** The discovery cache: issuers kept (default 500) and idle milliseconds (default 1 hour). */\n\treadonly cache?: IssuerCacheSetting;\n\t/**\n\t * The time of the discovery cache, and nothing else. The ID token's `exp`\n\t * and `nbf` are checked by oauth4webapi on the system clock, so a fixed\n\t * clock here never moves them.\n\t */\n\treadonly clock?: Clock;\n}\n\nexport interface OidcConnections {\n\t/**\n\t * Answers the provider of connection `name`, for `social.resolveProvider`.\n\t * `null` when `name` is not a provider name (it never reaches the source) or\n\t * the source has no such connection. A failure of the source\n\t * propagates untouched; a stored record that fails `checkConnection` (or\n\t * whose `id` is not `name`) is `PROVIDER_ERROR` with the reason `'refused'`\n\t * and one process warning naming the id, never a value.\n\t */\n\tresolve(name: string): Promise<SocialProvider | null>;\n\t/**\n\t * Home-realm discovery: the id of the connection that owns the domain of\n\t * `email`, or `null` (unknown domain, or not an address).\n\t */\n\tforEmail(email: string): Promise<string | null>;\n}\n\n/** The facade, with the DNS resolver of the guard replaceable (specs only). */\nexport function createConnections(\n\toptions: OidcConnectionsOptions,\n\tresolveHost?: GuardedFetchOptions['resolveHost'],\n): OidcConnections {\n\tcheckOptions(options);\n\tconst { source } = options;\n\tconst servers = connectionServers({\n\t\t...(options.fetch === undefined ? {} : { fetch: options.fetch }),\n\t\t...(options.timeout === undefined ? {} : { timeout: options.timeout }),\n\t\t...(options.allowUrl === undefined ? {} : { allowUrl: options.allowUrl }),\n\t\t...(options.cache === undefined ? {} : { cache: options.cache }),\n\t\t...(options.clock === undefined ? {} : { clock: options.clock }),\n\t\t...(resolveHost === undefined ? {} : { resolveHost }),\n\t});\n\tconst wiring = { servers, redirectUri: options.redirectUri };\n\t/** Ids whose refusal was already warned about, until they resolve fine. */\n\tconst warned = new Set<string>();\n\n\tfunction refuse(id: string) {\n\t\tif (!warned.has(id)) {\n\t\t\twarned.add(id);\n\t\t\tprocess.emitWarning(\n\t\t\t\t`oidcConnections: the stored connection \"${id}\" is malformed and is refused`,\n\t\t\t\t{ code: 'JANUS_SOCIAL_CONNECTION_REFUSED' },\n\t\t\t);\n\t\t}\n\t\treturn providerError('the connection', 'refused');\n\t}\n\n\treturn {\n\t\tasync resolve(name) {\n\t\t\tif (typeof name !== 'string' || !PROVIDER_NAME.test(name)) return null;\n\t\t\tconst stored = await source.findConnection(name);\n\t\t\tif (stored === null) {\n\t\t\t\twarned.delete(name);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet provider: SocialProvider;\n\t\t\ttry {\n\t\t\t\tconst record: OidcConnection = checkConnection(stored);\n\t\t\t\tif (record.id !== name) throw new TypeError('id mismatch');\n\t\t\t\tprovider = connectionProvider(record, wiring);\n\t\t\t} catch {\n\t\t\t\tthrow refuse(name);\n\t\t\t}\n\t\t\twarned.delete(name);\n\t\t\treturn provider;\n\t\t},\n\t\tasync forEmail(email) {\n\t\t\tif (typeof email !== 'string') return null;\n\t\t\tconst domain = domainOfEmail(email);\n\t\t\tif (domain === null) return null;\n\t\t\tconst found = await source.findConnectionByDomain(domain);\n\t\t\treturn isObject(found) &&\n\t\t\t\ttypeof found['id'] === 'string' &&\n\t\t\t\tPROVIDER_NAME.test(found['id'])\n\t\t\t\t? found['id']\n\t\t\t\t: null;\n\t\t},\n\t};\n}\n\n/**\n * The connections of an application as providers: wire `resolve` into the\n * core's `social.resolveProvider`, and use `forEmail` to send a visitor to\n * their company's sign-in. Throws a `TypeError` at construction for a bad\n * option, never later.\n */\nexport function oidcConnections(\n\toptions: OidcConnectionsOptions,\n): OidcConnections {\n\treturn createConnections(options);\n}\n",
38
+ "/** Reading a GitHub account: `GET /user` and `GET /user/emails`. */\n\nimport type { SocialIdentity } from '@softistx/janus';\nimport { providerError } from './failure';\nimport type { SocialFetch } from './options';\n\nconst API = 'https://api.github.com';\n\ninterface GithubUser {\n\tid?: unknown;\n\tname?: unknown;\n\tavatar_url?: unknown;\n}\n\ninterface GithubEmail {\n\temail?: unknown;\n\tprimary?: unknown;\n\tverified?: unknown;\n}\n\nasync function get(\n\tfetch: SocialFetch,\n\tpath: string,\n\taccessToken: string,\n): Promise<unknown> {\n\tconst answer = await fetch(`${API}${path}`, {\n\t\theaders: {\n\t\t\taccept: 'application/vnd.github+json',\n\t\t\tauthorization: `Bearer ${accessToken}`,\n\t\t\t'user-agent': 'softistx-janus-social',\n\t\t\t'x-github-api-version': '2022-11-28',\n\t\t},\n\t\tredirect: 'manual',\n\t});\n\tif (!answer.ok) throw providerError(`GitHub ${path}`, 'refused');\n\treturn answer.json();\n}\n\n/**\n * The account behind the access token. **The e-mail is the primary address,\n * and only when it is verified**: a verified secondary address is not the one\n * the account answers to, and an unverified one is anybody's claim. Without\n * such an address the identity has `email: null`.\n */\nexport async function githubIdentity(\n\taccessToken: string,\n\tfetch: SocialFetch,\n): Promise<SocialIdentity> {\n\tconst user = (await get(fetch, '/user', accessToken)) as GithubUser | null;\n\tconst id = user?.id;\n\tif (typeof id !== 'number' || !Number.isSafeInteger(id)) {\n\t\tthrow providerError('GitHub /user', 'refused');\n\t}\n\tconst emails = await get(fetch, '/user/emails', accessToken);\n\tconst primary = Array.isArray(emails)\n\t\t? (emails as GithubEmail[]).find(\n\t\t\t\t(entry) =>\n\t\t\t\t\tentry?.primary === true &&\n\t\t\t\t\tentry.verified === true &&\n\t\t\t\t\ttypeof entry.email === 'string' &&\n\t\t\t\t\tentry.email !== '',\n\t\t\t)\n\t\t: undefined;\n\tconst email = typeof primary?.email === 'string' ? primary.email : null;\n\tconst name = typeof user?.name === 'string' ? user.name : undefined;\n\tconst picture =\n\t\ttypeof user?.avatar_url === 'string' ? user.avatar_url : undefined;\n\treturn {\n\t\taccountId: String(id),\n\t\temail,\n\t\temailVerified: email !== null,\n\t\t...(name === undefined ? {} : { name }),\n\t\t...(picture === undefined ? {} : { picture }),\n\t};\n}\n",
39
+ "/** `oauth2Provider`: a plain OAuth 2.0 provider, read with its access token. */\n\nimport type { SocialProvider } from '@softistx/janus';\nimport { authorizationUrl } from './authorization-url';\nimport { checkCredentials, checkScopes, requireHttps } from './check-options';\nimport { redeem } from './code-exchange';\nimport { inStep, providerError } from './failure';\nimport type { OAuth2ProviderOptions } from './options';\nimport { clientAuth, fetcher, transport } from './transport';\n\n/**\n * A provider that speaks OAuth 2.0 and no OpenID Connect: no ID token, no\n * discovery, so you give both endpoints and `identity`, which reads the\n * account with the access token. PKCE `S256` and `state` are used; there is no\n * `nonce`. **`identity` is the only thing that vouches for the e-mail**:\n * answer `emailVerified: true` only for an address the provider itself says\n * its account holds.\n */\nexport function oauth2Provider(options: OAuth2ProviderOptions): SocialProvider {\n\tconst where = 'oauth2Provider';\n\tconst authorization = requireHttps(\n\t\twhere,\n\t\t'authorizationEndpoint',\n\t\toptions.authorizationEndpoint,\n\t);\n\trequireHttps(where, 'tokenEndpoint', options.tokenEndpoint);\n\tcheckCredentials(where, options);\n\tconst scopes = checkScopes(where, options.scopes);\n\tif (typeof options.identity !== 'function') {\n\t\tthrow new TypeError(`${where}: \"identity\" must be a function`);\n\t}\n\tconst method = options.clientAuthentication ?? 'post';\n\tif (method !== 'post' && method !== 'basic') {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"clientAuthentication\" must be 'post' or 'basic'`,\n\t\t);\n\t}\n\tconst server = {\n\t\tissuer: authorization.origin,\n\t\tauthorization_endpoint: options.authorizationEndpoint,\n\t\ttoken_endpoint: options.tokenEndpoint,\n\t};\n\tconst http = transport(options.fetch, options.timeout);\n\treturn {\n\t\tauthorizationUrl: (flow) =>\n\t\t\tauthorizationUrl(\n\t\t\t\t{\n\t\t\t\t\tendpoint: options.authorizationEndpoint,\n\t\t\t\t\tclientId: options.clientId,\n\t\t\t\t\tredirectUri: options.redirectUri,\n\t\t\t\t\tscopes,\n\t\t\t\t},\n\t\t\t\tflow,\n\t\t\t\tfalse,\n\t\t\t),\n\t\tasync exchange(flow) {\n\t\t\tconst { tokens } = await redeem(\n\t\t\t\t{\n\t\t\t\t\tclientId: options.clientId,\n\t\t\t\t\tauth: clientAuth(options.clientSecret, method),\n\t\t\t\t\tredirectUri: options.redirectUri,\n\t\t\t\t\thttp,\n\t\t\t\t\tserver,\n\t\t\t\t\toidc: false,\n\t\t\t\t},\n\t\t\t\tflow,\n\t\t\t);\n\t\t\tconst accessToken = tokens.access_token;\n\t\t\tif (typeof accessToken !== 'string' || accessToken === '') {\n\t\t\t\tthrow providerError('the token response', 'refused');\n\t\t\t}\n\t\t\treturn inStep('the account request', () =>\n\t\t\t\toptions.identity(accessToken, fetcher(options.fetch, options.timeout)),\n\t\t\t);\n\t\t},\n\t};\n}\n",
40
+ "/** `github`: GitHub through OAuth 2.0. */\n\nimport type { SocialProvider } from '@softistx/janus';\nimport { githubIdentity } from './github-identity';\nimport { oauth2Provider } from './oauth2';\nimport type { GithubOptions } from './options';\n\n/**\n * GitHub sign-in (an OAuth app or a GitHub App's user authorization). Asks for\n * `read:user` and `user:email`, with PKCE. The account is the numeric user id;\n * the e-mail is the **primary** address and only when GitHub marks it\n * **verified**, else `null`.\n */\nexport function github(options: GithubOptions): SocialProvider {\n\treturn oauth2Provider({\n\t\t...options,\n\t\tauthorizationEndpoint: 'https://github.com/login/oauth/authorize',\n\t\ttokenEndpoint: 'https://github.com/login/oauth/access_token',\n\t\tscopes: ['read:user', 'user:email'],\n\t\tidentity: githubIdentity,\n\t});\n}\n",
41
+ "/** Lazy, cached OpenID Connect discovery. */\n\nimport * as oauth from 'oauth4webapi';\nimport { inStep } from './failure';\nimport type { transport } from './transport';\n\n/**\n * Reads the provider's discovery document on first use and keeps it. **A\n * failure is not kept**: the next call asks again, so a provider that was\n * down at the first sign-in does not take the application down with it.\n * Concurrent first calls share one request.\n */\nexport function discover(\n\tissuer: string,\n\thttp: ReturnType<typeof transport>,\n): () => Promise<oauth.AuthorizationServer> {\n\tlet found: Promise<oauth.AuthorizationServer> | undefined;\n\treturn () => {\n\t\tif (found === undefined) {\n\t\t\tconst url = new URL(issuer);\n\t\t\tconst attempt = inStep('discovery', async () =>\n\t\t\t\toauth.processDiscoveryResponse(\n\t\t\t\t\turl,\n\t\t\t\t\tawait oauth.discoveryRequest(url, { algorithm: 'oidc', ...http }),\n\t\t\t\t),\n\t\t\t);\n\t\t\tfound = attempt;\n\t\t\tattempt.catch(() => {\n\t\t\t\tif (found === attempt) found = undefined;\n\t\t\t});\n\t\t}\n\t\treturn found;\n\t};\n}\n",
42
+ "/** `google`: Google through OpenID Connect. */\n\nimport type { SocialProvider } from '@softistx/janus';\nimport { checkCredentials, requireText } from './check-options';\nimport { identityOf, isTrue, text } from './claims';\nimport { discover } from './discovery';\nimport { providerError } from './failure';\nimport { createOidcProvider } from './oidc-engine';\nimport type { GoogleOptions } from './options';\nimport { transport } from './transport';\n\nconst ISSUER = 'https://accounts.google.com';\n\n/**\n * Google sign-in. The e-mail counts when the ID token's `email_verified` is\n * true. With `hostedDomain`, the sign-in is also refused unless the ID\n * token's `hd` claim is that domain — Google's `hd` request parameter is a\n * hint the visitor can edit, so the claim is what is trusted.\n */\nexport function google(options: GoogleOptions): SocialProvider {\n\tconst where = 'google';\n\tcheckCredentials(where, options);\n\tconst domain = options.hostedDomain;\n\tif (domain !== undefined) requireText(where, 'hostedDomain', domain);\n\treturn createOidcProvider({\n\t\tcredentials: options,\n\t\t// Neither honours `acr_values` (Google ignores it, Entra answers its own `acrs`).\n\t\tperRequestStepUp: false,\n\t\tscopes: ['openid', 'email', 'profile'],\n\t\tserver: discover(ISSUER, transport(options.fetch, options.timeout)),\n\t\t...(domain === undefined ? {} : { authorizationParams: { hd: domain } }),\n\t\tidentity: (claims) => {\n\t\t\tif (domain !== undefined && text(claims, 'hd') !== domain) {\n\t\t\t\tthrow providerError('the ID token', 'refused');\n\t\t\t}\n\t\t\treturn identityOf(\n\t\t\t\tclaims,\n\t\t\t\tisTrue(claims, 'email_verified'),\n\t\t\t\t'the ID token',\n\t\t\t);\n\t\t},\n\t});\n}\n",
43
+ "/**\n * Microsoft's multi-tenant issuer.\n *\n * For `common`, `organizations` and `consumers`, the discovery document's\n * issuer is the template `https://login.microsoftonline.com/{tenantid}/v2.0`,\n * and the ID token's `iss` carries the signed-in account's own tenant. A\n * strict issuer check (oauth4webapi's, rightly) can match neither, so this\n * package reads no discovery document for Microsoft: the endpoints are fixed,\n * and the issuer is built from the ID token's `tid` claim *before*\n * oauth4webapi checks `iss` against it. A GUID tenant or `consumers` is also\n * held to the tenant it names.\n */\n\nimport type * as oauth from 'oauth4webapi';\nimport { providerError } from './failure';\n\nconst LOGIN = 'https://login.microsoftonline.com';\nconst GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst DOMAIN =\n\t/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i;\n\n/** The tenant Microsoft gives every personal (consumer) account. */\nexport const CONSUMERS_TENANT = '9188040d-6c67-4c5b-b112-36a304b66dad';\n\n/** Whether `tenant` is a name Microsoft's endpoints take. */\nexport function isTenant(tenant: string): boolean {\n\treturn (\n\t\ttenant === 'common' ||\n\t\ttenant === 'organizations' ||\n\t\ttenant === 'consumers' ||\n\t\tGUID.test(tenant) ||\n\t\tDOMAIN.test(tenant)\n\t);\n}\n\n/** The server for `tenant`: fixed endpoints, and the issuer left as Microsoft's template. */\nexport function serverOf(tenant: string): oauth.AuthorizationServer {\n\tconst base = `${LOGIN}/${tenant}/oauth2/v2.0`;\n\treturn {\n\t\tissuer: `${LOGIN}/{tenantid}/v2.0`,\n\t\tauthorization_endpoint: `${base}/authorize`,\n\t\ttoken_endpoint: `${base}/token`,\n\t\ttoken_endpoint_auth_methods_supported: ['client_secret_post'],\n\t};\n}\n\n/** The tenant id an ID token claims (its payload read unverified; `iss` is checked later, against it). */\nfunction tenantOf(idToken: string): string | undefined {\n\tconst payload = idToken.split('.')[1];\n\tif (payload === undefined) return undefined;\n\ttry {\n\t\tconst claims = JSON.parse(\n\t\t\tBuffer.from(payload, 'base64url').toString('utf8'),\n\t\t) as { tid?: unknown };\n\t\treturn typeof claims.tid === 'string' && GUID.test(claims.tid)\n\t\t\t? claims.tid.toLowerCase()\n\t\t\t: undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Whether the account's tenant is one `tenant` lets in; `pinned` is a domain's resolved tenant id. */\nfunction admits(\n\ttenant: string,\n\ttid: string,\n\tpinned: string | undefined,\n): boolean {\n\tif (tenant === 'consumers') return tid === CONSUMERS_TENANT;\n\tif (tenant === 'organizations') return tid !== CONSUMERS_TENANT;\n\tif (GUID.test(tenant)) return tid === tenant.toLowerCase();\n\tif (pinned !== undefined) return tid === pinned;\n\treturn true;\n}\n\n/**\n * Resolves a domain tenant to its tenant id, once: the GUID in the issuer of\n * `<domain>/v2.0/.well-known/openid-configuration`. **Only a success is\n * kept.** Any other tenant name resolves to `undefined` and asks nothing.\n */\nexport function resolveTenant(\n\ttenant: string,\n\tfetchWith: (url: string, init: RequestInit) => Promise<Response>,\n): () => Promise<string | undefined> {\n\tif (\n\t\ttenant === 'common' ||\n\t\ttenant === 'organizations' ||\n\t\ttenant === 'consumers' ||\n\t\tGUID.test(tenant)\n\t) {\n\t\treturn async () => undefined;\n\t}\n\tlet found: string | undefined;\n\treturn async () => {\n\t\tif (found !== undefined) return found;\n\t\tconst answer = await fetchWith(\n\t\t\t`${LOGIN}/${tenant}/v2.0/.well-known/openid-configuration`,\n\t\t\t{ redirect: 'manual' },\n\t\t);\n\t\tconst body = answer.ok\n\t\t\t? ((await answer.json().catch(() => null)) as { issuer?: unknown } | null)\n\t\t\t: null;\n\t\tconst guid =\n\t\t\ttypeof body?.issuer === 'string'\n\t\t\t\t? /^https:\\/\\/login\\.microsoftonline\\.com\\/([^/]+)\\/v2\\.0$/.exec(\n\t\t\t\t\t\tbody.issuer,\n\t\t\t\t\t)?.[1]\n\t\t\t\t: undefined;\n\t\tif (guid === undefined || !GUID.test(guid)) {\n\t\t\tthrow providerError('the tenant lookup', 'refused');\n\t\t}\n\t\tfound = guid.toLowerCase();\n\t\treturn found;\n\t};\n}\n\n/**\n * The server to validate the token response against: the same endpoints, with\n * the issuer of the tenant the ID token names. An answer that is not a\n * success is left to oauth4webapi to report.\n */\nexport async function serverForTokens(\n\ttenant: string,\n\tpinned: () => Promise<string | undefined>,\n\tserver: oauth.AuthorizationServer,\n\tanswer: Response,\n): Promise<oauth.AuthorizationServer> {\n\tif (answer.status !== 200) return server;\n\tconst body = (await answer.json().catch(() => null)) as {\n\t\tid_token?: unknown;\n\t} | null;\n\tconst tid =\n\t\ttypeof body?.id_token === 'string' ? tenantOf(body.id_token) : undefined;\n\tif (tid === undefined || !admits(tenant, tid, await pinned())) {\n\t\tthrow providerError('the ID token', 'refused');\n\t}\n\treturn { ...server, issuer: `${LOGIN}/${tid}/v2.0` };\n}\n",
44
+ "/** `microsoft`: the Microsoft identity platform through OpenID Connect. */\n\nimport type { SocialProvider } from '@softistx/janus';\nimport { checkCredentials, requireText } from './check-options';\nimport { identityOf } from './claims';\nimport { inStep } from './failure';\nimport {\n\tisTenant,\n\tresolveTenant,\n\tserverForTokens,\n\tserverOf,\n} from './microsoft-tenant';\nimport { createOidcProvider } from './oidc-engine';\nimport type { MicrosoftOptions } from './options';\nimport { fetcher } from './transport';\n\n/**\n * Microsoft sign-in (work, school and personal accounts, by `tenant`).\n *\n * **The e-mail counts only when the ID token's optional `xms_edov` claim is\n * `true`** — Microsoft does not vouch for an address otherwise, and the\n * `email` claim of a work account can be set by a tenant admin to anything.\n * Add `xms_edov` to the app registration's optional ID-token claims, or every\n * Microsoft sign-in is an unverified e-mail (see the Microsoft guide). The\n * account is the token's `sub`, which is Microsoft's pairwise id for this app\n * registration.\n */\nexport function microsoft(options: MicrosoftOptions): SocialProvider {\n\tconst where = 'microsoft';\n\tcheckCredentials(where, options);\n\tconst tenant = options.tenant ?? 'common';\n\trequireText(where, 'tenant', tenant);\n\tif (!isTenant(tenant)) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: \"tenant\" must be common, organizations, consumers, a tenant id or a domain`,\n\t\t);\n\t}\n\tconst server = serverOf(tenant);\n\tconst pinned = resolveTenant(tenant, (url, init) =>\n\t\tinStep('the tenant lookup', () =>\n\t\t\tfetcher(options.fetch, options.timeout)(url, init),\n\t\t),\n\t);\n\treturn createOidcProvider({\n\t\tcredentials: options,\n\t\t// Neither honours `acr_values` (Google ignores it, Entra answers its own `acrs`).\n\t\tperRequestStepUp: false,\n\t\tscopes: ['openid', 'email', 'profile'],\n\t\tserver: async () => server,\n\t\tserverForTokens: (fixed, answer) =>\n\t\t\tserverForTokens(tenant, pinned, fixed, answer),\n\t\tidentity: (claims) =>\n\t\t\tidentityOf(claims, claims['xms_edov'] === true, 'the ID token'),\n\t});\n}\n",
45
+ "/** `oidcProvider`: any OpenID Connect provider, by its issuer. */\n\nimport type { SocialProvider } from '@softistx/janus';\nimport {\n\tcheckCredentials,\n\tcheckScopes,\n\tcheckSecurity,\n\trequireHttps,\n} from './check-options';\nimport { identityOf, isTrue } from './claims';\nimport { discover } from './discovery';\nimport { createOidcProvider } from './oidc-engine';\nimport type { OidcProviderOptions } from './options';\nimport { transport } from './transport';\n\nconst DEFAULT_SCOPES = ['openid', 'email', 'profile'];\n\n/**\n * An OpenID Connect provider, found through\n * `<issuer>/.well-known/openid-configuration` on first use. The authorization\n * code flow with PKCE; the ID token's `iss`, `aud`, `exp` and `nonce` are\n * checked, and `email_verified` decides whether its e-mail counts.\n */\nexport function oidcProvider(options: OidcProviderOptions): SocialProvider {\n\tconst where = 'oidcProvider';\n\trequireHttps(where, 'issuer', options.issuer);\n\tcheckCredentials(where, options);\n\tcheckSecurity(where, options);\n\tconst scopes = checkScopes(where, options.scopes ?? DEFAULT_SCOPES);\n\treturn createOidcProvider({\n\t\tcredentials: options,\n\t\tsecurity: options,\n\t\tscopes: scopes.includes('openid') ? scopes : ['openid', ...scopes],\n\t\tperRequestStepUp: true,\n\t\tserver: discover(options.issuer, transport(options.fetch, options.timeout)),\n\t\tidentity: (claims) =>\n\t\t\tidentityOf(claims, isTrue(claims, 'email_verified'), 'the ID token'),\n\t});\n}\n",
46
+ "/** `oidcStepUp`: an OpenID Connect tenant that enforces a step-up. */\n\nimport { SocialError, type SocialProvider } from '@softistx/janus';\nimport { checkCredentials, checkSecurity, requireHttps } from './check-options';\nimport { identityOf, isTrue } from './claims';\nimport { discover } from './discovery';\nimport { createOidcProvider } from './oidc-engine';\nimport type { OidcStepUpOptions } from './options';\nimport { checkStepUp, holdsStepUp } from './step-up';\nimport { transport } from './transport';\n\n/**\n * Sign-in, by the tenant's issuer. The e-mail counts when the ID\n * token's `email_verified` is true. With `acrValues` and `maxAge`, the\n * authorization request asks for them and the sign-in is refused unless the\n * ID token's `acr` and `auth_time` prove them: the request parameters are\n * hints the visitor can edit, so the claims are what is trusted; an unproven\n * step-up is `SOCIAL_STEP_UP_UNMET`. \"Now\" is `Date.now()` at the exchange.\n * A flow's own `stepUp` request is held too, on top of these fixed values\n * (the `acr_values` both list, the smaller `max_age`).\n */\nexport function oidcStepUp(options: OidcStepUpOptions): SocialProvider {\n\tconst where = 'oidcStepUp';\n\trequireHttps(where, 'issuer', options.issuer);\n\tcheckCredentials(where, options);\n\tcheckSecurity(where, options);\n\tconst { acrValues, maxAge } = options;\n\tcheckStepUp(where, acrValues, maxAge);\n\treturn createOidcProvider({\n\t\tcredentials: options,\n\t\tsecurity: options,\n\t\tscopes: ['openid', 'email', 'profile'],\n\t\tserver: discover(options.issuer, transport(options.fetch, options.timeout)),\n\t\tfixedStepUp: {\n\t\t\t...(acrValues === undefined ? {} : { acrValues }),\n\t\t\t...(maxAge === undefined ? {} : { maxAge }),\n\t\t},\n\t\tperRequestStepUp: true,\n\t\tidentity: (claims) => {\n\t\t\tif (!holdsStepUp(claims, acrValues, maxAge, Date.now())) {\n\t\t\t\tthrow new SocialError(\n\t\t\t\t\t'SOCIAL_STEP_UP_UNMET',\n\t\t\t\t\t'the ID token: the identity provider did not prove the step-up this provider requires',\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn identityOf(\n\t\t\t\tclaims,\n\t\t\t\tisTrue(claims, 'email_verified'),\n\t\t\t\t'the ID token',\n\t\t\t);\n\t\t},\n\t});\n}\n"
47
+ ],
48
+ "mappings": ";AAOA,IAAM,WAAW,IAAI,IAAI,CAAC,aAAa,aAAa,OAAO,CAAC;AAGrD,SAAS,WAAW,CAC1B,OACA,MACA,OAC0B;AAAA,EAC1B,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI;AAAA,IACrD,MAAM,IAAI,UAAU,GAAG,WA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AAW,WAAW;AAAA,EAC9B,YAAY,OAAO,WAAW,MAAM;AAAA,EACpC,OAAO,mBAAmB;AAAA,IACzB,aAAa;AAAA,IACb,UAAU;AAAA,IACV,QAAQ,CAAC,UAAU,SAAS,SAAS;AAAA,IACrC,QAAQ,SAAS,QAAQ,QAAQ,UAAU,QAAQ,OAAO,QAAQ,OAAO,CAAC;AAAA,IAC1E,aAAa;AAAA,SACR,cAAc,YAAY,CAAC,IAAI,EAAE,UAAU;AAAA,SAC3C,WAAW,YAAY,CAAC,IAAI,EAAE,OAAO;AAAA,IAC1C;AAAA,IACA,kBAAkB;AAAA,IAClB,UAAU,CAAC,WAAW;AAAA,MACrB,IAAI,CAAC,YAAY,QAAQ,WAAW,QAAQ,KAAK,IAAI,CAAC,GAAG;AAAA,QACxD,MAAM,IAAI,aACT,wBACA,sFACD;AAAA,MACD;AAAA,MACA,OAAO,WACN,QACA,OAAO,QAAQ,gBAAgB,GAC/B,cACD;AAAA;AAAA,EAEF,CAAC;AAAA;",
49
+ "debugId": "81FA006CA57599A964756E2164756E21",
50
+ "names": []
51
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Microsoft's multi-tenant issuer.
3
+ *
4
+ * For `common`, `organizations` and `consumers`, the discovery document's
5
+ * issuer is the template `https://login.microsoftonline.com/{tenantid}/v2.0`,
6
+ * and the ID token's `iss` carries the signed-in account's own tenant. A
7
+ * strict issuer check (oauth4webapi's, rightly) can match neither, so this
8
+ * package reads no discovery document for Microsoft: the endpoints are fixed,
9
+ * and the issuer is built from the ID token's `tid` claim *before*
10
+ * oauth4webapi checks `iss` against it. A GUID tenant or `consumers` is also
11
+ * held to the tenant it names.
12
+ */
13
+ import type * as oauth from 'oauth4webapi';
14
+ /** The tenant Microsoft gives every personal (consumer) account. */
15
+ export declare const CONSUMERS_TENANT = "9188040d-6c67-4c5b-b112-36a304b66dad";
16
+ /** Whether `tenant` is a name Microsoft's endpoints take. */
17
+ export declare function isTenant(tenant: string): boolean;
18
+ /** The server for `tenant`: fixed endpoints, and the issuer left as Microsoft's template. */
19
+ export declare function serverOf(tenant: string): oauth.AuthorizationServer;
20
+ /**
21
+ * Resolves a domain tenant to its tenant id, once: the GUID in the issuer of
22
+ * `<domain>/v2.0/.well-known/openid-configuration`. **Only a success is
23
+ * kept.** Any other tenant name resolves to `undefined` and asks nothing.
24
+ */
25
+ export declare function resolveTenant(tenant: string, fetchWith: (url: string, init: RequestInit) => Promise<Response>): () => Promise<string | undefined>;
26
+ /**
27
+ * The server to validate the token response against: the same endpoints, with
28
+ * the issuer of the tenant the ID token names. An answer that is not a
29
+ * success is left to oauth4webapi to report.
30
+ */
31
+ export declare function serverForTokens(tenant: string, pinned: () => Promise<string | undefined>, server: oauth.AuthorizationServer, answer: Response): Promise<oauth.AuthorizationServer>;
32
+ //# sourceMappingURL=microsoft-tenant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microsoft-tenant.d.ts","sourceRoot":"","sources":["../src/microsoft-tenant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAQ3C,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,yCAAyC,CAAC;AAEvE,6DAA6D;AAC7D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAQhD;AAED,6FAA6F;AAC7F,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,mBAAmB,CAQlE;AA+BD;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,GAC9D,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA+BnC;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,EACzC,MAAM,EAAE,KAAK,CAAC,mBAAmB,EACjC,MAAM,EAAE,QAAQ,GACd,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAWpC"}
@@ -0,0 +1,16 @@
1
+ /** `microsoft`: the Microsoft identity platform through OpenID Connect. */
2
+ import type { SocialProvider } from '@softistx/janus';
3
+ import type { MicrosoftOptions } from './options';
4
+ /**
5
+ * Microsoft sign-in (work, school and personal accounts, by `tenant`).
6
+ *
7
+ * **The e-mail counts only when the ID token's optional `xms_edov` claim is
8
+ * `true`** — Microsoft does not vouch for an address otherwise, and the
9
+ * `email` claim of a work account can be set by a tenant admin to anything.
10
+ * Add `xms_edov` to the app registration's optional ID-token claims, or every
11
+ * Microsoft sign-in is an unverified e-mail (see the Microsoft guide). The
12
+ * account is the token's `sub`, which is Microsoft's pairwise id for this app
13
+ * registration.
14
+ */
15
+ export declare function microsoft(options: MicrosoftOptions): SocialProvider;
16
+ //# sourceMappingURL=microsoft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microsoft.d.ts","sourceRoot":"","sources":["../src/microsoft.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAWtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGlD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CA2BnE"}
@@ -0,0 +1,13 @@
1
+ /** `oauth2Provider`: a plain OAuth 2.0 provider, read with its access token. */
2
+ import type { SocialProvider } from '@softistx/janus';
3
+ import type { OAuth2ProviderOptions } from './options';
4
+ /**
5
+ * A provider that speaks OAuth 2.0 and no OpenID Connect: no ID token, no
6
+ * discovery, so you give both endpoints and `identity`, which reads the
7
+ * account with the access token. PKCE `S256` and `state` are used; there is no
8
+ * `nonce`. **`identity` is the only thing that vouches for the e-mail**:
9
+ * answer `emailVerified: true` only for an address the provider itself says
10
+ * its account holds.
11
+ */
12
+ export declare function oauth2Provider(options: OAuth2ProviderOptions): SocialProvider;
13
+ //# sourceMappingURL=oauth2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../src/oauth2.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAGvD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CA0D7E"}