@hawcx/oauth-client 5.2.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +355 -0
- package/README.md +247 -0
- package/dist/client-assertion.d.ts.map +1 -1
- package/dist/client-assertion.js +6 -2
- package/dist/client-assertion.js.map +1 -1
- package/dist/delegation/exceptions.d.ts +34 -0
- package/dist/delegation/exceptions.d.ts.map +1 -1
- package/dist/delegation/exceptions.js +39 -1
- package/dist/delegation/exceptions.js.map +1 -1
- package/dist/delegation/hawcx.d.ts +6 -2
- package/dist/delegation/hawcx.d.ts.map +1 -1
- package/dist/delegation/hawcx.js.map +1 -1
- package/dist/delegation/index.d.ts +2 -1
- package/dist/delegation/index.d.ts.map +1 -1
- package/dist/delegation/index.js +3 -1
- package/dist/delegation/index.js.map +1 -1
- package/dist/delegation/transport.d.ts +6 -2
- package/dist/delegation/transport.d.ts.map +1 -1
- package/dist/delegation/transport.js +9 -2
- package/dist/delegation/transport.js.map +1 -1
- package/dist/errors.d.ts +11 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/url.d.ts +73 -0
- package/dist/internal/url.d.ts.map +1 -0
- package/dist/internal/url.js +210 -0
- package/dist/internal/url.js.map +1 -0
- package/dist/management/jwt_transport.d.ts +44 -3
- package/dist/management/jwt_transport.d.ts.map +1 -1
- package/dist/management/jwt_transport.js +60 -4
- package/dist/management/jwt_transport.js.map +1 -1
- package/dist/management/response_signature.d.ts +65 -0
- package/dist/management/response_signature.d.ts.map +1 -0
- package/dist/management/response_signature.js +170 -0
- package/dist/management/response_signature.js.map +1 -0
- package/dist/oauth.d.ts +89 -1
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +265 -34
- package/dist/oauth.js.map +1 -1
- package/dist/profile/client.d.ts +99 -0
- package/dist/profile/client.d.ts.map +1 -0
- package/dist/profile/client.js +209 -0
- package/dist/profile/client.js.map +1 -0
- package/dist/profile/errors.d.ts +62 -0
- package/dist/profile/errors.d.ts.map +1 -0
- package/dist/profile/errors.js +90 -0
- package/dist/profile/errors.js.map +1 -0
- package/dist/profile/http.d.ts +57 -0
- package/dist/profile/http.d.ts.map +1 -0
- package/dist/profile/http.js +295 -0
- package/dist/profile/http.js.map +1 -0
- package/dist/profile/tokens.d.ts +50 -0
- package/dist/profile/tokens.d.ts.map +1 -0
- package/dist/profile/tokens.js +137 -0
- package/dist/profile/tokens.js.map +1 -0
- package/dist/profile/types.d.ts +99 -0
- package/dist/profile/types.d.ts.map +1 -0
- package/dist/profile/types.js +7 -0
- package/dist/profile/types.js.map +1 -0
- package/dist/stepup/client.d.ts +11 -0
- package/dist/stepup/client.d.ts.map +1 -1
- package/dist/stepup/client.js +6 -1
- package/dist/stepup/client.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _ProfileHttp_o, _ProfileHttp_base;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ProfileHttp = exports.isObject = void 0;
|
|
16
|
+
exports.segment = segment;
|
|
17
|
+
/**
|
|
18
|
+
* One request path for the profile service: bearer + `X-Config-Id`, single-
|
|
19
|
+
* segment path encoding, bounded retries for idempotent methods (transient
|
|
20
|
+
* token-endpoint failures retried for every method, same budget), one 401
|
|
21
|
+
* refresh-and-replay, no redirects, problem+json → {@link ProfileApiError}.
|
|
22
|
+
*/
|
|
23
|
+
const errors_1 = require("../errors");
|
|
24
|
+
const url_1 = require("../internal/url");
|
|
25
|
+
const errors_2 = require("./errors");
|
|
26
|
+
const RETRY_METHODS = new Set(['GET', 'PUT', 'DELETE']);
|
|
27
|
+
const RETRY_STATUS = new Set([408, 429, 502, 503, 504]);
|
|
28
|
+
const RETRY_AFTER_CAP_MS = 30000;
|
|
29
|
+
const BACKOFF_BASE_MS = 200;
|
|
30
|
+
const BACKOFF_CAP_MS = 5000;
|
|
31
|
+
const urlError = (message) => new errors_1.HawcxError(message);
|
|
32
|
+
const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
33
|
+
exports.isObject = isObject;
|
|
34
|
+
/**
|
|
35
|
+
* Validate a caller-supplied path parameter and percent-encode it as exactly
|
|
36
|
+
* one segment (`?`, `#`, `%` encoded). Empty, `.`, `..`, and anything with
|
|
37
|
+
* `/`, `\` or a control character are refused client-side: an encoded `%2F`
|
|
38
|
+
* could still be decoded into a separator by a proxy.
|
|
39
|
+
*/
|
|
40
|
+
function segment(value, name) {
|
|
41
|
+
if (typeof value !== 'string' ||
|
|
42
|
+
value === '' ||
|
|
43
|
+
value === '.' ||
|
|
44
|
+
value === '..' ||
|
|
45
|
+
// eslint-disable-next-line no-control-regex
|
|
46
|
+
/[/\\\u0000-\u001f\u007f]/.test(value)) {
|
|
47
|
+
throw new errors_1.HawcxError(`${name} must be a non-empty string other than '.' or '..', without '/', '\\' or control characters`);
|
|
48
|
+
}
|
|
49
|
+
return encodeURIComponent(value);
|
|
50
|
+
}
|
|
51
|
+
class ProfileHttp {
|
|
52
|
+
constructor(options) {
|
|
53
|
+
_ProfileHttp_o.set(this, void 0);
|
|
54
|
+
_ProfileHttp_base.set(this, void 0);
|
|
55
|
+
__classPrivateFieldSet(this, _ProfileHttp_o, {
|
|
56
|
+
...options,
|
|
57
|
+
timeout: options.timeout ?? 10000,
|
|
58
|
+
maxRetries: options.maxRetries ?? 2,
|
|
59
|
+
sleep: options.sleep ?? (ms => new Promise(r => setTimeout(r, ms))),
|
|
60
|
+
fetch: options.fetch ?? fetch,
|
|
61
|
+
surface401: options.surface401 ?? false,
|
|
62
|
+
}, "f");
|
|
63
|
+
__classPrivateFieldSet(this, _ProfileHttp_base, (0, url_1.parseSecureBaseUrl)('baseUrl', options.baseUrl, urlError), "f");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* `segments` must already be encoded literals or {@link segment} output.
|
|
67
|
+
* Returns the parsed 2xx JSON body, which must pass `opts.valid` (default:
|
|
68
|
+
* a JSON object) or a `ProfileApiError` is thrown; a 204 to any method but
|
|
69
|
+
* DELETE is `Unexpected response body`. `null` only for a DELETE answered
|
|
70
|
+
* 2xx (whatever the body), or a DELETE answered 404 after an earlier attempt
|
|
71
|
+
* of the same call may have run (no response, a 2xx whose body failed
|
|
72
|
+
* mid-read, or 504).
|
|
73
|
+
*/
|
|
74
|
+
async request(method, segments, opts = {}) {
|
|
75
|
+
const o = __classPrivateFieldGet(this, _ProfileHttp_o, "f");
|
|
76
|
+
const query = new URLSearchParams();
|
|
77
|
+
for (const [k, v] of Object.entries(opts.query ?? {}))
|
|
78
|
+
if (v !== undefined)
|
|
79
|
+
query.set(k, String(v));
|
|
80
|
+
const qs = query.toString();
|
|
81
|
+
const path = `/${segments.join('/')}`;
|
|
82
|
+
// Joined via the URL guard: the result must stay on the base origin and path.
|
|
83
|
+
const url = (0, url_1.safeJoinUrl)(__classPrivateFieldGet(this, _ProfileHttp_base, "f"), qs ? `${path}?${qs}` : path, 'profile URL', urlError);
|
|
84
|
+
// For error messages: method + path only (the query may carry PII such as email).
|
|
85
|
+
const where = `${method} ${__classPrivateFieldGet(this, _ProfileHttp_base, "f").pathPrefix}${path}`;
|
|
86
|
+
const hasBody = opts.body !== undefined;
|
|
87
|
+
// Serialise once, up front: a bad body fails here with nothing sent.
|
|
88
|
+
let payload;
|
|
89
|
+
if (hasBody) {
|
|
90
|
+
try {
|
|
91
|
+
payload = JSON.stringify(opts.body);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
const e = new errors_1.HawcxError(`request body is not JSON-serialisable: ${err.message}`);
|
|
95
|
+
e.cause = err;
|
|
96
|
+
throw e;
|
|
97
|
+
}
|
|
98
|
+
if (payload === undefined)
|
|
99
|
+
throw new errors_1.HawcxError('request body is not JSON-serialisable');
|
|
100
|
+
}
|
|
101
|
+
const retryable = RETRY_METHODS.has(method);
|
|
102
|
+
let attempt = 0;
|
|
103
|
+
let replayed = false;
|
|
104
|
+
// Sticky for the whole call: some earlier attempt may have run server-side
|
|
105
|
+
// (sent with no HTTP response back, a 2xx whose body failed mid-read, or a
|
|
106
|
+
// 504 from the gateway).
|
|
107
|
+
let mayHaveRun = false;
|
|
108
|
+
// The 401 being replayed, while its fresh token is minted.
|
|
109
|
+
let unauthorized = null;
|
|
110
|
+
for (;;) {
|
|
111
|
+
let token;
|
|
112
|
+
try {
|
|
113
|
+
token = await o.tokens.getToken();
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
// Nothing was sent to the profile service, so any method may retry
|
|
117
|
+
// (POST/PATCH included); it spends the same budget.
|
|
118
|
+
const transient = transientTokenError(err);
|
|
119
|
+
if (attempt < o.maxRetries && transient) {
|
|
120
|
+
await o.sleep(backoff(attempt++));
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (unauthorized !== null && !transient) {
|
|
124
|
+
unauthorized.cause = err;
|
|
125
|
+
throw unauthorized;
|
|
126
|
+
}
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
unauthorized = null;
|
|
130
|
+
const headers = {
|
|
131
|
+
Authorization: `Bearer ${token}`,
|
|
132
|
+
'X-Config-Id': o.configId,
|
|
133
|
+
Accept: 'application/json',
|
|
134
|
+
};
|
|
135
|
+
if (hasBody)
|
|
136
|
+
headers['Content-Type'] = 'application/json';
|
|
137
|
+
let res;
|
|
138
|
+
let text = '';
|
|
139
|
+
let gotStatus = false;
|
|
140
|
+
try {
|
|
141
|
+
res = await o.fetch(url, {
|
|
142
|
+
method,
|
|
143
|
+
headers,
|
|
144
|
+
body: payload,
|
|
145
|
+
// A bearer token must never be replayed to wherever a 3xx points.
|
|
146
|
+
redirect: 'manual',
|
|
147
|
+
signal: AbortSignal.timeout(o.timeout),
|
|
148
|
+
});
|
|
149
|
+
gotStatus = true;
|
|
150
|
+
// A 2xx body that fails mid-read is a transport failure, like a dropped connection.
|
|
151
|
+
if (res.status >= 200 && res.status < 300 && res.status !== 204)
|
|
152
|
+
text = await res.text();
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
// Once a status line arrived the request was sent; only a fetch()
|
|
156
|
+
// rejection can be a connect-phase failure.
|
|
157
|
+
if (gotStatus || !nothingSent(err))
|
|
158
|
+
mayHaveRun = true;
|
|
159
|
+
if (retryable && attempt < o.maxRetries) {
|
|
160
|
+
await o.sleep(backoff(attempt++));
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const name = err?.name ?? 'Error';
|
|
164
|
+
// A 2xx arrived, so the call ran (a POST may have created the record):
|
|
165
|
+
// keep its status so the caller doesn't read it as "never connected".
|
|
166
|
+
const e = gotStatus
|
|
167
|
+
? new errors_2.ProfileApiError({
|
|
168
|
+
status: res.status,
|
|
169
|
+
title: 'Response body read failed',
|
|
170
|
+
detail: name,
|
|
171
|
+
requestId: (0, errors_2.requestIdFrom)(res.headers, null),
|
|
172
|
+
})
|
|
173
|
+
: new errors_2.ProfileApiError({ status: 0, title: name }, `0 ${name === 'TimeoutError' ? 'request timed out' : `network error (${name})`}: ${where}`);
|
|
174
|
+
e.cause = err;
|
|
175
|
+
throw e;
|
|
176
|
+
}
|
|
177
|
+
// Auth runs before any handler, so a 401 never mutated state: replay once.
|
|
178
|
+
if (res.status === 401 && !replayed) {
|
|
179
|
+
replayed = true;
|
|
180
|
+
if (o.surface401) {
|
|
181
|
+
unauthorized = (0, errors_2.parseProblem)(401, res.headers, await res.text().catch(() => ''));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
await res.body?.cancel().catch(() => { });
|
|
185
|
+
}
|
|
186
|
+
o.tokens.invalidate(token);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (res.status >= 200 && res.status < 300) {
|
|
190
|
+
// Only DELETE (deleteUser) returns nothing: any 2xx is success, body ignored.
|
|
191
|
+
// Every other method promises a body.
|
|
192
|
+
if (method === 'DELETE')
|
|
193
|
+
return null;
|
|
194
|
+
if (res.status === 204) {
|
|
195
|
+
throw new errors_2.ProfileApiError({
|
|
196
|
+
status: 204,
|
|
197
|
+
title: 'Unexpected response body',
|
|
198
|
+
requestId: (0, errors_2.requestIdFrom)(res.headers, null),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
let data;
|
|
202
|
+
let title = 'Invalid JSON response';
|
|
203
|
+
let parsed = false;
|
|
204
|
+
try {
|
|
205
|
+
data = JSON.parse(text);
|
|
206
|
+
parsed = true;
|
|
207
|
+
if ((opts.valid ?? exports.isObject)(data))
|
|
208
|
+
return data;
|
|
209
|
+
title = 'Unexpected response body';
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
// not JSON
|
|
213
|
+
}
|
|
214
|
+
throw new errors_2.ProfileApiError({
|
|
215
|
+
status: res.status,
|
|
216
|
+
title,
|
|
217
|
+
requestId: (0, errors_2.requestIdFrom)(res.headers, (0, exports.isObject)(data) ? data : null),
|
|
218
|
+
// Kept only for a markup page (a gateway or portal, starting with
|
|
219
|
+
// '<'): any other unparseable 2xx may be a mangled profile, i.e. PII.
|
|
220
|
+
rawBody: !parsed && /^[\s\uFEFF]*</.test(text) ? (0, errors_2.capRawBody)(text) : null,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
// An earlier attempt may have deleted it; later answers can't rule that out.
|
|
224
|
+
if (method === 'DELETE' && res.status === 404 && mayHaveRun) {
|
|
225
|
+
await res.body?.cancel().catch(() => { });
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
// 504: the upstream may have run it. 502 is ambiguous too (nginx also
|
|
229
|
+
// sends it when the upstream closed mid-request), but a false "deleted"
|
|
230
|
+
// is worse than a false 404, so 502 does not set the flag.
|
|
231
|
+
if (res.status === 504)
|
|
232
|
+
mayHaveRun = true;
|
|
233
|
+
const err = (0, errors_2.parseProblem)(res.status, res.headers, await res.text().catch(() => ''));
|
|
234
|
+
if (retryable && RETRY_STATUS.has(res.status) && attempt < o.maxRetries) {
|
|
235
|
+
await o.sleep(err.retryAfter !== null
|
|
236
|
+
? Math.min(err.retryAfter * 1000, RETRY_AFTER_CAP_MS)
|
|
237
|
+
: backoff(attempt));
|
|
238
|
+
attempt++;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
throw err;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.ProfileHttp = ProfileHttp;
|
|
246
|
+
_ProfileHttp_o = new WeakMap(), _ProfileHttp_base = new WeakMap();
|
|
247
|
+
/**
|
|
248
|
+
* Did this fetch rejection happen before anything was sent? Checked on the
|
|
249
|
+
* error and on its `cause` (undici), reading `code` or a string `errno`
|
|
250
|
+
* (node-fetch) together with `syscall`:
|
|
251
|
+
* - syscall `connect` / `getaddrinfo`: nothing sent, whatever the code;
|
|
252
|
+
* - no syscall: nothing sent only for DNS/connect-only and TLS handshake
|
|
253
|
+
* codes. Routing codes (EHOSTUNREACH etc.) can also hit an established
|
|
254
|
+
* keep-alive socket, so without syscall `connect` they may have run;
|
|
255
|
+
* - syscall `read` / `write`, ECONNRESET, timeouts and unrecognised errors:
|
|
256
|
+
* may have run.
|
|
257
|
+
*/
|
|
258
|
+
const CONNECT_ONLY_CODES = new Set([
|
|
259
|
+
'ECONNREFUSED',
|
|
260
|
+
'ENOTFOUND',
|
|
261
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
262
|
+
'ERR_SOCKET_CONNECTION_TIMEOUT',
|
|
263
|
+
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
264
|
+
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
265
|
+
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
266
|
+
'UNABLE_TO_GET_ISSUER_CERT',
|
|
267
|
+
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
268
|
+
]);
|
|
269
|
+
const connectOnlyCode = (code) => CONNECT_ONLY_CODES.has(code) ||
|
|
270
|
+
code.startsWith('EAI_') ||
|
|
271
|
+
code.startsWith('CERT_') ||
|
|
272
|
+
code.startsWith('ERR_TLS_') ||
|
|
273
|
+
code.startsWith('ERR_SSL_');
|
|
274
|
+
function notSent(e) {
|
|
275
|
+
const code = [e?.code, e?.errno].find((c) => typeof c === 'string');
|
|
276
|
+
if (code === undefined)
|
|
277
|
+
return false;
|
|
278
|
+
const syscall = e?.syscall;
|
|
279
|
+
if (syscall === 'connect' || syscall === 'getaddrinfo')
|
|
280
|
+
return true;
|
|
281
|
+
return syscall === undefined && connectOnlyCode(code);
|
|
282
|
+
}
|
|
283
|
+
function nothingSent(err) {
|
|
284
|
+
const e = err;
|
|
285
|
+
return notSent(e) || notSent(e?.cause);
|
|
286
|
+
}
|
|
287
|
+
/** Token endpoint: no HTTP response, or 408, 429, 502, 503, 504. */
|
|
288
|
+
function transientTokenError(err) {
|
|
289
|
+
return (err instanceof errors_1.TokenExchangeError && (err.network || RETRY_STATUS.has(err.statusCode ?? -1)));
|
|
290
|
+
}
|
|
291
|
+
/** Full jitter: uniform in [0, min(cap, base * 2^attempt)]. */
|
|
292
|
+
function backoff(attempt) {
|
|
293
|
+
return Math.random() * Math.min(BACKOFF_CAP_MS, BACKOFF_BASE_MS * 2 ** attempt);
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/profile/http.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+DA,0BAcC;AA7ED;;;;;GAKG;AACH,sCAA2D;AAC3D,yCAAsF;AACtF,qCAAoF;AAsCpF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACxD,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAClC,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,cAAc,GAAG,IAAK,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,IAAI,mBAAU,CAAC,OAAO,CAAC,CAAC;AAEvD,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CACnE,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAD9C,QAAA,QAAQ,YACsC;AAE3D;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,EAAE;QACZ,KAAK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AI,CAAC,CAAC;AACxD,CAAC;AACD,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,CAAC,GAAG,GAA+C,CAAC;IAC1D,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,oEAAoE;AACpE,SAAS,mBAAmB,CAAC,GAAY;IACvC,OAAO,CACL,GAAG,YAAY,2BAAkB,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,CAC7F,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,SAAS,OAAO,CAAC,OAAe;IAC9B,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,eAAe,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The token-endpoint poster, i.e. `HawcxOAuth.postTokenForm` (adds
|
|
3
|
+
* `client_id` + `client_assertion`, `X-Config-Id`, no redirects, error mapping).
|
|
4
|
+
*/
|
|
5
|
+
export interface TokenPoster {
|
|
6
|
+
postTokenForm(body: URLSearchParams, options?: {
|
|
7
|
+
fetch?: typeof fetch;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
}): Promise<Record<string, unknown>>;
|
|
10
|
+
}
|
|
11
|
+
export interface TokenSourceOptions {
|
|
12
|
+
fetch?: typeof fetch;
|
|
13
|
+
/** Token request timeout in ms (default: the HawcxOAuth client's `timeout`). */
|
|
14
|
+
timeout?: number;
|
|
15
|
+
/** Clock in ms; injectable for tests. */
|
|
16
|
+
now?: () => number;
|
|
17
|
+
/** Refresh before expiry (default true). Token exchange: false, re-exchanging can't extend it. */
|
|
18
|
+
refreshEarly?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const DEFAULT_PROFILE_AUDIENCE = "hx-profile";
|
|
21
|
+
/**
|
|
22
|
+
* Caches one access token and refreshes it at
|
|
23
|
+
* `expiry - min(60 s, expires_in / 2)` (at expiry with `refreshEarly: false`);
|
|
24
|
+
* expiry is counted from when the request was sent. Concurrent callers share a
|
|
25
|
+
* single in-flight request. An early refresh runs in the background: every
|
|
26
|
+
* caller, the one that started it included, gets the still-valid cached token.
|
|
27
|
+
* If it fails (any error), the cached token stays in use and the next early
|
|
28
|
+
* attempt waits 30 s (or until expiry, if sooner). Token material
|
|
29
|
+
* lives in `#private` fields so it never shows up in `JSON.stringify` /
|
|
30
|
+
* `util.inspect`.
|
|
31
|
+
*/
|
|
32
|
+
export declare class TokenSource {
|
|
33
|
+
#private;
|
|
34
|
+
constructor(oauth: TokenPoster, grant: Record<string, string>, options?: TokenSourceOptions);
|
|
35
|
+
getToken(): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Drop the cached token (e.g. after a 401) so the next call mints a new one.
|
|
38
|
+
* With `stale`, only if it is still the cached token: a concurrent refresh is kept.
|
|
39
|
+
*/
|
|
40
|
+
invalidate(stale?: string): void;
|
|
41
|
+
}
|
|
42
|
+
/** `client_credentials`; `scope` is sent only when `scopes` is given (absent ⇒ all allowed scopes; `[]` throws). */
|
|
43
|
+
export declare function machineTokenSource(oauth: TokenPoster, options?: TokenSourceOptions & {
|
|
44
|
+
scopes?: readonly string[];
|
|
45
|
+
}): TokenSource;
|
|
46
|
+
/** RFC 8693 exchange of the user's ID token (aud = this client) for a `profile:self` token. */
|
|
47
|
+
export declare function exchangeTokenSource(oauth: TokenPoster, idToken: string, options?: TokenSourceOptions & {
|
|
48
|
+
audience?: string;
|
|
49
|
+
}): TokenSource;
|
|
50
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/profile/tokens.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,W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|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _TokenSource_instances, _TokenSource_oauth, _TokenSource_grant, _TokenSource_options, _TokenSource_now, _TokenSource_refreshEarly, _TokenSource_token, _TokenSource_refreshAt, _TokenSource_expiresAt, _TokenSource_pending, _TokenSource_start, _TokenSource_mint;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TokenSource = exports.DEFAULT_PROFILE_AUDIENCE = void 0;
|
|
16
|
+
exports.machineTokenSource = machineTokenSource;
|
|
17
|
+
exports.exchangeTokenSource = exchangeTokenSource;
|
|
18
|
+
/**
|
|
19
|
+
* Access tokens for the profile service, minted at the OP token endpoint with
|
|
20
|
+
* `private_key_jwt` (RFC 7523): `client_credentials` (RFC 6749 §4.4) for the
|
|
21
|
+
* machine client, RFC 8693 token exchange of an ID token for the delegated one.
|
|
22
|
+
*/
|
|
23
|
+
const errors_1 = require("../errors");
|
|
24
|
+
exports.DEFAULT_PROFILE_AUDIENCE = 'hx-profile';
|
|
25
|
+
const MAX_SKEW_MS = 60000;
|
|
26
|
+
const EARLY_REFRESH_BACKOFF_MS = 30000;
|
|
27
|
+
/**
|
|
28
|
+
* Caches one access token and refreshes it at
|
|
29
|
+
* `expiry - min(60 s, expires_in / 2)` (at expiry with `refreshEarly: false`);
|
|
30
|
+
* expiry is counted from when the request was sent. Concurrent callers share a
|
|
31
|
+
* single in-flight request. An early refresh runs in the background: every
|
|
32
|
+
* caller, the one that started it included, gets the still-valid cached token.
|
|
33
|
+
* If it fails (any error), the cached token stays in use and the next early
|
|
34
|
+
* attempt waits 30 s (or until expiry, if sooner). Token material
|
|
35
|
+
* lives in `#private` fields so it never shows up in `JSON.stringify` /
|
|
36
|
+
* `util.inspect`.
|
|
37
|
+
*/
|
|
38
|
+
class TokenSource {
|
|
39
|
+
constructor(oauth, grant, options = {}) {
|
|
40
|
+
_TokenSource_instances.add(this);
|
|
41
|
+
_TokenSource_oauth.set(this, void 0);
|
|
42
|
+
_TokenSource_grant.set(this, void 0);
|
|
43
|
+
_TokenSource_options.set(this, void 0);
|
|
44
|
+
_TokenSource_now.set(this, void 0);
|
|
45
|
+
_TokenSource_refreshEarly.set(this, void 0);
|
|
46
|
+
_TokenSource_token.set(this, null);
|
|
47
|
+
_TokenSource_refreshAt.set(this, 0);
|
|
48
|
+
_TokenSource_expiresAt.set(this, 0);
|
|
49
|
+
_TokenSource_pending.set(this, null);
|
|
50
|
+
__classPrivateFieldSet(this, _TokenSource_oauth, oauth, "f");
|
|
51
|
+
__classPrivateFieldSet(this, _TokenSource_grant, grant, "f");
|
|
52
|
+
__classPrivateFieldSet(this, _TokenSource_options, { fetch: options.fetch, timeout: options.timeout }, "f");
|
|
53
|
+
__classPrivateFieldSet(this, _TokenSource_now, options.now ?? Date.now, "f");
|
|
54
|
+
__classPrivateFieldSet(this, _TokenSource_refreshEarly, options.refreshEarly ?? true, "f");
|
|
55
|
+
}
|
|
56
|
+
getToken() {
|
|
57
|
+
const token = __classPrivateFieldGet(this, _TokenSource_token, "f");
|
|
58
|
+
const now = __classPrivateFieldGet(this, _TokenSource_now, "f").call(this);
|
|
59
|
+
if (token !== null && now < __classPrivateFieldGet(this, _TokenSource_expiresAt, "f")) {
|
|
60
|
+
// Early refresh: in the background, nobody waits on it.
|
|
61
|
+
if (now >= __classPrivateFieldGet(this, _TokenSource_refreshAt, "f") && __classPrivateFieldGet(this, _TokenSource_pending, "f") === null)
|
|
62
|
+
__classPrivateFieldGet(this, _TokenSource_instances, "m", _TokenSource_start).call(this).catch(() => { });
|
|
63
|
+
return Promise.resolve(token);
|
|
64
|
+
}
|
|
65
|
+
return __classPrivateFieldGet(this, _TokenSource_pending, "f") ?? __classPrivateFieldGet(this, _TokenSource_instances, "m", _TokenSource_start).call(this);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Drop the cached token (e.g. after a 401) so the next call mints a new one.
|
|
69
|
+
* With `stale`, only if it is still the cached token: a concurrent refresh is kept.
|
|
70
|
+
*/
|
|
71
|
+
invalidate(stale) {
|
|
72
|
+
if (stale === undefined || __classPrivateFieldGet(this, _TokenSource_token, "f") === stale)
|
|
73
|
+
__classPrivateFieldSet(this, _TokenSource_token, null, "f");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.TokenSource = TokenSource;
|
|
77
|
+
_TokenSource_oauth = new WeakMap(), _TokenSource_grant = new WeakMap(), _TokenSource_options = new WeakMap(), _TokenSource_now = new WeakMap(), _TokenSource_refreshEarly = new WeakMap(), _TokenSource_token = new WeakMap(), _TokenSource_refreshAt = new WeakMap(), _TokenSource_expiresAt = new WeakMap(), _TokenSource_pending = new WeakMap(), _TokenSource_instances = new WeakSet(), _TokenSource_start = function _TokenSource_start() {
|
|
78
|
+
__classPrivateFieldSet(this, _TokenSource_pending, __classPrivateFieldGet(this, _TokenSource_instances, "m", _TokenSource_mint).call(this)
|
|
79
|
+
.catch((e) => {
|
|
80
|
+
// Early refresh failed: keep the still-valid token, back off.
|
|
81
|
+
const t = __classPrivateFieldGet(this, _TokenSource_token, "f");
|
|
82
|
+
const now = __classPrivateFieldGet(this, _TokenSource_now, "f").call(this);
|
|
83
|
+
if (t !== null && now < __classPrivateFieldGet(this, _TokenSource_expiresAt, "f")) {
|
|
84
|
+
__classPrivateFieldSet(this, _TokenSource_refreshAt, Math.min(now + EARLY_REFRESH_BACKOFF_MS, __classPrivateFieldGet(this, _TokenSource_expiresAt, "f")), "f");
|
|
85
|
+
return t;
|
|
86
|
+
}
|
|
87
|
+
throw e;
|
|
88
|
+
})
|
|
89
|
+
.finally(() => {
|
|
90
|
+
__classPrivateFieldSet(this, _TokenSource_pending, null, "f");
|
|
91
|
+
}), "f");
|
|
92
|
+
return __classPrivateFieldGet(this, _TokenSource_pending, "f");
|
|
93
|
+
}, _TokenSource_mint = async function _TokenSource_mint() {
|
|
94
|
+
const sentAt = __classPrivateFieldGet(this, _TokenSource_now, "f").call(this);
|
|
95
|
+
// Fresh form (and so a fresh assertion / jti) per request.
|
|
96
|
+
const data = await __classPrivateFieldGet(this, _TokenSource_oauth, "f").postTokenForm(new URLSearchParams(__classPrivateFieldGet(this, _TokenSource_grant, "f")), __classPrivateFieldGet(this, _TokenSource_options, "f"));
|
|
97
|
+
const token = data.access_token;
|
|
98
|
+
if (typeof token !== 'string' || token === '') {
|
|
99
|
+
throw new errors_1.TokenExchangeError('Token response missing access_token');
|
|
100
|
+
}
|
|
101
|
+
// Numeric strings accepted; anything not finite and positive caches nothing
|
|
102
|
+
// (every call re-mints).
|
|
103
|
+
const raw = data.expires_in;
|
|
104
|
+
const seconds = typeof raw === 'number' || typeof raw === 'string' ? Number(raw) : NaN;
|
|
105
|
+
const lifetimeMs = Number.isFinite(seconds) && seconds > 0 ? seconds * 1000 : 0;
|
|
106
|
+
__classPrivateFieldSet(this, _TokenSource_token, token, "f");
|
|
107
|
+
__classPrivateFieldSet(this, _TokenSource_expiresAt, sentAt + lifetimeMs, "f");
|
|
108
|
+
__classPrivateFieldSet(this, _TokenSource_refreshAt, __classPrivateFieldGet(this, _TokenSource_refreshEarly, "f")
|
|
109
|
+
? __classPrivateFieldGet(this, _TokenSource_expiresAt, "f") - Math.min(MAX_SKEW_MS, lifetimeMs / 2)
|
|
110
|
+
: __classPrivateFieldGet(this, _TokenSource_expiresAt, "f"), "f");
|
|
111
|
+
return token;
|
|
112
|
+
};
|
|
113
|
+
/** `client_credentials`; `scope` is sent only when `scopes` is given (absent ⇒ all allowed scopes; `[]` throws). */
|
|
114
|
+
function machineTokenSource(oauth, options = {}) {
|
|
115
|
+
const grant = { grant_type: 'client_credentials' };
|
|
116
|
+
if (options.scopes !== undefined) {
|
|
117
|
+
if (options.scopes.length === 0) {
|
|
118
|
+
throw new errors_1.HawcxError("scopes is empty: omit scopes to use the client's default, or pass at least one scope");
|
|
119
|
+
}
|
|
120
|
+
grant.scope = options.scopes.join(' ');
|
|
121
|
+
}
|
|
122
|
+
return new TokenSource(oauth, grant, options);
|
|
123
|
+
}
|
|
124
|
+
/** RFC 8693 exchange of the user's ID token (aud = this client) for a `profile:self` token. */
|
|
125
|
+
function exchangeTokenSource(oauth, idToken, options = {}) {
|
|
126
|
+
return new TokenSource(oauth, {
|
|
127
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
|
|
128
|
+
subject_token: idToken,
|
|
129
|
+
subject_token_type: 'urn:ietf:params:oauth:token-type:id_token',
|
|
130
|
+
requested_token_type: 'urn:ietf:params:oauth:token-type:access_token',
|
|
131
|
+
audience: options.audience ?? exports.DEFAULT_PROFILE_AUDIENCE,
|
|
132
|
+
scope: 'profile:self',
|
|
133
|
+
},
|
|
134
|
+
// The OP caps exp at the ID token's: an early re-exchange can't extend it.
|
|
135
|
+
{ ...options, refreshEarly: false });
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/profile/tokens.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AA0HA,gDAcC;AAGD,kDAkBC;AA7JD;;;;GAIG;AACH,sCAA2D;AAuB9C,QAAA,wB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AC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,+FAA+F;AAC/F,SAAgB,mBAAmB,CACjC,KAAkB,EAClB,OAAe,EACf,UAAsD,EAAE;IAExD,OAAO,IAAI,WAAW,CACpB,KAAK,EACL;QACE,UAAU,EAAE,iDAAiD;QAC7D,aAAa,EAAE,OAAO;QACtB,kBAAkB,EAAE,2CAA2C;QAC/D,oBAAoB,EAAE,+CAA+C;QACrE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,gCAAwB;QACtD,KAAK,EAAE,cAAc;KACtB;IACD,2EAA2E;IAC3E,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile service wire models. Field names are snake_case exactly as on the
|
|
3
|
+
* wire; unknown response fields are passed through untouched.
|
|
4
|
+
*/
|
|
5
|
+
export interface Profile {
|
|
6
|
+
tenant_id: string;
|
|
7
|
+
user_id: string;
|
|
8
|
+
email?: string | null;
|
|
9
|
+
email_verified: boolean;
|
|
10
|
+
phone?: string | null;
|
|
11
|
+
phone_verified: boolean;
|
|
12
|
+
given_name?: string | null;
|
|
13
|
+
family_name?: string | null;
|
|
14
|
+
display_name?: string | null;
|
|
15
|
+
date_of_birth?: string | null;
|
|
16
|
+
address?: Record<string, unknown> | null;
|
|
17
|
+
locale?: string | null;
|
|
18
|
+
timezone?: string | null;
|
|
19
|
+
marketing_opt_in: boolean;
|
|
20
|
+
custom_attributes: Record<string, unknown>;
|
|
21
|
+
status: string;
|
|
22
|
+
created_at: string;
|
|
23
|
+
updated_at: string;
|
|
24
|
+
}
|
|
25
|
+
export interface Consent {
|
|
26
|
+
consent_id: string;
|
|
27
|
+
purpose: string;
|
|
28
|
+
status: string;
|
|
29
|
+
lawful_basis?: string | null;
|
|
30
|
+
notice_version?: string | null;
|
|
31
|
+
source?: string | null;
|
|
32
|
+
created_at: string;
|
|
33
|
+
}
|
|
34
|
+
export interface AuditEvent {
|
|
35
|
+
event_id: string;
|
|
36
|
+
actor: string;
|
|
37
|
+
action: string;
|
|
38
|
+
resource: string;
|
|
39
|
+
before_hash?: string | null;
|
|
40
|
+
after_hash?: string | null;
|
|
41
|
+
detail?: unknown;
|
|
42
|
+
created_at: string;
|
|
43
|
+
}
|
|
44
|
+
export interface Page<T> {
|
|
45
|
+
items: T[];
|
|
46
|
+
/** Pass back as `cursor` for the next page; `null` on the last page. */
|
|
47
|
+
nextCursor: string | null;
|
|
48
|
+
}
|
|
49
|
+
export interface ConsentsPage {
|
|
50
|
+
/** Latest consent per purpose. */
|
|
51
|
+
current: Record<string, Consent>;
|
|
52
|
+
history: Consent[];
|
|
53
|
+
nextCursor: string | null;
|
|
54
|
+
}
|
|
55
|
+
/** Writable profile fields for the delegated `updateMe`. `null` clears, omitted = unchanged. */
|
|
56
|
+
export type MyProfilePatch = Partial<{
|
|
57
|
+
given_name: string | null;
|
|
58
|
+
family_name: string | null;
|
|
59
|
+
display_name: string | null;
|
|
60
|
+
date_of_birth: string | null;
|
|
61
|
+
address: Record<string, unknown> | null;
|
|
62
|
+
locale: string | null;
|
|
63
|
+
timezone: string | null;
|
|
64
|
+
}>;
|
|
65
|
+
/** PATCH body for `updateUser`: `null` clears a field, an omitted key is left unchanged. */
|
|
66
|
+
export type ProfilePatch = MyProfilePatch & {
|
|
67
|
+
status?: string;
|
|
68
|
+
};
|
|
69
|
+
/** PUT body for `replaceUser`. */
|
|
70
|
+
export interface ReplaceUserInput {
|
|
71
|
+
given_name: string;
|
|
72
|
+
family_name: string;
|
|
73
|
+
display_name?: string | null;
|
|
74
|
+
date_of_birth?: string | null;
|
|
75
|
+
address?: Record<string, unknown> | null;
|
|
76
|
+
locale?: string | null;
|
|
77
|
+
timezone?: string | null;
|
|
78
|
+
status?: string;
|
|
79
|
+
}
|
|
80
|
+
/** POST body for `createUser`; the identity `user_id` must already exist. */
|
|
81
|
+
export interface CreateUserInput extends ReplaceUserInput {
|
|
82
|
+
user_id: string;
|
|
83
|
+
}
|
|
84
|
+
export interface ConsentInput {
|
|
85
|
+
status: 'granted' | 'withdrawn';
|
|
86
|
+
lawful_basis?: string;
|
|
87
|
+
notice_version?: string;
|
|
88
|
+
source?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface PageOptions {
|
|
91
|
+
cursor?: string;
|
|
92
|
+
/** 1–200, server default 50. */
|
|
93
|
+
limit?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface ListUsersOptions extends PageOptions {
|
|
96
|
+
email?: string;
|
|
97
|
+
status?: string;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/profile/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAA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AAW,gBAAiB,SAAQ,WAAW;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/profile/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
package/dist/stepup/client.d.ts
CHANGED
|
@@ -34,6 +34,17 @@ export interface StepUpClientPrivateKeyJwtOptions extends StepUpClientBaseOption
|
|
|
34
34
|
apiKey?: string;
|
|
35
35
|
/** JWT time-to-live in seconds (default: 60). */
|
|
36
36
|
jwtTtlSeconds?: number;
|
|
37
|
+
/**
|
|
38
|
+
* OIDC issuer whose `/.well-known/jwks.json` verifies response signatures
|
|
39
|
+
* (default: `baseUrl`). See {@link JwtBearerTransportOptions.issuer}.
|
|
40
|
+
*/
|
|
41
|
+
issuer?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Verify `X-Response-Signature` on every successful response (default:
|
|
44
|
+
* `true`). Emergency escape hatch only — see
|
|
45
|
+
* {@link JwtBearerTransportOptions.verifyResponseSignature}.
|
|
46
|
+
*/
|
|
47
|
+
verifyResponseSignature?: boolean;
|
|
37
48
|
}
|
|
38
49
|
export declare class StepUpClient {
|
|
39
50
|
private transport;
|