@hawcx/oauth-client 0.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/LICENSE +22 -0
- package/README.md +304 -0
- package/dist/client.d.ts +134 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +301 -0
- package/dist/client.js.map +1 -0
- package/dist/delegation/client.d.ts +116 -0
- package/dist/delegation/client.d.ts.map +1 -0
- package/dist/delegation/client.js +227 -0
- package/dist/delegation/client.js.map +1 -0
- package/dist/delegation/crypto.d.ts +72 -0
- package/dist/delegation/crypto.d.ts.map +1 -0
- package/dist/delegation/crypto.js +356 -0
- package/dist/delegation/crypto.js.map +1 -0
- package/dist/delegation/exceptions.d.ts +32 -0
- package/dist/delegation/exceptions.d.ts.map +1 -0
- package/dist/delegation/exceptions.js +61 -0
- package/dist/delegation/exceptions.js.map +1 -0
- package/dist/delegation/hawcx.d.ts +254 -0
- package/dist/delegation/hawcx.d.ts.map +1 -0
- package/dist/delegation/hawcx.js +326 -0
- package/dist/delegation/hawcx.js.map +1 -0
- package/dist/delegation/index.d.ts +14 -0
- package/dist/delegation/index.d.ts.map +1 -0
- package/dist/delegation/index.js +30 -0
- package/dist/delegation/index.js.map +1 -0
- package/dist/exceptions.d.ts +52 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +81 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +61 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +263 -0
- package/dist/utils.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hawcx-specific delegation client with high-level convenience methods.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a streamlined API for common Hawcx operations like
|
|
5
|
+
* MFA configuration, user management, and device operations. All cryptographic
|
|
6
|
+
* operations (encryption, signing, verification) are handled automatically.
|
|
7
|
+
*/
|
|
8
|
+
import { Signer } from './client';
|
|
9
|
+
import { Verifier, EciesX25519Encryptor, EciesX25519Decryptor } from './crypto';
|
|
10
|
+
/**
|
|
11
|
+
* Supported MFA methods for Hawcx authentication.
|
|
12
|
+
*
|
|
13
|
+
* This enum ensures type safety and prevents typos when specifying MFA methods.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { MfaMethod } from '@hawcx/oauth-client';
|
|
18
|
+
*
|
|
19
|
+
* // Use enum for type safety
|
|
20
|
+
* await client.initiateMfaChange({
|
|
21
|
+
* userid: "user@example.com",
|
|
22
|
+
* mfaMethod: MfaMethod.SMS, // Type-safe!
|
|
23
|
+
* phoneNumber: "+15551234567"
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // String values still work for backwards compatibility
|
|
27
|
+
* await client.initiateMfaChange({
|
|
28
|
+
* userid: "user@example.com",
|
|
29
|
+
* mfaMethod: "sms", // Also works
|
|
30
|
+
* phoneNumber: "+15551234567"
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare enum MfaMethod {
|
|
35
|
+
EMAIL = "email",
|
|
36
|
+
SMS = "sms",
|
|
37
|
+
TOTP = "totp"
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Options for initializing Hawcx delegation client from keys
|
|
41
|
+
*/
|
|
42
|
+
export interface HawcxClientFromKeysOptions {
|
|
43
|
+
/** Service Provider's Ed25519 private key (PEM format) */
|
|
44
|
+
spSigningKey: string;
|
|
45
|
+
/** Service Provider's X25519 private key (PEM format) */
|
|
46
|
+
spEncryptionKey: string;
|
|
47
|
+
/** IDP's Ed25519 public key (PEM format) */
|
|
48
|
+
idpVerifyKey: string;
|
|
49
|
+
/** IDP's X25519 public key (PEM format) */
|
|
50
|
+
idpEncryptionKey: string;
|
|
51
|
+
/** Hawcx API base URL (e.g., "https://ceasar-api.hawcx.com") */
|
|
52
|
+
baseUrl: string;
|
|
53
|
+
/** Service Provider identifier (usually OAuth client_id) */
|
|
54
|
+
spId: string;
|
|
55
|
+
/** Optional Hawcx API key */
|
|
56
|
+
apiKey?: string;
|
|
57
|
+
/** Request timeout in seconds (default: 15) */
|
|
58
|
+
timeout?: number;
|
|
59
|
+
/** Internal - Key ID for SP signatures (default: "hawcx", do not change) */
|
|
60
|
+
kid?: string;
|
|
61
|
+
/** Internal - Key ID for IDP verification (default: "hawcx", do not change) */
|
|
62
|
+
idpKid?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Options for initiating MFA change
|
|
66
|
+
*/
|
|
67
|
+
export interface InitiateMfaChangeOptions {
|
|
68
|
+
/** User identifier (typically email address) */
|
|
69
|
+
userid: string;
|
|
70
|
+
/** MFA method to configure (MfaMethod enum or 'email', 'sms', 'totp' string) */
|
|
71
|
+
mfaMethod: MfaMethod | string;
|
|
72
|
+
/** Phone number with country code (required for SMS, e.g., "+15551234567") */
|
|
73
|
+
phoneNumber?: string;
|
|
74
|
+
/** Target MFA method after verification (optional) */
|
|
75
|
+
mfaChangeTo?: MfaMethod | string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Options for verifying MFA change
|
|
79
|
+
*/
|
|
80
|
+
export interface VerifyMfaChangeOptions {
|
|
81
|
+
/** User identifier (must match initiate request) */
|
|
82
|
+
userid: string;
|
|
83
|
+
/** Session ID from initiateMfaChange response */
|
|
84
|
+
sessionId: string;
|
|
85
|
+
/** One-time password entered by user (6 digits) */
|
|
86
|
+
otp: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* High-level client for Hawcx delegation operations.
|
|
90
|
+
*
|
|
91
|
+
* This client provides simplified methods for common Hawcx operations:
|
|
92
|
+
* - MFA configuration (email, SMS, TOTP)
|
|
93
|
+
* - User credential management
|
|
94
|
+
* - Device operations
|
|
95
|
+
*
|
|
96
|
+
* All requests are automatically encrypted (ECIES) and signed (Ed25519/RSA-PSS).
|
|
97
|
+
* All responses are automatically verified and decrypted.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* // Initialize from keys
|
|
102
|
+
* const client = HawcxDelegationClient.fromKeys({
|
|
103
|
+
* spSigningKey: process.env.SP_SIGNING_KEY!,
|
|
104
|
+
* spEncryptionKey: process.env.SP_ENCRYPTION_KEY!,
|
|
105
|
+
* idpVerifyKey: process.env.IDP_VERIFY_KEY!,
|
|
106
|
+
* idpEncryptionKey: process.env.IDP_ENCRYPTION_KEY!,
|
|
107
|
+
* baseUrl: 'https://ceasar-api.hawcx.com',
|
|
108
|
+
* spId: 'my-client-id'
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* // Initiate SMS MFA setup
|
|
112
|
+
* const result = await client.initiateMfaChange({
|
|
113
|
+
* userid: "user@example.com",
|
|
114
|
+
* mfaMethod: "sms",
|
|
115
|
+
* phoneNumber: "+15551234567"
|
|
116
|
+
* });
|
|
117
|
+
* console.log(result.session_id);
|
|
118
|
+
*
|
|
119
|
+
* // Verify OTP
|
|
120
|
+
* await client.verifyMfaChange({
|
|
121
|
+
* userid: "user@example.com",
|
|
122
|
+
* sessionId: result.session_id,
|
|
123
|
+
* otp: "123456"
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare class HawcxDelegationClient {
|
|
128
|
+
private client;
|
|
129
|
+
private apiKey?;
|
|
130
|
+
baseUrl: string;
|
|
131
|
+
spId: string;
|
|
132
|
+
constructor(options: {
|
|
133
|
+
baseUrl: string;
|
|
134
|
+
signer: Signer;
|
|
135
|
+
verifier: Verifier;
|
|
136
|
+
encryptor: EciesX25519Encryptor;
|
|
137
|
+
decryptor: EciesX25519Decryptor;
|
|
138
|
+
spId: string;
|
|
139
|
+
apiKey?: string;
|
|
140
|
+
timeout?: number;
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* Create client from explicit key values (recommended).
|
|
144
|
+
*
|
|
145
|
+
* This method allows the application to load keys from any source
|
|
146
|
+
* (env vars, config files, secrets manager, etc.) and pass them
|
|
147
|
+
* as values to the SDK.
|
|
148
|
+
*
|
|
149
|
+
* @param options - Configuration options
|
|
150
|
+
* @returns Configured HawcxDelegationClient instance
|
|
151
|
+
* @throws DelegationRequestError if key initialization fails
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* import * as process from 'process';
|
|
156
|
+
*
|
|
157
|
+
* // App controls how to load keys
|
|
158
|
+
* const client = HawcxDelegationClient.fromKeys({
|
|
159
|
+
* spSigningKey: process.env.MY_SIGNING_KEY!,
|
|
160
|
+
* spEncryptionKey: process.env.MY_ENCRYPTION_KEY!,
|
|
161
|
+
* idpVerifyKey: process.env.IDP_VERIFY_KEY!,
|
|
162
|
+
* idpEncryptionKey: process.env.IDP_ENCRYPT_KEY!,
|
|
163
|
+
* baseUrl: process.env.HAWCX_URL!,
|
|
164
|
+
* spId: process.env.MY_CLIENT_ID!
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
static fromKeys(options: HawcxClientFromKeysOptions): HawcxDelegationClient;
|
|
169
|
+
/**
|
|
170
|
+
* Build Hawcx API authentication headers
|
|
171
|
+
*/
|
|
172
|
+
private buildAuthHeaders;
|
|
173
|
+
/**
|
|
174
|
+
* Initiate MFA setup or change for a user.
|
|
175
|
+
*
|
|
176
|
+
* This method starts the MFA enrollment/update process by sending an OTP
|
|
177
|
+
* to the user via their chosen method (email, SMS, or generating a TOTP secret).
|
|
178
|
+
*
|
|
179
|
+
* @param options - MFA initiation configuration
|
|
180
|
+
* @returns Dictionary containing session_id and optional TOTP details
|
|
181
|
+
* @throws DelegationRequestError if request fails or parameters are invalid
|
|
182
|
+
* @throws Error if SMS method specified without phone_number
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* import { MfaMethod } from '@hawcx/oauth-client';
|
|
187
|
+
*
|
|
188
|
+
* // Email MFA (with enum - recommended!)
|
|
189
|
+
* const result = await client.initiateMfaChange({
|
|
190
|
+
* userid: "user@example.com",
|
|
191
|
+
* mfaMethod: MfaMethod.EMAIL
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* // SMS MFA (string also works)
|
|
195
|
+
* const result = await client.initiateMfaChange({
|
|
196
|
+
* userid: "user@example.com",
|
|
197
|
+
* mfaMethod: "sms",
|
|
198
|
+
* phoneNumber: "+15551234567"
|
|
199
|
+
* });
|
|
200
|
+
*
|
|
201
|
+
* // TOTP MFA
|
|
202
|
+
* const result = await client.initiateMfaChange({
|
|
203
|
+
* userid: "user@example.com",
|
|
204
|
+
* mfaMethod: MfaMethod.TOTP
|
|
205
|
+
* });
|
|
206
|
+
* console.log(`Scan QR code: ${result.otpauth_uri}`);
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
initiateMfaChange(options: InitiateMfaChangeOptions): Promise<Record<string, any>>;
|
|
210
|
+
/**
|
|
211
|
+
* Verify OTP and complete MFA configuration change.
|
|
212
|
+
*
|
|
213
|
+
* This method verifies the OTP sent to the user and completes the MFA
|
|
214
|
+
* enrollment/update process.
|
|
215
|
+
*
|
|
216
|
+
* @param options - MFA verification configuration
|
|
217
|
+
* @returns Dictionary containing success message and optional mfa_changed_to
|
|
218
|
+
* @throws DelegationRequestError if verification fails
|
|
219
|
+
* @throws Error if OTP format is invalid
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* // Get OTP from user
|
|
224
|
+
* const otp = getUserInput();
|
|
225
|
+
*
|
|
226
|
+
* // Verify and complete MFA setup
|
|
227
|
+
* const result = await client.verifyMfaChange({
|
|
228
|
+
* userid: "user@example.com",
|
|
229
|
+
* sessionId: sessionId,
|
|
230
|
+
* otp: otp
|
|
231
|
+
* });
|
|
232
|
+
* console.log(`MFA updated: ${result.detail}`);
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
verifyMfaChange(options: VerifyMfaChangeOptions): Promise<Record<string, any>>;
|
|
236
|
+
/**
|
|
237
|
+
* Get user's stored credentials and MFA status.
|
|
238
|
+
*
|
|
239
|
+
* This method retrieves the user's credentials from Hawcx, including
|
|
240
|
+
* their current MFA configuration.
|
|
241
|
+
*
|
|
242
|
+
* @param userid - User identifier
|
|
243
|
+
* @returns Dictionary containing user credentials and MFA status
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* const creds = await client.getUserCredentials("user@example.com");
|
|
248
|
+
* console.log(`MFA method: ${creds.mfa_method}`);
|
|
249
|
+
* console.log(`Phone: ${creds.contact}`);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
getUserCredentials(userid: string): Promise<Record<string, any>>;
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=hawcx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hawcx.d.ts","sourceRoot":"","sources":["../../src/delegation/hawcx.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAuB,MAAM,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAEL,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,eAAe,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB,gEAAgE;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;;;;;;;OAyBG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,0BAA0B,GAAG,qBAAqB;IAqC3E;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAyDxF;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAgCpF;;;;;;;;;;;;;;;OAeG;IACG,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAmBvE"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hawcx-specific delegation client with high-level convenience methods.
|
|
4
|
+
*
|
|
5
|
+
* This module provides a streamlined API for common Hawcx operations like
|
|
6
|
+
* MFA configuration, user management, and device operations. All cryptographic
|
|
7
|
+
* operations (encryption, signing, verification) are handled automatically.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.HawcxDelegationClient = exports.MfaMethod = void 0;
|
|
11
|
+
const client_1 = require("./client");
|
|
12
|
+
const crypto_1 = require("./crypto");
|
|
13
|
+
const exceptions_1 = require("./exceptions");
|
|
14
|
+
/**
|
|
15
|
+
* Supported MFA methods for Hawcx authentication.
|
|
16
|
+
*
|
|
17
|
+
* This enum ensures type safety and prevents typos when specifying MFA methods.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { MfaMethod } from '@hawcx/oauth-client';
|
|
22
|
+
*
|
|
23
|
+
* // Use enum for type safety
|
|
24
|
+
* await client.initiateMfaChange({
|
|
25
|
+
* userid: "user@example.com",
|
|
26
|
+
* mfaMethod: MfaMethod.SMS, // Type-safe!
|
|
27
|
+
* phoneNumber: "+15551234567"
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // String values still work for backwards compatibility
|
|
31
|
+
* await client.initiateMfaChange({
|
|
32
|
+
* userid: "user@example.com",
|
|
33
|
+
* mfaMethod: "sms", // Also works
|
|
34
|
+
* phoneNumber: "+15551234567"
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
var MfaMethod;
|
|
39
|
+
(function (MfaMethod) {
|
|
40
|
+
MfaMethod["EMAIL"] = "email";
|
|
41
|
+
MfaMethod["SMS"] = "sms";
|
|
42
|
+
MfaMethod["TOTP"] = "totp";
|
|
43
|
+
})(MfaMethod || (exports.MfaMethod = MfaMethod = {}));
|
|
44
|
+
/**
|
|
45
|
+
* High-level client for Hawcx delegation operations.
|
|
46
|
+
*
|
|
47
|
+
* This client provides simplified methods for common Hawcx operations:
|
|
48
|
+
* - MFA configuration (email, SMS, TOTP)
|
|
49
|
+
* - User credential management
|
|
50
|
+
* - Device operations
|
|
51
|
+
*
|
|
52
|
+
* All requests are automatically encrypted (ECIES) and signed (Ed25519/RSA-PSS).
|
|
53
|
+
* All responses are automatically verified and decrypted.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Initialize from keys
|
|
58
|
+
* const client = HawcxDelegationClient.fromKeys({
|
|
59
|
+
* spSigningKey: process.env.SP_SIGNING_KEY!,
|
|
60
|
+
* spEncryptionKey: process.env.SP_ENCRYPTION_KEY!,
|
|
61
|
+
* idpVerifyKey: process.env.IDP_VERIFY_KEY!,
|
|
62
|
+
* idpEncryptionKey: process.env.IDP_ENCRYPTION_KEY!,
|
|
63
|
+
* baseUrl: 'https://ceasar-api.hawcx.com',
|
|
64
|
+
* spId: 'my-client-id'
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* // Initiate SMS MFA setup
|
|
68
|
+
* const result = await client.initiateMfaChange({
|
|
69
|
+
* userid: "user@example.com",
|
|
70
|
+
* mfaMethod: "sms",
|
|
71
|
+
* phoneNumber: "+15551234567"
|
|
72
|
+
* });
|
|
73
|
+
* console.log(result.session_id);
|
|
74
|
+
*
|
|
75
|
+
* // Verify OTP
|
|
76
|
+
* await client.verifyMfaChange({
|
|
77
|
+
* userid: "user@example.com",
|
|
78
|
+
* sessionId: result.session_id,
|
|
79
|
+
* otp: "123456"
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
class HawcxDelegationClient {
|
|
84
|
+
constructor(options) {
|
|
85
|
+
this.client = new client_1.IdpDelegationClient({
|
|
86
|
+
baseUrl: options.baseUrl,
|
|
87
|
+
signer: options.signer,
|
|
88
|
+
verifier: options.verifier,
|
|
89
|
+
encryptor: options.encryptor,
|
|
90
|
+
decryptor: options.decryptor,
|
|
91
|
+
spId: options.spId,
|
|
92
|
+
timeout: options.timeout,
|
|
93
|
+
});
|
|
94
|
+
this.apiKey = options.apiKey;
|
|
95
|
+
this.baseUrl = options.baseUrl;
|
|
96
|
+
this.spId = options.spId;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create client from explicit key values (recommended).
|
|
100
|
+
*
|
|
101
|
+
* This method allows the application to load keys from any source
|
|
102
|
+
* (env vars, config files, secrets manager, etc.) and pass them
|
|
103
|
+
* as values to the SDK.
|
|
104
|
+
*
|
|
105
|
+
* @param options - Configuration options
|
|
106
|
+
* @returns Configured HawcxDelegationClient instance
|
|
107
|
+
* @throws DelegationRequestError if key initialization fails
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* import * as process from 'process';
|
|
112
|
+
*
|
|
113
|
+
* // App controls how to load keys
|
|
114
|
+
* const client = HawcxDelegationClient.fromKeys({
|
|
115
|
+
* spSigningKey: process.env.MY_SIGNING_KEY!,
|
|
116
|
+
* spEncryptionKey: process.env.MY_ENCRYPTION_KEY!,
|
|
117
|
+
* idpVerifyKey: process.env.IDP_VERIFY_KEY!,
|
|
118
|
+
* idpEncryptionKey: process.env.IDP_ENCRYPT_KEY!,
|
|
119
|
+
* baseUrl: process.env.HAWCX_URL!,
|
|
120
|
+
* spId: process.env.MY_CLIENT_ID!
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
static fromKeys(options) {
|
|
125
|
+
const { spSigningKey, spEncryptionKey, idpVerifyKey, idpEncryptionKey, baseUrl, spId, apiKey, timeout = 15, kid = 'hawcx', idpKid = 'hawcx', } = options;
|
|
126
|
+
try {
|
|
127
|
+
const signer = new crypto_1.Ed25519Signer(spSigningKey, kid);
|
|
128
|
+
const verifier = new crypto_1.Verifier({ [idpKid]: idpVerifyKey });
|
|
129
|
+
const encryptor = new crypto_1.EciesX25519Encryptor(idpEncryptionKey);
|
|
130
|
+
const decryptor = new crypto_1.EciesX25519Decryptor(spEncryptionKey);
|
|
131
|
+
console.log(`Initialized HawcxDelegationClient with base_url=${baseUrl}, sp_id=${spId}`);
|
|
132
|
+
return new HawcxDelegationClient({
|
|
133
|
+
baseUrl,
|
|
134
|
+
signer,
|
|
135
|
+
verifier,
|
|
136
|
+
encryptor,
|
|
137
|
+
decryptor,
|
|
138
|
+
spId,
|
|
139
|
+
apiKey,
|
|
140
|
+
timeout,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
throw new exceptions_1.DelegationRequestError(`Failed to initialize crypto helpers: ${error}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Build Hawcx API authentication headers
|
|
149
|
+
*/
|
|
150
|
+
buildAuthHeaders() {
|
|
151
|
+
const headers = {};
|
|
152
|
+
if (this.apiKey) {
|
|
153
|
+
headers['apikey'] = this.apiKey;
|
|
154
|
+
}
|
|
155
|
+
return headers;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Initiate MFA setup or change for a user.
|
|
159
|
+
*
|
|
160
|
+
* This method starts the MFA enrollment/update process by sending an OTP
|
|
161
|
+
* to the user via their chosen method (email, SMS, or generating a TOTP secret).
|
|
162
|
+
*
|
|
163
|
+
* @param options - MFA initiation configuration
|
|
164
|
+
* @returns Dictionary containing session_id and optional TOTP details
|
|
165
|
+
* @throws DelegationRequestError if request fails or parameters are invalid
|
|
166
|
+
* @throws Error if SMS method specified without phone_number
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* import { MfaMethod } from '@hawcx/oauth-client';
|
|
171
|
+
*
|
|
172
|
+
* // Email MFA (with enum - recommended!)
|
|
173
|
+
* const result = await client.initiateMfaChange({
|
|
174
|
+
* userid: "user@example.com",
|
|
175
|
+
* mfaMethod: MfaMethod.EMAIL
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* // SMS MFA (string also works)
|
|
179
|
+
* const result = await client.initiateMfaChange({
|
|
180
|
+
* userid: "user@example.com",
|
|
181
|
+
* mfaMethod: "sms",
|
|
182
|
+
* phoneNumber: "+15551234567"
|
|
183
|
+
* });
|
|
184
|
+
*
|
|
185
|
+
* // TOTP MFA
|
|
186
|
+
* const result = await client.initiateMfaChange({
|
|
187
|
+
* userid: "user@example.com",
|
|
188
|
+
* mfaMethod: MfaMethod.TOTP
|
|
189
|
+
* });
|
|
190
|
+
* console.log(`Scan QR code: ${result.otpauth_uri}`);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
async initiateMfaChange(options) {
|
|
194
|
+
const { userid, mfaMethod, phoneNumber, mfaChangeTo } = options;
|
|
195
|
+
// Convert enum to string if needed
|
|
196
|
+
const mfaMethodStr = typeof mfaMethod === 'string' ? mfaMethod : String(mfaMethod);
|
|
197
|
+
const mfaChangeToStr = mfaChangeTo
|
|
198
|
+
? typeof mfaChangeTo === 'string'
|
|
199
|
+
? mfaChangeTo
|
|
200
|
+
: String(mfaChangeTo)
|
|
201
|
+
: undefined;
|
|
202
|
+
// Validate method
|
|
203
|
+
const validMethods = [MfaMethod.EMAIL, MfaMethod.SMS, MfaMethod.TOTP];
|
|
204
|
+
if (!validMethods.includes(mfaMethodStr)) {
|
|
205
|
+
throw new Error(`Invalid mfa_method '${mfaMethodStr}'. Must be one of: ${validMethods.join(', ')}`);
|
|
206
|
+
}
|
|
207
|
+
// Validate SMS requires phone number
|
|
208
|
+
if (mfaMethodStr === MfaMethod.SMS && !phoneNumber) {
|
|
209
|
+
throw new Error('phone_number is required for SMS MFA');
|
|
210
|
+
}
|
|
211
|
+
// Build Hawcx UpdateTable API payload
|
|
212
|
+
const payload = {
|
|
213
|
+
userid,
|
|
214
|
+
mfa_method: mfaMethodStr,
|
|
215
|
+
};
|
|
216
|
+
// Add SMS phone number
|
|
217
|
+
if (mfaMethodStr === MfaMethod.SMS && phoneNumber) {
|
|
218
|
+
payload.contact = phoneNumber;
|
|
219
|
+
}
|
|
220
|
+
// Add target method if changing
|
|
221
|
+
if (mfaChangeToStr) {
|
|
222
|
+
payload.mfa_change_to = mfaChangeToStr;
|
|
223
|
+
}
|
|
224
|
+
console.log(`[MFA Initiate] Method=${mfaMethodStr} for user=${userid}`);
|
|
225
|
+
try {
|
|
226
|
+
const response = await this.client.sendSecureRequest({
|
|
227
|
+
endpoint: '/hc_auth/v5/update/initiate',
|
|
228
|
+
payload,
|
|
229
|
+
extraHeaders: this.buildAuthHeaders(),
|
|
230
|
+
});
|
|
231
|
+
console.log(`[MFA Initiate] Success for user=${userid}, session_id=${response.session_id}`);
|
|
232
|
+
return response;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error(`[MFA Initiate] Failed for user=${userid}:`, error);
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Verify OTP and complete MFA configuration change.
|
|
241
|
+
*
|
|
242
|
+
* This method verifies the OTP sent to the user and completes the MFA
|
|
243
|
+
* enrollment/update process.
|
|
244
|
+
*
|
|
245
|
+
* @param options - MFA verification configuration
|
|
246
|
+
* @returns Dictionary containing success message and optional mfa_changed_to
|
|
247
|
+
* @throws DelegationRequestError if verification fails
|
|
248
|
+
* @throws Error if OTP format is invalid
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* // Get OTP from user
|
|
253
|
+
* const otp = getUserInput();
|
|
254
|
+
*
|
|
255
|
+
* // Verify and complete MFA setup
|
|
256
|
+
* const result = await client.verifyMfaChange({
|
|
257
|
+
* userid: "user@example.com",
|
|
258
|
+
* sessionId: sessionId,
|
|
259
|
+
* otp: otp
|
|
260
|
+
* });
|
|
261
|
+
* console.log(`MFA updated: ${result.detail}`);
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
async verifyMfaChange(options) {
|
|
265
|
+
const { userid, sessionId, otp } = options;
|
|
266
|
+
// Validate OTP format
|
|
267
|
+
if (!otp || otp.length !== 6 || !/^\d{6}$/.test(otp)) {
|
|
268
|
+
throw new Error('OTP must be a 6-digit code');
|
|
269
|
+
}
|
|
270
|
+
// Build Hawcx UpdateTable API payload
|
|
271
|
+
const payload = {
|
|
272
|
+
userid,
|
|
273
|
+
session_id: sessionId,
|
|
274
|
+
otp,
|
|
275
|
+
};
|
|
276
|
+
console.log(`[MFA Verify] Verifying OTP for user=${userid}, session=${sessionId}`);
|
|
277
|
+
try {
|
|
278
|
+
const response = await this.client.sendSecureRequest({
|
|
279
|
+
endpoint: '/hc_auth/v5/update/verify',
|
|
280
|
+
payload,
|
|
281
|
+
extraHeaders: this.buildAuthHeaders(),
|
|
282
|
+
});
|
|
283
|
+
console.log(`[MFA Verify] Success for user=${userid}`);
|
|
284
|
+
return response;
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
console.error(`[MFA Verify] Failed for user=${userid}:`, error);
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Get user's stored credentials and MFA status.
|
|
293
|
+
*
|
|
294
|
+
* This method retrieves the user's credentials from Hawcx, including
|
|
295
|
+
* their current MFA configuration.
|
|
296
|
+
*
|
|
297
|
+
* @param userid - User identifier
|
|
298
|
+
* @returns Dictionary containing user credentials and MFA status
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* const creds = await client.getUserCredentials("user@example.com");
|
|
303
|
+
* console.log(`MFA method: ${creds.mfa_method}`);
|
|
304
|
+
* console.log(`Phone: ${creds.contact}`);
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
async getUserCredentials(userid) {
|
|
308
|
+
const payload = { userid };
|
|
309
|
+
console.log(`[Get Creds] Fetching credentials for user=${userid}`);
|
|
310
|
+
try {
|
|
311
|
+
const response = await this.client.sendSecureRequest({
|
|
312
|
+
endpoint: '/hc_auth/v5/update/get-creds',
|
|
313
|
+
payload,
|
|
314
|
+
extraHeaders: this.buildAuthHeaders(),
|
|
315
|
+
});
|
|
316
|
+
console.log(`[Get Creds] Success for user=${userid}`);
|
|
317
|
+
return response;
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
console.error(`[Get Creds] Failed for user=${userid}:`, error);
|
|
321
|
+
throw error;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
exports.HawcxDelegationClient = HawcxDelegationClient;
|
|
326
|
+
//# sourceMappingURL=hawcx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hawcx.js","sourceRoot":"","sources":["../../src/delegation/hawcx.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,qCAAuD;AACvD,qCAKkB;AAClB,6CAAsD;AAEtD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IAC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YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE;aACtC,CAAC,CAAC;YAEH,OAAO,CAAC,GAAG,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;YACtD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,MAAM,GAAG,EAAE,KAAK,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAlSD,sDAkSC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hawcx OAuth Client SDK - Delegation Module
|
|
3
|
+
*
|
|
4
|
+
* Exposes the client and utilities for making secure, backend-to-backend
|
|
5
|
+
* delegated requests to an IDP.
|
|
6
|
+
*
|
|
7
|
+
* For Hawcx-specific operations, use HawcxDelegationClient for simplified high-level API.
|
|
8
|
+
* For generic delegation operations, use IdpDelegationClient for lower-level control.
|
|
9
|
+
*/
|
|
10
|
+
export { IdpDelegationClient } from './client';
|
|
11
|
+
export { HawcxDelegationClient, MfaMethod } from './hawcx';
|
|
12
|
+
export { Ed25519Signer, RsaPssSigner, Verifier, EciesX25519Encryptor, EciesX25519Decryptor, nowS, } from './crypto';
|
|
13
|
+
export { DelegationError, DelegationCryptoError, DelegationRequestError, DelegationResponseError, } from './exceptions';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/delegation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,IAAI,GACL,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hawcx OAuth Client SDK - Delegation Module
|
|
4
|
+
*
|
|
5
|
+
* Exposes the client and utilities for making secure, backend-to-backend
|
|
6
|
+
* delegated requests to an IDP.
|
|
7
|
+
*
|
|
8
|
+
* For Hawcx-specific operations, use HawcxDelegationClient for simplified high-level API.
|
|
9
|
+
* For generic delegation operations, use IdpDelegationClient for lower-level control.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DelegationResponseError = exports.DelegationRequestError = exports.DelegationCryptoError = exports.DelegationError = exports.nowS = exports.EciesX25519Decryptor = exports.EciesX25519Encryptor = exports.Verifier = exports.RsaPssSigner = exports.Ed25519Signer = exports.MfaMethod = exports.HawcxDelegationClient = exports.IdpDelegationClient = void 0;
|
|
13
|
+
var client_1 = require("./client");
|
|
14
|
+
Object.defineProperty(exports, "IdpDelegationClient", { enumerable: true, get: function () { return client_1.IdpDelegationClient; } });
|
|
15
|
+
var hawcx_1 = require("./hawcx");
|
|
16
|
+
Object.defineProperty(exports, "HawcxDelegationClient", { enumerable: true, get: function () { return hawcx_1.HawcxDelegationClient; } });
|
|
17
|
+
Object.defineProperty(exports, "MfaMethod", { enumerable: true, get: function () { return hawcx_1.MfaMethod; } });
|
|
18
|
+
var crypto_1 = require("./crypto");
|
|
19
|
+
Object.defineProperty(exports, "Ed25519Signer", { enumerable: true, get: function () { return crypto_1.Ed25519Signer; } });
|
|
20
|
+
Object.defineProperty(exports, "RsaPssSigner", { enumerable: true, get: function () { return crypto_1.RsaPssSigner; } });
|
|
21
|
+
Object.defineProperty(exports, "Verifier", { enumerable: true, get: function () { return crypto_1.Verifier; } });
|
|
22
|
+
Object.defineProperty(exports, "EciesX25519Encryptor", { enumerable: true, get: function () { return crypto_1.EciesX25519Encryptor; } });
|
|
23
|
+
Object.defineProperty(exports, "EciesX25519Decryptor", { enumerable: true, get: function () { return crypto_1.EciesX25519Decryptor; } });
|
|
24
|
+
Object.defineProperty(exports, "nowS", { enumerable: true, get: function () { return crypto_1.nowS; } });
|
|
25
|
+
var exceptions_1 = require("./exceptions");
|
|
26
|
+
Object.defineProperty(exports, "DelegationError", { enumerable: true, get: function () { return exceptions_1.DelegationError; } });
|
|
27
|
+
Object.defineProperty(exports, "DelegationCryptoError", { enumerable: true, get: function () { return exceptions_1.DelegationCryptoError; } });
|
|
28
|
+
Object.defineProperty(exports, "DelegationRequestError", { enumerable: true, get: function () { return exceptions_1.DelegationRequestError; } });
|
|
29
|
+
Object.defineProperty(exports, "DelegationResponseError", { enumerable: true, get: function () { return exceptions_1.DelegationResponseError; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/delegation/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,mCAA+C;AAAtC,6GAAA,mBAAmB,OAAA;AAC5B,iCAA2D;AAAlD,8GAAA,qBAAqB,OAAA;AAAE,kGAAA,SAAS,OAAA;AACzC,mCAOkB;AANhB,uGAAA,aAAa,OAAA;AACb,sGAAA,YAAY,OAAA;AACZ,kGAAA,QAAQ,OAAA;AACR,8GAAA,oBAAoB,OAAA;AACpB,8GAAA,oBAAoB,OAAA;AACpB,8FAAA,IAAI,OAAA;AAEN,2CAKsB;AAJpB,6GAAA,eAAe,OAAA;AACf,mHAAA,qBAAqB,OAAA;AACrB,oHAAA,sBAAsB,OAAA;AACtB,qHAAA,uBAAuB,OAAA"}
|