@proof-holdings/sdk 0.0.0-stage → 1.1.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 +25 -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 +27 -0
- package/dist/cjs/resources/profiles.d.ts.map +1 -0
- package/dist/cjs/resources/profiles.js +50 -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 +21 -0
- package/dist/cjs/resources/templates.d.ts.map +1 -0
- package/dist/cjs/resources/templates.js +38 -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 +1418 -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 +27 -0
- package/dist/esm/resources/profiles.d.ts.map +1 -0
- package/dist/esm/resources/profiles.js +46 -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 +21 -0
- package/dist/esm/resources/templates.d.ts.map +1 -0
- package/dist/esm/resources/templates.js +34 -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 +1418 -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,95 @@
|
|
|
1
|
+
declare const MESSAGE_ALG: "RSA-OAEP-256+AES-256-GCM";
|
|
2
|
+
declare const PRIVATE_KEY_ALG: "PBKDF2-SHA256+AES-256-GCM";
|
|
3
|
+
export interface CiphertextEnvelopeV1 {
|
|
4
|
+
v: 1;
|
|
5
|
+
alg: typeof MESSAGE_ALG;
|
|
6
|
+
ek: string;
|
|
7
|
+
iv: string;
|
|
8
|
+
ct: string;
|
|
9
|
+
tag: string;
|
|
10
|
+
kid: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CiphertextEnvelopeV2 {
|
|
13
|
+
v: 2;
|
|
14
|
+
alg: typeof MESSAGE_ALG;
|
|
15
|
+
ek: string;
|
|
16
|
+
approver_ek: Record<string, string>;
|
|
17
|
+
iv: string;
|
|
18
|
+
ct: string;
|
|
19
|
+
tag: string;
|
|
20
|
+
kid: string;
|
|
21
|
+
}
|
|
22
|
+
/** Union of all envelope versions. */
|
|
23
|
+
export type CiphertextEnvelope = CiphertextEnvelopeV1 | CiphertextEnvelopeV2;
|
|
24
|
+
export interface EncryptedPrivateKey {
|
|
25
|
+
v: 1;
|
|
26
|
+
alg: typeof PRIVATE_KEY_ALG;
|
|
27
|
+
iv: string;
|
|
28
|
+
ct: string;
|
|
29
|
+
tag: string;
|
|
30
|
+
salt: string;
|
|
31
|
+
kid: string;
|
|
32
|
+
}
|
|
33
|
+
export interface HitlKeyPair {
|
|
34
|
+
publicKeyPem: string;
|
|
35
|
+
encryptedPrivateKey: EncryptedPrivateKey;
|
|
36
|
+
kid: string;
|
|
37
|
+
}
|
|
38
|
+
/** Compute kid = lowercase_hex(SHA-256(DER-encoded SPKI public key bytes)) */
|
|
39
|
+
export declare function computeKid(publicKeyPem: string): string;
|
|
40
|
+
/** Generate an RSA-4096 key pair. Returns PEM-encoded SPKI public + PKCS#8 private. */
|
|
41
|
+
export declare function generateKeyPair(): {
|
|
42
|
+
publicKeyPem: string;
|
|
43
|
+
privateKeyPem: string;
|
|
44
|
+
};
|
|
45
|
+
/** Derive a 256-bit key from password + salt using PBKDF2-SHA256 at 600k iterations. */
|
|
46
|
+
export declare function deriveKey(password: string, salt: Buffer): Buffer;
|
|
47
|
+
export declare function validateMessageEnvelope(obj: unknown): obj is CiphertextEnvelope;
|
|
48
|
+
export declare function validatePrivateKeyEnvelope(obj: unknown): obj is EncryptedPrivateKey;
|
|
49
|
+
/**
|
|
50
|
+
* Encrypt a confirmation message for a HITL config.
|
|
51
|
+
* AAD = `{hitlId}`
|
|
52
|
+
*/
|
|
53
|
+
export declare function encryptMessage(plaintext: string, publicKeyPem: string, hitlId: string): CiphertextEnvelopeV1;
|
|
54
|
+
/**
|
|
55
|
+
* Encrypt a confirmation message with multi-recipient wrapping (v2).
|
|
56
|
+
* Wraps the AES content key with the owner's public key AND each approver's
|
|
57
|
+
* public key, so every enrolled approver can decrypt with their own key.
|
|
58
|
+
* AAD = `{hitlId}`.
|
|
59
|
+
*
|
|
60
|
+
* @param approverKeys - Map of authorization_id → approver PEM public key
|
|
61
|
+
*/
|
|
62
|
+
export declare function encryptMessageV2(plaintext: string, ownerPublicKeyPem: string, hitlId: string, approverKeys: Record<string, string>): CiphertextEnvelopeV2;
|
|
63
|
+
/**
|
|
64
|
+
* Encrypt a message with fixed AES key and IV (for test vector generation only).
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export declare function encryptMessageWithFixedInputs(plaintext: string, publicKeyPem: string, hitlId: string, aesKey: Buffer, iv: Buffer): CiphertextEnvelope;
|
|
68
|
+
/**
|
|
69
|
+
* Decrypt a confirmation message envelope.
|
|
70
|
+
* AAD = `{hitlId}`
|
|
71
|
+
*/
|
|
72
|
+
export declare function decryptMessage(envelope: CiphertextEnvelope, privateKeyPem: string, hitlId: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Encrypt an RSA private key with a user password for storage.
|
|
75
|
+
* AAD = `{hitlId}:{userId}`
|
|
76
|
+
*/
|
|
77
|
+
export declare function encryptPrivateKey(privateKeyPem: string, password: string, publicKeyPem: string, hitlId: string, userId: string): EncryptedPrivateKey;
|
|
78
|
+
/**
|
|
79
|
+
* Decrypt an RSA private key using the user's password.
|
|
80
|
+
* AAD = `{hitlId}:{userId}`
|
|
81
|
+
* Returns PEM-encoded PKCS#8 private key.
|
|
82
|
+
*/
|
|
83
|
+
export declare function decryptPrivateKey(envelope: EncryptedPrivateKey, password: string, hitlId: string, userId: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Generate a new RSA-4096 key pair and encrypt the private key with a password.
|
|
86
|
+
* Returns everything needed for `PUT /api/v1/hitl/:id/keys`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function generateEncryptionKeyPair(password: string, hitlId: string, userId: string): {
|
|
89
|
+
publicKeyPem: string;
|
|
90
|
+
encryptedPrivateKey: EncryptedPrivateKey;
|
|
91
|
+
kdfSalt: string;
|
|
92
|
+
kid: string;
|
|
93
|
+
};
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=hitl-crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitl-crypto.d.ts","sourceRoot":"","sources":["../../../src/crypto/hitl-crypto.ts"],"names":[],"mappings":"AAiB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AAE,MAAM,GACb,MAAM,CAiBR;AAMD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAUlG"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.computeKid = computeKid;
|
|
7
|
+
exports.generateKeyPair = generateKeyPair;
|
|
8
|
+
exports.deriveKey = deriveKey;
|
|
9
|
+
exports.validateMessageEnvelope = validateMessageEnvelope;
|
|
10
|
+
exports.validatePrivateKeyEnvelope = validatePrivateKeyEnvelope;
|
|
11
|
+
exports.encryptMessage = encryptMessage;
|
|
12
|
+
exports.encryptMessageV2 = encryptMessageV2;
|
|
13
|
+
exports.encryptMessageWithFixedInputs = encryptMessageWithFixedInputs;
|
|
14
|
+
exports.decryptMessage = decryptMessage;
|
|
15
|
+
exports.encryptPrivateKey = encryptPrivateKey;
|
|
16
|
+
exports.decryptPrivateKey = decryptPrivateKey;
|
|
17
|
+
exports.generateEncryptionKeyPair = generateEncryptionKeyPair;
|
|
18
|
+
/**
|
|
19
|
+
* HITL End-to-End Encryption — Crypto Module
|
|
20
|
+
*
|
|
21
|
+
* Implements the envelope spec from docs/ENCRYPTION_ENVELOPE.md.
|
|
22
|
+
* Uses Node.js crypto module (works in Node.js 18+).
|
|
23
|
+
*
|
|
24
|
+
* Two modes:
|
|
25
|
+
* - Encrypt-only: agent has public key, encrypts messages for the approver
|
|
26
|
+
* - Encrypt+decrypt: approver has password, decrypts messages in browser
|
|
27
|
+
*/
|
|
28
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Constants
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
const ENVELOPE_VERSION = 1;
|
|
33
|
+
const MESSAGE_ALG = 'RSA-OAEP-256+AES-256-GCM';
|
|
34
|
+
const PRIVATE_KEY_ALG = 'PBKDF2-SHA256+AES-256-GCM';
|
|
35
|
+
const AES_KEY_BYTES = 32;
|
|
36
|
+
const AES_IV_BYTES = 12;
|
|
37
|
+
const AES_TAG_BYTES = 16;
|
|
38
|
+
const RSA_EK_BYTES = 512; // 4096-bit RSA
|
|
39
|
+
const PBKDF2_ITERATIONS = 600000;
|
|
40
|
+
const PBKDF2_SALT_BYTES = 16;
|
|
41
|
+
const PBKDF2_KEY_BYTES = 32;
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Base64url helpers
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
function toBase64url(buf) {
|
|
46
|
+
return buf.toString('base64url');
|
|
47
|
+
}
|
|
48
|
+
function fromBase64url(str) {
|
|
49
|
+
return Buffer.from(str, 'base64url');
|
|
50
|
+
}
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Key Identifier
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
/** Compute kid = lowercase_hex(SHA-256(DER-encoded SPKI public key bytes)) */
|
|
55
|
+
function computeKid(publicKeyPem) {
|
|
56
|
+
const keyObject = crypto_1.default.createPublicKey(publicKeyPem);
|
|
57
|
+
const der = keyObject.export({ type: 'spki', format: 'der' });
|
|
58
|
+
return crypto_1.default.createHash('sha256').update(der).digest('hex');
|
|
59
|
+
}
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// RSA Key Generation
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
/** Generate an RSA-4096 key pair. Returns PEM-encoded SPKI public + PKCS#8 private. */
|
|
64
|
+
function generateKeyPair() {
|
|
65
|
+
const { publicKey, privateKey } = crypto_1.default.generateKeyPairSync('rsa', {
|
|
66
|
+
modulusLength: 4096,
|
|
67
|
+
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
|
68
|
+
privateKeyEncoding: { type: 'pkcs8', format: 'pem' },
|
|
69
|
+
});
|
|
70
|
+
return { publicKeyPem: publicKey, privateKeyPem: privateKey };
|
|
71
|
+
}
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// PBKDF2
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
/** Derive a 256-bit key from password + salt using PBKDF2-SHA256 at 600k iterations. */
|
|
76
|
+
function deriveKey(password, salt) {
|
|
77
|
+
return crypto_1.default.pbkdf2Sync(password, salt, PBKDF2_ITERATIONS, PBKDF2_KEY_BYTES, 'sha256');
|
|
78
|
+
}
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// AES-256-GCM
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
function aesGcmEncrypt(key, iv, plaintext, aad) {
|
|
83
|
+
const cipher = crypto_1.default.createCipheriv('aes-256-gcm', key, iv);
|
|
84
|
+
cipher.setAAD(aad);
|
|
85
|
+
const ciphertext = Buffer.concat([cipher.update(plaintext), cipher.final()]);
|
|
86
|
+
const tag = cipher.getAuthTag();
|
|
87
|
+
return { ciphertext, tag };
|
|
88
|
+
}
|
|
89
|
+
function aesGcmDecrypt(key, iv, ciphertext, tag, aad) {
|
|
90
|
+
const decipher = crypto_1.default.createDecipheriv('aes-256-gcm', key, iv);
|
|
91
|
+
decipher.setAuthTag(tag);
|
|
92
|
+
decipher.setAAD(aad);
|
|
93
|
+
try {
|
|
94
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw new Error('Decryption failed');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// RSA-OAEP-SHA256 wrap/unwrap
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
function rsaOaepWrap(publicKeyPem, plaintext) {
|
|
104
|
+
const keyObject = crypto_1.default.createPublicKey(publicKeyPem);
|
|
105
|
+
return crypto_1.default.publicEncrypt({ key: keyObject, padding: crypto_1.default.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: 'sha256' }, plaintext);
|
|
106
|
+
}
|
|
107
|
+
function rsaOaepUnwrap(privateKeyPem, ciphertext) {
|
|
108
|
+
const keyObject = crypto_1.default.createPrivateKey(privateKeyPem);
|
|
109
|
+
try {
|
|
110
|
+
return crypto_1.default.privateDecrypt({ key: keyObject, padding: crypto_1.default.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: 'sha256' }, ciphertext);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
throw new Error('Decryption failed');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Envelope Validation
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
function validateMessageEnvelope(obj) {
|
|
120
|
+
if (!obj || typeof obj !== 'object')
|
|
121
|
+
return false;
|
|
122
|
+
const e = obj;
|
|
123
|
+
if (e.v !== 1 && e.v !== 2)
|
|
124
|
+
return false;
|
|
125
|
+
if (e.alg !== MESSAGE_ALG)
|
|
126
|
+
return false;
|
|
127
|
+
if (typeof e.ek !== 'string' || fromBase64url(e.ek).length !== RSA_EK_BYTES)
|
|
128
|
+
return false;
|
|
129
|
+
if (typeof e.iv !== 'string' || fromBase64url(e.iv).length !== AES_IV_BYTES)
|
|
130
|
+
return false;
|
|
131
|
+
if (typeof e.tag !== 'string' || fromBase64url(e.tag).length !== AES_TAG_BYTES)
|
|
132
|
+
return false;
|
|
133
|
+
if (typeof e.ct !== 'string' || !e.ct)
|
|
134
|
+
return false;
|
|
135
|
+
if (typeof e.kid !== 'string' || !/^[a-f0-9]{64}$/.test(e.kid))
|
|
136
|
+
return false;
|
|
137
|
+
// v2: per-recipient wrapped keys (authorization_id → base64url, each RSA_EK_BYTES long)
|
|
138
|
+
if (e.v === 2) {
|
|
139
|
+
if (!e.approver_ek || typeof e.approver_ek !== 'object' || Array.isArray(e.approver_ek))
|
|
140
|
+
return false;
|
|
141
|
+
for (const wrapped of Object.values(e.approver_ek)) {
|
|
142
|
+
if (typeof wrapped !== 'string' || fromBase64url(wrapped).length !== RSA_EK_BYTES)
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Reject unknown fields (v2 additionally allows approver_ek)
|
|
147
|
+
const known = new Set(e.v === 2
|
|
148
|
+
? ['v', 'alg', 'ek', 'approver_ek', 'iv', 'ct', 'tag', 'kid']
|
|
149
|
+
: ['v', 'alg', 'ek', 'iv', 'ct', 'tag', 'kid']);
|
|
150
|
+
for (const key of Object.keys(e)) {
|
|
151
|
+
if (!known.has(key))
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
function validatePrivateKeyEnvelope(obj) {
|
|
157
|
+
if (!obj || typeof obj !== 'object')
|
|
158
|
+
return false;
|
|
159
|
+
const e = obj;
|
|
160
|
+
if (e.v !== 1)
|
|
161
|
+
return false;
|
|
162
|
+
if (e.alg !== PRIVATE_KEY_ALG)
|
|
163
|
+
return false;
|
|
164
|
+
if (typeof e.iv !== 'string' || fromBase64url(e.iv).length !== AES_IV_BYTES)
|
|
165
|
+
return false;
|
|
166
|
+
if (typeof e.tag !== 'string' || fromBase64url(e.tag).length !== AES_TAG_BYTES)
|
|
167
|
+
return false;
|
|
168
|
+
if (typeof e.ct !== 'string' || !e.ct)
|
|
169
|
+
return false;
|
|
170
|
+
if (typeof e.salt !== 'string' || fromBase64url(e.salt).length !== PBKDF2_SALT_BYTES)
|
|
171
|
+
return false;
|
|
172
|
+
if (typeof e.kid !== 'string' || !/^[a-f0-9]{64}$/.test(e.kid))
|
|
173
|
+
return false;
|
|
174
|
+
const known = new Set(['v', 'alg', 'iv', 'ct', 'tag', 'salt', 'kid']);
|
|
175
|
+
for (const key of Object.keys(e)) {
|
|
176
|
+
if (!known.has(key))
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
// Message Encryption (Section 4.1)
|
|
183
|
+
// ---------------------------------------------------------------------------
|
|
184
|
+
/**
|
|
185
|
+
* Encrypt a confirmation message for a HITL config.
|
|
186
|
+
* AAD = `{hitlId}`
|
|
187
|
+
*/
|
|
188
|
+
function encryptMessage(plaintext, publicKeyPem, hitlId) {
|
|
189
|
+
const aesKey = crypto_1.default.randomBytes(AES_KEY_BYTES);
|
|
190
|
+
const iv = crypto_1.default.randomBytes(AES_IV_BYTES);
|
|
191
|
+
const aad = Buffer.from(hitlId, 'utf8');
|
|
192
|
+
const plaintextBuf = Buffer.from(plaintext, 'utf8');
|
|
193
|
+
const { ciphertext, tag } = aesGcmEncrypt(aesKey, iv, plaintextBuf, aad);
|
|
194
|
+
const ek = rsaOaepWrap(publicKeyPem, aesKey);
|
|
195
|
+
const kid = computeKid(publicKeyPem);
|
|
196
|
+
return {
|
|
197
|
+
v: ENVELOPE_VERSION,
|
|
198
|
+
alg: MESSAGE_ALG,
|
|
199
|
+
ek: toBase64url(ek),
|
|
200
|
+
iv: toBase64url(iv),
|
|
201
|
+
ct: toBase64url(ciphertext),
|
|
202
|
+
tag: toBase64url(tag),
|
|
203
|
+
kid,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Encrypt a confirmation message with multi-recipient wrapping (v2).
|
|
208
|
+
* Wraps the AES content key with the owner's public key AND each approver's
|
|
209
|
+
* public key, so every enrolled approver can decrypt with their own key.
|
|
210
|
+
* AAD = `{hitlId}`.
|
|
211
|
+
*
|
|
212
|
+
* @param approverKeys - Map of authorization_id → approver PEM public key
|
|
213
|
+
*/
|
|
214
|
+
function encryptMessageV2(plaintext, ownerPublicKeyPem, hitlId, approverKeys) {
|
|
215
|
+
const aesKey = crypto_1.default.randomBytes(AES_KEY_BYTES);
|
|
216
|
+
const iv = crypto_1.default.randomBytes(AES_IV_BYTES);
|
|
217
|
+
const aad = Buffer.from(hitlId, 'utf8');
|
|
218
|
+
const plaintextBuf = Buffer.from(plaintext, 'utf8');
|
|
219
|
+
const { ciphertext, tag } = aesGcmEncrypt(aesKey, iv, plaintextBuf, aad);
|
|
220
|
+
const ek = rsaOaepWrap(ownerPublicKeyPem, aesKey);
|
|
221
|
+
const kid = computeKid(ownerPublicKeyPem);
|
|
222
|
+
// Wrap the same AES key with each approver's public key.
|
|
223
|
+
const approver_ek = {};
|
|
224
|
+
for (const [authzId, approverPem] of Object.entries(approverKeys)) {
|
|
225
|
+
approver_ek[authzId] = toBase64url(rsaOaepWrap(approverPem, aesKey));
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
v: 2,
|
|
229
|
+
alg: MESSAGE_ALG,
|
|
230
|
+
ek: toBase64url(ek),
|
|
231
|
+
approver_ek,
|
|
232
|
+
iv: toBase64url(iv),
|
|
233
|
+
ct: toBase64url(ciphertext),
|
|
234
|
+
tag: toBase64url(tag),
|
|
235
|
+
kid,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Encrypt a message with fixed AES key and IV (for test vector generation only).
|
|
240
|
+
* @internal
|
|
241
|
+
*/
|
|
242
|
+
function encryptMessageWithFixedInputs(plaintext, publicKeyPem, hitlId, aesKey, iv) {
|
|
243
|
+
const aad = Buffer.from(hitlId, 'utf8');
|
|
244
|
+
const plaintextBuf = Buffer.from(plaintext, 'utf8');
|
|
245
|
+
const { ciphertext, tag } = aesGcmEncrypt(aesKey, iv, plaintextBuf, aad);
|
|
246
|
+
const ek = rsaOaepWrap(publicKeyPem, aesKey);
|
|
247
|
+
const kid = computeKid(publicKeyPem);
|
|
248
|
+
return {
|
|
249
|
+
v: ENVELOPE_VERSION,
|
|
250
|
+
alg: MESSAGE_ALG,
|
|
251
|
+
ek: toBase64url(ek),
|
|
252
|
+
iv: toBase64url(iv),
|
|
253
|
+
ct: toBase64url(ciphertext),
|
|
254
|
+
tag: toBase64url(tag),
|
|
255
|
+
kid,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Decrypt a confirmation message envelope.
|
|
260
|
+
* AAD = `{hitlId}`
|
|
261
|
+
*/
|
|
262
|
+
function decryptMessage(envelope, privateKeyPem, hitlId) {
|
|
263
|
+
if (!validateMessageEnvelope(envelope)) {
|
|
264
|
+
throw new Error('Decryption failed');
|
|
265
|
+
}
|
|
266
|
+
const ek = fromBase64url(envelope.ek);
|
|
267
|
+
const iv = fromBase64url(envelope.iv);
|
|
268
|
+
const ct = fromBase64url(envelope.ct);
|
|
269
|
+
const tag = fromBase64url(envelope.tag);
|
|
270
|
+
const aad = Buffer.from(hitlId, 'utf8');
|
|
271
|
+
const aesKey = rsaOaepUnwrap(privateKeyPem, ek);
|
|
272
|
+
const plaintext = aesGcmDecrypt(aesKey, iv, ct, tag, aad);
|
|
273
|
+
return plaintext.toString('utf8');
|
|
274
|
+
}
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
// Private Key Encryption (Section 4.2)
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
/**
|
|
279
|
+
* Encrypt an RSA private key with a user password for storage.
|
|
280
|
+
* AAD = `{hitlId}:{userId}`
|
|
281
|
+
*/
|
|
282
|
+
function encryptPrivateKey(privateKeyPem, password, publicKeyPem, hitlId, userId) {
|
|
283
|
+
const salt = crypto_1.default.randomBytes(PBKDF2_SALT_BYTES);
|
|
284
|
+
const derivedKey = deriveKey(password, salt);
|
|
285
|
+
const iv = crypto_1.default.randomBytes(AES_IV_BYTES);
|
|
286
|
+
const aad = Buffer.from(`${hitlId}:${userId}`, 'utf8');
|
|
287
|
+
const privateKeyDer = crypto_1.default.createPrivateKey(privateKeyPem).export({ type: 'pkcs8', format: 'der' });
|
|
288
|
+
const { ciphertext, tag } = aesGcmEncrypt(derivedKey, iv, privateKeyDer, aad);
|
|
289
|
+
const kid = computeKid(publicKeyPem);
|
|
290
|
+
return {
|
|
291
|
+
v: ENVELOPE_VERSION,
|
|
292
|
+
alg: PRIVATE_KEY_ALG,
|
|
293
|
+
iv: toBase64url(iv),
|
|
294
|
+
ct: toBase64url(ciphertext),
|
|
295
|
+
tag: toBase64url(tag),
|
|
296
|
+
salt: toBase64url(salt),
|
|
297
|
+
kid,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Decrypt an RSA private key using the user's password.
|
|
302
|
+
* AAD = `{hitlId}:{userId}`
|
|
303
|
+
* Returns PEM-encoded PKCS#8 private key.
|
|
304
|
+
*/
|
|
305
|
+
function decryptPrivateKey(envelope, password, hitlId, userId) {
|
|
306
|
+
if (!validatePrivateKeyEnvelope(envelope)) {
|
|
307
|
+
throw new Error('Decryption failed');
|
|
308
|
+
}
|
|
309
|
+
const salt = fromBase64url(envelope.salt);
|
|
310
|
+
const derivedKey = deriveKey(password, salt);
|
|
311
|
+
const iv = fromBase64url(envelope.iv);
|
|
312
|
+
const ct = fromBase64url(envelope.ct);
|
|
313
|
+
const tag = fromBase64url(envelope.tag);
|
|
314
|
+
const aad = Buffer.from(`${hitlId}:${userId}`, 'utf8');
|
|
315
|
+
const privateKeyDer = aesGcmDecrypt(derivedKey, iv, ct, tag, aad);
|
|
316
|
+
// Convert DER back to PEM
|
|
317
|
+
const keyObject = crypto_1.default.createPrivateKey({ key: privateKeyDer, format: 'der', type: 'pkcs8' });
|
|
318
|
+
return keyObject.export({ type: 'pkcs8', format: 'pem' });
|
|
319
|
+
}
|
|
320
|
+
// ---------------------------------------------------------------------------
|
|
321
|
+
// Full Key Setup (convenience)
|
|
322
|
+
// ---------------------------------------------------------------------------
|
|
323
|
+
/**
|
|
324
|
+
* Generate a new RSA-4096 key pair and encrypt the private key with a password.
|
|
325
|
+
* Returns everything needed for `PUT /api/v1/hitl/:id/keys`.
|
|
326
|
+
*/
|
|
327
|
+
function generateEncryptionKeyPair(password, hitlId, userId) {
|
|
328
|
+
const { publicKeyPem, privateKeyPem } = generateKeyPair();
|
|
329
|
+
const encrypted = encryptPrivateKey(privateKeyPem, password, publicKeyPem, hitlId, userId);
|
|
330
|
+
const kid = computeKid(publicKeyPem);
|
|
331
|
+
return {
|
|
332
|
+
publicKeyPem,
|
|
333
|
+
encryptedPrivateKey: encrypted,
|
|
334
|
+
kdfSalt: encrypted.salt,
|
|
335
|
+
kid,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=hitl-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitl-crypto.js","sourceRoot":"","sources":["../../../src/crypto/hitl-crypto.ts"],"names":[],"mappings":";;;;;AAwFA,gCAIC;AAOD,0CAOC;AAOD,8BAEC;AAgED,0DA6BC;AAED,gEAeC;AAUD,wCAuBC;AAUD,4CA+BC;AAMD,sEAuBC;AAMD,wCAmBC;AAUD,8CAyBC;AAOD,8CAsBC;AAUD,8DAcC;AAzbD;;;;;;;;;GASG;AACH,oDAA4B;AAE5B,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,WAAW,GAAG,0BAAmC,CAAC;AACxD,MAAM,eAAe,GAAG,2BAAoC,CAAC;AAC7D,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,YAAY,GAAG,GAAG,CAAC,CAAC,eAAe;AACzC,MAAM,iBAAiB,GAAG,MAAO,CAAC;AAClC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,M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Aa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3F,MAAM,GAAG,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,OAAO;QACL,YAAY;QACZ,mBAAmB,EAAE,SAAS;QAC9B,OAAO,EAAE,SAAS,CAAC,IAAI;QACvB,GAAG;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ApiError } from './types.js';
|
|
2
|
+
export declare class ProofError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly statusCode: number;
|
|
5
|
+
readonly details?: unknown;
|
|
6
|
+
readonly requestId?: string;
|
|
7
|
+
constructor(message: string, code: string, statusCode: number, details?: unknown, requestId?: string);
|
|
8
|
+
static fromResponse(statusCode: number, error?: ApiError): ProofError;
|
|
9
|
+
}
|
|
10
|
+
export declare class ValidationError extends ProofError {
|
|
11
|
+
constructor(message: string, code: string, details?: unknown, requestId?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class AuthenticationError extends ProofError {
|
|
14
|
+
constructor(message: string, code: string, details?: unknown, requestId?: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class ForbiddenError extends ProofError {
|
|
17
|
+
constructor(message: string, code: string, details?: unknown, requestId?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class NotFoundError extends ProofError {
|
|
20
|
+
constructor(message: string, code: string, details?: unknown, requestId?: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class ConflictError extends ProofError {
|
|
23
|
+
constructor(message: string, code: string, details?: unknown, requestId?: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class RateLimitError extends ProofError {
|
|
26
|
+
/** Seconds to wait before retrying (from error response retryAfter field) */
|
|
27
|
+
readonly retryAfter?: number;
|
|
28
|
+
/** Number of remaining attempts before lockout (auth endpoints only) */
|
|
29
|
+
readonly remainingAttempts?: number;
|
|
30
|
+
constructor(message: string, code: string, details?: unknown, requestId?: string, retryAfter?: number, remainingAttempts?: number);
|
|
31
|
+
static fromApiError(error: ApiError): RateLimitError;
|
|
32
|
+
}
|
|
33
|
+
export declare class ServerError extends ProofError {
|
|
34
|
+
constructor(message: string, code: string, statusCode?: number, details?: unknown, requestId?: string);
|
|
35
|
+
}
|
|
36
|
+
export declare class NetworkError extends ProofError {
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
export declare class TimeoutError extends ProofError {
|
|
40
|
+
constructor(message?: string);
|
|
41
|
+
}
|
|
42
|
+
export declare class PollingTimeoutError extends ProofError {
|
|
43
|
+
constructor(message?: string);
|
|
44
|
+
}
|
|
45
|
+
export declare class ConfirmationDeniedError extends ProofError {
|
|
46
|
+
/** ID of the confirmation that triggered the error */
|
|
47
|
+
readonly confirmationId: string;
|
|
48
|
+
/** Non-approved terminal status that triggered the error ('denied' or, for the createAndWait gate, 'expired') */
|
|
49
|
+
readonly status: string;
|
|
50
|
+
constructor(confirmationId: string, status?: string);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClC,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,EACjB,SAAS,CAAC,EAAE,MAAM;IAWpB,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,GAAG,UA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M,EAAE,UAAU,GAAE,MAAY,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM;CAI3G;AAED,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,OAAO,GAAE,MAA4B;CAIlD;AAED,qBAAa,mBAAoB,SAAQ,UAAU;gBACrC,OAAO,GAAE,MAAmD;CAIzE;AAED,qBAAa,uBAAwB,SAAQ,UAAU;IACrD,sDAAsD;IACtD,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC,iHAAiH;IACjH,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,cAAc,EAAE,MAAM,EAAE,MAAM,GAAE,MAAiB;CAM9D"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfirmationDeniedError = exports.PollingTimeoutError = exports.TimeoutError = exports.NetworkError = exports.ServerError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.AuthenticationError = exports.ValidationError = exports.ProofError = void 0;
|
|
4
|
+
class ProofError extends Error {
|
|
5
|
+
constructor(message, code, statusCode, details, requestId) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'ProofError';
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.details = details;
|
|
11
|
+
this.requestId = requestId;
|
|
12
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
13
|
+
}
|
|
14
|
+
static fromResponse(statusCode, error) {
|
|
15
|
+
const code = error?.code ?? `http_${statusCode}`;
|
|
16
|
+
const message = error?.message ?? `Request failed with status ${statusCode}`;
|
|
17
|
+
const details = error?.details;
|
|
18
|
+
const requestId = error?.request_id;
|
|
19
|
+
switch (statusCode) {
|
|
20
|
+
case 400: return new ValidationError(message, code, details, requestId);
|
|
21
|
+
case 401: return new AuthenticationError(message, code, details, requestId);
|
|
22
|
+
case 403: return new ForbiddenError(message, code, details, requestId);
|
|
23
|
+
case 404: return new NotFoundError(message, code, details, requestId);
|
|
24
|
+
case 409: return new ConflictError(message, code, details, requestId);
|
|
25
|
+
case 429:
|
|
26
|
+
return error
|
|
27
|
+
? RateLimitError.fromApiError(error)
|
|
28
|
+
: new RateLimitError(message, code, details, requestId);
|
|
29
|
+
default:
|
|
30
|
+
if (statusCode >= 500)
|
|
31
|
+
return new ServerError(message, code, statusCode, details, requestId);
|
|
32
|
+
return new ProofError(message, code, statusCode, details, requestId);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ProofError = ProofError;
|
|
37
|
+
class ValidationError extends ProofError {
|
|
38
|
+
constructor(message, code, details, requestId) {
|
|
39
|
+
super(message, code, 400, details, requestId);
|
|
40
|
+
this.name = 'ValidationError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.ValidationError = ValidationError;
|
|
44
|
+
class AuthenticationError extends ProofError {
|
|
45
|
+
constructor(message, code, details, requestId) {
|
|
46
|
+
super(message, code, 401, details, requestId);
|
|
47
|
+
this.name = 'AuthenticationError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.AuthenticationError = AuthenticationError;
|
|
51
|
+
class ForbiddenError extends ProofError {
|
|
52
|
+
constructor(message, code, details, requestId) {
|
|
53
|
+
super(message, code, 403, details, requestId);
|
|
54
|
+
this.name = 'ForbiddenError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ForbiddenError = ForbiddenError;
|
|
58
|
+
class NotFoundError extends ProofError {
|
|
59
|
+
constructor(message, code, details, requestId) {
|
|
60
|
+
super(message, code, 404, details, requestId);
|
|
61
|
+
this.name = 'NotFoundError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.NotFoundError = NotFoundError;
|
|
65
|
+
class ConflictError extends ProofError {
|
|
66
|
+
constructor(message, code, details, requestId) {
|
|
67
|
+
super(message, code, 409, details, requestId);
|
|
68
|
+
this.name = 'ConflictError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ConflictError = ConflictError;
|
|
72
|
+
class RateLimitError extends ProofError {
|
|
73
|
+
constructor(message, code, details, requestId, retryAfter, remainingAttempts) {
|
|
74
|
+
super(message, code, 429, details, requestId);
|
|
75
|
+
this.name = 'RateLimitError';
|
|
76
|
+
this.retryAfter = retryAfter;
|
|
77
|
+
this.remainingAttempts = remainingAttempts;
|
|
78
|
+
}
|
|
79
|
+
static fromApiError(error) {
|
|
80
|
+
return new RateLimitError(error.message, error.code, error.details, error.request_id, error.retryAfter, error.remaining_attempts);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.RateLimitError = RateLimitError;
|
|
84
|
+
class ServerError extends ProofError {
|
|
85
|
+
constructor(message, code, statusCode = 500, details, requestId) {
|
|
86
|
+
super(message, code, statusCode, details, requestId);
|
|
87
|
+
this.name = 'ServerError';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ServerError = ServerError;
|
|
91
|
+
class NetworkError extends ProofError {
|
|
92
|
+
constructor(message) {
|
|
93
|
+
super(message, 'network_error', 0);
|
|
94
|
+
this.name = 'NetworkError';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.NetworkError = NetworkError;
|
|
98
|
+
class TimeoutError extends ProofError {
|
|
99
|
+
constructor(message = 'Request timed out') {
|
|
100
|
+
super(message, 'timeout', 0);
|
|
101
|
+
this.name = 'TimeoutError';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.TimeoutError = TimeoutError;
|
|
105
|
+
class PollingTimeoutError extends ProofError {
|
|
106
|
+
constructor(message = 'Polling timed out waiting for completion') {
|
|
107
|
+
super(message, 'polling_timeout', 0);
|
|
108
|
+
this.name = 'PollingTimeoutError';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.PollingTimeoutError = PollingTimeoutError;
|
|
112
|
+
class ConfirmationDeniedError extends ProofError {
|
|
113
|
+
constructor(confirmationId, status = 'denied') {
|
|
114
|
+
super(`Confirmation ${confirmationId} was ${status}`, 'confirmation_denied', 0);
|
|
115
|
+
this.name = 'ConfirmationDeniedError';
|
|
116
|
+
this.confirmationId = confirmationId;
|
|
117
|
+
this.status = status;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.ConfirmationDeniedError = ConfirmationDeniedError;
|
|
121
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAW,SAAQ,KAAK;IAMnC,YACE,OAAe,EACf,IAAY,EACZ,UAAkB,EAClB,OAAiB,EACjB,SAAkB;QAElB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,UAAkB,EAAE,KAAgB;QACtD,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,QAAQ,UAAU,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,8BAA8B,UAAU,EAAE,CAAC;QAC7E,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,CAAC;QAC/B,MAAM,SAAS,GAAG,KAAK,EAAE,UAAU,CAAC;QAEpC,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK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