@coffre/core 0.15.0 → 0.16.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 (70) hide show
  1. package/README.md +1 -1
  2. package/dist/{access-CgQTlUMz.js → access-CF8UG59J.js} +70 -95
  3. package/dist/{access-DqLJjnLM.d.ts → access-ERdGGHG7.d.ts} +45 -64
  4. package/dist/access.d.ts +2 -2
  5. package/dist/access.js +2 -2
  6. package/dist/envelope.d.ts +28 -9
  7. package/dist/envelope.js +25 -8
  8. package/dist/identity.d.ts +3 -1018
  9. package/dist/identity.js +885 -623
  10. package/dist/index-DuG9p3GH.d.ts +1233 -0
  11. package/dist/kek.d.ts +10 -16
  12. package/dist/kek.js +26 -41
  13. package/dist/log.d.ts +114 -0
  14. package/dist/log.js +291 -0
  15. package/dist/mcp.d.ts +27 -4
  16. package/dist/mcp.js +31 -10
  17. package/dist/recipe-BgJpmJum.d.ts +128 -0
  18. package/dist/recipe.d.ts +2 -127
  19. package/dist/{registry-D7X-x202.d.ts → registry-B7_LUDsJ.d.ts} +30 -5
  20. package/dist/schemas.d.ts +14 -12
  21. package/dist/schemas.js +16 -14
  22. package/dist/{types-Cp3lB_-W.js → types-DwTO_b4H.js} +17 -5
  23. package/dist/vault.d.ts +1771 -1419
  24. package/dist/vault.js +96 -302
  25. package/dist/{workloads-D049JH0M.d.ts → workloads-CW2dK4AW.d.ts} +1 -9
  26. package/dist/workloads.d.ts +2 -2
  27. package/dist/workloads.js +1 -9
  28. package/package.json +7 -7
  29. package/src/access.ts +63 -95
  30. package/src/changes/access.ts +140 -0
  31. package/src/changes/freezes.ts +40 -0
  32. package/src/changes/mcp.ts +150 -0
  33. package/src/changes/places.ts +219 -0
  34. package/src/changes/secrets.ts +235 -0
  35. package/src/changes/signin.ts +197 -0
  36. package/src/changes/workloads.ts +166 -0
  37. package/src/context.ts +18 -2
  38. package/src/envelope.ts +35 -12
  39. package/src/identity/auth.ts +11 -3
  40. package/src/identity/aws.ts +62 -0
  41. package/src/identity/github-app.ts +45 -24
  42. package/src/identity/index.ts +3 -2
  43. package/src/identity/{profile-rules.ts → profiles.ts} +1 -9
  44. package/src/identity/proofs.ts +306 -0
  45. package/src/identity/signin/config.ts +1 -1
  46. package/src/identity/tokens.ts +10 -3
  47. package/src/identity/verifier.ts +73 -14
  48. package/src/identity/workload-token.ts +4 -0
  49. package/src/identity/workloads.ts +0 -11
  50. package/src/kek/aws-kms.ts +18 -13
  51. package/src/kek/check.ts +16 -46
  52. package/src/kek/index.ts +2 -2
  53. package/src/kek/types.ts +15 -3
  54. package/src/log/index.ts +7 -0
  55. package/src/{audit → log}/tiles.ts +18 -49
  56. package/src/{audit → log}/tree.ts +2 -2
  57. package/src/mcp.ts +36 -9
  58. package/src/schemas.ts +15 -12
  59. package/src/vault.ts +251 -1150
  60. package/dist/merkle.d.ts +0 -456
  61. package/dist/merkle.js +0 -964
  62. package/src/answers.ts +0 -209
  63. package/src/audit/leaf.ts +0 -81
  64. package/src/audit/merkle.ts +0 -13
  65. package/src/audit/note.ts +0 -187
  66. package/src/audit/pair.ts +0 -86
  67. package/src/audit/verify.ts +0 -393
  68. package/src/audit/witness.ts +0 -50
  69. package/src/checkpoint.ts +0 -22
  70. package/src/identity/run-proof.ts +0 -159
@@ -1,1018 +1,3 @@
1
- import { $ as githubReusable, A as PROFILE_URNS, B as WorkloadProfile, C as MAX_ISSUER_BYTES, D as OIDC_PROFILES, E as MAX_SOURCES, F as Starts, G as checkPolicy, H as canonicalClaims, I as WORKLOAD_PROFILES, J as defaultIssuer, K as claimAt, L as WORKLOAD_SIGN_IN_PATH, M as REPEATING_PROFILES, N as REQUIRED_CLAIMS, O as POLICY_DEFAULTS, P as SESSION_MS, Q as githubEventsAt, R as WorkloadAlert, S as MAX_CLAIM_BYTES, T as MAX_READ_PLACES, U as checkBinding, V as addressWithin, W as checkFetchUrl, X as freezeTarget, Y as differingClaims, Z as fullRef, _ as GITLAB_PIPELINE_SOURCES, a as BindingPolicy, at as policyText, b as MAX_BINDINGS, c as CheckedBinding, ct as ConstraintsInvalid, d as EVENT_EXPOSURE, dt as constraintsAllow, et as githubWorkflow, f as EXCHANGED_CREDENTIAL_MS, ft as constraintsText, g as GITLAB_ISSUER, h as GITHUB_ISSUER, i as BindingInvalid, it as parseCidr, j as Preset, k as POLICY_FIELDS, l as Cidr, lt as MAX_CONSTRAINTS, m as GITHUB_EVENTS, n as BearerProfile, nt as isBearerProfile, o as BindingReads, ot as workflowRef, p as EXCHANGE_SKEW_SECONDS, pt as intersect, q as claimValues, r as BindingClaims, rt as parseAddress, s as CREDENTIAL_NAME, st as Constraints, t as BEARER_PROFILES, tt as gitlabProject, u as ClaimValue, ut as checkConstraints, v as GOOGLE_ISSUER, w as MAX_READ_KEYS, x as MAX_CLAIMS, y as KEY_NAMING_PROFILES, z as WorkloadCaller } from "./workloads-D049JH0M.js";
2
- import { MAX_PROOF_LENGTH, MAX_SIGNED_HEADERS, ProofClaims, ProofClaims as ProofClaims$1, PublicJwk, PublicJwk as PublicJwk$1, canonicalHtu, canonicalRequest, fetchMethod, sentTarget, thumbprint } from "@coffre/client/dpop";
3
- import { JSONWebKeySet, JWTPayload } from "jose";
4
- //#region src/identity/github-app.d.ts
5
- /**
6
- * The deployment's own GitHub App, made once with `githubApp(…)` and passed
7
- * to each side that uses it (docs/github-app.md):
8
- *
9
- * const app = githubApp({ appId, privateKey, clientId, clientSecret });
10
- * signin({ providers: [github({ app })], workloads: { limits, github: app } })
11
- *
12
- * Sign-in uses its OAuth client, `clientId` and `clientSecret`, as it would
13
- * an OAuth app's (`github({ app })`). The forge side, `workloads.github`,
14
- * uses its ID and private key: it lists the repositories the app is
15
- * installed on, private ones too, where an owner trusts a workflow, and
16
- * resolves `owner/name` to the IDs a binding names, with Metadata:
17
- * read-only, so what it reaches there is the names and IDs of those
18
- * repositories. Either side may go without the other: `github({ clientId,
19
- * clientSecret })` signs in alone, and an app with no client lists alone.
20
- *
21
- * The app's private key lives with the app, the rest of the deployment's
22
- * configuration, not in the vault: it opens no secret, and the vault's
23
- * isolation is for the keys that do. It and the client secret stay in this
24
- * object's private fields, and no message, log line or answer carries them,
25
- * the JWTs it signs or the installation tokens they buy.
26
- *
27
- * The object lives as long as its configuration: the isolate's, on Workers,
28
- * or the process's. It keeps settled values only (AGENTS.md, "What an
29
- * isolate keeps"): the imported key, the app's name, and each
30
- * installation's token until shortly before it expires. Concurrent first
31
- * calls each import and ask for their own.
32
- */
33
- export type GitHubAppOptions = {
34
- /** The app's ID, on its settings page ("App ID"): a number, not its client ID. */
35
- appId: string | number;
36
- /** A private key generated on its settings page: the PEM file, as downloaded. */
37
- privateKey: string;
38
- /** Its OAuth client, on the same page: for signing people in with it, `github({ app })`. Both, or neither. */
39
- clientId?: string;
40
- clientSecret?: string;
41
- /** https://github.com, or a GitHub Enterprise Server host: where people sign in. */
42
- webUrl?: string;
43
- /**
44
- * https://api.github.com, or `${host}/api/v3` on Enterprise Server. The
45
- * forge side takes github.com's only, or the dev IdP's on loopback: an
46
- * Enterprise Server's runs sign their tokens under another issuer than
47
- * the one its lookups bind to.
48
- */
49
- apiUrl?: string;
50
- };
51
- /** A repository, by the IDs a binding names: what `GET /workloads/lookup` answers. */
52
- export type GitHubRepository = {
53
- github: string;
54
- repositoryId: string;
55
- ownerId: string;
56
- private: boolean;
57
- };
58
- /** What the app reaches: its name and where to install it, the accounts it is installed on, and their repositories. */
59
- export type GitHubAppRepositories = {
60
- app: {
61
- name: string;
62
- installUrl: string;
63
- };
64
- /** The accounts it is installed on, by login. */
65
- installations: string[];
66
- /** By name. */
67
- repositories: GitHubRepository[];
68
- /** More than one listing reaches: the others are typed by name. */
69
- truncated: boolean;
70
- };
71
- /** GitHub could not be asked, or refused the app: the message says which, for a person, and carries no credential. */
72
- export declare class GitHubAppUnavailable extends Error {
73
- constructor(message: string, options?: {
74
- cause?: unknown;
75
- });
76
- }
77
- /** Requests one listing makes at most, tokens included: well under a Worker's subrequest limit. */
78
- export declare const MAX_LISTING_REQUESTS = 40;
79
- /** A token GitHub issues for an hour is used until this long before it ends, so that none expires mid-call. */
80
- export declare const TOKEN_MARGIN_MS: number;
81
- export declare class GitHubApp {
82
- #private;
83
- readonly appId: string;
84
- readonly webUrl: string;
85
- readonly apiUrl: string;
86
- /** Its OAuth client's ID, which is no secret; null when it was given none. */
87
- readonly clientId: string | null;
88
- constructor(options: {
89
- appId: string;
90
- apiUrl: string;
91
- webUrl?: string;
92
- pkcs8: Uint8Array<ArrayBuffer>;
93
- client?: {
94
- clientId: string;
95
- clientSecret: string;
96
- };
97
- }, io?: {
98
- fetch?: typeof fetch;
99
- now?: () => number;
100
- });
101
- /** Its OAuth client, for `github({ app })`; null when it was given none. */
102
- signinClient(): {
103
- clientId: string;
104
- clientSecret: string;
105
- } | null;
106
- /** Every repository of every account the app is installed on, as many as `MAX_LISTING_REQUESTS` reach. */
107
- repositories(): Promise<GitHubAppRepositories>;
108
- /** `owner/name`'s IDs, when the app is installed on it; null when it is not, its installation is suspended, or GitHub knows no such repository. */
109
- repository(fullName: string): Promise<GitHubRepository | null>;
110
- }
111
- /**
112
- * A private key's PEM as PKCS #8, which Web Crypto imports: GitHub's
113
- * download is PKCS #1 (`BEGIN RSA PRIVATE KEY`), wrapped here as an RSA
114
- * key's PKCS #8. Escaped newlines, as an environment variable sometimes
115
- * holds them, are newlines. Never says what the key was.
116
- */
117
- export declare function pkcs8Of(pem: string): Uint8Array<ArrayBuffer>;
118
- //#endregion
119
- //#region src/identity/signin/types.d.ts
120
- /**
121
- * What a provider reports about the person who just signed in.
122
- *
123
- * `subject` is the provider's permanent id for the account: OIDC's `sub`,
124
- * GitHub's numeric user id. coffre binds to it and to nothing else, since a
125
- * login name can be renamed and an email address can be handed to someone new.
126
- */
127
- export type SigninProfile = {
128
- subject: string;
129
- /** Verified addresses only, lowercased, the provider's primary first. */
130
- emails: string[];
131
- name: string | null;
132
- };
133
- /**
134
- * What must survive the round trip through the provider: the anti-CSRF
135
- * state, the PKCE verifier and, for OIDC, the nonce. coffre keeps it in an
136
- * encrypted, short-lived cookie rather than in the database, so an
137
- * unauthenticated visitor cannot make coffre write anything.
138
- */
139
- export type PendingSignin = {
140
- state: string;
141
- codeVerifier: string;
142
- nonce: string | null;
143
- };
144
- export type SigninErrorCode =
145
- /** The person cancelled, or the provider refused them. */
146
- 'provider_denied' |
147
- /** The callback does not belong to the sign-in this browser started. */
148
- 'state_mismatch' |
149
- /** The provider answered, but not in a way that can be trusted. */
150
- 'invalid_response' |
151
- /** The provider could not be reached. */
152
- 'provider_unavailable' |
153
- /** The account has no verified email address to match an invitation with. */
154
- 'no_verified_email' |
155
- /** A Google account outside the configured Workspace domain. */
156
- 'wrong_domain' |
157
- /** A GitHub account outside the configured organization. */
158
- 'not_in_organization';
159
- export declare class SigninError extends Error {
160
- readonly code: SigninErrorCode;
161
- constructor(code: SigninErrorCode, message: string);
162
- }
163
- export type ProviderOptions = {
164
- /** Injected by tests; defaults to globalThis.fetch. */
165
- fetch?: typeof fetch;
166
- };
167
- /** Which mark the sign-in button carries: GitHub's, Google's, Microsoft's, or a plain key. */
168
- export type SigninBrand = 'github' | 'google' | 'microsoft' | 'oidc';
169
- /**
170
- * A way to sign in: send the browser to whoever knows the person, and take
171
- * back who they are. `github()`, `google()`, `microsoft()` and `oidc()` make
172
- * one; so can a deployment, for a provider that is none of those. coffre
173
- * does everything around it: the pending state, sealed in a cookie between
174
- * the two calls, binding the profile to a member, sessions, CLI logins and
175
- * service tokens.
176
- *
177
- * const acme: SigninProvider = {
178
- * id: 'acme',
179
- * issuer: 'https://sso.acme.example',
180
- * label: 'Acme SSO',
181
- * brand: 'oidc',
182
- * async start(redirectUri) { … return { url, pending: { state, codeVerifier, nonce: null } }; },
183
- * async finish(callbackUrl, redirectUri, pending) { … return { subject, emails, name }; },
184
- * };
185
- */
186
- export interface SigninProvider {
187
- /** Stable: part of the callback URL, `/auth/callback/{id}`, and of every account bound through it. */
188
- readonly id: string;
189
- /** The authority whose subjects these are; changing it requires linking accounts again. */
190
- readonly issuer: string;
191
- /** Button text: "Continue with {label}". */
192
- readonly label: string;
193
- readonly brand: SigninBrand;
194
- /** Where to send the browser, and what to remember until it comes back. */
195
- start(redirectUri: string, options?: {
196
- loginHint?: string;
197
- }): Promise<{
198
- url: URL;
199
- pending: PendingSignin;
200
- }>;
201
- /**
202
- * The person back from the provider, verified: check the callback against
203
- * `pending`, and throw a SigninError for anything that does not hold.
204
- */
205
- finish(callbackUrl: URL, redirectUri: string, pending: PendingSignin): Promise<SigninProfile>;
206
- }
207
- //#endregion
208
- //#region src/identity/signin/github.d.ts
209
- /**
210
- * GitHub's OAuth web flow, which is OAuth 2.0 without OpenID Connect: no ID
211
- * token, so the profile comes from the REST API with the access token the
212
- * code is exchanged for. That token is used for these two or three calls and
213
- * then dropped; coffre never stores it.
214
- *
215
- * Works with an OAuth App or a GitHub App's user authorization, on github.com
216
- * or GitHub Enterprise Server.
217
- */
218
- export declare class GitHubSigninProvider implements SigninProvider {
219
- #private;
220
- readonly id: string;
221
- readonly issuer: string;
222
- readonly label: string;
223
- readonly brand: SigninBrand;
224
- /** What it was made from, as checked. */
225
- readonly config: GitHubProviderConfig;
226
- constructor(config: GitHubProviderConfig, options?: ProviderOptions);
227
- start(redirectUri: string, options?: {
228
- loginHint?: string;
229
- }): Promise<{
230
- url: URL;
231
- pending: PendingSignin;
232
- }>;
233
- finish(callbackUrl: URL, redirectUri: string, pending: PendingSignin): Promise<SigninProfile>;
234
- }
235
- //#endregion
236
- //#region src/identity/signin/oidc.d.ts
237
- /**
238
- * The authorization code flow with PKCE, against any OpenID Connect issuer.
239
- *
240
- * Protocol work is delegated to oauth4webapi: discovery with issuer
241
- * validation, the RFC 9207 `iss` check on the callback, the token request and
242
- * ID token claim validation (issuer, audience, expiry, nonce). The ID token is
243
- * received straight from the token endpoint over TLS with client
244
- * authentication, which OpenID Connect Core 3.1.3.7 accepts in place of
245
- * checking its signature.
246
- */
247
- export declare class OidcSigninProvider implements SigninProvider {
248
- #private;
249
- readonly id: string;
250
- readonly issuer: string;
251
- readonly label: string;
252
- readonly brand: SigninBrand;
253
- /** What it was made from, as checked. */
254
- readonly config: OidcProviderConfig;
255
- constructor(config: OidcProviderConfig, options?: ProviderOptions);
256
- start(redirectUri: string, options?: {
257
- loginHint?: string;
258
- }): Promise<{
259
- url: URL;
260
- pending: PendingSignin;
261
- }>;
262
- finish(callbackUrl: URL, redirectUri: string, pending: PendingSignin): Promise<SigninProfile>;
263
- }
264
- //#endregion
265
- //#region src/identity/signin/config.d.ts
266
- type ProviderBase = {
267
- id: string;
268
- label: string;
269
- brand: SigninBrand;
270
- clientId: string;
271
- clientSecret: string;
272
- };
273
- export type OidcProviderConfig = ProviderBase & {
274
- /** Issuer identifier; discovery is fetched from `${issuer}/.well-known/openid-configuration`. */
275
- issuer: string;
276
- scopes: string[];
277
- /** Extra authorization request parameters, such as Google's `hd` hint. */
278
- authorizationParams: Record<string, string>;
279
- /**
280
- * The Google Workspace domain the ID token's `hd` claim must equal. The
281
- * `hd` request parameter only filters Google's account picker; the claim is
282
- * what proves membership.
283
- */
284
- hostedDomain: string | null;
285
- };
286
- export type GitHubProviderConfig = ProviderBase & {
287
- /** https://github.com, or a GitHub Enterprise Server host. */
288
- webUrl: string;
289
- /** https://api.github.com, or `${host}/api/v3` on Enterprise Server. */
290
- apiUrl: string;
291
- /** When set, only active members of this organization may sign in. */
292
- organization: string | null;
293
- };
294
- export type SigninPage = {
295
- /** Heading on the sign-in page, e.g. "Acme secrets". */
296
- title: string;
297
- /** One line under it, e.g. "Use your acme.example Google account." */
298
- note: string | null;
299
- };
300
- export type SigninConfig = {
301
- /** The origin people reach coffre at. Callback URLs are built from it, never from the Host header. */
302
- publicUrl: string;
303
- providers: SigninProvider[];
304
- page: SigninPage;
305
- /** Absolute lifetime of a browser session. */
306
- browserSessionHours: number;
307
- /** Absolute lifetime of a CLI session. */
308
- cliSessionDays: number;
309
- /** CI runs signing in as services with their platform's ID token, when on (`workloads.ts`). */
310
- workloads: WorkloadsConfig | null;
311
- /** MCP clients acting as the people who connect them, when on (docs/design/mcp.md). */
312
- mcp: McpConfig | null;
313
- };
314
- /**
315
- * Workload identity: CI runs that sign in as a service with the ID token
316
- * their platform signs for them, through the trust bindings an owner sets
317
- * on the service (docs/design/oidc.md). Off unless the deployment turns it on.
318
- */
319
- export type WorkloadsOptions = {
320
- /**
321
- * The two limits every exchange passes before coffre does any work for
322
- * it: one per source address, and one for all sources together. On
323
- * Workers, two rate-limiting bindings (`env.WORKLOADS_PER_SOURCE`,
324
- * `env.WORKLOADS_TOTAL`), which Cloudflare counts per location; on Node,
325
- * `processLimits()` from `@coffre/server/node`, which counts per process.
326
- * Required: an exchange is never without them.
327
- */
328
- limits: WorkloadLimits;
329
- /**
330
- * Lets a binding's issuer be plain HTTP on loopback, as the dev IdP's is:
331
- * for local development and conformance. Refused unless the public URL is
332
- * loopback too, so no instance anyone else can reach ever trusts one.
333
- */
334
- allowLoopbackIssuersForDevelopment?: boolean;
335
- /**
336
- * The deployment's own GitHub App, `githubApp(…)`, installed on its
337
- * organizations: where an owner trusts a workflow, the pages list the
338
- * repositories it is installed on, private ones too, and a repository
339
- * typed by name resolves through it (docs/github-app.md). The same value
340
- * may sign people in, `github({ app })`. Left out, repositories are typed,
341
- * and only public ones' IDs are looked up.
342
- */
343
- github?: GitHubApp;
344
- /**
345
- * Leaves services nothing but key-bound sessions (docs/design/
346
- * workload-access.md, section 6.3): no service token is issued or taken,
347
- * and `/api/auth/oidc` answers 410. Its sessions still read their
348
- * bindings' listed `reads`. Taken, and not yet enforced: that design's PR
349
- * 1a does.
350
- */
351
- useOnly?: boolean;
352
- /** Stricter still: no binding may list `reads`, so services read plain values only. Taken, and not yet enforced (PR 1a). */
353
- noReads?: boolean;
354
- /** The deployment's own delivery of a workload's alerts, called in the background after the response: a Slack webhook, a pager. */
355
- alert?: (alert: WorkloadAlert) => unknown;
356
- };
357
- /** Cloudflare's rate-limiting binding, as coffre calls it; `processLimits()` has the same shape. */
358
- export type RateLimiter = {
359
- limit(options: {
360
- key: string;
361
- }): Promise<{
362
- success: boolean;
363
- }>;
364
- };
365
- export type WorkloadLimits = {
366
- perSource: RateLimiter;
367
- total: RateLimiter;
368
- };
369
- export type WorkloadsConfig = {
370
- allowLoopback: boolean;
371
- limits: WorkloadLimits;
372
- github: GitHubApp | null;
373
- useOnly: boolean;
374
- noReads: boolean;
375
- alert: ((alert: WorkloadAlert) => unknown) | null;
376
- };
377
- /**
378
- * MCP clients, Claude among them, acting as the people who connect them,
379
- * with coffre as their OAuth authorization server (docs/design/mcp.md). Off
380
- * unless the deployment turns it on.
381
- */
382
- export type McpOptions = {
383
- /**
384
- * The limits every unauthenticated OAuth request passes before coffre does
385
- * any work for it, one per source address and one for all together, and
386
- * the one each connection's tool calls pass. On Workers, three
387
- * rate-limiting bindings; on Node, `processLimits()` from
388
- * `@coffre/server/node`. Required.
389
- */
390
- limits: McpLimits;
391
- /**
392
- * Lets a client's metadata document be plain HTTP on loopback: for local
393
- * development and conformance. Refused unless the public URL is loopback
394
- * too.
395
- */
396
- allowLoopbackClientsForDevelopment?: boolean;
397
- };
398
- export type McpLimits = {
399
- perSource: RateLimiter;
400
- perConnection: RateLimiter;
401
- total: RateLimiter;
402
- };
403
- export type McpConfig = {
404
- allowLoopback: boolean;
405
- limits: McpLimits;
406
- };
407
- type Credentials = {
408
- clientId: string;
409
- clientSecret: string;
410
- };
411
- /**
412
- * Any OpenID Connect provider, by issuer URL.
413
- *
414
- * Okta, Auth0, Keycloak, Authentik, Zitadel, Clerk, WorkOS, Dex and the like
415
- * all live here; so does a broker, for providers that only speak SAML or LDAP.
416
- */
417
- export declare function oidc(options: OidcOptions): OidcSigninProvider;
418
- type OidcOptions = Credentials & {
419
- id: string;
420
- label: string;
421
- issuer: string;
422
- scopes?: string[];
423
- authorizationParams?: Record<string, string>;
424
- };
425
- /** Google accounts; with `domain`, only that Google Workspace's accounts. */
426
- export declare function google(options: Credentials & {
427
- id?: string;
428
- label?: string;
429
- domain?: string;
430
- }): OidcSigninProvider;
431
- /**
432
- * Microsoft Entra ID, for one tenant.
433
- *
434
- * The tenant must be its GUID. Entra's multi-tenant endpoints (`common`,
435
- * `organizations`) publish an issuer template rather than an issuer, which
436
- * standard OIDC validation rejects, and "any work account in the world" is not
437
- * an audience a secrets manager wants anyway.
438
- *
439
- * Entra email claims do not prove address ownership. Sign in through another
440
- * provider and link the Microsoft account first; later sign-ins use its subject.
441
- */
442
- export declare function microsoft(options: Credentials & {
443
- id?: string;
444
- label?: string;
445
- tenant: string;
446
- }): OidcSigninProvider;
447
- /**
448
- * GitHub accounts; with `organization`, only that organization's members.
449
- * Through an OAuth app, or a GitHub App's OAuth client, by its credentials;
450
- * or the deployment's GitHub App, `github({ app })`, the same value its
451
- * `workloads.github` lists repositories with:
452
- *
453
- * const app = githubApp({ appId, privateKey, clientId, clientSecret });
454
- * signin({ providers: [github({ app, organization: 'acme' })], workloads: { limits, github: app } })
455
- */
456
- export declare function github(options: {
457
- id?: string;
458
- label?: string;
459
- organization?: string;
460
- } & ((Credentials & {
461
- webUrl?: string;
462
- apiUrl?: string;
463
- }) | {
464
- app: GitHubApp;
465
- })): GitHubSigninProvider;
466
- /**
467
- * The deployment's GitHub App, checked where it is written: its numeric ID
468
- * and private key, and its OAuth client when it signs people in too. One
469
- * value, passed to each side that uses it: `github({ app })` and
470
- * `workloads.github` (`../github-app.ts`).
471
- */
472
- export declare function githubApp(options: GitHubAppOptions): GitHubApp;
473
- export declare function publicOrigin(value: string): string;
474
- /** Sign-in configuration, checked: at least one provider, each whole, ids unique, lifetimes sane. */
475
- export declare function defineSignin(options: {
476
- publicUrl: string;
477
- providers: SigninProvider[];
478
- page?: {
479
- title?: string;
480
- note?: string;
481
- };
482
- browserSessionHours?: number;
483
- cliSessionDays?: number;
484
- workloads?: WorkloadsOptions;
485
- mcp?: McpOptions;
486
- }): SigninConfig;
487
- //#endregion
488
- //#region src/identity/types.d.ts
489
- /**
490
- * An authenticated caller.
491
- *
492
- * Modelled as a tagged union rather than "a user with an optional email",
493
- * because Cloudflare Access issues two structurally different tokens:
494
- *
495
- * identity token -> sub = user uuid, email = "admin@acme.example"
496
- * service token -> sub = "" , common_name = "<client-id>.access", NO email
497
- *
498
- * Machine callers (external-secrets, CI) are most of the real traffic, so the
499
- * shape that cannot represent them is the wrong shape.
500
- */
501
- export type Principal = {
502
- type: 'user';
503
- /** Stable identifier used in grants and in the audit log. */
504
- id: string;
505
- email: string;
506
- subject: string;
507
- } | {
508
- type: 'service';
509
- /** Stable identifier used in grants and in the audit log. */
510
- id: string;
511
- commonName: string;
512
- };
513
- /**
514
- * Verifies a bearer token and returns the caller it identifies.
515
- *
516
- * Cloudflare mode verifies Access JWTs against the team domain; signin mode
517
- * looks up coffre's own credentials.
518
- */
519
- export interface IdentityVerifier {
520
- /**
521
- * `recall`: the request reads values, and has the vault check, before it
522
- * answers, an answer about its caller kept from an earlier request
523
- * (server accesses.ts): a verifier that asks the vault may give that one.
524
- */
525
- verify(token: string, request?: {
526
- sourceIp: string | null;
527
- recall?: boolean;
528
- }): Promise<Principal>;
529
- }
530
- /** Access delivers the JWT to the origin in this header. */
531
- export declare const ACCESS_JWT_HEADER = "cf-access-jwt-assertion";
532
- /** Where Access JWTs are checked: the team's keys, and the application's AUD tag. */
533
- export type AccessVerifierConfig = {
534
- /** Cloudflare Access team domain, e.g. https://acme.cloudflareaccess.com */
535
- issuer: string;
536
- /** Usually `${issuer}/cdn-cgi/access/certs`. */
537
- jwksUrl: string;
538
- /** The AUD tag of the specific Access application. */
539
- audience: string;
540
- /** Seconds of clock skew tolerated. Kept at 0 by default deliberately. */
541
- clockToleranceSeconds?: number;
542
- };
543
- //#endregion
544
- //#region src/identity/auth.d.ts
545
- /**
546
- * Who vouches for the person at the other end of a request.
547
- *
548
- * - `signin`: coffre itself, after the person signs in with one of the
549
- * deployment's providers: GitHub, Google, Microsoft, any OIDC issuer, or
550
- * one of its own.
551
- * - `cloudflare`: Cloudflare Access, in front of coffre.
552
- *
553
- * Either way, coffre decides who is a member, and issues its own sessions,
554
- * CLI logins and service tokens.
555
- */
556
- export type AuthConfig = {
557
- mode: 'signin';
558
- signin: SigninConfig;
559
- } | {
560
- mode: 'cloudflare';
561
- access: AccessVerifierConfig;
562
- };
563
- /**
564
- * What a deployment writes as `auth`: `signin(…)` or `cloudflareAccess(…)`.
565
- * Each checks its own options when called; sign-in is finished against the
566
- * deployment's public URL, which its callbacks are built from.
567
- */
568
- export type Auth = {
569
- resolve(publicUrl: string): AuthConfig;
570
- };
571
- /**
572
- * Cloudflare Access in front of coffre: every request carries Access's
573
- * signed assertion, checked against the team's keys and the application's
574
- * AUD tag.
575
- *
576
- * cloudflareAccess({ teamDomain: 'acme.cloudflareaccess.com', audience: env.ACCESS_AUD })
577
- */
578
- export declare function cloudflareAccess(options: {
579
- teamDomain: string;
580
- audience: string;
581
- }): Auth;
582
- export type SigninOptions = {
583
- /** At least one: `github`, `google`, `microsoft`, `oidc`, or the deployment's own `SigninProvider`. */
584
- providers: SigninProvider[];
585
- /** Heading on the sign-in page, e.g. "Acme secrets". */
586
- title?: string;
587
- /** One line under it, e.g. "Use your acme.example Google account." */
588
- note?: string;
589
- /** Absolute lifetime of a browser session; 12 hours unless set, at most a week. */
590
- browserSessionHours?: number;
591
- /** Absolute lifetime of a CLI session; 30 days unless set, at most a year. */
592
- cliSessionDays?: number;
593
- /** Lets CI runs sign in as services with their platform's ID token: `{}` turns it on. */
594
- workloads?: WorkloadsOptions;
595
- /** Lets MCP clients, Claude among them, act as the people who connect them (docs/mcp.md). */
596
- mcp?: McpOptions;
597
- };
598
- /**
599
- * coffre's own sign-in page, with these providers:
600
- *
601
- * signin({ providers: [github({ clientId, clientSecret, organization: 'acme' })] })
602
- */
603
- export declare function signin(options: SigninOptions): Auth;
604
- //#endregion
605
- //#region src/identity/dpop.d.ts
606
- /** How far a proof's `iat` may be from now: the nonce, not the clock, is what makes a proof fresh. */
607
- export declare const PROOF_SKEW_SECONDS = 300;
608
- /** Why a proof was refused, which a 401's `reason` names under `error="invalid_dpop_proof"`. */
609
- export type ProofReason = 'malformed' | 'key' | 'jkt' | 'signature' | 'htm' | 'htu' | 'ath' | 'req' | 'iat';
610
- export type ProofRefusal = {
611
- ok: false;
612
- reason: ProofReason;
613
- message: string;
614
- };
615
- /** A proof whose shape, key and claims hold: what `verifyProof` checks against the request. */
616
- export type ParsedProof = {
617
- ok: true;
618
- jwk: PublicJwk$1;
619
- claims: ProofClaims$1;
620
- /** The headers it signs, in `hdr`'s order; null for a proof that signs no content. */
621
- hdr: readonly string[] | null;
622
- signingInput: string;
623
- signature: Uint8Array;
624
- };
625
- /** A proof that holds for its request: its key's thumbprint, and what the gate checks. */
626
- export type VerifiedProof = {
627
- ok: true;
628
- jkt: string;
629
- jti: string;
630
- nonce: string | null;
631
- iat: number;
632
- hdr: readonly string[] | null;
633
- };
634
- /** What the request says a proof must sign. */
635
- export type ProofExpectation = {
636
- /** The request's method and URL, as received: `Request.method`, which the Fetch API has normalized as `fetchMethod` does. */
637
- method: string;
638
- url: string | URL;
639
- /** The session row's `jkt`; none at the exchange, where the proof's key becomes the session's. */
640
- jkt?: string;
641
- /** The session token the request carries, which `ath` signs; none at the exchange. */
642
- token?: string;
643
- /** The request's headers and its body's digest, which `hdr` and `req` sign: for a request coffre forwards. */
644
- content?: {
645
- headers: Headers;
646
- body: string;
647
- };
648
- /** Seconds `iat` may be from now: 300 unless said, 60 at the exchange. */
649
- skewSeconds?: number;
650
- /** Now, in milliseconds, for tests. */
651
- now?: number;
652
- };
653
- /** Steps 1 to 3: the proof's shape, its key's and its claims', with no I/O. */
654
- export declare function parseProof(proof: string): ParsedProof | ProofRefusal;
655
- /**
656
- * Steps 5 and 6: the proof against its request, `parseProof`'s first when
657
- * given a string. Nothing here reads a store, so the gate (step 7) still
658
- * decides whether this `jti` was seen.
659
- */
660
- export declare function verifyProof(proof: string | ParsedProof, expect: ProofExpectation): Promise<VerifiedProof | ProofRefusal>;
661
- /** A count a request asks the gate for: the requests under `key` in the last `windowMs`, at most `most`. */
662
- export type GateCount = {
663
- key: string;
664
- windowMs: number;
665
- most: number;
666
- };
667
- /** What the gate answers a request: its nonce on success, or why not. */
668
- export type GateAdmission = {
669
- ok: true;
670
- nonce: string;
671
- } | {
672
- ok: false;
673
- reason: 'use_dpop_nonce';
674
- nonce: string;
675
- } | {
676
- ok: false;
677
- reason: 'replayed' | 'overloaded';
678
- } |
679
- /** `first`: the first refusal of this key in its window, which alerts. */
680
- {
681
- ok: false;
682
- reason: 'limit';
683
- key: string;
684
- retryAfterMs: number;
685
- first: boolean;
686
- };
687
- /**
688
- * One workload's gate (section 5.2): a Durable Object on Workers, an object
689
- * in the process on Node. Its nonces are epochs: a gate accepts the current
690
- * and the previous one, remembers each epoch's `jti`s, and draws a new epoch
691
- * when it starts, so a restart forgets nothing that matters. It decides no
692
- * one's access: freezes, revocations and grants are the database's.
693
- */
694
- export interface Gate {
695
- /** Its current nonce, `g<n>.<epoch>`, for an answer that admits no proof: the exchange's `DPoP-Nonce`. */
696
- nonce(): Promise<string>;
697
- /**
698
- * Replay and nonce, for a request that carries a proof (a Cloudflare call
699
- * carries none, and has counts only); then, in the same call, every count
700
- * the request asks for. A nonce of an epoch gone gets `use_dpop_nonce`; a
701
- * proof with none never reaches the gate, and gets `nonce()`'s.
702
- */
703
- admit(request: {
704
- replay?: {
705
- session: string;
706
- jti: string;
707
- nonce: string;
708
- };
709
- counts?: readonly GateCount[];
710
- }): Promise<GateAdmission>;
711
- }
712
- //#endregion
713
- //#region src/identity/profile-rules.d.ts
714
- /**
715
- * What each platform's binding and tokens must say beyond the claims a
716
- * binding names (docs/design/workload-access.md, section 4.2). Core holds
717
- * the rules every profile shares: the required claims, the issuers that
718
- * force a profile, the policy's fields. These are each platform's own:
719
- * the shape of the IDs it issues, which issuer goes with which, and what a
720
- * token of it says that its binding cannot.
721
- *
722
- * A binding names IDs the platform never reuses, so each is checked for
723
- * the shape the platform gives it: a name in its place is refused, since a
724
- * name can be taken again after its owner is gone.
725
- */
726
- export type ProfileRules = {
727
- /** At binding time, after `checkBinding` and `checkPolicy`. Throws `BindingInvalid`. */
728
- binding(binding: CheckedBinding, policy: BindingPolicy): void;
729
- /** At the exchange, once the token verified and matched its binding's claims: why it is still refused, or null. */
730
- token(claims: Record<string, unknown>, binding: {
731
- issuer: string;
732
- claims: BindingClaims;
733
- policy: BindingPolicy;
734
- }): string | null;
735
- };
736
- export declare const PROFILE_RULES: { readonly [P in WorkloadProfile]?: ProfileRules; };
737
- /**
738
- * The audiences a token of a binding may name, the first the one its SDK
739
- * asks for: the session's key, `<publicUrl>#jkt=<thumbprint>`, for the
740
- * platforms whose caller picks the audience, and `?jkt=` for one that
741
- * refuses a `#` in it (section 4.2); the exact audience of a platform that
742
- * fixes it; this instance's URL for every other.
743
- */
744
- export declare function expectedAudiences(profile: WorkloadProfile, policy: BindingPolicy, expected: {
745
- publicUrl: string;
746
- jkt: string;
747
- }): string[];
748
- //#endregion
749
- //#region src/identity/run-proof.d.ts
750
- /**
751
- * The claims of the run a credential was issued for, as the issuer
752
- * asserted them: in the sign-in's record, so that a read leads back to its
753
- * run. What the issuer says, not proof of which run sent the request.
754
- */
755
- export declare const RUN_CLAIMS: readonly ["sub", "jti", "actor", "event_name", "ref", "base_ref", "head_ref", "sha", "repository", "repository_id", "run_id", "run_attempt", "workflow_ref", "job_workflow_ref", "job_workflow_sha", "environment", "project_path", "project_id", "namespace_id", "pipeline_id", "pipeline_source", "job_id", "kubernetes.io.pod.name"];
756
- /** A binding's `jwks_uri` when it carries its issuer's keys: the SHA-256 of those keys (`UploadedKeys`), where a fetched set's URL would be. */
757
- export declare const UPLOADED_KEYS = "sha256:";
758
- /** The run's claims, as the issuer stated them: those that say which run, each bounded. */
759
- export declare function runClaims(claims: Record<string, unknown>): Record<string, string | number>;
760
- /** A token's one audience, or null for none or several: a token for several parties is no single party's. */
761
- export declare function soleAudience(aud: unknown): string | null;
762
- /**
763
- * A binding as the vault weighs a sign-in through it (T149, PR 3b): its
764
- * sealed object's columns, the instance it was made on (`origin`), and the
765
- * keys uploaded with it as its row keeps them, which must be the ones its
766
- * `jwksUri` digests. Only such a binding's: the vault fetches nothing, so
767
- * the tokens of an issuer that publishes its keys are the app's to verify.
768
- */
769
- export type RunBinding = {
770
- profile: WorkloadProfile;
771
- issuer: string;
772
- origin: string;
773
- jwksUri: string;
774
- jwks: string;
775
- claims: string;
776
- policy: string | null;
777
- };
778
- /** Why a run's proof buys nothing, as the app's refusals say it (`ExchangeReason`), with the key a refused token named. */
779
- export declare class RunProofRefused extends Error {
780
- readonly reason: string;
781
- readonly kid: string | null;
782
- constructor(reason: string, message: string, kid?: string | null);
783
- }
784
- /** What a run's proof says, verified: what the credential it buys is held to. */
785
- export type RunProof = {
786
- claims: Record<string, unknown>;
787
- /** The run's claims, for the sign-in's record. */
788
- run: Record<string, string | number>;
789
- /** The token's signing input's hash, spent once; null for a token its platform hands out again, or one that names the session's key. */
790
- spent: Buffer | null;
791
- /** The last instant the token holds by its own times, ms: a CI run's (its `exp`, its `iat`'s hour); null for a workload's session. */
792
- validUntil: number | null;
793
- /** A workload's session's hard end by the token, ms (its `exp`); null when the token names the session's key, or for a CI run. */
794
- notAfter: number | null;
795
- };
796
- /**
797
- * Verify a CI run's or a workload's ID token against one binding, sealed
798
- * (D148), whose keys were uploaded with it: the vault's own check, which
799
- * no app can steer, and which asks no one. The binding's keys, held to the
800
- * digest its seal covers (a key they lack is refused, never looked for),
801
- * its issuer, its audience (the instance it was made on, or, for a
802
- * platform whose caller names the session's key, that key: `jkt`, from the
803
- * DPoP proof the vault verified, never from the app), the token's times,
804
- * the binding's claims and its profile's rules. Throws `RunProofRefused`.
805
- */
806
- export declare function verifyRunToken(token: string, binding: RunBinding, context: {
807
- now: Date;
808
- workload: {
809
- jkt: string;
810
- } | null;
811
- }): Promise<RunProof>;
812
- //#endregion
813
- //#region src/identity/signin/sealed.d.ts
814
- /**
815
- * Derive a purpose-bound key from one of coffre's existing 32-byte secrets.
816
- *
817
- * HKDF with a distinct `info` string gives a key that is independent of the
818
- * source for every practical purpose, so the sign-in cookie needs no new
819
- * secret to provision and a leak of one derived key says nothing about the
820
- * others.
821
- */
822
- export declare function deriveKey(secret: Uint8Array, purpose: string): Buffer;
823
- /**
824
- * Encrypt a small JSON value for a round trip through the browser.
825
- *
826
- * AES-256-GCM authenticates as well as hides, so a tampered or forged value
827
- * fails to open rather than decoding into something else. The expiry sits
828
- * inside the ciphertext, which keeps an old cookie from being replayed past
829
- * it even by a client that ignores Max-Age.
830
- */
831
- export declare function seal(key: Uint8Array, value: unknown, ttlSeconds: number, now?: number): string;
832
- /** The sealed value, or null when it is malformed, forged, tampered with or expired. */
833
- export declare function unseal<T>(key: Uint8Array, sealed: string | undefined | null, now?: number): T | null;
834
- //#endregion
835
- //#region src/identity/tokens.d.ts
836
- /**
837
- * Bearer credentials coffre issues itself: browser sessions, CLI sessions,
838
- * service tokens, personal tokens, which act as the person who made
839
- * them within the scope they named, and handles, which reach nothing but
840
- * the credential proxy (`@coffre/server/plugins/credential-proxy`): the
841
- * placeholder a person's app holds in place of a secret's value. And a
842
- * workload's sessions, which are bound to its key and useless without a
843
- * proof it signs (docs/design/workload-access.md, section 5), and the
844
- * enrollment codes CI mints for platforms that sign nothing, which are no
845
- * credential at all: they buy a session at `/api/auth/workload`, and every
846
- * other route refuses one.
847
- *
848
- * A token is a kind prefix and 32 random bytes, e.g.
849
- * `coffre_cli_Qm9Y...`. The prefix tells a person (or a secret scanner) what a
850
- * leaked string is; the database stores only its SHA-256, which is enough
851
- * for lookups and useless to anyone who reads the table. A plain hash is the
852
- * right tool here, unlike for passwords: 256 bits of randomness leave nothing
853
- * to brute-force.
854
- */
855
- export type CredentialKind = 'browser' | 'cli' | 'service' | 'personal' | 'handle' | 'workload';
856
- /** What a token's prefix says it is: a credential, or an enrollment code. */
857
- export type TokenKind = CredentialKind | 'enrollment';
858
- export declare function generateToken(kind: TokenKind): string;
859
- /** Whether a string has the shape of a coffre token, before any lookup. */
860
- export declare function isCoffreToken(value: string): boolean;
861
- /**
862
- * The kind a token's prefix says, before any lookup. Its hash covers the
863
- * prefix, so a token found under its hash is the kind it says.
864
- */
865
- export declare function tokenKind(token: string): TokenKind | null;
866
- export declare function hashToken(token: string): Buffer;
867
- /**
868
- * Enough of a token to recognize it in a list, never enough to use it: the
869
- * kind prefix and the last four characters. The prefix is matched rather than
870
- * cut at the last underscore, because base64url uses `_` too.
871
- */
872
- export declare function tokenHint(token: string): string;
873
- //#endregion
874
- //#region src/identity/verifier.d.ts
875
- type AccessClaims = JWTPayload & {
876
- email?: unknown;
877
- common_name?: unknown;
878
- };
879
- /**
880
- * Verifies Cloudflare Access JWTs.
881
- *
882
- * Signature and claim verification of the token Access sends with each
883
- * request.
884
- */
885
- export declare class AccessIdentityVerifier implements IdentityVerifier {
886
- #private;
887
- constructor(config: AccessVerifierConfig);
888
- verify(token: string): Promise<Principal>;
889
- }
890
- /**
891
- * Derive the caller from verified claims.
892
- *
893
- * Order matters. A service token is identified by `common_name` and carries an
894
- * empty `sub`; an identity token carries both `sub` and `email`. Anything else
895
- * is rejected rather than being allowed through as an authenticated caller
896
- * with no name -- an audit row with a null actor answers no question worth
897
- * asking.
898
- */
899
- export declare function toPrincipal(claims: AccessClaims): Principal;
900
- //#endregion
901
- //#region src/identity/workload-token.d.ts
902
- /**
903
- * An ID token a CI platform signed for a run, as the exchange checks it
904
- * (docs/design/oidc.md, section 3). The checks run in this order; each
905
- * refusal says which, as a reason a CI user can act on.
906
- */
907
- /** A compact JWS is three base64url parts; the whole token at most this long. */
908
- export declare const MAX_TOKEN_BYTES: number;
909
- /** Each side of every time check. */
910
- export declare const CLOCK_TOLERANCE_SECONDS = 30;
911
- /** The oldest token accepted, by its `iat`: tokens handed to a job at its start fit, day-old ones do not. */
912
- export declare const MAX_TOKEN_AGE_SECONDS = 3600;
913
- /** RS256 and ES256 (P-256), as for Access assertions: never `none`, never HS*. */
914
- export declare const WORKLOAD_ALGORITHMS: readonly ["RS256", "ES256"];
915
- export type WorkloadRefusal =
916
- /** Not a compact JWS, or claims that are not the right types. */
917
- 'malformed' |
918
- /** The signature does not verify under the issuer's keys. */
919
- 'signature' |
920
- /** Signed by a key the issuer's set does not hold, now. */
921
- 'unknown_key' |
922
- /** Past its `exp`. */
923
- 'expired' |
924
- /** Its `iat` is more than an hour ago, or not yet. */
925
- 'too_old' |
926
- /** It lives longer than an hour, `exp` − `iat`, where its binding carries its keys. */
927
- 'too_long' |
928
- /** Its `nbf` is still to come. */
929
- 'not_yet_valid' |
930
- /** Its audience is not this instance alone. */
931
- 'audience';
932
- export declare class WorkloadTokenRefused extends Error {
933
- readonly reason: WorkloadRefusal;
934
- constructor(reason: WorkloadRefusal, message: string);
935
- }
936
- /** What a token says before anything about it is trusted: enough to find the binding it would match. */
937
- export type DecodedToken = {
938
- header: Record<string, unknown>;
939
- claims: Record<string, unknown> & {
940
- iss: string;
941
- sub: string;
942
- exp: number;
943
- iat: number;
944
- };
945
- /**
946
- * SHA-256 of `header.payload`, exactly as received: what the signature
947
- * covers, and so the one spelling of the token. Hashing the whole token
948
- * would not do: an ES256 signature (r, s) has a twin, (r, n − s), that
949
- * verifies the same claims, so the whole token has two spellings.
950
- */
951
- signingInputHash: Buffer;
952
- };
953
- /** A token's parts and claims, checked for shape and types only. Throws `WorkloadTokenRefused('malformed')`. */
954
- export declare function decodeWorkloadToken(token: string): DecodedToken;
955
- /**
956
- * Verify a token under an issuer's keys: the signature by jose, with the
957
- * algorithms fixed and nothing taken from the header but `alg` and `kid`;
958
- * the issuer exactly; `exp`, `nbf` and `iat` within the tolerance, `iat` at
959
- * most an hour old; and the audience, this instance's public URL alone.
960
- * With `maxLifetime`, in seconds, a token whose `exp` is further than that
961
- * from its `iat` is refused too. With `maxAge: null`, its `iat` may be any
962
- * age, and its own `exp` alone ends it: a token its platform hands out
963
- * again for hours, a managed identity's (docs/design/workload-access.md,
964
- * section 4.2). Returns the verified claims.
965
- */
966
- export declare function verifyWorkloadToken(token: string, keys: JSONWebKeySet, expected: {
967
- issuer: string;
968
- audience: string;
969
- now: Date;
970
- maxLifetime?: number;
971
- maxAge?: null;
972
- }): Promise<JWTPayload & DecodedToken['claims']>;
973
- /**
974
- * Why a token issued at `iat` may not be exchanged at `now`, both in
975
- * seconds, or null: issued `maxAge` seconds ago at most, an hour unless
976
- * said, exactly, and no further ahead than the clock tolerance.
977
- * Verification and the exchange's commit both ask it.
978
- */
979
- export declare function issuedRefusal(iat: number, now: number, maxAge?: number): WorkloadTokenRefused | null;
980
- /** At most this many keys in a set, fetched or uploaded. */
981
- export declare const MAX_KEYS = 32;
982
- /** One key of an uploaded set, as an owner sees it: its `kid`, its algorithm, and its RFC 7638 thumbprint. */
983
- export type KeySummary = {
984
- kid: string | null;
985
- alg: (typeof WORKLOAD_ALGORITHMS)[number];
986
- thumbprint: string;
987
- };
988
- /**
989
- * A key set uploaded with a binding, as the binding keeps it: its public
990
- * keys alone, as canonical JSON, and that JSON's SHA-256, in hex, which
991
- * stands in the binding where a URL would and so is under its MAC.
992
- */
993
- export type UploadedKeys = {
994
- jwks: string;
995
- digest: string;
996
- keys: KeySummary[];
997
- };
998
- /** A key set that cannot be uploaded, said so an owner can fix it. */
999
- export declare class KeysInvalid extends Error {
1000
- constructor(message: string);
1001
- }
1002
- /**
1003
- * An issuer's public keys, as uploaded for a binding: a JWKS, `{ "keys": [
1004
- * … ] }`, of RSA keys of 2048 bits or more, for RS256, and P-256 keys, for
1005
- * ES256, each kept with only the members that verify (`kty`, `kid`, `use`,
1006
- * `alg` and the key), in the order of their thumbprints, so that one set
1007
- * however listed has one digest. An RSA key's parameters are checked
1008
- * before jose sees them, since it takes some that verify anything: an
1009
- * exponent of 1 makes every signature its message. Keys for encryption are
1010
- * left out, as from a fetched set; a private or a symmetric key refuses the
1011
- * whole set, since coffre keeps no secret of an issuer's. Throws
1012
- * `KeysInvalid`.
1013
- */
1014
- export declare function uploadedKeys(value: unknown): Promise<UploadedKeys>;
1015
- /** The keys of a set `uploadedKeys` kept, as an owner sees them. */
1016
- export declare function keySummaries(jwks: string): KeySummary[];
1017
- //#endregion
1018
- export { BEARER_PROFILES, BearerProfile, BindingClaims, BindingInvalid, BindingPolicy, BindingReads, CREDENTIAL_NAME, CheckedBinding, Cidr, ClaimValue, Constraints, ConstraintsInvalid, EVENT_EXPOSURE, EXCHANGED_CREDENTIAL_MS, EXCHANGE_SKEW_SECONDS, GITHUB_EVENTS, GITHUB_ISSUER, GITLAB_ISSUER, GITLAB_PIPELINE_SOURCES, GOOGLE_ISSUER, type JSONWebKeySet, KEY_NAMING_PROFILES, MAX_BINDINGS, MAX_CLAIMS, MAX_CLAIM_BYTES, MAX_CONSTRAINTS, MAX_ISSUER_BYTES, MAX_PROOF_LENGTH, MAX_READ_KEYS, MAX_READ_PLACES, MAX_SIGNED_HEADERS, MAX_SOURCES, OIDC_PROFILES, POLICY_DEFAULTS, POLICY_FIELDS, PROFILE_URNS, Preset, type ProofClaims, type PublicJwk, REPEATING_PROFILES, REQUIRED_CLAIMS, SESSION_MS, Starts, WORKLOAD_PROFILES, WORKLOAD_SIGN_IN_PATH, WorkloadAlert, WorkloadCaller, WorkloadProfile, addressWithin, canonicalClaims, canonicalHtu, canonicalRequest, checkBinding, checkConstraints, checkFetchUrl, checkPolicy, claimAt, claimValues, constraintsAllow, constraintsText, defaultIssuer, differingClaims, fetchMethod, freezeTarget, fullRef, githubEventsAt, githubReusable, githubWorkflow, gitlabProject, intersect, isBearerProfile, parseAddress, parseCidr, policyText, sentTarget, thumbprint, workflowRef };
1
+ import { $ as audiencesOf, $t as google, A as VerifiedProof, At as Auth, B as assumedRole, Bt as McpConfig, C as PROOF_SKEW_SECONDS, Ct as WorkloadRefusal, D as ProofReason, Dt as keySummaries, E as ProofExpectation, Et as issuedRefusal, F as sentTarget, Ft as ACCESS_JWT_HEADER, G as ExchangeRefused, Gt as SigninConfig, H as matchAwsAnswer, Ht as McpOptions, I as thumbprint, It as AccessVerifierConfig, J as ProofBinding, Jt as WorkloadsConfig, K as IdTokenMatch, Kt as SigninPage, L as verifyProof, Lt as IdentityVerifier, M as canonicalRequest, Mt as SigninOptions, N as fetchMethod, Nt as cloudflareAccess, O as ProofRefusal, Ot as uploadedKeys, P as parseProof, Pt as signin, Q as audienceTried, Qt as githubApp, R as AwsIdentity, Rt as Principal, S as MAX_SIGNED_HEADERS, St as WORKLOAD_ALGORITHMS, T as ProofClaims, Tt as decodeWorkloadToken, U as CARRIED, Ut as OidcProviderConfig, V as awsClaims, Vt as McpLimits, W as ExchangeRefusal, Wt as RateLimiter, X as RUN_CLAIMS, Xt as defineSignin, Y as ProofFor, Yt as WorkloadsOptions, Z as VerifiedUnder, Zt as github, _ as expectedAudiences, _n as GitHubRepository, _t as KeysInvalid, a as CredentialKind, an as GitHubSigninProvider, at as profileRefusal, b as GateCount, bn as pkcs8Of, bt as MAX_TOKEN_BYTES, c as hashToken, cn as SigninBrand, ct as sessionRefusal, d as tokenKind, dn as SigninProfile, dt as spends, en as lifetime, et as hardEnd, f as deriveKey, fn as SigninProvider, ft as timesRefusal, g as ProfileRules, gn as GitHubAppUnavailable, gt as KeySummary, h as PROFILE_RULES, hn as GitHubAppRepositories, ht as JSONWebKeySet, i as toPrincipal, in as OidcSigninProvider, it as policyOf, j as canonicalHtu, jt as AuthConfig, k as PublicJwk, kt as verifyWorkloadToken, l as isCoffreToken, ln as SigninError, lt as signatureRefusal, m as unseal, mn as GitHubAppOptions, mt as DecodedToken, n as AccessKeysUnavailable, nn as oidc, nt as matchIdToken, o as TokenKind, on as PendingSignin, ot as readIdToken, p as seal, pn as GitHubApp, pt as CLOCK_TOLERANCE_SECONDS, q as MAX_RUN_CLAIM, qt as WorkloadLimits, r as AccessVerifierIo, rn as publicOrigin, rt as oldestMatching, s as generateToken, sn as ProviderOptions, st as runClaims, t as AccessIdentityVerifier, tn as microsoft, tt as issues, u as tokenHint, un as SigninErrorCode, ut as soleAudience, v as Gate, vn as MAX_LISTING_REQUESTS, vt as MAX_KEYS, w as ParsedProof, wt as WorkloadTokenRefused, x as MAX_PROOF_LENGTH, xt as UploadedKeys, y as GateAdmission, yn as TOKEN_MARGIN_MS, yt as MAX_TOKEN_AGE_SECONDS, z as CallerIdentity, zt as GitHubProviderConfig } from "./index-DuG9p3GH.js";
2
+ import { $ as parseAddress, A as REPEATING_PROFILES, B as checkFetchUrl, C as MAX_READ_PLACES, D as POLICY_FIELDS, E as POLICY_DEFAULTS, F as WorkloadCaller, G as differingClaims, H as claimAt, I as WorkloadProfile, J as githubEventsAt, K as freezeTarget, L as addressWithin, M as Starts, N as WORKLOAD_PROFILES, O as PROFILE_URNS, P as WorkloadAlert, Q as isBearerProfile, R as canonicalClaims, S as MAX_READ_KEYS, T as OIDC_PROFILES, U as claimValues, V as checkPolicy, W as defaultIssuer, X as githubWorkflow, Y as githubReusable, Z as gitlabProject, _ as KEY_NAMING_PROFILES, a as BindingPolicy, at as MAX_CONSTRAINTS, b as MAX_CLAIM_BYTES, c as CheckedBinding, ct as constraintsText, d as EVENT_EXPOSURE, et as parseCidr, f as GITHUB_EVENTS, g as GOOGLE_ISSUER, h as GITLAB_PIPELINE_SOURCES, i as BindingInvalid, it as ConstraintsInvalid, j as REQUIRED_CLAIMS, k as Preset, l as Cidr, lt as intersect, m as GITLAB_ISSUER, n as BearerProfile, nt as workflowRef, o as BindingReads, ot as checkConstraints, p as GITHUB_ISSUER, q as fullRef, r as BindingClaims, rt as Constraints, s as CREDENTIAL_NAME, st as constraintsAllow, t as BEARER_PROFILES, tt as policyText, u as ClaimValue, v as MAX_BINDINGS, w as MAX_SOURCES, x as MAX_ISSUER_BYTES, y as MAX_CLAIMS, z as checkBinding } from "./workloads-CW2dK4AW.js";
3
+ export { ACCESS_JWT_HEADER, AccessIdentityVerifier, AccessKeysUnavailable, AccessVerifierConfig, AccessVerifierIo, Auth, AuthConfig, AwsIdentity, BEARER_PROFILES, BearerProfile, BindingClaims, BindingInvalid, BindingPolicy, BindingReads, CARRIED, CLOCK_TOLERANCE_SECONDS, CREDENTIAL_NAME, CallerIdentity, CheckedBinding, Cidr, ClaimValue, Constraints, ConstraintsInvalid, CredentialKind, DecodedToken, EVENT_EXPOSURE, ExchangeRefusal, ExchangeRefused, GITHUB_EVENTS, GITHUB_ISSUER, GITLAB_ISSUER, GITLAB_PIPELINE_SOURCES, GOOGLE_ISSUER, Gate, GateAdmission, GateCount, GitHubApp, GitHubAppOptions, GitHubAppRepositories, GitHubAppUnavailable, GitHubProviderConfig, GitHubRepository, GitHubSigninProvider, IdTokenMatch, IdentityVerifier, type JSONWebKeySet, KEY_NAMING_PROFILES, KeySummary, KeysInvalid, MAX_BINDINGS, MAX_CLAIMS, MAX_CLAIM_BYTES, MAX_CONSTRAINTS, MAX_ISSUER_BYTES, MAX_KEYS, MAX_LISTING_REQUESTS, MAX_PROOF_LENGTH, MAX_READ_KEYS, MAX_READ_PLACES, MAX_RUN_CLAIM, MAX_SIGNED_HEADERS, MAX_SOURCES, MAX_TOKEN_AGE_SECONDS, MAX_TOKEN_BYTES, McpConfig, McpLimits, McpOptions, OIDC_PROFILES, OidcProviderConfig, OidcSigninProvider, POLICY_DEFAULTS, POLICY_FIELDS, PROFILE_RULES, PROFILE_URNS, PROOF_SKEW_SECONDS, ParsedProof, PendingSignin, Preset, Principal, ProfileRules, ProofBinding, type ProofClaims, ProofExpectation, ProofFor, ProofReason, ProofRefusal, ProviderOptions, type PublicJwk, REPEATING_PROFILES, REQUIRED_CLAIMS, RUN_CLAIMS, RateLimiter, SigninBrand, SigninConfig, SigninError, SigninErrorCode, SigninOptions, SigninPage, SigninProfile, SigninProvider, Starts, TOKEN_MARGIN_MS, TokenKind, UploadedKeys, VerifiedProof, VerifiedUnder, WORKLOAD_ALGORITHMS, WORKLOAD_PROFILES, WorkloadAlert, WorkloadCaller, WorkloadLimits, WorkloadProfile, WorkloadRefusal, WorkloadTokenRefused, WorkloadsConfig, WorkloadsOptions, addressWithin, assumedRole, audienceTried, audiencesOf, awsClaims, canonicalClaims, canonicalHtu, canonicalRequest, checkBinding, checkConstraints, checkFetchUrl, checkPolicy, claimAt, claimValues, cloudflareAccess, constraintsAllow, constraintsText, decodeWorkloadToken, defaultIssuer, defineSignin, deriveKey, differingClaims, expectedAudiences, fetchMethod, freezeTarget, fullRef, generateToken, github, githubApp, githubEventsAt, githubReusable, githubWorkflow, gitlabProject, google, hardEnd, hashToken, intersect, isBearerProfile, isCoffreToken, issuedRefusal, issues, keySummaries, lifetime, matchAwsAnswer, matchIdToken, microsoft, oidc, oldestMatching, parseAddress, parseCidr, parseProof, pkcs8Of, policyOf, policyText, profileRefusal, publicOrigin, readIdToken, runClaims, seal, sentTarget, sessionRefusal, signatureRefusal, signin, soleAudience, spends, thumbprint, timesRefusal, toPrincipal, tokenHint, tokenKind, unseal, uploadedKeys, verifyProof, verifyWorkloadToken, workflowRef };