@proof-holdings/sdk 0.0.0-stage → 1.2.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.
- package/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +239 -2
- package/dist/cjs/client.d.ts +48 -0
- package/dist/cjs/client.d.ts.map +1 -0
- package/dist/cjs/client.js +73 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/credentials.d.ts +46 -0
- package/dist/cjs/credentials.d.ts.map +1 -0
- package/dist/cjs/credentials.js +137 -0
- package/dist/cjs/credentials.js.map +1 -0
- package/dist/cjs/crypto/hitl-crypto.d.ts +95 -0
- package/dist/cjs/crypto/hitl-crypto.d.ts.map +1 -0
- package/dist/cjs/crypto/hitl-crypto.js +338 -0
- package/dist/cjs/crypto/hitl-crypto.js.map +1 -0
- package/dist/cjs/errors.d.ts +52 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +121 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/http.d.ts +62 -0
- package/dist/cjs/http.d.ts.map +1 -0
- package/dist/cjs/http.js +192 -0
- package/dist/cjs/http.js.map +1 -0
- package/dist/cjs/index.d.ts +26 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +79 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/jwks/key-set-cache.d.ts +105 -0
- package/dist/cjs/jwks/key-set-cache.d.ts.map +1 -0
- package/dist/cjs/jwks/key-set-cache.js +277 -0
- package/dist/cjs/jwks/key-set-cache.js.map +1 -0
- package/dist/cjs/jwks/keyset.d.ts +139 -0
- package/dist/cjs/jwks/keyset.d.ts.map +1 -0
- package/dist/cjs/jwks/keyset.js +503 -0
- package/dist/cjs/jwks/keyset.js.map +1 -0
- package/dist/cjs/jwks/support.d.ts +9 -0
- package/dist/cjs/jwks/support.d.ts.map +1 -0
- package/dist/cjs/jwks/support.js +12 -0
- package/dist/cjs/jwks/support.js.map +1 -0
- package/dist/cjs/polling.d.ts +10 -0
- package/dist/cjs/polling.d.ts.map +1 -0
- package/dist/cjs/polling.js +74 -0
- package/dist/cjs/polling.js.map +1 -0
- package/dist/cjs/resources/auth-sessions.d.ts +41 -0
- package/dist/cjs/resources/auth-sessions.d.ts.map +1 -0
- package/dist/cjs/resources/auth-sessions.js +34 -0
- package/dist/cjs/resources/auth-sessions.js.map +1 -0
- package/dist/cjs/resources/authorizations.d.ts +23 -0
- package/dist/cjs/resources/authorizations.d.ts.map +1 -0
- package/dist/cjs/resources/authorizations.js +29 -0
- package/dist/cjs/resources/authorizations.js.map +1 -0
- package/dist/cjs/resources/circles.d.ts +38 -0
- package/dist/cjs/resources/circles.d.ts.map +1 -0
- package/dist/cjs/resources/circles.js +67 -0
- package/dist/cjs/resources/circles.js.map +1 -0
- package/dist/cjs/resources/confirmations.d.ts +111 -0
- package/dist/cjs/resources/confirmations.d.ts.map +1 -0
- package/dist/cjs/resources/confirmations.js +86 -0
- package/dist/cjs/resources/confirmations.js.map +1 -0
- package/dist/cjs/resources/delegations.d.ts +36 -0
- package/dist/cjs/resources/delegations.d.ts.map +1 -0
- package/dist/cjs/resources/delegations.js +47 -0
- package/dist/cjs/resources/delegations.js.map +1 -0
- package/dist/cjs/resources/hitl-chat-id.d.ts +42 -0
- package/dist/cjs/resources/hitl-chat-id.d.ts.map +1 -0
- package/dist/cjs/resources/hitl-chat-id.js +37 -0
- package/dist/cjs/resources/hitl-chat-id.js.map +1 -0
- package/dist/cjs/resources/hitl-keys.d.ts +13 -0
- package/dist/cjs/resources/hitl-keys.d.ts.map +1 -0
- package/dist/cjs/resources/hitl-keys.js +22 -0
- package/dist/cjs/resources/hitl-keys.js.map +1 -0
- package/dist/cjs/resources/hitl.d.ts +39 -0
- package/dist/cjs/resources/hitl.d.ts.map +1 -0
- package/dist/cjs/resources/hitl.js +58 -0
- package/dist/cjs/resources/hitl.js.map +1 -0
- package/dist/cjs/resources/me.d.ts +102 -0
- package/dist/cjs/resources/me.d.ts.map +1 -0
- package/dist/cjs/resources/me.js +85 -0
- package/dist/cjs/resources/me.js.map +1 -0
- package/dist/cjs/resources/profiles.d.ts +47 -0
- package/dist/cjs/resources/profiles.d.ts.map +1 -0
- package/dist/cjs/resources/profiles.js +70 -0
- package/dist/cjs/resources/profiles.js.map +1 -0
- package/dist/cjs/resources/proof-me.d.ts +48 -0
- package/dist/cjs/resources/proof-me.d.ts.map +1 -0
- package/dist/cjs/resources/proof-me.js +24 -0
- package/dist/cjs/resources/proof-me.js.map +1 -0
- package/dist/cjs/resources/proofs.d.ts +81 -0
- package/dist/cjs/resources/proofs.d.ts.map +1 -0
- package/dist/cjs/resources/proofs.js +437 -0
- package/dist/cjs/resources/proofs.js.map +1 -0
- package/dist/cjs/resources/public-profiles.d.ts +36 -0
- package/dist/cjs/resources/public-profiles.d.ts.map +1 -0
- package/dist/cjs/resources/public-profiles.js +49 -0
- package/dist/cjs/resources/public-profiles.js.map +1 -0
- package/dist/cjs/resources/sessions.d.ts +15 -0
- package/dist/cjs/resources/sessions.d.ts.map +1 -0
- package/dist/cjs/resources/sessions.js +26 -0
- package/dist/cjs/resources/sessions.js.map +1 -0
- package/dist/cjs/resources/templates.d.ts +25 -0
- package/dist/cjs/resources/templates.d.ts.map +1 -0
- package/dist/cjs/resources/templates.js +46 -0
- package/dist/cjs/resources/templates.js.map +1 -0
- package/dist/cjs/resources/verification-requests.d.ts +56 -0
- package/dist/cjs/resources/verification-requests.d.ts.map +1 -0
- package/dist/cjs/resources/verification-requests.js +61 -0
- package/dist/cjs/resources/verification-requests.js.map +1 -0
- package/dist/cjs/resources/verifications.d.ts +60 -0
- package/dist/cjs/resources/verifications.d.ts.map +1 -0
- package/dist/cjs/resources/verifications.js +91 -0
- package/dist/cjs/resources/verifications.js.map +1 -0
- package/dist/cjs/resources/webhook-deliveries.d.ts +15 -0
- package/dist/cjs/resources/webhook-deliveries.d.ts.map +1 -0
- package/dist/cjs/resources/webhook-deliveries.js +26 -0
- package/dist/cjs/resources/webhook-deliveries.js.map +1 -0
- package/dist/cjs/streaming.d.ts +87 -0
- package/dist/cjs/streaming.d.ts.map +1 -0
- package/dist/cjs/streaming.js +289 -0
- package/dist/cjs/streaming.js.map +1 -0
- package/dist/cjs/types.d.ts +1483 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +6 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.d.ts.map +1 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/client.d.ts +48 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +69 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/credentials.d.ts +46 -0
- package/dist/esm/credentials.d.ts.map +1 -0
- package/dist/esm/credentials.js +127 -0
- package/dist/esm/credentials.js.map +1 -0
- package/dist/esm/crypto/hitl-crypto.d.ts +95 -0
- package/dist/esm/crypto/hitl-crypto.d.ts.map +1 -0
- package/dist/esm/crypto/hitl-crypto.js +321 -0
- package/dist/esm/crypto/hitl-crypto.js.map +1 -0
- package/dist/esm/errors.d.ts +52 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +106 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/http.d.ts +62 -0
- package/dist/esm/http.d.ts.map +1 -0
- package/dist/esm/http.js +187 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.d.ts +26 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/jwks/key-set-cache.d.ts +105 -0
- package/dist/esm/jwks/key-set-cache.d.ts.map +1 -0
- package/dist/esm/jwks/key-set-cache.js +268 -0
- package/dist/esm/jwks/key-set-cache.js.map +1 -0
- package/dist/esm/jwks/keyset.d.ts +139 -0
- package/dist/esm/jwks/keyset.d.ts.map +1 -0
- package/dist/esm/jwks/keyset.js +489 -0
- package/dist/esm/jwks/keyset.js.map +1 -0
- package/dist/esm/jwks/support.d.ts +9 -0
- package/dist/esm/jwks/support.d.ts.map +1 -0
- package/dist/esm/jwks/support.js +9 -0
- package/dist/esm/jwks/support.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/polling.d.ts +10 -0
- package/dist/esm/polling.d.ts.map +1 -0
- package/dist/esm/polling.js +71 -0
- package/dist/esm/polling.js.map +1 -0
- package/dist/esm/resources/auth-sessions.d.ts +41 -0
- package/dist/esm/resources/auth-sessions.d.ts.map +1 -0
- package/dist/esm/resources/auth-sessions.js +30 -0
- package/dist/esm/resources/auth-sessions.js.map +1 -0
- package/dist/esm/resources/authorizations.d.ts +23 -0
- package/dist/esm/resources/authorizations.d.ts.map +1 -0
- package/dist/esm/resources/authorizations.js +25 -0
- package/dist/esm/resources/authorizations.js.map +1 -0
- package/dist/esm/resources/circles.d.ts +38 -0
- package/dist/esm/resources/circles.d.ts.map +1 -0
- package/dist/esm/resources/circles.js +63 -0
- package/dist/esm/resources/circles.js.map +1 -0
- package/dist/esm/resources/confirmations.d.ts +111 -0
- package/dist/esm/resources/confirmations.d.ts.map +1 -0
- package/dist/esm/resources/confirmations.js +82 -0
- package/dist/esm/resources/confirmations.js.map +1 -0
- package/dist/esm/resources/delegations.d.ts +36 -0
- package/dist/esm/resources/delegations.d.ts.map +1 -0
- package/dist/esm/resources/delegations.js +43 -0
- package/dist/esm/resources/delegations.js.map +1 -0
- package/dist/esm/resources/hitl-chat-id.d.ts +42 -0
- package/dist/esm/resources/hitl-chat-id.d.ts.map +1 -0
- package/dist/esm/resources/hitl-chat-id.js +33 -0
- package/dist/esm/resources/hitl-chat-id.js.map +1 -0
- package/dist/esm/resources/hitl-keys.d.ts +13 -0
- package/dist/esm/resources/hitl-keys.d.ts.map +1 -0
- package/dist/esm/resources/hitl-keys.js +18 -0
- package/dist/esm/resources/hitl-keys.js.map +1 -0
- package/dist/esm/resources/hitl.d.ts +39 -0
- package/dist/esm/resources/hitl.d.ts.map +1 -0
- package/dist/esm/resources/hitl.js +54 -0
- package/dist/esm/resources/hitl.js.map +1 -0
- package/dist/esm/resources/me.d.ts +102 -0
- package/dist/esm/resources/me.d.ts.map +1 -0
- package/dist/esm/resources/me.js +81 -0
- package/dist/esm/resources/me.js.map +1 -0
- package/dist/esm/resources/profiles.d.ts +47 -0
- package/dist/esm/resources/profiles.d.ts.map +1 -0
- package/dist/esm/resources/profiles.js +66 -0
- package/dist/esm/resources/profiles.js.map +1 -0
- package/dist/esm/resources/proof-me.d.ts +48 -0
- package/dist/esm/resources/proof-me.d.ts.map +1 -0
- package/dist/esm/resources/proof-me.js +20 -0
- package/dist/esm/resources/proof-me.js.map +1 -0
- package/dist/esm/resources/proofs.d.ts +81 -0
- package/dist/esm/resources/proofs.d.ts.map +1 -0
- package/dist/esm/resources/proofs.js +433 -0
- package/dist/esm/resources/proofs.js.map +1 -0
- package/dist/esm/resources/public-profiles.d.ts +36 -0
- package/dist/esm/resources/public-profiles.d.ts.map +1 -0
- package/dist/esm/resources/public-profiles.js +45 -0
- package/dist/esm/resources/public-profiles.js.map +1 -0
- package/dist/esm/resources/sessions.d.ts +15 -0
- package/dist/esm/resources/sessions.d.ts.map +1 -0
- package/dist/esm/resources/sessions.js +22 -0
- package/dist/esm/resources/sessions.js.map +1 -0
- package/dist/esm/resources/templates.d.ts +25 -0
- package/dist/esm/resources/templates.d.ts.map +1 -0
- package/dist/esm/resources/templates.js +42 -0
- package/dist/esm/resources/templates.js.map +1 -0
- package/dist/esm/resources/verification-requests.d.ts +56 -0
- package/dist/esm/resources/verification-requests.d.ts.map +1 -0
- package/dist/esm/resources/verification-requests.js +57 -0
- package/dist/esm/resources/verification-requests.js.map +1 -0
- package/dist/esm/resources/verifications.d.ts +60 -0
- package/dist/esm/resources/verifications.d.ts.map +1 -0
- package/dist/esm/resources/verifications.js +87 -0
- package/dist/esm/resources/verifications.js.map +1 -0
- package/dist/esm/resources/webhook-deliveries.d.ts +15 -0
- package/dist/esm/resources/webhook-deliveries.d.ts.map +1 -0
- package/dist/esm/resources/webhook-deliveries.js +22 -0
- package/dist/esm/resources/webhook-deliveries.js.map +1 -0
- package/dist/esm/streaming.d.ts +87 -0
- package/dist/esm/streaming.d.ts.map +1 -0
- package/dist/esm/streaming.js +286 -0
- package/dist/esm/streaming.js.map +1 -0
- package/dist/esm/types.d.ts +1483 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +64 -4
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface HttpClientConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
timeout: number;
|
|
5
|
+
maxRetries: number;
|
|
6
|
+
fetch: typeof globalThis.fetch;
|
|
7
|
+
}
|
|
8
|
+
type QueryValue = string | number | boolean | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Read a response body, giving up one byte past `limit`.
|
|
11
|
+
*
|
|
12
|
+
* `response.text()` would buffer the WHOLE body and measure afterwards, which is not a ceiling
|
|
13
|
+
* at all for a reply that declares no length: a multi-gigabyte answer is fully in memory before
|
|
14
|
+
* anything refuses it. Returns null when the body is over the limit.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readCapped(response: Response, limit: number): Promise<string | null>;
|
|
17
|
+
export declare class HttpClient {
|
|
18
|
+
readonly baseUrl: string;
|
|
19
|
+
private readonly apiKey;
|
|
20
|
+
private readonly timeout;
|
|
21
|
+
private readonly maxRetries;
|
|
22
|
+
private readonly _fetch;
|
|
23
|
+
constructor(config: HttpClientConfig);
|
|
24
|
+
request<T>(method: string, path: string, options?: {
|
|
25
|
+
body?: unknown;
|
|
26
|
+
query?: Record<string, QueryValue>;
|
|
27
|
+
}): Promise<T>;
|
|
28
|
+
get<T>(path: string, query?: Record<string, QueryValue>): Promise<T>;
|
|
29
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
30
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
31
|
+
del<T>(path: string): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Raw fetch with auth + user-agent headers applied. Used for SSE streaming
|
|
34
|
+
* and other non-JSON responses. Does NOT retry, does NOT parse body, does
|
|
35
|
+
* NOT apply the default request timeout — the caller owns lifecycle via
|
|
36
|
+
* AbortSignal.
|
|
37
|
+
*/
|
|
38
|
+
rawFetch(path: string, options?: {
|
|
39
|
+
headers?: Record<string, string>;
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
query?: Record<string, QueryValue>;
|
|
42
|
+
}): Promise<Response>;
|
|
43
|
+
/**
|
|
44
|
+
* Fetch a PUBLIC artifact by absolute url through the configured transport — no API key, no
|
|
45
|
+
* retries, redirects refused.
|
|
46
|
+
*
|
|
47
|
+
* The key is left off deliberately rather than forgotten: the issuer's status list is a shared
|
|
48
|
+
* document whose whole point is that reading it says nothing about WHICH proof is being checked
|
|
49
|
+
* (`docs/api-map.yaml`, the status-list endpoint is public). Sending a credential with it would
|
|
50
|
+
* hand the issuer the one fact the design withholds. Redirects are refused because the caller
|
|
51
|
+
* has already decided the url's origin is trusted, and a redirect would move it.
|
|
52
|
+
*/
|
|
53
|
+
fetchPublic(url: string, options: {
|
|
54
|
+
timeoutMs: number;
|
|
55
|
+
headers?: Record<string, string>;
|
|
56
|
+
}): Promise<Response>;
|
|
57
|
+
private buildUrl;
|
|
58
|
+
private backoff;
|
|
59
|
+
private sleep;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBA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AC;IAIhD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhC;;;;;OAKG;IACH,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;KAAO,GAC3G,OAAO,CAAC,QAAQ,CAAC;IAUpB;;;;;;;;;OASG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IAY7G,OAAO,CAAC,QAAQ;IAYhB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,KAAK;CAGd"}
|
package/dist/cjs/http.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClient = void 0;
|
|
4
|
+
exports.readCapped = readCapped;
|
|
5
|
+
const errors_js_1 = require("./errors.js");
|
|
6
|
+
const version_js_1 = require("./version.js");
|
|
7
|
+
/**
|
|
8
|
+
* Read a response body, giving up one byte past `limit`.
|
|
9
|
+
*
|
|
10
|
+
* `response.text()` would buffer the WHOLE body and measure afterwards, which is not a ceiling
|
|
11
|
+
* at all for a reply that declares no length: a multi-gigabyte answer is fully in memory before
|
|
12
|
+
* anything refuses it. Returns null when the body is over the limit.
|
|
13
|
+
*/
|
|
14
|
+
async function readCapped(response, limit) {
|
|
15
|
+
const body = response.body;
|
|
16
|
+
if (!body) {
|
|
17
|
+
// No streamable body (a mocked or already-buffered response): fall back to reading it whole,
|
|
18
|
+
// which is still bounded by whatever produced it. Measured in BYTES, like the streamed path
|
|
19
|
+
// and like the ceiling itself — `text.length` counts UTF-16 units, which is a different
|
|
20
|
+
// number for any non-ASCII body.
|
|
21
|
+
const text = await response.text();
|
|
22
|
+
return new TextEncoder().encode(text).byteLength > limit ? null : text;
|
|
23
|
+
}
|
|
24
|
+
const reader = body.getReader();
|
|
25
|
+
const decoder = new TextDecoder();
|
|
26
|
+
let read = 0;
|
|
27
|
+
let out = '';
|
|
28
|
+
try {
|
|
29
|
+
for (;;) {
|
|
30
|
+
const { done, value } = await reader.read();
|
|
31
|
+
if (done)
|
|
32
|
+
break;
|
|
33
|
+
read += value.byteLength;
|
|
34
|
+
if (read > limit)
|
|
35
|
+
return null;
|
|
36
|
+
out += decoder.decode(value, { stream: true });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
await reader.cancel().catch(() => undefined);
|
|
41
|
+
}
|
|
42
|
+
return out + decoder.decode();
|
|
43
|
+
}
|
|
44
|
+
class HttpClient {
|
|
45
|
+
constructor(config) {
|
|
46
|
+
this.apiKey = config.apiKey;
|
|
47
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
48
|
+
this.timeout = config.timeout;
|
|
49
|
+
this.maxRetries = config.maxRetries;
|
|
50
|
+
this._fetch = config.fetch;
|
|
51
|
+
}
|
|
52
|
+
async request(method, path, options) {
|
|
53
|
+
const url = this.buildUrl(path, options?.query);
|
|
54
|
+
let lastError;
|
|
55
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
56
|
+
const controller = new AbortController();
|
|
57
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
58
|
+
try {
|
|
59
|
+
const response = await this._fetch(url, {
|
|
60
|
+
method,
|
|
61
|
+
headers: {
|
|
62
|
+
'Content-Type': 'application/json',
|
|
63
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
64
|
+
'User-Agent': `proof-sdk-js/${version_js_1.VERSION}`,
|
|
65
|
+
},
|
|
66
|
+
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
67
|
+
signal: controller.signal,
|
|
68
|
+
});
|
|
69
|
+
clearTimeout(timeoutId);
|
|
70
|
+
// Rate limiting — retry with backoff
|
|
71
|
+
if (response.status === 429 && attempt < this.maxRetries) {
|
|
72
|
+
const retryAfter = response.headers.get('Retry-After');
|
|
73
|
+
const delay = retryAfter ? parseInt(retryAfter, 10) * 1000 : this.backoff(attempt);
|
|
74
|
+
await this.sleep(delay);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// Server errors — retry with backoff
|
|
78
|
+
if (response.status >= 500 && attempt < this.maxRetries) {
|
|
79
|
+
await this.sleep(this.backoff(attempt));
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
// Non-JSON success (e.g. avatar images): return a {data, content_type}
|
|
83
|
+
// envelope instead of attempting a JSON parse. Only when the server
|
|
84
|
+
// EXPLICITLY declares a non-JSON content type — responses without a
|
|
85
|
+
// Content-Type header keep the legacy JSON-parse path.
|
|
86
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
87
|
+
if (response.ok && contentType !== '' && !contentType.includes('application/json')) {
|
|
88
|
+
const buf = await response.arrayBuffer();
|
|
89
|
+
if (buf.byteLength > 0) {
|
|
90
|
+
return { data: new Uint8Array(buf), content_type: contentType };
|
|
91
|
+
}
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
// Parse response body
|
|
95
|
+
const body = (await response.json().catch(() => ({})));
|
|
96
|
+
// Error responses
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
const apiError = body.error;
|
|
99
|
+
throw errors_js_1.ProofError.fromResponse(response.status, apiError);
|
|
100
|
+
}
|
|
101
|
+
return body;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
clearTimeout(timeoutId);
|
|
105
|
+
if (error instanceof errors_js_1.ProofError)
|
|
106
|
+
throw error;
|
|
107
|
+
lastError = error;
|
|
108
|
+
// Abort = timeout
|
|
109
|
+
if (lastError.name === 'AbortError') {
|
|
110
|
+
if (attempt < this.maxRetries) {
|
|
111
|
+
await this.sleep(this.backoff(attempt));
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
throw new errors_js_1.TimeoutError(`Request to ${method} ${path} timed out after ${this.timeout}ms`);
|
|
115
|
+
}
|
|
116
|
+
// Network errors — retry
|
|
117
|
+
if (attempt < this.maxRetries) {
|
|
118
|
+
await this.sleep(this.backoff(attempt));
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
throw new errors_js_1.NetworkError(lastError?.message ?? 'Network request failed');
|
|
124
|
+
}
|
|
125
|
+
get(path, query) {
|
|
126
|
+
return this.request('GET', path, { query });
|
|
127
|
+
}
|
|
128
|
+
post(path, body) {
|
|
129
|
+
return this.request('POST', path, { body });
|
|
130
|
+
}
|
|
131
|
+
put(path, body) {
|
|
132
|
+
return this.request('PUT', path, { body });
|
|
133
|
+
}
|
|
134
|
+
del(path) {
|
|
135
|
+
return this.request('DELETE', path);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Raw fetch with auth + user-agent headers applied. Used for SSE streaming
|
|
139
|
+
* and other non-JSON responses. Does NOT retry, does NOT parse body, does
|
|
140
|
+
* NOT apply the default request timeout — the caller owns lifecycle via
|
|
141
|
+
* AbortSignal.
|
|
142
|
+
*/
|
|
143
|
+
rawFetch(path, options = {}) {
|
|
144
|
+
const url = this.buildUrl(path, options.query);
|
|
145
|
+
const headers = {
|
|
146
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
147
|
+
'User-Agent': `proof-sdk-js/${version_js_1.VERSION}`,
|
|
148
|
+
...(options.headers ?? {}),
|
|
149
|
+
};
|
|
150
|
+
return this._fetch(url, { method: 'GET', headers, signal: options.signal });
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Fetch a PUBLIC artifact by absolute url through the configured transport — no API key, no
|
|
154
|
+
* retries, redirects refused.
|
|
155
|
+
*
|
|
156
|
+
* The key is left off deliberately rather than forgotten: the issuer's status list is a shared
|
|
157
|
+
* document whose whole point is that reading it says nothing about WHICH proof is being checked
|
|
158
|
+
* (`docs/api-map.yaml`, the status-list endpoint is public). Sending a credential with it would
|
|
159
|
+
* hand the issuer the one fact the design withholds. Redirects are refused because the caller
|
|
160
|
+
* has already decided the url's origin is trusted, and a redirect would move it.
|
|
161
|
+
*/
|
|
162
|
+
fetchPublic(url, options) {
|
|
163
|
+
return this._fetch(url, {
|
|
164
|
+
method: 'GET',
|
|
165
|
+
headers: {
|
|
166
|
+
'User-Agent': `proof-sdk-js/${version_js_1.VERSION}`,
|
|
167
|
+
...(options.headers ?? {}),
|
|
168
|
+
},
|
|
169
|
+
redirect: 'error',
|
|
170
|
+
signal: AbortSignal.timeout(options.timeoutMs),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
buildUrl(path, query) {
|
|
174
|
+
const url = new URL(path, this.baseUrl);
|
|
175
|
+
if (query) {
|
|
176
|
+
for (const [key, value] of Object.entries(query)) {
|
|
177
|
+
if (value !== undefined) {
|
|
178
|
+
url.searchParams.set(key, String(value));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return url.toString();
|
|
183
|
+
}
|
|
184
|
+
backoff(attempt) {
|
|
185
|
+
return Math.min(1000 * Math.pow(2, attempt), 10000);
|
|
186
|
+
}
|
|
187
|
+
sleep(ms) {
|
|
188
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.HttpClient = HttpClient;
|
|
192
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":";;;AAqBA,gCA2BC;AAhDD,2CAAqE;AAErE,6CAAuC;AAYvC;;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EO,QAAQ,CAAC,IAAY,EAAE,KAAkC;QAC/D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACxB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAEO,OAAO,CAAC,OAAe;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAzLD,gCAyLC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { Proof } from './client.js';
|
|
2
|
+
export { VERSION } from './version.js';
|
|
3
|
+
export { resolveApiKey, resolveBaseUrl, credentialKey, defaultCredentialsPath, LOGIN_COMMAND, } from './credentials.js';
|
|
4
|
+
export type { ResolvedKey, KeySource } from './credentials.js';
|
|
5
|
+
export { streamEndpoint, type SSEEvent, type StreamEvent, type StreamOptions, type StreamConfig, } from './streaming.js';
|
|
6
|
+
export { AuthSessions, type AuthSession, type AuthSessionStreamConnected, type AuthSessionStreamUpdate, type AuthSessionStreamEvent, } from './resources/auth-sessions.js';
|
|
7
|
+
export { Me, type PhoneAddSession, type PhoneAddSessionStreamConnected, type PhoneAddSessionStreamUpdate, type PhoneAddSessionStreamEvent, type EmailAddSession, type EmailAddSessionStreamConnected, type EmailAddSessionStreamUpdate, type EmailAddSessionStreamEvent, type TwoFASession, type TwoFASessionStreamConnected, type TwoFASessionStreamUpdate, type TwoFASessionStreamEvent, } from './resources/me.js';
|
|
8
|
+
export { HitlChatIdDiscovery, type ChatIdDiscovery, type ChatIdDiscoveryStreamConnected, type ChatIdDiscoveryStreamUpdate, type ChatIdDiscoveryStreamEvent, } from './resources/hitl-chat-id.js';
|
|
9
|
+
export type { ConfirmationStreamConnected, ConfirmationStreamUpdate, ConfirmationStreamEvent, } from './resources/confirmations.js';
|
|
10
|
+
export type { VerificationStreamConnected, VerificationStreamUpdate, VerificationStreamEvent, } from './resources/verifications.js';
|
|
11
|
+
export { Authorizations } from './resources/authorizations.js';
|
|
12
|
+
export type { VerificationRequestAssetStatus, VerificationRequestAssetStreamConnected, VerificationRequestAssetStreamUpdate, VerificationRequestAssetStreamEvent, } from './resources/verification-requests.js';
|
|
13
|
+
export { Hitl } from './resources/hitl.js';
|
|
14
|
+
export { Templates } from './resources/templates.js';
|
|
15
|
+
export { Profiles } from './resources/profiles.js';
|
|
16
|
+
export { PublicProfiles } from './resources/public-profiles.js';
|
|
17
|
+
export { ProofMe } from './resources/proof-me.js';
|
|
18
|
+
export type { ProofMeChannel, CreateIdentityChallengeParams, IdentityChallenge, IdentityChallengeStatus, } from './resources/proof-me.js';
|
|
19
|
+
export { Circles } from './resources/circles.js';
|
|
20
|
+
export { Delegations } from './resources/delegations.js';
|
|
21
|
+
export { ProofError, ValidationError, AuthenticationError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, NetworkError, TimeoutError, PollingTimeoutError, ConfirmationDeniedError, } from './errors.js';
|
|
22
|
+
export type { VerificationType, VerificationChannel, VerificationStatus, SessionChannel, SessionSmsNumber, VerificationRequestStatus, ActionType, ApiError, Pagination, PaginatedList, ChallengeInstructions, ProofToken, Verification, CreateVerificationParams, ListVerificationsParams, ResendResponse, TestVerifyResponse, StartDomainVerificationParams, DomainVerification, DomainCheckResponse, VerifiedUserVerification, VerifiedUser, ListVerifiedUsersParams, MultiChannelPhoneChannel, CreateMultiChannelVerificationParams, MultiChannelChannelBlock, MultiChannelVerificationResponse, MultiChannelGroupStatusResponse, RequestedAsset, VerificationRequestAsset, VerificationRequest, VerificationRequestListItem, CancelVerificationRequestResponse, CreateVerificationRequestParams, ListVerificationRequestsParams, ProofStatus, ProofValidation, RevokedProof, RevocationList, RevokeResponse, OfflineVerificationResult, OfflineVerificationOptions, OfflineFailureReason, OfflinePullHint, Session, CreateSessionParams, WebhookDelivery, WebhookRetryResponse, WebhookDeliveryList, WebhookDeliveryStats, WebhookPagination, ListWebhookDeliveriesParams, HitlStatus, HitlChannel, HitlConfig, CreateHitlParams, UpdateHitlParams, HitlListParams, HitlListResponse, HitlAuthorizationResult, HitlAuthorizationResponse, HitlFinalizeResponse, ChatIdDiscoveryCreateResponse, ApprovalLinkResponse, VerificationRequestProof, VerificationRequestProofsResponse, CircleStatus, CircleMemberStatus, CircleMemberChannelType, CircleMemberChannelStatus, CircleMember, Circle, CircleListResponse, CircleMemberInput, CreateCircleParams, UpdateCircleParams, CircleListParams, CircleMemberListResponse, CreateCircleMemberParams, CircleMemberInviteResponse, CircleMemberDrillResponse, AddCircleMemberChannelParams, CircleMemberChannel, CircleMemberChannelListResponse, DelegateIdentifierType, DelegationStatus, DelegationEffectiveStatus, RevokeDelegationReason, DelegateIdentifier, Delegation, DelegationWithToken, DelegationDetail, CreateDelegationParams, DelegationListParams, DelegationListResponse, RevokeDelegationParams, HitlKeysResponse, HitlKeysPutParams, HitlKeysPutResponse, HitlKeysDeleteResponse, HitlApproverKey, HitlApproverKeysResponse, Authorization, UpdateAuthorizationBody, CreateAuthorizationParams, AuthorizationListParams, AuthorizationListResponse, CreateAuthorizationResponse, AuthorizationExportParams, AuthorizationExportResponse, TemplateChannel, TemplateMessageType, TemplateContent, TemplateProjectOptions, Template, TemplateVariable, TemplateListResponse, TemplateDefaultsResponse, TemplateGetResponse, TemplateUpsertResponse, TemplateDeleteResponse, RenderedTemplate, TemplatePreviewParams, TemplatePreviewResponse, TemplateRenderParams, TemplateRenderResponse, ProfileTheme, CustomLink, Profile, CreateProfileParams, UpdateProfileParams, ProfileListResponse, ProfileDeleteResponse, ProfileTemplate, ProfileTemplateListResponse, ProfileTemplateUpdateParams, ProfileTemplatePreviewParams, ProfileTemplatePreviewResponse, PublicProfileProof, PublicProfileLink, PublicProfileView, PublicProfileDelegation, UsernameAvailabilityResponse, BinaryResponse, AvatarResponse, ComputedState, MeEnvironmentParams, MeSearchBucket, MeSearchParams, MeSearchResults, PlatformSummary, ApiKeyMetadata, ApiKeyUsage, WebhookEventType, ProofOptions, WaitOptions, ConfirmAndWaitOptions, } from './types.js';
|
|
23
|
+
export { computeKid, generateKeyPair, generateEncryptionKeyPair, deriveKey, encryptMessage, encryptMessageV2, decryptMessage, encryptPrivateKey, decryptPrivateKey, validateMessageEnvelope, validatePrivateKeyEnvelope, } from './crypto/hitl-crypto.js';
|
|
24
|
+
export type { CiphertextEnvelope, CiphertextEnvelopeV1, CiphertextEnvelopeV2, EncryptedPrivateKey, HitlKeyPair, } from './crypto/hitl-crypto.js';
|
|
25
|
+
export { Proof as default } from './client.js';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,sBAAsB,EACtB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EACL,cAAc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Ac,EACd,WAAW,EAGX,gBAAgB,EAGhB,YAAY,EACZ,WAAW,EACX,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,eAAe,EACf,yBAAyB,EACzB,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = exports.validatePrivateKeyEnvelope = exports.validateMessageEnvelope = exports.decryptPrivateKey = exports.encryptPrivateKey = exports.decryptMessage = exports.encryptMessageV2 = exports.encryptMessage = exports.deriveKey = exports.generateEncryptionKeyPair = exports.generateKeyPair = exports.computeKid = exports.ConfirmationDeniedError = exports.PollingTimeoutError = exports.TimeoutError = exports.NetworkError = exports.ServerError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.AuthenticationError = exports.ValidationError = exports.ProofError = exports.Delegations = exports.Circles = exports.ProofMe = exports.PublicProfiles = exports.Profiles = exports.Templates = exports.Hitl = exports.Authorizations = exports.HitlChatIdDiscovery = exports.Me = exports.AuthSessions = exports.streamEndpoint = exports.LOGIN_COMMAND = exports.defaultCredentialsPath = exports.credentialKey = exports.resolveBaseUrl = exports.resolveApiKey = exports.VERSION = exports.Proof = void 0;
|
|
4
|
+
var client_js_1 = require("./client.js");
|
|
5
|
+
Object.defineProperty(exports, "Proof", { enumerable: true, get: function () { return client_js_1.Proof; } });
|
|
6
|
+
var version_js_1 = require("./version.js");
|
|
7
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_js_1.VERSION; } });
|
|
8
|
+
// Key and base-URL resolution (what `new Proof()` with no key runs)
|
|
9
|
+
var credentials_js_1 = require("./credentials.js");
|
|
10
|
+
Object.defineProperty(exports, "resolveApiKey", { enumerable: true, get: function () { return credentials_js_1.resolveApiKey; } });
|
|
11
|
+
Object.defineProperty(exports, "resolveBaseUrl", { enumerable: true, get: function () { return credentials_js_1.resolveBaseUrl; } });
|
|
12
|
+
Object.defineProperty(exports, "credentialKey", { enumerable: true, get: function () { return credentials_js_1.credentialKey; } });
|
|
13
|
+
Object.defineProperty(exports, "defaultCredentialsPath", { enumerable: true, get: function () { return credentials_js_1.defaultCredentialsPath; } });
|
|
14
|
+
Object.defineProperty(exports, "LOGIN_COMMAND", { enumerable: true, get: function () { return credentials_js_1.LOGIN_COMMAND; } });
|
|
15
|
+
// Streaming helpers
|
|
16
|
+
var streaming_js_1 = require("./streaming.js");
|
|
17
|
+
Object.defineProperty(exports, "streamEndpoint", { enumerable: true, get: function () { return streaming_js_1.streamEndpoint; } });
|
|
18
|
+
// Resource classes and types for streaming endpoints
|
|
19
|
+
var auth_sessions_js_1 = require("./resources/auth-sessions.js");
|
|
20
|
+
Object.defineProperty(exports, "AuthSessions", { enumerable: true, get: function () { return auth_sessions_js_1.AuthSessions; } });
|
|
21
|
+
var me_js_1 = require("./resources/me.js");
|
|
22
|
+
Object.defineProperty(exports, "Me", { enumerable: true, get: function () { return me_js_1.Me; } });
|
|
23
|
+
var hitl_chat_id_js_1 = require("./resources/hitl-chat-id.js");
|
|
24
|
+
Object.defineProperty(exports, "HitlChatIdDiscovery", { enumerable: true, get: function () { return hitl_chat_id_js_1.HitlChatIdDiscovery; } });
|
|
25
|
+
// Authorization consent resource
|
|
26
|
+
var authorizations_js_1 = require("./resources/authorizations.js");
|
|
27
|
+
Object.defineProperty(exports, "Authorizations", { enumerable: true, get: function () { return authorizations_js_1.Authorizations; } });
|
|
28
|
+
// HITL config resource
|
|
29
|
+
var hitl_js_1 = require("./resources/hitl.js");
|
|
30
|
+
Object.defineProperty(exports, "Hitl", { enumerable: true, get: function () { return hitl_js_1.Hitl; } });
|
|
31
|
+
// Message templates resource
|
|
32
|
+
var templates_js_1 = require("./resources/templates.js");
|
|
33
|
+
Object.defineProperty(exports, "Templates", { enumerable: true, get: function () { return templates_js_1.Templates; } });
|
|
34
|
+
// Profiles resource
|
|
35
|
+
var profiles_js_1 = require("./resources/profiles.js");
|
|
36
|
+
Object.defineProperty(exports, "Profiles", { enumerable: true, get: function () { return profiles_js_1.Profiles; } });
|
|
37
|
+
// Public profiles resource
|
|
38
|
+
var public_profiles_js_1 = require("./resources/public-profiles.js");
|
|
39
|
+
Object.defineProperty(exports, "PublicProfiles", { enumerable: true, get: function () { return public_profiles_js_1.PublicProfiles; } });
|
|
40
|
+
// Proof-Me resource (anti-impersonation challengers + identity challenges + drills)
|
|
41
|
+
var proof_me_js_1 = require("./resources/proof-me.js");
|
|
42
|
+
Object.defineProperty(exports, "ProofMe", { enumerable: true, get: function () { return proof_me_js_1.ProofMe; } });
|
|
43
|
+
// Circles resource (people-primitive: members + member channels)
|
|
44
|
+
var circles_js_1 = require("./resources/circles.js");
|
|
45
|
+
Object.defineProperty(exports, "Circles", { enumerable: true, get: function () { return circles_js_1.Circles; } });
|
|
46
|
+
// Delegations resource (Proof of Delegation: domain → typed artifact)
|
|
47
|
+
var delegations_js_1 = require("./resources/delegations.js");
|
|
48
|
+
Object.defineProperty(exports, "Delegations", { enumerable: true, get: function () { return delegations_js_1.Delegations; } });
|
|
49
|
+
// Error classes
|
|
50
|
+
var errors_js_1 = require("./errors.js");
|
|
51
|
+
Object.defineProperty(exports, "ProofError", { enumerable: true, get: function () { return errors_js_1.ProofError; } });
|
|
52
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_js_1.ValidationError; } });
|
|
53
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_js_1.AuthenticationError; } });
|
|
54
|
+
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return errors_js_1.ForbiddenError; } });
|
|
55
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_js_1.NotFoundError; } });
|
|
56
|
+
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return errors_js_1.ConflictError; } });
|
|
57
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_js_1.RateLimitError; } });
|
|
58
|
+
Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return errors_js_1.ServerError; } });
|
|
59
|
+
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return errors_js_1.NetworkError; } });
|
|
60
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_js_1.TimeoutError; } });
|
|
61
|
+
Object.defineProperty(exports, "PollingTimeoutError", { enumerable: true, get: function () { return errors_js_1.PollingTimeoutError; } });
|
|
62
|
+
Object.defineProperty(exports, "ConfirmationDeniedError", { enumerable: true, get: function () { return errors_js_1.ConfirmationDeniedError; } });
|
|
63
|
+
// HITL E2E encryption crypto helpers
|
|
64
|
+
var hitl_crypto_js_1 = require("./crypto/hitl-crypto.js");
|
|
65
|
+
Object.defineProperty(exports, "computeKid", { enumerable: true, get: function () { return hitl_crypto_js_1.computeKid; } });
|
|
66
|
+
Object.defineProperty(exports, "generateKeyPair", { enumerable: true, get: function () { return hitl_crypto_js_1.generateKeyPair; } });
|
|
67
|
+
Object.defineProperty(exports, "generateEncryptionKeyPair", { enumerable: true, get: function () { return hitl_crypto_js_1.generateEncryptionKeyPair; } });
|
|
68
|
+
Object.defineProperty(exports, "deriveKey", { enumerable: true, get: function () { return hitl_crypto_js_1.deriveKey; } });
|
|
69
|
+
Object.defineProperty(exports, "encryptMessage", { enumerable: true, get: function () { return hitl_crypto_js_1.encryptMessage; } });
|
|
70
|
+
Object.defineProperty(exports, "encryptMessageV2", { enumerable: true, get: function () { return hitl_crypto_js_1.encryptMessageV2; } });
|
|
71
|
+
Object.defineProperty(exports, "decryptMessage", { enumerable: true, get: function () { return hitl_crypto_js_1.decryptMessage; } });
|
|
72
|
+
Object.defineProperty(exports, "encryptPrivateKey", { enumerable: true, get: function () { return hitl_crypto_js_1.encryptPrivateKey; } });
|
|
73
|
+
Object.defineProperty(exports, "decryptPrivateKey", { enumerable: true, get: function () { return hitl_crypto_js_1.decryptPrivateKey; } });
|
|
74
|
+
Object.defineProperty(exports, "validateMessageEnvelope", { enumerable: true, get: function () { return hitl_crypto_js_1.validateMessageEnvelope; } });
|
|
75
|
+
Object.defineProperty(exports, "validatePrivateKeyEnvelope", { enumerable: true, get: function () { return hitl_crypto_js_1.validatePrivateKeyEnvelope; } });
|
|
76
|
+
// Default export for convenience: import Proof from '@proof-holdings/sdk'
|
|
77
|
+
var client_js_2 = require("./client.js");
|
|
78
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_js_2.Proof; } });
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAA3B,kGAAA,KAAK,OAAA;AACd,2CAAuC;AAA9B,qGAAA,OAAO,OAAA;AAEhB,oEAAoE;AACpE,mDAM0B;AALxB,+GAAA,aAAa,OAAA;AACb,gHAAA,cAAc,OAAA;AACd,+GAAA,aAAa,OAAA;AACb,wHAAA,sBAAsB,OAAA;AACtB,+GAAA,aAAa,OAAA;AAIf,oBAAoB;AACpB,+CAMwB;AALtB,8GAAA,cAAc,OAAA;AAOhB,qDAAqD;AACrD,iEAMsC;AALpC,gHAAA,YAAY,OAAA;AAMd,2CAc2B;AAbzB,2FAAA,EAAE,OAAA;AAcJ,+DAMqC;AALnC,sHAAA,mBAAmB,OAAA;AAiBrB,iCAAiC;AACjC,mEAA+D;AAAtD,mHAAA,cAAc,OAAA;AAQvB,uBAAuB;AACvB,+CAA2C;AAAlC,+FAAA,IAAI,OAAA;AAEb,6BAA6B;AAC7B,yDAAqD;AAA5C,yGAAA,SAAS,OAAA;AAElB,oBAAoB;AACpB,uDAAmD;AAA1C,uGAAA,QAAQ,OAAA;AAEjB,2BAA2B;AAC3B,qEAAgE;AAAvD,oHAAA,cAAc,OAAA;AAEvB,oFAAoF;AACpF,uDAAkD;AAAzC,sGAAA,OAAO,OAAA;AAQhB,iEAAiE;AACjE,qDAAiD;AAAxC,qGAAA,OAAO,OAAA;AAEhB,sEAAsE;AACtE,6DAAyD;AAAhD,6GAAA,WAAW,OAAA;AAEpB,gBAAgB;AAChB,yCAaqB;AAZnB,uGAAA,UAAU,OAAA;AACV,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,wGAAA,WAAW,OAAA;AACX,yGAAA,YAAY,OAAA;AACZ,yGAAA,YAAY,OAAA;AACZ,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AAuMzB,qCAAqC;AACrC,0DAYiC;AAX/B,4GAAA,UAAU,OAAA;AACV,iHAAA,eAAe,OAAA;AACf,2HAAA,yBAAyB,OAAA;AACzB,2GAAA,SAAS,OAAA;AACT,gHAAA,cAAc,OAAA;AACd,kHAAA,gBAAgB,OAAA;AAChB,gHAAA,cAAc,OAAA;AACd,mHAAA,iBAAiB,OAAA;AACjB,mHAAA,iBAAiB,OAAA;AACjB,yHAAA,uBAAuB,OAAA;AACvB,4HAAA,0BAA0B,OAAA;AAU5B,0EAA0E;AAC1E,yCAA+C;AAAtC,oGAAA,KAAK,OAAW"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The issuer's key set as offline verification holds it — the I/O half around `keyset.ts`, which
|
|
3
|
+
* owns the rules. Mirrors `packages/delegation-verifier/src/jwks.ts`, minus persistence: this SDK
|
|
4
|
+
* keeps tombstones in memory only.
|
|
5
|
+
*
|
|
6
|
+
* Replaces jose's `createRemoteJWKSet`, which hid the fetch time and the registry's own JWK members
|
|
7
|
+
* and so could enforce neither tombstones, windows nor staleness. The behaviours it supplied are
|
|
8
|
+
* kept: a 10-minute reuse window, one forced refetch per 30 s for an unknown `kid`, one fetch in
|
|
9
|
+
* flight at a time. What it did not do, and this does:
|
|
10
|
+
*
|
|
11
|
+
* - A fetch is MERGED into what the verifier knows (`mergeFetchedDocument`), never swapped in.
|
|
12
|
+
* - A failed refetch does not discard the cache. Within `maxJwksAgeMs` its CONFIRMED keys keep
|
|
13
|
+
* answering; beyond it the answer is `stale` — except an applied tombstone, which is `revoked`
|
|
14
|
+
* at any age. A set never fetched has nothing to fall back on and stays `unavailable`.
|
|
15
|
+
* - A failed refetch of a cached set is retried at most once per cooldown, so an outage does not
|
|
16
|
+
* turn every verification into an outbound request.
|
|
17
|
+
* - Age is measured on a monotonic clock; claim checks use the wall clock.
|
|
18
|
+
*/
|
|
19
|
+
import { type KeyLike } from 'jose';
|
|
20
|
+
import { type HttpClient } from '../http.js';
|
|
21
|
+
import type { KeyFamily, KeyRecord, KeySetEvent } from './keyset.js';
|
|
22
|
+
export declare const SUPPORTED_ALGORITHMS: readonly ["RS256", "ES256"];
|
|
23
|
+
export type SupportedAlgorithm = (typeof SUPPORTED_ALGORITHMS)[number];
|
|
24
|
+
/** How long a `kid` miss — or a failed refetch of a cached set — suppresses further fetches. */
|
|
25
|
+
export declare const KEY_MISS_COOLDOWN_MS = 30000;
|
|
26
|
+
/** How long a fetched key set is reused without refetching (jose's default, kept). */
|
|
27
|
+
export declare const KEY_SET_TTL_MS: number;
|
|
28
|
+
/** Default `maxJwksAgeMs`. */
|
|
29
|
+
export declare const DEFAULT_MAX_JWKS_AGE_MS: number;
|
|
30
|
+
/** Largest accepted `maxJwksAgeMs` — below the issuer's ~30-day lead on its next key. */
|
|
31
|
+
export declare const MAX_JWKS_AGE_CAP_MS: number;
|
|
32
|
+
export interface JwksClock {
|
|
33
|
+
monotonicMs(): number;
|
|
34
|
+
wallMs(): number;
|
|
35
|
+
}
|
|
36
|
+
/** Test seam — replaces both clocks; `null` restores the system clocks. Not exported from the package. */
|
|
37
|
+
export declare function setJwksClockForTests(replacement: JwksClock | null): void;
|
|
38
|
+
/** Test seam — receives every key-set event; `null` detaches. Not exported from the package. */
|
|
39
|
+
export declare function setJwksEventListenerForTests(listener: ((event: KeySetEvent) => void) | null): void;
|
|
40
|
+
export declare function nowWallMs(): number;
|
|
41
|
+
/** Throws unless `value` is a usable `maxJwksAgeMs`: whole milliseconds, 1 … 25 days. */
|
|
42
|
+
export declare function assertMaxJwksAgeMs(value: unknown): asserts value is number;
|
|
43
|
+
export declare function isSupportedAlgorithm(alg: unknown): alg is SupportedAlgorithm;
|
|
44
|
+
export interface KeyCandidate {
|
|
45
|
+
key: KeyLike | Uint8Array;
|
|
46
|
+
record: KeyRecord;
|
|
47
|
+
}
|
|
48
|
+
export type KeyResolution = {
|
|
49
|
+
kind: 'keys';
|
|
50
|
+
candidates: KeyCandidate[];
|
|
51
|
+
registryLive: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'revoked';
|
|
54
|
+
kid: string;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'wrong_purpose';
|
|
57
|
+
kid: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'unknown';
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'stale';
|
|
62
|
+
cacheAgeSeconds: number | null;
|
|
63
|
+
} | {
|
|
64
|
+
kind: 'unavailable';
|
|
65
|
+
message: string;
|
|
66
|
+
};
|
|
67
|
+
export declare class KeySetCache {
|
|
68
|
+
private readonly http;
|
|
69
|
+
private readonly jwksUri;
|
|
70
|
+
private readonly maxJwksAgeMs;
|
|
71
|
+
private state;
|
|
72
|
+
/** Imported keys by key material + algorithm; `null` records a JWK that failed to import. */
|
|
73
|
+
private readonly imported;
|
|
74
|
+
private lastMissAt;
|
|
75
|
+
private lastFailedAt;
|
|
76
|
+
private inFlight;
|
|
77
|
+
private forceNext;
|
|
78
|
+
constructor(http: HttpClient, jwksUri: string, maxJwksAgeMs: number);
|
|
79
|
+
/**
|
|
80
|
+
* The keys that may verify a token of `family` carrying `kid` — or why none may. Fetches when the
|
|
81
|
+
* set is older than the TTL, after `forceRefresh()`, or once per cooldown when `kid` is unknown.
|
|
82
|
+
*/
|
|
83
|
+
resolve(kid: string | undefined, alg: SupportedAlgorithm, family: KeyFamily): Promise<KeyResolution>;
|
|
84
|
+
/** Make the next resolution refetch, ignoring the TTL and both cooldowns. Keeps what is known. */
|
|
85
|
+
forceRefresh(): void;
|
|
86
|
+
/** Forget every applied and pending tombstone — the documented manual reset. */
|
|
87
|
+
clearTombstones(): void;
|
|
88
|
+
/** What the cache holds, for tests. */
|
|
89
|
+
diagnostics(): {
|
|
90
|
+
cacheAgeSeconds: number | null;
|
|
91
|
+
registryLive: boolean;
|
|
92
|
+
vanishedKids: string[];
|
|
93
|
+
};
|
|
94
|
+
private cacheAgeMs;
|
|
95
|
+
private isFresh;
|
|
96
|
+
/**
|
|
97
|
+
* One fetch at a time. The shared promise RESOLVES to the outcome rather than recording it on
|
|
98
|
+
* the instance, so a waiter cannot be handed the result of the NEXT fetch.
|
|
99
|
+
*/
|
|
100
|
+
private runFetch;
|
|
101
|
+
private fetchDocument;
|
|
102
|
+
private resolveFromState;
|
|
103
|
+
private importRecord;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=key-set-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-set-cache.d.ts","sourceRoot":"","sources":["../../../src/jwks/key-set-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAuB,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,YAAY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