@freedomofpress/sigstore-browser 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/bundle.d.ts +2 -3
  2. package/dist/bundle.js.map +1 -1
  3. package/dist/cli.d.ts +0 -1
  4. package/dist/cli.js.map +1 -1
  5. package/dist/dsse.d.ts +0 -1
  6. package/dist/dsse.js +4 -9
  7. package/dist/dsse.js.map +1 -1
  8. package/dist/errors.d.ts +0 -1
  9. package/dist/errors.js.map +1 -1
  10. package/dist/index.d.ts +9 -10
  11. package/dist/index.js +5 -5
  12. package/dist/index.js.map +1 -1
  13. package/dist/interfaces.d.ts +1 -2
  14. package/dist/interfaces.js +1 -1
  15. package/dist/interfaces.js.map +1 -1
  16. package/dist/oid.d.ts +0 -1
  17. package/dist/oid.js.map +1 -1
  18. package/dist/policy.d.ts +0 -1
  19. package/dist/policy.js +1 -1
  20. package/dist/policy.js.map +1 -1
  21. package/dist/rfc3161/error.d.ts +0 -1
  22. package/dist/rfc3161/error.js.map +1 -1
  23. package/dist/rfc3161/index.d.ts +0 -1
  24. package/dist/rfc3161/index.js.map +1 -1
  25. package/dist/rfc3161/timestamp.d.ts +0 -1
  26. package/dist/rfc3161/timestamp.js +3 -3
  27. package/dist/rfc3161/timestamp.js.map +1 -1
  28. package/dist/rfc3161/tstinfo.d.ts +0 -1
  29. package/dist/rfc3161/tstinfo.js +2 -3
  30. package/dist/rfc3161/tstinfo.js.map +1 -1
  31. package/dist/sigstore.d.ts +2 -3
  32. package/dist/sigstore.js +11 -14
  33. package/dist/sigstore.js.map +1 -1
  34. package/dist/timestamp/tsa.d.ts +1 -2
  35. package/dist/timestamp/tsa.js +1 -1
  36. package/dist/timestamp/tsa.js.map +1 -1
  37. package/dist/tlog/body.d.ts +0 -1
  38. package/dist/tlog/body.js +1 -1
  39. package/dist/tlog/body.js.map +1 -1
  40. package/dist/tlog/checkpoint.d.ts +0 -1
  41. package/dist/tlog/checkpoint.js.map +1 -1
  42. package/dist/tlog/dsse.d.ts +0 -1
  43. package/dist/tlog/dsse.js +6 -4
  44. package/dist/tlog/dsse.js.map +1 -1
  45. package/dist/tlog/hashedrekord.d.ts +0 -1
  46. package/dist/tlog/hashedrekord.js.map +1 -1
  47. package/dist/tlog/intoto.d.ts +0 -1
  48. package/dist/tlog/intoto.js +2 -3
  49. package/dist/tlog/intoto.js.map +1 -1
  50. package/dist/tlog/merkle.d.ts +0 -1
  51. package/dist/tlog/merkle.js +8 -102
  52. package/dist/tlog/merkle.js.map +1 -1
  53. package/dist/trust/tuf-root.d.ts +0 -1
  54. package/dist/trust/tuf-root.js.map +1 -1
  55. package/dist/trust/tuf.d.ts +0 -1
  56. package/dist/trust/tuf.js +2 -5
  57. package/dist/trust/tuf.js.map +1 -1
  58. package/dist/x509/cert.d.ts +0 -1
  59. package/dist/x509/cert.js +2 -2
  60. package/dist/x509/cert.js.map +1 -1
  61. package/dist/x509/chain.d.ts +0 -1
  62. package/dist/x509/chain.js +2 -2
  63. package/dist/x509/chain.js.map +1 -1
  64. package/dist/x509/ext.d.ts +0 -1
  65. package/dist/x509/ext.js.map +1 -1
  66. package/dist/x509/index.d.ts +1 -2
  67. package/dist/x509/index.js +1 -1
  68. package/dist/x509/index.js.map +1 -1
  69. package/dist/x509/sct.d.ts +0 -1
  70. package/dist/x509/sct.js.map +1 -1
  71. package/package.json +16 -9
  72. package/.github/workflows/conformance.yml +0 -29
  73. package/.github/workflows/publish.yml +0 -47
  74. package/dist/bundle.d.ts.map +0 -1
  75. package/dist/cli.d.ts.map +0 -1
  76. package/dist/dsse.d.ts.map +0 -1
  77. package/dist/errors.d.ts.map +0 -1
  78. package/dist/index.d.ts.map +0 -1
  79. package/dist/interfaces.d.ts.map +0 -1
  80. package/dist/oid.d.ts.map +0 -1
  81. package/dist/policy.d.ts.map +0 -1
  82. package/dist/rfc3161/error.d.ts.map +0 -1
  83. package/dist/rfc3161/index.d.ts.map +0 -1
  84. package/dist/rfc3161/timestamp.d.ts.map +0 -1
  85. package/dist/rfc3161/tstinfo.d.ts.map +0 -1
  86. package/dist/sigstore.d.ts.map +0 -1
  87. package/dist/timestamp/tsa.d.ts.map +0 -1
  88. package/dist/tlog/body.d.ts.map +0 -1
  89. package/dist/tlog/checkpoint.d.ts.map +0 -1
  90. package/dist/tlog/dsse.d.ts.map +0 -1
  91. package/dist/tlog/hashedrekord.d.ts.map +0 -1
  92. package/dist/tlog/intoto.d.ts.map +0 -1
  93. package/dist/tlog/merkle.d.ts.map +0 -1
  94. package/dist/trust/tuf-root.d.ts.map +0 -1
  95. package/dist/trust/tuf.d.ts.map +0 -1
  96. package/dist/x509/cert.d.ts.map +0 -1
  97. package/dist/x509/chain.d.ts.map +0 -1
  98. package/dist/x509/ext.d.ts.map +0 -1
  99. package/dist/x509/index.d.ts.map +0 -1
  100. package/dist/x509/sct.d.ts.map +0 -1
  101. package/eslint.config.mjs +0 -31
  102. package/src/bundle.ts +0 -186
  103. package/src/cli.ts +0 -290
  104. package/src/dsse.ts +0 -49
  105. package/src/ed25519.browser.test.ts +0 -76
  106. package/src/errors.ts +0 -82
  107. package/src/index.browser.test.ts +0 -301
  108. package/src/index.ts +0 -93
  109. package/src/interfaces.ts +0 -150
  110. package/src/oid.ts +0 -34
  111. package/src/policy.ts +0 -476
  112. package/src/rfc3161/error.ts +0 -16
  113. package/src/rfc3161/index.ts +0 -17
  114. package/src/rfc3161/timestamp.ts +0 -268
  115. package/src/rfc3161/tstinfo.ts +0 -78
  116. package/src/security.browser.test.ts +0 -249
  117. package/src/sigstore.ts +0 -605
  118. package/src/timestamp/tsa.ts +0 -212
  119. package/src/tlog/body.ts +0 -84
  120. package/src/tlog/checkpoint.ts +0 -154
  121. package/src/tlog/dsse.ts +0 -153
  122. package/src/tlog/hashedrekord.ts +0 -136
  123. package/src/tlog/intoto.ts +0 -109
  124. package/src/tlog/merkle.ts +0 -152
  125. package/src/trust/README.md +0 -38
  126. package/src/trust/tuf-root.ts +0 -3
  127. package/src/trust/tuf.ts +0 -233
  128. package/src/verify.browser.test.ts +0 -281
  129. package/src/x509/cert.ts +0 -569
  130. package/src/x509/chain.ts +0 -212
  131. package/src/x509/ext.ts +0 -356
  132. package/src/x509/index.ts +0 -19
  133. package/src/x509/sct.ts +0 -156
  134. package/test/fixtures/rekor2.ts +0 -14
  135. package/test/fixtures/sigstore.ts +0 -13
  136. package/tsconfig.json +0 -18
  137. package/vite.config.playwright.ts +0 -14
  138. package/vite.config.ts +0 -18
package/src/policy.ts DELETED
@@ -1,476 +0,0 @@
1
- /**
2
- * Adapted from sigstore-python sigstore/verify/policy.py
3
- *
4
- * This module provides policy verification for checking certificate identity claims.
5
- * Each policy class verifies a specific X.509 extension value against an expected value.
6
- *
7
- * There are two types of extension formats:
8
- * - V1 extensions: Raw OCTET STRING containing the value directly
9
- * - V2 extensions: DER-encoded UTF8String (RFC 5280 compliant)
10
- *
11
- * Policies can be combined using:
12
- * - AllOf: All child policies must pass (logical AND)
13
- * - AnyOf: At least one child policy must pass (logical OR)
14
- * - Identity: Verifies SAN with optional issuer check
15
- */
16
-
17
- import { PolicyError } from "./errors.js";
18
- import {
19
- X509Certificate,
20
- EXTENSION_OID_FULCIO_ISSUER_V1,
21
- EXTENSION_OID_GITHUB_WORKFLOW_TRIGGER,
22
- EXTENSION_OID_GITHUB_WORKFLOW_SHA,
23
- EXTENSION_OID_GITHUB_WORKFLOW_NAME,
24
- EXTENSION_OID_GITHUB_WORKFLOW_REPOSITORY,
25
- EXTENSION_OID_GITHUB_WORKFLOW_REF,
26
- EXTENSION_OID_OTHERNAME,
27
- EXTENSION_OID_FULCIO_ISSUER_V2,
28
- EXTENSION_OID_BUILD_SIGNER_URI,
29
- EXTENSION_OID_BUILD_SIGNER_DIGEST,
30
- EXTENSION_OID_RUNNER_ENVIRONMENT,
31
- EXTENSION_OID_SOURCE_REPOSITORY_URI,
32
- EXTENSION_OID_SOURCE_REPOSITORY_DIGEST,
33
- EXTENSION_OID_SOURCE_REPOSITORY_REF,
34
- EXTENSION_OID_SOURCE_REPOSITORY_IDENTIFIER,
35
- EXTENSION_OID_SOURCE_REPOSITORY_OWNER_URI,
36
- EXTENSION_OID_SOURCE_REPOSITORY_OWNER_IDENTIFIER,
37
- EXTENSION_OID_BUILD_CONFIG_URI,
38
- EXTENSION_OID_BUILD_CONFIG_DIGEST,
39
- EXTENSION_OID_BUILD_TRIGGER,
40
- EXTENSION_OID_RUN_INVOCATION_URI,
41
- EXTENSION_OID_SOURCE_REPOSITORY_VISIBILITY,
42
- } from "./x509/cert.js";
43
-
44
- // Standard GitHub Actions OIDC issuer
45
- // https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/about-security-hardening-with-openid-connect
46
- export const GITHUB_OIDC_ISSUER = "https://token.actions.githubusercontent.com";
47
-
48
- /**
49
- * Interface that all verification policies conform to.
50
- */
51
- export interface VerificationPolicy {
52
- verify(cert: X509Certificate): void | Promise<void>;
53
- }
54
-
55
- /**
56
- * Base class for V1 extension policies (raw OCTET STRING value).
57
- */
58
- abstract class SingleX509ExtPolicyV1 implements VerificationPolicy {
59
- abstract readonly oid: string;
60
- abstract readonly name: string;
61
- protected readonly expectedValue: string;
62
-
63
- constructor(value: string) {
64
- this.expectedValue = value;
65
- }
66
-
67
- protected abstract getExtensionValue(cert: X509Certificate): string | undefined;
68
-
69
- verify(cert: X509Certificate): void {
70
- const extValue = this.getExtensionValue(cert);
71
- if (extValue === undefined) {
72
- throw new PolicyError(
73
- `Certificate does not contain ${this.name} (${this.oid}) extension`
74
- );
75
- }
76
- if (extValue !== this.expectedValue) {
77
- throw new PolicyError(
78
- `Certificate's ${this.name} does not match ` +
79
- `(got '${extValue}', expected '${this.expectedValue}')`
80
- );
81
- }
82
- }
83
- }
84
-
85
- /**
86
- * Base class for V2 extension policies (DER-encoded UTF8String).
87
- * Uses the same verify logic as V1 since our extension classes handle the parsing.
88
- */
89
- abstract class SingleX509ExtPolicyV2 extends SingleX509ExtPolicyV1 {}
90
-
91
- // ============================================================================
92
- // V1 Extension Policies (OID 1.3.6.1.4.1.57264.1.1 - 1.3.6.1.4.1.57264.1.6)
93
- // ============================================================================
94
-
95
- /**
96
- * Verifies the certificate's OIDC issuer (V1 format).
97
- * OID: 1.3.6.1.4.1.57264.1.1
98
- */
99
- export class OIDCIssuer extends SingleX509ExtPolicyV1 {
100
- readonly oid = EXTENSION_OID_FULCIO_ISSUER_V1;
101
- readonly name = "OIDCIssuer";
102
-
103
- protected getExtensionValue(cert: X509Certificate): string | undefined {
104
- return cert.extFulcioIssuerV1?.issuer;
105
- }
106
- }
107
-
108
- /**
109
- * Verifies the certificate's GitHub Actions workflow trigger.
110
- * OID: 1.3.6.1.4.1.57264.1.2
111
- */
112
- export class GitHubWorkflowTrigger extends SingleX509ExtPolicyV1 {
113
- readonly oid = EXTENSION_OID_GITHUB_WORKFLOW_TRIGGER;
114
- readonly name = "GitHubWorkflowTrigger";
115
-
116
- protected getExtensionValue(cert: X509Certificate): string | undefined {
117
- return cert.extGitHubWorkflowTrigger?.workflowTrigger;
118
- }
119
- }
120
-
121
- /**
122
- * Verifies the certificate's GitHub Actions workflow commit SHA.
123
- * OID: 1.3.6.1.4.1.57264.1.3
124
- */
125
- export class GitHubWorkflowSHA extends SingleX509ExtPolicyV1 {
126
- readonly oid = EXTENSION_OID_GITHUB_WORKFLOW_SHA;
127
- readonly name = "GitHubWorkflowSHA";
128
-
129
- protected getExtensionValue(cert: X509Certificate): string | undefined {
130
- return cert.extGitHubWorkflowSHA?.workflowSHA;
131
- }
132
- }
133
-
134
- /**
135
- * Verifies the certificate's GitHub Actions workflow name.
136
- * OID: 1.3.6.1.4.1.57264.1.4
137
- */
138
- export class GitHubWorkflowName extends SingleX509ExtPolicyV1 {
139
- readonly oid = EXTENSION_OID_GITHUB_WORKFLOW_NAME;
140
- readonly name = "GitHubWorkflowName";
141
-
142
- protected getExtensionValue(cert: X509Certificate): string | undefined {
143
- return cert.extGitHubWorkflowName?.workflowName;
144
- }
145
- }
146
-
147
- /**
148
- * Verifies the certificate's GitHub Actions workflow repository.
149
- * OID: 1.3.6.1.4.1.57264.1.5
150
- */
151
- export class GitHubWorkflowRepository extends SingleX509ExtPolicyV1 {
152
- readonly oid = EXTENSION_OID_GITHUB_WORKFLOW_REPOSITORY;
153
- readonly name = "GitHubWorkflowRepository";
154
-
155
- protected getExtensionValue(cert: X509Certificate): string | undefined {
156
- return cert.extGitHubWorkflowRepository?.workflowRepository;
157
- }
158
- }
159
-
160
- /**
161
- * Verifies the certificate's GitHub Actions workflow ref.
162
- * OID: 1.3.6.1.4.1.57264.1.6
163
- */
164
- export class GitHubWorkflowRef extends SingleX509ExtPolicyV1 {
165
- readonly oid = EXTENSION_OID_GITHUB_WORKFLOW_REF;
166
- readonly name = "GitHubWorkflowRef";
167
-
168
- protected getExtensionValue(cert: X509Certificate): string | undefined {
169
- return cert.extGitHubWorkflowRef?.workflowRef;
170
- }
171
- }
172
-
173
- // ============================================================================
174
- // V2 Extension Policies (OID 1.3.6.1.4.1.57264.1.8 - 1.3.6.1.4.1.57264.1.22)
175
- // ============================================================================
176
-
177
- /**
178
- * Verifies the certificate's OIDC issuer (V2 format, DER-encoded).
179
- * OID: 1.3.6.1.4.1.57264.1.8
180
- */
181
- export class OIDCIssuerV2 extends SingleX509ExtPolicyV2 {
182
- readonly oid = EXTENSION_OID_FULCIO_ISSUER_V2;
183
- readonly name = "OIDCIssuerV2";
184
-
185
- protected getExtensionValue(cert: X509Certificate): string | undefined {
186
- return cert.extFulcioIssuerV2?.issuer;
187
- }
188
- }
189
-
190
- /**
191
- * Verifies the certificate's Build Signer URI.
192
- * OID: 1.3.6.1.4.1.57264.1.9
193
- */
194
- export class OIDCBuildSignerURI extends SingleX509ExtPolicyV2 {
195
- readonly oid = EXTENSION_OID_BUILD_SIGNER_URI;
196
- readonly name = "OIDCBuildSignerURI";
197
-
198
- protected getExtensionValue(cert: X509Certificate): string | undefined {
199
- return cert.extBuildSignerURI?.buildSignerURI;
200
- }
201
- }
202
-
203
- /**
204
- * Verifies the certificate's Build Signer Digest.
205
- * OID: 1.3.6.1.4.1.57264.1.10
206
- */
207
- export class OIDCBuildSignerDigest extends SingleX509ExtPolicyV2 {
208
- readonly oid = EXTENSION_OID_BUILD_SIGNER_DIGEST;
209
- readonly name = "OIDCBuildSignerDigest";
210
-
211
- protected getExtensionValue(cert: X509Certificate): string | undefined {
212
- return cert.extBuildSignerDigest?.buildSignerDigest;
213
- }
214
- }
215
-
216
- /**
217
- * Verifies the certificate's Runner Environment.
218
- * OID: 1.3.6.1.4.1.57264.1.11
219
- */
220
- export class OIDCRunnerEnvironment extends SingleX509ExtPolicyV2 {
221
- readonly oid = EXTENSION_OID_RUNNER_ENVIRONMENT;
222
- readonly name = "OIDCRunnerEnvironment";
223
-
224
- protected getExtensionValue(cert: X509Certificate): string | undefined {
225
- return cert.extRunnerEnvironment?.runnerEnvironment;
226
- }
227
- }
228
-
229
- /**
230
- * Verifies the certificate's Source Repository URI.
231
- * OID: 1.3.6.1.4.1.57264.1.12
232
- */
233
- export class OIDCSourceRepositoryURI extends SingleX509ExtPolicyV2 {
234
- readonly oid = EXTENSION_OID_SOURCE_REPOSITORY_URI;
235
- readonly name = "OIDCSourceRepositoryURI";
236
-
237
- protected getExtensionValue(cert: X509Certificate): string | undefined {
238
- return cert.extSourceRepositoryURI?.sourceRepositoryURI;
239
- }
240
- }
241
-
242
- /**
243
- * Verifies the certificate's Source Repository Digest.
244
- * OID: 1.3.6.1.4.1.57264.1.13
245
- */
246
- export class OIDCSourceRepositoryDigest extends SingleX509ExtPolicyV2 {
247
- readonly oid = EXTENSION_OID_SOURCE_REPOSITORY_DIGEST;
248
- readonly name = "OIDCSourceRepositoryDigest";
249
-
250
- protected getExtensionValue(cert: X509Certificate): string | undefined {
251
- return cert.extSourceRepositoryDigest?.sourceRepositoryDigest;
252
- }
253
- }
254
-
255
- /**
256
- * Verifies the certificate's Source Repository Ref.
257
- * OID: 1.3.6.1.4.1.57264.1.14
258
- */
259
- export class OIDCSourceRepositoryRef extends SingleX509ExtPolicyV2 {
260
- readonly oid = EXTENSION_OID_SOURCE_REPOSITORY_REF;
261
- readonly name = "OIDCSourceRepositoryRef";
262
-
263
- protected getExtensionValue(cert: X509Certificate): string | undefined {
264
- return cert.extSourceRepositoryRef?.sourceRepositoryRef;
265
- }
266
- }
267
-
268
- /**
269
- * Verifies the certificate's Source Repository Identifier.
270
- * OID: 1.3.6.1.4.1.57264.1.15
271
- */
272
- export class OIDCSourceRepositoryIdentifier extends SingleX509ExtPolicyV2 {
273
- readonly oid = EXTENSION_OID_SOURCE_REPOSITORY_IDENTIFIER;
274
- readonly name = "OIDCSourceRepositoryIdentifier";
275
-
276
- protected getExtensionValue(cert: X509Certificate): string | undefined {
277
- return cert.extSourceRepositoryIdentifier?.sourceRepositoryIdentifier;
278
- }
279
- }
280
-
281
- /**
282
- * Verifies the certificate's Source Repository Owner URI.
283
- * OID: 1.3.6.1.4.1.57264.1.16
284
- */
285
- export class OIDCSourceRepositoryOwnerURI extends SingleX509ExtPolicyV2 {
286
- readonly oid = EXTENSION_OID_SOURCE_REPOSITORY_OWNER_URI;
287
- readonly name = "OIDCSourceRepositoryOwnerURI";
288
-
289
- protected getExtensionValue(cert: X509Certificate): string | undefined {
290
- return cert.extSourceRepositoryOwnerURI?.sourceRepositoryOwnerURI;
291
- }
292
- }
293
-
294
- /**
295
- * Verifies the certificate's Source Repository Owner Identifier.
296
- * OID: 1.3.6.1.4.1.57264.1.17
297
- */
298
- export class OIDCSourceRepositoryOwnerIdentifier extends SingleX509ExtPolicyV2 {
299
- readonly oid = EXTENSION_OID_SOURCE_REPOSITORY_OWNER_IDENTIFIER;
300
- readonly name = "OIDCSourceRepositoryOwnerIdentifier";
301
-
302
- protected getExtensionValue(cert: X509Certificate): string | undefined {
303
- return cert.extSourceRepositoryOwnerIdentifier?.sourceRepositoryOwnerIdentifier;
304
- }
305
- }
306
-
307
- /**
308
- * Verifies the certificate's Build Config URI.
309
- * OID: 1.3.6.1.4.1.57264.1.18
310
- */
311
- export class OIDCBuildConfigURI extends SingleX509ExtPolicyV2 {
312
- readonly oid = EXTENSION_OID_BUILD_CONFIG_URI;
313
- readonly name = "OIDCBuildConfigURI";
314
-
315
- protected getExtensionValue(cert: X509Certificate): string | undefined {
316
- return cert.extBuildConfigURI?.buildConfigURI;
317
- }
318
- }
319
-
320
- /**
321
- * Verifies the certificate's Build Config Digest.
322
- * OID: 1.3.6.1.4.1.57264.1.19
323
- */
324
- export class OIDCBuildConfigDigest extends SingleX509ExtPolicyV2 {
325
- readonly oid = EXTENSION_OID_BUILD_CONFIG_DIGEST;
326
- readonly name = "OIDCBuildConfigDigest";
327
-
328
- protected getExtensionValue(cert: X509Certificate): string | undefined {
329
- return cert.extBuildConfigDigest?.buildConfigDigest;
330
- }
331
- }
332
-
333
- /**
334
- * Verifies the certificate's Build Trigger.
335
- * OID: 1.3.6.1.4.1.57264.1.20
336
- */
337
- export class OIDCBuildTrigger extends SingleX509ExtPolicyV2 {
338
- readonly oid = EXTENSION_OID_BUILD_TRIGGER;
339
- readonly name = "OIDCBuildTrigger";
340
-
341
- protected getExtensionValue(cert: X509Certificate): string | undefined {
342
- return cert.extBuildTrigger?.buildTrigger;
343
- }
344
- }
345
-
346
- /**
347
- * Verifies the certificate's Run Invocation URI.
348
- * OID: 1.3.6.1.4.1.57264.1.21
349
- */
350
- export class OIDCRunInvocationURI extends SingleX509ExtPolicyV2 {
351
- readonly oid = EXTENSION_OID_RUN_INVOCATION_URI;
352
- readonly name = "OIDCRunInvocationURI";
353
-
354
- protected getExtensionValue(cert: X509Certificate): string | undefined {
355
- return cert.extRunInvocationURI?.runInvocationURI;
356
- }
357
- }
358
-
359
- /**
360
- * Verifies the certificate's Source Repository Visibility at signing.
361
- * OID: 1.3.6.1.4.1.57264.1.22
362
- */
363
- export class OIDCSourceRepositoryVisibility extends SingleX509ExtPolicyV2 {
364
- readonly oid = EXTENSION_OID_SOURCE_REPOSITORY_VISIBILITY;
365
- readonly name = "OIDCSourceRepositoryVisibility";
366
-
367
- protected getExtensionValue(cert: X509Certificate): string | undefined {
368
- return cert.extSourceRepositoryVisibility?.sourceRepositoryVisibility;
369
- }
370
- }
371
-
372
- // ============================================================================
373
- // Policy Combinators
374
- // ============================================================================
375
-
376
- /**
377
- * The "any of" policy, corresponding to a logical OR between child policies.
378
- * An empty list of child policies is considered trivially invalid.
379
- */
380
- export class AnyOf implements VerificationPolicy {
381
- private children: VerificationPolicy[];
382
-
383
- constructor(children: VerificationPolicy[]) {
384
- this.children = children;
385
- }
386
-
387
- async verify(cert: X509Certificate): Promise<void> {
388
- for (const child of this.children) {
389
- try {
390
- await child.verify(cert);
391
- return;
392
- } catch {
393
- // Continue to next policy
394
- }
395
- }
396
- throw new PolicyError(`0 of ${this.children.length} policies succeeded`);
397
- }
398
- }
399
-
400
- /**
401
- * The "all of" policy, corresponding to a logical AND between child policies.
402
- * An empty list of child policies is considered trivially invalid.
403
- */
404
- export class AllOf implements VerificationPolicy {
405
- private children: VerificationPolicy[];
406
-
407
- constructor(children: VerificationPolicy[]) {
408
- this.children = children;
409
- }
410
-
411
- async verify(cert: X509Certificate): Promise<void> {
412
- if (this.children.length < 1) {
413
- throw new PolicyError("no child policies to verify");
414
- }
415
- for (const child of this.children) {
416
- await child.verify(cert);
417
- }
418
- }
419
- }
420
-
421
- // ============================================================================
422
- // Identity Policy
423
- // ============================================================================
424
-
425
- /**
426
- * Verifies the certificate's "identity", corresponding to the X.509v3 SAN.
427
- *
428
- * Identities can be verified modulo an OIDC issuer, to prevent an unexpected
429
- * issuer from offering a particular identity.
430
- *
431
- * Supported SAN types include emails, URIs, and Sigstore-specific "other names".
432
- */
433
- export class Identity implements VerificationPolicy {
434
- private identity: string;
435
- private issuerPolicy: OIDCIssuer | null;
436
-
437
- constructor(options: { identity: string; issuer?: string }) {
438
- this.identity = options.identity;
439
- this.issuerPolicy = options.issuer ? new OIDCIssuer(options.issuer) : null;
440
- }
441
-
442
- verify(cert: X509Certificate): void {
443
- if (this.issuerPolicy) {
444
- this.issuerPolicy.verify(cert);
445
- }
446
-
447
- const sanExt = cert.extSubjectAltName;
448
- if (!sanExt) {
449
- throw new PolicyError("Certificate does not contain SubjectAlternativeName extension");
450
- }
451
-
452
- const allSans = new Set<string>();
453
-
454
- // Add email (rfc822Name)
455
- if (sanExt.rfc822Name) {
456
- allSans.add(sanExt.rfc822Name);
457
- }
458
-
459
- // Add URI
460
- if (sanExt.uri) {
461
- allSans.add(sanExt.uri);
462
- }
463
-
464
- // Add Sigstore-specific otherName
465
- const otherName = sanExt.otherName(EXTENSION_OID_OTHERNAME);
466
- if (otherName) {
467
- allSans.add(otherName);
468
- }
469
-
470
- if (!allSans.has(this.identity)) {
471
- throw new PolicyError(
472
- `Certificate's SANs do not match ${this.identity}; actual SANs: ${Array.from(allSans).join(", ")}`
473
- );
474
- }
475
- }
476
- }
@@ -1,16 +0,0 @@
1
- /*
2
- Copyright 2023 The Sigstore Authors.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
- export class RFC3161TimestampVerificationError extends Error {}
@@ -1,17 +0,0 @@
1
- /*
2
- Copyright 2023 The Sigstore Authors.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- export { RFC3161Timestamp } from "./timestamp.js";