@hawcx/oauth-client 0.2.0 → 5.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/README.md +587 -204
- package/dist/client-assertion.d.ts +45 -0
- package/dist/client-assertion.d.ts.map +1 -0
- package/dist/client-assertion.js +141 -0
- package/dist/client-assertion.js.map +1 -0
- package/dist/delegation/credentials.d.ts +92 -0
- package/dist/delegation/credentials.d.ts.map +1 -0
- package/dist/delegation/credentials.js +215 -0
- package/dist/delegation/credentials.js.map +1 -0
- package/dist/delegation/crypto.d.ts +2 -2
- package/dist/delegation/crypto.d.ts.map +1 -1
- package/dist/delegation/crypto.js +41 -32
- package/dist/delegation/crypto.js.map +1 -1
- package/dist/delegation/exceptions.d.ts +12 -5
- package/dist/delegation/exceptions.d.ts.map +1 -1
- package/dist/delegation/exceptions.js +12 -14
- package/dist/delegation/exceptions.js.map +1 -1
- package/dist/delegation/factory.d.ts +20 -0
- package/dist/delegation/factory.d.ts.map +1 -0
- package/dist/delegation/factory.js +49 -0
- package/dist/delegation/factory.js.map +1 -0
- package/dist/delegation/hawcx.d.ts +59 -224
- package/dist/delegation/hawcx.d.ts.map +1 -1
- package/dist/delegation/hawcx.js +99 -299
- package/dist/delegation/hawcx.js.map +1 -1
- package/dist/delegation/index.d.ts +4 -9
- package/dist/delegation/index.d.ts.map +1 -1
- package/dist/delegation/index.js +5 -17
- package/dist/delegation/index.js.map +1 -1
- package/dist/delegation/transport.d.ts +40 -0
- package/dist/delegation/transport.d.ts.map +1 -0
- package/dist/delegation/transport.js +120 -0
- package/dist/delegation/transport.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +12 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -27
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.ts +265 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +497 -0
- package/dist/oauth.js.map +1 -0
- package/dist/stepup/client.d.ts +26 -0
- package/dist/stepup/client.d.ts.map +1 -0
- package/dist/stepup/client.js +78 -0
- package/dist/stepup/client.js.map +1 -0
- package/dist/stepup/index.d.ts +3 -0
- package/dist/stepup/index.d.ts.map +1 -0
- package/dist/stepup/index.js +19 -0
- package/dist/stepup/index.js.map +1 -0
- package/dist/stepup/types.d.ts +35 -0
- package/dist/stepup/types.d.ts.map +1 -0
- package/dist/stepup/types.js +3 -0
- package/dist/stepup/types.js.map +1 -0
- package/package.json +13 -16
- package/dist/client.d.ts +0 -134
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -300
- package/dist/client.js.map +0 -1
- package/dist/delegation/client.d.ts +0 -116
- package/dist/delegation/client.d.ts.map +0 -1
- package/dist/delegation/client.js +0 -227
- package/dist/delegation/client.js.map +0 -1
- package/dist/exceptions.d.ts +0 -52
- package/dist/exceptions.d.ts.map +0 -1
- package/dist/exceptions.js +0 -81
- package/dist/exceptions.js.map +0 -1
- package/dist/utils.d.ts +0 -61
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -263
- package/dist/utils.js.map +0 -1
|
@@ -59,6 +59,28 @@ function b64e(buffer) {
|
|
|
59
59
|
function b64d(str) {
|
|
60
60
|
return Buffer.from(str, 'base64url');
|
|
61
61
|
}
|
|
62
|
+
async function hkdf(digest, key, salt, info, length) {
|
|
63
|
+
return await new Promise((resolve, reject) => {
|
|
64
|
+
crypto.hkdf(digest, key, salt, info, length, (err, derivedKey) => {
|
|
65
|
+
if (err) {
|
|
66
|
+
reject(err);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
resolve(Buffer.from(derivedKey));
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function generateX25519KeyPair() {
|
|
74
|
+
return await new Promise((resolve, reject) => {
|
|
75
|
+
crypto.generateKeyPair('x25519', undefined, (err, publicKey, privateKey) => {
|
|
76
|
+
if (err) {
|
|
77
|
+
reject(err);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
resolve({ publicKey, privateKey });
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
62
84
|
/**
|
|
63
85
|
* Ed25519 signer for delegation requests
|
|
64
86
|
*/
|
|
@@ -80,7 +102,7 @@ class Ed25519Signer {
|
|
|
80
102
|
if (error instanceof exceptions_1.DelegationCryptoError) {
|
|
81
103
|
throw error;
|
|
82
104
|
}
|
|
83
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
105
|
+
throw new exceptions_1.DelegationCryptoError('Failed to load Ed25519 private key', { cause: error });
|
|
84
106
|
}
|
|
85
107
|
}
|
|
86
108
|
/**
|
|
@@ -97,7 +119,7 @@ class Ed25519Signer {
|
|
|
97
119
|
};
|
|
98
120
|
}
|
|
99
121
|
catch (error) {
|
|
100
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
122
|
+
throw new exceptions_1.DelegationCryptoError('Ed25519 signing failed', { cause: error });
|
|
101
123
|
}
|
|
102
124
|
}
|
|
103
125
|
}
|
|
@@ -123,7 +145,7 @@ class RsaPssSigner {
|
|
|
123
145
|
if (error instanceof exceptions_1.DelegationCryptoError) {
|
|
124
146
|
throw error;
|
|
125
147
|
}
|
|
126
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
148
|
+
throw new exceptions_1.DelegationCryptoError('Failed to load RSA private key', { cause: error });
|
|
127
149
|
}
|
|
128
150
|
}
|
|
129
151
|
/**
|
|
@@ -135,7 +157,7 @@ class RsaPssSigner {
|
|
|
135
157
|
const signature = crypto.sign('sha256', data, {
|
|
136
158
|
key: this.sk,
|
|
137
159
|
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
|
|
138
|
-
saltLength: crypto.constants.
|
|
160
|
+
saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST,
|
|
139
161
|
});
|
|
140
162
|
return {
|
|
141
163
|
alg: this.alg,
|
|
@@ -144,7 +166,7 @@ class RsaPssSigner {
|
|
|
144
166
|
};
|
|
145
167
|
}
|
|
146
168
|
catch (error) {
|
|
147
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
169
|
+
throw new exceptions_1.DelegationCryptoError('RSA-PSS signing failed', { cause: error });
|
|
148
170
|
}
|
|
149
171
|
}
|
|
150
172
|
}
|
|
@@ -168,7 +190,7 @@ class Verifier {
|
|
|
168
190
|
}
|
|
169
191
|
}
|
|
170
192
|
catch (error) {
|
|
171
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
193
|
+
throw new exceptions_1.DelegationCryptoError('Failed to load one or more public keys', { cause: error });
|
|
172
194
|
}
|
|
173
195
|
}
|
|
174
196
|
/**
|
|
@@ -197,7 +219,7 @@ class Verifier {
|
|
|
197
219
|
isValid = crypto.verify('sha256', dataToVerify, {
|
|
198
220
|
key: pub,
|
|
199
221
|
padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
|
|
200
|
-
saltLength: crypto.constants.
|
|
222
|
+
saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST,
|
|
201
223
|
}, sig);
|
|
202
224
|
}
|
|
203
225
|
else {
|
|
@@ -211,7 +233,7 @@ class Verifier {
|
|
|
211
233
|
if (error instanceof exceptions_1.DelegationCryptoError) {
|
|
212
234
|
throw error;
|
|
213
235
|
}
|
|
214
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
236
|
+
throw new exceptions_1.DelegationCryptoError('Signature verification failed', { cause: error });
|
|
215
237
|
}
|
|
216
238
|
}
|
|
217
239
|
}
|
|
@@ -230,42 +252,29 @@ class EciesX25519Encryptor {
|
|
|
230
252
|
if (key.asymmetricKeyType !== 'x25519') {
|
|
231
253
|
throw new exceptions_1.DelegationCryptoError('peer_pub_pem must be an X25519 public key');
|
|
232
254
|
}
|
|
233
|
-
|
|
234
|
-
this.peerPublicKey = key.export({ type: 'spki', format: 'der' }).slice(-32);
|
|
255
|
+
this.peerPublicKey = key;
|
|
235
256
|
}
|
|
236
257
|
catch (error) {
|
|
237
258
|
if (error instanceof exceptions_1.DelegationCryptoError) {
|
|
238
259
|
throw error;
|
|
239
260
|
}
|
|
240
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
261
|
+
throw new exceptions_1.DelegationCryptoError('Failed to load ECIES peer public key', { cause: error });
|
|
241
262
|
}
|
|
242
263
|
}
|
|
243
264
|
/**
|
|
244
265
|
* Encrypt plaintext using ECIES
|
|
245
266
|
*/
|
|
246
|
-
encrypt(plaintext) {
|
|
267
|
+
async encrypt(plaintext) {
|
|
247
268
|
try {
|
|
248
269
|
// Generate ephemeral X25519 keypair
|
|
249
|
-
const
|
|
250
|
-
privateKeyEncoding: { type: 'pkcs8', format: 'pem' },
|
|
251
|
-
publicKeyEncoding: { type: 'spki', format: 'pem' },
|
|
252
|
-
});
|
|
253
|
-
const ephPrivKey = crypto.createPrivateKey(ephPrivateKey.privateKey);
|
|
254
|
-
const ephPubKey = crypto.createPublicKey(ephPrivateKey.publicKey);
|
|
270
|
+
const { publicKey: ephPubKey, privateKey: ephPrivKey } = await generateX25519KeyPair();
|
|
255
271
|
// Perform ECDH
|
|
256
272
|
const shared = crypto.diffieHellman({
|
|
257
273
|
privateKey: ephPrivKey,
|
|
258
|
-
publicKey:
|
|
259
|
-
key: Buffer.concat([
|
|
260
|
-
Buffer.from([0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e, 0x03, 0x21, 0x00]),
|
|
261
|
-
this.peerPublicKey,
|
|
262
|
-
]),
|
|
263
|
-
format: 'der',
|
|
264
|
-
type: 'spki',
|
|
265
|
-
}),
|
|
274
|
+
publicKey: this.peerPublicKey,
|
|
266
275
|
});
|
|
267
276
|
// Derive AES key using HKDF
|
|
268
|
-
const key =
|
|
277
|
+
const key = await hkdf('sha256', shared, Buffer.alloc(0), Buffer.from('idp-sp-ecies-v1'), 32);
|
|
269
278
|
// Encrypt with AES-GCM
|
|
270
279
|
const nonce = crypto.randomBytes(12);
|
|
271
280
|
const cipher = crypto.createCipheriv('aes-256-gcm', Buffer.from(key), nonce);
|
|
@@ -283,7 +292,7 @@ class EciesX25519Encryptor {
|
|
|
283
292
|
return Buffer.from(JSON.stringify(envelope));
|
|
284
293
|
}
|
|
285
294
|
catch (error) {
|
|
286
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
295
|
+
throw new exceptions_1.DelegationCryptoError('ECIES encryption failed', { cause: error });
|
|
287
296
|
}
|
|
288
297
|
}
|
|
289
298
|
}
|
|
@@ -306,13 +315,13 @@ class EciesX25519Decryptor {
|
|
|
306
315
|
if (error instanceof exceptions_1.DelegationCryptoError) {
|
|
307
316
|
throw error;
|
|
308
317
|
}
|
|
309
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
318
|
+
throw new exceptions_1.DelegationCryptoError('Failed to load ECIES private key', { cause: error });
|
|
310
319
|
}
|
|
311
320
|
}
|
|
312
321
|
/**
|
|
313
322
|
* Decrypt ECIES envelope
|
|
314
323
|
*/
|
|
315
|
-
decrypt(envelopeJson) {
|
|
324
|
+
async decrypt(envelopeJson) {
|
|
316
325
|
try {
|
|
317
326
|
const envelope = JSON.parse(envelopeJson.toString('utf-8'));
|
|
318
327
|
if (envelope.enc !== 'x25519-aesgcm') {
|
|
@@ -340,7 +349,7 @@ class EciesX25519Decryptor {
|
|
|
340
349
|
publicKey: epk,
|
|
341
350
|
});
|
|
342
351
|
// Derive AES key using HKDF
|
|
343
|
-
const key =
|
|
352
|
+
const key = await hkdf('sha256', shared, Buffer.alloc(0), Buffer.from('idp-sp-ecies-v1'), 32);
|
|
344
353
|
// Decrypt with AES-GCM
|
|
345
354
|
const decipher = crypto.createDecipheriv('aes-256-gcm', Buffer.from(key), nonce);
|
|
346
355
|
decipher.setAuthTag(tag);
|
|
@@ -348,7 +357,7 @@ class EciesX25519Decryptor {
|
|
|
348
357
|
return plaintext;
|
|
349
358
|
}
|
|
350
359
|
catch (error) {
|
|
351
|
-
throw new exceptions_1.DelegationCryptoError(
|
|
360
|
+
throw new exceptions_1.DelegationCryptoError('ECIES decryption failed', { cause: error });
|
|
352
361
|
}
|
|
353
362
|
}
|
|
354
363
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/delegation/crypto.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUH,oBAEC;AAVD,+CAAiC;AACjC,6CAAqD;AAErD,4BAA4B;AAE5B;;GAEG;AACH,SAAgB,IAAI;IAClB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,IAAI,CAAC,MAAc;IAC1B,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAS,IAAI,CAAC,GAAW;IACvB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AACvC,CAAC;AAUD;;GAEG;AACH,MAAa,aAAa;IAKxB,YAAY,UAAkB,EAAE,GAAY;QAFrC,QAAG,GAAW,SAAS,CAAC;QAG7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC;YACH,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,gBAAgB,CAAC;gBAChC,GAAG,EAAE,UAAU;gBACf,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;YAEH,sBAAsB;YACtB,IAAI,IAAI,CAAC,EAAE,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;gBAC5C,MAAM,IAAI,kCAAqB,CAAC,4CAA4C,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,kCAAqB,EAAE,CAAC;gBAC3C,MAAM,KAAK,CAAC;YACd,CAAC;YACD,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AI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;YACjF,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACzB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAEzE,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,kCAAqB,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;CACF;AA7ED,oDA6EC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Custom exceptions for the Delegation module
|
|
3
3
|
*/
|
|
4
|
-
import { HawcxOAuthError } from '../
|
|
4
|
+
import { HawcxOAuthError } from '../errors';
|
|
5
5
|
/**
|
|
6
6
|
* Base exception for delegation errors
|
|
7
7
|
*/
|
|
8
|
+
export interface DelegationErrorOptions {
|
|
9
|
+
cause?: unknown;
|
|
10
|
+
}
|
|
8
11
|
export declare class DelegationError extends HawcxOAuthError {
|
|
9
|
-
|
|
12
|
+
readonly cause?: unknown;
|
|
13
|
+
constructor(message: string, options?: DelegationErrorOptions);
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
16
|
* Raised for cryptographic errors (signing, encryption, etc.)
|
|
13
17
|
*/
|
|
14
18
|
export declare class DelegationCryptoError extends DelegationError {
|
|
15
|
-
constructor(message: string);
|
|
19
|
+
constructor(message: string, options?: DelegationErrorOptions);
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* Raised for errors sending requests to the IDP
|
|
@@ -20,13 +24,16 @@ export declare class DelegationCryptoError extends DelegationError {
|
|
|
20
24
|
export declare class DelegationRequestError extends DelegationError {
|
|
21
25
|
statusCode?: number;
|
|
22
26
|
responseBody?: string;
|
|
23
|
-
constructor(message: string,
|
|
27
|
+
constructor(message: string, options?: DelegationErrorOptions & {
|
|
28
|
+
statusCode?: number;
|
|
29
|
+
responseBody?: string;
|
|
30
|
+
});
|
|
24
31
|
toString(): string;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Raised for errors in the IDP's response
|
|
28
35
|
*/
|
|
29
36
|
export declare class DelegationResponseError extends DelegationError {
|
|
30
|
-
constructor(message: string);
|
|
37
|
+
constructor(message: string, options?: DelegationErrorOptions);
|
|
31
38
|
}
|
|
32
39
|
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/delegation/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/delegation/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,eAAgB,SAAQ,eAAe;IAClD,SAAgB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B;CAMlE;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;gBAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B;CAKlE;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,eAAe;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;gBAGpB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,sBAAsB,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAO;IASvF,QAAQ,IAAI,MAAM;CAOnB;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;gBAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B;CAKlE"}
|
|
@@ -4,14 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DelegationResponseError = exports.DelegationRequestError = exports.DelegationCryptoError = exports.DelegationError = void 0;
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
class DelegationError extends exceptions_1.HawcxOAuthError {
|
|
12
|
-
constructor(message) {
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
class DelegationError extends errors_1.HawcxOAuthError {
|
|
9
|
+
constructor(message, options = {}) {
|
|
13
10
|
super(message);
|
|
14
11
|
this.name = 'DelegationError';
|
|
12
|
+
this.cause = options.cause;
|
|
15
13
|
Object.setPrototypeOf(this, DelegationError.prototype);
|
|
16
14
|
}
|
|
17
15
|
}
|
|
@@ -20,8 +18,8 @@ exports.DelegationError = DelegationError;
|
|
|
20
18
|
* Raised for cryptographic errors (signing, encryption, etc.)
|
|
21
19
|
*/
|
|
22
20
|
class DelegationCryptoError extends DelegationError {
|
|
23
|
-
constructor(message) {
|
|
24
|
-
super(message);
|
|
21
|
+
constructor(message, options = {}) {
|
|
22
|
+
super(message, options);
|
|
25
23
|
this.name = 'DelegationCryptoError';
|
|
26
24
|
Object.setPrototypeOf(this, DelegationCryptoError.prototype);
|
|
27
25
|
}
|
|
@@ -31,11 +29,11 @@ exports.DelegationCryptoError = DelegationCryptoError;
|
|
|
31
29
|
* Raised for errors sending requests to the IDP
|
|
32
30
|
*/
|
|
33
31
|
class DelegationRequestError extends DelegationError {
|
|
34
|
-
constructor(message,
|
|
35
|
-
super(message);
|
|
32
|
+
constructor(message, options = {}) {
|
|
33
|
+
super(message, options);
|
|
36
34
|
this.name = 'DelegationRequestError';
|
|
37
|
-
this.statusCode = statusCode;
|
|
38
|
-
this.responseBody = responseBody;
|
|
35
|
+
this.statusCode = options.statusCode;
|
|
36
|
+
this.responseBody = options.responseBody;
|
|
39
37
|
Object.setPrototypeOf(this, DelegationRequestError.prototype);
|
|
40
38
|
}
|
|
41
39
|
toString() {
|
|
@@ -51,8 +49,8 @@ exports.DelegationRequestError = DelegationRequestError;
|
|
|
51
49
|
* Raised for errors in the IDP's response
|
|
52
50
|
*/
|
|
53
51
|
class DelegationResponseError extends DelegationError {
|
|
54
|
-
constructor(message) {
|
|
55
|
-
super(message);
|
|
52
|
+
constructor(message, options = {}) {
|
|
53
|
+
super(message, options);
|
|
56
54
|
this.name = 'DelegationResponseError';
|
|
57
55
|
Object.setPrototypeOf(this, DelegationResponseError.prototype);
|
|
58
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/delegation/exceptions.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../src/delegation/exceptions.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAA4C;AAS5C,MAAa,eAAgB,SAAQ,wBAAe;IAGlD,YAAY,OAAe,EAAE,UAAkC,EAAE;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;CACF;AATD,0CASC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,eAAe;IACxD,YAAY,OAAe,EAAE,UAAkC,EAAE;QAC/D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;CACF;AAND,sDAMC;AAED;;GAEG;AACH,MAAa,sBAAuB,SAAQ,eAAe;IAIzD,YACE,OAAe,EACf,UAAmF,EAAE;QAErF,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC;QACxB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,GAAG,GAAG,IAAI,UAAU,IAAI,CAAC,UAAU,GAAG,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtBD,wDAsBC;AAED;;GAEG;AACH,MAAa,uBAAwB,SAAQ,eAAe;IAC1D,YAAY,OAAe,EAAE,UAAkC,EAAE;QAC/D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;CACF;AAND,0DAMC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DelegationTransport } from './transport';
|
|
2
|
+
export interface DelegationKeyMaterial {
|
|
3
|
+
spSigningKey: string;
|
|
4
|
+
spEncryptionKey: string;
|
|
5
|
+
idpVerifyKey: string;
|
|
6
|
+
idpEncryptionKey: string;
|
|
7
|
+
spKid: string;
|
|
8
|
+
idpKid: string;
|
|
9
|
+
signingAlg?: 'ed25519' | 'rsa-pss-sha256';
|
|
10
|
+
}
|
|
11
|
+
export interface DelegationTransportBaseOptions {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
timeoutSeconds?: number;
|
|
14
|
+
clockSkewSeconds?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function buildTransportFromSecretKey(options: DelegationTransportBaseOptions & {
|
|
17
|
+
secretKey: string;
|
|
18
|
+
}): DelegationTransport;
|
|
19
|
+
export declare function buildTransportFromKeys(options: DelegationTransportBaseOptions & DelegationKeyMaterial): DelegationTransport;
|
|
20
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/delegation/factory.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAA8B,MAAM,aAAa,CAAC;AAE9E,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC;CAC3C;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,8BAA8B,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAC9D,mBAAmB,CAqBrB;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,8BAA8B,GAAG,qBAAqB,GAC9D,mBAAmB,CAoCrB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildTransportFromSecretKey = buildTransportFromSecretKey;
|
|
4
|
+
exports.buildTransportFromKeys = buildTransportFromKeys;
|
|
5
|
+
const crypto_1 = require("./crypto");
|
|
6
|
+
const credentials_1 = require("./credentials");
|
|
7
|
+
const exceptions_1 = require("./exceptions");
|
|
8
|
+
const transport_1 = require("./transport");
|
|
9
|
+
function buildTransportFromSecretKey(options) {
|
|
10
|
+
const { baseUrl, timeoutSeconds, clockSkewSeconds, secretKey } = options;
|
|
11
|
+
const creds = (0, credentials_1.parseHawcxSecretKey)(secretKey);
|
|
12
|
+
const signer = new crypto_1.Ed25519Signer(creds.signingKeyPem, creds.kid);
|
|
13
|
+
const verifier = new crypto_1.Verifier({ [creds.hkid]: creds.verifyKeyPem });
|
|
14
|
+
const encryptor = new crypto_1.EciesX25519Encryptor(creds.encryptKeyPem);
|
|
15
|
+
const decryptor = new crypto_1.EciesX25519Decryptor(creds.decryptKeyPem);
|
|
16
|
+
const transportOptions = {
|
|
17
|
+
baseUrl,
|
|
18
|
+
signer,
|
|
19
|
+
verifier,
|
|
20
|
+
encryptor,
|
|
21
|
+
decryptor,
|
|
22
|
+
timeoutSeconds,
|
|
23
|
+
clockSkewSeconds,
|
|
24
|
+
};
|
|
25
|
+
return new transport_1.DelegationTransport(transportOptions);
|
|
26
|
+
}
|
|
27
|
+
function buildTransportFromKeys(options) {
|
|
28
|
+
const { baseUrl, timeoutSeconds, clockSkewSeconds, spSigningKey, spEncryptionKey, idpVerifyKey, idpEncryptionKey, spKid, idpKid, } = options;
|
|
29
|
+
if (!spKid || !idpKid) {
|
|
30
|
+
throw new exceptions_1.DelegationCryptoError('spKid and idpKid are required for key-based initialization');
|
|
31
|
+
}
|
|
32
|
+
const signer = options.signingAlg === 'rsa-pss-sha256'
|
|
33
|
+
? new crypto_1.RsaPssSigner(spSigningKey, spKid)
|
|
34
|
+
: new crypto_1.Ed25519Signer(spSigningKey, spKid);
|
|
35
|
+
const verifier = new crypto_1.Verifier({ [idpKid]: idpVerifyKey });
|
|
36
|
+
const encryptor = new crypto_1.EciesX25519Encryptor(idpEncryptionKey);
|
|
37
|
+
const decryptor = new crypto_1.EciesX25519Decryptor(spEncryptionKey);
|
|
38
|
+
const transportOptions = {
|
|
39
|
+
baseUrl,
|
|
40
|
+
signer,
|
|
41
|
+
verifier,
|
|
42
|
+
encryptor,
|
|
43
|
+
decryptor,
|
|
44
|
+
timeoutSeconds,
|
|
45
|
+
clockSkewSeconds,
|
|
46
|
+
};
|
|
47
|
+
return new transport_1.DelegationTransport(transportOptions);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/delegation/factory.ts"],"names":[],"mappings":";;AA2BA,kEAuBC;AAED,wDAsCC;AA1FD,qCAMkB;AAClB,+CAAoD;AACpD,6CAAqD;AACrD,2CAA8E;AAkB9E,SAAgB,2BAA2B,CACzC,OAA+D;IAE/D,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzE,MAAM,KAAK,GAAG,IAAA,iCAAmB,EAAC,SAAS,CAAC,CAAC;IAE7C,MAAM,MAAM,GAAG,IAAI,sBAAa,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,IAAI,iBAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,IAAI,6BAAoB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,IAAI,6BAAoB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEhE,MAAM,gBAAgB,GAA+B;QACnD,OAAO;QACP,MAAM;QACN,QAA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