@registrystack/client 0.0.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,302 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ /**
4
+ * One opaque, locally verified progressive result. Its getters keep the
5
+ * ambiguity check for `value` lazy and retain the exact artifact below the
6
+ * FFI boundary until the caller asks for it.
7
+ */
8
+ export declare class AudienceScopedResult {
9
+ get responseFormat(): string
10
+ get evidence(): any
11
+ get traceId(): string | null
12
+ get assertion(): Buffer | null
13
+ get credential(): string | null
14
+ get values(): any
15
+ get value(): any
16
+ get subjectContinuity(): SubjectContinuity
17
+ }
18
+
19
+ /** A relying party's connection to one Evidence deployment. */
20
+ export declare class EvidenceClient {
21
+ /**
22
+ * Build a client for one deployment. `trustedJwks` and `revokedKeyIds` are
23
+ * mandatory trust inputs. A key set or revoked-key list the verifier could
24
+ * never use is refused, exactly as the Rust configuration refuses it.
25
+ *
26
+ * `maxResponseBytes` bounds the signed response `send` reads.
27
+ * `maxMetadataBytes` bounds the documents `discover` and `fetchJwks` read,
28
+ * which are neither signed nor verified, and is a separate decision.
29
+ */
30
+ constructor(config: any)
31
+ /**
32
+ * Build the progressive client from an application-owned profile. An
33
+ * optional private JWK is an in-memory override for a secret-manager
34
+ * integration; it is parsed without ever rendering its contents in an
35
+ * error. Profile paths and file-backed secrets remain inside the core
36
+ * client and are likewise redacted there.
37
+ */
38
+ static fromProfile(path: string, privateKeyJwk?: any): EvidenceClient
39
+ /**
40
+ * Close the expectations for one request and generate its nonce. No I/O
41
+ * happens here. The returned request is good for exactly one exchange:
42
+ * spend it with `send` or `requestAndVerify`.
43
+ */
44
+ prepare(spec: { responseFormat: 'signed-jws' | 'sd-jwt-vc'; [key: string]: any }): PreparedEvidenceRequest
45
+ /**
46
+ * Close one independently nonce-bound policy for each positional item in
47
+ * a multi-subject request batch. No I/O happens here, and the returned
48
+ * opaque batch is good for exactly one exchange.
49
+ */
50
+ prepareBatch(spec: { requirement: string; purpose: string; audience: string; evidenceType: string; issuedBy: string; providedBy: string; configurationRevision: string; expectedAssuranceProfile: any; expectedOutputs: ReadonlyArray<Readonly<Record<string, any>>>; maximumAssertionLifetimeSeconds: number; clockSkewSeconds: number; items: ReadonlyArray<{ subjects: ReadonlyArray<{ role: string; selectorProfile: string; selectorValues?: Readonly<Record<string, string | number | boolean>> | null }>; subjectExpectations: 'acceptFirstUse' | { pinned: ReadonlyArray<{ role: string; binding: string }> } }> }): PreparedEvidenceRequestBatch
51
+ /**
52
+ * Read the request shapes this requester is entitled to send. Discovery
53
+ * is authoring input, not a trust anchor: it never supplies verification
54
+ * expectations for a request already in flight.
55
+ */
56
+ discover(): Promise<any>
57
+ /**
58
+ * Read the deployment's published verification key set, for an
59
+ * out-of-band pinning workflow. Verification never calls this: a key set
60
+ * fetched from the same origin as the response it would verify
61
+ * establishes nothing.
62
+ */
63
+ fetchJwks(): Promise<any>
64
+ /**
65
+ * Refresh the profile's public metadata under the core client's bounded,
66
+ * single-flight cache policy. It never substitutes a response-time key
67
+ * refresh for the key snapshot closed before a request.
68
+ */
69
+ refreshMetadata(): Promise<void>
70
+ /**
71
+ * Discover, prepare, send exactly once, and verify one audience-scoped
72
+ * request. The request object intentionally accepts only explicit
73
+ * selectors or explicit role maps, and the Rust core owns all definition
74
+ * selection, metadata trust, receipt matching, and result construction.
75
+ */
76
+ request(request: any): Promise<AudienceScopedResult>
77
+ /**
78
+ * Send one prepared request and read the signed response.
79
+ *
80
+ * `prepared` allows exactly one send: a second call with the same object
81
+ * rejects with the configuration failure the Rust layer already
82
+ * produces, without reaching the deployment. Retrying means preparing
83
+ * again, for a fresh nonce.
84
+ */
85
+ send(prepared: PreparedEvidenceRequest): Promise<RawEvidenceResponse>
86
+ /**
87
+ * Send one prepared request batch and read its unverified envelope. The
88
+ * same opaque prepared object cannot be sent twice.
89
+ */
90
+ sendBatch(prepared: PreparedEvidenceRequestBatch): Promise<RawEvidenceRequestBatchResponse>
91
+ /**
92
+ * Verify a signed response against the policy its request closed, as of
93
+ * now. The trusted key set is the one pinned at construction, always.
94
+ *
95
+ * Unlike sending, verifying is unrestricted: it is offline and
96
+ * idempotent, so a retained response may be re-verified against a
97
+ * retained prepared request as often as needed, including after the
98
+ * single send has been spent.
99
+ */
100
+ verify(prepared: PreparedEvidenceRequest, response: RawEvidenceResponse): VerifiedEvidence
101
+ /**
102
+ * Atomically verify every available member against the policy at its own
103
+ * request position. No partial result is returned when one member fails.
104
+ */
105
+ verifyBatch(prepared: PreparedEvidenceRequestBatch, response: RawEvidenceRequestBatchResponse): VerifiedEvidenceRequestBatch
106
+ /**
107
+ * Request evidence and verify it in one step. This spends the single
108
+ * send `prepared` allows, exactly as `send` does, so calling it twice
109
+ * with one prepared request fails locally on the second call.
110
+ */
111
+ requestAndVerify(prepared: PreparedEvidenceRequest): Promise<VerifiedEvidence>
112
+ /** Send and atomically verify one prepared request batch in one step. */
113
+ requestAndVerifyBatch(prepared: PreparedEvidenceRequestBatch): Promise<VerifiedEvidenceRequestBatch>
114
+ /**
115
+ * Verify a retained response as of an explicit instant, given as
116
+ * milliseconds since the Unix epoch.
117
+ *
118
+ * `verify` judges a response against the current clock, which is right
119
+ * when the response has just arrived. This variant names the instant
120
+ * instead, for re-verifying a retained response or replaying a retained
121
+ * transaction record at the instant the original decision was made.
122
+ *
123
+ * A past instant is the direction that costs something: naming a stale
124
+ * instant accepts an assertion whose validity interval has since
125
+ * elapsed, because the question asked is whether it was acceptable then,
126
+ * and the answer stays yes forever. A live trust decision calls `verify`,
127
+ * not this.
128
+ */
129
+ verifyAsOf(prepared: PreparedEvidenceRequest, response: RawEvidenceResponse, asOfMillis: number): VerifiedEvidence
130
+ /**
131
+ * Atomically verify a retained request-batch envelope as of an explicit
132
+ * instant, in milliseconds since the Unix epoch.
133
+ */
134
+ verifyBatchAsOf(prepared: PreparedEvidenceRequestBatch, response: RawEvidenceRequestBatchResponse, asOfMillis: number): VerifiedEvidenceRequestBatch
135
+ }
136
+
137
+ /**
138
+ * One request, closed and nonce-bearing, before any byte has left the
139
+ * process.
140
+ *
141
+ * There is no constructor exposed to JS: the only way to obtain one is
142
+ * `EvidenceClient.prepare`, which mirrors the real type having no public
143
+ * constructor of its own either.
144
+ */
145
+ export declare class PreparedEvidenceRequest {
146
+ /** The nonce this request carries. Retain it with the transaction record. */
147
+ get requestNonce(): string
148
+ /**
149
+ * The closed verification policy, with the subject set as `prepare` left
150
+ * it.
151
+ */
152
+ get policyDocument(): any
153
+ /**
154
+ * `"acceptFirstUse"` or `{ pinned: [{ role, binding }, ...] }`, exactly as
155
+ * this request was prepared.
156
+ */
157
+ get subjectExpectations(): any
158
+ }
159
+
160
+ /**
161
+ * One ordered request batch, with one nonce and closed policy per item,
162
+ * before any byte has left the process.
163
+ *
164
+ * There is no constructor exposed to JS. The only way to obtain this opaque
165
+ * class is `EvidenceClient.prepareBatch`, and every `Arc` clone shares the
166
+ * real batch's one-send flag rather than recreating it.
167
+ */
168
+ export declare class PreparedEvidenceRequestBatch {
169
+ /** Independently generated item nonces in request order. */
170
+ get requestNonces(): Array<string>
171
+ /** Independently closed policy documents in request order. */
172
+ get policyDocuments(): Array<any>
173
+ /** Subject-verification stances in request order. */
174
+ get subjectExpectations(): Array<any>
175
+ /** Number of positional requests in this batch. */
176
+ get count(): number
177
+ }
178
+
179
+ /**
180
+ * Request-batch response bytes read but not yet judged.
181
+ *
182
+ * The class is opaque and has no JS constructor. It can only be returned by
183
+ * `EvidenceClient.sendBatch` and handed back to batch verification.
184
+ */
185
+ export declare class RawEvidenceRequestBatchResponse {
186
+ /** Response envelope bytes exactly as received. */
187
+ get body(): Buffer
188
+ /** Deployment correlation identifier for the whole batch exchange. */
189
+ get traceId(): string | null
190
+ }
191
+
192
+ /**
193
+ * A signed response, read but not yet judged.
194
+ *
195
+ * There is no constructor exposed to JS: the real Rust type has no public
196
+ * constructor either, so the only way to obtain one is `EvidenceClient.send`.
197
+ */
198
+ export declare class RawEvidenceResponse {
199
+ /**
200
+ * The signed response bytes, exactly as received. Nothing in them has
201
+ * been trusted yet; `verify` is what judges them.
202
+ */
203
+ get body(): Buffer
204
+ /**
205
+ * The validated W3C trace identifier for this exchange. It is support
206
+ * correlation only, not an Evidence audit operation identity.
207
+ */
208
+ get traceId(): string | null
209
+ }
210
+
211
+ /**
212
+ * The issuance envelope answering one request that presented several holder
213
+ * keys, read but not yet judged.
214
+ *
215
+ * The envelope's order is the request's own: `credentials[i]` answers the
216
+ * key the request sent as `holderKeys[i]`, one credential per key, and a
217
+ * caller that needs that correspondence spelled out can ask for it by index
218
+ * with `credentialForHolderKey`. There is no partial envelope: either every
219
+ * presented key was answered or reading the envelope failed.
220
+ *
221
+ * Reading it judges nothing. Each credential is verified individually,
222
+ * exactly as a single credential is, and parsing this envelope is not a step
223
+ * in that.
224
+ */
225
+ export declare class SdJwtVcBatchResponse {
226
+ /**
227
+ * Read an envelope from the response bytes a batch exchange returned,
228
+ * such as `RawEvidenceResponse.body`.
229
+ *
230
+ * This is a constructor rather than a static factory because napi-rs
231
+ * defines a generated static as non-writable and non-configurable on the
232
+ * class object, which leaves `client.js` no way to patch its throw path
233
+ * the way it patches every other member here. A constructor it can
234
+ * subclass, exactly as it already does for `EvidenceClient`.
235
+ */
236
+ constructor(body: Buffer)
237
+ /**
238
+ * Every credential the envelope carries, in the order the request
239
+ * presented its holder keys.
240
+ */
241
+ get credentials(): Array<string>
242
+ /**
243
+ * How many credentials the envelope carries, which is how many holder
244
+ * keys the request presented.
245
+ */
246
+ get count(): number
247
+ /**
248
+ * The credential bound to the holder key the request sent at `index`, or
249
+ * `null` when the envelope carries no credential at that position.
250
+ */
251
+ credentialForHolderKey(index: number): string | null
252
+ }
253
+
254
+ /**
255
+ * An application-owned receipt emitted after a verified audience-scoped
256
+ * result. It is serializable but deliberately opaque to this binding: no
257
+ * selector or disclosed value is copied into it here.
258
+ */
259
+ export type SubjectContinuity =
260
+ | { status: 'firstUse', receipt: any }
261
+ | { status: 'matched', receipt: any }
262
+
263
+ /**
264
+ * A response that satisfied every expectation.
265
+ *
266
+ * Unlike the opaque classes above, this crosses as a plain object: it is a
267
+ * terminal result nothing hands back into a later call, so there is no
268
+ * single-send flag or unconstructible real type to protect by staying
269
+ * opaque.
270
+ */
271
+ export interface VerifiedEvidence {
272
+ /** The verified payload, serialized field for field with no hand mapping. */
273
+ evidence: any
274
+ /**
275
+ * The validated W3C trace identifier for the exchange that produced this
276
+ * payload. It is support correlation only, not an Evidence audit operation
277
+ * identity.
278
+ */
279
+ traceId?: string
280
+ /**
281
+ * The role-bound subject bindings this payload carries. Persist these
282
+ * after a first-use acceptance and pass them back as `subjectExpectations:
283
+ * { pinned: [...] }` from then on.
284
+ */
285
+ pinnedSubjectExpectations: any
286
+ }
287
+
288
+ /** Every item of an atomically verified request-batch response. */
289
+ export interface VerifiedEvidenceRequestBatch {
290
+ items: Array<VerifiedEvidenceRequestBatchItem>
291
+ traceId?: string
292
+ }
293
+
294
+ /**
295
+ * One ordered terminal request-batch result.
296
+ *
297
+ * The generated TypeScript declaration is a discriminated union:
298
+ * `{ status: "available", verified } | { status: "notAvailable" }`.
299
+ */
300
+ export type VerifiedEvidenceRequestBatchItem =
301
+ | { status: 'available', verified: VerifiedEvidence }
302
+ | { status: 'notAvailable' }
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('../native').load('evidence');
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import * as discovery from './discovery/client'
2
+ import * as evidence from './evidence/client'
3
+ import * as relay from './relay/client'
4
+ import * as breg from './breg/client'
5
+
6
+ export { discovery, evidence, relay, breg }
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ // One assignment per namespace, never a `module.exports` object literal: Node
4
+ // scans this file for these statements to synthesise the named exports an ESM
5
+ // consumer imports, and `require()` sees the same four properties either way.
6
+ exports.discovery = require('./discovery/client');
7
+ exports.evidence = require('./evidence/client');
8
+ exports.relay = require('./relay/client');
9
+ exports.breg = require('./breg/client');
package/native.js ADDED
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const PACKAGE_VERSION = '0.27.0';
4
+ const PRODUCTS = new Set(['discovery', 'evidence', 'relay', 'breg']);
5
+
6
+ function target() {
7
+ if (process.platform === 'darwin' && process.arch === 'arm64') return 'darwin-arm64';
8
+ if (process.platform === 'linux' && process.arch === 'arm64') return 'linux-arm64-gnu';
9
+ if (process.platform === 'linux' && process.arch === 'x64') return 'linux-x64-gnu';
10
+ throw new Error(`@registrystack/client does not support ${process.platform}-${process.arch}`);
11
+ }
12
+
13
+ function load(product) {
14
+ if (!PRODUCTS.has(product)) throw new Error(`unknown Registry Stack client product: ${product}`);
15
+ const suffix = target();
16
+ const packageName = `@registrystack/client-${suffix}`;
17
+ let bindings;
18
+ try {
19
+ bindings = require(packageName);
20
+ } catch (error) {
21
+ error.message = `Unable to load ${packageName}. Reinstall @registrystack/client for this platform. ${error.message}`;
22
+ throw error;
23
+ }
24
+ const installedVersion = require(`${packageName}/package.json`).version;
25
+ if (installedVersion !== PACKAGE_VERSION) {
26
+ throw new Error(`Native client package version mismatch: expected ${PACKAGE_VERSION}, got ${installedVersion}`);
27
+ }
28
+ if (!Object.hasOwn(bindings, product)) {
29
+ throw new Error(`${packageName} does not contain the ${product} binding`);
30
+ }
31
+ return bindings[product];
32
+ }
33
+
34
+ module.exports = { load };
package/package.json CHANGED
@@ -1,21 +1,49 @@
1
1
  {
2
2
  "name": "@registrystack/client",
3
- "version": "0.0.0",
4
- "description": "Reserved package identity for the unified Registry Stack client.",
3
+ "version": "0.27.0",
4
+ "description": "Unified Node.js client for Registry Stack products.",
5
5
  "license": "Apache-2.0",
6
+ "publishConfig": {
7
+ "access": "public",
8
+ "provenance": true
9
+ },
6
10
  "repository": {
7
11
  "type": "git",
8
- "url": "git+https://github.com/registrystack/registry-stack.git"
12
+ "url": "https://github.com/registrystack/registry-stack"
9
13
  },
10
- "homepage": "https://github.com/registrystack/registry-stack",
11
- "bugs": {
12
- "url": "https://github.com/registrystack/registry-stack/issues"
13
- },
14
- "publishConfig": {
15
- "access": "public"
14
+ "main": "index.js",
15
+ "types": "index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./index.d.ts",
19
+ "default": "./index.js"
20
+ }
16
21
  },
17
22
  "files": [
18
- "README.md",
19
- "LICENSE"
20
- ]
23
+ "index.js",
24
+ "index.d.ts",
25
+ "native.js",
26
+ "discovery",
27
+ "evidence",
28
+ "relay",
29
+ "breg"
30
+ ],
31
+ "engines": {
32
+ "node": ">=22.12.0"
33
+ },
34
+ "scripts": {
35
+ "sync": "python3 ../../release/scripts/sync-registry-client-node.py",
36
+ "sync:check": "python3 ../../release/scripts/sync-registry-client-node.py --check",
37
+ "test": "npm run sync:check && node --test __test__/*.test.js",
38
+ "check:types": "tsc --noEmit --strict --skipLibCheck false --types node --moduleResolution node16 --module node16 --target es2022 index.d.ts __test__/facade.test-d.ts"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "22.20.1",
42
+ "typescript": "6.0.3"
43
+ },
44
+ "optionalDependencies": {
45
+ "@registrystack/client-darwin-arm64": "0.27.0",
46
+ "@registrystack/client-linux-arm64-gnu": "0.27.0",
47
+ "@registrystack/client-linux-x64-gnu": "0.27.0"
48
+ }
21
49
  }