@grow-codes/oidc 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +120 -0
- package/LICENSE +202 -0
- package/NOTICE +61 -0
- package/README.md +30 -2
- package/lib/chunk-4JJJPKI5.js +233 -0
- package/lib/chunk-4JJJPKI5.js.map +1 -0
- package/lib/chunk-WO2QXDBJ.cjs +255 -0
- package/lib/chunk-WO2QXDBJ.cjs.map +1 -0
- package/lib/index.cjs +1899 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +717 -0
- package/lib/index.d.ts +717 -0
- package/lib/index.js +1748 -0
- package/lib/index.js.map +1 -0
- package/lib/testing/index.cjs +588 -0
- package/lib/testing/index.cjs.map +1 -0
- package/lib/testing/index.d.cts +280 -0
- package/lib/testing/index.d.ts +280 -0
- package/lib/testing/index.js +566 -0
- package/lib/testing/index.js.map +1 -0
- package/lib/verifier-ERmLmytF.d.cts +211 -0
- package/lib/verifier-ERmLmytF.d.ts +211 -0
- package/package.json +106 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/testing/core-ops.ts","../../src/testing/expect.ts","../../src/testing/ops.ts","../../src/testing/runner.ts","../../src/oidc/fake-idp.ts"],"names":[],"mappings":";;;;;;;;AAcO,IAAM,OAAA,GAAmC;AAAA,EAC9C,GAAA,EAAK;AAAA,IACH,MAAA,EAAQ,CAAC,MAAA,KAAW,MAAA,CAAO,MAAA,EAAO;AAAA,IAClC,IAAA,EAAM,CAAC,MAAA,KAAW,MAAA,CAAO,IAAA,EAAK;AAAA,IAC9B,aAAA,EAAe,CAAC,MAAA,KAAW,MAAA,CAAO,aAAA,EAAc;AAAA,IAChD,KAAA,EAAO,CAAC,MAAA,KAAW,MAAA,CAAO,KAAA;AAAM,GAClC;AAAA,EACA,OAAA,EAAS,CAAC,MAAA,KAAW,MAAA,CAAO,KAAA;AAC9B;ACIO,SAAS,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AA,CAAQ,cAAA,CAAe,QAAQ,IAAI,CAAA;AAC9D,IAAA,OAAO,IAAI,QAAQ,MAAM,CAAA,CAAE,mBAAmB,MAAyB,CAAA,CAAE,IAAA,CAAK,GAAA,CAAI,UAAU,CAAA;AAAA,EAC9F;AAAA;AAAA,EAGA,MAAM,IAAA,GAAsB;AAC1B,IAAA,MAAM,SAAS,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA;AACf,IAAA,IAAI,WAAW,MAAA,EAAW;AACxB,MAAA,MAAA,CAAO,mBAAA,EAAoB;AAC3B,MAAA,MAAM,IAAI,OAAA,CAAc,CAAC,OAAA,KAAY;AACnC,QAAA,MAAA,CAAO,MAAM,MAAM;AACjB,UAAA,OAAA,EAAQ;AAAA,QACV,CAAC,CAAA;AAAA,MACH,CAAC,CAAA;AAAA,IACH;AAAA,EACF;AACF","file":"index.js","sourcesContent":["// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\nimport type { HealthStatus } from \"../core/health.js\";\nimport type { CategoryOps } from \"./runner.js\";\n\n/** What the `core` scenarios need from a client (`<Service>Client` satisfies it). */\nexport interface CoreTarget {\n health(options?: { signal?: AbortSignal }): Promise<HealthStatus>;\n ping(options?: { signal?: AbortSignal }): Promise<number>;\n serverVersion(options?: { signal?: AbortSignal }): Promise<string>;\n close(): Promise<void>;\n}\n\n/** `core` ops: `health ping serverVersion close`. The client is closed after each scenario. */\nexport const coreOps: CategoryOps<CoreTarget> = {\n ops: {\n health: (client) => client.health(),\n ping: (client) => client.ping(),\n serverVersion: (client) => client.serverVersion(),\n close: (client) => client.close(),\n },\n dispose: (client) => client.close(),\n};\n","// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\nimport { inspect, isDeepStrictEqual } from \"node:util\";\nimport { TimeoutError, pollUntil } from \"../core/index.js\";\nimport type { OpContext } from \"./runner.js\";\n\n/** Step expectations (SPEC §6). Every listed key must hold. */\nexport interface Expectation {\n reveal?: string;\n equals?: unknown;\n null?: boolean;\n notNull?: boolean;\n true?: boolean;\n false?: boolean;\n error?: string;\n contains?: unknown;\n notContains?: unknown;\n count?: number;\n minCount?: number;\n sorted?: boolean;\n type?: \"string\" | \"number\" | \"boolean\" | \"object\" | \"array\";\n stringForm?: { contains?: string; notContains?: string };\n tree?: Record<string, string[]>;\n}\n\n/** Converts Maps (recursively) to plain objects for comparisons. */\nexport function toPlain(value: unknown): unknown {\n if (value instanceof Map) {\n return Object.fromEntries([...value.entries()].map(([k, v]) => [String(k), toPlain(v)]));\n }\n if (value instanceof Set) return [...value].map(toPlain);\n if (Array.isArray(value)) return value.map(toPlain);\n return value;\n}\n\n/**\n * Subset equality: objects in `expected` compare only the listed keys (recursively); arrays\n * must have the same length with element-wise subset equality; other values use strict equality.\n */\nexport function subsetEquals(actual: unknown, expected: unknown): boolean {\n const a = toPlain(actual);\n if (Array.isArray(expected)) {\n return (\n Array.isArray(a) &&\n a.length === expected.length &&\n expected.every((e, i) => subsetEquals(a[i], e))\n );\n }\n if (expected !== null && typeof expected === \"object\") {\n if (a === null || typeof a !== \"object\" || Array.isArray(a)) return false;\n const obj = a as Record<string, unknown>;\n return Object.entries(expected).every(([k, v]) => subsetEquals(obj[k], v));\n }\n return isDeepStrictEqual(a, expected);\n}\n\n/** Size used by `count`/`minCount`: arrays, maps, sets, traces (`spans`), results (`records`), objects, strings. */\nexport function sizeOf(value: unknown): number {\n if (Array.isArray(value)) return value.length;\n if (value instanceof Map || value instanceof Set) return value.size;\n if (typeof value === \"string\") return value.length;\n if (value !== null && typeof value === \"object\") {\n const obj = value as Record<string, unknown>;\n if (Array.isArray(obj.spans)) return obj.spans.length;\n if (Array.isArray(obj.records)) return obj.records.length;\n return Object.keys(obj).length;\n }\n throw new Error(`cannot count a ${value === null ? \"null\" : typeof value}`);\n}\n\n/** The language string forms checked by `stringForm`: `String()`, JSON and `util.inspect`. */\nexport function stringForms(value: unknown): string[] {\n const forms: string[] = [];\n try {\n forms.push(String(value));\n } catch {\n // objects without a string form\n }\n try {\n const json = JSON.stringify(toPlain(value));\n if (typeof json === \"string\") forms.push(json);\n } catch {\n // not serialisable\n }\n forms.push(inspect(value, { depth: 20, maxArrayLength: null, maxStringLength: null }));\n return forms;\n}\n\nfunction sortKey(item: unknown): string {\n if (typeof item === \"string\") return item;\n if (item !== null && typeof item === \"object\") {\n const obj = item as Record<string, unknown>;\n if (typeof obj.name === \"string\") return obj.name;\n if (typeof obj.id === \"string\") return obj.id;\n }\n return String(item);\n}\n\nfunction containsValue(actual: unknown, needle: unknown): boolean {\n if (typeof actual === \"string\") return typeof needle === \"string\" && actual.includes(needle);\n const list =\n actual instanceof Map ? [...actual.keys()] : actual instanceof Set ? [...actual] : actual;\n if (Array.isArray(list))\n return list.some(\n (item) =>\n isDeepStrictEqual(item, needle) ||\n (needle !== null && typeof needle === \"object\" && subsetEquals(item, needle)),\n );\n if (actual !== null && typeof actual === \"object\" && typeof needle === \"string\")\n return needle in actual;\n return false;\n}\n\nfunction typeName(value: unknown): string {\n if (Array.isArray(value)) return \"array\";\n if (value === null) return \"null\";\n return typeof value;\n}\n\ninterface SpanLike {\n spanId: string;\n parentSpanId?: string;\n name: string;\n}\n\nfunction checkTree(value: unknown, tree: Record<string, string[]>): void {\n const spans = (value as { spans?: unknown } | null)?.spans;\n if (!Array.isArray(spans)) throw new Error(\"tree: result has no spans\");\n const list = spans as SpanLike[];\n for (const [parentName, children] of Object.entries(tree)) {\n const parents = list.filter((s) => s.name === parentName);\n if (parents.length === 0) throw new Error(`tree: no span named \"${parentName}\"`);\n const ids = new Set(parents.map((p) => p.spanId));\n const actual = list\n .filter((s) => s.parentSpanId !== undefined && ids.has(s.parentSpanId))\n .map((s) => s.name);\n const absent = children.filter((c) => !actual.includes(c));\n if (absent.length > 0) {\n throw new Error(\n `tree: \"${parentName}\" lacks children ${JSON.stringify(absent)} (has ${JSON.stringify(actual)})`,\n );\n }\n }\n}\n\nfunction describe(value: unknown): string {\n return inspect(value, { depth: 4, breakLength: Infinity });\n}\n\n/** Throws an Error describing the first expectation that does not hold. */\nexport function checkExpectations(value: unknown, expect: Expectation): void {\n if (expect.reveal !== undefined) {\n const v = value as { reveal?: () => string } | null;\n if (typeof v?.reveal !== \"function\") throw new Error(\"reveal: result is not a SecretValue\");\n if (v.reveal() !== expect.reveal)\n throw new Error(\"reveal: value differs from the expected text\");\n }\n if (\"equals\" in expect && !subsetEquals(value, expect.equals)) {\n throw new Error(`equals: expected ${describe(expect.equals)}, got ${describe(value)}`);\n }\n if (expect.null === true && value !== null && value !== undefined)\n throw new Error(`null: got ${describe(value)}`);\n if (expect.notNull === true && (value === null || value === undefined))\n throw new Error(\"notNull: got null\");\n if (expect.true === true && value !== true) throw new Error(`true: got ${describe(value)}`);\n if (expect.false === true && value !== false) throw new Error(`false: got ${describe(value)}`);\n if (\"contains\" in expect && !containsValue(value, expect.contains)) {\n throw new Error(`contains: ${describe(expect.contains)} not found in ${describe(value)}`);\n }\n if (\"notContains\" in expect && containsValue(value, expect.notContains)) {\n throw new Error(`notContains: ${describe(expect.notContains)} found`);\n }\n if (expect.count !== undefined && sizeOf(value) !== expect.count) {\n throw new Error(`count: expected ${expect.count}, got ${sizeOf(value)}`);\n }\n if (expect.minCount !== undefined && sizeOf(value) < expect.minCount) {\n throw new Error(`minCount: expected >= ${expect.minCount}, got ${sizeOf(value)}`);\n }\n if (expect.sorted === true) {\n if (!Array.isArray(value)) throw new Error(\"sorted: result is not an array\");\n const keys = value.map(sortKey);\n for (let i = 1; i < keys.length; i++) {\n if ((keys[i - 1] as string) > (keys[i] as string))\n throw new Error(`sorted: \"${keys[i - 1] as string}\" before \"${keys[i] as string}\"`);\n }\n }\n if (expect.type !== undefined && typeName(value) !== expect.type) {\n throw new Error(`type: expected ${expect.type}, got ${typeName(value)}`);\n }\n if (expect.stringForm !== undefined) {\n const forms = stringForms(value);\n const { contains, notContains } = expect.stringForm;\n if (notContains !== undefined && forms.some((f) => f.includes(notContains))) {\n throw new Error(\"stringForm: the string form contains a forbidden value\");\n }\n if (contains !== undefined && !forms.some((f) => f.includes(contains))) {\n throw new Error(`stringForm: no string form contains ${JSON.stringify(contains)}`);\n }\n }\n if (expect.tree !== undefined) checkTree(value, expect.tree);\n}\n\n/** Options of {@link pollForExpectation}. */\nexport interface PollForExpectationOptions {\n /** Name used in the timeout message (default `\"poll\"`). */\n operation?: string;\n /** Default timeout when the step has no `timeoutMs` arg (default 60000 ms). */\n defaultTimeoutMs?: number;\n}\n\n/**\n * For op handlers of eventually consistent reads: calls `fn` until the step's expectation passes\n * or `args.timeoutMs` (default 60000; poll every `args.intervalMs`, default 1000) runs out, then\n * returns the last value so the runner reports the shortfall. Backends such as Tempo or\n * SkyWalking list a new service tens of seconds late. Steps without an expectation (or with\n * `expect.error`) call `fn` once; errors from `fn` are thrown at once.\n */\nexport async function pollForExpectation<T>(\n fn: () => Promise<T>,\n args: Readonly<Record<string, unknown>>,\n context: Pick<OpContext, \"step\" | \"substitute\">,\n options: PollForExpectationOptions = {},\n): Promise<T> {\n const expect = context.step.expect;\n if (expect === undefined || expect.error !== undefined) return fn();\n const expectation = context.substitute(expect);\n let last: { value: T } | undefined;\n try {\n return await pollUntil(\n async () => {\n last = { value: await fn() };\n return last.value;\n },\n (value) => {\n try {\n checkExpectations(value, expectation);\n return true;\n } catch {\n return false;\n }\n },\n {\n timeoutMs:\n typeof args.timeoutMs === \"number\"\n ? args.timeoutMs\n : (options.defaultTimeoutMs ?? 60_000),\n intervalMs: typeof args.intervalMs === \"number\" ? args.intervalMs : 1000,\n operation: options.operation ?? \"poll\",\n },\n );\n } catch (error) {\n if (error instanceof TimeoutError && last !== undefined) return last.value;\n throw error;\n }\n}\n","// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\n/**\n * Built-in op handlers by category. Each category file is included only when the service has\n * that category (`@sdk-kit:if` blocks); see `runner.ts` for the handler contract.\n */\n\nimport { coreOps } from \"./core-ops.js\";\nimport type { CategoryOps } from \"./runner.js\";\n\n/** Built-in handlers: `core` always, plus the service's categories. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const builtinOps: Readonly<Record<string, CategoryOps<any>>> = Object.freeze({\n core: coreOps,\n});\n","// Generated by sdk-kit 0.3.0 — do not edit; change sdk-kit and run \"sdk-kit sync\"\n\n/**\n * Conformance runner (SPEC §6): loads `conformance/scenarios/*.json`, runs the scenarios of the\n * selected categories against targets built by factories, and returns a report.\n *\n * ## Op handler contract (for category op files)\n *\n * Each category ships one file `src/testing/<category>-ops.ts` that exports a\n * {@link CategoryOps} object named `<category>Ops` (`coreOps`, `secretsOps`, `loggingOps`,\n * `tracingOps`) plus the target type its factory returns (`LoggingTarget`, `TracingTarget`).\n * `src/testing/ops.ts` wires the built-in files into {@link builtinOps} with `@sdk-kit:if`\n * blocks. Services can add or override ops at run time with {@link registerOps} or the\n * `ops` option of {@link runConformance}.\n *\n * A handler receives the target, the step `args` with every `${var}` already substituted\n * (`#{i}` is left for the handler), and an {@link OpContext}. It returns the op result; the\n * runner evaluates `expect` on it (or on the thrown error's `code` for `expect.error`) and\n * stores it under `save`.\n */\n\nimport { readFileSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { checkExpectations, type Expectation } from \"./expect.js\";\nimport { builtinOps } from \"./ops.js\";\n\n/** Scenario categories. */\nexport type Category = \"core\" | \"secrets\" | \"logging\" | \"tracing\";\n\n/** One step of a scenario file. */\nexport interface ScenarioStep {\n op: string;\n args?: Record<string, unknown>;\n expect?: Expectation;\n save?: string;\n requires?: string[];\n}\n\n/** A scenario file (`spec/schemas/scenario.schema.json`). */\nexport interface Scenario {\n id: string;\n category: Category;\n description?: string;\n requires?: string[];\n batchOptions?: Record<string, unknown>;\n steps: ScenarioStep[];\n}\n\n/** Context passed to factories (one target per scenario). */\nexport interface FactoryContext {\n scenario: Scenario;\n /** Random 8-char lowercase run id (`${run}`). */\n run: string;\n /** Resolved provider prefix (`${prefix}`). */\n prefix: string;\n /** Scenario `batchOptions` (logging) for the factory to apply. */\n batchOptions?: Record<string, unknown>;\n}\n\n/** Builds a target for one scenario. */\nexport type Factory<T> = (context: FactoryContext) => T | Promise<T>;\n\n/** Context passed to op handlers. */\nexport interface OpContext {\n readonly scenario: Scenario;\n readonly step: ScenarioStep;\n /** `${run}`. */\n readonly run: string;\n /** `${prefix}`. */\n readonly prefix: string;\n /** Variables (`${name}`): run, prefix, saved results, and values set by handlers. */\n readonly vars: Record<string, unknown>;\n /** Capabilities declared for this category. */\n readonly capabilities: ReadonlySet<string>;\n /** Replaces `${var}` placeholders in strings, recursively. */\n substitute<T>(value: T): T;\n /** Registers cleanup run after the scenario (in reverse order), even when it fails. */\n onCleanup(fn: () => unknown): void;\n}\n\n/** One op handler. */\nexport type OpHandler<T> = (\n target: T,\n args: Record<string, unknown>,\n context: OpContext,\n) => unknown;\n\n/** Handlers by op name. */\nexport type OpHandlers<T> = Readonly<Record<string, OpHandler<T>>>;\n\n/** Everything the runner needs for one category. */\nexport interface CategoryOps<T> {\n ops: OpHandlers<T>;\n /** Called after each scenario (e.g. close the client). */\n dispose?: (target: T, context: OpContext) => unknown;\n /** Extra variables derived from the target (e.g. tracing `serviceName`). */\n variables?: (target: T) => Record<string, unknown>;\n}\n\n/** {@link CategoryOps} of any target type. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyOps = CategoryOps<any>;\n\nconst registry = new Map<string, AnyOps>();\n\n/**\n * Adds or overrides op handlers for a category (merged over the built-in ones). Pass a\n * {@link CategoryOps} or plain handlers.\n */\nexport function registerOps<T>(category: string, ops: CategoryOps<T> | OpHandlers<T>): void {\n const normalized: CategoryOps<T> = isCategoryOps(ops) ? ops : { ops };\n const prev = registry.get(category);\n registry.set(category, prev === undefined ? normalized : mergeOps(prev, normalized));\n}\n\n/** Removes run-time registrations (tests). */\nexport function resetRegisteredOps(): void {\n registry.clear();\n}\n\nfunction isCategoryOps<T>(value: CategoryOps<T> | OpHandlers<T>): value is CategoryOps<T> {\n return (\n typeof (value as { ops?: unknown }).ops === \"object\" &&\n typeof (value as { ops?: unknown }).ops !== \"function\"\n );\n}\n\nfunction mergeOps(base: AnyOps, over: AnyOps): AnyOps {\n const merged: AnyOps = { ops: { ...base.ops, ...over.ops } };\n const dispose = over.dispose ?? base.dispose;\n const variables = over.variables ?? base.variables;\n if (dispose !== undefined) merged.dispose = dispose;\n if (variables !== undefined) merged.variables = variables;\n return merged;\n}\n\n/** Op handlers in effect for a category: built-ins, run-time registrations, then `extra`. */\nexport function resolveOps(\n category: string,\n extra?: Readonly<Record<string, AnyOps | OpHandlers<unknown>>>,\n): AnyOps | undefined {\n let ops: AnyOps | undefined = (builtinOps as Readonly<Record<string, AnyOps | undefined>>)[\n category\n ];\n const registered = registry.get(category);\n if (registered !== undefined) ops = ops === undefined ? registered : mergeOps(ops, registered);\n const more = extra?.[category];\n if (more !== undefined) {\n const normalized: AnyOps = isCategoryOps(more) ? more : { ops: more };\n ops = ops === undefined ? normalized : mergeOps(ops, normalized);\n }\n return ops;\n}\n\n/** Factories by category (`core → client`, `secrets → SecretsProvider`, …). */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ConformanceFactories = Partial<Record<Category, Factory<any>>>;\n\n/** Options of {@link runConformance}. */\nexport interface ConformanceOptions {\n /** Directory with the scenario JSON files (`<repo>/conformance/scenarios`). */\n scenariosDir: string;\n /** Categories to run (default: every category with a factory). */\n categories?: readonly Category[];\n /** Target factories. */\n factories: ConformanceFactories;\n /** Declared capabilities: one list for all categories, or per category. */\n capabilities?: readonly string[] | Partial<Record<Category, readonly string[]>>;\n /** Provider prefix (default `grow-conformance/${run}/`; may contain `${run}`). */\n prefix?: string;\n /** Extra variables. */\n variables?: Record<string, unknown>;\n /** Run only these scenario ids. */\n only?: readonly string[];\n /** Extra op handlers by category. */\n ops?: Readonly<Record<string, AnyOps | OpHandlers<unknown>>>;\n /** Run-id generator (default: random 8 lowercase alphanumerics). */\n runId?: () => string;\n}\n\n/** Outcome of one step. */\nexport interface StepResult {\n index: number;\n op: string;\n status: \"passed\" | \"failed\" | \"skipped\";\n error?: string;\n skipReason?: string;\n durationMs: number;\n}\n\n/** Outcome of one scenario. */\nexport interface ScenarioResult {\n id: string;\n category: Category;\n status: \"passed\" | \"failed\" | \"skipped\";\n skipReason?: string;\n error?: string;\n steps: StepResult[];\n durationMs: number;\n}\n\n/** Report returned by {@link runConformance}. */\nexport interface ConformanceReport {\n ok: boolean;\n passed: number;\n failed: number;\n skipped: number;\n results: ScenarioResult[];\n}\n\n/** Random 8-char lowercase id. */\nexport function randomRunId(): string {\n const alphabet = \"abcdefghijklmnopqrstuvwxyz0123456789\";\n let out = \"\";\n for (let i = 0; i < 8; i++)\n out += alphabet[Math.floor(Math.random() * alphabet.length)] as string;\n return out;\n}\n\n/** Loads and sorts (by id) every scenario file in a directory. */\nexport function loadScenarios(scenariosDir: string): Scenario[] {\n const files = readdirSync(scenariosDir).filter((f) => f.endsWith(\".json\"));\n const scenarios = files.map((f) => {\n const parsed = JSON.parse(readFileSync(join(scenariosDir, f), \"utf8\")) as Scenario;\n if (\n typeof parsed.id !== \"string\" ||\n typeof parsed.category !== \"string\" ||\n !Array.isArray(parsed.steps)\n ) {\n throw new Error(`invalid scenario file ${f}`);\n }\n return parsed;\n });\n return scenarios.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));\n}\n\nconst VAR = /\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}/g;\nconst WHOLE_VAR = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/;\n\n/** Replaces `${name}` placeholders recursively. Unknown variables throw. */\nexport function substitute<T>(value: T, vars: Readonly<Record<string, unknown>>): T {\n const lookup = (name: string): unknown => {\n if (!(name in vars)) throw new Error(`unknown variable \\${${name}}`);\n return vars[name];\n };\n const walk = (v: unknown): unknown => {\n if (typeof v === \"string\") {\n const whole = WHOLE_VAR.exec(v);\n if (whole !== null) return lookup(whole[1] as string);\n return v.replace(VAR, (_m, name: string) => String(lookup(name)));\n }\n if (Array.isArray(v)) return v.map(walk);\n if (v !== null && typeof v === \"object\") {\n return Object.fromEntries(\n Object.entries(v).map(([k, x]) => [\n k.replace(VAR, (_m, name: string) => String(lookup(name))),\n walk(x),\n ]),\n );\n }\n return v;\n };\n return walk(value) as T;\n}\n\nfunction capabilitySet(options: ConformanceOptions, category: Category): Set<string> {\n const caps = options.capabilities;\n if (caps === undefined) return new Set();\n if (Array.isArray(caps)) return new Set(caps as readonly string[]);\n return new Set((caps as Partial<Record<Category, readonly string[]>>)[category] ?? []);\n}\n\nfunction missing(requires: readonly string[] | undefined, caps: ReadonlySet<string>): string[] {\n return (requires ?? []).filter((r) => !caps.has(r));\n}\n\nfunction message(err: unknown): string {\n if (err instanceof Error) {\n const code = (err as { code?: unknown }).code;\n return typeof code === \"string\" ? `${code}: ${err.message}` : err.message;\n }\n return String(err);\n}\n\n/** Selected scenarios plus the reason a scenario is skipped up front (if any). */\nexport function planScenarios(\n options: ConformanceOptions,\n): { scenario: Scenario; skipReason?: string }[] {\n const categories = new Set<string>(options.categories ?? Object.keys(options.factories));\n for (const c of categories) {\n if ((options.factories as Record<string, unknown>)[c] === undefined) {\n throw new Error(`conformance: no factory for category \"${c}\"`);\n }\n }\n return loadScenarios(options.scenariosDir)\n .filter((s) => categories.has(s.category))\n .filter((s) => options.only === undefined || options.only.includes(s.id))\n .map((scenario) => {\n const lacking = missing(scenario.requires, capabilitySet(options, scenario.category));\n return lacking.length > 0\n ? { scenario, skipReason: `missing capabilities: ${lacking.join(\", \")}` }\n : { scenario };\n });\n}\n\n/** Runs one scenario. */\nexport async function runScenario(\n scenario: Scenario,\n options: ConformanceOptions,\n): Promise<ScenarioResult> {\n const started = performance.now();\n const caps = capabilitySet(options, scenario.category);\n const result: ScenarioResult = {\n id: scenario.id,\n category: scenario.category,\n status: \"passed\",\n steps: [],\n durationMs: 0,\n };\n const lacking = missing(scenario.requires, caps);\n if (lacking.length > 0) {\n result.status = \"skipped\";\n result.skipReason = `missing capabilities: ${lacking.join(\", \")}`;\n return result;\n }\n const category = resolveOps(scenario.category, options.ops);\n const factory = options.factories[scenario.category];\n if (category === undefined || factory === undefined) {\n result.status = \"failed\";\n result.error =\n category === undefined\n ? `no op handlers for category \"${scenario.category}\"`\n : `no factory for category \"${scenario.category}\"`;\n return result;\n }\n const run = (options.runId ?? randomRunId)();\n const vars: Record<string, unknown> = { ...options.variables, run };\n const prefix = substitute(options.prefix ?? \"grow-conformance/${run}/\", vars);\n vars.prefix = prefix;\n const cleanups: (() => unknown)[] = [];\n let currentStep: ScenarioStep = scenario.steps[0] ?? { op: \"\" };\n const context: OpContext = {\n scenario,\n get step() {\n return currentStep;\n },\n run,\n prefix,\n vars,\n capabilities: caps,\n substitute: <T>(v: T): T => substitute(v, vars),\n onCleanup: (fn) => {\n cleanups.push(fn);\n },\n };\n let target: unknown;\n try {\n target = await factory({\n scenario,\n run,\n prefix,\n ...(scenario.batchOptions === undefined ? {} : { batchOptions: scenario.batchOptions }),\n });\n Object.assign(vars, category.variables?.(target) ?? {}, { ...options.variables, run, prefix });\n for (const [index, step] of scenario.steps.entries()) {\n currentStep = step;\n const stepStart = performance.now();\n const stepResult: StepResult = { index, op: step.op, status: \"passed\", durationMs: 0 };\n result.steps.push(stepResult);\n const stepLacking = missing(step.requires, caps);\n if (stepLacking.length > 0) {\n stepResult.status = \"skipped\";\n stepResult.skipReason = `missing capabilities: ${stepLacking.join(\", \")}`;\n continue;\n }\n try {\n const handler = category.ops[step.op];\n if (handler === undefined)\n throw new Error(`unknown op \"${step.op}\" for category ${scenario.category}`);\n const args = substitute(step.args ?? {}, vars);\n const expectation = step.expect === undefined ? undefined : substitute(step.expect, vars);\n let value: unknown;\n let thrown: unknown;\n let failed = false;\n try {\n value = await handler(target, args, context);\n } catch (err) {\n failed = true;\n thrown = err;\n }\n if (expectation?.error !== undefined) {\n if (!failed) throw new Error(`expected error ${expectation.error} but the op succeeded`);\n const code = (thrown as { code?: unknown }).code;\n if (code !== expectation.error) {\n throw new Error(`expected error ${expectation.error}, got ${message(thrown)}`);\n }\n } else {\n if (failed) throw thrown;\n if (expectation !== undefined) checkExpectations(value, expectation);\n if (step.save !== undefined) vars[step.save] = value;\n }\n } catch (err) {\n stepResult.status = \"failed\";\n stepResult.error = message(err);\n result.status = \"failed\";\n result.error = `step ${index} (${step.op}): ${stepResult.error}`;\n break;\n } finally {\n stepResult.durationMs = performance.now() - stepStart;\n }\n }\n } catch (err) {\n result.status = \"failed\";\n result.error = `setup: ${message(err)}`;\n } finally {\n if (target !== undefined && category.dispose !== undefined) {\n try {\n await category.dispose(target, context);\n } catch (err) {\n if (result.status !== \"failed\") {\n result.status = \"failed\";\n result.error = `dispose: ${message(err)}`;\n }\n }\n }\n for (const fn of cleanups.reverse()) {\n try {\n await fn();\n } catch {\n // cleanup failures never hide the scenario outcome\n }\n }\n result.durationMs = performance.now() - started;\n }\n return result;\n}\n\n/** Runs every selected scenario sequentially and returns the report. */\nexport async function runConformance(options: ConformanceOptions): Promise<ConformanceReport> {\n const results: ScenarioResult[] = [];\n for (const { scenario } of planScenarios(options)) {\n results.push(await runScenario(scenario, options));\n }\n const count = (s: ScenarioResult[\"status\"]): number =>\n results.filter((r) => r.status === s).length;\n const failed = count(\"failed\");\n return { ok: failed === 0, passed: count(\"passed\"), failed, skipped: count(\"skipped\"), results };\n}\n\n/** Human-readable report (one line per scenario, failures with their error). */\nexport function formatReport(report: ConformanceReport): string {\n const lines = report.results.map((r) => {\n const extra =\n r.status === \"failed\"\n ? ` — ${r.error ?? \"\"}`\n : r.status === \"skipped\"\n ? ` — ${r.skipReason ?? \"\"}`\n : \"\";\n const skippedSteps = r.steps\n .filter((s) => s.status === \"skipped\")\n .map((s) => `${s.op}#${s.index}`);\n const stepNote = skippedSteps.length > 0 ? ` (skipped steps: ${skippedSteps.join(\", \")})` : \"\";\n return `${r.status.toUpperCase().padEnd(7)} ${r.id}${extra}${stepNote}`;\n });\n lines.push(`passed ${report.passed}, failed ${report.failed}, skipped ${report.skipped}`);\n return lines.join(\"\\n\");\n}\n\n/** Throws when the report has failures. */\nexport function assertConformance(report: ConformanceReport): void {\n if (!report.ok) throw new Error(`conformance failed:\\n${formatReport(report)}`);\n}\n\n/** One scenario as a test case (see {@link conformanceCases}). */\nexport interface ConformanceCase {\n id: string;\n category: Category;\n /** Set when the scenario is skipped (missing capabilities). */\n skip?: string;\n /** Runs the scenario; throws on failure. */\n run(): Promise<ScenarioResult>;\n}\n\n/**\n * Test-framework helper: one case per selected scenario, loaded synchronously.\n *\n * ```ts\n * for (const c of conformanceCases(options)) it.skipIf(c.skip !== undefined)(c.id, () => c.run());\n * ```\n */\nexport function conformanceCases(options: ConformanceOptions): ConformanceCase[] {\n return planScenarios(options).map(({ scenario, skipReason }) => ({\n id: scenario.id,\n category: scenario.category,\n ...(skipReason === undefined ? {} : { skip: skipReason }),\n run: async () => {\n const result = await runScenario(scenario, options);\n if (result.status === \"failed\")\n throw new Error(`${scenario.id}: ${result.error ?? \"failed\"}`);\n return result;\n },\n }));\n}\n","// Service-owned: a local fake OpenID provider for tests (discovery + JWKS over HTTP, token minting).\n\nimport { createServer, type Server } from \"node:http\";\nimport type { AddressInfo } from \"node:net\";\n\nimport { type CryptoKey, type JWK, SignJWT, exportJWK, generateKeyPair } from \"jose\";\n\nimport type { SigningAlgorithm } from \"./verifier.js\";\n\n/** One signing key of the fake IdP. */\nexport interface FakeIdpKey {\n kid: string;\n alg: SigningAlgorithm;\n privateKey: CryptoKey;\n publicJwk: JWK;\n}\n\n/** Options of {@link FakeIdp.prototype.mint}. */\nexport interface MintOptions {\n /** Claims merged over the defaults (`iss`, `aud`, `sub`, `iat`, `exp`). `undefined` removes one. */\n claims?: Record<string, unknown>;\n /** Signing key id (default: the current key). */\n kid?: string;\n /** Header overrides (e.g. `{ kid: undefined }`). */\n header?: Record<string, unknown>;\n /** Lifetime in seconds (default 300). */\n ttlSeconds?: number;\n}\n\n/**\n * A local OpenID provider for unit and conformance tests: serves\n * `/.well-known/openid-configuration` and `/jwks` on 127.0.0.1, mints signed tokens and rotates\n * keys. Never use it outside tests.\n */\nexport class FakeIdp {\n /** Issuer URL (`http://127.0.0.1:<port>`), set by {@link start}. */\n issuer = \"\";\n /** Audience put into minted tokens. */\n readonly audience: string;\n /** Keys published in the JWKS. */\n readonly keys: FakeIdpKey[] = [];\n /** Request counters per path. */\n readonly hits: Record<string, number> = {};\n /** When set, the server answers every request with this status. */\n failStatus: number | undefined;\n #server: Server | undefined;\n #current = \"\";\n #counter = 0;\n\n constructor(audience = \"test-client\") {\n this.audience = audience;\n }\n\n /** Starts the server and creates the first key (`alg`, default RS256). */\n async start(alg: SigningAlgorithm = \"RS256\"): Promise<this> {\n const server = createServer((req, res) => {\n const path = (req.url ?? \"/\").split(\"?\")[0] ?? \"/\";\n this.hits[path] = (this.hits[path] ?? 0) + 1;\n if (this.failStatus !== undefined) {\n res.writeHead(this.failStatus).end();\n return;\n }\n let body: unknown;\n if (path === \"/.well-known/openid-configuration\") {\n body = {\n issuer: this.issuer,\n jwks_uri: `${this.issuer}/jwks`,\n id_token_signing_alg_values_supported: [\"RS256\", \"ES256\", \"EdDSA\"],\n };\n } else if (path === \"/jwks\") {\n body = { keys: this.keys.map((key) => key.publicJwk) };\n } else {\n res.writeHead(404).end();\n return;\n }\n res.writeHead(200, { \"content-type\": \"application/json\" }).end(JSON.stringify(body));\n });\n await new Promise<void>((resolve) => server.listen(0, \"127.0.0.1\", resolve));\n this.#server = server;\n this.issuer = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;\n await this.rotate(alg);\n return this;\n }\n\n /** Adds a new key and makes it current (the old keys stay published until removed). */\n async rotate(alg: SigningAlgorithm = \"RS256\"): Promise<FakeIdpKey> {\n this.#counter += 1;\n const kid = `key-${this.#counter}`;\n const { privateKey, publicKey } = await generateKeyPair(\n alg,\n alg === \"EdDSA\" ? { crv: \"Ed25519\" } : {},\n );\n const publicJwk = { ...(await exportJWK(publicKey)), kid, alg, use: \"sig\" };\n const key: FakeIdpKey = { kid, alg, privateKey, publicJwk };\n this.keys.push(key);\n this.#current = kid;\n return key;\n }\n\n /** Removes a key from the JWKS. */\n removeKey(kid: string): void {\n const index = this.keys.findIndex((key) => key.kid === kid);\n if (index >= 0) this.keys.splice(index, 1);\n }\n\n /** Signs a token with the current (or the given) key. */\n async mint(options: MintOptions = {}): Promise<string> {\n const kid = options.kid ?? this.#current;\n const key = this.keys.find((candidate) => candidate.kid === kid);\n if (key === undefined) throw new Error(`fake idp: unknown kid ${kid}`);\n const now = Math.floor(Date.now() / 1000);\n const claims: Record<string, unknown> = {\n iss: this.issuer,\n aud: this.audience,\n sub: \"user-1\",\n iat: now,\n exp: now + (options.ttlSeconds ?? 300),\n ...options.claims,\n };\n for (const [name, value] of Object.entries(claims))\n if (value === undefined) Reflect.deleteProperty(claims, name);\n const header: Record<string, unknown> = {\n alg: key.alg,\n kid: key.kid,\n typ: \"JWT\",\n ...options.header,\n };\n for (const [name, value] of Object.entries(header))\n if (value === undefined) Reflect.deleteProperty(header, name);\n return new SignJWT(claims).setProtectedHeader(header as { alg: string }).sign(key.privateKey);\n }\n\n /** Stops the server. */\n async stop(): Promise<void> {\n const server = this.#server;\n this.#server = undefined;\n if (server !== undefined) {\n server.closeAllConnections();\n await new Promise<void>((resolve) => {\n server.close(() => {\n resolve();\n });\n });\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/** Replacement text for every redacted value. */
|
|
2
|
+
declare const REDACTED = "[REDACTED]";
|
|
3
|
+
declare const INSPECT: unique symbol;
|
|
4
|
+
/** Field and query parameter name substrings that make a value sensitive (case-insensitive). */
|
|
5
|
+
declare const SENSITIVE_FIELD_PARTS: readonly string[];
|
|
6
|
+
/** Minimum length of a known secret value that {@link redactText} replaces. */
|
|
7
|
+
declare const MIN_SECRET_LENGTH = 4;
|
|
8
|
+
/** True when a header with this name must be redacted (SPEC §2.6). */
|
|
9
|
+
declare function isSensitiveHeader(name: string): boolean;
|
|
10
|
+
/** True when a field or query parameter with this name must be redacted (SPEC §2.6). */
|
|
11
|
+
declare function isSensitiveField(name: string, extraKeys?: readonly string[]): boolean;
|
|
12
|
+
/** Header input accepted by {@link redactHeaders}. */
|
|
13
|
+
type HeadersInput = Readonly<Record<string, string | readonly string[] | undefined>> | Iterable<readonly [string, string]>;
|
|
14
|
+
/** Returns a copy of the headers with every sensitive value replaced by {@link REDACTED}. */
|
|
15
|
+
declare function redactHeaders(headers: HeadersInput): Record<string, string>;
|
|
16
|
+
/** Redacts credentials in the user-info part and the values of sensitive query parameters. */
|
|
17
|
+
declare function redactUrl(url: string | URL): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a deep copy of `value` in which every map entry whose key is sensitive is replaced by
|
|
20
|
+
* {@link REDACTED}. Recurses into nested objects and arrays; other values are copied as is.
|
|
21
|
+
*/
|
|
22
|
+
declare function redactFields<T>(value: T, extraKeys?: readonly string[]): T;
|
|
23
|
+
/** A known secret: a plain string or a {@link Secret}. */
|
|
24
|
+
type KnownSecret = string | Secret | null | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Replaces every occurrence of each known secret value (length >= 4) in `text` with
|
|
27
|
+
* {@link REDACTED}. Longer secrets are replaced first so overlapping values never leak a suffix.
|
|
28
|
+
*/
|
|
29
|
+
declare function redactText(text: string, knownSecrets?: Iterable<KnownSecret>): string;
|
|
30
|
+
/**
|
|
31
|
+
* Wraps a credential. `toString()`, `JSON.stringify` and `util.inspect` all print
|
|
32
|
+
* {@link REDACTED}; {@link Secret.reveal} returns the value.
|
|
33
|
+
*/
|
|
34
|
+
declare class Secret {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(value: string);
|
|
37
|
+
/** Wraps a string (returns `undefined` for `undefined`/empty, keeps an existing Secret). */
|
|
38
|
+
static from(value: string | Secret | undefined | null): Secret | undefined;
|
|
39
|
+
/** The wrapped value. */
|
|
40
|
+
reveal(): string;
|
|
41
|
+
/** Constant-time-ish comparison with another value. */
|
|
42
|
+
equals(other: string | Secret): boolean;
|
|
43
|
+
toString(): string;
|
|
44
|
+
toJSON(): string;
|
|
45
|
+
[INSPECT](): string;
|
|
46
|
+
}
|
|
47
|
+
/** Redacts the message of an arbitrary error value, keeping its name and `code`. */
|
|
48
|
+
declare function redactError(err: unknown, knownSecrets?: Iterable<KnownSecret>): Error;
|
|
49
|
+
|
|
50
|
+
/** An environment map (defaults to `process.env`); injectable so tests never touch the real one. */
|
|
51
|
+
type EnvMap = Readonly<Record<string, string | undefined>>;
|
|
52
|
+
/**
|
|
53
|
+
* Parses a duration into milliseconds: integer milliseconds (`"1500"`) or Go-style units
|
|
54
|
+
* (`"500ms"`, `"10s"`, `"2m"`, `"1h"`, `"1m30s"`). Returns `undefined` when invalid.
|
|
55
|
+
*/
|
|
56
|
+
declare function parseDuration(raw: string): number | undefined;
|
|
57
|
+
/** Parses `true/false/1/0/yes/no/on/off` (case-insensitive). Returns `undefined` when invalid. */
|
|
58
|
+
declare function parseBool(raw: string): boolean | undefined;
|
|
59
|
+
/** Parses a base-10 integer (optional sign). Returns `undefined` when invalid. */
|
|
60
|
+
declare function parseInteger(raw: string): number | undefined;
|
|
61
|
+
/** A variable found by {@link EnvReader.lookup}. */
|
|
62
|
+
interface EnvHit {
|
|
63
|
+
/** Name of the variable that supplied the value. */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Raw (non-empty) value. */
|
|
66
|
+
value: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Reads configuration from the environment with the SPEC §2.2 precedence
|
|
70
|
+
* `GROW_<KEY_UPPER>_<NAME>` > vendor variables (in order). Empty values count as unset.
|
|
71
|
+
* Every reader returns `undefined` when no variable is present; an invalid value throws
|
|
72
|
+
* {@link ConfigError} naming the variable but never its value.
|
|
73
|
+
*/
|
|
74
|
+
declare class EnvReader {
|
|
75
|
+
#private;
|
|
76
|
+
readonly prefix: string;
|
|
77
|
+
/**
|
|
78
|
+
* @param prefix e.g. `"GROW_OIDC_"`.
|
|
79
|
+
* @param env environment map, defaults to `process.env`.
|
|
80
|
+
*/
|
|
81
|
+
constructor(prefix: string, env?: EnvMap);
|
|
82
|
+
/** Finds the first present variable: `<prefix><name>`, then each vendor name. */
|
|
83
|
+
lookup(name: string, vendorNames?: readonly string[]): EnvHit | undefined;
|
|
84
|
+
/** String value. */
|
|
85
|
+
string(name: string, vendorNames?: readonly string[]): string | undefined;
|
|
86
|
+
/** Credential value wrapped in a {@link Secret}. */
|
|
87
|
+
secret(name: string, vendorNames?: readonly string[]): Secret | undefined;
|
|
88
|
+
/** Duration in milliseconds (see {@link parseDuration}). */
|
|
89
|
+
duration(name: string, vendorNames?: readonly string[]): number | undefined;
|
|
90
|
+
/** Boolean (see {@link parseBool}). */
|
|
91
|
+
bool(name: string, vendorNames?: readonly string[]): boolean | undefined;
|
|
92
|
+
/** Integer. */
|
|
93
|
+
int(name: string, vendorNames?: readonly string[]): number | undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Result of `client.health()` (SPEC §2.4). */
|
|
97
|
+
interface HealthStatus {
|
|
98
|
+
/** Whether the service answered and reports itself usable. */
|
|
99
|
+
healthy: boolean;
|
|
100
|
+
/** `"ok" | "degraded" | "unhealthy" | "unreachable"` or the vendor's word. */
|
|
101
|
+
status: string;
|
|
102
|
+
/** Extra vendor details (string values). */
|
|
103
|
+
details: Record<string, string>;
|
|
104
|
+
}
|
|
105
|
+
/** True when a vendor status word means healthy. */
|
|
106
|
+
declare function isHealthyWord(status: string): boolean;
|
|
107
|
+
/** Builds a {@link HealthStatus}; `healthy` defaults to {@link isHealthyWord}(status). */
|
|
108
|
+
declare function healthStatus(status: string, details?: Record<string, unknown>, healthy?: boolean): HealthStatus;
|
|
109
|
+
/**
|
|
110
|
+
* Runs a health probe and converts failures into a {@link HealthStatus} (SPEC §2.4): network
|
|
111
|
+
* errors and timeouts → `unreachable`; HTTP errors → `unhealthy` (with the status code in
|
|
112
|
+
* `details.httpStatus`). Only `CANCELLED` and `CONFIG` errors are rethrown.
|
|
113
|
+
*/
|
|
114
|
+
declare function probeHealth(probe: () => Promise<HealthStatus>): Promise<HealthStatus>;
|
|
115
|
+
|
|
116
|
+
/** Signing algorithms accepted by default (asymmetric only; `none` and HMAC are never accepted). */
|
|
117
|
+
declare const DEFAULT_ALGORITHMS: readonly SigningAlgorithm[];
|
|
118
|
+
/** Supported JWS algorithms. */
|
|
119
|
+
type SigningAlgorithm = "RS256" | "ES256" | "EdDSA";
|
|
120
|
+
/** Default clock skew tolerated for `exp` / `nbf` / `iat`: 60 s. */
|
|
121
|
+
declare const DEFAULT_CLOCK_SKEW_MS = 60000;
|
|
122
|
+
/** Default JWKS cache lifetime: 10 minutes. */
|
|
123
|
+
declare const DEFAULT_JWKS_CACHE_TTL_MS = 600000;
|
|
124
|
+
/** Default minimum interval between two JWKS refetches triggered by an unknown `kid`: 30 s. */
|
|
125
|
+
declare const DEFAULT_JWKS_REFRESH_COOLDOWN_MS = 30000;
|
|
126
|
+
/** Default HTTP timeout of discovery and JWKS requests: 10 s. */
|
|
127
|
+
declare const DEFAULT_HTTP_TIMEOUT_MS = 10000;
|
|
128
|
+
/** The authenticated user of a verified access token. */
|
|
129
|
+
interface AuthUser {
|
|
130
|
+
/** `sub` claim. */
|
|
131
|
+
sub: string;
|
|
132
|
+
/** `email` claim when present. */
|
|
133
|
+
email?: string;
|
|
134
|
+
/** `name` claim, else `preferred_username`, when present. */
|
|
135
|
+
name?: string;
|
|
136
|
+
/** Role names from the roles claim (strings, or Casdoor-style `{name}` objects). */
|
|
137
|
+
roles: string[];
|
|
138
|
+
/** Every claim of the token. */
|
|
139
|
+
claims: Record<string, unknown>;
|
|
140
|
+
}
|
|
141
|
+
/** Options of a {@link Verifier}. */
|
|
142
|
+
interface VerifierOptions {
|
|
143
|
+
/** Expected `iss` (exact match). Discovery uses `<issuer>/.well-known/openid-configuration`. */
|
|
144
|
+
issuer: string;
|
|
145
|
+
/** Expected `aud` (the token's `aud` must contain it). */
|
|
146
|
+
audience: string;
|
|
147
|
+
/** JWKS URL; skips discovery when set. */
|
|
148
|
+
jwksUrl?: string;
|
|
149
|
+
/** Claim (or dotted path such as `realm_access.roles`) holding the roles. Default `roles`. */
|
|
150
|
+
rolesClaim?: string;
|
|
151
|
+
/** Accepted algorithms. Default RS256, ES256, EdDSA. */
|
|
152
|
+
algorithms?: readonly SigningAlgorithm[];
|
|
153
|
+
/** Clock skew tolerance in milliseconds. Default 60 000. */
|
|
154
|
+
clockSkewMs?: number;
|
|
155
|
+
/** JWKS cache lifetime in milliseconds. Default 600 000. */
|
|
156
|
+
jwksCacheTtlMs?: number;
|
|
157
|
+
/** Minimum interval between unknown-`kid` refetches in milliseconds. Default 30 000. */
|
|
158
|
+
jwksRefreshCooldownMs?: number;
|
|
159
|
+
/** Timeout of discovery/JWKS requests in milliseconds. Default 10 000. */
|
|
160
|
+
httpTimeoutMs?: number;
|
|
161
|
+
/** `fetch` implementation (tests, proxies). Default `globalThis.fetch`. */
|
|
162
|
+
fetch?: typeof fetch;
|
|
163
|
+
/** Clock in epoch milliseconds (tests). Default `Date.now`. */
|
|
164
|
+
now?: () => number;
|
|
165
|
+
}
|
|
166
|
+
/** Anything a bearer token can be read from: Node/Express requests, Fetch `Request`s, `Headers`. */
|
|
167
|
+
type RequestLike = {
|
|
168
|
+
headers: Headers;
|
|
169
|
+
} | {
|
|
170
|
+
headers: Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
171
|
+
} | Headers | null | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the bearer token of a request's `Authorization` header (scheme case-insensitive), or
|
|
174
|
+
* `null` when there is none.
|
|
175
|
+
*/
|
|
176
|
+
declare function bearerToken(req: RequestLike): string | null;
|
|
177
|
+
/**
|
|
178
|
+
* Verifies OIDC access tokens (JWT) against the issuer's JWKS.
|
|
179
|
+
*
|
|
180
|
+
* Checks the signature (RS256/ES256/EdDSA allow-list), `iss` (exact), `aud` (contains),
|
|
181
|
+
* `exp` (required) and `nbf` with a clock skew (default 60 s). Keys come from
|
|
182
|
+
* `jwksUrl` or OIDC discovery, are cached (default 10 min) and refetched when a token names an
|
|
183
|
+
* unknown `kid` (key rotation, at most once per cooldown).
|
|
184
|
+
*
|
|
185
|
+
* Errors: `AuthenticationError` for every invalid token (the message names the failed check, never
|
|
186
|
+
* the token), `UnavailableError` when discovery/JWKS cannot be fetched, `ConfigError` for bad options.
|
|
187
|
+
*/
|
|
188
|
+
declare class Verifier {
|
|
189
|
+
#private;
|
|
190
|
+
readonly issuer: string;
|
|
191
|
+
readonly audience: string;
|
|
192
|
+
readonly rolesClaim: string;
|
|
193
|
+
readonly algorithms: readonly SigningAlgorithm[];
|
|
194
|
+
readonly clockSkewMs: number;
|
|
195
|
+
constructor(options: VerifierOptions);
|
|
196
|
+
/**
|
|
197
|
+
* Builds a verifier from `GROW_AUTH_ISSUER` (required), `GROW_AUTH_AUDIENCE` (default
|
|
198
|
+
* `GROW_AUTH_CLIENT_ID`), `GROW_AUTH_JWKS_URL`, `GROW_AUTH_ROLES_CLAIM` (default `roles`) and
|
|
199
|
+
* `GROW_AUTH_CLOCK_SKEW` (duration, default 60s). Explicit `overrides` win.
|
|
200
|
+
*/
|
|
201
|
+
static fromEnv(overrides?: Partial<VerifierOptions>, env?: EnvMap): Verifier;
|
|
202
|
+
/** Verifies a raw JWT access token and returns its user. */
|
|
203
|
+
verify(token: string): Promise<AuthUser>;
|
|
204
|
+
/** Verifies the bearer token of a request (`AuthenticationError` when there is none). */
|
|
205
|
+
verifyRequest(req: RequestLike): Promise<AuthUser>;
|
|
206
|
+
/** Drops the cached JWKS so the next verification refetches it. */
|
|
207
|
+
clearCache(): void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { DEFAULT_ALGORITHMS as D, EnvReader as E, MIN_SECRET_LENGTH as M, Secret as S, Verifier as V, DEFAULT_CLOCK_SKEW_MS as b, DEFAULT_HTTP_TIMEOUT_MS as c, DEFAULT_JWKS_CACHE_TTL_MS as d, DEFAULT_JWKS_REFRESH_COOLDOWN_MS as e, REDACTED as h, SENSITIVE_FIELD_PARTS as i, bearerToken as l, healthStatus as m, isHealthyWord as n, isSensitiveField as o, isSensitiveHeader as p, parseBool as q, parseDuration as r, parseInteger as s, probeHealth as t, redactError as u, redactFields as v, redactHeaders as w, redactText as x, redactUrl as y };
|
|
211
|
+
export type { AuthUser as A, HealthStatus as H, KnownSecret as K, RequestLike as R, EnvMap as a, EnvHit as f, HeadersInput as g, SigningAlgorithm as j, VerifierOptions as k };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/** Replacement text for every redacted value. */
|
|
2
|
+
declare const REDACTED = "[REDACTED]";
|
|
3
|
+
declare const INSPECT: unique symbol;
|
|
4
|
+
/** Field and query parameter name substrings that make a value sensitive (case-insensitive). */
|
|
5
|
+
declare const SENSITIVE_FIELD_PARTS: readonly string[];
|
|
6
|
+
/** Minimum length of a known secret value that {@link redactText} replaces. */
|
|
7
|
+
declare const MIN_SECRET_LENGTH = 4;
|
|
8
|
+
/** True when a header with this name must be redacted (SPEC §2.6). */
|
|
9
|
+
declare function isSensitiveHeader(name: string): boolean;
|
|
10
|
+
/** True when a field or query parameter with this name must be redacted (SPEC §2.6). */
|
|
11
|
+
declare function isSensitiveField(name: string, extraKeys?: readonly string[]): boolean;
|
|
12
|
+
/** Header input accepted by {@link redactHeaders}. */
|
|
13
|
+
type HeadersInput = Readonly<Record<string, string | readonly string[] | undefined>> | Iterable<readonly [string, string]>;
|
|
14
|
+
/** Returns a copy of the headers with every sensitive value replaced by {@link REDACTED}. */
|
|
15
|
+
declare function redactHeaders(headers: HeadersInput): Record<string, string>;
|
|
16
|
+
/** Redacts credentials in the user-info part and the values of sensitive query parameters. */
|
|
17
|
+
declare function redactUrl(url: string | URL): string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a deep copy of `value` in which every map entry whose key is sensitive is replaced by
|
|
20
|
+
* {@link REDACTED}. Recurses into nested objects and arrays; other values are copied as is.
|
|
21
|
+
*/
|
|
22
|
+
declare function redactFields<T>(value: T, extraKeys?: readonly string[]): T;
|
|
23
|
+
/** A known secret: a plain string or a {@link Secret}. */
|
|
24
|
+
type KnownSecret = string | Secret | null | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Replaces every occurrence of each known secret value (length >= 4) in `text` with
|
|
27
|
+
* {@link REDACTED}. Longer secrets are replaced first so overlapping values never leak a suffix.
|
|
28
|
+
*/
|
|
29
|
+
declare function redactText(text: string, knownSecrets?: Iterable<KnownSecret>): string;
|
|
30
|
+
/**
|
|
31
|
+
* Wraps a credential. `toString()`, `JSON.stringify` and `util.inspect` all print
|
|
32
|
+
* {@link REDACTED}; {@link Secret.reveal} returns the value.
|
|
33
|
+
*/
|
|
34
|
+
declare class Secret {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(value: string);
|
|
37
|
+
/** Wraps a string (returns `undefined` for `undefined`/empty, keeps an existing Secret). */
|
|
38
|
+
static from(value: string | Secret | undefined | null): Secret | undefined;
|
|
39
|
+
/** The wrapped value. */
|
|
40
|
+
reveal(): string;
|
|
41
|
+
/** Constant-time-ish comparison with another value. */
|
|
42
|
+
equals(other: string | Secret): boolean;
|
|
43
|
+
toString(): string;
|
|
44
|
+
toJSON(): string;
|
|
45
|
+
[INSPECT](): string;
|
|
46
|
+
}
|
|
47
|
+
/** Redacts the message of an arbitrary error value, keeping its name and `code`. */
|
|
48
|
+
declare function redactError(err: unknown, knownSecrets?: Iterable<KnownSecret>): Error;
|
|
49
|
+
|
|
50
|
+
/** An environment map (defaults to `process.env`); injectable so tests never touch the real one. */
|
|
51
|
+
type EnvMap = Readonly<Record<string, string | undefined>>;
|
|
52
|
+
/**
|
|
53
|
+
* Parses a duration into milliseconds: integer milliseconds (`"1500"`) or Go-style units
|
|
54
|
+
* (`"500ms"`, `"10s"`, `"2m"`, `"1h"`, `"1m30s"`). Returns `undefined` when invalid.
|
|
55
|
+
*/
|
|
56
|
+
declare function parseDuration(raw: string): number | undefined;
|
|
57
|
+
/** Parses `true/false/1/0/yes/no/on/off` (case-insensitive). Returns `undefined` when invalid. */
|
|
58
|
+
declare function parseBool(raw: string): boolean | undefined;
|
|
59
|
+
/** Parses a base-10 integer (optional sign). Returns `undefined` when invalid. */
|
|
60
|
+
declare function parseInteger(raw: string): number | undefined;
|
|
61
|
+
/** A variable found by {@link EnvReader.lookup}. */
|
|
62
|
+
interface EnvHit {
|
|
63
|
+
/** Name of the variable that supplied the value. */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Raw (non-empty) value. */
|
|
66
|
+
value: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Reads configuration from the environment with the SPEC §2.2 precedence
|
|
70
|
+
* `GROW_<KEY_UPPER>_<NAME>` > vendor variables (in order). Empty values count as unset.
|
|
71
|
+
* Every reader returns `undefined` when no variable is present; an invalid value throws
|
|
72
|
+
* {@link ConfigError} naming the variable but never its value.
|
|
73
|
+
*/
|
|
74
|
+
declare class EnvReader {
|
|
75
|
+
#private;
|
|
76
|
+
readonly prefix: string;
|
|
77
|
+
/**
|
|
78
|
+
* @param prefix e.g. `"GROW_OIDC_"`.
|
|
79
|
+
* @param env environment map, defaults to `process.env`.
|
|
80
|
+
*/
|
|
81
|
+
constructor(prefix: string, env?: EnvMap);
|
|
82
|
+
/** Finds the first present variable: `<prefix><name>`, then each vendor name. */
|
|
83
|
+
lookup(name: string, vendorNames?: readonly string[]): EnvHit | undefined;
|
|
84
|
+
/** String value. */
|
|
85
|
+
string(name: string, vendorNames?: readonly string[]): string | undefined;
|
|
86
|
+
/** Credential value wrapped in a {@link Secret}. */
|
|
87
|
+
secret(name: string, vendorNames?: readonly string[]): Secret | undefined;
|
|
88
|
+
/** Duration in milliseconds (see {@link parseDuration}). */
|
|
89
|
+
duration(name: string, vendorNames?: readonly string[]): number | undefined;
|
|
90
|
+
/** Boolean (see {@link parseBool}). */
|
|
91
|
+
bool(name: string, vendorNames?: readonly string[]): boolean | undefined;
|
|
92
|
+
/** Integer. */
|
|
93
|
+
int(name: string, vendorNames?: readonly string[]): number | undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Result of `client.health()` (SPEC §2.4). */
|
|
97
|
+
interface HealthStatus {
|
|
98
|
+
/** Whether the service answered and reports itself usable. */
|
|
99
|
+
healthy: boolean;
|
|
100
|
+
/** `"ok" | "degraded" | "unhealthy" | "unreachable"` or the vendor's word. */
|
|
101
|
+
status: string;
|
|
102
|
+
/** Extra vendor details (string values). */
|
|
103
|
+
details: Record<string, string>;
|
|
104
|
+
}
|
|
105
|
+
/** True when a vendor status word means healthy. */
|
|
106
|
+
declare function isHealthyWord(status: string): boolean;
|
|
107
|
+
/** Builds a {@link HealthStatus}; `healthy` defaults to {@link isHealthyWord}(status). */
|
|
108
|
+
declare function healthStatus(status: string, details?: Record<string, unknown>, healthy?: boolean): HealthStatus;
|
|
109
|
+
/**
|
|
110
|
+
* Runs a health probe and converts failures into a {@link HealthStatus} (SPEC §2.4): network
|
|
111
|
+
* errors and timeouts → `unreachable`; HTTP errors → `unhealthy` (with the status code in
|
|
112
|
+
* `details.httpStatus`). Only `CANCELLED` and `CONFIG` errors are rethrown.
|
|
113
|
+
*/
|
|
114
|
+
declare function probeHealth(probe: () => Promise<HealthStatus>): Promise<HealthStatus>;
|
|
115
|
+
|
|
116
|
+
/** Signing algorithms accepted by default (asymmetric only; `none` and HMAC are never accepted). */
|
|
117
|
+
declare const DEFAULT_ALGORITHMS: readonly SigningAlgorithm[];
|
|
118
|
+
/** Supported JWS algorithms. */
|
|
119
|
+
type SigningAlgorithm = "RS256" | "ES256" | "EdDSA";
|
|
120
|
+
/** Default clock skew tolerated for `exp` / `nbf` / `iat`: 60 s. */
|
|
121
|
+
declare const DEFAULT_CLOCK_SKEW_MS = 60000;
|
|
122
|
+
/** Default JWKS cache lifetime: 10 minutes. */
|
|
123
|
+
declare const DEFAULT_JWKS_CACHE_TTL_MS = 600000;
|
|
124
|
+
/** Default minimum interval between two JWKS refetches triggered by an unknown `kid`: 30 s. */
|
|
125
|
+
declare const DEFAULT_JWKS_REFRESH_COOLDOWN_MS = 30000;
|
|
126
|
+
/** Default HTTP timeout of discovery and JWKS requests: 10 s. */
|
|
127
|
+
declare const DEFAULT_HTTP_TIMEOUT_MS = 10000;
|
|
128
|
+
/** The authenticated user of a verified access token. */
|
|
129
|
+
interface AuthUser {
|
|
130
|
+
/** `sub` claim. */
|
|
131
|
+
sub: string;
|
|
132
|
+
/** `email` claim when present. */
|
|
133
|
+
email?: string;
|
|
134
|
+
/** `name` claim, else `preferred_username`, when present. */
|
|
135
|
+
name?: string;
|
|
136
|
+
/** Role names from the roles claim (strings, or Casdoor-style `{name}` objects). */
|
|
137
|
+
roles: string[];
|
|
138
|
+
/** Every claim of the token. */
|
|
139
|
+
claims: Record<string, unknown>;
|
|
140
|
+
}
|
|
141
|
+
/** Options of a {@link Verifier}. */
|
|
142
|
+
interface VerifierOptions {
|
|
143
|
+
/** Expected `iss` (exact match). Discovery uses `<issuer>/.well-known/openid-configuration`. */
|
|
144
|
+
issuer: string;
|
|
145
|
+
/** Expected `aud` (the token's `aud` must contain it). */
|
|
146
|
+
audience: string;
|
|
147
|
+
/** JWKS URL; skips discovery when set. */
|
|
148
|
+
jwksUrl?: string;
|
|
149
|
+
/** Claim (or dotted path such as `realm_access.roles`) holding the roles. Default `roles`. */
|
|
150
|
+
rolesClaim?: string;
|
|
151
|
+
/** Accepted algorithms. Default RS256, ES256, EdDSA. */
|
|
152
|
+
algorithms?: readonly SigningAlgorithm[];
|
|
153
|
+
/** Clock skew tolerance in milliseconds. Default 60 000. */
|
|
154
|
+
clockSkewMs?: number;
|
|
155
|
+
/** JWKS cache lifetime in milliseconds. Default 600 000. */
|
|
156
|
+
jwksCacheTtlMs?: number;
|
|
157
|
+
/** Minimum interval between unknown-`kid` refetches in milliseconds. Default 30 000. */
|
|
158
|
+
jwksRefreshCooldownMs?: number;
|
|
159
|
+
/** Timeout of discovery/JWKS requests in milliseconds. Default 10 000. */
|
|
160
|
+
httpTimeoutMs?: number;
|
|
161
|
+
/** `fetch` implementation (tests, proxies). Default `globalThis.fetch`. */
|
|
162
|
+
fetch?: typeof fetch;
|
|
163
|
+
/** Clock in epoch milliseconds (tests). Default `Date.now`. */
|
|
164
|
+
now?: () => number;
|
|
165
|
+
}
|
|
166
|
+
/** Anything a bearer token can be read from: Node/Express requests, Fetch `Request`s, `Headers`. */
|
|
167
|
+
type RequestLike = {
|
|
168
|
+
headers: Headers;
|
|
169
|
+
} | {
|
|
170
|
+
headers: Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
171
|
+
} | Headers | null | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the bearer token of a request's `Authorization` header (scheme case-insensitive), or
|
|
174
|
+
* `null` when there is none.
|
|
175
|
+
*/
|
|
176
|
+
declare function bearerToken(req: RequestLike): string | null;
|
|
177
|
+
/**
|
|
178
|
+
* Verifies OIDC access tokens (JWT) against the issuer's JWKS.
|
|
179
|
+
*
|
|
180
|
+
* Checks the signature (RS256/ES256/EdDSA allow-list), `iss` (exact), `aud` (contains),
|
|
181
|
+
* `exp` (required) and `nbf` with a clock skew (default 60 s). Keys come from
|
|
182
|
+
* `jwksUrl` or OIDC discovery, are cached (default 10 min) and refetched when a token names an
|
|
183
|
+
* unknown `kid` (key rotation, at most once per cooldown).
|
|
184
|
+
*
|
|
185
|
+
* Errors: `AuthenticationError` for every invalid token (the message names the failed check, never
|
|
186
|
+
* the token), `UnavailableError` when discovery/JWKS cannot be fetched, `ConfigError` for bad options.
|
|
187
|
+
*/
|
|
188
|
+
declare class Verifier {
|
|
189
|
+
#private;
|
|
190
|
+
readonly issuer: string;
|
|
191
|
+
readonly audience: string;
|
|
192
|
+
readonly rolesClaim: string;
|
|
193
|
+
readonly algorithms: readonly SigningAlgorithm[];
|
|
194
|
+
readonly clockSkewMs: number;
|
|
195
|
+
constructor(options: VerifierOptions);
|
|
196
|
+
/**
|
|
197
|
+
* Builds a verifier from `GROW_AUTH_ISSUER` (required), `GROW_AUTH_AUDIENCE` (default
|
|
198
|
+
* `GROW_AUTH_CLIENT_ID`), `GROW_AUTH_JWKS_URL`, `GROW_AUTH_ROLES_CLAIM` (default `roles`) and
|
|
199
|
+
* `GROW_AUTH_CLOCK_SKEW` (duration, default 60s). Explicit `overrides` win.
|
|
200
|
+
*/
|
|
201
|
+
static fromEnv(overrides?: Partial<VerifierOptions>, env?: EnvMap): Verifier;
|
|
202
|
+
/** Verifies a raw JWT access token and returns its user. */
|
|
203
|
+
verify(token: string): Promise<AuthUser>;
|
|
204
|
+
/** Verifies the bearer token of a request (`AuthenticationError` when there is none). */
|
|
205
|
+
verifyRequest(req: RequestLike): Promise<AuthUser>;
|
|
206
|
+
/** Drops the cached JWKS so the next verification refetches it. */
|
|
207
|
+
clearCache(): void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { DEFAULT_ALGORITHMS as D, EnvReader as E, MIN_SECRET_LENGTH as M, Secret as S, Verifier as V, DEFAULT_CLOCK_SKEW_MS as b, DEFAULT_HTTP_TIMEOUT_MS as c, DEFAULT_JWKS_CACHE_TTL_MS as d, DEFAULT_JWKS_REFRESH_COOLDOWN_MS as e, REDACTED as h, SENSITIVE_FIELD_PARTS as i, bearerToken as l, healthStatus as m, isHealthyWord as n, isSensitiveField as o, isSensitiveHeader as p, parseBool as q, parseDuration as r, parseInteger as s, probeHealth as t, redactError as u, redactFields as v, redactHeaders as w, redactText as x, redactUrl as y };
|
|
211
|
+
export type { AuthUser as A, HealthStatus as H, KnownSecret as K, RequestLike as R, EnvMap as a, EnvHit as f, HeadersInput as g, SigningAlgorithm as j, VerifierOptions as k };
|