@enactprotocol/trust 2.0.0 → 2.0.2
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/hash.d.ts +53 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +104 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +41 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +130 -0
- package/dist/keys.js.map +1 -0
- package/dist/sigstore/attestation.d.ts +245 -0
- package/dist/sigstore/attestation.d.ts.map +1 -0
- package/dist/sigstore/attestation.js +324 -0
- package/dist/sigstore/attestation.js.map +1 -0
- package/dist/sigstore/cosign.d.ts +90 -0
- package/dist/sigstore/cosign.d.ts.map +1 -0
- package/dist/sigstore/cosign.js +457 -0
- package/dist/sigstore/cosign.js.map +1 -0
- package/dist/sigstore/index.d.ts +17 -0
- package/dist/sigstore/index.d.ts.map +1 -0
- package/dist/sigstore/index.js +21 -0
- package/dist/sigstore/index.js.map +1 -0
- package/dist/sigstore/oauth/client.d.ts +38 -0
- package/dist/sigstore/oauth/client.d.ts.map +1 -0
- package/dist/sigstore/oauth/client.js +71 -0
- package/dist/sigstore/oauth/client.js.map +1 -0
- package/dist/sigstore/oauth/index.d.ts +47 -0
- package/dist/sigstore/oauth/index.d.ts.map +1 -0
- package/dist/sigstore/oauth/index.js +66 -0
- package/dist/sigstore/oauth/index.js.map +1 -0
- package/dist/sigstore/oauth/server.d.ts +29 -0
- package/dist/sigstore/oauth/server.d.ts.map +1 -0
- package/dist/sigstore/oauth/server.js +145 -0
- package/dist/sigstore/oauth/server.js.map +1 -0
- package/dist/sigstore/policy.d.ts +85 -0
- package/dist/sigstore/policy.d.ts.map +1 -0
- package/dist/sigstore/policy.js +351 -0
- package/dist/sigstore/policy.js.map +1 -0
- package/dist/sigstore/signing.d.ts +94 -0
- package/dist/sigstore/signing.d.ts.map +1 -0
- package/dist/sigstore/signing.js +477 -0
- package/dist/sigstore/signing.js.map +1 -0
- package/dist/sigstore/types.d.ts +541 -0
- package/dist/sigstore/types.d.ts.map +1 -0
- package/dist/sigstore/types.js +5 -0
- package/dist/sigstore/types.js.map +1 -0
- package/dist/sigstore/verification.d.ts +66 -0
- package/dist/sigstore/verification.d.ts.map +1 -0
- package/dist/sigstore/verification.js +317 -0
- package/dist/sigstore/verification.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cosign CLI integration for interactive OIDC signing
|
|
3
|
+
*
|
|
4
|
+
* The sigstore-js library is designed for CI environments where OIDC tokens
|
|
5
|
+
* are available via environment variables. For interactive local signing,
|
|
6
|
+
* we shell out to the cosign CLI which handles the browser-based OAuth flow.
|
|
7
|
+
*/
|
|
8
|
+
import { execSync, spawn } from "node:child_process";
|
|
9
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
/**
|
|
13
|
+
* Check if cosign CLI is available
|
|
14
|
+
*/
|
|
15
|
+
export function isCosignAvailable() {
|
|
16
|
+
try {
|
|
17
|
+
execSync("which cosign", { encoding: "utf-8", stdio: "pipe" });
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get cosign version information
|
|
26
|
+
*/
|
|
27
|
+
export function getCosignVersion() {
|
|
28
|
+
try {
|
|
29
|
+
const output = execSync("cosign version", { encoding: "utf-8", stdio: "pipe" });
|
|
30
|
+
const match = output.match(/GitVersion:\s+v?([\d.]+)/);
|
|
31
|
+
return match?.[1];
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sign a blob (file or buffer) using cosign with interactive OIDC
|
|
39
|
+
*
|
|
40
|
+
* This opens a browser for OAuth authentication with Sigstore's public
|
|
41
|
+
* OIDC provider. The signature, certificate, and Rekor entry are bundled
|
|
42
|
+
* together in the Sigstore bundle format.
|
|
43
|
+
*
|
|
44
|
+
* @param data - The data to sign (Buffer or path to file)
|
|
45
|
+
* @param options - Signing options
|
|
46
|
+
* @returns The signing result with bundle
|
|
47
|
+
*/
|
|
48
|
+
export async function signWithCosign(data, options = {}) {
|
|
49
|
+
if (!isCosignAvailable()) {
|
|
50
|
+
throw new Error("cosign CLI is not installed. Install it with: brew install cosign\n" +
|
|
51
|
+
"See: https://docs.sigstore.dev/cosign/system_config/installation/");
|
|
52
|
+
}
|
|
53
|
+
const { timeout = 120000, outputPath, verbose = false } = options;
|
|
54
|
+
// Create temp directory for working files
|
|
55
|
+
const tempDir = join(tmpdir(), `enact-sign-${Date.now()}`);
|
|
56
|
+
mkdirSync(tempDir, { recursive: true });
|
|
57
|
+
const blobPath = join(tempDir, "blob");
|
|
58
|
+
const bundlePath = outputPath ?? join(tempDir, "bundle.json");
|
|
59
|
+
try {
|
|
60
|
+
// Write data to temp file if it's a buffer
|
|
61
|
+
if (Buffer.isBuffer(data)) {
|
|
62
|
+
writeFileSync(blobPath, data);
|
|
63
|
+
}
|
|
64
|
+
else if (typeof data === "string" && existsSync(data)) {
|
|
65
|
+
// It's a file path, copy to temp location
|
|
66
|
+
const content = readFileSync(data);
|
|
67
|
+
writeFileSync(blobPath, content);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// It's string content
|
|
71
|
+
writeFileSync(blobPath, data);
|
|
72
|
+
}
|
|
73
|
+
// Run cosign sign-blob with bundle output
|
|
74
|
+
// The --yes flag auto-confirms the OIDC consent prompt
|
|
75
|
+
const args = [
|
|
76
|
+
"sign-blob",
|
|
77
|
+
"--yes", // Auto-confirm OIDC consent
|
|
78
|
+
"--bundle",
|
|
79
|
+
bundlePath,
|
|
80
|
+
"--output-signature",
|
|
81
|
+
"/dev/null", // We only want the bundle
|
|
82
|
+
"--output-certificate",
|
|
83
|
+
"/dev/null", // Bundle includes the cert
|
|
84
|
+
blobPath,
|
|
85
|
+
];
|
|
86
|
+
if (verbose) {
|
|
87
|
+
console.log(`Running: cosign ${args.join(" ")}`);
|
|
88
|
+
}
|
|
89
|
+
await new Promise((resolve, reject) => {
|
|
90
|
+
const proc = spawn("cosign", args, {
|
|
91
|
+
stdio: verbose ? "inherit" : ["inherit", "pipe", "pipe"],
|
|
92
|
+
timeout,
|
|
93
|
+
});
|
|
94
|
+
let stderr = "";
|
|
95
|
+
if (!verbose) {
|
|
96
|
+
proc.stderr?.on("data", (data) => {
|
|
97
|
+
stderr += data.toString();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
proc.on("error", (err) => {
|
|
101
|
+
reject(new Error(`Failed to run cosign: ${err.message}`));
|
|
102
|
+
});
|
|
103
|
+
proc.on("close", (code) => {
|
|
104
|
+
if (code === 0) {
|
|
105
|
+
resolve();
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Check for common error patterns
|
|
109
|
+
if (stderr.includes("context deadline exceeded") || stderr.includes("timeout")) {
|
|
110
|
+
reject(new Error("OIDC authentication timed out. Please try again and complete the browser flow."));
|
|
111
|
+
}
|
|
112
|
+
else if (stderr.includes("cancelled")) {
|
|
113
|
+
reject(new Error("Signing was cancelled."));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
reject(new Error(`cosign exited with code ${code}: ${stderr || "(no output)"}`));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
// Read the bundle
|
|
122
|
+
if (!existsSync(bundlePath)) {
|
|
123
|
+
throw new Error("cosign did not produce a bundle file");
|
|
124
|
+
}
|
|
125
|
+
const bundleContent = readFileSync(bundlePath, "utf-8");
|
|
126
|
+
const bundle = JSON.parse(bundleContent);
|
|
127
|
+
// Extract signer identity from the bundle if possible
|
|
128
|
+
const signerIdentity = extractSignerFromBundle(bundle);
|
|
129
|
+
return {
|
|
130
|
+
bundle,
|
|
131
|
+
bundlePath,
|
|
132
|
+
signerIdentity,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
// Clean up temp files (but not the output bundle if specified)
|
|
137
|
+
try {
|
|
138
|
+
if (existsSync(blobPath)) {
|
|
139
|
+
unlinkSync(blobPath);
|
|
140
|
+
}
|
|
141
|
+
if (!outputPath && existsSync(bundlePath)) {
|
|
142
|
+
unlinkSync(bundlePath);
|
|
143
|
+
}
|
|
144
|
+
// Try to remove temp dir
|
|
145
|
+
if (existsSync(tempDir)) {
|
|
146
|
+
const { rmdirSync } = require("node:fs");
|
|
147
|
+
rmdirSync(tempDir, { recursive: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Ignore cleanup errors
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Sign an in-toto attestation using cosign
|
|
157
|
+
*
|
|
158
|
+
* For in-toto attestations, we use cosign attest-blob which wraps the
|
|
159
|
+
* attestation in a DSSE envelope.
|
|
160
|
+
*
|
|
161
|
+
* @param attestation - The in-toto statement to sign
|
|
162
|
+
* @param options - Signing options
|
|
163
|
+
* @returns The signing result with bundle
|
|
164
|
+
*/
|
|
165
|
+
export async function attestWithCosign(attestation, options = {}) {
|
|
166
|
+
if (!isCosignAvailable()) {
|
|
167
|
+
throw new Error("cosign CLI is not installed. Install it with: brew install cosign\n" +
|
|
168
|
+
"See: https://docs.sigstore.dev/cosign/system_config/installation/");
|
|
169
|
+
}
|
|
170
|
+
const { timeout = 120000, outputPath, verbose = false } = options;
|
|
171
|
+
// Create temp directory for working files
|
|
172
|
+
const tempDir = join(tmpdir(), `enact-attest-${Date.now()}`);
|
|
173
|
+
mkdirSync(tempDir, { recursive: true });
|
|
174
|
+
const predicatePath = join(tempDir, "predicate.json");
|
|
175
|
+
const bundlePath = outputPath ?? join(tempDir, "bundle.json");
|
|
176
|
+
// cosign attest-blob needs a subject file (the thing being attested)
|
|
177
|
+
// For tool attestations, we'll create a dummy subject file
|
|
178
|
+
const subjectPath = join(tempDir, "subject");
|
|
179
|
+
try {
|
|
180
|
+
// Extract the predicate from the in-toto statement
|
|
181
|
+
// cosign attest-blob takes the predicate separately
|
|
182
|
+
const statement = attestation;
|
|
183
|
+
// Write the predicate to a file
|
|
184
|
+
writeFileSync(predicatePath, JSON.stringify(statement.predicate, null, 2));
|
|
185
|
+
// Create a subject file with the expected content
|
|
186
|
+
// The subject should be the content that matches the digest in the statement
|
|
187
|
+
// For now, we'll just create a placeholder and rely on the predicate
|
|
188
|
+
const subjectName = statement.subject?.[0]?.name ?? "tool.yaml";
|
|
189
|
+
writeFileSync(subjectPath, subjectName);
|
|
190
|
+
// Use cosign attest-blob
|
|
191
|
+
// Note: attest-blob is for custom predicates, which is what we have
|
|
192
|
+
const args = [
|
|
193
|
+
"attest-blob",
|
|
194
|
+
"--yes", // Auto-confirm OIDC consent
|
|
195
|
+
"--bundle",
|
|
196
|
+
bundlePath,
|
|
197
|
+
"--predicate",
|
|
198
|
+
predicatePath,
|
|
199
|
+
"--type",
|
|
200
|
+
statement.predicateType,
|
|
201
|
+
subjectPath,
|
|
202
|
+
];
|
|
203
|
+
if (verbose) {
|
|
204
|
+
console.log(`Running: cosign ${args.join(" ")}`);
|
|
205
|
+
}
|
|
206
|
+
await new Promise((resolve, reject) => {
|
|
207
|
+
const proc = spawn("cosign", args, {
|
|
208
|
+
stdio: verbose ? "inherit" : ["inherit", "pipe", "pipe"],
|
|
209
|
+
timeout,
|
|
210
|
+
});
|
|
211
|
+
let stderr = "";
|
|
212
|
+
if (!verbose) {
|
|
213
|
+
proc.stderr?.on("data", (data) => {
|
|
214
|
+
stderr += data.toString();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
proc.on("error", (err) => {
|
|
218
|
+
reject(new Error(`Failed to run cosign: ${err.message}`));
|
|
219
|
+
});
|
|
220
|
+
proc.on("close", (code) => {
|
|
221
|
+
if (code === 0) {
|
|
222
|
+
resolve();
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
if (stderr.includes("context deadline exceeded") || stderr.includes("timeout")) {
|
|
226
|
+
reject(new Error("OIDC authentication timed out. Please try again and complete the browser flow."));
|
|
227
|
+
}
|
|
228
|
+
else if (stderr.includes("cancelled")) {
|
|
229
|
+
reject(new Error("Signing was cancelled."));
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
reject(new Error(`cosign exited with code ${code}: ${stderr || "(no output)"}`));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
// Read the bundle
|
|
238
|
+
if (!existsSync(bundlePath)) {
|
|
239
|
+
throw new Error("cosign did not produce a bundle file");
|
|
240
|
+
}
|
|
241
|
+
const bundleContent = readFileSync(bundlePath, "utf-8");
|
|
242
|
+
const bundle = JSON.parse(bundleContent);
|
|
243
|
+
// Extract signer identity from the bundle
|
|
244
|
+
const signerIdentity = extractSignerFromBundle(bundle);
|
|
245
|
+
return {
|
|
246
|
+
bundle,
|
|
247
|
+
bundlePath,
|
|
248
|
+
signerIdentity,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
finally {
|
|
252
|
+
// Clean up temp files
|
|
253
|
+
try {
|
|
254
|
+
for (const file of [predicatePath, subjectPath]) {
|
|
255
|
+
if (existsSync(file)) {
|
|
256
|
+
unlinkSync(file);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (!outputPath && existsSync(bundlePath)) {
|
|
260
|
+
unlinkSync(bundlePath);
|
|
261
|
+
}
|
|
262
|
+
if (existsSync(tempDir)) {
|
|
263
|
+
const { rmdirSync } = require("node:fs");
|
|
264
|
+
rmdirSync(tempDir, { recursive: true });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// Ignore cleanup errors
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Verify a blob signature using cosign
|
|
274
|
+
*
|
|
275
|
+
* @param data - The data that was signed
|
|
276
|
+
* @param bundle - The Sigstore bundle
|
|
277
|
+
* @param expectedIdentity - Expected signer identity (email)
|
|
278
|
+
* @param expectedIssuer - Expected OIDC issuer
|
|
279
|
+
* @returns Whether verification succeeded
|
|
280
|
+
*/
|
|
281
|
+
export async function verifyWithCosign(data, bundle, expectedIdentity, expectedIssuer) {
|
|
282
|
+
if (!isCosignAvailable()) {
|
|
283
|
+
throw new Error("cosign CLI is not installed");
|
|
284
|
+
}
|
|
285
|
+
const tempDir = join(tmpdir(), `enact-verify-${Date.now()}`);
|
|
286
|
+
mkdirSync(tempDir, { recursive: true });
|
|
287
|
+
const blobPath = join(tempDir, "blob");
|
|
288
|
+
const bundlePath = join(tempDir, "bundle.json");
|
|
289
|
+
try {
|
|
290
|
+
// Write data and bundle to temp files
|
|
291
|
+
if (Buffer.isBuffer(data)) {
|
|
292
|
+
writeFileSync(blobPath, data);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
writeFileSync(blobPath, data);
|
|
296
|
+
}
|
|
297
|
+
writeFileSync(bundlePath, JSON.stringify(bundle, null, 2));
|
|
298
|
+
// Build cosign verify-blob command
|
|
299
|
+
const args = ["verify-blob", "--bundle", bundlePath];
|
|
300
|
+
if (expectedIdentity) {
|
|
301
|
+
args.push("--certificate-identity", expectedIdentity);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
// Use regex to match any identity
|
|
305
|
+
args.push("--certificate-identity-regexp", ".*");
|
|
306
|
+
}
|
|
307
|
+
if (expectedIssuer) {
|
|
308
|
+
args.push("--certificate-oidc-issuer", expectedIssuer);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
// Match common Sigstore OIDC issuers
|
|
312
|
+
args.push("--certificate-oidc-issuer-regexp", "(https://accounts.google.com|https://github.com/login/oauth|https://oauth2.sigstore.dev/auth)");
|
|
313
|
+
}
|
|
314
|
+
args.push(blobPath);
|
|
315
|
+
execSync(`cosign ${args.join(" ")}`, {
|
|
316
|
+
encoding: "utf-8",
|
|
317
|
+
stdio: "pipe",
|
|
318
|
+
});
|
|
319
|
+
const identity = extractSignerFromBundle(bundle);
|
|
320
|
+
return {
|
|
321
|
+
verified: true,
|
|
322
|
+
error: undefined,
|
|
323
|
+
identity,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
328
|
+
return {
|
|
329
|
+
verified: false,
|
|
330
|
+
error,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
finally {
|
|
334
|
+
// Clean up
|
|
335
|
+
try {
|
|
336
|
+
for (const file of [blobPath, bundlePath]) {
|
|
337
|
+
if (existsSync(file)) {
|
|
338
|
+
unlinkSync(file);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (existsSync(tempDir)) {
|
|
342
|
+
const { rmdirSync } = require("node:fs");
|
|
343
|
+
rmdirSync(tempDir, { recursive: true });
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
// Ignore cleanup errors
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Extract signer identity (email) from a Sigstore bundle
|
|
353
|
+
*
|
|
354
|
+
* The certificate in the bundle contains the signer's email in the
|
|
355
|
+
* Subject Alternative Name (SAN) extension.
|
|
356
|
+
*/
|
|
357
|
+
function extractSignerFromBundle(bundle) {
|
|
358
|
+
try {
|
|
359
|
+
// The certificate is in verificationMaterial.certificate.rawBytes (base64)
|
|
360
|
+
const certB64 = bundle?.verificationMaterial?.certificate?.rawBytes;
|
|
361
|
+
if (!certB64) {
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
// Decode the certificate
|
|
365
|
+
const certDer = Buffer.from(certB64, "base64");
|
|
366
|
+
// Simple extraction of email from certificate
|
|
367
|
+
// Look for the email pattern in the SAN extension
|
|
368
|
+
// This is a simplified extraction - a proper implementation would parse X.509
|
|
369
|
+
const certStr = certDer.toString("latin1");
|
|
370
|
+
// Look for email pattern - match word chars, dots, hyphens, plus before @
|
|
371
|
+
// and domain after, but stop at non-word characters
|
|
372
|
+
const emailMatch = certStr.match(/[\w.+-]+@[\w.-]+\.[a-zA-Z]{2,}/);
|
|
373
|
+
return emailMatch?.[0];
|
|
374
|
+
}
|
|
375
|
+
catch {
|
|
376
|
+
return undefined;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Verify an attestation bundle using cosign
|
|
381
|
+
*
|
|
382
|
+
* @param bundle - The Sigstore bundle containing a DSSE-wrapped attestation
|
|
383
|
+
* @param expectedIdentity - Expected signer identity (email)
|
|
384
|
+
* @param expectedIssuer - Expected OIDC issuer
|
|
385
|
+
* @param predicateType - The attestation predicate type (optional)
|
|
386
|
+
* @returns Verification result
|
|
387
|
+
*/
|
|
388
|
+
export async function verifyAttestationWithCosign(bundle, expectedIdentity, expectedIssuer, predicateType) {
|
|
389
|
+
if (!isCosignAvailable()) {
|
|
390
|
+
throw new Error("cosign CLI is not installed");
|
|
391
|
+
}
|
|
392
|
+
const tempDir = join(tmpdir(), `enact-verify-attest-${Date.now()}`);
|
|
393
|
+
mkdirSync(tempDir, { recursive: true });
|
|
394
|
+
const bundlePath = join(tempDir, "bundle.json");
|
|
395
|
+
try {
|
|
396
|
+
writeFileSync(bundlePath, JSON.stringify(bundle, null, 2));
|
|
397
|
+
// Build cosign verify-blob-attestation command
|
|
398
|
+
const args = ["verify-blob-attestation", "--bundle", bundlePath];
|
|
399
|
+
if (expectedIdentity) {
|
|
400
|
+
args.push("--certificate-identity", expectedIdentity);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
args.push("--certificate-identity-regexp", ".*");
|
|
404
|
+
}
|
|
405
|
+
if (expectedIssuer) {
|
|
406
|
+
args.push("--certificate-oidc-issuer", expectedIssuer);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
// Match common Sigstore OIDC issuers
|
|
410
|
+
args.push("--certificate-oidc-issuer-regexp", ".*");
|
|
411
|
+
}
|
|
412
|
+
if (predicateType) {
|
|
413
|
+
args.push("--type", predicateType);
|
|
414
|
+
}
|
|
415
|
+
// Don't check claims against a subject file
|
|
416
|
+
args.push("--check-claims=false");
|
|
417
|
+
// Use /dev/null as the "subject" - attestation verification doesn't need it
|
|
418
|
+
args.push("/dev/null");
|
|
419
|
+
// Use spawnSync to avoid shell escaping issues
|
|
420
|
+
const { spawnSync } = require("node:child_process");
|
|
421
|
+
const result = spawnSync("cosign", args, {
|
|
422
|
+
encoding: "utf-8",
|
|
423
|
+
stdio: "pipe",
|
|
424
|
+
});
|
|
425
|
+
if (result.status !== 0) {
|
|
426
|
+
throw new Error(result.stderr || result.stdout || `cosign exited with code ${result.status}`);
|
|
427
|
+
}
|
|
428
|
+
const identity = extractSignerFromBundle(bundle);
|
|
429
|
+
return {
|
|
430
|
+
verified: true,
|
|
431
|
+
error: undefined,
|
|
432
|
+
identity,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
catch (err) {
|
|
436
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
437
|
+
return {
|
|
438
|
+
verified: false,
|
|
439
|
+
error,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
finally {
|
|
443
|
+
try {
|
|
444
|
+
if (existsSync(bundlePath)) {
|
|
445
|
+
unlinkSync(bundlePath);
|
|
446
|
+
}
|
|
447
|
+
if (existsSync(tempDir)) {
|
|
448
|
+
const { rmdirSync } = require("node:fs");
|
|
449
|
+
rmdirSync(tempDir, { recursive: true });
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
// Ignore cleanup errors
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
//# sourceMappingURL=cosign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosign.js","sourceRoot":"","sources":["../../src/sigstore/cosign.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,CAAC;QACH,QAAQ,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAChF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QACvD,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AA0BD;;;;;;;;;;GA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AI,MAAM,CAAC,MAAM,IAAI,2BAA2B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAChG,CAAC;QAED,MAAM,QAAQ,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,SAAS;YAChB,QAAQ;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/D,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,KAAK;SACN,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC3B,UAAU,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC;YACD,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;gBACzC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sigstore integration for Enact
|
|
3
|
+
*
|
|
4
|
+
* This module provides Sigstore-based attestation signing and verification
|
|
5
|
+
* capabilities for the Enact tool ecosystem.
|
|
6
|
+
*/
|
|
7
|
+
export type { OIDCProvider, OIDCIdentity, OIDCOptions, FulcioCertificate, FulcioCertificateOptions, RekorEntry, RekorInclusionProof, RekorEntryOptions, InTotoStatement, InTotoSubject, SLSAProvenancePredicate, SLSAResourceDescriptor, SigstoreBundle, TransparencyLogEntry, SigningOptions, SigningResult, VerificationOptions, VerificationResult, VerificationDetails, ExpectedIdentity, TrustRoot, CertificateAuthority, TransparencyLog, TimestampAuthority, TrustPolicy, TrustedIdentityRule, TrustPolicyResult, VerifiedAttestation, EnactToolPredicate, EnactAttestationBundle, } from "./types";
|
|
8
|
+
export { signArtifact, signAttestation, extractOIDCIdentity, extractCertificateFromBundle, extractIdentityFromBundle, detectOIDCProvider, getOIDCTokenFromEnvironment, FULCIO_PUBLIC_URL, REKOR_PUBLIC_URL, TSA_PUBLIC_URL, OIDC_ISSUERS, } from "./signing";
|
|
9
|
+
export { OAuthIdentityProvider, CallbackServer, OAuthClient, initializeOAuthClient, SIGSTORE_OAUTH_ISSUER, SIGSTORE_CLIENT_ID, } from "./oauth";
|
|
10
|
+
export type { OAuthIdentityProviderOptions, IdentityProvider, } from "./oauth";
|
|
11
|
+
export { isCosignAvailable, getCosignVersion, signWithCosign, attestWithCosign, verifyWithCosign, verifyAttestationWithCosign, } from "./cosign";
|
|
12
|
+
export type { CosignSignOptions, CosignSignResult } from "./cosign";
|
|
13
|
+
export { verifyBundle, createBundleVerifier, isVerified, } from "./verification";
|
|
14
|
+
export { createSubjectFromContent, createSubjectFromFile, createSubjectWithMultipleDigests, createStatement, createSLSAProvenance, createSLSAProvenanceStatement, createEnactToolPredicate, createEnactToolStatement, createEnactAuditPredicate, createEnactAuditStatement, createResourceDescriptorFromFile, createResourceDescriptorFromContent, ENACT_BASE_URL, INTOTO_STATEMENT_TYPE, SLSA_PROVENANCE_TYPE, ENACT_TOOL_TYPE, ENACT_AUDIT_TYPE, ENACT_BUILD_TYPE, } from "./attestation";
|
|
15
|
+
export { createTrustPolicy, createIdentityRule, evaluateTrustPolicy, isTrusted, serializeTrustPolicy, deserializeTrustPolicy, DEFAULT_TRUST_POLICY, PERMISSIVE_POLICY, STRICT_POLICY, } from "./policy";
|
|
16
|
+
export type { SLSAProvenanceOptions, EnactToolAttestationOptions, EnactAuditAttestationOptions, EnactAuditPredicate, } from "./attestation";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sigstore/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAEV,YAAY,EACZ,YAAY,EACZ,WAAW,EAEX,iBAAiB,EACjB,wBAAwB,EAExB,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EAEjB,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EAEtB,cAAc,EACd,oBAAoB,EAEpB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAEhB,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EAEnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,4BAA4B,EAC5B,yBAAyB,EACzB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,GACb,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGpE,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,UAAU,GACX,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,gCAAgC,EAChC,eAAe,EACf,oBAAoB,EACpB,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,gCAAgC,EAChC,mCAAmC,EAEnC,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sigstore integration for Enact
|
|
3
|
+
*
|
|
4
|
+
* This module provides Sigstore-based attestation signing and verification
|
|
5
|
+
* capabilities for the Enact tool ecosystem.
|
|
6
|
+
*/
|
|
7
|
+
// Signing
|
|
8
|
+
export { signArtifact, signAttestation, extractOIDCIdentity, extractCertificateFromBundle, extractIdentityFromBundle, detectOIDCProvider, getOIDCTokenFromEnvironment, FULCIO_PUBLIC_URL, REKOR_PUBLIC_URL, TSA_PUBLIC_URL, OIDC_ISSUERS, } from "./signing";
|
|
9
|
+
// OAuth Identity Provider (for interactive signing)
|
|
10
|
+
export { OAuthIdentityProvider, CallbackServer, OAuthClient, initializeOAuthClient, SIGSTORE_OAUTH_ISSUER, SIGSTORE_CLIENT_ID, } from "./oauth";
|
|
11
|
+
// Cosign CLI integration (fallback for interactive signing)
|
|
12
|
+
export { isCosignAvailable, getCosignVersion, signWithCosign, attestWithCosign, verifyWithCosign, verifyAttestationWithCosign, } from "./cosign";
|
|
13
|
+
// Verification
|
|
14
|
+
export { verifyBundle, createBundleVerifier, isVerified, } from "./verification";
|
|
15
|
+
// Attestation creation
|
|
16
|
+
export { createSubjectFromContent, createSubjectFromFile, createSubjectWithMultipleDigests, createStatement, createSLSAProvenance, createSLSAProvenanceStatement, createEnactToolPredicate, createEnactToolStatement, createEnactAuditPredicate, createEnactAuditStatement, createResourceDescriptorFromFile, createResourceDescriptorFromContent,
|
|
17
|
+
// Constants
|
|
18
|
+
ENACT_BASE_URL, INTOTO_STATEMENT_TYPE, SLSA_PROVENANCE_TYPE, ENACT_TOOL_TYPE, ENACT_AUDIT_TYPE, ENACT_BUILD_TYPE, } from "./attestation";
|
|
19
|
+
// Trust policy
|
|
20
|
+
export { createTrustPolicy, createIdentityRule, evaluateTrustPolicy, isTrusted, serializeTrustPolicy, deserializeTrustPolicy, DEFAULT_TRUST_POLICY, PERMISSIVE_POLICY, STRICT_POLICY, } from "./policy";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sigstore/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4CH,UAAU;AACV,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,4BAA4B,EAC5B,yBAAyB,EACzB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,oDAAoD;AACpD,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAMjB,4DAA4D;AAC5D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAGlB,eAAe;AACf,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,uBAAuB;AACvB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,gCAAgC,EAChC,eAAe,EACf,oBAAoB,EACpB,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,gCAAgC,EAChC,mCAAmC;AACnC,YAAY;AACZ,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,eAAe;AACf,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Client
|
|
3
|
+
*
|
|
4
|
+
* Wrapper around openid-client for PKCE-based OAuth flow with Sigstore.
|
|
5
|
+
*/
|
|
6
|
+
import { type BaseClient } from "openid-client";
|
|
7
|
+
interface OAuthClientOptions {
|
|
8
|
+
issuer: string;
|
|
9
|
+
redirectURL: string;
|
|
10
|
+
clientID: string;
|
|
11
|
+
clientSecret: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Initialize an OAuth client by discovering the issuer's configuration
|
|
15
|
+
*/
|
|
16
|
+
export declare function initializeOAuthClient(options: OAuthClientOptions): Promise<OAuthClient>;
|
|
17
|
+
/**
|
|
18
|
+
* OAuthClient wraps an openid-client Client instance to maintain
|
|
19
|
+
* state for the PKCE authorization flow.
|
|
20
|
+
*/
|
|
21
|
+
export declare class OAuthClient {
|
|
22
|
+
private client;
|
|
23
|
+
private redirectURL;
|
|
24
|
+
private verifier;
|
|
25
|
+
private nonce;
|
|
26
|
+
private state;
|
|
27
|
+
constructor(client: BaseClient, redirectURL: string);
|
|
28
|
+
/**
|
|
29
|
+
* Get the authorization URL to redirect the user to
|
|
30
|
+
*/
|
|
31
|
+
get authorizationUrl(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Exchange the callback URL for an ID token
|
|
34
|
+
*/
|
|
35
|
+
getIDToken(callbackURL: string): Promise<string>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/sigstore/oauth/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,eAAe,CAAC;AAEpE,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAiB7F;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM;IAQnD;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,CAS7B;IAED;;OAEG;IACU,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAe9D"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth Client
|
|
3
|
+
*
|
|
4
|
+
* Wrapper around openid-client for PKCE-based OAuth flow with Sigstore.
|
|
5
|
+
*/
|
|
6
|
+
import { Issuer, generators } from "openid-client";
|
|
7
|
+
/**
|
|
8
|
+
* Initialize an OAuth client by discovering the issuer's configuration
|
|
9
|
+
*/
|
|
10
|
+
export async function initializeOAuthClient(options) {
|
|
11
|
+
const issuer = await Issuer.discover(options.issuer);
|
|
12
|
+
const client = new issuer.Client(options.clientSecret
|
|
13
|
+
? {
|
|
14
|
+
client_id: options.clientID,
|
|
15
|
+
client_secret: options.clientSecret,
|
|
16
|
+
token_endpoint_auth_method: "client_secret_basic",
|
|
17
|
+
}
|
|
18
|
+
: {
|
|
19
|
+
client_id: options.clientID,
|
|
20
|
+
token_endpoint_auth_method: "none",
|
|
21
|
+
});
|
|
22
|
+
return new OAuthClient(client, options.redirectURL);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* OAuthClient wraps an openid-client Client instance to maintain
|
|
26
|
+
* state for the PKCE authorization flow.
|
|
27
|
+
*/
|
|
28
|
+
export class OAuthClient {
|
|
29
|
+
client;
|
|
30
|
+
redirectURL;
|
|
31
|
+
verifier;
|
|
32
|
+
nonce;
|
|
33
|
+
state;
|
|
34
|
+
constructor(client, redirectURL) {
|
|
35
|
+
this.client = client;
|
|
36
|
+
this.redirectURL = redirectURL;
|
|
37
|
+
this.verifier = generators.codeVerifier(32);
|
|
38
|
+
this.nonce = generators.nonce(32);
|
|
39
|
+
this.state = generators.state(16);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the authorization URL to redirect the user to
|
|
43
|
+
*/
|
|
44
|
+
get authorizationUrl() {
|
|
45
|
+
return this.client.authorizationUrl({
|
|
46
|
+
scope: "openid email",
|
|
47
|
+
redirect_uri: this.redirectURL,
|
|
48
|
+
code_challenge: generators.codeChallenge(this.verifier),
|
|
49
|
+
code_challenge_method: "S256",
|
|
50
|
+
state: this.state,
|
|
51
|
+
nonce: this.nonce,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Exchange the callback URL for an ID token
|
|
56
|
+
*/
|
|
57
|
+
async getIDToken(callbackURL) {
|
|
58
|
+
const params = this.client.callbackParams(callbackURL);
|
|
59
|
+
const tokenSet = await this.client.callback(this.redirectURL, params, {
|
|
60
|
+
response_type: "code",
|
|
61
|
+
code_verifier: this.verifier,
|
|
62
|
+
state: this.state,
|
|
63
|
+
nonce: this.nonce,
|
|
64
|
+
});
|
|
65
|
+
if (!tokenSet.id_token) {
|
|
66
|
+
throw new Error("No ID token received from OAuth provider");
|
|
67
|
+
}
|
|
68
|
+
return tokenSet.id_token;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/sigstore/oauth/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAmB,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AASpE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAA2B;IACrE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAC9B,OAAO,CAAC,YAAY;QAClB,CAAC,CAAC;YACE,SAAS,EAAE,OAAO,CAAC,QAAQ;YAC3B,aAAa,EAAE,OAAO,CAAC,YAAY;YACnC,0BAA0B,EAAE,qBAA8B;SAC3D;QACH,CAAC,CAAC;YACE,SAAS,EAAE,OAAO,CAAC,QAAQ;YAC3B,0BAA0B,EAAE,MAAe;SAC5C,CACN,CAAC;IAEF,OAAO,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAa;IACnB,WAAW,CAAS;IACpB,QAAQ,CAAS;IACjB,KAAK,CAAS;IACd,KAAK,CAAS;IAEtB,YAAY,MAAkB,EAAE,WAAmB;QACjD,IAAI,CAAC,M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