@hawcx/oauth-client 0.2.0 → 4.0.1

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.
Files changed (71) hide show
  1. package/README.md +475 -210
  2. package/dist/delegation/credentials.d.ts +92 -0
  3. package/dist/delegation/credentials.d.ts.map +1 -0
  4. package/dist/delegation/credentials.js +215 -0
  5. package/dist/delegation/credentials.js.map +1 -0
  6. package/dist/delegation/crypto.d.ts +2 -2
  7. package/dist/delegation/crypto.d.ts.map +1 -1
  8. package/dist/delegation/crypto.js +41 -32
  9. package/dist/delegation/crypto.js.map +1 -1
  10. package/dist/delegation/exceptions.d.ts +12 -5
  11. package/dist/delegation/exceptions.d.ts.map +1 -1
  12. package/dist/delegation/exceptions.js +12 -14
  13. package/dist/delegation/exceptions.js.map +1 -1
  14. package/dist/delegation/factory.d.ts +20 -0
  15. package/dist/delegation/factory.d.ts.map +1 -0
  16. package/dist/delegation/factory.js +49 -0
  17. package/dist/delegation/factory.js.map +1 -0
  18. package/dist/delegation/hawcx.d.ts +67 -224
  19. package/dist/delegation/hawcx.d.ts.map +1 -1
  20. package/dist/delegation/hawcx.js +116 -299
  21. package/dist/delegation/hawcx.js.map +1 -1
  22. package/dist/delegation/index.d.ts +4 -9
  23. package/dist/delegation/index.d.ts.map +1 -1
  24. package/dist/delegation/index.js +5 -17
  25. package/dist/delegation/index.js.map +1 -1
  26. package/dist/delegation/transport.d.ts +40 -0
  27. package/dist/delegation/transport.d.ts.map +1 -0
  28. package/dist/delegation/transport.js +120 -0
  29. package/dist/delegation/transport.js.map +1 -0
  30. package/dist/errors.d.ts +14 -0
  31. package/dist/errors.d.ts.map +1 -0
  32. package/dist/errors.js +29 -0
  33. package/dist/errors.js.map +1 -0
  34. package/dist/index.d.ts +10 -15
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +15 -27
  37. package/dist/index.js.map +1 -1
  38. package/dist/oauth.d.ts +98 -0
  39. package/dist/oauth.d.ts.map +1 -0
  40. package/dist/oauth.js +150 -0
  41. package/dist/oauth.js.map +1 -0
  42. package/dist/stepup/client.d.ts +26 -0
  43. package/dist/stepup/client.d.ts.map +1 -0
  44. package/dist/stepup/client.js +84 -0
  45. package/dist/stepup/client.js.map +1 -0
  46. package/dist/stepup/index.d.ts +3 -0
  47. package/dist/stepup/index.d.ts.map +1 -0
  48. package/dist/stepup/index.js +19 -0
  49. package/dist/stepup/index.js.map +1 -0
  50. package/dist/stepup/types.d.ts +36 -0
  51. package/dist/stepup/types.d.ts.map +1 -0
  52. package/dist/stepup/types.js +3 -0
  53. package/dist/stepup/types.js.map +1 -0
  54. package/package.json +16 -17
  55. package/LICENSE +0 -22
  56. package/dist/client.d.ts +0 -134
  57. package/dist/client.d.ts.map +0 -1
  58. package/dist/client.js +0 -300
  59. package/dist/client.js.map +0 -1
  60. package/dist/delegation/client.d.ts +0 -116
  61. package/dist/delegation/client.d.ts.map +0 -1
  62. package/dist/delegation/client.js +0 -227
  63. package/dist/delegation/client.js.map +0 -1
  64. package/dist/exceptions.d.ts +0 -52
  65. package/dist/exceptions.d.ts.map +0 -1
  66. package/dist/exceptions.js +0 -81
  67. package/dist/exceptions.js.map +0 -1
  68. package/dist/utils.d.ts +0 -61
  69. package/dist/utils.d.ts.map +0 -1
  70. package/dist/utils.js +0 -263
  71. package/dist/utils.js.map +0 -1
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * Secure transport for ECIES-encrypted and signed delegation requests.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DelegationTransport = void 0;
7
+ const crypto_1 = require("./crypto");
8
+ const exceptions_1 = require("./exceptions");
9
+ class DelegationTransport {
10
+ constructor(options) {
11
+ this.baseUrl = options.baseUrl.replace(/\/$/, '');
12
+ this.signer = options.signer;
13
+ this.verifier = options.verifier;
14
+ this.encryptor = options.encryptor;
15
+ this.decryptor = options.decryptor;
16
+ this.timeoutSeconds = options.timeoutSeconds ?? 15;
17
+ this.clockSkewSeconds = options.clockSkewSeconds ?? 300;
18
+ }
19
+ /**
20
+ * Send an encrypted and signed delegation request to the IDP.
21
+ */
22
+ async send(options) {
23
+ const { endpoint, payload, includeBaseUrl = true, headers: extraHeaders = {} } = options;
24
+ let encryptedEnv;
25
+ let headers;
26
+ try {
27
+ const body = Buffer.from(JSON.stringify(payload));
28
+ encryptedEnv = await this.encryptor.encrypt(body);
29
+ const ts = (0, crypto_1.nowS)();
30
+ const sig = this.signer.signDetached(encryptedEnv, ts);
31
+ headers = {
32
+ 'Content-Type': 'application/json',
33
+ 'X-Enc-Alg': 'x25519-aesgcm',
34
+ 'X-Timestamp': String(ts),
35
+ 'X-Signature-Alg': sig.alg,
36
+ 'X-Signature': sig.signatureB64,
37
+ };
38
+ if (sig.kid) {
39
+ headers['X-Key-Id'] = sig.kid;
40
+ }
41
+ Object.assign(headers, extraHeaders);
42
+ }
43
+ catch (error) {
44
+ throw new exceptions_1.DelegationRequestError('Failed to prepare secure request', { cause: error });
45
+ }
46
+ let response;
47
+ let responseData;
48
+ try {
49
+ const url = includeBaseUrl ? this.baseUrl + endpoint : endpoint;
50
+ const controller = new AbortController();
51
+ const timeoutId = setTimeout(() => controller.abort(), this.timeoutSeconds * 1000);
52
+ try {
53
+ response = await fetch(url, {
54
+ method: 'POST',
55
+ headers,
56
+ body: encryptedEnv,
57
+ signal: controller.signal,
58
+ });
59
+ }
60
+ finally {
61
+ clearTimeout(timeoutId);
62
+ }
63
+ responseData = Buffer.from(await response.arrayBuffer());
64
+ }
65
+ catch (error) {
66
+ throw new exceptions_1.DelegationRequestError('Request to IDP failed', { cause: error });
67
+ }
68
+ try {
69
+ const respSig = response.headers.get('x-signature');
70
+ const respAlg = response.headers.get('x-signature-alg');
71
+ const respKid = response.headers.get('x-key-id');
72
+ const respTsHeader = response.headers.get('x-timestamp');
73
+ if (!respSig || !respAlg || !respTsHeader) {
74
+ throw new exceptions_1.DelegationResponseError('Missing signature headers in IDP response');
75
+ }
76
+ const respTs = Number(respTsHeader);
77
+ if (!Number.isFinite(respTs)) {
78
+ throw new exceptions_1.DelegationResponseError('Invalid response timestamp');
79
+ }
80
+ const skew = Math.abs((0, crypto_1.nowS)() - respTs);
81
+ if (skew > this.clockSkewSeconds) {
82
+ throw new exceptions_1.DelegationResponseError(`Response timestamp outside allowed skew (${this.clockSkewSeconds}s)`);
83
+ }
84
+ this.verifier.verify(responseData, respTs, respSig, respAlg, respKid ?? undefined);
85
+ if (response.headers.get('x-enc-alg') !== 'x25519-aesgcm') {
86
+ throw new exceptions_1.DelegationResponseError('IDP response must be ECIES encrypted');
87
+ }
88
+ const plaintext = await this.decryptor.decrypt(responseData);
89
+ const decryptedData = JSON.parse(plaintext.toString('utf-8'));
90
+ if (response.status >= 400) {
91
+ const errorDetail = decryptedData?.detail;
92
+ const errorBody = errorDetail ? String(errorDetail) : JSON.stringify(decryptedData);
93
+ throw new exceptions_1.DelegationRequestError(`IDP returned ${response.status}`, {
94
+ statusCode: response.status,
95
+ responseBody: errorBody,
96
+ });
97
+ }
98
+ return decryptedData;
99
+ }
100
+ catch (error) {
101
+ if (error instanceof exceptions_1.DelegationRequestError) {
102
+ throw error;
103
+ }
104
+ if (error instanceof exceptions_1.DelegationResponseError) {
105
+ throw error;
106
+ }
107
+ if (response.status >= 400) {
108
+ const responseText = responseData.toString('utf-8').substring(0, 500);
109
+ throw new exceptions_1.DelegationRequestError(`IDP returned ${response.status}`, {
110
+ statusCode: response.status,
111
+ responseBody: responseText,
112
+ cause: error,
113
+ });
114
+ }
115
+ throw new exceptions_1.DelegationResponseError('Failed to process secure response', { cause: error });
116
+ }
117
+ }
118
+ }
119
+ exports.DelegationTransport = DelegationTransport;
120
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/delegation/transport.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,qCAOkB;AAClB,6CAA+E;AA0B/E,MAAa,mBAAmB;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 * Hawcx OAuth Errors
3
+ */
4
+ export declare class HawcxOAuthError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ export declare class TokenExchangeError extends HawcxOAuthError {
8
+ readonly statusCode?: number;
9
+ constructor(message: string, statusCode?: number);
10
+ }
11
+ export declare class TokenVerificationError extends HawcxOAuthError {
12
+ constructor(message: string);
13
+ }
14
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKjD;AAED,qBAAa,sBAAuB,SAAQ,eAAe;gBAC7C,OAAO,EAAE,MAAM;CAI5B"}
package/dist/errors.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * Hawcx OAuth Errors
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TokenVerificationError = exports.TokenExchangeError = exports.HawcxOAuthError = void 0;
7
+ class HawcxOAuthError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = 'HawcxOAuthError';
11
+ }
12
+ }
13
+ exports.HawcxOAuthError = HawcxOAuthError;
14
+ class TokenExchangeError extends HawcxOAuthError {
15
+ constructor(message, statusCode) {
16
+ super(message);
17
+ this.name = 'TokenExchangeError';
18
+ this.statusCode = statusCode;
19
+ }
20
+ }
21
+ exports.TokenExchangeError = TokenExchangeError;
22
+ class TokenVerificationError extends HawcxOAuthError {
23
+ constructor(message) {
24
+ super(message);
25
+ this.name = 'TokenVerificationError';
26
+ }
27
+ }
28
+ exports.TokenVerificationError = TokenVerificationError;
29
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,kBAAmB,SAAQ,eAAe;IAGrD,YAAY,OAAe,EAAE,UAAmB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AARD,gDAQC;AAED,MAAa,sBAAuB,SAAQ,eAAe;IACzD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC"}
package/dist/index.d.ts CHANGED
@@ -1,26 +1,21 @@
1
1
  /**
2
2
  * Hawcx OAuth Client SDK
3
3
  *
4
- * A lightweight, production-ready Node.js library for exchanging OAuth authorization
5
- * codes and verifying JWT claims. Built with security, reliability, and ease of use in mind.
4
+ * Simple, production-ready SDK for exchanging authorization codes
5
+ * and verifying JWT tokens with Hawcx OAuth service.
6
6
  *
7
7
  * @example
8
8
  * ```typescript
9
- * import { exchangeCodeForClaims } from '@hawcx/oauth-client';
9
+ * import { HawcxOAuth } from '@hawcx/oauth-client';
10
10
  *
11
- * const claims = await exchangeCodeForClaims({
12
- * code: 'abc123',
13
- * oauthTokenUrl: 'https://oauth.example.com/token',
14
- * clientId: 'my-app',
15
- * publicKey: 'path/to/public.pem'
16
- * });
17
- * console.log(claims.sub); // 'user@example.com'
11
+ * const oauth = new HawcxOAuth({ configId: 'your-api-key' });
12
+ * const { idToken, claims } = await oauth.exchangeCode(code, codeVerifier);
18
13
  * ```
19
14
  */
20
- export { exchangeCodeForClaims, exchangeCodeForTokenAndClaims, verifyJwt, } from './client';
21
- export type { ExchangeCodeOptions, VerifyJwtOptions } from './client';
22
- export { fetchJwks, getKeyFromJwks } from './utils';
23
- export { HawcxOAuthError, InvalidPublicKeyError, OAuthExchangeError, JWTVerificationError, } from './exceptions';
15
+ export { HawcxOAuth } from './oauth';
16
+ export type { HawcxOAuthConfig, ExchangeResult, JwtClaims } from './oauth';
17
+ export { HawcxOAuthError, TokenExchangeError, TokenVerificationError } from './errors';
24
18
  export * from './delegation';
25
- export declare const VERSION = "0.1.0";
19
+ export * from './stepup';
20
+ export declare const VERSION = "4.0.1";
26
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,SAAS,GACV,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGtE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGpD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,cAAc,cAAc,CAAC;AAE7B,eAAO,MAAM,OAAO,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGvF,cAAc,cAAc,CAAC;AAG7B,cAAc,UAAU,CAAC;AAEzB,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -2,20 +2,15 @@
2
2
  /**
3
3
  * Hawcx OAuth Client SDK
4
4
  *
5
- * A lightweight, production-ready Node.js library for exchanging OAuth authorization
6
- * codes and verifying JWT claims. Built with security, reliability, and ease of use in mind.
5
+ * Simple, production-ready SDK for exchanging authorization codes
6
+ * and verifying JWT tokens with Hawcx OAuth service.
7
7
  *
8
8
  * @example
9
9
  * ```typescript
10
- * import { exchangeCodeForClaims } from '@hawcx/oauth-client';
10
+ * import { HawcxOAuth } from '@hawcx/oauth-client';
11
11
  *
12
- * const claims = await exchangeCodeForClaims({
13
- * code: 'abc123',
14
- * oauthTokenUrl: 'https://oauth.example.com/token',
15
- * clientId: 'my-app',
16
- * publicKey: 'path/to/public.pem'
17
- * });
18
- * console.log(claims.sub); // 'user@example.com'
12
+ * const oauth = new HawcxOAuth({ configId: 'your-api-key' });
13
+ * const { idToken, claims } = await oauth.exchangeCode(code, codeVerifier);
19
14
  * ```
20
15
  */
21
16
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -33,23 +28,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
33
28
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
34
29
  };
35
30
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.VERSION = exports.JWTVerificationError = exports.OAuthExchangeError = exports.InvalidPublicKeyError = exports.HawcxOAuthError = exports.getKeyFromJwks = exports.fetchJwks = exports.verifyJwt = exports.exchangeCodeForTokenAndClaims = exports.exchangeCodeForClaims = void 0;
37
- // Core OAuth client
38
- var client_1 = require("./client");
39
- Object.defineProperty(exports, "exchangeCodeForClaims", { enumerable: true, get: function () { return client_1.exchangeCodeForClaims; } });
40
- Object.defineProperty(exports, "exchangeCodeForTokenAndClaims", { enumerable: true, get: function () { return client_1.exchangeCodeForTokenAndClaims; } });
41
- Object.defineProperty(exports, "verifyJwt", { enumerable: true, get: function () { return client_1.verifyJwt; } });
42
- // JWKS utilities
43
- var utils_1 = require("./utils");
44
- Object.defineProperty(exports, "fetchJwks", { enumerable: true, get: function () { return utils_1.fetchJwks; } });
45
- Object.defineProperty(exports, "getKeyFromJwks", { enumerable: true, get: function () { return utils_1.getKeyFromJwks; } });
46
- // Exceptions
47
- var exceptions_1 = require("./exceptions");
48
- Object.defineProperty(exports, "HawcxOAuthError", { enumerable: true, get: function () { return exceptions_1.HawcxOAuthError; } });
49
- Object.defineProperty(exports, "InvalidPublicKeyError", { enumerable: true, get: function () { return exceptions_1.InvalidPublicKeyError; } });
50
- Object.defineProperty(exports, "OAuthExchangeError", { enumerable: true, get: function () { return exceptions_1.OAuthExchangeError; } });
51
- Object.defineProperty(exports, "JWTVerificationError", { enumerable: true, get: function () { return exceptions_1.JWTVerificationError; } });
31
+ exports.VERSION = exports.TokenVerificationError = exports.TokenExchangeError = exports.HawcxOAuthError = exports.HawcxOAuth = void 0;
32
+ var oauth_1 = require("./oauth");
33
+ Object.defineProperty(exports, "HawcxOAuth", { enumerable: true, get: function () { return oauth_1.HawcxOAuth; } });
34
+ var errors_1 = require("./errors");
35
+ Object.defineProperty(exports, "HawcxOAuthError", { enumerable: true, get: function () { return errors_1.HawcxOAuthError; } });
36
+ Object.defineProperty(exports, "TokenExchangeError", { enumerable: true, get: function () { return errors_1.TokenExchangeError; } });
37
+ Object.defineProperty(exports, "TokenVerificationError", { enumerable: true, get: function () { return errors_1.TokenVerificationError; } });
52
38
  // Delegation module
53
39
  __exportStar(require("./delegation"), exports);
54
- exports.VERSION = '0.1.0';
40
+ // Step-up module
41
+ __exportStar(require("./stepup"), exports);
42
+ exports.VERSION = '4.0.1';
55
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;;;;;;;;;;;AAEH,oBAAoB;AACpB,mCAIkB;AAHhB,+GAAA,qBAAqB,OAAA;AACrB,uHAAA,6BAA6B,OAAA;AAC7B,mGAAA,SAAS,OAAA;AAIX,iBAAiB;AACjB,iCAAoD;AAA3C,kGAAA,SAAS,OAAA;AAAE,uGAAA,cAAc,OAAA;AAElC,aAAa;AACb,2CAKsB;AAJpB,6GAAA,eAAe,OAAA;AACf,mHAAA,qBAAqB,OAAA;AACrB,gHAAA,kBAAkB,OAAA;AAClB,kHAAA,oBAAoB,OAAA;AAGtB,oBAAoB;AACpB,+CAA6B;AAEhB,QAAA,OAAO,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;AAEH,iCAAqC;AAA5B,mGAAA,UAAU,OAAA;AAEnB,mCAAuF;AAA9E,yGAAA,eAAe,OAAA;AAAE,4GAAA,kBAAkB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAEpE,oBAAoB;AACpB,+CAA6B;AAE7B,iBAAiB;AACjB,2CAAyB;AAEZ,QAAA,OAAO,GAAG,OAAO,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Hawcx OAuth Client
3
+ *
4
+ * Simple, clean implementation using the jose library for JWT verification.
5
+ */
6
+ import { type JWTPayload } from 'jose';
7
+ export interface HawcxOAuthConfig {
8
+ /** Your Hawcx API key (X-Config-Id) */
9
+ configId: string;
10
+ /** Base URL override (default: https://api.hawcx.com) */
11
+ baseUrl?: string;
12
+ /** Request timeout in ms (default: 10000) */
13
+ timeout?: number;
14
+ }
15
+ export interface JwtClaims extends JWTPayload {
16
+ /** Subject (user ID) */
17
+ sub?: string;
18
+ /** Issuer */
19
+ iss?: string;
20
+ /** Audience */
21
+ aud?: string | string[];
22
+ /** Issued at (unix timestamp) */
23
+ iat?: number;
24
+ /** Expiration (unix timestamp) */
25
+ exp?: number;
26
+ /** Not before (unix timestamp) */
27
+ nbf?: number;
28
+ /** JWT ID */
29
+ jti?: string;
30
+ /** Nonce */
31
+ nonce?: string;
32
+ /** Authentication methods */
33
+ amr?: string[];
34
+ /** MFA method used */
35
+ mfa_method?: string;
36
+ /** Email */
37
+ email?: string;
38
+ /** Name */
39
+ name?: string;
40
+ }
41
+ export interface ExchangeResult {
42
+ /** Raw id_token JWT */
43
+ idToken: string;
44
+ /** Verified JWT claims */
45
+ claims: JwtClaims;
46
+ }
47
+ /**
48
+ * Hawcx OAuth Client
49
+ *
50
+ * Handles code exchange and JWT verification using the jose library.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const oauth = new HawcxOAuth({ configId: 'your-api-key' });
55
+ *
56
+ * // Exchange authorization code for tokens
57
+ * const { idToken, claims } = await oauth.exchangeCode(code, codeVerifier);
58
+ * console.log(claims.sub); // user ID
59
+ *
60
+ * // Later, verify an existing token
61
+ * const claims = await oauth.verifyToken(idToken);
62
+ * ```
63
+ */
64
+ export declare class HawcxOAuth {
65
+ private readonly configId;
66
+ private readonly baseUrl;
67
+ private readonly timeout;
68
+ private jwks;
69
+ constructor(config: HawcxOAuthConfig);
70
+ /**
71
+ * Exchange authorization code for id_token and verified claims.
72
+ *
73
+ * @param code - Authorization code from auth flow
74
+ * @param codeVerifier - PKCE code verifier
75
+ * @returns id_token and verified claims
76
+ */
77
+ exchangeCode(code: string, codeVerifier: string): Promise<ExchangeResult>;
78
+ /**
79
+ * Verify a JWT token and return its claims.
80
+ *
81
+ * Uses the jose library which handles all signature formats automatically,
82
+ * including ECDSA signature conversion between P1363 and DER formats.
83
+ *
84
+ * @param token - JWT token to verify
85
+ * @returns Verified claims
86
+ */
87
+ verifyToken(token: string): Promise<JwtClaims>;
88
+ /**
89
+ * Get or create the remote JWKS.
90
+ * The jose library handles caching internally.
91
+ */
92
+ private getJwks;
93
+ /**
94
+ * Clear the JWKS cache (useful for testing or key rotation).
95
+ */
96
+ clearCache(): void;
97
+ }
98
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAKtE,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,eAAe;IACf,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,MAAM,EAAE,SAAS,CAAC;CACnB;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,IAAI,CAAsD;gBAEtD,MAAM,EAAE,gBAAgB;IASpC;;;;;;OAMG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAkD/E;;;;;;;;OAQG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IA+BpD;;;OAGG;IACH,OAAO,CAAC,OAAO;IAaf;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB"}
package/dist/oauth.js ADDED
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ /**
3
+ * Hawcx OAuth Client
4
+ *
5
+ * Simple, clean implementation using the jose library for JWT verification.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.HawcxOAuth = void 0;
9
+ const jose_1 = require("jose");
10
+ const errors_1 = require("./errors");
11
+ const DEFAULT_BASE_URL = 'https://api.hawcx.com';
12
+ /**
13
+ * Hawcx OAuth Client
14
+ *
15
+ * Handles code exchange and JWT verification using the jose library.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const oauth = new HawcxOAuth({ configId: 'your-api-key' });
20
+ *
21
+ * // Exchange authorization code for tokens
22
+ * const { idToken, claims } = await oauth.exchangeCode(code, codeVerifier);
23
+ * console.log(claims.sub); // user ID
24
+ *
25
+ * // Later, verify an existing token
26
+ * const claims = await oauth.verifyToken(idToken);
27
+ * ```
28
+ */
29
+ class HawcxOAuth {
30
+ constructor(config) {
31
+ this.jwks = null;
32
+ if (!config.configId) {
33
+ throw new Error('configId is required');
34
+ }
35
+ this.configId = config.configId;
36
+ this.baseUrl = (config.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, '');
37
+ this.timeout = config.timeout ?? 10000;
38
+ }
39
+ /**
40
+ * Exchange authorization code for id_token and verified claims.
41
+ *
42
+ * @param code - Authorization code from auth flow
43
+ * @param codeVerifier - PKCE code verifier
44
+ * @returns id_token and verified claims
45
+ */
46
+ async exchangeCode(code, codeVerifier) {
47
+ if (!code)
48
+ throw new errors_1.TokenExchangeError('code is required');
49
+ if (!codeVerifier)
50
+ throw new errors_1.TokenExchangeError('codeVerifier is required');
51
+ // Exchange code for token
52
+ const tokenUrl = `${this.baseUrl}/oauth2/token`;
53
+ const body = new URLSearchParams();
54
+ body.append('code', code);
55
+ body.append('code_verifier', codeVerifier);
56
+ let response;
57
+ try {
58
+ response = await fetch(tokenUrl, {
59
+ method: 'POST',
60
+ headers: {
61
+ 'Content-Type': 'application/x-www-form-urlencoded',
62
+ 'X-Config-Id': this.configId,
63
+ },
64
+ body: body.toString(),
65
+ signal: AbortSignal.timeout(this.timeout),
66
+ });
67
+ }
68
+ catch (err) {
69
+ throw new errors_1.TokenExchangeError(`Network error: ${err}`);
70
+ }
71
+ if (!response.ok) {
72
+ let errorMsg = `HTTP ${response.status}`;
73
+ try {
74
+ const data = (await response.json());
75
+ errorMsg = data.error_description || data.error || errorMsg;
76
+ }
77
+ catch {
78
+ // ignore parse errors
79
+ }
80
+ throw new errors_1.TokenExchangeError(errorMsg, response.status);
81
+ }
82
+ const data = (await response.json());
83
+ const idToken = data.id_token;
84
+ if (!idToken) {
85
+ throw new errors_1.TokenExchangeError('Response missing id_token');
86
+ }
87
+ // Verify the token
88
+ const claims = await this.verifyToken(idToken);
89
+ return { idToken, claims };
90
+ }
91
+ /**
92
+ * Verify a JWT token and return its claims.
93
+ *
94
+ * Uses the jose library which handles all signature formats automatically,
95
+ * including ECDSA signature conversion between P1363 and DER formats.
96
+ *
97
+ * @param token - JWT token to verify
98
+ * @returns Verified claims
99
+ */
100
+ async verifyToken(token) {
101
+ if (!token)
102
+ throw new errors_1.TokenVerificationError('token is required');
103
+ try {
104
+ // Get or create the JWKS
105
+ const jwks = this.getJwks();
106
+ // Verify the token using jose - handles all the crypto automatically
107
+ const { payload } = await (0, jose_1.jwtVerify)(token, jwks);
108
+ return payload;
109
+ }
110
+ catch (err) {
111
+ if (err instanceof errors_1.TokenVerificationError)
112
+ throw err;
113
+ const message = err instanceof Error ? err.message : String(err);
114
+ // Map jose errors to our error types
115
+ if (message.includes('expired')) {
116
+ throw new errors_1.TokenVerificationError('Token expired');
117
+ }
118
+ if (message.includes('not yet valid') || message.includes('nbf')) {
119
+ throw new errors_1.TokenVerificationError('Token not yet valid');
120
+ }
121
+ if (message.includes('signature')) {
122
+ throw new errors_1.TokenVerificationError('Invalid signature');
123
+ }
124
+ throw new errors_1.TokenVerificationError(`Token verification failed: ${message}`);
125
+ }
126
+ }
127
+ /**
128
+ * Get or create the remote JWKS.
129
+ * The jose library handles caching internally.
130
+ */
131
+ getJwks() {
132
+ if (!this.jwks) {
133
+ const jwksUrl = new URL(`${this.baseUrl}/keys`);
134
+ this.jwks = (0, jose_1.createRemoteJWKSet)(jwksUrl, {
135
+ headers: {
136
+ 'X-Config-Id': this.configId,
137
+ },
138
+ });
139
+ }
140
+ return this.jwks;
141
+ }
142
+ /**
143
+ * Clear the JWKS cache (useful for testing or key rotation).
144
+ */
145
+ clearCache() {
146
+ this.jwks = null;
147
+ }
148
+ }
149
+ exports.HawcxOAuth = HawcxOAuth;
150
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,+BAAsE;AACtE,qCAAsE;AAEtE,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAmDjD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,UAAU;IAMrB,YAAY,MAAwB;QAF5B,SAAI,GAAiD,IAAI,CAAC;QAGhE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CA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AAC;YAErD,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAEjE,qCAAqC;YACrC,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAChC,MAAM,IAAI,+BAAsB,CAAC,eAAe,CAAC,CAAC;YACpD,CAAC;YACD,IAAI,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjE,MAAM,IAAI,+BAAsB,CAAC,qBAAqB,CAAC,CAAC;YAC1D,CAAC;YACD,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,+BAAsB,CAAC,mBAAmB,CAAC,CAAC;YACxD,CAAC;YAED,MAAM,IAAI,+BAAsB,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,OAAO;QACb,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,OAAO,CAAC,CAAC;YAEhD,IAAI,CAAC,IAAI,GAAG,IAAA,yBAAkB,EAAC,OAAO,EAAE;gBACtC,OAAO,EAAE;oBACP,aAAa,EAAE,IAAI,CAAC,QAAQ;iBAC7B;aACF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAvID,gCAuIC"}
@@ -0,0 +1,26 @@
1
+ import { DelegationTransport } from '../delegation/transport';
2
+ import { DelegationKeyMaterial } from '../delegation/factory';
3
+ import { StepUpClientBaseOptions, StepUpConsumeOptions, StepUpConsumeResponse, StepUpStartOptions, StepUpStartTokenResponse } from './types';
4
+ export interface StepUpClientSecretKeyOptions extends StepUpClientBaseOptions {
5
+ secretKey: string;
6
+ apiKey?: string;
7
+ }
8
+ export type StepUpClientKeyOptions = StepUpClientBaseOptions & DelegationKeyMaterial & {
9
+ apiKey?: string;
10
+ };
11
+ export declare class StepUpClient {
12
+ private transport;
13
+ private options;
14
+ private apiKey?;
15
+ constructor(options: {
16
+ transport: DelegationTransport;
17
+ clientOptions: StepUpClientBaseOptions;
18
+ apiKey?: string;
19
+ });
20
+ static fromSecretKey(options: StepUpClientSecretKeyOptions): StepUpClient;
21
+ static fromKeys(options: StepUpClientKeyOptions): StepUpClient;
22
+ private buildExtraHeaders;
23
+ startToken(options: StepUpStartOptions): Promise<StepUpStartTokenResponse>;
24
+ consumeReceipt(options: StepUpConsumeOptions): Promise<StepUpConsumeResponse>;
25
+ }
26
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/stepup/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAuD,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnH,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,4BAA6B,SAAQ,uBAAuB;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,sBAAsB,GAAG,uBAAuB,GAAG,qBAAqB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3G,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,MAAM,CAAC,CAAS;gBAEZ,OAAO,EAAE;QACnB,SAAS,EAAE,mBAAmB,CAAC;QAC/B,aAAa,EAAE,uBAAuB,CAAC;QACvC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAMD,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,4BAA4B,GAAG,YAAY;IAMzE,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,YAAY;IAM9D,OAAO,CAAC,iBAAiB;IAmBnB,UAAU,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA6B1E,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAoBpF"}