@intentius/chant 0.124.62 → 0.124.64
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/cli/handlers/approve.d.ts +26 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +167 -18
- package/dist/cli/handlers/plan.d.ts +10 -0
- package/dist/cli/handlers/plan.d.ts.map +1 -0
- package/dist/cli/handlers/plan.js +71 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +2 -1
- package/dist/cli/handlers/release.d.ts +11 -7
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +93 -20
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +48 -7
- package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
- package/dist/cli/mcp/workspace-tools.js +2 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +43 -0
- package/dist/cli/registry.d.ts +18 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/config.d.ts +50 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/gate-decision.d.ts +1 -1
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +4 -2
- package/dist/gate-statement.schema.json +46 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
- package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
- package/dist/lifecycle/gate-ledger.d.ts +28 -5
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +6 -0
- package/dist/lifecycle/gate-seal.d.ts +59 -7
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +68 -15
- package/dist/lifecycle/gate-statement.d.ts +95 -0
- package/dist/lifecycle/gate-statement.d.ts.map +1 -0
- package/dist/lifecycle/gate-statement.js +110 -0
- package/dist/lifecycle/gate-webauthn.d.ts +79 -0
- package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
- package/dist/lifecycle/gate-webauthn.js +105 -0
- package/dist/lifecycle/git.d.ts +1 -1
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +24 -19
- package/dist/lifecycle/ledger-remote.d.ts +37 -0
- package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
- package/dist/lifecycle/ledger-remote.js +42 -0
- package/dist/lifecycle/plan-stale.d.ts +76 -0
- package/dist/lifecycle/plan-stale.d.ts.map +1 -0
- package/dist/lifecycle/plan-stale.js +120 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
- package/dist/lifecycle/publish-credentials.js +2 -0
- package/dist/lifecycle/publish-declaration.d.ts +107 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +110 -1
- package/dist/lifecycle/publish-forge.d.ts +5 -1
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +13 -4
- package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
- package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
- package/dist/lifecycle/publish-git-ssh.js +180 -0
- package/dist/lifecycle/publish-github.d.ts +69 -0
- package/dist/lifecycle/publish-github.d.ts.map +1 -0
- package/dist/lifecycle/publish-github.js +153 -0
- package/dist/lifecycle/publish-homebrew.d.ts +77 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
- package/dist/lifecycle/publish-homebrew.js +265 -0
- package/dist/lifecycle/publish-marketplace.d.ts +85 -0
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
- package/dist/lifecycle/publish-marketplace.js +398 -0
- package/dist/lifecycle/publish-targets.d.ts +6 -0
- package/dist/lifecycle/publish-targets.d.ts.map +1 -1
- package/dist/lifecycle/publish-targets.js +15 -0
- package/dist/lifecycle/publish-tauri.d.ts +61 -0
- package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
- package/dist/lifecycle/publish-tauri.js +181 -0
- package/dist/lifecycle/release-cut.d.ts +51 -5
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +165 -16
- package/dist/lifecycle/release-publish.d.ts +18 -2
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.js +5 -0
- package/dist/lifecycle/release-revocation.d.ts +4 -3
- package/dist/lifecycle/release-revocation.d.ts.map +1 -1
- package/dist/lifecycle/release-revocation.js +5 -4
- package/dist/lifecycle/release-store.d.ts +32 -0
- package/dist/lifecycle/release-store.d.ts.map +1 -1
- package/dist/lifecycle/release-store.js +11 -0
- package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.js +17 -9
- package/dist/lifecycle/test-passkey.d.ts +25 -0
- package/dist/lifecycle/test-passkey.d.ts.map +1 -0
- package/dist/lifecycle/test-passkey.js +39 -0
- package/dist/notify.d.ts +23 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +8 -2
- package/dist/notify.schema.json +12 -3
- package/dist/op/gate.d.ts +1 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +2 -1
- package/dist/pr-forge.d.ts +20 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +87 -8
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +333 -331
- package/dist/workspace/ci-builds.d.ts +21 -0
- package/dist/workspace/ci-builds.d.ts.map +1 -1
- package/dist/workspace/ci-builds.js +14 -0
- package/dist/workspace/ci-green.d.ts +45 -2
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +123 -5
- package/dist/workspace/ci-quarantine-report.d.ts +80 -0
- package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine-report.js +204 -0
- package/dist/workspace/ci-quarantine.d.ts +73 -0
- package/dist/workspace/ci-quarantine.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine.js +170 -0
- package/dist/workspace/ci-serve.d.ts.map +1 -1
- package/dist/workspace/ci-serve.js +7 -4
- package/dist/workspace/class-data.d.ts +3 -1
- package/dist/workspace/class-data.d.ts.map +1 -1
- package/dist/workspace/class-data.js +4 -1
- package/dist/workspace/declaration.d.ts +45 -2
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +45 -2
- package/dist/workspace/declaration.schema.json +51 -3
- package/dist/workspace/forge-work.d.ts +76 -0
- package/dist/workspace/forge-work.d.ts.map +1 -0
- package/dist/workspace/forge-work.js +160 -0
- package/dist/workspace/identity-gate-rule.d.ts +3 -2
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +5 -7
- package/dist/workspace/identity.d.ts +3 -2
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/identity.js +6 -3
- package/dist/workspace/intent-cli.d.ts +3 -2
- package/dist/workspace/intent-cli.d.ts.map +1 -1
- package/dist/workspace/intent-cli.js +26 -5
- package/dist/workspace/intent-record.d.ts +3 -0
- package/dist/workspace/intent-record.d.ts.map +1 -1
- package/dist/workspace/intent-record.schema.json +32 -0
- package/dist/workspace/intent.d.ts +9 -0
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +2 -0
- package/dist/workspace/intent.schema.json +32 -0
- package/dist/workspace/kind-readers.d.ts.map +1 -1
- package/dist/workspace/kind-readers.js +2 -1
- package/dist/workspace/kinds.d.ts +6 -1
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +8 -3
- package/dist/workspace/plan-stale.schema.json +286 -0
- package/dist/workspace/release-candidates.d.ts +42 -7
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +64 -23
- package/dist/workspace/release-candidates.schema.json +55 -2
- package/dist/workspace/releases.schema.json +47 -0
- package/dist/workspace/trust/policy.d.ts +10 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +19 -1
- package/dist/workspace/trust/run-commits.d.ts.map +1 -1
- package/dist/workspace/trust/run-commits.js +2 -1
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +34 -3
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +6 -1
- package/package.json +2 -1
- package/src/cli/handlers/approve-external-signature.test.ts +328 -0
- package/src/cli/handlers/approve.ts +206 -18
- package/src/cli/handlers/plan.ts +74 -0
- package/src/cli/handlers/pr.ts +2 -1
- package/src/cli/handlers/release.ts +84 -20
- package/src/cli/main.ts +48 -7
- package/src/cli/mcp/workspace-tools.ts +2 -1
- package/src/cli/parse-args.ts +33 -0
- package/src/cli/registry.ts +18 -2
- package/src/config.ts +8 -0
- package/src/gate-decision-bundle.test.ts +4 -2
- package/src/gate-decision.ts +11 -2
- package/src/gate-statement.schema.json +46 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
- package/src/lifecycle/gate-ledger.ts +34 -5
- package/src/lifecycle/gate-seal.ts +86 -15
- package/src/lifecycle/gate-statement.ts +144 -0
- package/src/lifecycle/gate-webauthn.test.ts +77 -0
- package/src/lifecycle/gate-webauthn.ts +133 -0
- package/src/lifecycle/git.ts +23 -19
- package/src/lifecycle/ledger-remote.test.ts +183 -0
- package/src/lifecycle/ledger-remote.ts +46 -0
- package/src/lifecycle/plan-stale.test.ts +149 -0
- package/src/lifecycle/plan-stale.ts +172 -0
- package/src/lifecycle/publish-credentials.ts +2 -0
- package/src/lifecycle/publish-declaration.ts +116 -1
- package/src/lifecycle/publish-forge.ts +14 -4
- package/src/lifecycle/publish-git-ssh.ts +202 -0
- package/src/lifecycle/publish-github.ts +174 -0
- package/src/lifecycle/publish-homebrew.test.ts +358 -0
- package/src/lifecycle/publish-homebrew.ts +283 -0
- package/src/lifecycle/publish-marketplace.test.ts +406 -0
- package/src/lifecycle/publish-marketplace.ts +421 -0
- package/src/lifecycle/publish-resume.test.ts +40 -0
- package/src/lifecycle/publish-target-context.test.ts +2 -2
- package/src/lifecycle/publish-targets.test.ts +23 -0
- package/src/lifecycle/publish-targets.ts +15 -0
- package/src/lifecycle/publish-tauri.test.ts +163 -0
- package/src/lifecycle/publish-tauri.ts +198 -0
- package/src/lifecycle/release-cut-lane.test.ts +177 -0
- package/src/lifecycle/release-cut-override.test.ts +213 -0
- package/src/lifecycle/release-cut.ts +198 -17
- package/src/lifecycle/release-publish.ts +23 -3
- package/src/lifecycle/release-revocation.ts +5 -4
- package/src/lifecycle/release-store.ts +44 -0
- package/src/lifecycle/snapshot-store.ts +16 -9
- package/src/lifecycle/test-passkey.ts +55 -0
- package/src/notify-bundle.test.ts +3 -1
- package/src/notify.schema.json +12 -3
- package/src/notify.ts +20 -3
- package/src/op/gate.ts +2 -1
- package/src/override-gate-bundle.test.ts +2 -0
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +38 -0
- package/src/pr-forge.ts +93 -11
- package/src/pr-requires.test.ts +9 -0
- package/src/release-floors.ts +1 -1
- package/src/stage-hooks-bundle.test.ts +2 -0
- package/src/wave-runtime-bundle.test.ts +3 -2
- package/src/workspace/ci-builds.ts +27 -0
- package/src/workspace/ci-green-stale.test.ts +193 -0
- package/src/workspace/ci-green.ts +137 -6
- package/src/workspace/ci-quarantine-report.test.ts +145 -0
- package/src/workspace/ci-quarantine-report.ts +234 -0
- package/src/workspace/ci-quarantine.test.ts +160 -0
- package/src/workspace/ci-quarantine.ts +188 -0
- package/src/workspace/ci-serve.ts +7 -4
- package/src/workspace/class-data.ts +5 -1
- package/src/workspace/declaration.schema.json +51 -3
- package/src/workspace/declaration.test.ts +1 -0
- package/src/workspace/declaration.ts +88 -5
- package/src/workspace/forge-work.test.ts +143 -0
- package/src/workspace/forge-work.ts +195 -0
- package/src/workspace/identity-gate-rule.ts +6 -8
- package/src/workspace/identity.ts +6 -3
- package/src/workspace/intent-cli.ts +24 -5
- package/src/workspace/intent-record.schema.json +32 -0
- package/src/workspace/intent-record.ts +3 -0
- package/src/workspace/intent.schema.json +32 -0
- package/src/workspace/intent.ts +9 -0
- package/src/workspace/kind-readers.ts +2 -1
- package/src/workspace/kinds.test.ts +13 -0
- package/src/workspace/kinds.ts +12 -3
- package/src/workspace/plan-stale.schema.json +286 -0
- package/src/workspace/release-candidates.schema.json +55 -2
- package/src/workspace/release-candidates.test.ts +77 -4
- package/src/workspace/release-candidates.ts +80 -23
- package/src/workspace/releases.schema.json +47 -0
- package/src/workspace/trust/gate-seal.test.ts +44 -0
- package/src/workspace/trust/policy.ts +24 -1
- package/src/workspace/trust/run-commits.ts +2 -1
- package/src/workspace/trust/seal.ts +35 -3
- package/src/workspace/trust/trust-files.test.ts +5 -0
- package/src/workspace/trust/trust-files.ts +15 -1
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* does not accept). An RSA signature over SHA-1 does not verify.
|
|
19
19
|
*/
|
|
20
20
|
import type { Signer } from "../workspace/trust/trust-files.js";
|
|
21
|
+
import { type PasskeySigner } from "./gate-webauthn.js";
|
|
22
|
+
export { isWebAuthnAssertion, passkeyPublicKey, verifyWebAuthnAssertion, webAuthnChallenge, type PasskeySigner, type WebAuthnAssertion, type WebAuthnCheck } from "./gate-webauthn.js";
|
|
21
23
|
/**
|
|
22
24
|
* The ssh signature namespace of a gate approval's seal (#3163, ws-080), so a
|
|
23
25
|
* verdict, record or commit signature can't stand in for one.
|
|
@@ -35,6 +37,12 @@ export interface SealedGateApproval {
|
|
|
35
37
|
timestamp: string;
|
|
36
38
|
/** The checkpoint the approval lets a run resume from (#3947), when it carries one. */
|
|
37
39
|
checkpointDigest?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A line the relay set for the signature to bind as well (#4697), such as
|
|
42
|
+
* a platform's deploy id and an expiry. chant doesn't read it; the seal
|
|
43
|
+
* signs it. A carried approval keeps the original's.
|
|
44
|
+
*/
|
|
45
|
+
binding?: string;
|
|
38
46
|
/** The line a carried approval came from (#3949): the names and time its seal was made under. */
|
|
39
47
|
carriedFrom?: {
|
|
40
48
|
op: string;
|
|
@@ -52,11 +60,13 @@ export interface SealedGateApproval {
|
|
|
52
60
|
*/
|
|
53
61
|
export declare function sealedFieldsOf(a: SealedGateApproval): SealedGateApproval;
|
|
54
62
|
/**
|
|
55
|
-
* The version of a seal over `a` (#3947):
|
|
56
|
-
*
|
|
57
|
-
*
|
|
63
|
+
* The version of a seal over `a` (#3947): 3 when the approval carries a
|
|
64
|
+
* relay's binding (#4697), 2 when it carries a checkpoint digest and no
|
|
65
|
+
* binding, and 1 otherwise. Each signs the lines of the one before plus its
|
|
66
|
+
* own. `chant approve --sign` and `--signature` record 2 and 3 on the seal; a
|
|
67
|
+
* seal records no version for 1.
|
|
58
68
|
*/
|
|
59
|
-
export declare function gateSealVersion(a: Pick<SealedGateApproval, "checkpointDigest" | "carriedFrom">): 1 | 2;
|
|
69
|
+
export declare function gateSealVersion(a: Pick<SealedGateApproval, "checkpointDigest" | "carriedFrom" | "binding">): 1 | 2 | 3;
|
|
60
70
|
/**
|
|
61
71
|
* The bytes a gate approval's seal signs (#3163): the op (or component), the
|
|
62
72
|
* gate, the environment, the plan digest, the approver and the time, joined
|
|
@@ -72,6 +82,14 @@ export declare function gateSealVersion(a: Pick<SealedGateApproval, "checkpointD
|
|
|
72
82
|
* then covered by the seal too, and removing or swapping the digest stops it
|
|
73
83
|
* verifying. An approval with none signs what a version 1 seal signed.
|
|
74
84
|
*
|
|
85
|
+
* Seal version 3 (#4697) adds a binding line the relay set, `binding
|
|
86
|
+
* <text>`, after everything else, checkpoint included. A platform puts what
|
|
87
|
+
* it needs the person's signature to cover there too (a deploy id and an
|
|
88
|
+
* expiry); chant records and checks it and reads nothing in it. An approval
|
|
89
|
+
* with no binding signs what a version 1 or 2 seal signed, so those still
|
|
90
|
+
* verify, and an older chant, which leaves the line out, finds a version 3
|
|
91
|
+
* seal doesn't verify and counts nothing for it.
|
|
92
|
+
*
|
|
75
93
|
* A carried approval (#3949) signs what the line it came from signed: see
|
|
76
94
|
* {@link sealedFieldsOf}.
|
|
77
95
|
*/
|
|
@@ -111,17 +129,51 @@ export interface GateSigners {
|
|
|
111
129
|
/** Whether a signers file exists at base. False: no seal verifies, so a sealed gate passes nothing. */
|
|
112
130
|
active: boolean;
|
|
113
131
|
signers: Signer[];
|
|
132
|
+
/** The passkeys `.chant/trust.json` lists at base (#4646). Absent: none. */
|
|
133
|
+
passkeys?: PasskeySigner[];
|
|
114
134
|
/** Why the trust config could not be read, when it could not. `active` is false then. */
|
|
115
135
|
problems: string[];
|
|
116
136
|
}
|
|
117
137
|
/** Whether ssh-keygen's `namespaces="..."` pattern list admits `namespace`: a `*`/`?` pattern matches, and a `!` pattern that matches refuses. */
|
|
118
138
|
export declare function namespaceAllowed(list: string | undefined, namespace: string): boolean;
|
|
139
|
+
/** The seal kind of an approval signed with a passkey (#4646). A seal with no `kind` is an ssh signature. */
|
|
140
|
+
export declare const WEBAUTHN_SEAL_KIND = "webauthn";
|
|
141
|
+
/** What {@link checkGateSignature} reads: the ssh signers and the passkeys at base. */
|
|
142
|
+
export interface GateSignerKeys {
|
|
143
|
+
signers: readonly Signer[];
|
|
144
|
+
passkeys?: readonly PasskeySigner[];
|
|
145
|
+
}
|
|
146
|
+
/** What {@link checkGateSignature} found. `unlisted`: nothing at base is listed for the principal. */
|
|
147
|
+
export type GateSignatureCheck = {
|
|
148
|
+
ok: true;
|
|
149
|
+
key: string;
|
|
150
|
+
} | {
|
|
151
|
+
ok: false;
|
|
152
|
+
unlisted: boolean;
|
|
153
|
+
reason: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Whether `seal`'s signature over `payload` verifies for `principal` with a
|
|
157
|
+
* key listed for them at base (#4646): an ssh signature in the `chant-gate`
|
|
158
|
+
* namespace against the signers file's keys, or, for a seal of kind
|
|
159
|
+
* `webauthn`, an assertion against the passkeys `.chant/trust.json` lists.
|
|
160
|
+
* The one check `chant approve`, the `identity.gates` rule, a sealed gate and
|
|
161
|
+
* `checkGateSeal` all make. Never throws.
|
|
162
|
+
*/
|
|
163
|
+
export declare function checkGateSignature(keys: GateSignerKeys, principal: string, seal: {
|
|
164
|
+
signature: string;
|
|
165
|
+
} & Record<string, unknown>, payload: Buffer): GateSignatureCheck;
|
|
119
166
|
/**
|
|
120
167
|
* Why this approval does not count toward a sealed gate, or null when it
|
|
121
168
|
* does: its seal verifies, for the approver it names, against a key `signers`
|
|
122
|
-
* lists for that approver in the `chant-gate` namespace
|
|
123
|
-
*
|
|
124
|
-
*
|
|
169
|
+
* lists for that approver in the `chant-gate` namespace, or a passkey
|
|
170
|
+
* `.chant/trust.json` lists for them (#4646). With no signers file at base,
|
|
171
|
+
* nothing counts. The same rule as `sealedApprovalRule` in
|
|
172
|
+
* `../../op/gate-review.ts`.
|
|
125
173
|
*/
|
|
126
174
|
export declare function gateSealRefusal(signers: GateSigners, a: SealedGateApproval): string | null;
|
|
175
|
+
/** "key" or "passkey", for a refusal that names what is missing for a seal's kind. */
|
|
176
|
+
export declare function unlistedWhat(seal: object): string;
|
|
177
|
+
/** Where the missing key would be listed: the signers file, or `.chant/trust.json` for a passkey. */
|
|
178
|
+
export declare function unlistedWhere(seal: object, signersWhere: string): string;
|
|
127
179
|
//# sourceMappingURL=gate-seal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-seal.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-seal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"gate-seal.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-seal.ts"],"names":[],"mappings":"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"}
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* does not accept). An RSA signature over SHA-1 does not verify.
|
|
19
19
|
*/
|
|
20
20
|
import { createHash, createPublicKey, verify } from "node:crypto";
|
|
21
|
+
import { verifyWebAuthnAssertion } from "./gate-webauthn.js";
|
|
22
|
+
export { isWebAuthnAssertion, passkeyPublicKey, verifyWebAuthnAssertion, webAuthnChallenge } from "./gate-webauthn.js";
|
|
21
23
|
/**
|
|
22
24
|
* The ssh signature namespace of a gate approval's seal (#3163, ws-080), so a
|
|
23
25
|
* verdict, record or commit signature can't stand in for one.
|
|
@@ -43,11 +45,15 @@ export function sealedFieldsOf(a) {
|
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
|
-
* The version of a seal over `a` (#3947):
|
|
47
|
-
*
|
|
48
|
-
*
|
|
48
|
+
* The version of a seal over `a` (#3947): 3 when the approval carries a
|
|
49
|
+
* relay's binding (#4697), 2 when it carries a checkpoint digest and no
|
|
50
|
+
* binding, and 1 otherwise. Each signs the lines of the one before plus its
|
|
51
|
+
* own. `chant approve --sign` and `--signature` record 2 and 3 on the seal; a
|
|
52
|
+
* seal records no version for 1.
|
|
49
53
|
*/
|
|
50
54
|
export function gateSealVersion(a) {
|
|
55
|
+
if (a.binding !== undefined)
|
|
56
|
+
return 3;
|
|
51
57
|
const checkpoint = a.carriedFrom !== undefined ? a.carriedFrom.checkpointDigest : a.checkpointDigest;
|
|
52
58
|
return checkpoint !== undefined ? 2 : 1;
|
|
53
59
|
}
|
|
@@ -66,14 +72,23 @@ export function gateSealVersion(a) {
|
|
|
66
72
|
* then covered by the seal too, and removing or swapping the digest stops it
|
|
67
73
|
* verifying. An approval with none signs what a version 1 seal signed.
|
|
68
74
|
*
|
|
75
|
+
* Seal version 3 (#4697) adds a binding line the relay set, `binding
|
|
76
|
+
* <text>`, after everything else, checkpoint included. A platform puts what
|
|
77
|
+
* it needs the person's signature to cover there too (a deploy id and an
|
|
78
|
+
* expiry); chant records and checks it and reads nothing in it. An approval
|
|
79
|
+
* with no binding signs what a version 1 or 2 seal signed, so those still
|
|
80
|
+
* verify, and an older chant, which leaves the line out, finds a version 3
|
|
81
|
+
* seal doesn't verify and counts nothing for it.
|
|
82
|
+
*
|
|
69
83
|
* A carried approval (#3949) signs what the line it came from signed: see
|
|
70
84
|
* {@link sealedFieldsOf}.
|
|
71
85
|
*/
|
|
72
86
|
export function gateSealPayload(approval) {
|
|
73
87
|
const a = sealedFieldsOf(approval);
|
|
74
88
|
const relay = a.relayedBy !== undefined ? `\nrelayed-by ${a.relayedBy}` : "";
|
|
75
|
-
const checkpoint =
|
|
76
|
-
|
|
89
|
+
const checkpoint = a.checkpointDigest !== undefined ? `\ncheckpoint ${a.checkpointDigest}` : "";
|
|
90
|
+
const binding = a.binding !== undefined ? `\nbinding ${a.binding}` : "";
|
|
91
|
+
return Buffer.from(`${a.op}\n${a.gate}\n${a.environment ?? ""}\n${a.planDigest ?? ""}\n${a.resolvedBy}\n${a.timestamp}${relay}${checkpoint}${binding}`, "utf-8");
|
|
77
92
|
}
|
|
78
93
|
// ── SSHSIG ───────────────────────────────────────────────────────────────
|
|
79
94
|
/** A reader over ssh wire format: `take(n)` bytes, or `take()` one length-prefixed string. */
|
|
@@ -233,12 +248,45 @@ export function namespaceAllowed(list, namespace) {
|
|
|
233
248
|
}
|
|
234
249
|
return allowed;
|
|
235
250
|
}
|
|
251
|
+
/** The seal kind of an approval signed with a passkey (#4646). A seal with no `kind` is an ssh signature. */
|
|
252
|
+
export const WEBAUTHN_SEAL_KIND = "webauthn";
|
|
253
|
+
/**
|
|
254
|
+
* Whether `seal`'s signature over `payload` verifies for `principal` with a
|
|
255
|
+
* key listed for them at base (#4646): an ssh signature in the `chant-gate`
|
|
256
|
+
* namespace against the signers file's keys, or, for a seal of kind
|
|
257
|
+
* `webauthn`, an assertion against the passkeys `.chant/trust.json` lists.
|
|
258
|
+
* The one check `chant approve`, the `identity.gates` rule, a sealed gate and
|
|
259
|
+
* `checkGateSeal` all make. Never throws.
|
|
260
|
+
*/
|
|
261
|
+
export function checkGateSignature(keys, principal, seal, payload) {
|
|
262
|
+
const name = normalise(principal);
|
|
263
|
+
if (seal.kind === WEBAUTHN_SEAL_KIND) {
|
|
264
|
+
const passkeys = (keys.passkeys ?? []).filter((p) => normalise(p.principal) === name);
|
|
265
|
+
if (passkeys.length === 0)
|
|
266
|
+
return { ok: false, unlisted: true, reason: `${principal} has no passkey in .chant/trust.json at base` };
|
|
267
|
+
const assertion = { id: seal.key, clientDataJSON: seal.clientDataJSON, authenticatorData: seal.authenticatorData, signature: seal.signature };
|
|
268
|
+
if (typeof assertion.id !== "string" || typeof assertion.clientDataJSON !== "string" || typeof assertion.authenticatorData !== "string") {
|
|
269
|
+
return { ok: false, unlisted: false, reason: "a webauthn seal needs key (the credential id), clientDataJSON and authenticatorData" };
|
|
270
|
+
}
|
|
271
|
+
const r = verifyWebAuthnAssertion(assertion, payload, passkeys);
|
|
272
|
+
return r.ok ? r : { ok: false, unlisted: false, reason: r.reason };
|
|
273
|
+
}
|
|
274
|
+
if (seal.kind !== undefined)
|
|
275
|
+
return { ok: false, unlisted: false, reason: `a seal of kind ${JSON.stringify(seal.kind)} is not one this chant reads` };
|
|
276
|
+
const listed = keys.signers.filter((s) => normalise(s.principal) === name);
|
|
277
|
+
if (listed.length === 0)
|
|
278
|
+
return { ok: false, unlisted: true, reason: `${principal} has no key in the signers file at base` };
|
|
279
|
+
const blobs = listed.filter((s) => namespaceAllowed(s.namespaces, GATE_SEAL_NAMESPACE)).map((s) => Buffer.from(s.key.split(" ")[1] ?? "", "base64"));
|
|
280
|
+
const r = verifySshSignatureWith(seal.signature, payload, GATE_SEAL_NAMESPACE, blobs);
|
|
281
|
+
return r.ok ? r : { ok: false, unlisted: false, reason: r.reason };
|
|
282
|
+
}
|
|
236
283
|
/**
|
|
237
284
|
* Why this approval does not count toward a sealed gate, or null when it
|
|
238
285
|
* does: its seal verifies, for the approver it names, against a key `signers`
|
|
239
|
-
* lists for that approver in the `chant-gate` namespace
|
|
240
|
-
*
|
|
241
|
-
*
|
|
286
|
+
* lists for that approver in the `chant-gate` namespace, or a passkey
|
|
287
|
+
* `.chant/trust.json` lists for them (#4646). With no signers file at base,
|
|
288
|
+
* nothing counts. The same rule as `sealedApprovalRule` in
|
|
289
|
+
* `../../op/gate-review.ts`.
|
|
242
290
|
*/
|
|
243
291
|
export function gateSealRefusal(signers, a) {
|
|
244
292
|
const where = `${signers.signersPath} at base`;
|
|
@@ -255,11 +303,16 @@ export function gateSealRefusal(signers, a) {
|
|
|
255
303
|
}
|
|
256
304
|
if (normalise(seal.signer) !== normalise(a.resolvedBy))
|
|
257
305
|
return `the seal on ${what} is by ${seal.signer}, and its approver is ${a.resolvedBy || "empty"}`;
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
306
|
+
const r = checkGateSignature(signers, a.resolvedBy, seal, gateSealPayload(a));
|
|
307
|
+
if (r.ok)
|
|
308
|
+
return null;
|
|
309
|
+
return r.unlisted ? `${a.resolvedBy} has no ${unlistedWhat(seal)} in ${unlistedWhere(seal, where)}, so the seal can't count` : `the seal does not verify for ${a.resolvedBy} against ${where}: ${r.reason}`;
|
|
310
|
+
}
|
|
311
|
+
/** "key" or "passkey", for a refusal that names what is missing for a seal's kind. */
|
|
312
|
+
export function unlistedWhat(seal) {
|
|
313
|
+
return seal.kind === WEBAUTHN_SEAL_KIND ? "passkey" : "key";
|
|
314
|
+
}
|
|
315
|
+
/** Where the missing key would be listed: the signers file, or `.chant/trust.json` for a passkey. */
|
|
316
|
+
export function unlistedWhere(seal, signersWhere) {
|
|
317
|
+
return seal.kind === WEBAUTHN_SEAL_KIND ? ".chant/trust.json at base" : signersWhere;
|
|
265
318
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A gate approval's statement, for a signature made outside chant (#4646).
|
|
3
|
+
*
|
|
4
|
+
* `chant approve --sign` signs `gateSealPayload`'s bytes with an ssh key on
|
|
5
|
+
* the machine running chant. A platform that collects the approval somewhere
|
|
6
|
+
* else (a phone with a passkey, a device key on another machine) needs the
|
|
7
|
+
* same bytes before anything is recorded: `chant approve <op> <gate>
|
|
8
|
+
* --statement` prints them as a `chant-gate-statement/v1` document
|
|
9
|
+
* (`../gate-statement.schema.json`), with the time fixed so the signature and
|
|
10
|
+
* the approval that records it cover the same line. The platform has the
|
|
11
|
+
* person sign them and hands the signature to `chant approve --signature`,
|
|
12
|
+
* with the same `--actor`, `--relayed-by` and `--at`.
|
|
13
|
+
*
|
|
14
|
+
* The relay can add a line of its own for the signature to bind, `--binding
|
|
15
|
+
* <text>` on both calls (#4697): a platform's deploy id and an expiry, say.
|
|
16
|
+
* It is signed last as `binding <text>` (seal version 3) and kept on the
|
|
17
|
+
* approval, and chant checks only that it is one line of printable text no
|
|
18
|
+
* longer than {@link GATE_BINDING_MAX_BYTES}.
|
|
19
|
+
*/
|
|
20
|
+
import { GATE_SEAL_NAMESPACE, type SealedGateApproval, type WebAuthnAssertion } from "./gate-seal.js";
|
|
21
|
+
/**
|
|
22
|
+
* The first chant that prints a gate's statement, records an approval
|
|
23
|
+
* signed elsewhere (`chant approve --signature`), reads `passkeys` in
|
|
24
|
+
* `.chant/trust.json` and verifies a seal of kind `webauthn` (#4646). An
|
|
25
|
+
* older chant reads a trust.json with `passkeys` as invalid, which turns
|
|
26
|
+
* attestation off, and counts no passkey seal toward a gate.
|
|
27
|
+
*/
|
|
28
|
+
export declare const GATE_EXTERNAL_SIGNATURE_FLOOR = "0.124.63";
|
|
29
|
+
/**
|
|
30
|
+
* The first chant that takes `--binding` and signs and checks a binding line
|
|
31
|
+
* (seal version 3, #4697). An older chant leaves the line out of what it
|
|
32
|
+
* checks, so it finds a version 3 seal doesn't verify and counts nothing for
|
|
33
|
+
* it, whatever the gate.
|
|
34
|
+
*/
|
|
35
|
+
export declare const GATE_BINDING_FLOOR = "0.124.64";
|
|
36
|
+
/** The longest binding `--binding` takes, in UTF-8 bytes (#4697). */
|
|
37
|
+
export declare const GATE_BINDING_MAX_BYTES = 512;
|
|
38
|
+
/**
|
|
39
|
+
* Why `text` can't be a gate statement's binding line (#4697), or null when
|
|
40
|
+
* it can: it must be non-empty, at most {@link GATE_BINDING_MAX_BYTES} UTF-8
|
|
41
|
+
* bytes, with no leading or trailing space, and printable on one line, so no
|
|
42
|
+
* control or format character (bidi overrides among them), line or paragraph
|
|
43
|
+
* separator, unassigned code point or lone surrogate.
|
|
44
|
+
*/
|
|
45
|
+
export declare function gateBindingProblem(text: string): string | null;
|
|
46
|
+
export declare const GATE_STATEMENT_SCHEMA = "chant-gate-statement/v1";
|
|
47
|
+
/** The `$id` of `../gate-statement.schema.json`, which the package exports as `@intentius/chant/gate-statement.schema.json`. */
|
|
48
|
+
export declare const GATE_STATEMENT_SCHEMA_ID = "https://intentius.io/chant/schemas/gate-statement/v1/gate-statement.schema.json";
|
|
49
|
+
/** What `chant approve <op> <gate> --statement` prints. */
|
|
50
|
+
export interface GateStatement {
|
|
51
|
+
schema: typeof GATE_STATEMENT_SCHEMA;
|
|
52
|
+
chantVersion: string;
|
|
53
|
+
op: string;
|
|
54
|
+
gate: string;
|
|
55
|
+
environment: string | null;
|
|
56
|
+
planDigest: string | null;
|
|
57
|
+
resolvedBy: string;
|
|
58
|
+
relayedBy: string | null;
|
|
59
|
+
timestamp: string;
|
|
60
|
+
checkpointDigest: string | null;
|
|
61
|
+
/** The relay's binding line (#4697, `--binding`), or null. When set the statement ends with `binding <text>`. */
|
|
62
|
+
binding: string | null;
|
|
63
|
+
/** 3 when the statement signs a binding, else 2 when it signs a checkpoint digest, else 1. */
|
|
64
|
+
sealVersion: 1 | 2 | 3;
|
|
65
|
+
/** The ssh signature namespace an ssh key signs the statement in. */
|
|
66
|
+
namespace: typeof GATE_SEAL_NAMESPACE;
|
|
67
|
+
/** The statement's UTF-8 text, LF-joined with no final newline. */
|
|
68
|
+
text: string;
|
|
69
|
+
/** The same bytes, base64. */
|
|
70
|
+
statement: string;
|
|
71
|
+
/** `sha256:` and the bytes' SHA-256 in hex. */
|
|
72
|
+
digest: string;
|
|
73
|
+
/** The WebAuthn challenge: base64url of the bytes' SHA-256, no padding. */
|
|
74
|
+
challenge: string;
|
|
75
|
+
}
|
|
76
|
+
/** The statement of approval `a`, as `chant approve --statement` prints it. */
|
|
77
|
+
export declare function gateStatement(a: SealedGateApproval, chantVersion: string): GateStatement;
|
|
78
|
+
/** A signature `chant approve --signature` was handed. */
|
|
79
|
+
export type ExternalSignature = {
|
|
80
|
+
kind: "ssh";
|
|
81
|
+
signature: string;
|
|
82
|
+
} | {
|
|
83
|
+
kind: "webauthn";
|
|
84
|
+
assertion: WebAuthnAssertion;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Read what `--signature` names: an armored ssh signature, or a WebAuthn
|
|
88
|
+
* assertion as JSON, either `{ id, clientDataJSON, authenticatorData,
|
|
89
|
+
* signature }` or a `PublicKeyCredential`'s `toJSON()` with those three
|
|
90
|
+
* under `response`. Returns a problem when it is neither.
|
|
91
|
+
*/
|
|
92
|
+
export declare function readExternalSignature(text: string): ExternalSignature | {
|
|
93
|
+
problem: string;
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=gate-statement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-statement.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-statement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,mBAAmB,EAA4E,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE7K;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,aAAa,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,aAAe,CAAC;AAE/C,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ9D;AAED,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAE/D,gIAAgI;AAChI,eAAO,MAAM,wBAAwB,oFAAoF,CAAC;AAE1H,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,OAAO,qBAAqB,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iHAAiH;IACjH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,8FAA8F;IAC9F,WAAW,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,qEAAqE;IACrE,SAAS,EAAE,OAAO,mBAAmB,CAAC;IACtC,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,CAAC,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAqBxF;AAED,0DAA0D;AAC1D,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAExH;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAgB3F"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A gate approval's statement, for a signature made outside chant (#4646).
|
|
3
|
+
*
|
|
4
|
+
* `chant approve --sign` signs `gateSealPayload`'s bytes with an ssh key on
|
|
5
|
+
* the machine running chant. A platform that collects the approval somewhere
|
|
6
|
+
* else (a phone with a passkey, a device key on another machine) needs the
|
|
7
|
+
* same bytes before anything is recorded: `chant approve <op> <gate>
|
|
8
|
+
* --statement` prints them as a `chant-gate-statement/v1` document
|
|
9
|
+
* (`../gate-statement.schema.json`), with the time fixed so the signature and
|
|
10
|
+
* the approval that records it cover the same line. The platform has the
|
|
11
|
+
* person sign them and hands the signature to `chant approve --signature`,
|
|
12
|
+
* with the same `--actor`, `--relayed-by` and `--at`.
|
|
13
|
+
*
|
|
14
|
+
* The relay can add a line of its own for the signature to bind, `--binding
|
|
15
|
+
* <text>` on both calls (#4697): a platform's deploy id and an expiry, say.
|
|
16
|
+
* It is signed last as `binding <text>` (seal version 3) and kept on the
|
|
17
|
+
* approval, and chant checks only that it is one line of printable text no
|
|
18
|
+
* longer than {@link GATE_BINDING_MAX_BYTES}.
|
|
19
|
+
*/
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
import { NEXT_RELEASE } from "../release-floors.js";
|
|
22
|
+
import { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, isWebAuthnAssertion, webAuthnChallenge } from "./gate-seal.js";
|
|
23
|
+
/**
|
|
24
|
+
* The first chant that prints a gate's statement, records an approval
|
|
25
|
+
* signed elsewhere (`chant approve --signature`), reads `passkeys` in
|
|
26
|
+
* `.chant/trust.json` and verifies a seal of kind `webauthn` (#4646). An
|
|
27
|
+
* older chant reads a trust.json with `passkeys` as invalid, which turns
|
|
28
|
+
* attestation off, and counts no passkey seal toward a gate.
|
|
29
|
+
*/
|
|
30
|
+
export const GATE_EXTERNAL_SIGNATURE_FLOOR = "0.124.63";
|
|
31
|
+
/**
|
|
32
|
+
* The first chant that takes `--binding` and signs and checks a binding line
|
|
33
|
+
* (seal version 3, #4697). An older chant leaves the line out of what it
|
|
34
|
+
* checks, so it finds a version 3 seal doesn't verify and counts nothing for
|
|
35
|
+
* it, whatever the gate.
|
|
36
|
+
*/
|
|
37
|
+
export const GATE_BINDING_FLOOR = NEXT_RELEASE;
|
|
38
|
+
/** The longest binding `--binding` takes, in UTF-8 bytes (#4697). */
|
|
39
|
+
export const GATE_BINDING_MAX_BYTES = 512;
|
|
40
|
+
/**
|
|
41
|
+
* Why `text` can't be a gate statement's binding line (#4697), or null when
|
|
42
|
+
* it can: it must be non-empty, at most {@link GATE_BINDING_MAX_BYTES} UTF-8
|
|
43
|
+
* bytes, with no leading or trailing space, and printable on one line, so no
|
|
44
|
+
* control or format character (bidi overrides among them), line or paragraph
|
|
45
|
+
* separator, unassigned code point or lone surrogate.
|
|
46
|
+
*/
|
|
47
|
+
export function gateBindingProblem(text) {
|
|
48
|
+
if (text === "")
|
|
49
|
+
return "it is empty";
|
|
50
|
+
const bytes = Buffer.byteLength(text, "utf-8");
|
|
51
|
+
if (bytes > GATE_BINDING_MAX_BYTES)
|
|
52
|
+
return `it is ${bytes} bytes, and the most is ${GATE_BINDING_MAX_BYTES}`;
|
|
53
|
+
if (text.trim() !== text)
|
|
54
|
+
return "it starts or ends with white space";
|
|
55
|
+
const bad = /[\p{C}\p{Zl}\p{Zp}]/u.exec(text);
|
|
56
|
+
if (bad)
|
|
57
|
+
return `it holds U+${bad[0].codePointAt(0).toString(16).toUpperCase().padStart(4, "0")}, and it must be printable text on one line`;
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
export const GATE_STATEMENT_SCHEMA = "chant-gate-statement/v1";
|
|
61
|
+
/** The `$id` of `../gate-statement.schema.json`, which the package exports as `@intentius/chant/gate-statement.schema.json`. */
|
|
62
|
+
export const GATE_STATEMENT_SCHEMA_ID = "https://intentius.io/chant/schemas/gate-statement/v1/gate-statement.schema.json";
|
|
63
|
+
/** The statement of approval `a`, as `chant approve --statement` prints it. */
|
|
64
|
+
export function gateStatement(a, chantVersion) {
|
|
65
|
+
const bytes = gateSealPayload(a);
|
|
66
|
+
return {
|
|
67
|
+
schema: GATE_STATEMENT_SCHEMA,
|
|
68
|
+
chantVersion,
|
|
69
|
+
op: a.op,
|
|
70
|
+
gate: a.gate,
|
|
71
|
+
environment: a.environment ?? null,
|
|
72
|
+
planDigest: a.planDigest ?? null,
|
|
73
|
+
resolvedBy: a.resolvedBy,
|
|
74
|
+
relayedBy: a.relayedBy ?? null,
|
|
75
|
+
timestamp: a.timestamp,
|
|
76
|
+
checkpointDigest: a.checkpointDigest ?? null,
|
|
77
|
+
binding: a.binding ?? null,
|
|
78
|
+
sealVersion: gateSealVersion(a),
|
|
79
|
+
namespace: GATE_SEAL_NAMESPACE,
|
|
80
|
+
text: bytes.toString("utf-8"),
|
|
81
|
+
statement: bytes.toString("base64"),
|
|
82
|
+
digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}`,
|
|
83
|
+
challenge: webAuthnChallenge(bytes),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Read what `--signature` names: an armored ssh signature, or a WebAuthn
|
|
88
|
+
* assertion as JSON, either `{ id, clientDataJSON, authenticatorData,
|
|
89
|
+
* signature }` or a `PublicKeyCredential`'s `toJSON()` with those three
|
|
90
|
+
* under `response`. Returns a problem when it is neither.
|
|
91
|
+
*/
|
|
92
|
+
export function readExternalSignature(text) {
|
|
93
|
+
const armored = /-----BEGIN SSH SIGNATURE-----[^-]*-----END SSH SIGNATURE-----/.exec(text);
|
|
94
|
+
if (armored)
|
|
95
|
+
return { kind: "ssh", signature: `${armored[0]}\n` };
|
|
96
|
+
let raw;
|
|
97
|
+
try {
|
|
98
|
+
raw = JSON.parse(text);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return { problem: "it is neither an armored ssh signature (-----BEGIN SSH SIGNATURE-----) nor a WebAuthn assertion in JSON" };
|
|
102
|
+
}
|
|
103
|
+
const o = raw;
|
|
104
|
+
const flat = o && typeof o === "object" && o.response && typeof o.response === "object" ? { id: o.id, ...o.response } : raw;
|
|
105
|
+
if (!isWebAuthnAssertion(flat)) {
|
|
106
|
+
return { problem: "a WebAuthn assertion needs id, clientDataJSON, authenticatorData and signature, each base64url" };
|
|
107
|
+
}
|
|
108
|
+
const { id, clientDataJSON, authenticatorData, signature } = flat;
|
|
109
|
+
return { kind: "webauthn", assertion: { id, clientDataJSON, authenticatorData, signature } };
|
|
110
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A gate approval signed with a passkey (#4646): a WebAuthn assertion over
|
|
3
|
+
* the gate's statement, checked with node:crypto.
|
|
4
|
+
*
|
|
5
|
+
* A platform that collects an approval on a phone asks the browser for an
|
|
6
|
+
* assertion (`navigator.credentials.get`) whose challenge is the statement's
|
|
7
|
+
* digest, `base64url(SHA-256(statement))` with no padding, where the
|
|
8
|
+
* statement is `gateSealPayload`'s bytes (`chant approve --statement` prints
|
|
9
|
+
* them). The assertion is relayed to `chant approve --signature`, checked
|
|
10
|
+
* against a passkey `.chant/trust.json` lists at base for the approver, and
|
|
11
|
+
* kept on the approval's seal, so anyone can check it again offline.
|
|
12
|
+
*
|
|
13
|
+
* The check follows WebAuthn level 2, section 7.2, for what can be checked
|
|
14
|
+
* without the relying party's state: the client data's type is
|
|
15
|
+
* `webauthn.get`, its challenge is the statement's, its origin is one the
|
|
16
|
+
* passkey lists and it is not cross-origin; the authenticator data's rpIdHash
|
|
17
|
+
* is SHA-256 of the passkey's rpId and both the user-present and
|
|
18
|
+
* user-verified flags are set; and the signature over authenticatorData ||
|
|
19
|
+
* SHA-256(clientDataJSON) verifies with the passkey's public key. The
|
|
20
|
+
* signature counter is not checked: a ledger line can't know the
|
|
21
|
+
* authenticator's last count.
|
|
22
|
+
*
|
|
23
|
+
* Like `./gate-seal.ts`, this imports node:crypto and nothing else, so a
|
|
24
|
+
* bundled gate decision carries it.
|
|
25
|
+
*/
|
|
26
|
+
import { type KeyObject } from "node:crypto";
|
|
27
|
+
/**
|
|
28
|
+
* A passkey `.chant/trust.json` lists for a person (#4646): the credential
|
|
29
|
+
* id, its public key, the relying party it was made for, and the origins an
|
|
30
|
+
* assertion may come from.
|
|
31
|
+
*/
|
|
32
|
+
export interface PasskeySigner {
|
|
33
|
+
principal: string;
|
|
34
|
+
/** The credential id (`rawId`), base64url with no padding. */
|
|
35
|
+
id: string;
|
|
36
|
+
/**
|
|
37
|
+
* The credential's public key as DER SubjectPublicKeyInfo, base64url: what
|
|
38
|
+
* `AuthenticatorAttestationResponse.getPublicKey()` gives. Ed25519 (EdDSA),
|
|
39
|
+
* P-256 (ES256) and RSA (RS256) keys verify.
|
|
40
|
+
*/
|
|
41
|
+
publicKey: string;
|
|
42
|
+
/** The relying party id the credential is scoped to, such as `example.com`. */
|
|
43
|
+
rpId: string;
|
|
44
|
+
/** Origins an assertion may come from, such as `https://control.example.com`. */
|
|
45
|
+
origins: string[];
|
|
46
|
+
}
|
|
47
|
+
/** A WebAuthn assertion as a browser returns it, each field base64url. */
|
|
48
|
+
export interface WebAuthnAssertion {
|
|
49
|
+
/** The credential id. */
|
|
50
|
+
id: string;
|
|
51
|
+
clientDataJSON: string;
|
|
52
|
+
authenticatorData: string;
|
|
53
|
+
signature: string;
|
|
54
|
+
}
|
|
55
|
+
/** What {@link verifyWebAuthnAssertion} found. On success, `key` is the credential id. */
|
|
56
|
+
export type WebAuthnCheck = {
|
|
57
|
+
ok: true;
|
|
58
|
+
key: string;
|
|
59
|
+
} | {
|
|
60
|
+
ok: false;
|
|
61
|
+
reason: string;
|
|
62
|
+
};
|
|
63
|
+
/** Whether `raw` has the shape of a {@link WebAuthnAssertion}. */
|
|
64
|
+
export declare function isWebAuthnAssertion(raw: unknown): raw is WebAuthnAssertion;
|
|
65
|
+
/** The challenge a passkey signs for `statement`: base64url of its SHA-256, no padding. */
|
|
66
|
+
export declare function webAuthnChallenge(statement: Buffer): string;
|
|
67
|
+
/** The passkey's key and the algorithm its signature is checked with, or why it can't be read. */
|
|
68
|
+
export declare function passkeyPublicKey(publicKey: string): {
|
|
69
|
+
key: KeyObject;
|
|
70
|
+
alg: "EdDSA" | "ES256" | "RS256";
|
|
71
|
+
} | {
|
|
72
|
+
problem: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Whether `assertion` signs `statement` with one of `passkeys`, chosen by
|
|
76
|
+
* credential id. Never throws.
|
|
77
|
+
*/
|
|
78
|
+
export declare function verifyWebAuthnAssertion(assertion: WebAuthnAssertion, statement: Buffer, passkeys: readonly PasskeySigner[]): WebAuthnCheck;
|
|
79
|
+
//# sourceMappingURL=gate-webauthn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-webauthn.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-webauthn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAElF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,0FAA0F;AAC1F,MAAM,MAAM,aAAa,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAItF,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,iBAAiB,CAM1E;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,kGAAkG;AAClG,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAW9H;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,CAmC1I"}
|