@coffre/core 0.10.1 → 0.11.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/dist/{access-CF4noOjL.d.ts → access-CU3xEOLH.d.ts} +96 -3
- package/dist/{access-Dl13x6mB.js → access-CembYDiI.js} +121 -7
- package/dist/access.d.ts +2 -2
- package/dist/access.js +2 -2
- package/dist/dotenv.js +1 -1
- package/dist/identity.d.ts +148 -13
- package/dist/identity.js +347 -19
- package/dist/kek.js +1 -1
- package/dist/schemas.js +1 -1
- package/dist/vault.d.ts +37 -7
- package/dist/workloads-CP54Q72p.d.ts +418 -0
- package/dist/workloads.d.ts +2 -206
- package/dist/workloads.js +395 -10
- package/package.json +4 -3
- package/src/access.ts +149 -9
- package/src/dotenv.ts +1 -1
- package/src/identity/constraints.ts +168 -0
- package/src/identity/dpop.ts +234 -0
- package/src/identity/index.ts +2 -0
- package/src/identity/signin/config.ts +33 -2
- package/src/identity/signin/sealed.ts +5 -2
- package/src/identity/tokens.ts +17 -7
- package/src/identity/verifier.ts +2 -2
- package/src/identity/workload-token.ts +12 -9
- package/src/identity/workloads.ts +523 -13
- package/src/kek/local.ts +4 -2
- package/src/vault.ts +38 -7
|
@@ -313,6 +313,18 @@ declare function ownsInstance(standing: {
|
|
|
313
313
|
role: InstanceRole;
|
|
314
314
|
scope: Scope;
|
|
315
315
|
}): boolean;
|
|
316
|
+
/**
|
|
317
|
+
* Whether the holder is an Owner of a project, as a person on no
|
|
318
|
+
* credential's scope: an Owner of the whole instance, one scoped to the
|
|
319
|
+
* project, or one by a grant on it. They alone issue a service's token or
|
|
320
|
+
* trust binding that reads its sensitive values (R32, `readsSensitive`),
|
|
321
|
+
* and so make a sensitive value of its own a secret in place, and take its
|
|
322
|
+
* environments' protection off (R30): an Owner reads any value there
|
|
323
|
+
* anyway, through a service account they give read (break-glass). An
|
|
324
|
+
* Owner scoped to environments by slug, Owner of every `prod`, owns no
|
|
325
|
+
* project, and an Owner's token, scoped, none.
|
|
326
|
+
*/
|
|
327
|
+
declare function ownsProject(holder: Holdings, projectId: string): boolean;
|
|
316
328
|
/**
|
|
317
329
|
* Which projects, or environments, a scope takes in: all of them, only
|
|
318
330
|
* those listed, or all but those listed. Projects are listed by id, so a
|
|
@@ -408,7 +420,9 @@ declare function grantKind(grant: GrantPlace): 'project' | 'environment' | null;
|
|
|
408
420
|
* Each grant keeps what its role held when the credential was issued, both
|
|
409
421
|
* columns (`permissions`), and no more than its issuer held, so neither a
|
|
410
422
|
* role an Owner widens later nor its issuer widens the credential
|
|
411
|
-
* (docs/design/roles.md, section 8, rule 3).
|
|
423
|
+
* (docs/design/roles.md, section 8, rule 3). A service's grant keeps too
|
|
424
|
+
* whether its issuer was an Owner of the place, who alone hands a service
|
|
425
|
+
* its sensitive values (`readsSensitive`).
|
|
412
426
|
*/
|
|
413
427
|
type CredentialScope = readonly ScopeGrant[];
|
|
414
428
|
/** What a role holds, or a credential's grant held when it was issued: where nothing is protected, and in a protected environment. */
|
|
@@ -421,11 +435,18 @@ type Columns = {
|
|
|
421
435
|
* the credential was issued (`issuedGrant`). One kept by a release before
|
|
422
436
|
* 0.10, its role's name alone, holds that role as it ships, a constant no
|
|
423
437
|
* edit changes, so it never widens either: a built-in role's, or nothing
|
|
424
|
-
* for any other name.
|
|
438
|
+
* for any other name. A service's, whether it reads the sensitive values
|
|
439
|
+
* there: true only when an Owner of its project issued it
|
|
440
|
+
* (`readsSensitive`); left out on a person's, who reads none. A
|
|
441
|
+
* workload's, the keys there it may read rather than use, by ID, or `'*'`
|
|
442
|
+
* for every one (docs/design/workload-access.md, section 6.1): its
|
|
443
|
+
* binding's `reads` at that place, and left out for any other credential.
|
|
425
444
|
*/
|
|
426
445
|
type ScopeGrant = GrantPlace & {
|
|
427
446
|
role: Role;
|
|
428
447
|
permissions?: Columns;
|
|
448
|
+
sensitive?: boolean;
|
|
449
|
+
reads?: readonly string[] | '*';
|
|
429
450
|
};
|
|
430
451
|
/**
|
|
431
452
|
* A grant of a scope with what its role holds now in `policy`, kept: what a
|
|
@@ -515,7 +536,21 @@ type Holdings = {
|
|
|
515
536
|
policy?: Policy;
|
|
516
537
|
/** A service account's, which holds each role's normal column everywhere; a person's holds a protected environment's column there. */
|
|
517
538
|
service?: boolean;
|
|
539
|
+
/**
|
|
540
|
+
* What the request came in on (`CallerKind`): a workload's key-bound
|
|
541
|
+
* session is handed back only the values its scope lists (`useOnly`).
|
|
542
|
+
* Absent, anything but a workload.
|
|
543
|
+
*/
|
|
544
|
+
kind?: CallerKind;
|
|
518
545
|
};
|
|
546
|
+
/**
|
|
547
|
+
* What kind of credential a request comes in on: a person's (a session or
|
|
548
|
+
* a personal token), a bearer's (a service token, or one a trust binding
|
|
549
|
+
* exchanged), or a workload's key-bound session, which reads only plain
|
|
550
|
+
* values and those its binding lists (docs/design/workload-access.md,
|
|
551
|
+
* section 6.1). The vault is told it with every call (`Through`).
|
|
552
|
+
*/
|
|
553
|
+
type CallerKind = 'person' | 'bearer' | 'workload';
|
|
519
554
|
/** Someone who holds nothing: a stranger, a removed member, a tampered row. */
|
|
520
555
|
declare const NOTHING: Holdings;
|
|
521
556
|
/**
|
|
@@ -543,6 +578,64 @@ declare function allows(holder: Holdings, permission: Permission, place: Place):
|
|
|
543
578
|
* role its scope names there: a viewer's token reads it, and writes nothing.
|
|
544
579
|
*/
|
|
545
580
|
declare function withinCredential(holder: Holdings, permission: Permission, place: Place): boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Whether a sensitive value of the project `projectId` is handed to
|
|
583
|
+
* `holder` (R32): never to a person, Owners included (R16); to a service
|
|
584
|
+
* account, only on a credential an Owner of that project issued, as a
|
|
585
|
+
* grant of its scope in the project says (`ScopeGrant`'s `sensitive`).
|
|
586
|
+
* The project is the value's own, wherever it is read: a reference's
|
|
587
|
+
* source's, which lends its value and nature (R23), while whoever reads it
|
|
588
|
+
* is decided where it is held. A person who could not read the value gets
|
|
589
|
+
* it through no account they set up, nor through a value made sensitive
|
|
590
|
+
* after they issued its token, nor through a reference into a project
|
|
591
|
+
* they do not own:
|
|
592
|
+
*
|
|
593
|
+
* ci, a Viewer of backend/dev, which holds STRIPE_SECRET_KEY, sensitive
|
|
594
|
+
* its token, issued by Ada, a Developer reads every other value there
|
|
595
|
+
* its token, issued by an Owner of backend reads STRIPE_SECRET_KEY too
|
|
596
|
+
* billing/dev/LEAK, a reference to it; a token for billing/dev
|
|
597
|
+
* issued by an Owner of billing alone reads every other value there
|
|
598
|
+
*/
|
|
599
|
+
declare function readsSensitive(holder: Holdings, projectId: string): boolean;
|
|
600
|
+
/** A key, by its id and where its value is held: a reference's source's, an inherited key's parent's. */
|
|
601
|
+
type HeldKey = {
|
|
602
|
+
projectId: string;
|
|
603
|
+
environmentId: string;
|
|
604
|
+
secretId: string;
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* Whether a value is use-only to `holder` (docs/design/workload-access.md,
|
|
608
|
+
* section 6.1): a workload is handed back no secret or sensitive value but
|
|
609
|
+
* one its credential's scope lists, by the key's id, on a grant that covers
|
|
610
|
+
* the place where the value is held, never the place a request names. A
|
|
611
|
+
* rename therefore moves no listing, and no reference, fork or copy moves a
|
|
612
|
+
* value under one. Nobody else's: their roles and the value's nature decide.
|
|
613
|
+
* A plain value is no secret, use-only to nobody, so it is never asked of.
|
|
614
|
+
*
|
|
615
|
+
* api-prod lists STRIPE_WEBHOOK_SECRET's id at market/prod
|
|
616
|
+
* market/prod/STRIPE_WEBHOOK_SECRET read
|
|
617
|
+
* STRIPE_SECRET_KEY, renamed STRIPE_WEBHOOK_SECRET once that moved use only: another id
|
|
618
|
+
* market/dev/S, a reference to it, with "*" at market/dev use only: held in market/prod
|
|
619
|
+
*/
|
|
620
|
+
declare function useOnly(holder: Holdings, key: HeldKey): boolean;
|
|
621
|
+
/**
|
|
622
|
+
* A workload's credential scope with its binding's `reads` on it, by
|
|
623
|
+
* environment ID (docs/design/workload-access.md, section 6.1): each
|
|
624
|
+
* environment's list on a grant at that environment, the scope's own there,
|
|
625
|
+
* or, where only a grant on its project reaches it, a grant made at the
|
|
626
|
+
* environment holding no more than that one does there. What the scope
|
|
627
|
+
* holds is unchanged, only what of it is handed back: a place it reaches
|
|
628
|
+
* nowhere lists nothing, and a list a grant carried is replaced, so a
|
|
629
|
+
* session reads what its binding lists now. `projectOf` names each listed
|
|
630
|
+
* environment's project; one it does not name, gone since, lists nothing.
|
|
631
|
+
*
|
|
632
|
+
* scope viewer on market
|
|
633
|
+
* reads { <prod>: { keys: [<STRIPE_WEBHOOK_SECRET>] } }
|
|
634
|
+
* result viewer on market; viewer on market/prod, reading STRIPE_WEBHOOK_SECRET
|
|
635
|
+
*/
|
|
636
|
+
declare function scopeWithReads(scope: CredentialScope, reads: Readonly<Record<string, {
|
|
637
|
+
readonly keys?: readonly string[] | '*';
|
|
638
|
+
}>> | undefined, projectOf: ReadonlyMap<string, string>): CredentialScope;
|
|
546
639
|
/**
|
|
547
640
|
* Whether the actor may give or take grants at this place: with
|
|
548
641
|
* `grant.manage` there, from a project grant or an instance role whose
|
|
@@ -638,4 +731,4 @@ declare function readsWholeLog(holder: Holdings): boolean;
|
|
|
638
731
|
*/
|
|
639
732
|
declare function makesProjects(holder: Holdings): boolean;
|
|
640
733
|
//#endregion
|
|
641
|
-
export {
|
|
734
|
+
export { isCredentialScope as $, Scope as A, convertEveryProjectGrants as At, credentialScopeInWords as B, Place as C, useOnly as Ct, ROLE_NAMES as D, ConvertedGrant as Dt, ROLE_ID as E, ConversionInput as Et, administers as F, givesService as G, definitionProblem as H, admits as I, heldColumns as J, grantKind as K, allows as L, ServiceAccount as M, ServiceSetting as N, Role as O, EveryProjectGrant as Ot, UNWRITTEN_FORK_MS as P, isBuiltinRole as Q, assignableToEnvironment as R, Permission as S, unscoped as St, ROLES as T, Conversion as Tt, delegable as U, definitionOf as V, delegableRoles as W, inScope as X, holds as Y, instanceRoleGrants as Z, MAX_PERSONAL_TOKEN_MINUTES as _, runsInstance as _t, DEFAULT_POLICY as a, makesProjects as at, PERMISSIONS as b, scopeWithReads as bt, EVERY_ENVIRONMENT as c, normalDefinition as ct, GrantPlace as d, ownsProject as dt, isInstanceRole as et, HeldKey as f, protectedWithin as ft, InstanceRole as g, roleGrants as gt, INSTANCE_ROLE_NAMES as h, readsWholeLog as ht, CredentialScope as i, issuesCredential as it, ScopeGrant as j, RoleDefinition as k, Narrowed as kt, FIXED_ROLES as l, normalScope as lt, INSTANCE_ROLES as m, readsSensitive as mt, CallerKind as n, isScope as nt, DELEGABLE_ROLES as o, managesService as ot, Holdings as p, protects as pt, guarded as q, Columns as r, issuedGrant as rt, EVERYWHERE as s, mayManageAccess as st, BuiltinRole as t, isRole as tt, Filter as u, ownsInstance as ut, MAX_SCOPE_PLACES as v, scopeDefinition as vt, Policy as w, withinCredential as wt, PROJECT_ONLY_PERMISSIONS as x, setsUpServices as xt, NOTHING as y, scopeInWords as yt, covers as z };
|
|
@@ -271,7 +271,11 @@ function assignableToEnvironment(role, policy = DEFAULT_POLICY) {
|
|
|
271
271
|
}
|
|
272
272
|
/** A project role's definition in `policy`, or undefined for none. */
|
|
273
273
|
function definitionOf(policy, role) {
|
|
274
|
-
return
|
|
274
|
+
return own(policy.roles, role);
|
|
275
|
+
}
|
|
276
|
+
/** A record's own value at `key`: `constructor` or `__proto__` names nothing. */
|
|
277
|
+
function own(record, key) {
|
|
278
|
+
return Object.hasOwn(record, key) ? record[key] : void 0;
|
|
275
279
|
}
|
|
276
280
|
/**
|
|
277
281
|
* A person's role on the whole instance: what they hold in every project
|
|
@@ -326,7 +330,7 @@ function isInstanceRole(value) {
|
|
|
326
330
|
}
|
|
327
331
|
/** Whether an instance role holds `permission` where nothing is protected, as `policy` defines it: as it ships, unless told. */
|
|
328
332
|
function instanceRoleGrants(role, permission, policy = DEFAULT_POLICY) {
|
|
329
|
-
return (policy.instanceRoles
|
|
333
|
+
return (own(policy.instanceRoles, role)?.permissions ?? []).includes(permission);
|
|
330
334
|
}
|
|
331
335
|
/** The policy before any Owner edits it: every role as it ships, and no environment protected. */
|
|
332
336
|
const DEFAULT_POLICY = {
|
|
@@ -411,6 +415,22 @@ function administers(role) {
|
|
|
411
415
|
function ownsInstance(standing) {
|
|
412
416
|
return standing.role === "owner" && unscoped(standing.scope);
|
|
413
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* Whether the holder is an Owner of a project, as a person on no
|
|
420
|
+
* credential's scope: an Owner of the whole instance, one scoped to the
|
|
421
|
+
* project, or one by a grant on it. They alone issue a service's token or
|
|
422
|
+
* trust binding that reads its sensitive values (R32, `readsSensitive`),
|
|
423
|
+
* and so make a sensitive value of its own a secret in place, and take its
|
|
424
|
+
* environments' protection off (R30): an Owner reads any value there
|
|
425
|
+
* anyway, through a service account they give read (break-glass). An
|
|
426
|
+
* Owner scoped to environments by slug, Owner of every `prod`, owns no
|
|
427
|
+
* project, and an Owner's token, scoped, none.
|
|
428
|
+
*/
|
|
429
|
+
function ownsProject(holder, projectId) {
|
|
430
|
+
if (holder.credentialScope != null || holder.service === true) return false;
|
|
431
|
+
const place = { projectId };
|
|
432
|
+
return holder.role === "owner" && inScope(holder.scope, place) || holder.grants.some((grant) => grant.role === "owner" && covers(grant, place));
|
|
433
|
+
}
|
|
414
434
|
/** Every project and every environment. */
|
|
415
435
|
const EVERYWHERE = {
|
|
416
436
|
projects: "all",
|
|
@@ -551,7 +571,7 @@ function heldColumns(holder, place) {
|
|
|
551
571
|
*/
|
|
552
572
|
function protectedWithin(policy, place) {
|
|
553
573
|
if (place.environmentId != null) return [];
|
|
554
|
-
return (policy.protectedIn
|
|
574
|
+
return (own(policy.protectedIn, place.projectId) ?? []).map(({ environmentId, slug }) => ({
|
|
555
575
|
projectId: place.projectId,
|
|
556
576
|
environmentId,
|
|
557
577
|
environmentSlug: slug
|
|
@@ -612,8 +632,11 @@ function isCredentialScope(value) {
|
|
|
612
632
|
const column = (list) => Array.isArray(list) && list.every((permission) => PERMISSIONS.includes(permission)) && new Set(list).size === list.length;
|
|
613
633
|
return value.every((grant) => {
|
|
614
634
|
if (typeof grant !== "object" || grant === null || Array.isArray(grant)) return false;
|
|
615
|
-
const { projectId, environmentId, role, permissions, ...rest } = grant;
|
|
635
|
+
const { projectId, environmentId, role, permissions, sensitive, reads, ...rest } = grant;
|
|
616
636
|
if (Object.keys(rest).length > 0 || typeof projectId !== "string" || typeof role !== "string") return false;
|
|
637
|
+
if (sensitive !== void 0 && typeof sensitive !== "boolean") return false;
|
|
638
|
+
if (reads !== void 0 && environmentId === null) return false;
|
|
639
|
+
if (reads !== void 0 && reads !== "*" && !(Array.isArray(reads) && reads.every((id) => typeof id === "string") && new Set(reads).size === reads.length)) return false;
|
|
617
640
|
if (!ROLE_ID.test(role)) return false;
|
|
618
641
|
if (permissions === void 0) {
|
|
619
642
|
if (!isBuiltinRole(role)) return false;
|
|
@@ -661,7 +684,7 @@ function covers(grant, place) {
|
|
|
661
684
|
function allows(holder, permission, place) {
|
|
662
685
|
if (holder.credentialScope != null && !scopeHolds(holder, permission, place)) return false;
|
|
663
686
|
const policy = holder.policy ?? DEFAULT_POLICY;
|
|
664
|
-
if (inScope(holder.scope, place) && holds(policy.instanceRoles
|
|
687
|
+
if (inScope(holder.scope, place) && holds(own(policy.instanceRoles, holder.role), permission, place, holder)) return true;
|
|
665
688
|
return holder.grants.some((grant) => covers(grant, place) && holds(definitionOf(policy, grant.role), permission, place, holder));
|
|
666
689
|
}
|
|
667
690
|
/**
|
|
@@ -679,6 +702,97 @@ function scopeHolds(holder, permission, place) {
|
|
|
679
702
|
return (holder.credentialScope ?? []).some((grant) => covers(grant, place) && holds(scopeDefinition(grant), permission, place, holder));
|
|
680
703
|
}
|
|
681
704
|
/**
|
|
705
|
+
* Whether a sensitive value of the project `projectId` is handed to
|
|
706
|
+
* `holder` (R32): never to a person, Owners included (R16); to a service
|
|
707
|
+
* account, only on a credential an Owner of that project issued, as a
|
|
708
|
+
* grant of its scope in the project says (`ScopeGrant`'s `sensitive`).
|
|
709
|
+
* The project is the value's own, wherever it is read: a reference's
|
|
710
|
+
* source's, which lends its value and nature (R23), while whoever reads it
|
|
711
|
+
* is decided where it is held. A person who could not read the value gets
|
|
712
|
+
* it through no account they set up, nor through a value made sensitive
|
|
713
|
+
* after they issued its token, nor through a reference into a project
|
|
714
|
+
* they do not own:
|
|
715
|
+
*
|
|
716
|
+
* ci, a Viewer of backend/dev, which holds STRIPE_SECRET_KEY, sensitive
|
|
717
|
+
* its token, issued by Ada, a Developer reads every other value there
|
|
718
|
+
* its token, issued by an Owner of backend reads STRIPE_SECRET_KEY too
|
|
719
|
+
* billing/dev/LEAK, a reference to it; a token for billing/dev
|
|
720
|
+
* issued by an Owner of billing alone reads every other value there
|
|
721
|
+
*/
|
|
722
|
+
function readsSensitive(holder, projectId) {
|
|
723
|
+
return holder.service === true && (holder.credentialScope ?? []).some((grant) => grant.sensitive === true && grant.projectId === projectId);
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Whether a value is use-only to `holder` (docs/design/workload-access.md,
|
|
727
|
+
* section 6.1): a workload is handed back no secret or sensitive value but
|
|
728
|
+
* one its credential's scope lists, by the key's id, on a grant that covers
|
|
729
|
+
* the place where the value is held, never the place a request names. A
|
|
730
|
+
* rename therefore moves no listing, and no reference, fork or copy moves a
|
|
731
|
+
* value under one. Nobody else's: their roles and the value's nature decide.
|
|
732
|
+
* A plain value is no secret, use-only to nobody, so it is never asked of.
|
|
733
|
+
*
|
|
734
|
+
* api-prod lists STRIPE_WEBHOOK_SECRET's id at market/prod
|
|
735
|
+
* market/prod/STRIPE_WEBHOOK_SECRET read
|
|
736
|
+
* STRIPE_SECRET_KEY, renamed STRIPE_WEBHOOK_SECRET once that moved use only: another id
|
|
737
|
+
* market/dev/S, a reference to it, with "*" at market/dev use only: held in market/prod
|
|
738
|
+
*/
|
|
739
|
+
function useOnly(holder, key) {
|
|
740
|
+
if (holder.kind !== "workload") return false;
|
|
741
|
+
const place = {
|
|
742
|
+
projectId: key.projectId,
|
|
743
|
+
environmentId: key.environmentId,
|
|
744
|
+
environmentSlug: null
|
|
745
|
+
};
|
|
746
|
+
return !(holder.credentialScope ?? []).some((grant) => covers(grant, place) && (grant.reads === "*" || (grant.reads?.includes(key.secretId) ?? false)));
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* A workload's credential scope with its binding's `reads` on it, by
|
|
750
|
+
* environment ID (docs/design/workload-access.md, section 6.1): each
|
|
751
|
+
* environment's list on a grant at that environment, the scope's own there,
|
|
752
|
+
* or, where only a grant on its project reaches it, a grant made at the
|
|
753
|
+
* environment holding no more than that one does there. What the scope
|
|
754
|
+
* holds is unchanged, only what of it is handed back: a place it reaches
|
|
755
|
+
* nowhere lists nothing, and a list a grant carried is replaced, so a
|
|
756
|
+
* session reads what its binding lists now. `projectOf` names each listed
|
|
757
|
+
* environment's project; one it does not name, gone since, lists nothing.
|
|
758
|
+
*
|
|
759
|
+
* scope viewer on market
|
|
760
|
+
* reads { <prod>: { keys: [<STRIPE_WEBHOOK_SECRET>] } }
|
|
761
|
+
* result viewer on market; viewer on market/prod, reading STRIPE_WEBHOOK_SECRET
|
|
762
|
+
*/
|
|
763
|
+
function scopeWithReads(scope, reads, projectOf) {
|
|
764
|
+
const unlisted = scope.map(({ reads: _, ...grant }) => grant);
|
|
765
|
+
const result = [...unlisted];
|
|
766
|
+
for (const [environmentId, { keys }] of Object.entries(reads ?? {})) {
|
|
767
|
+
const projectId = projectOf.get(environmentId);
|
|
768
|
+
if (keys === void 0 || projectId === void 0) continue;
|
|
769
|
+
const at = result.findIndex((grant) => grant.projectId === projectId && grant.environmentId === environmentId);
|
|
770
|
+
if (at >= 0) {
|
|
771
|
+
result[at] = {
|
|
772
|
+
...result[at],
|
|
773
|
+
reads: keys
|
|
774
|
+
};
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
777
|
+
const project = unlisted.find((grant) => grant.projectId === projectId && grant.environmentId === null);
|
|
778
|
+
if (project === void 0) continue;
|
|
779
|
+
const { permissions, protected: guarded } = scopeDefinition(project);
|
|
780
|
+
const here = (column) => column.filter((permission) => !PROJECT_ONLY_PERMISSIONS.includes(permission));
|
|
781
|
+
result.push({
|
|
782
|
+
projectId,
|
|
783
|
+
environmentId,
|
|
784
|
+
role: project.role,
|
|
785
|
+
permissions: {
|
|
786
|
+
normal: here(permissions),
|
|
787
|
+
protected: here(guarded)
|
|
788
|
+
},
|
|
789
|
+
...project.sensitive === void 0 ? {} : { sensitive: project.sensitive },
|
|
790
|
+
reads: keys
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
return result;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
682
796
|
* Whether the actor may give or take grants at this place: with
|
|
683
797
|
* `grant.manage` there, from a project grant or an instance role whose
|
|
684
798
|
* scope takes it in. A grant on a project reaches all its environments, so
|
|
@@ -777,7 +891,7 @@ function issuesCredential(holder, setting, actor, account, scope) {
|
|
|
777
891
|
* they hold `audit.read` in.
|
|
778
892
|
*/
|
|
779
893
|
function readsWholeLog(holder) {
|
|
780
|
-
const role = (holder.policy ?? DEFAULT_POLICY).instanceRoles
|
|
894
|
+
const role = own((holder.policy ?? DEFAULT_POLICY).instanceRoles, holder.role);
|
|
781
895
|
return holder.credentialScope == null && unscoped(holder.scope) && role !== void 0 && role.permissions.includes("audit.read") && role.protected.includes("audit.read");
|
|
782
896
|
}
|
|
783
897
|
/**
|
|
@@ -791,4 +905,4 @@ function makesProjects(holder) {
|
|
|
791
905
|
return holder.credentialScope == null && administers(holder.role) && environments === "all" && (projects === "all" || "except" in projects);
|
|
792
906
|
}
|
|
793
907
|
//#endregion
|
|
794
|
-
export {
|
|
908
|
+
export { runsInstance as $, heldColumns as A, issuesCredential as B, definitionOf as C, givesService as D, delegableRoles as E, isCredentialScope as F, normalScope as G, managesService as H, isInstanceRole as I, protectedWithin as J, ownsInstance as K, isRole as L, inScope as M, instanceRoleGrants as N, grantKind as O, isBuiltinRole as P, roleGrants as Q, isScope as R, credentialScopeInWords as S, delegable as T, mayManageAccess as U, makesProjects as V, normalDefinition as W, readsSensitive as X, protects as Y, readsWholeLog as Z, administers as _, FIXED_ROLES as a, useOnly as at, assignableToEnvironment as b, MAX_PERSONAL_TOKEN_MINUTES as c, PERMISSIONS as d, scopeDefinition as et, PROJECT_ONLY_PERMISSIONS as f, UNWRITTEN_FORK_MS as g, ROLE_NAMES as h, EVERY_ENVIRONMENT as i, unscoped as it, holds as j, guarded as k, MAX_SCOPE_PLACES as l, ROLE_ID as m, DELEGABLE_ROLES as n, scopeWithReads as nt, INSTANCE_ROLES as o, withinCredential as ot, ROLES as p, ownsProject as q, EVERYWHERE as r, setsUpServices as rt, INSTANCE_ROLE_NAMES as s, convertEveryProjectGrants as st, DEFAULT_POLICY as t, scopeInWords as tt, NOTHING as u, admits as v, definitionProblem as w, covers as x, allows as y, issuedGrant as z };
|
package/dist/access.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { BuiltinRole, Columns, type Conversion, type ConversionInput, type ConvertedGrant, CredentialScope, DEFAULT_POLICY, DELEGABLE_ROLES, EVERYWHERE, EVERY_ENVIRONMENT, type EveryProjectGrant, FIXED_ROLES, Filter, GrantPlace, Holdings, INSTANCE_ROLES, INSTANCE_ROLE_NAMES, InstanceRole, MAX_PERSONAL_TOKEN_MINUTES, MAX_SCOPE_PLACES, NOTHING, type Narrowed, PERMISSIONS, PROJECT_ONLY_PERMISSIONS, Permission, Place, Policy, ROLES, ROLE_ID, ROLE_NAMES, Role, RoleDefinition, Scope, ScopeGrant, ServiceAccount, ServiceSetting, UNWRITTEN_FORK_MS, administers, admits, allows, assignableToEnvironment, convertEveryProjectGrants, covers, credentialScopeInWords, definitionOf, definitionProblem, delegable, delegableRoles, givesService, grantKind, guarded, heldColumns, holds, inScope, instanceRoleGrants, isBuiltinRole, isCredentialScope, isInstanceRole, isRole, isScope, issuedGrant, issuesCredential, makesProjects, managesService, mayManageAccess, normalDefinition, normalScope, ownsInstance, protectedWithin, protects, readsWholeLog, roleGrants, runsInstance, scopeDefinition, scopeInWords, setsUpServices, unscoped, withinCredential };
|
|
1
|
+
import { $ as isCredentialScope, A as Scope, At as convertEveryProjectGrants, B as credentialScopeInWords, C as Place, Ct as useOnly, D as ROLE_NAMES, Dt as ConvertedGrant, E as ROLE_ID, Et as ConversionInput, F as administers, G as givesService, H as definitionProblem, I as admits, J as heldColumns, K as grantKind, L as allows, M as ServiceAccount, N as ServiceSetting, O as Role, Ot as EveryProjectGrant, P as UNWRITTEN_FORK_MS, Q as isBuiltinRole, R as assignableToEnvironment, S as Permission, St as unscoped, T as ROLES, Tt as Conversion, U as delegable, V as definitionOf, W as delegableRoles, X as inScope, Y as holds, Z as instanceRoleGrants, _ as MAX_PERSONAL_TOKEN_MINUTES, _t as runsInstance, a as DEFAULT_POLICY, at as makesProjects, b as PERMISSIONS, bt as scopeWithReads, c as EVERY_ENVIRONMENT, ct as normalDefinition, d as GrantPlace, dt as ownsProject, et as isInstanceRole, f as HeldKey, ft as protectedWithin, g as InstanceRole, gt as roleGrants, h as INSTANCE_ROLE_NAMES, ht as readsWholeLog, i as CredentialScope, it as issuesCredential, j as ScopeGrant, k as RoleDefinition, kt as Narrowed, l as FIXED_ROLES, lt as normalScope, m as INSTANCE_ROLES, mt as readsSensitive, n as CallerKind, nt as isScope, o as DELEGABLE_ROLES, ot as managesService, p as Holdings, pt as protects, q as guarded, r as Columns, rt as issuedGrant, s as EVERYWHERE, st as mayManageAccess, t as BuiltinRole, tt as isRole, u as Filter, ut as ownsInstance, v as MAX_SCOPE_PLACES, vt as scopeDefinition, w as Policy, wt as withinCredential, x as PROJECT_ONLY_PERMISSIONS, xt as setsUpServices, y as NOTHING, yt as scopeInWords, z as covers } from "./access-CU3xEOLH.js";
|
|
2
|
+
export { BuiltinRole, CallerKind, Columns, type Conversion, type ConversionInput, type ConvertedGrant, CredentialScope, DEFAULT_POLICY, DELEGABLE_ROLES, EVERYWHERE, EVERY_ENVIRONMENT, type EveryProjectGrant, FIXED_ROLES, Filter, GrantPlace, HeldKey, Holdings, INSTANCE_ROLES, INSTANCE_ROLE_NAMES, InstanceRole, MAX_PERSONAL_TOKEN_MINUTES, MAX_SCOPE_PLACES, NOTHING, type Narrowed, PERMISSIONS, PROJECT_ONLY_PERMISSIONS, Permission, Place, Policy, ROLES, ROLE_ID, ROLE_NAMES, Role, RoleDefinition, Scope, ScopeGrant, ServiceAccount, ServiceSetting, UNWRITTEN_FORK_MS, administers, admits, allows, assignableToEnvironment, convertEveryProjectGrants, covers, credentialScopeInWords, definitionOf, definitionProblem, delegable, delegableRoles, givesService, grantKind, guarded, heldColumns, holds, inScope, instanceRoleGrants, isBuiltinRole, isCredentialScope, isInstanceRole, isRole, isScope, issuedGrant, issuesCredential, makesProjects, managesService, mayManageAccess, normalDefinition, normalScope, ownsInstance, ownsProject, protectedWithin, protects, readsSensitive, readsWholeLog, roleGrants, runsInstance, scopeDefinition, scopeInWords, scopeWithReads, setsUpServices, unscoped, useOnly, withinCredential };
|
package/dist/access.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { DEFAULT_POLICY, DELEGABLE_ROLES, EVERYWHERE, EVERY_ENVIRONMENT, FIXED_ROLES, INSTANCE_ROLES, INSTANCE_ROLE_NAMES, MAX_PERSONAL_TOKEN_MINUTES, MAX_SCOPE_PLACES, NOTHING, PERMISSIONS, PROJECT_ONLY_PERMISSIONS, ROLES, ROLE_ID, ROLE_NAMES, UNWRITTEN_FORK_MS, administers, admits, allows, assignableToEnvironment, convertEveryProjectGrants, covers, credentialScopeInWords, definitionOf, definitionProblem, delegable, delegableRoles, givesService, grantKind, guarded, heldColumns, holds, inScope, instanceRoleGrants, isBuiltinRole, isCredentialScope, isInstanceRole, isRole, isScope, issuedGrant, issuesCredential, makesProjects, managesService, mayManageAccess, normalDefinition, normalScope, ownsInstance, protectedWithin, protects, readsWholeLog, roleGrants, runsInstance, scopeDefinition, scopeInWords, setsUpServices, unscoped, withinCredential };
|
|
1
|
+
import { $ as runsInstance, A as heldColumns, B as issuesCredential, C as definitionOf, D as givesService, E as delegableRoles, F as isCredentialScope, G as normalScope, H as managesService, I as isInstanceRole, J as protectedWithin, K as ownsInstance, L as isRole, M as inScope, N as instanceRoleGrants, O as grantKind, P as isBuiltinRole, Q as roleGrants, R as isScope, S as credentialScopeInWords, T as delegable, U as mayManageAccess, V as makesProjects, W as normalDefinition, X as readsSensitive, Y as protects, Z as readsWholeLog, _ as administers, a as FIXED_ROLES, at as useOnly, b as assignableToEnvironment, c as MAX_PERSONAL_TOKEN_MINUTES, d as PERMISSIONS, et as scopeDefinition, f as PROJECT_ONLY_PERMISSIONS, g as UNWRITTEN_FORK_MS, h as ROLE_NAMES, i as EVERY_ENVIRONMENT, it as unscoped, j as holds, k as guarded, l as MAX_SCOPE_PLACES, m as ROLE_ID, n as DELEGABLE_ROLES, nt as scopeWithReads, o as INSTANCE_ROLES, ot as withinCredential, p as ROLES, q as ownsProject, r as EVERYWHERE, rt as setsUpServices, s as INSTANCE_ROLE_NAMES, st as convertEveryProjectGrants, t as DEFAULT_POLICY, tt as scopeInWords, u as NOTHING, v as admits, w as definitionProblem, x as covers, y as allows, z as issuedGrant } from "./access-CembYDiI.js";
|
|
2
|
+
export { DEFAULT_POLICY, DELEGABLE_ROLES, EVERYWHERE, EVERY_ENVIRONMENT, FIXED_ROLES, INSTANCE_ROLES, INSTANCE_ROLE_NAMES, MAX_PERSONAL_TOKEN_MINUTES, MAX_SCOPE_PLACES, NOTHING, PERMISSIONS, PROJECT_ONLY_PERMISSIONS, ROLES, ROLE_ID, ROLE_NAMES, UNWRITTEN_FORK_MS, administers, admits, allows, assignableToEnvironment, convertEveryProjectGrants, covers, credentialScopeInWords, definitionOf, definitionProblem, delegable, delegableRoles, givesService, grantKind, guarded, heldColumns, holds, inScope, instanceRoleGrants, isBuiltinRole, isCredentialScope, isInstanceRole, isRole, isScope, issuedGrant, issuesCredential, makesProjects, managesService, mayManageAccess, normalDefinition, normalScope, ownsInstance, ownsProject, protectedWithin, protects, readsSensitive, readsWholeLog, roleGrants, runsInstance, scopeDefinition, scopeInWords, scopeWithReads, setsUpServices, unscoped, useOnly, withinCredential };
|
package/dist/dotenv.js
CHANGED
package/dist/identity.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
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-CP54Q72p.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";
|
|
2
3
|
import { JSONWebKeySet, JWTPayload } from "jose";
|
|
3
4
|
//#region src/identity/github-app.d.ts
|
|
4
5
|
/**
|
|
@@ -340,6 +341,18 @@ export type WorkloadsOptions = {
|
|
|
340
341
|
* and only public ones' IDs are looked up.
|
|
341
342
|
*/
|
|
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;
|
|
343
356
|
};
|
|
344
357
|
/** Cloudflare's rate-limiting binding, as coffre calls it; `processLimits()` has the same shape. */
|
|
345
358
|
export type RateLimiter = {
|
|
@@ -357,6 +370,9 @@ export type WorkloadsConfig = {
|
|
|
357
370
|
allowLoopback: boolean;
|
|
358
371
|
limits: WorkloadLimits;
|
|
359
372
|
github: GitHubApp | null;
|
|
373
|
+
useOnly: boolean;
|
|
374
|
+
noReads: boolean;
|
|
375
|
+
alert: ((alert: WorkloadAlert) => unknown) | null;
|
|
360
376
|
};
|
|
361
377
|
/**
|
|
362
378
|
* MCP clients, Claude among them, acting as the people who connect them,
|
|
@@ -580,6 +596,114 @@ export type SigninOptions = {
|
|
|
580
596
|
*/
|
|
581
597
|
export declare function signin(options: SigninOptions): Auth;
|
|
582
598
|
//#endregion
|
|
599
|
+
//#region src/identity/dpop.d.ts
|
|
600
|
+
/** How far a proof's `iat` may be from now: the nonce, not the clock, is what makes a proof fresh. */
|
|
601
|
+
export declare const PROOF_SKEW_SECONDS = 300;
|
|
602
|
+
/** Why a proof was refused, which a 401's `reason` names under `error="invalid_dpop_proof"`. */
|
|
603
|
+
export type ProofReason = 'malformed' | 'key' | 'jkt' | 'signature' | 'htm' | 'htu' | 'ath' | 'req' | 'iat';
|
|
604
|
+
export type ProofRefusal = {
|
|
605
|
+
ok: false;
|
|
606
|
+
reason: ProofReason;
|
|
607
|
+
message: string;
|
|
608
|
+
};
|
|
609
|
+
/** A proof whose shape, key and claims hold: what `verifyProof` checks against the request. */
|
|
610
|
+
export type ParsedProof = {
|
|
611
|
+
ok: true;
|
|
612
|
+
jwk: PublicJwk$1;
|
|
613
|
+
claims: ProofClaims$1;
|
|
614
|
+
/** The headers it signs, in `hdr`'s order; null for a proof that signs no content. */
|
|
615
|
+
hdr: readonly string[] | null;
|
|
616
|
+
signingInput: string;
|
|
617
|
+
signature: Uint8Array;
|
|
618
|
+
};
|
|
619
|
+
/** A proof that holds for its request: its key's thumbprint, and what the gate checks. */
|
|
620
|
+
export type VerifiedProof = {
|
|
621
|
+
ok: true;
|
|
622
|
+
jkt: string;
|
|
623
|
+
jti: string;
|
|
624
|
+
nonce: string | null;
|
|
625
|
+
iat: number;
|
|
626
|
+
hdr: readonly string[] | null;
|
|
627
|
+
};
|
|
628
|
+
/** What the request says a proof must sign. */
|
|
629
|
+
export type ProofExpectation = {
|
|
630
|
+
/** The request's method and URL, as received: `Request.method`, which the Fetch API has normalized as `fetchMethod` does. */
|
|
631
|
+
method: string;
|
|
632
|
+
url: string | URL;
|
|
633
|
+
/** The session row's `jkt`; none at the exchange, where the proof's key becomes the session's. */
|
|
634
|
+
jkt?: string;
|
|
635
|
+
/** The session token the request carries, which `ath` signs; none at the exchange. */
|
|
636
|
+
token?: string;
|
|
637
|
+
/** The request's headers and its body's digest, which `hdr` and `req` sign: for a request coffre forwards. */
|
|
638
|
+
content?: {
|
|
639
|
+
headers: Headers;
|
|
640
|
+
body: string;
|
|
641
|
+
};
|
|
642
|
+
/** Seconds `iat` may be from now: 300 unless said, 60 at the exchange. */
|
|
643
|
+
skewSeconds?: number;
|
|
644
|
+
/** Now, in milliseconds, for tests. */
|
|
645
|
+
now?: number;
|
|
646
|
+
};
|
|
647
|
+
/** Steps 1 to 3: the proof's shape, its key's and its claims', with no I/O. */
|
|
648
|
+
export declare function parseProof(proof: string): ParsedProof | ProofRefusal;
|
|
649
|
+
/**
|
|
650
|
+
* Steps 5 and 6: the proof against its request, `parseProof`'s first when
|
|
651
|
+
* given a string. Nothing here reads a store, so the gate (step 7) still
|
|
652
|
+
* decides whether this `jti` was seen.
|
|
653
|
+
*/
|
|
654
|
+
export declare function verifyProof(proof: string | ParsedProof, expect: ProofExpectation): Promise<VerifiedProof | ProofRefusal>;
|
|
655
|
+
/** A count a request asks the gate for: the requests under `key` in the last `windowMs`, at most `most`. */
|
|
656
|
+
export type GateCount = {
|
|
657
|
+
key: string;
|
|
658
|
+
windowMs: number;
|
|
659
|
+
most: number;
|
|
660
|
+
};
|
|
661
|
+
/** What the gate answers a request: its nonce on success, or why not. */
|
|
662
|
+
export type GateAdmission = {
|
|
663
|
+
ok: true;
|
|
664
|
+
nonce: string;
|
|
665
|
+
} | {
|
|
666
|
+
ok: false;
|
|
667
|
+
reason: 'use_dpop_nonce';
|
|
668
|
+
nonce: string;
|
|
669
|
+
} | {
|
|
670
|
+
ok: false;
|
|
671
|
+
reason: 'replayed' | 'overloaded';
|
|
672
|
+
} |
|
|
673
|
+
/** `first`: the first refusal of this key in its window, which alerts. */
|
|
674
|
+
{
|
|
675
|
+
ok: false;
|
|
676
|
+
reason: 'limit';
|
|
677
|
+
key: string;
|
|
678
|
+
retryAfterMs: number;
|
|
679
|
+
first: boolean;
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
682
|
+
* One workload's gate (section 5.2): a Durable Object on Workers, an object
|
|
683
|
+
* in the process on Node. Its nonces are epochs: a gate accepts the current
|
|
684
|
+
* and the previous one, remembers each epoch's `jti`s, and draws a new epoch
|
|
685
|
+
* when it starts, so a restart forgets nothing that matters. It decides no
|
|
686
|
+
* one's access: freezes, revocations and grants are the database's.
|
|
687
|
+
*/
|
|
688
|
+
export interface Gate {
|
|
689
|
+
/** Its current nonce, `g<n>.<epoch>`, for an answer that admits no proof: the exchange's `DPoP-Nonce`. */
|
|
690
|
+
nonce(): Promise<string>;
|
|
691
|
+
/**
|
|
692
|
+
* Replay and nonce, for a request that carries a proof (a Cloudflare call
|
|
693
|
+
* carries none, and has counts only); then, in the same call, every count
|
|
694
|
+
* the request asks for. A nonce of an epoch gone gets `use_dpop_nonce`; a
|
|
695
|
+
* proof with none never reaches the gate, and gets `nonce()`'s.
|
|
696
|
+
*/
|
|
697
|
+
admit(request: {
|
|
698
|
+
replay?: {
|
|
699
|
+
session: string;
|
|
700
|
+
jti: string;
|
|
701
|
+
nonce: string;
|
|
702
|
+
};
|
|
703
|
+
counts?: readonly GateCount[];
|
|
704
|
+
}): Promise<GateAdmission>;
|
|
705
|
+
}
|
|
706
|
+
//#endregion
|
|
583
707
|
//#region src/identity/signin/sealed.d.ts
|
|
584
708
|
/**
|
|
585
709
|
* Derive a purpose-bound key from one of coffre's existing 32-byte secrets.
|
|
@@ -608,7 +732,12 @@ export declare function unseal<T>(key: Uint8Array, sealed: string | undefined |
|
|
|
608
732
|
* service tokens, personal tokens, which act as the person who made
|
|
609
733
|
* them within the scope they named, and handles, which reach nothing but
|
|
610
734
|
* the credential proxy (`@coffre/server/plugins/credential-proxy`): the
|
|
611
|
-
* placeholder a person's app holds in place of a secret's value.
|
|
735
|
+
* placeholder a person's app holds in place of a secret's value. And a
|
|
736
|
+
* workload's sessions, which are bound to its key and useless without a
|
|
737
|
+
* proof it signs (docs/design/workload-access.md, section 5), and the
|
|
738
|
+
* enrollment codes CI mints for platforms that sign nothing, which are no
|
|
739
|
+
* credential at all: they buy a session at `/api/auth/workload`, and every
|
|
740
|
+
* other route refuses one.
|
|
612
741
|
*
|
|
613
742
|
* A token is a kind prefix and 32 random bytes, e.g.
|
|
614
743
|
* `coffre_cli_Qm9Y...`. The prefix tells a person (or a secret scanner) what a
|
|
@@ -617,15 +746,17 @@ export declare function unseal<T>(key: Uint8Array, sealed: string | undefined |
|
|
|
617
746
|
* right tool here, unlike for passwords: 256 bits of randomness leave nothing
|
|
618
747
|
* to brute-force.
|
|
619
748
|
*/
|
|
620
|
-
export type CredentialKind = 'browser' | 'cli' | 'service' | 'personal' | 'handle';
|
|
621
|
-
|
|
749
|
+
export type CredentialKind = 'browser' | 'cli' | 'service' | 'personal' | 'handle' | 'workload';
|
|
750
|
+
/** What a token's prefix says it is: a credential, or an enrollment code. */
|
|
751
|
+
export type TokenKind = CredentialKind | 'enrollment';
|
|
752
|
+
export declare function generateToken(kind: TokenKind): string;
|
|
622
753
|
/** Whether a string has the shape of a coffre token, before any lookup. */
|
|
623
754
|
export declare function isCoffreToken(value: string): boolean;
|
|
624
755
|
/**
|
|
625
756
|
* The kind a token's prefix says, before any lookup. Its hash covers the
|
|
626
757
|
* prefix, so a token found under its hash is the kind it says.
|
|
627
758
|
*/
|
|
628
|
-
export declare function tokenKind(token: string):
|
|
759
|
+
export declare function tokenKind(token: string): TokenKind | null;
|
|
629
760
|
export declare function hashToken(token: string): Buffer;
|
|
630
761
|
/**
|
|
631
762
|
* Enough of a token to recognize it in a list, never enough to use it: the
|
|
@@ -642,8 +773,8 @@ type AccessClaims = JWTPayload & {
|
|
|
642
773
|
/**
|
|
643
774
|
* Verifies Cloudflare Access JWTs.
|
|
644
775
|
*
|
|
645
|
-
* Signature and claim verification
|
|
646
|
-
*
|
|
776
|
+
* Signature and claim verification of the token Access sends with each
|
|
777
|
+
* request.
|
|
647
778
|
*/
|
|
648
779
|
export declare class AccessIdentityVerifier implements IdentityVerifier {
|
|
649
780
|
#private;
|
|
@@ -721,21 +852,25 @@ export declare function decodeWorkloadToken(token: string): DecodedToken;
|
|
|
721
852
|
* the issuer exactly; `exp`, `nbf` and `iat` within the tolerance, `iat` at
|
|
722
853
|
* most an hour old; and the audience, this instance's public URL alone.
|
|
723
854
|
* With `maxLifetime`, in seconds, a token whose `exp` is further than that
|
|
724
|
-
* from its `iat` is refused too.
|
|
855
|
+
* from its `iat` is refused too. With `maxAge: null`, its `iat` may be any
|
|
856
|
+
* age, and its own `exp` alone ends it: a token its platform hands out
|
|
857
|
+
* again for hours, a managed identity's (docs/design/workload-access.md,
|
|
858
|
+
* section 4.2). Returns the verified claims.
|
|
725
859
|
*/
|
|
726
860
|
export declare function verifyWorkloadToken(token: string, keys: JSONWebKeySet, expected: {
|
|
727
861
|
issuer: string;
|
|
728
862
|
audience: string;
|
|
729
863
|
now: Date;
|
|
730
864
|
maxLifetime?: number;
|
|
865
|
+
maxAge?: null;
|
|
731
866
|
}): Promise<JWTPayload & DecodedToken['claims']>;
|
|
732
867
|
/**
|
|
733
868
|
* Why a token issued at `iat` may not be exchanged at `now`, both in
|
|
734
|
-
* seconds, or null: issued
|
|
735
|
-
* ahead than the clock tolerance.
|
|
736
|
-
* both ask it.
|
|
869
|
+
* seconds, or null: issued `maxAge` seconds ago at most, an hour unless
|
|
870
|
+
* said, exactly, and no further ahead than the clock tolerance.
|
|
871
|
+
* Verification and the exchange's commit both ask it.
|
|
737
872
|
*/
|
|
738
|
-
export declare function issuedRefusal(iat: number, now: number): WorkloadTokenRefused | null;
|
|
873
|
+
export declare function issuedRefusal(iat: number, now: number, maxAge?: number): WorkloadTokenRefused | null;
|
|
739
874
|
/** At most this many keys in a set, fetched or uploaded. */
|
|
740
875
|
export declare const MAX_KEYS = 32;
|
|
741
876
|
/** One key of an uploaded set, as an owner sees it: its `kid`, its algorithm, and its RFC 7638 thumbprint. */
|
|
@@ -774,4 +909,4 @@ export declare function uploadedKeys(value: unknown): Promise<UploadedKeys>;
|
|
|
774
909
|
/** The keys of a set `uploadedKeys` kept, as an owner sees them. */
|
|
775
910
|
export declare function keySummaries(jwks: string): KeySummary[];
|
|
776
911
|
//#endregion
|
|
777
|
-
export { BindingClaims, BindingInvalid, BindingPolicy, ClaimValue, EVENT_EXPOSURE, GITHUB_EVENTS, GITHUB_ISSUER, GITLAB_ISSUER, GITLAB_PIPELINE_SOURCES, type JSONWebKeySet, MAX_BINDINGS, MAX_CLAIMS, MAX_CLAIM_BYTES, MAX_ISSUER_BYTES, REQUIRED_CLAIMS, Starts, WORKLOAD_PROFILES, WorkloadProfile, canonicalClaims, checkBinding, checkFetchUrl, claimAt, claimValues, defaultIssuer, differingClaims, fullRef, githubEventsAt, githubReusable, githubWorkflow, gitlabProject, workflowRef };
|
|
912
|
+
export { BEARER_PROFILES, BearerProfile, BindingClaims, BindingInvalid, BindingPolicy, BindingReads, CREDENTIAL_NAME, CheckedBinding, Cidr, ClaimValue, Constraints, ConstraintsInvalid, EVENT_EXPOSURE, 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, Starts, WORKLOAD_PROFILES, 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 };
|