@stogas/sigstore 0.1.0-alpha.1 → 0.1.0-alpha.12

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # `@stogas/sigstore`
2
2
 
3
- Small, networkless WebAssembly verifier for the standard GitHub/Sigstore v0.3 DSSE and in-toto
4
- profile supported by Stogas. It verifies embedded Fulcio, SCT, Rekor v1 and v2, RFC 3161, subject,
5
- identity, and GitHub Actions provenance material without fetching TUF or calling Sigstore
3
+ Small, networkless WebAssembly verifier for the Sigstore v0.3 DSSE and in-toto profile of build
4
+ attestations from GitHub Actions and GitLab.com. It verifies embedded Fulcio, SCT, Rekor v1 and v2,
5
+ RFC 3161, subject, identity and CI provenance material without fetching TUF or calling Sigstore
6
6
  services.
7
7
 
8
8
  Pass Sigstore's current `trusted_root.json`, which you vouch for: fetch it through a TUF client
@@ -13,15 +13,32 @@ older attestations.
13
13
  Use `stogas` to verify the complete Stogas confidential-gateway evidence and transport.
14
14
 
15
15
  ```js
16
- import { verify_github_attestation } from '@stogas/sigstore';
16
+ import { verify_build_attestation } from '@stogas/sigstore';
17
17
 
18
- const verified = verify_github_attestation(
18
+ const verified = verify_build_attestation(
19
19
  attestationBytes,
20
- JSON.stringify(subjects),
21
- JSON.stringify(policy),
20
+ [{ name: 'gateway.igvm', sha256: '1b75d0ea…' }],
21
+ {
22
+ repository: 'https://github.com/StogasAI/gateway',
23
+ workflow_identity:
24
+ 'https://github.com/StogasAI/gateway/.github/workflows/gateway-igvm-release.yml@refs/tags/v0.0.1',
25
+ source_ref: 'refs/tags/v0.0.1',
26
+ source_commit: '27eb4b954a372975c9e7c5dbc77fbf0d0ca53b3f',
27
+ predicate_type: 'https://slsa.dev/provenance/v1'
28
+ },
22
29
  trustedRootJson
23
30
  );
24
31
  ```
25
32
 
26
- The default Node/Bun export initializes WebAssembly synchronously. Browser consumers initialize
33
+ It returns the authenticated log time, the subjects and the statement's predicate. The
34
+ repository's host selects the provider: a GitLab.com project such as
35
+ `https://gitlab.com/stogasai/gateway` takes the identity
36
+ `https://gitlab.com/stogasai/gateway//.gitlab-ci.yml@refs/tags/v0.0.1`. The job writes the
37
+ predicate, so the policy's repository, ref, commit, workflow and hosted runner come from the Fulcio
38
+ certificate instead. `verify_dsse_attestation` takes the same arguments with
39
+ any signer's identity, `{ certificate_identity, certificate_oidc_issuer, predicate_type }`, and
40
+ leaves the predicate to your own policy. Unknown fields in subjects and policies throw, so that a
41
+ misspelled requirement cannot go unchecked.
42
+
43
+ The default Node, Bun and Deno export initializes WebAssembly synchronously. Browser consumers initialize
27
44
  the `/browser` module once with its default initializer; compatible Workers use `/worker`.
@@ -1 +1,10 @@
1
- export { verify_github_attestation } from '../../pkg/browser/stogas_sigstore.js';
1
+ export {
2
+ verify_dsse_attestation,
3
+ verify_build_attestation
4
+ } from '../../pkg/browser/stogas_sigstore.js';
5
+ export type {
6
+ BuildPolicy,
7
+ IdentityPolicy,
8
+ Subject,
9
+ VerifiedAttestation
10
+ } from '../../pkg/browser/stogas_sigstore.js';
@@ -1,7 +1,11 @@
1
1
  import { readFileSync } from 'node:fs';
2
- import { initSync, verify_github_attestation } from '../../pkg/browser/stogas_sigstore.js';
2
+ import {
3
+ initSync,
4
+ verify_dsse_attestation,
5
+ verify_build_attestation
6
+ } from '../../pkg/browser/stogas_sigstore.js';
3
7
 
4
8
  const wasm = readFileSync(new URL('../../pkg/browser/stogas_sigstore_bg.wasm', import.meta.url));
5
9
  initSync({ module: wasm });
6
10
 
7
- export { verify_github_attestation };
11
+ export { verify_dsse_attestation, verify_build_attestation };
@@ -1 +1,10 @@
1
- export { verify_github_attestation } from '../../pkg/browser/stogas_sigstore.js';
1
+ export {
2
+ verify_dsse_attestation,
3
+ verify_build_attestation
4
+ } from '../../pkg/browser/stogas_sigstore.js';
5
+ export type {
6
+ BuildPolicy,
7
+ IdentityPolicy,
8
+ Subject,
9
+ VerifiedAttestation
10
+ } from '../../pkg/browser/stogas_sigstore.js';
@@ -1,6 +1,10 @@
1
1
  import wasmModule from '../../pkg/browser/stogas_sigstore_bg.wasm';
2
- import { initSync, verify_github_attestation } from '../../pkg/browser/stogas_sigstore.js';
2
+ import {
3
+ initSync,
4
+ verify_dsse_attestation,
5
+ verify_build_attestation
6
+ } from '../../pkg/browser/stogas_sigstore.js';
3
7
 
4
8
  initSync({ module: wasmModule });
5
9
 
6
- export { verify_github_attestation };
10
+ export { verify_dsse_attestation, verify_build_attestation };
package/package.json CHANGED
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "name": "@stogas/sigstore",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "Lightweight networkless WASM verification for GitHub/Sigstore in-toto attestations",
5
+ "keywords": [
6
+ "attestation",
7
+ "in-toto",
8
+ "provenance",
9
+ "sigstore",
10
+ "slsa",
11
+ "webassembly"
12
+ ],
5
13
  "license": "Apache-2.0",
6
14
  "repository": {
7
15
  "type": "git",
8
16
  "url": "git+https://github.com/StogasAI/stogas.git",
9
17
  "directory": "packages/sigstore"
10
18
  },
11
- "homepage": "https://github.com/StogasAI/stogas#packages",
19
+ "homepage": "https://github.com/StogasAI/stogas/tree/main/packages/sigstore#readme",
12
20
  "bugs": "https://github.com/StogasAI/stogas/issues",
13
21
  "engines": {
14
22
  "node": ">=20"
@@ -27,15 +35,16 @@
27
35
  "exports": {
28
36
  ".": {
29
37
  "types": "./bindings/node/node.d.ts",
30
- "import": "./bindings/node/node.js"
38
+ "default": "./bindings/node/node.js"
31
39
  },
32
40
  "./browser": {
33
41
  "types": "./pkg/browser/stogas_sigstore.d.ts",
34
- "import": "./pkg/browser/stogas_sigstore.js"
42
+ "default": "./pkg/browser/stogas_sigstore.js"
35
43
  },
36
44
  "./worker": {
37
45
  "types": "./bindings/worker/worker.d.ts",
38
- "import": "./bindings/worker/worker.js"
39
- }
46
+ "default": "./bindings/worker/worker.js"
47
+ },
48
+ "./package.json": "./package.json"
40
49
  }
41
50
  }
@@ -1,8 +1,43 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /** A file that the attestation must name, with its lowercase SHA-256 digest. */
5
+ export interface Subject {
6
+ name: string;
7
+ sha256: string;
8
+ }
9
+ /**
10
+ * The repository, workflow or pipeline file, ref and commit whose GitHub Actions or GitLab.com CI
11
+ * job made the attestation. The repository's host selects the provider.
12
+ */
13
+ export interface BuildPolicy {
14
+ repository: string;
15
+ workflow_identity: string;
16
+ source_ref: string;
17
+ source_commit: string;
18
+ predicate_type: string;
19
+ }
20
+ /** Any signer's exact certificate identity and OIDC issuer. */
21
+ export interface IdentityPolicy {
22
+ certificate_identity: string;
23
+ certificate_oidc_issuer: string;
24
+ predicate_type: string;
25
+ }
26
+ export interface VerifiedAttestation {
27
+ /** When Rekor or a timestamp authority recorded the signature, in seconds since the UNIX epoch. */
28
+ integrated_time: number;
29
+ predicate_type: string;
30
+ /** `[name, sha256]` */
31
+ subjects: [string, string][];
32
+ /** The statement's predicate, as its signer wrote it. */
33
+ predicate: unknown;
34
+ }
35
+
36
+
37
+
4
38
  /**
5
- * Verify a GitHub/Sigstore attestation against Sigstore's `trusted_root.json`.
39
+ * Verify a build attestation from a GitHub Actions or GitLab.com hosted runner against
40
+ * Sigstore's `trusted_root.json`.
6
41
  *
7
42
  * The caller vouches for the trusted root. Signed log and timestamp times decide validity, so
8
43
  * the result does not depend on the platform clock.
@@ -11,15 +46,29 @@
11
46
  *
12
47
  * Returns a JavaScript error for a malformed trusted root or policy, or untrusted evidence.
13
48
  */
14
- export function verify_github_attestation(bundle: Uint8Array, expected_subjects_json: string, policy_json: string, trusted_root_json: string): any;
49
+ export function verify_build_attestation(bundle: Uint8Array, subjects: Subject[], policy: BuildPolicy, trusted_root_json: string): VerifiedAttestation;
50
+
51
+ /**
52
+ * Verify any signer's DSSE attestation against an exact certificate identity and OIDC issuer.
53
+ *
54
+ * The result carries the statement's predicate, to which the caller applies its own policy.
55
+ *
56
+ * # Errors
57
+ *
58
+ * Returns a JavaScript error for a malformed trusted root or policy, or untrusted evidence.
59
+ */
60
+ export function verify_dsse_attestation(bundle: Uint8Array, subjects: Subject[], policy: IdentityPolicy, trusted_root_json: string): VerifiedAttestation;
15
61
 
16
62
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
17
63
 
18
64
  export interface InitOutput {
19
65
  readonly memory: WebAssembly.Memory;
20
- readonly verify_github_attestation: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
66
+ readonly verify_build_attestation: (a: number, b: number, c: any, d: any, e: number, f: number) => [number, number, number];
67
+ readonly verify_dsse_attestation: (a: number, b: number, c: any, d: any, e: number, f: number) => [number, number, number];
21
68
  readonly __wbindgen_malloc: (a: number, b: number) => number;
22
69
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
70
+ readonly __wbindgen_exn_store: (a: number) => void;
71
+ readonly __externref_table_alloc: () => number;
23
72
  readonly __wbindgen_externrefs: WebAssembly.Table;
24
73
  readonly __externref_table_dealloc: (a: number) => void;
25
74
  readonly __wbindgen_start: () => void;
@@ -1,7 +1,8 @@
1
1
  /* @ts-self-types="./stogas_sigstore.d.ts" */
2
2
 
3
3
  /**
4
- * Verify a GitHub/Sigstore attestation against Sigstore's `trusted_root.json`.
4
+ * Verify a build attestation from a GitHub Actions or GitLab.com hosted runner against
5
+ * Sigstore's `trusted_root.json`.
5
6
  *
6
7
  * The caller vouches for the trusted root. Signed log and timestamp times decide validity, so
7
8
  * the result does not depend on the platform clock.
@@ -10,21 +11,43 @@
10
11
  *
11
12
  * Returns a JavaScript error for a malformed trusted root or policy, or untrusted evidence.
12
13
  * @param {Uint8Array} bundle
13
- * @param {string} expected_subjects_json
14
- * @param {string} policy_json
14
+ * @param {Subject[]} subjects
15
+ * @param {BuildPolicy} policy
15
16
  * @param {string} trusted_root_json
16
- * @returns {any}
17
+ * @returns {VerifiedAttestation}
17
18
  */
18
- export function verify_github_attestation(bundle, expected_subjects_json, policy_json, trusted_root_json) {
19
+ export function verify_build_attestation(bundle, subjects, policy, trusted_root_json) {
19
20
  const ptr0 = passArray8ToWasm0(bundle, wasm.__wbindgen_malloc);
20
21
  const len0 = WASM_VECTOR_LEN;
21
- const ptr1 = passStringToWasm0(expected_subjects_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
22
+ const ptr1 = passStringToWasm0(trusted_root_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
22
23
  const len1 = WASM_VECTOR_LEN;
23
- const ptr2 = passStringToWasm0(policy_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
24
- const len2 = WASM_VECTOR_LEN;
25
- const ptr3 = passStringToWasm0(trusted_root_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
26
- const len3 = WASM_VECTOR_LEN;
27
- const ret = wasm.verify_github_attestation(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
24
+ const ret = wasm.verify_build_attestation(ptr0, len0, subjects, policy, ptr1, len1);
25
+ if (ret[2]) {
26
+ throw takeFromExternrefTable0(ret[1]);
27
+ }
28
+ return takeFromExternrefTable0(ret[0]);
29
+ }
30
+
31
+ /**
32
+ * Verify any signer's DSSE attestation against an exact certificate identity and OIDC issuer.
33
+ *
34
+ * The result carries the statement's predicate, to which the caller applies its own policy.
35
+ *
36
+ * # Errors
37
+ *
38
+ * Returns a JavaScript error for a malformed trusted root or policy, or untrusted evidence.
39
+ * @param {Uint8Array} bundle
40
+ * @param {Subject[]} subjects
41
+ * @param {IdentityPolicy} policy
42
+ * @param {string} trusted_root_json
43
+ * @returns {VerifiedAttestation}
44
+ */
45
+ export function verify_dsse_attestation(bundle, subjects, policy, trusted_root_json) {
46
+ const ptr0 = passArray8ToWasm0(bundle, wasm.__wbindgen_malloc);
47
+ const len0 = WASM_VECTOR_LEN;
48
+ const ptr1 = passStringToWasm0(trusted_root_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49
+ const len1 = WASM_VECTOR_LEN;
50
+ const ret = wasm.verify_dsse_attestation(ptr0, len0, subjects, policy, ptr1, len1);
28
51
  if (ret[2]) {
29
52
  throw takeFromExternrefTable0(ret[1]);
30
53
  }
@@ -44,9 +67,25 @@ function __wbg_get_imports() {
44
67
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
45
68
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
46
69
  },
70
+ __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
71
+ const ret = typeof(arg0) === 'string';
72
+ return ret;
73
+ },
74
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
75
+ const obj = arg1;
76
+ const ret = typeof(obj) === 'string' ? obj : undefined;
77
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
78
+ var len1 = WASM_VECTOR_LEN;
79
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
80
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
81
+ },
47
82
  __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
48
83
  throw new Error(getStringFromWasm0(arg0, arg1));
49
84
  },
85
+ __wbg_new_28744009d011f847: function() {
86
+ const ret = new Map();
87
+ return ret;
88
+ },
50
89
  __wbg_new_617a8cdb8bb1130e: function() {
51
90
  const ret = new Object();
52
91
  return ret;
@@ -55,12 +94,20 @@ function __wbg_get_imports() {
55
94
  const ret = new Array();
56
95
  return ret;
57
96
  },
97
+ __wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
98
+ const ret = arg0.set(arg1, arg2);
99
+ return ret;
100
+ },
58
101
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
59
102
  arg0[arg1] = arg2;
60
103
  },
61
104
  __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
62
105
  arg0[arg1 >>> 0] = arg2;
63
106
  },
107
+ __wbg_stringify_52ff602c1cc4fbb6: function() { return handleError(function (arg0) {
108
+ const ret = JSON.stringify(arg0);
109
+ return ret;
110
+ }, arguments); },
64
111
  __wbindgen_generic_0000000000000001: function(arg0) {
65
112
  // Cast intrinsic for `F64 -> Externref`.
66
113
  const ret = arg0;
@@ -76,6 +123,11 @@ function __wbg_get_imports() {
76
123
  const ret = getStringFromWasm0(arg0, arg1);
77
124
  return ret;
78
125
  },
126
+ __wbindgen_generic_0000000000000004: function(arg0) {
127
+ // Cast intrinsic for `U64 -> Externref`.
128
+ const ret = BigInt.asUintN(64, arg0);
129
+ return ret;
130
+ },
79
131
  __wbindgen_init_externref_table: function() {
80
132
  const table = wasm.__wbindgen_externrefs;
81
133
  const offset = table.grow(4);
@@ -92,6 +144,12 @@ function __wbg_get_imports() {
92
144
  };
93
145
  }
94
146
 
147
+ function addToExternrefTable0(obj) {
148
+ const idx = wasm.__externref_table_alloc();
149
+ wasm.__wbindgen_externrefs.set(idx, obj);
150
+ return idx;
151
+ }
152
+
95
153
  let cachedDataViewMemory0 = null;
96
154
  function getDataViewMemory0() {
97
155
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -112,6 +170,19 @@ function getUint8ArrayMemory0() {
112
170
  return cachedUint8ArrayMemory0;
113
171
  }
114
172
 
173
+ function handleError(f, args) {
174
+ try {
175
+ return f.apply(this, args);
176
+ } catch (e) {
177
+ const idx = addToExternrefTable0(e);
178
+ wasm.__wbindgen_exn_store(idx);
179
+ }
180
+ }
181
+
182
+ function isLikeNone(x) {
183
+ return x === undefined || x === null;
184
+ }
185
+
115
186
  function passArray8ToWasm0(arg, malloc) {
116
187
  const ptr = malloc(arg.length * 1, 1) >>> 0;
117
188
  getUint8ArrayMemory0().set(arg, ptr / 1);
Binary file
@@ -1,9 +1,12 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const verify_github_attestation: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
4
+ export const verify_build_attestation: (a: number, b: number, c: any, d: any, e: number, f: number) => [number, number, number];
5
+ export const verify_dsse_attestation: (a: number, b: number, c: any, d: any, e: number, f: number) => [number, number, number];
5
6
  export const __wbindgen_malloc: (a: number, b: number) => number;
6
7
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
8
+ export const __wbindgen_exn_store: (a: number) => void;
9
+ export const __externref_table_alloc: () => number;
7
10
  export const __wbindgen_externrefs: WebAssembly.Table;
8
11
  export const __externref_table_dealloc: (a: number) => void;
9
12
  export const __wbindgen_start: () => void;