@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
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Client for sending secure, ECIES-encrypted and signed delegation requests to an IDP
|
|
3
|
-
*/
|
|
4
|
-
import { Verifier, EciesX25519Encryptor, EciesX25519Decryptor, Ed25519Signer, RsaPssSigner } from './crypto';
|
|
5
|
-
export type Signer = Ed25519Signer | RsaPssSigner;
|
|
6
|
-
/**
|
|
7
|
-
* Options for sending secure delegation requests
|
|
8
|
-
*/
|
|
9
|
-
export interface SecureRequestOptions {
|
|
10
|
-
/** API endpoint path (e.g., "/mfa/update" or "/device/revoke") */
|
|
11
|
-
endpoint: string;
|
|
12
|
-
/** Request payload dictionary to be encrypted and sent */
|
|
13
|
-
payload: Record<string, any>;
|
|
14
|
-
/** If true, prepends base_url to endpoint (default: true) */
|
|
15
|
-
includeBaseUrl?: boolean;
|
|
16
|
-
/** Optional additional HTTP headers (e.g., API keys) */
|
|
17
|
-
extraHeaders?: Record<string, string>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Client for sending secure, ECIES-encrypted and signed delegation requests to an IDP.
|
|
21
|
-
*/
|
|
22
|
-
export declare class IdpDelegationClient {
|
|
23
|
-
private baseUrl;
|
|
24
|
-
private signer;
|
|
25
|
-
private verifier;
|
|
26
|
-
private encryptor;
|
|
27
|
-
private decryptor;
|
|
28
|
-
private spId;
|
|
29
|
-
private timeout;
|
|
30
|
-
constructor(options: {
|
|
31
|
-
baseUrl: string;
|
|
32
|
-
signer: Signer;
|
|
33
|
-
verifier: Verifier;
|
|
34
|
-
encryptor: EciesX25519Encryptor;
|
|
35
|
-
decryptor: EciesX25519Decryptor;
|
|
36
|
-
spId: string;
|
|
37
|
-
timeout?: number;
|
|
38
|
-
});
|
|
39
|
-
/**
|
|
40
|
-
* Send an encrypted and signed delegation request to the IDP.
|
|
41
|
-
*
|
|
42
|
-
* This method automatically handles all cryptographic operations:
|
|
43
|
-
* - ECIES (X25519 + AES-GCM) encryption of the request payload
|
|
44
|
-
* - Ed25519/RSA-PSS detached signature generation
|
|
45
|
-
* - HTTP header construction with delegation metadata
|
|
46
|
-
* - Response signature verification
|
|
47
|
-
* - ECIES decryption of the response
|
|
48
|
-
*
|
|
49
|
-
* @param options - Request configuration options
|
|
50
|
-
* @returns Decrypted and verified response dictionary from the IDP
|
|
51
|
-
* @throws DelegationRequestError - If request preparation or sending fails
|
|
52
|
-
* @throws DelegationResponseError - If response verification or decryption fails
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* // Initialize client
|
|
57
|
-
* const client = new IdpDelegationClient({
|
|
58
|
-
* baseUrl: "https://idp.example.com",
|
|
59
|
-
* signer, verifier,
|
|
60
|
-
* encryptor, decryptor,
|
|
61
|
-
* spId: "my-sp"
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* // Send secure request with automatic crypto
|
|
65
|
-
* const response = await client.sendSecureRequest({
|
|
66
|
-
* endpoint: "/mfa/update",
|
|
67
|
-
* payload: {
|
|
68
|
-
* userid: "user@example.com",
|
|
69
|
-
* mfa_method: "sms",
|
|
70
|
-
* contact: "+15551234567"
|
|
71
|
-
* }
|
|
72
|
-
* });
|
|
73
|
-
* console.log(response); // { success: true, session_id: '...' }
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* Security Notes:
|
|
77
|
-
* - All requests are encrypted with ECIES (X25519 + AES-GCM)
|
|
78
|
-
* - All requests include a detached signature (Ed25519 or RSA-PSS)
|
|
79
|
-
* - All responses are verified and decrypted automatically
|
|
80
|
-
* - Timestamps are included to prevent replay attacks
|
|
81
|
-
*/
|
|
82
|
-
sendSecureRequest(options: SecureRequestOptions): Promise<Record<string, any>>;
|
|
83
|
-
/**
|
|
84
|
-
* Request an MFA method update for a user.
|
|
85
|
-
*
|
|
86
|
-
* @param options - MFA update configuration
|
|
87
|
-
* @returns The decrypted acknowledgment response from the IDP
|
|
88
|
-
*/
|
|
89
|
-
mfaUpdate(options: {
|
|
90
|
-
userId: string;
|
|
91
|
-
method: string;
|
|
92
|
-
enabled: boolean;
|
|
93
|
-
reason: string;
|
|
94
|
-
requestedBy?: string;
|
|
95
|
-
}): Promise<Record<string, any>>;
|
|
96
|
-
/**
|
|
97
|
-
* Request the current MFA status for a user.
|
|
98
|
-
*
|
|
99
|
-
* @param userId - The ID of the user to query
|
|
100
|
-
* @returns The decrypted acknowledgment response from the IDP containing the MFA status
|
|
101
|
-
*/
|
|
102
|
-
mfaGetStatus(userId: string): Promise<Record<string, any>>;
|
|
103
|
-
/**
|
|
104
|
-
* Request to revoke a user's device.
|
|
105
|
-
*
|
|
106
|
-
* @param options - Device revocation configuration
|
|
107
|
-
* @returns The decrypted acknowledgment response from the IDP
|
|
108
|
-
*/
|
|
109
|
-
deviceRevoke(options: {
|
|
110
|
-
userId: string;
|
|
111
|
-
deviceId: string;
|
|
112
|
-
reason: string;
|
|
113
|
-
requestedBy?: string;
|
|
114
|
-
}): Promise<Record<string, any>>;
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/delegation/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAEL,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB,MAAM,MAAM,MAAM,GAAG,aAAa,GAAG,YAAY,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,6DAA6D;IAC7D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,QAAQ,CAAC;QACnB,SAAS,EAAE,oBAAoB,CAAC;QAChC,SAAS,EAAE,oBAAoB,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACG,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAyGpF;;;;;OAKG;IACG,SAAS,CAAC,OAAO,EAAE;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAqBhC;;;;;OAKG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAmBhE;;;;;OAKG;IACG,YAAY,CAAC,OAAO,EAAE;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAoBjC"}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Client for sending secure, ECIES-encrypted and signed delegation requests to an IDP
|
|
4
|
-
*/
|
|
5
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.IdpDelegationClient = void 0;
|
|
10
|
-
const axios_1 = __importDefault(require("axios"));
|
|
11
|
-
const uuid_1 = require("uuid");
|
|
12
|
-
const crypto_1 = require("./crypto");
|
|
13
|
-
const exceptions_1 = require("./exceptions");
|
|
14
|
-
/**
|
|
15
|
-
* Client for sending secure, ECIES-encrypted and signed delegation requests to an IDP.
|
|
16
|
-
*/
|
|
17
|
-
class IdpDelegationClient {
|
|
18
|
-
constructor(options) {
|
|
19
|
-
this.baseUrl = options.baseUrl.replace(/\/$/, '');
|
|
20
|
-
this.signer = options.signer;
|
|
21
|
-
this.verifier = options.verifier;
|
|
22
|
-
this.encryptor = options.encryptor;
|
|
23
|
-
this.decryptor = options.decryptor;
|
|
24
|
-
this.spId = options.spId;
|
|
25
|
-
this.timeout = options.timeout || 15;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Send an encrypted and signed delegation request to the IDP.
|
|
29
|
-
*
|
|
30
|
-
* This method automatically handles all cryptographic operations:
|
|
31
|
-
* - ECIES (X25519 + AES-GCM) encryption of the request payload
|
|
32
|
-
* - Ed25519/RSA-PSS detached signature generation
|
|
33
|
-
* - HTTP header construction with delegation metadata
|
|
34
|
-
* - Response signature verification
|
|
35
|
-
* - ECIES decryption of the response
|
|
36
|
-
*
|
|
37
|
-
* @param options - Request configuration options
|
|
38
|
-
* @returns Decrypted and verified response dictionary from the IDP
|
|
39
|
-
* @throws DelegationRequestError - If request preparation or sending fails
|
|
40
|
-
* @throws DelegationResponseError - If response verification or decryption fails
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* // Initialize client
|
|
45
|
-
* const client = new IdpDelegationClient({
|
|
46
|
-
* baseUrl: "https://idp.example.com",
|
|
47
|
-
* signer, verifier,
|
|
48
|
-
* encryptor, decryptor,
|
|
49
|
-
* spId: "my-sp"
|
|
50
|
-
* });
|
|
51
|
-
*
|
|
52
|
-
* // Send secure request with automatic crypto
|
|
53
|
-
* const response = await client.sendSecureRequest({
|
|
54
|
-
* endpoint: "/mfa/update",
|
|
55
|
-
* payload: {
|
|
56
|
-
* userid: "user@example.com",
|
|
57
|
-
* mfa_method: "sms",
|
|
58
|
-
* contact: "+15551234567"
|
|
59
|
-
* }
|
|
60
|
-
* });
|
|
61
|
-
* console.log(response); // { success: true, session_id: '...' }
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* Security Notes:
|
|
65
|
-
* - All requests are encrypted with ECIES (X25519 + AES-GCM)
|
|
66
|
-
* - All requests include a detached signature (Ed25519 or RSA-PSS)
|
|
67
|
-
* - All responses are verified and decrypted automatically
|
|
68
|
-
* - Timestamps are included to prevent replay attacks
|
|
69
|
-
*/
|
|
70
|
-
async sendSecureRequest(options) {
|
|
71
|
-
const { endpoint, payload, includeBaseUrl = true, extraHeaders = {} } = options;
|
|
72
|
-
let encryptedEnv;
|
|
73
|
-
let headers;
|
|
74
|
-
try {
|
|
75
|
-
// Step 1: Serialize and encrypt the payload
|
|
76
|
-
const body = Buffer.from(JSON.stringify(payload));
|
|
77
|
-
encryptedEnv = this.encryptor.encrypt(body);
|
|
78
|
-
// Step 2: Generate timestamp and signature
|
|
79
|
-
const ts = (0, crypto_1.nowS)();
|
|
80
|
-
const sig = this.signer.signDetached(encryptedEnv, ts);
|
|
81
|
-
// Step 3: Build delegation headers
|
|
82
|
-
headers = {
|
|
83
|
-
'Content-Type': 'application/json',
|
|
84
|
-
'X-Enc-Alg': 'x25519-aesgcm',
|
|
85
|
-
'X-SP-Id': this.spId,
|
|
86
|
-
'X-Timestamp': String(ts),
|
|
87
|
-
'X-Signature-Alg': sig.alg,
|
|
88
|
-
'X-Signature': sig.signatureB64,
|
|
89
|
-
};
|
|
90
|
-
if (sig.kid) {
|
|
91
|
-
headers['X-Key-Id'] = sig.kid;
|
|
92
|
-
}
|
|
93
|
-
// Merge extra headers (e.g., API authentication headers)
|
|
94
|
-
Object.assign(headers, extraHeaders);
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
throw new exceptions_1.DelegationRequestError(`Failed to prepare secure request: ${error}`);
|
|
98
|
-
}
|
|
99
|
-
// Step 4: Send encrypted request to IDP
|
|
100
|
-
let response;
|
|
101
|
-
try {
|
|
102
|
-
const url = includeBaseUrl ? this.baseUrl + endpoint : endpoint;
|
|
103
|
-
response = await axios_1.default.post(url, encryptedEnv, {
|
|
104
|
-
headers,
|
|
105
|
-
timeout: this.timeout * 1000,
|
|
106
|
-
validateStatus: () => true, // Don't throw on any status
|
|
107
|
-
responseType: 'arraybuffer',
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
if (axios_1.default.isAxiosError(error)) {
|
|
112
|
-
throw new exceptions_1.DelegationRequestError(`Request to IDP failed: ${error.message}`);
|
|
113
|
-
}
|
|
114
|
-
throw new exceptions_1.DelegationRequestError(`Request to IDP failed: ${error}`);
|
|
115
|
-
}
|
|
116
|
-
// Step 5: Verify and decrypt response (even for error statuses)
|
|
117
|
-
try {
|
|
118
|
-
const respTs = parseInt(response.headers['x-timestamp'] || String((0, crypto_1.nowS)()));
|
|
119
|
-
const respSig = response.headers['x-signature'];
|
|
120
|
-
const respAlg = response.headers['x-signature-alg'];
|
|
121
|
-
const respKid = response.headers['x-key-id'];
|
|
122
|
-
if (!respSig || !respAlg) {
|
|
123
|
-
throw new exceptions_1.DelegationResponseError('Missing signature headers in IDP response');
|
|
124
|
-
}
|
|
125
|
-
this.verifier.verify(Buffer.from(response.data), respTs, respSig, respAlg, respKid);
|
|
126
|
-
// Step 6: Verify encryption and decrypt response
|
|
127
|
-
if (response.headers['x-enc-alg'] !== 'x25519-aesgcm') {
|
|
128
|
-
throw new exceptions_1.DelegationResponseError('IDP response must be ECIES encrypted');
|
|
129
|
-
}
|
|
130
|
-
const plaintext = this.decryptor.decrypt(Buffer.from(response.data));
|
|
131
|
-
const decryptedData = JSON.parse(plaintext.toString('utf-8'));
|
|
132
|
-
// Now check HTTP status and include decrypted error message if available
|
|
133
|
-
if (response.status >= 400) {
|
|
134
|
-
const errorDetail = decryptedData.detail || JSON.stringify(decryptedData);
|
|
135
|
-
throw new exceptions_1.DelegationRequestError(`IDP returned ${response.status}: ${errorDetail}`, response.status, errorDetail);
|
|
136
|
-
}
|
|
137
|
-
return decryptedData;
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
if (error instanceof exceptions_1.DelegationRequestError) {
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
if (error instanceof exceptions_1.DelegationResponseError) {
|
|
144
|
-
throw error;
|
|
145
|
-
}
|
|
146
|
-
// If we can't decrypt, fall back to raw response
|
|
147
|
-
if (response.status >= 400) {
|
|
148
|
-
const responseText = Buffer.from(response.data).toString('utf-8').substring(0, 500);
|
|
149
|
-
throw new exceptions_1.DelegationRequestError(`IDP returned ${response.status}: ${responseText}`, response.status);
|
|
150
|
-
}
|
|
151
|
-
throw new exceptions_1.DelegationResponseError(`Failed to process secure response: ${error}`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Request an MFA method update for a user.
|
|
156
|
-
*
|
|
157
|
-
* @param options - MFA update configuration
|
|
158
|
-
* @returns The decrypted acknowledgment response from the IDP
|
|
159
|
-
*/
|
|
160
|
-
async mfaUpdate(options) {
|
|
161
|
-
const { userId, method, enabled, reason, requestedBy } = options;
|
|
162
|
-
const payload = {
|
|
163
|
-
v: '1',
|
|
164
|
-
type: 'delegation.request',
|
|
165
|
-
action: 'mfa.update',
|
|
166
|
-
sp: { id: this.spId, kid: this.signer.kid },
|
|
167
|
-
subject: { user_id: userId },
|
|
168
|
-
params: { method, enabled: Boolean(enabled) },
|
|
169
|
-
audit: { reason, requested_by: requestedBy || userId },
|
|
170
|
-
jti: (0, uuid_1.v4)().replace(/-/g, ''),
|
|
171
|
-
iat: (0, crypto_1.nowS)(),
|
|
172
|
-
};
|
|
173
|
-
return this.sendSecureRequest({
|
|
174
|
-
endpoint: '/mfa/update',
|
|
175
|
-
payload,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Request the current MFA status for a user.
|
|
180
|
-
*
|
|
181
|
-
* @param userId - The ID of the user to query
|
|
182
|
-
* @returns The decrypted acknowledgment response from the IDP containing the MFA status
|
|
183
|
-
*/
|
|
184
|
-
async mfaGetStatus(userId) {
|
|
185
|
-
const payload = {
|
|
186
|
-
v: '1',
|
|
187
|
-
type: 'delegation.request',
|
|
188
|
-
action: 'mfa.get_status',
|
|
189
|
-
sp: { id: this.spId, kid: this.signer.kid },
|
|
190
|
-
subject: { user_id: userId },
|
|
191
|
-
params: {},
|
|
192
|
-
audit: { reason: 'User status query', requested_by: userId },
|
|
193
|
-
jti: (0, uuid_1.v4)().replace(/-/g, ''),
|
|
194
|
-
iat: (0, crypto_1.nowS)(),
|
|
195
|
-
};
|
|
196
|
-
return this.sendSecureRequest({
|
|
197
|
-
endpoint: '/mfa/get',
|
|
198
|
-
payload,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Request to revoke a user's device.
|
|
203
|
-
*
|
|
204
|
-
* @param options - Device revocation configuration
|
|
205
|
-
* @returns The decrypted acknowledgment response from the IDP
|
|
206
|
-
*/
|
|
207
|
-
async deviceRevoke(options) {
|
|
208
|
-
const { userId, deviceId, reason, requestedBy } = options;
|
|
209
|
-
const payload = {
|
|
210
|
-
v: '1',
|
|
211
|
-
type: 'delegation.request',
|
|
212
|
-
action: 'device.revoke',
|
|
213
|
-
sp: { id: this.spId, kid: this.signer.kid },
|
|
214
|
-
subject: { user_id: userId, device_id: deviceId },
|
|
215
|
-
params: {},
|
|
216
|
-
audit: { reason, requested_by: requestedBy || userId },
|
|
217
|
-
jti: (0, uuid_1.v4)().replace(/-/g, ''),
|
|
218
|
-
iat: (0, crypto_1.nowS)(),
|
|
219
|
-
};
|
|
220
|
-
return this.sendSecureRequest({
|
|
221
|
-
endpoint: '/device/revoke',
|
|
222
|
-
payload,
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
exports.IdpDelegationClient = IdpDelegationClient;
|
|
227
|
-
//# sourceMappingURL=client.js.map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1B,MAAM,EAAE,eAAe;YACvB,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;YAC3C,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE;YACjD,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,IAAI,MAAM,EAAE;YACtD,GAAG,EAAE,IAAA,SAAM,GAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;YAC/B,GAAG,EAAE,IAAA,aAAI,GAAE;SACZ,CAAC;QAEF,OAAO,IAAI,CAAC,iBAAiB,CAAC;YAC5B,QAAQ,EAAE,gBAAgB;YAC1B,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AAxQD,kDAwQC"}
|
package/dist/exceptions.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom exceptions for the Hawcx OAuth Client SDK
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Base exception for all hawcx_oauth_client errors
|
|
6
|
-
*/
|
|
7
|
-
export declare class HawcxOAuthError extends Error {
|
|
8
|
-
constructor(message: string);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Raised when the OAuth code exchange fails.
|
|
12
|
-
*
|
|
13
|
-
* This can happen due to:
|
|
14
|
-
* - Invalid or expired authorization code
|
|
15
|
-
* - Network connectivity issues
|
|
16
|
-
* - OAuth server errors
|
|
17
|
-
* - Malformed responses
|
|
18
|
-
*/
|
|
19
|
-
export declare class OAuthExchangeError extends HawcxOAuthError {
|
|
20
|
-
statusCode?: number;
|
|
21
|
-
responseBody?: any;
|
|
22
|
-
constructor(message: string, statusCode?: number, responseBody?: any);
|
|
23
|
-
toString(): string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Raised when JWT signature or claims verification fails.
|
|
27
|
-
*
|
|
28
|
-
* This can happen due to:
|
|
29
|
-
* - Invalid JWT signature (tampering detected)
|
|
30
|
-
* - Expired token
|
|
31
|
-
* - Wrong audience or issuer
|
|
32
|
-
* - Token not yet valid (nbf claim)
|
|
33
|
-
* - Malformed JWT structure
|
|
34
|
-
*/
|
|
35
|
-
export declare class JWTVerificationError extends HawcxOAuthError {
|
|
36
|
-
originalError?: Error;
|
|
37
|
-
constructor(message: string, originalError?: Error);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Raised when the provided public key is invalid or unreadable.
|
|
41
|
-
*
|
|
42
|
-
* This can happen due to:
|
|
43
|
-
* - File not found
|
|
44
|
-
* - Invalid PEM format
|
|
45
|
-
* - Wrong key algorithm
|
|
46
|
-
* - Permission denied
|
|
47
|
-
* - Empty key
|
|
48
|
-
*/
|
|
49
|
-
export declare class InvalidPublicKeyError extends HawcxOAuthError {
|
|
50
|
-
constructor(message: string);
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=exceptions.d.ts.map
|
package/dist/exceptions.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAK5B;AAED;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG;IAQpE,QAAQ,IAAI,MAAM;CAOnB;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAqB,SAAQ,eAAe;IACvD,aAAa,CAAC,EAAE,KAAK,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAMnD;AAED;;;;;;;;;GASG;AACH,qBAAa,qBAAsB,SAAQ,eAAe;gBAC5C,OAAO,EAAE,MAAM;CAK5B"}
|
package/dist/exceptions.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Custom exceptions for the Hawcx OAuth Client SDK
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.InvalidPublicKeyError = exports.JWTVerificationError = exports.OAuthExchangeError = exports.HawcxOAuthError = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Base exception for all hawcx_oauth_client errors
|
|
9
|
-
*/
|
|
10
|
-
class HawcxOAuthError extends Error {
|
|
11
|
-
constructor(message) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.name = 'HawcxOAuthError';
|
|
14
|
-
Object.setPrototypeOf(this, HawcxOAuthError.prototype);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.HawcxOAuthError = HawcxOAuthError;
|
|
18
|
-
/**
|
|
19
|
-
* Raised when the OAuth code exchange fails.
|
|
20
|
-
*
|
|
21
|
-
* This can happen due to:
|
|
22
|
-
* - Invalid or expired authorization code
|
|
23
|
-
* - Network connectivity issues
|
|
24
|
-
* - OAuth server errors
|
|
25
|
-
* - Malformed responses
|
|
26
|
-
*/
|
|
27
|
-
class OAuthExchangeError extends HawcxOAuthError {
|
|
28
|
-
constructor(message, statusCode, responseBody) {
|
|
29
|
-
super(message);
|
|
30
|
-
this.name = 'OAuthExchangeError';
|
|
31
|
-
this.statusCode = statusCode;
|
|
32
|
-
this.responseBody = responseBody;
|
|
33
|
-
Object.setPrototypeOf(this, OAuthExchangeError.prototype);
|
|
34
|
-
}
|
|
35
|
-
toString() {
|
|
36
|
-
let base = this.message;
|
|
37
|
-
if (this.statusCode) {
|
|
38
|
-
base = `${base} (HTTP ${this.statusCode})`;
|
|
39
|
-
}
|
|
40
|
-
return base;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.OAuthExchangeError = OAuthExchangeError;
|
|
44
|
-
/**
|
|
45
|
-
* Raised when JWT signature or claims verification fails.
|
|
46
|
-
*
|
|
47
|
-
* This can happen due to:
|
|
48
|
-
* - Invalid JWT signature (tampering detected)
|
|
49
|
-
* - Expired token
|
|
50
|
-
* - Wrong audience or issuer
|
|
51
|
-
* - Token not yet valid (nbf claim)
|
|
52
|
-
* - Malformed JWT structure
|
|
53
|
-
*/
|
|
54
|
-
class JWTVerificationError extends HawcxOAuthError {
|
|
55
|
-
constructor(message, originalError) {
|
|
56
|
-
super(message);
|
|
57
|
-
this.name = 'JWTVerificationError';
|
|
58
|
-
this.originalError = originalError;
|
|
59
|
-
Object.setPrototypeOf(this, JWTVerificationError.prototype);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.JWTVerificationError = JWTVerificationError;
|
|
63
|
-
/**
|
|
64
|
-
* Raised when the provided public key is invalid or unreadable.
|
|
65
|
-
*
|
|
66
|
-
* This can happen due to:
|
|
67
|
-
* - File not found
|
|
68
|
-
* - Invalid PEM format
|
|
69
|
-
* - Wrong key algorithm
|
|
70
|
-
* - Permission denied
|
|
71
|
-
* - Empty key
|
|
72
|
-
*/
|
|
73
|
-
class InvalidPublicKeyError extends HawcxOAuthError {
|
|
74
|
-
constructor(message) {
|
|
75
|
-
super(message);
|
|
76
|
-
this.name = 'InvalidPublicKeyError';
|
|
77
|
-
Object.setPrototypeOf(this, InvalidPublicKeyError.prototype);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.InvalidPublicKeyError = InvalidPublicKeyError;
|
|
81
|
-
//# sourceMappingURL=exceptions.js.map
|
package/dist/exceptions.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":";AAAA;;GAEG;;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,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;CACF;AAND,sDAMC"}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal utilities for the Hawcx OAuth Client SDK
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Load public key from string or file.
|
|
6
|
-
*
|
|
7
|
-
* @param keyInput - Either a PEM-formatted public key string or a path to a key file
|
|
8
|
-
* @returns PEM-formatted public key string
|
|
9
|
-
* @throws InvalidPublicKeyError if the key cannot be loaded or is invalid
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // From file
|
|
14
|
-
* const key = loadPublicKey('keys/public.pem');
|
|
15
|
-
*
|
|
16
|
-
* // From string
|
|
17
|
-
* const key = loadPublicKey(process.env.PUBLIC_KEY!);
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function loadPublicKey(keyInput: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Fetch JWKS (JSON Web Key Set) from a URL with caching.
|
|
23
|
-
*
|
|
24
|
-
* @param jwksUrl - URL to fetch JWKS from (e.g., https://example.com/.well-known/jwks.json)
|
|
25
|
-
* @param timeout - Request timeout in milliseconds (default: 10000)
|
|
26
|
-
* @param ttl - Cache TTL in milliseconds (default: 3600000)
|
|
27
|
-
* @returns JWKS object containing 'keys' array
|
|
28
|
-
* @throws InvalidPublicKeyError if JWKS cannot be fetched or is invalid
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const jwks = await fetchJwks('https://example.com/.well-known/jwks.json');
|
|
33
|
-
* console.log(jwks.keys[0].kid);
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function fetchJwks(jwksUrl: string, timeout?: number, ttl?: number): Promise<any>;
|
|
37
|
-
/**
|
|
38
|
-
* Extract a public key from JWKS and convert to PEM format.
|
|
39
|
-
*
|
|
40
|
-
* @param jwks - JWKS object (must contain 'keys' array)
|
|
41
|
-
* @param kid - Key ID to search for (optional). If not provided, uses first key.
|
|
42
|
-
* @returns PEM-formatted public key string
|
|
43
|
-
* @throws InvalidPublicKeyError if key cannot be found or converted
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* const jwks = await fetchJwks('https://example.com/.well-known/jwks.json');
|
|
48
|
-
* const pemKey = getKeyFromJwks(jwks, 'key-123');
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export declare function getKeyFromJwks(jwks: any, kid?: string): string;
|
|
52
|
-
/**
|
|
53
|
-
* Convert a JWK (JSON Web Key) to PEM format.
|
|
54
|
-
* Supports RSA and EC (Elliptic Curve) keys.
|
|
55
|
-
*
|
|
56
|
-
* @param jwk - JWK object
|
|
57
|
-
* @returns PEM-formatted public key string
|
|
58
|
-
* @throws InvalidPublicKeyError if JWK cannot be converted
|
|
59
|
-
*/
|
|
60
|
-
export declare function jwkToPem(jwk: any): string;
|
|
61
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgCtD;AAuCD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAc,EACvB,GAAG,GAAE,MAAuB,GAC3B,OAAO,CAAC,GAAG,CAAC,CA2Cd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAyB9D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CA+BzC"}
|