@grow-codes/oidc 0.0.0-stage → 0.1.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.
- package/AGENTS.md +122 -0
- package/LICENSE +202 -0
- package/NOTICE +61 -0
- package/README.md +30 -2
- package/lib/chunk-2PTQBDJ6.cjs +890 -0
- package/lib/chunk-2PTQBDJ6.cjs.map +1 -0
- package/lib/chunk-HB2FEHOY.js +843 -0
- package/lib/chunk-HB2FEHOY.js.map +1 -0
- package/lib/index.cjs +1378 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +717 -0
- package/lib/index.d.ts +717 -0
- package/lib/index.js +1152 -0
- package/lib/index.js.map +1 -0
- package/lib/testing/index.cjs +591 -0
- package/lib/testing/index.cjs.map +1 -0
- package/lib/testing/index.d.cts +283 -0
- package/lib/testing/index.d.ts +283 -0
- package/lib/testing/index.js +569 -0
- package/lib/testing/index.js.map +1 -0
- package/lib/verifier-AJ2o8XWA.d.cts +219 -0
- package/lib/verifier-AJ2o8XWA.d.ts +219 -0
- package/package.json +106 -4
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,1378 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk2PTQBDJ6_cjs = require('./chunk-2PTQBDJ6.cjs');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var undici = require('undici');
|
|
6
|
+
var module$1 = require('module');
|
|
7
|
+
var path = require('path');
|
|
8
|
+
|
|
9
|
+
// src/core/health.ts
|
|
10
|
+
var HEALTHY_WORDS = /* @__PURE__ */ new Set([
|
|
11
|
+
"ok",
|
|
12
|
+
"up",
|
|
13
|
+
"healthy",
|
|
14
|
+
"pass",
|
|
15
|
+
"passing",
|
|
16
|
+
"green",
|
|
17
|
+
"ready",
|
|
18
|
+
"available",
|
|
19
|
+
"running",
|
|
20
|
+
"serving"
|
|
21
|
+
]);
|
|
22
|
+
function isHealthyWord(status) {
|
|
23
|
+
return HEALTHY_WORDS.has(status.trim().toLowerCase());
|
|
24
|
+
}
|
|
25
|
+
function healthStatus(status, details = {}, healthy = isHealthyWord(status)) {
|
|
26
|
+
const flat = {};
|
|
27
|
+
for (const [k, v] of Object.entries(details)) {
|
|
28
|
+
if (v === void 0 || v === null) continue;
|
|
29
|
+
if (typeof v === "string") flat[k] = v;
|
|
30
|
+
else if (typeof v === "number" || typeof v === "boolean" || typeof v === "bigint")
|
|
31
|
+
flat[k] = String(v);
|
|
32
|
+
else if (typeof v === "object") flat[k] = JSON.stringify(v);
|
|
33
|
+
}
|
|
34
|
+
return { healthy, status, details: flat };
|
|
35
|
+
}
|
|
36
|
+
async function probeHealth(probe) {
|
|
37
|
+
try {
|
|
38
|
+
return await probe();
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (err instanceof chunk2PTQBDJ6_cjs.OidcError) {
|
|
41
|
+
if (err.code === chunk2PTQBDJ6_cjs.ErrorCode.Cancelled || err.code === chunk2PTQBDJ6_cjs.ErrorCode.Config) throw err;
|
|
42
|
+
if (err.httpStatus !== void 0) {
|
|
43
|
+
return healthStatus("unhealthy", { httpStatus: err.httpStatus, error: err.code }, false);
|
|
44
|
+
}
|
|
45
|
+
return healthStatus("unreachable", { error: err.code }, false);
|
|
46
|
+
}
|
|
47
|
+
return healthStatus("unreachable", { error: chunk2PTQBDJ6_cjs.ErrorCode.Unavailable }, false);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/core/hooks.ts
|
|
52
|
+
var silentLogger = Object.freeze({
|
|
53
|
+
debug: () => void 0,
|
|
54
|
+
info: () => void 0,
|
|
55
|
+
warn: () => void 0,
|
|
56
|
+
error: () => void 0
|
|
57
|
+
});
|
|
58
|
+
function safeCall(fn, ...args) {
|
|
59
|
+
if (fn === void 0) return;
|
|
60
|
+
try {
|
|
61
|
+
const result = fn(...args);
|
|
62
|
+
if (result instanceof Promise) result.catch(() => void 0);
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function safeLogger(logger) {
|
|
67
|
+
if (logger === void 0) return silentLogger;
|
|
68
|
+
return {
|
|
69
|
+
debug: (m, f) => {
|
|
70
|
+
safeCall(
|
|
71
|
+
(a, b) => {
|
|
72
|
+
logger.debug(a, b);
|
|
73
|
+
},
|
|
74
|
+
m,
|
|
75
|
+
f
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
info: (m, f) => {
|
|
79
|
+
safeCall(
|
|
80
|
+
(a, b) => {
|
|
81
|
+
logger.info(a, b);
|
|
82
|
+
},
|
|
83
|
+
m,
|
|
84
|
+
f
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
warn: (m, f) => {
|
|
88
|
+
safeCall(
|
|
89
|
+
(a, b) => {
|
|
90
|
+
logger.warn(a, b);
|
|
91
|
+
},
|
|
92
|
+
m,
|
|
93
|
+
f
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
error: (m, f) => {
|
|
97
|
+
safeCall(
|
|
98
|
+
(a, b) => {
|
|
99
|
+
logger.error(a, b);
|
|
100
|
+
},
|
|
101
|
+
m,
|
|
102
|
+
f
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/core/retry.ts
|
|
109
|
+
var RetryPolicy = class _RetryPolicy {
|
|
110
|
+
static DEFAULTS = Object.freeze({
|
|
111
|
+
maxRetries: 3,
|
|
112
|
+
initialBackoffMs: 100,
|
|
113
|
+
maxBackoffMs: 1e4,
|
|
114
|
+
multiplier: 2,
|
|
115
|
+
maxRetryAfterMs: 6e4
|
|
116
|
+
});
|
|
117
|
+
maxRetries;
|
|
118
|
+
initialBackoffMs;
|
|
119
|
+
maxBackoffMs;
|
|
120
|
+
multiplier;
|
|
121
|
+
maxRetryAfterMs;
|
|
122
|
+
random;
|
|
123
|
+
constructor(options = {}) {
|
|
124
|
+
const d = _RetryPolicy.DEFAULTS;
|
|
125
|
+
this.maxRetries = options.maxRetries ?? d.maxRetries;
|
|
126
|
+
this.initialBackoffMs = options.initialBackoffMs ?? d.initialBackoffMs;
|
|
127
|
+
this.maxBackoffMs = options.maxBackoffMs ?? d.maxBackoffMs;
|
|
128
|
+
this.multiplier = options.multiplier ?? d.multiplier;
|
|
129
|
+
this.maxRetryAfterMs = options.maxRetryAfterMs ?? d.maxRetryAfterMs;
|
|
130
|
+
this.random = options.random ?? Math.random;
|
|
131
|
+
Object.freeze(this);
|
|
132
|
+
}
|
|
133
|
+
/** Returns a policy from options, keeping an existing instance as is. */
|
|
134
|
+
static from(value) {
|
|
135
|
+
return value instanceof _RetryPolicy ? value : new _RetryPolicy(value);
|
|
136
|
+
}
|
|
137
|
+
/** Upper bound of the backoff before retry `n` (0-based): `min(max, initial * multiplier^n)`. */
|
|
138
|
+
backoffCapMs(retry) {
|
|
139
|
+
return Math.min(this.maxBackoffMs, this.initialBackoffMs * this.multiplier ** retry);
|
|
140
|
+
}
|
|
141
|
+
/** Full-jitter backoff before retry `n` (0-based): `random(0, backoffCapMs(n))`. */
|
|
142
|
+
backoffMs(retry) {
|
|
143
|
+
return this.random() * this.backoffCapMs(retry);
|
|
144
|
+
}
|
|
145
|
+
/** Validation problems (empty when valid). */
|
|
146
|
+
problems() {
|
|
147
|
+
const out = [];
|
|
148
|
+
if (!Number.isInteger(this.maxRetries) || this.maxRetries < 0)
|
|
149
|
+
out.push("retry.maxRetries must be an integer >= 0");
|
|
150
|
+
if (!(this.initialBackoffMs >= 0)) out.push("retry.initialBackoffMs must be >= 0");
|
|
151
|
+
if (!(this.maxBackoffMs >= 0)) out.push("retry.maxBackoffMs must be >= 0");
|
|
152
|
+
if (!(this.multiplier >= 1)) out.push("retry.multiplier must be >= 1");
|
|
153
|
+
if (!(this.maxRetryAfterMs >= 0)) out.push("retry.maxRetryAfterMs must be >= 0");
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
toJSON() {
|
|
157
|
+
return {
|
|
158
|
+
maxRetries: this.maxRetries,
|
|
159
|
+
initialBackoffMs: this.initialBackoffMs,
|
|
160
|
+
maxBackoffMs: this.maxBackoffMs,
|
|
161
|
+
multiplier: this.multiplier,
|
|
162
|
+
maxRetryAfterMs: this.maxRetryAfterMs
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
function parseRetryAfter(value, now = Date.now()) {
|
|
167
|
+
if (value === null || value === void 0) return void 0;
|
|
168
|
+
const text = value.trim();
|
|
169
|
+
if (text === "") return void 0;
|
|
170
|
+
if (/^\d+(\.\d+)?$/.test(text)) return Math.round(Number(text) * 1e3);
|
|
171
|
+
if (!/[a-z]/i.test(text)) return void 0;
|
|
172
|
+
const at = Date.parse(text);
|
|
173
|
+
if (Number.isNaN(at)) return void 0;
|
|
174
|
+
return Math.max(0, at - now);
|
|
175
|
+
}
|
|
176
|
+
var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set([
|
|
177
|
+
"GET",
|
|
178
|
+
"HEAD",
|
|
179
|
+
"OPTIONS",
|
|
180
|
+
"PUT",
|
|
181
|
+
"DELETE"
|
|
182
|
+
]);
|
|
183
|
+
function isIdempotentMethod(method) {
|
|
184
|
+
return IDEMPOTENT_METHODS.has(method.toUpperCase());
|
|
185
|
+
}
|
|
186
|
+
function isRetryableStatus(status, idempotent) {
|
|
187
|
+
if (status === 429) return true;
|
|
188
|
+
if (!idempotent) return false;
|
|
189
|
+
return status === 408 || status === 500 || status === 502 || status === 503 || status === 504;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/core/options.ts
|
|
193
|
+
var DEFAULT_TIMEOUTS = Object.freeze({
|
|
194
|
+
connectTimeoutMs: 1e4,
|
|
195
|
+
requestTimeoutMs: 3e4,
|
|
196
|
+
totalTimeoutMs: 12e4
|
|
197
|
+
});
|
|
198
|
+
function resolveCommonConfig(options, defaultUrl) {
|
|
199
|
+
const out = {
|
|
200
|
+
url: options.url ?? defaultUrl,
|
|
201
|
+
connectTimeoutMs: options.connectTimeoutMs ?? DEFAULT_TIMEOUTS.connectTimeoutMs,
|
|
202
|
+
requestTimeoutMs: options.requestTimeoutMs ?? DEFAULT_TIMEOUTS.requestTimeoutMs,
|
|
203
|
+
totalTimeoutMs: options.totalTimeoutMs ?? DEFAULT_TIMEOUTS.totalTimeoutMs,
|
|
204
|
+
retry: RetryPolicy.from(options.retry),
|
|
205
|
+
tls: Object.freeze({ ...options.tls }),
|
|
206
|
+
headers: Object.freeze({ ...options.headers })
|
|
207
|
+
};
|
|
208
|
+
if (options.proxy !== void 0) out.proxy = options.proxy;
|
|
209
|
+
if (options.userAgentSuffix !== void 0) out.userAgentSuffix = options.userAgentSuffix;
|
|
210
|
+
if (options.hooks !== void 0) out.hooks = options.hooks;
|
|
211
|
+
if (options.logger !== void 0) out.logger = options.logger;
|
|
212
|
+
return out;
|
|
213
|
+
}
|
|
214
|
+
function isHttpUrl(value) {
|
|
215
|
+
try {
|
|
216
|
+
const u = new URL(value);
|
|
217
|
+
return u.protocol === "http:" || u.protocol === "https:";
|
|
218
|
+
} catch {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function validateCommonConfig(config) {
|
|
223
|
+
const problems = [];
|
|
224
|
+
if (!isHttpUrl(config.url)) problems.push("url must be an http or https URL");
|
|
225
|
+
for (const key of ["connectTimeoutMs", "requestTimeoutMs", "totalTimeoutMs"]) {
|
|
226
|
+
const v = config[key];
|
|
227
|
+
if (!Number.isFinite(v) || v <= 0) problems.push(`${key} must be a positive number`);
|
|
228
|
+
}
|
|
229
|
+
problems.push(...config.retry.problems());
|
|
230
|
+
const tls = config.tls;
|
|
231
|
+
if (tls.clientCertPath === void 0 !== (tls.clientKeyPath === void 0)) {
|
|
232
|
+
problems.push("tls.clientCertPath and tls.clientKeyPath must be given together");
|
|
233
|
+
}
|
|
234
|
+
if (config.proxy !== void 0 && !isHttpUrl(config.proxy)) {
|
|
235
|
+
problems.push("proxy must be an http or https URL");
|
|
236
|
+
}
|
|
237
|
+
if (problems.length > 0) throw new chunk2PTQBDJ6_cjs.ConfigError(`invalid configuration: ${problems.join("; ")}`);
|
|
238
|
+
}
|
|
239
|
+
function readCommonEnv(reader, vendor = {}) {
|
|
240
|
+
const out = {};
|
|
241
|
+
const url = reader.string("URL", vendor.url);
|
|
242
|
+
if (url !== void 0) out.url = url;
|
|
243
|
+
const connect = reader.duration("CONNECT_TIMEOUT");
|
|
244
|
+
if (connect !== void 0) out.connectTimeoutMs = connect;
|
|
245
|
+
const request = reader.duration("REQUEST_TIMEOUT");
|
|
246
|
+
if (request !== void 0) out.requestTimeoutMs = request;
|
|
247
|
+
const total = reader.duration("TOTAL_TIMEOUT");
|
|
248
|
+
if (total !== void 0) out.totalTimeoutMs = total;
|
|
249
|
+
const maxRetries = reader.int("MAX_RETRIES");
|
|
250
|
+
if (maxRetries !== void 0) out.retry = { maxRetries };
|
|
251
|
+
const tls = {};
|
|
252
|
+
const ca = reader.string("CA_CERT", vendor.caCert);
|
|
253
|
+
if (ca !== void 0) tls.caCertPath = ca;
|
|
254
|
+
const cert = reader.string("CLIENT_CERT", vendor.clientCert);
|
|
255
|
+
if (cert !== void 0) tls.clientCertPath = cert;
|
|
256
|
+
const key = reader.string("CLIENT_KEY", vendor.clientKey);
|
|
257
|
+
if (key !== void 0) tls.clientKeyPath = key;
|
|
258
|
+
const insecure = reader.bool("INSECURE_SKIP_VERIFY", vendor.insecureSkipVerify);
|
|
259
|
+
if (insecure !== void 0) tls.insecureSkipVerify = insecure;
|
|
260
|
+
if (Object.keys(tls).length > 0) out.tls = tls;
|
|
261
|
+
const proxy = reader.string("PROXY", vendor.proxy);
|
|
262
|
+
if (proxy !== void 0) out.proxy = proxy;
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
function definedOnly(value) {
|
|
266
|
+
const out = {};
|
|
267
|
+
for (const [k, v] of Object.entries(value)) {
|
|
268
|
+
if (v !== void 0) out[k] = v;
|
|
269
|
+
}
|
|
270
|
+
return out;
|
|
271
|
+
}
|
|
272
|
+
function mergeOptions(...layers) {
|
|
273
|
+
const out = {};
|
|
274
|
+
for (const layer of layers) {
|
|
275
|
+
if (layer === void 0) continue;
|
|
276
|
+
for (const [k, v] of Object.entries(definedOnly(layer))) {
|
|
277
|
+
const prev = out[k];
|
|
278
|
+
if ((k === "tls" || k === "headers" || k === "retry" && !(v instanceof RetryPolicy)) && typeof prev === "object" && prev !== null) {
|
|
279
|
+
const base = prev instanceof RetryPolicy ? prev.toJSON() : prev;
|
|
280
|
+
out[k] = { ...base, ...definedOnly(v) };
|
|
281
|
+
} else {
|
|
282
|
+
out[k] = v;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return out;
|
|
287
|
+
}
|
|
288
|
+
function describeCommonConfig(config) {
|
|
289
|
+
const headers = {};
|
|
290
|
+
for (const k of Object.keys(config.headers)) headers[k] = chunk2PTQBDJ6_cjs.REDACTED;
|
|
291
|
+
const out = {
|
|
292
|
+
url: chunk2PTQBDJ6_cjs.redactUrl(config.url),
|
|
293
|
+
connectTimeoutMs: config.connectTimeoutMs,
|
|
294
|
+
requestTimeoutMs: config.requestTimeoutMs,
|
|
295
|
+
totalTimeoutMs: config.totalTimeoutMs,
|
|
296
|
+
retry: config.retry.toJSON(),
|
|
297
|
+
tls: {
|
|
298
|
+
...config.tls,
|
|
299
|
+
...config.tls.caCertPem === void 0 ? {} : { caCertPem: chunk2PTQBDJ6_cjs.REDACTED }
|
|
300
|
+
},
|
|
301
|
+
headers
|
|
302
|
+
};
|
|
303
|
+
if (config.proxy !== void 0) out.proxy = chunk2PTQBDJ6_cjs.redactUrl(config.proxy);
|
|
304
|
+
if (config.userAgentSuffix !== void 0) out.userAgentSuffix = config.userAgentSuffix;
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
function secretValues(...values) {
|
|
308
|
+
return values.filter((v) => v instanceof chunk2PTQBDJ6_cjs.Secret).map((s) => s.reveal());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// src/core/version.ts
|
|
312
|
+
var SDK_VERSION = "0.1.1";
|
|
313
|
+
var PACKAGE_KEY = "oidc";
|
|
314
|
+
var LANGUAGE = "typescript";
|
|
315
|
+
var SDK_KIT_VERSION = "0.3.0";
|
|
316
|
+
|
|
317
|
+
// src/core/transport.ts
|
|
318
|
+
var DEFAULT_REQUEST_ID_HEADERS = [
|
|
319
|
+
"x-request-id",
|
|
320
|
+
"x-amzn-requestid",
|
|
321
|
+
"x-amz-request-id",
|
|
322
|
+
"x-datadog-request-id",
|
|
323
|
+
"request-id",
|
|
324
|
+
"x-correlation-id"
|
|
325
|
+
];
|
|
326
|
+
var MAX_VENDOR_TEXT = 300;
|
|
327
|
+
var PRE_SEND_CODES = /* @__PURE__ */ new Set([
|
|
328
|
+
"ECONNREFUSED",
|
|
329
|
+
"ENOTFOUND",
|
|
330
|
+
"EAI_AGAIN",
|
|
331
|
+
"EHOSTUNREACH",
|
|
332
|
+
"ENETUNREACH",
|
|
333
|
+
"EADDRNOTAVAIL",
|
|
334
|
+
"UND_ERR_CONNECT_TIMEOUT"
|
|
335
|
+
]);
|
|
336
|
+
var TLS_CODE = /CERT|SELF_SIGNED|UNABLE_TO_|ERR_TLS|ERR_SSL|DEPTH_ZERO/;
|
|
337
|
+
var CANCEL = /* @__PURE__ */ Symbol("cancel");
|
|
338
|
+
var ATTEMPT_TIMEOUT = /* @__PURE__ */ Symbol("attempt-timeout");
|
|
339
|
+
var insecureWarned = false;
|
|
340
|
+
var AbortedAttempt = class extends Error {
|
|
341
|
+
kind;
|
|
342
|
+
constructor(kind) {
|
|
343
|
+
super("aborted");
|
|
344
|
+
this.kind = kind;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
function errorCode(err) {
|
|
348
|
+
let current = err;
|
|
349
|
+
for (let depth = 0; depth < 5 && current !== void 0 && current !== null; depth++) {
|
|
350
|
+
const code = current.code;
|
|
351
|
+
if (typeof code === "string") return code;
|
|
352
|
+
current = current.cause;
|
|
353
|
+
}
|
|
354
|
+
return void 0;
|
|
355
|
+
}
|
|
356
|
+
function readPem(path) {
|
|
357
|
+
return path === void 0 ? void 0 : fs.readFileSync(path, "utf8");
|
|
358
|
+
}
|
|
359
|
+
function createDispatcher(config, logger = safeLogger(config.logger)) {
|
|
360
|
+
const tls = config.tls;
|
|
361
|
+
if (tls.insecureSkipVerify === true && !insecureWarned) {
|
|
362
|
+
insecureWarned = true;
|
|
363
|
+
logger.warn("TLS certificate verification is disabled (insecureSkipVerify); use only in tests");
|
|
364
|
+
}
|
|
365
|
+
const caParts = [tls.caCertPem, readPem(tls.caCertPath)].filter(
|
|
366
|
+
(v) => v !== void 0
|
|
367
|
+
);
|
|
368
|
+
const tlsOptions = {
|
|
369
|
+
timeout: config.connectTimeoutMs,
|
|
370
|
+
rejectUnauthorized: tls.insecureSkipVerify !== true,
|
|
371
|
+
...caParts.length > 0 ? { ca: caParts } : {},
|
|
372
|
+
...tls.clientCertPath === void 0 ? {} : { cert: readPem(tls.clientCertPath) },
|
|
373
|
+
...tls.clientKeyPath === void 0 ? {} : { key: readPem(tls.clientKeyPath) }
|
|
374
|
+
};
|
|
375
|
+
if (config.proxy !== void 0) {
|
|
376
|
+
return new undici.ProxyAgent({
|
|
377
|
+
uri: config.proxy,
|
|
378
|
+
connect: { timeout: config.connectTimeoutMs },
|
|
379
|
+
requestTls: tlsOptions
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return new undici.Agent({ connect: tlsOptions });
|
|
383
|
+
}
|
|
384
|
+
var HttpTransport = class {
|
|
385
|
+
/** `grow-codes-<key>/<version> (typescript)[ <suffix>]`. */
|
|
386
|
+
userAgent;
|
|
387
|
+
retry;
|
|
388
|
+
#config;
|
|
389
|
+
#options;
|
|
390
|
+
#logger;
|
|
391
|
+
#hooks;
|
|
392
|
+
#fetch;
|
|
393
|
+
#sleep;
|
|
394
|
+
#now;
|
|
395
|
+
#requestIdHeaders;
|
|
396
|
+
#dispatcher;
|
|
397
|
+
#closed = false;
|
|
398
|
+
constructor(options) {
|
|
399
|
+
this.#options = options;
|
|
400
|
+
this.#config = options.config;
|
|
401
|
+
this.retry = options.config.retry;
|
|
402
|
+
this.#logger = safeLogger(options.config.logger);
|
|
403
|
+
this.#hooks = options.config.hooks ?? {};
|
|
404
|
+
this.#fetch = undici.fetch;
|
|
405
|
+
this.#sleep = options.sleep ?? chunk2PTQBDJ6_cjs.sleep;
|
|
406
|
+
this.#now = options.now ?? Date.now;
|
|
407
|
+
this.#requestIdHeaders = options.requestIdHeaders ?? DEFAULT_REQUEST_ID_HEADERS;
|
|
408
|
+
this.#dispatcher = options.dispatcher;
|
|
409
|
+
const suffix = options.config.userAgentSuffix;
|
|
410
|
+
this.userAgent = `grow-codes-${PACKAGE_KEY}/${SDK_VERSION} (${LANGUAGE})` + (suffix !== void 0 && suffix !== "" ? ` ${suffix}` : "");
|
|
411
|
+
}
|
|
412
|
+
/** Whether {@link close} was called. */
|
|
413
|
+
get closed() {
|
|
414
|
+
return this.#closed;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Throws `CancelledError` (`"<operation>: client is closed"`, not retryable) once {@link close}
|
|
418
|
+
* was called (SPEC §2.4). Requests check this themselves; service methods that send no request
|
|
419
|
+
* (cached reads, local helpers) call it first.
|
|
420
|
+
*/
|
|
421
|
+
ensureOpen(operation) {
|
|
422
|
+
if (this.#closed) throw new chunk2PTQBDJ6_cjs.CancelledError(`${operation}: client is closed`);
|
|
423
|
+
}
|
|
424
|
+
/** Builds the absolute URL for a path and query. */
|
|
425
|
+
buildUrl(path, query) {
|
|
426
|
+
let url;
|
|
427
|
+
if (/^https?:\/\//i.test(path)) {
|
|
428
|
+
url = new URL(path);
|
|
429
|
+
} else {
|
|
430
|
+
const base = this.#config.url.endsWith("/") ? this.#config.url : this.#config.url + "/";
|
|
431
|
+
url = new URL(path.replace(/^\/+/, ""), base);
|
|
432
|
+
}
|
|
433
|
+
for (const [k, v] of Object.entries(query ?? {})) {
|
|
434
|
+
if (v === void 0 || v === null) continue;
|
|
435
|
+
if (Array.isArray(v)) {
|
|
436
|
+
for (const item of v)
|
|
437
|
+
url.searchParams.append(k, String(item));
|
|
438
|
+
} else {
|
|
439
|
+
url.searchParams.append(k, String(v));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return url;
|
|
443
|
+
}
|
|
444
|
+
/** Redacts known secrets from a text (error messages, vendor text). */
|
|
445
|
+
redact(text) {
|
|
446
|
+
return chunk2PTQBDJ6_cjs.redactText(text, this.#knownSecrets());
|
|
447
|
+
}
|
|
448
|
+
#knownSecrets() {
|
|
449
|
+
return [...this.#options.knownSecrets?.() ?? []];
|
|
450
|
+
}
|
|
451
|
+
#getDispatcher() {
|
|
452
|
+
this.#dispatcher ??= createDispatcher(this.#config, this.#logger);
|
|
453
|
+
return this.#dispatcher;
|
|
454
|
+
}
|
|
455
|
+
/** `GET` shortcut. */
|
|
456
|
+
get(path, options = {}) {
|
|
457
|
+
return this.request({ ...options, method: "GET", path });
|
|
458
|
+
}
|
|
459
|
+
/** `POST` shortcut. */
|
|
460
|
+
post(path, options = {}) {
|
|
461
|
+
return this.request({ ...options, method: "POST", path });
|
|
462
|
+
}
|
|
463
|
+
/** `PUT` shortcut. */
|
|
464
|
+
put(path, options = {}) {
|
|
465
|
+
return this.request({ ...options, method: "PUT", path });
|
|
466
|
+
}
|
|
467
|
+
/** `DELETE` shortcut. */
|
|
468
|
+
delete(path, options = {}) {
|
|
469
|
+
return this.request({ ...options, method: "DELETE", path });
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Sends a request with retries; throws an SDK error on failure. Every error message passes
|
|
473
|
+
* through {@link redact} with the known secrets.
|
|
474
|
+
*/
|
|
475
|
+
async request(options) {
|
|
476
|
+
try {
|
|
477
|
+
return await this.#request(options);
|
|
478
|
+
} catch (err) {
|
|
479
|
+
if (err instanceof chunk2PTQBDJ6_cjs.OidcError) err.message = this.redact(err.message);
|
|
480
|
+
throw err;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
async #request(options) {
|
|
484
|
+
const method = (options.method ?? "GET").toUpperCase();
|
|
485
|
+
const operation = options.operation ?? `${method} ${options.path.split("?")[0] ?? ""}`;
|
|
486
|
+
this.ensureOpen(operation);
|
|
487
|
+
const signal = options.signal;
|
|
488
|
+
if (signal?.aborted === true) throw new chunk2PTQBDJ6_cjs.CancelledError(`${operation}: cancelled`);
|
|
489
|
+
const url = this.buildUrl(options.path, options.query);
|
|
490
|
+
const safeUrl = chunk2PTQBDJ6_cjs.redactUrl(url);
|
|
491
|
+
const headers = this.#buildHeaders(options);
|
|
492
|
+
const body = options.json !== void 0 ? JSON.stringify(options.json) : options.body;
|
|
493
|
+
const idempotent = options.idempotent ?? isIdempotentMethod(method);
|
|
494
|
+
const requestTimeout = options.requestTimeoutMs ?? this.#config.requestTimeoutMs;
|
|
495
|
+
const totalTimeout = options.totalTimeoutMs ?? this.#config.totalTimeoutMs;
|
|
496
|
+
const start = this.#now();
|
|
497
|
+
const deadline = start + totalTimeout;
|
|
498
|
+
const policy = this.retry;
|
|
499
|
+
for (let attempt = 1; ; attempt++) {
|
|
500
|
+
const remaining = deadline - this.#now();
|
|
501
|
+
if (remaining <= 0) {
|
|
502
|
+
throw new chunk2PTQBDJ6_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`);
|
|
503
|
+
}
|
|
504
|
+
const attemptTimeout = Math.min(requestTimeout, remaining);
|
|
505
|
+
const isTotal = attemptTimeout < requestTimeout;
|
|
506
|
+
safeCall(this.#hooks.onRequest, {
|
|
507
|
+
method,
|
|
508
|
+
url: safeUrl,
|
|
509
|
+
headers: chunk2PTQBDJ6_cjs.redactHeaders(headers),
|
|
510
|
+
attempt
|
|
511
|
+
});
|
|
512
|
+
this.#logger.debug("http request", { method, url: safeUrl, attempt });
|
|
513
|
+
const attemptStart = this.#now();
|
|
514
|
+
let failure;
|
|
515
|
+
let willRetry = false;
|
|
516
|
+
let waitMs = 0;
|
|
517
|
+
try {
|
|
518
|
+
const res = await this.#attempt(
|
|
519
|
+
url,
|
|
520
|
+
method,
|
|
521
|
+
headers,
|
|
522
|
+
body,
|
|
523
|
+
attemptTimeout,
|
|
524
|
+
signal,
|
|
525
|
+
options.responseType ?? "json",
|
|
526
|
+
options.allowStatus ?? []
|
|
527
|
+
);
|
|
528
|
+
const durationMs = this.#now() - attemptStart;
|
|
529
|
+
const requestId = this.#requestId(res.headers);
|
|
530
|
+
safeCall(this.#hooks.onResponse, {
|
|
531
|
+
method,
|
|
532
|
+
url: safeUrl,
|
|
533
|
+
status: res.status,
|
|
534
|
+
durationMs,
|
|
535
|
+
attempt,
|
|
536
|
+
...requestId === void 0 ? {} : { requestId }
|
|
537
|
+
});
|
|
538
|
+
this.#logger.debug("http response", {
|
|
539
|
+
method,
|
|
540
|
+
url: safeUrl,
|
|
541
|
+
status: res.status,
|
|
542
|
+
durationMs,
|
|
543
|
+
attempt
|
|
544
|
+
});
|
|
545
|
+
if (res.status < 400 || options.allowStatus?.includes(res.status) === true) {
|
|
546
|
+
return {
|
|
547
|
+
status: res.status,
|
|
548
|
+
headers: res.headers,
|
|
549
|
+
data: res.data,
|
|
550
|
+
...requestId === void 0 ? {} : { requestId },
|
|
551
|
+
durationMs: this.#now() - start,
|
|
552
|
+
attempts: attempt,
|
|
553
|
+
...res.status >= 400 ? { text: res.text } : {}
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
const retryAfter = res.status === 429 || res.status === 503 ? parseRetryAfter(res.headers.get("retry-after"), this.#now()) : void 0;
|
|
557
|
+
const reason = this.vendorText(res.text);
|
|
558
|
+
const defaultError = chunk2PTQBDJ6_cjs.errorForStatus(operation, res.status, {
|
|
559
|
+
...reason === void 0 ? {} : { reason },
|
|
560
|
+
...requestId === void 0 ? {} : { requestId },
|
|
561
|
+
...retryAfter === void 0 ? {} : { retryAfterMs: retryAfter }
|
|
562
|
+
});
|
|
563
|
+
const classified = this.#classifyResponse(options.classifyError, {
|
|
564
|
+
operation,
|
|
565
|
+
method,
|
|
566
|
+
status: res.status,
|
|
567
|
+
headers: res.headers,
|
|
568
|
+
body: res.text,
|
|
569
|
+
...reason === void 0 ? {} : { reason },
|
|
570
|
+
...requestId === void 0 ? {} : { requestId },
|
|
571
|
+
...retryAfter === void 0 ? {} : { retryAfterMs: retryAfter },
|
|
572
|
+
attempt,
|
|
573
|
+
defaultError
|
|
574
|
+
});
|
|
575
|
+
failure = classified ?? defaultError;
|
|
576
|
+
if (isRetryableStatus(res.status, idempotent) && (classified === void 0 || classified.retryable) && attempt <= policy.maxRetries) {
|
|
577
|
+
const backoff = policy.backoffMs(attempt - 1);
|
|
578
|
+
if (retryAfter !== void 0) {
|
|
579
|
+
if (retryAfter > policy.maxRetryAfterMs || retryAfter >= deadline - this.#now()) {
|
|
580
|
+
willRetry = false;
|
|
581
|
+
} else {
|
|
582
|
+
willRetry = true;
|
|
583
|
+
waitMs = Math.max(retryAfter, backoff);
|
|
584
|
+
}
|
|
585
|
+
} else {
|
|
586
|
+
willRetry = true;
|
|
587
|
+
waitMs = backoff;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
} catch (err) {
|
|
591
|
+
failure = this.#classify(err, operation, attemptTimeout, isTotal, totalTimeout);
|
|
592
|
+
const preSend = PRE_SEND_CODES.has(errorCode(err) ?? "");
|
|
593
|
+
willRetry = failure.retryable && !(failure.code === "TIMEOUT" && isTotal) && (idempotent || preSend) && attempt <= policy.maxRetries;
|
|
594
|
+
waitMs = willRetry ? policy.backoffMs(attempt - 1) : 0;
|
|
595
|
+
}
|
|
596
|
+
if (willRetry && waitMs >= deadline - this.#now()) {
|
|
597
|
+
safeCall(this.#hooks.onError, {
|
|
598
|
+
method,
|
|
599
|
+
url: safeUrl,
|
|
600
|
+
error: failure,
|
|
601
|
+
attempt,
|
|
602
|
+
willRetry: false
|
|
603
|
+
});
|
|
604
|
+
throw new chunk2PTQBDJ6_cjs.TimeoutError(
|
|
605
|
+
`${operation}: total timeout of ${totalTimeout} ms exceeded after ${attempt} attempts`,
|
|
606
|
+
{
|
|
607
|
+
cause: failure,
|
|
608
|
+
...failure.httpStatus === void 0 ? {} : { httpStatus: failure.httpStatus },
|
|
609
|
+
...failure.requestId === void 0 ? {} : { requestId: failure.requestId }
|
|
610
|
+
}
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
safeCall(this.#hooks.onError, { method, url: safeUrl, error: failure, attempt, willRetry });
|
|
614
|
+
if (!willRetry) {
|
|
615
|
+
this.#logger.debug("http call failed", {
|
|
616
|
+
method,
|
|
617
|
+
url: safeUrl,
|
|
618
|
+
attempt,
|
|
619
|
+
code: failure.code
|
|
620
|
+
});
|
|
621
|
+
throw failure;
|
|
622
|
+
}
|
|
623
|
+
this.#logger.warn("http call failed, retrying", {
|
|
624
|
+
method,
|
|
625
|
+
url: safeUrl,
|
|
626
|
+
attempt,
|
|
627
|
+
code: failure.code,
|
|
628
|
+
waitMs: Math.round(waitMs)
|
|
629
|
+
});
|
|
630
|
+
await this.#sleep(waitMs, signal).catch((err) => {
|
|
631
|
+
throw err instanceof chunk2PTQBDJ6_cjs.OidcError ? err : new chunk2PTQBDJ6_cjs.CancelledError(`${operation}: cancelled`);
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
#buildHeaders(options) {
|
|
636
|
+
const headers = {
|
|
637
|
+
accept: "application/json",
|
|
638
|
+
"user-agent": this.userAgent
|
|
639
|
+
};
|
|
640
|
+
const layers = [
|
|
641
|
+
this.#config.headers,
|
|
642
|
+
this.#options.defaultHeaders?.() ?? {},
|
|
643
|
+
options.headers ?? {}
|
|
644
|
+
];
|
|
645
|
+
for (const layer of layers) {
|
|
646
|
+
for (const [k, v] of Object.entries(layer)) headers[k.toLowerCase()] = v;
|
|
647
|
+
}
|
|
648
|
+
if (options.json !== void 0 && headers["content-type"] === void 0) {
|
|
649
|
+
headers["content-type"] = "application/json";
|
|
650
|
+
}
|
|
651
|
+
return headers;
|
|
652
|
+
}
|
|
653
|
+
async #attempt(url, method, headers, body, timeoutMs, signal, responseType, allowStatus) {
|
|
654
|
+
const controller = new AbortController();
|
|
655
|
+
const timer = setTimeout(() => {
|
|
656
|
+
controller.abort(ATTEMPT_TIMEOUT);
|
|
657
|
+
}, timeoutMs);
|
|
658
|
+
timer.unref();
|
|
659
|
+
const onAbort = () => {
|
|
660
|
+
controller.abort(CANCEL);
|
|
661
|
+
};
|
|
662
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
663
|
+
try {
|
|
664
|
+
const init = {
|
|
665
|
+
method,
|
|
666
|
+
headers,
|
|
667
|
+
signal: controller.signal,
|
|
668
|
+
dispatcher: this.#getDispatcher(),
|
|
669
|
+
redirect: "follow"
|
|
670
|
+
};
|
|
671
|
+
if (body !== void 0) init.body = body;
|
|
672
|
+
const res = await this.#fetch(url, init);
|
|
673
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
674
|
+
const isError = res.status >= 400;
|
|
675
|
+
const allowed = isError && allowStatus.includes(res.status);
|
|
676
|
+
const text = isError || responseType === "json" || responseType === "text" ? new TextDecoder().decode(bytes) : "";
|
|
677
|
+
let data;
|
|
678
|
+
if (isError && !allowed || responseType === "none") {
|
|
679
|
+
data = void 0;
|
|
680
|
+
} else if (responseType === "bytes") {
|
|
681
|
+
data = bytes;
|
|
682
|
+
} else if (responseType === "text") {
|
|
683
|
+
data = text;
|
|
684
|
+
} else if (allowed) {
|
|
685
|
+
data = parseJsonOrUndefined(text);
|
|
686
|
+
} else {
|
|
687
|
+
data = this.#parseJson(text, res.status);
|
|
688
|
+
}
|
|
689
|
+
return { status: res.status, headers: res.headers, data, text };
|
|
690
|
+
} catch (err) {
|
|
691
|
+
const reason = controller.signal.reason;
|
|
692
|
+
if (controller.signal.aborted && (reason === CANCEL || reason === ATTEMPT_TIMEOUT)) {
|
|
693
|
+
throw new AbortedAttempt(reason);
|
|
694
|
+
}
|
|
695
|
+
throw err;
|
|
696
|
+
} finally {
|
|
697
|
+
clearTimeout(timer);
|
|
698
|
+
signal?.removeEventListener("abort", onAbort);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
#parseJson(text, status) {
|
|
702
|
+
if (text.trim() === "") return void 0;
|
|
703
|
+
try {
|
|
704
|
+
return JSON.parse(text);
|
|
705
|
+
} catch {
|
|
706
|
+
throw new chunk2PTQBDJ6_cjs.UnavailableError(`invalid JSON in response (HTTP ${status})`, {
|
|
707
|
+
retryable: false,
|
|
708
|
+
httpStatus: status
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
#classify(err, operation, timeoutMs, isTotal, totalTimeout) {
|
|
713
|
+
if (err instanceof chunk2PTQBDJ6_cjs.OidcError) return err;
|
|
714
|
+
if (err instanceof AbortedAttempt) {
|
|
715
|
+
if (err.kind === CANCEL) return new chunk2PTQBDJ6_cjs.CancelledError(`${operation}: cancelled`);
|
|
716
|
+
return isTotal ? new chunk2PTQBDJ6_cjs.TimeoutError(`${operation}: total timeout of ${totalTimeout} ms exceeded`) : new chunk2PTQBDJ6_cjs.TimeoutError(`${operation}: request timed out after ${timeoutMs} ms`);
|
|
717
|
+
}
|
|
718
|
+
const cause = chunk2PTQBDJ6_cjs.redactError(err, this.#knownSecrets());
|
|
719
|
+
const code = errorCode(err);
|
|
720
|
+
if (code === "UND_ERR_CONNECT_TIMEOUT") {
|
|
721
|
+
return new chunk2PTQBDJ6_cjs.TimeoutError(
|
|
722
|
+
`${operation}: connect timeout after ${this.#config.connectTimeoutMs} ms`,
|
|
723
|
+
{ cause }
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
if (code !== void 0 && TLS_CODE.test(code)) {
|
|
727
|
+
return new chunk2PTQBDJ6_cjs.UnavailableError(`${operation}: TLS error (${code})`, { cause, retryable: false });
|
|
728
|
+
}
|
|
729
|
+
return new chunk2PTQBDJ6_cjs.UnavailableError(
|
|
730
|
+
`${operation}: network error${code === void 0 ? "" : ` (${code})`}`,
|
|
731
|
+
{ cause }
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
#classifyResponse(perRequest, response) {
|
|
735
|
+
for (const classify of [perRequest, this.#options.classifyError]) {
|
|
736
|
+
if (classify === void 0) continue;
|
|
737
|
+
let mapped;
|
|
738
|
+
try {
|
|
739
|
+
mapped = classify(response);
|
|
740
|
+
} catch (err) {
|
|
741
|
+
mapped = err instanceof chunk2PTQBDJ6_cjs.OidcError ? err : void 0;
|
|
742
|
+
}
|
|
743
|
+
if (mapped instanceof chunk2PTQBDJ6_cjs.OidcError) return mapped;
|
|
744
|
+
}
|
|
745
|
+
return void 0;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Extracts the vendor error message from a response body (JSON `message`, `error`, … or plain
|
|
749
|
+
* text; HTML is ignored), collapses whitespace, trims, redacts secrets and truncates it to
|
|
750
|
+
* {@link MAX_VENDOR_TEXT} characters. Returns `undefined` when there is nothing useful.
|
|
751
|
+
*/
|
|
752
|
+
vendorText(text) {
|
|
753
|
+
const trimmed = text.trim();
|
|
754
|
+
if (trimmed === "") return void 0;
|
|
755
|
+
let extracted;
|
|
756
|
+
try {
|
|
757
|
+
extracted = extractMessage(JSON.parse(trimmed));
|
|
758
|
+
} catch {
|
|
759
|
+
extracted = /^\s*</.test(trimmed) ? void 0 : trimmed;
|
|
760
|
+
}
|
|
761
|
+
const collapsed = extracted?.replace(/\s+/g, " ").trim();
|
|
762
|
+
if (collapsed === void 0 || collapsed === "") return void 0;
|
|
763
|
+
const redacted = redactSecretsInText(this.redact(collapsed));
|
|
764
|
+
return redacted.length > MAX_VENDOR_TEXT ? redacted.slice(0, MAX_VENDOR_TEXT - 1).trimEnd() + "\u2026" : redacted;
|
|
765
|
+
}
|
|
766
|
+
#requestId(headers) {
|
|
767
|
+
for (const name of this.#requestIdHeaders) {
|
|
768
|
+
const v = headers.get(name);
|
|
769
|
+
if (v !== null && v !== "") return v;
|
|
770
|
+
}
|
|
771
|
+
return void 0;
|
|
772
|
+
}
|
|
773
|
+
/** Releases connections. Idempotent. */
|
|
774
|
+
async close() {
|
|
775
|
+
if (this.#closed) return;
|
|
776
|
+
this.#closed = true;
|
|
777
|
+
const dispatcher = this.#dispatcher;
|
|
778
|
+
this.#dispatcher = void 0;
|
|
779
|
+
if (dispatcher !== void 0 && this.#options.dispatcher === void 0) {
|
|
780
|
+
await dispatcher.close().catch(() => void 0);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
function parseJsonOrUndefined(text) {
|
|
785
|
+
if (text.trim() === "") return void 0;
|
|
786
|
+
try {
|
|
787
|
+
return JSON.parse(text);
|
|
788
|
+
} catch {
|
|
789
|
+
return void 0;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
function extractMessage(body) {
|
|
793
|
+
if (typeof body === "string") return body;
|
|
794
|
+
if (body === null || typeof body !== "object") return void 0;
|
|
795
|
+
if (Array.isArray(body)) return body.length > 0 ? extractMessage(body[0]) : void 0;
|
|
796
|
+
const obj = body;
|
|
797
|
+
for (const key of [
|
|
798
|
+
"message",
|
|
799
|
+
"error_description",
|
|
800
|
+
"error",
|
|
801
|
+
"errors",
|
|
802
|
+
"detail",
|
|
803
|
+
"msg",
|
|
804
|
+
"title",
|
|
805
|
+
"reason"
|
|
806
|
+
]) {
|
|
807
|
+
const found = extractMessage(obj[key]);
|
|
808
|
+
if (found !== void 0 && found !== "") return found;
|
|
809
|
+
}
|
|
810
|
+
return void 0;
|
|
811
|
+
}
|
|
812
|
+
var SECRET_ASSIGNMENT = /((?:password|passwd|secret|token|authorization|api[_-]?key|access[_-]?key|private[_-]?key|credential|session|signature)["']?\s*[:=]\s*["']?)([^"'\s,;&}]+)/gi;
|
|
813
|
+
var BEARER = /\b(bearer|basic)\s+[A-Za-z0-9._~+/=-]+/gi;
|
|
814
|
+
function redactSecretsInText(text) {
|
|
815
|
+
return text.replace(BEARER, "$1 [REDACTED]").replace(SECRET_ASSIGNMENT, "$1[REDACTED]");
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// src/config.ts
|
|
819
|
+
var INSPECT = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
820
|
+
var CATALOG_PORT = "8000";
|
|
821
|
+
var VENDOR_ENV = {
|
|
822
|
+
url: [],
|
|
823
|
+
token: []
|
|
824
|
+
};
|
|
825
|
+
var OidcConfig = class _OidcConfig {
|
|
826
|
+
/** Default endpoint. */
|
|
827
|
+
static DEFAULT_URL = `http://127.0.0.1:${/\d+/.exec(CATALOG_PORT)?.[0] ?? "8080"}`;
|
|
828
|
+
/** Prefix of every environment variable. */
|
|
829
|
+
static ENV_PREFIX = "GROW_OIDC_";
|
|
830
|
+
url;
|
|
831
|
+
connectTimeoutMs;
|
|
832
|
+
requestTimeoutMs;
|
|
833
|
+
totalTimeoutMs;
|
|
834
|
+
retry;
|
|
835
|
+
tls;
|
|
836
|
+
proxy;
|
|
837
|
+
headers;
|
|
838
|
+
userAgentSuffix;
|
|
839
|
+
hooks;
|
|
840
|
+
logger;
|
|
841
|
+
/** API token. */
|
|
842
|
+
token;
|
|
843
|
+
/** Applies defaults, validates (throws {@link ConfigError}) and freezes. */
|
|
844
|
+
constructor(options = {}) {
|
|
845
|
+
const common = resolveCommonConfig(options, _OidcConfig.DEFAULT_URL);
|
|
846
|
+
this.url = common.url;
|
|
847
|
+
this.connectTimeoutMs = common.connectTimeoutMs;
|
|
848
|
+
this.requestTimeoutMs = common.requestTimeoutMs;
|
|
849
|
+
this.totalTimeoutMs = common.totalTimeoutMs;
|
|
850
|
+
this.retry = common.retry;
|
|
851
|
+
this.tls = common.tls;
|
|
852
|
+
this.headers = common.headers;
|
|
853
|
+
if (common.proxy !== void 0) this.proxy = common.proxy;
|
|
854
|
+
if (common.userAgentSuffix !== void 0) this.userAgentSuffix = common.userAgentSuffix;
|
|
855
|
+
if (common.hooks !== void 0) this.hooks = common.hooks;
|
|
856
|
+
if (common.logger !== void 0) this.logger = common.logger;
|
|
857
|
+
const token = chunk2PTQBDJ6_cjs.Secret.from(options.token);
|
|
858
|
+
if (token !== void 0) this.token = token;
|
|
859
|
+
this.validate();
|
|
860
|
+
Object.freeze(this);
|
|
861
|
+
}
|
|
862
|
+
/** Returns `options` when it already is a config, otherwise builds one. */
|
|
863
|
+
static from(options = {}) {
|
|
864
|
+
if (options instanceof _OidcConfig) return options;
|
|
865
|
+
return new _OidcConfig(options);
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Builds a config from the environment. Precedence: explicit `overrides` >
|
|
869
|
+
* `GROW_OIDC_<NAME>` > vendor variables ({@link VENDOR_ENV}) > defaults.
|
|
870
|
+
*/
|
|
871
|
+
static fromEnv(overrides = {}, env = process.env) {
|
|
872
|
+
const reader = new chunk2PTQBDJ6_cjs.EnvReader(_OidcConfig.ENV_PREFIX, env);
|
|
873
|
+
const fromEnv = readCommonEnv(reader, VENDOR_ENV);
|
|
874
|
+
const token = reader.secret("TOKEN", VENDOR_ENV.token);
|
|
875
|
+
if (token !== void 0) fromEnv.token = token;
|
|
876
|
+
const merged = mergeOptions(fromEnv, overrides);
|
|
877
|
+
return new _OidcConfig(merged);
|
|
878
|
+
}
|
|
879
|
+
/** Throws {@link ConfigError} when a setting is invalid. Service rules go here. */
|
|
880
|
+
validate() {
|
|
881
|
+
validateCommonConfig(this);
|
|
882
|
+
if (this.token?.reveal().trim() === "")
|
|
883
|
+
throw new chunk2PTQBDJ6_cjs.ConfigError("invalid configuration: token must not be blank");
|
|
884
|
+
}
|
|
885
|
+
/** Credential values to redact from error messages and logs. */
|
|
886
|
+
knownSecrets() {
|
|
887
|
+
return secretValues(this.token);
|
|
888
|
+
}
|
|
889
|
+
/** Debug form with every credential redacted. */
|
|
890
|
+
toJSON() {
|
|
891
|
+
return { ...describeCommonConfig(this), token: this.token === void 0 ? null : chunk2PTQBDJ6_cjs.REDACTED };
|
|
892
|
+
}
|
|
893
|
+
toString() {
|
|
894
|
+
return `OidcConfig(${JSON.stringify(this.toJSON())})`;
|
|
895
|
+
}
|
|
896
|
+
[INSPECT]() {
|
|
897
|
+
return this.toString();
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
// src/client.ts
|
|
902
|
+
var DISCOVERY_PATH = ".well-known/openid-configuration";
|
|
903
|
+
function trimTrailingSlashes(value) {
|
|
904
|
+
let end = value.length;
|
|
905
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
|
|
906
|
+
return value.slice(0, end);
|
|
907
|
+
}
|
|
908
|
+
function relativeEndpoint(base, endpoint) {
|
|
909
|
+
const root = trimTrailingSlashes(base);
|
|
910
|
+
if (endpoint.startsWith(root + "/")) return endpoint.slice(root.length);
|
|
911
|
+
try {
|
|
912
|
+
const url = new URL(endpoint);
|
|
913
|
+
return url.pathname + url.search;
|
|
914
|
+
} catch {
|
|
915
|
+
return endpoint;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
var OidcClient = class _OidcClient {
|
|
919
|
+
/** The immutable configuration. */
|
|
920
|
+
config;
|
|
921
|
+
#transport;
|
|
922
|
+
#closed = false;
|
|
923
|
+
/** Accepts a {@link OidcConfig} or plain options. */
|
|
924
|
+
constructor(config = {}, internals = {}) {
|
|
925
|
+
const cfg = OidcConfig.from(config);
|
|
926
|
+
this.config = cfg;
|
|
927
|
+
this.#transport = new HttpTransport({
|
|
928
|
+
...internals,
|
|
929
|
+
config: cfg,
|
|
930
|
+
knownSecrets: () => cfg.knownSecrets()
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
/** Builds a client from `GROW_OIDC_*` (and vendor) environment variables. */
|
|
934
|
+
static fromEnv(overrides = {}) {
|
|
935
|
+
return new _OidcClient(OidcConfig.fromEnv(overrides));
|
|
936
|
+
}
|
|
937
|
+
/** The shared HTTP transport (for service modules). @internal */
|
|
938
|
+
get transport() {
|
|
939
|
+
return this.#transport;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Unauthenticated liveness: `GET <url>/.well-known/openid-configuration` (healthy when the
|
|
943
|
+
* discovery document answers 2xx). Never throws for an unhealthy or unreachable provider (only
|
|
944
|
+
* `CANCELLED` and `CONFIG`).
|
|
945
|
+
*/
|
|
946
|
+
health(options = {}) {
|
|
947
|
+
return probeHealth(async () => {
|
|
948
|
+
const doc = await this.#discovery("health", options);
|
|
949
|
+
const details = {};
|
|
950
|
+
if (typeof doc.issuer === "string") details.issuer = doc.issuer;
|
|
951
|
+
return healthStatus("ok", details);
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Authenticated round trip with the configured access token (`token`): `GET` the provider's
|
|
956
|
+
* `userinfo_endpoint` from discovery. Returns the latency in milliseconds; a rejected token
|
|
957
|
+
* raises `AuthenticationError`, a provider without userinfo `UnsupportedError`.
|
|
958
|
+
*/
|
|
959
|
+
async ping(options = {}) {
|
|
960
|
+
const start = performance.now();
|
|
961
|
+
const doc = await this.#discovery("ping", options);
|
|
962
|
+
if (typeof doc.userinfo_endpoint !== "string" || doc.userinfo_endpoint === "") {
|
|
963
|
+
throw new chunk2PTQBDJ6_cjs.UnsupportedError("ping: the provider has no userinfo endpoint");
|
|
964
|
+
}
|
|
965
|
+
const token = this.config.token;
|
|
966
|
+
await this.#transport.get(relativeEndpoint(this.config.url, doc.userinfo_endpoint), {
|
|
967
|
+
operation: "ping",
|
|
968
|
+
responseType: "none",
|
|
969
|
+
headers: token === void 0 ? {} : { authorization: `Bearer ${token.reveal()}` },
|
|
970
|
+
...options
|
|
971
|
+
});
|
|
972
|
+
return performance.now() - start;
|
|
973
|
+
}
|
|
974
|
+
/** OpenID Connect has no version endpoint: always `UnsupportedError` (`CANCELLED` once closed). */
|
|
975
|
+
serverVersion(_options = {}) {
|
|
976
|
+
return new Promise((_resolve, reject) => {
|
|
977
|
+
this.#transport.ensureOpen("serverVersion");
|
|
978
|
+
reject(new chunk2PTQBDJ6_cjs.UnsupportedError("serverVersion: OpenID Connect providers expose no version"));
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
async #discovery(operation, options) {
|
|
982
|
+
const res = await this.#transport.get(DISCOVERY_PATH, { operation, ...options });
|
|
983
|
+
const data = res.data;
|
|
984
|
+
return data !== null && typeof data === "object" && !Array.isArray(data) ? data : {};
|
|
985
|
+
}
|
|
986
|
+
/** Releases connections. Idempotent. */
|
|
987
|
+
async close() {
|
|
988
|
+
if (this.#closed) return;
|
|
989
|
+
this.#closed = true;
|
|
990
|
+
await this.#transport.close();
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
// src/oidc/express.ts
|
|
995
|
+
function deny(res, status, error) {
|
|
996
|
+
if (status === 401) res.setHeader("WWW-Authenticate", 'Bearer error="invalid_token"');
|
|
997
|
+
res.status(status).json({ error });
|
|
998
|
+
}
|
|
999
|
+
function expressAuth(verifier, options = {}) {
|
|
1000
|
+
return async (req, res, next) => {
|
|
1001
|
+
const token = chunk2PTQBDJ6_cjs.bearerToken(req);
|
|
1002
|
+
if (token === null) {
|
|
1003
|
+
if (options.optional === true) {
|
|
1004
|
+
next();
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
deny(res, 401, "unauthorized");
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
try {
|
|
1011
|
+
req.user = await verifier.verify(token);
|
|
1012
|
+
} catch (err) {
|
|
1013
|
+
if (err instanceof chunk2PTQBDJ6_cjs.UnavailableError) {
|
|
1014
|
+
deny(res, 503, "auth_unavailable");
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
if (err instanceof chunk2PTQBDJ6_cjs.OidcError) {
|
|
1018
|
+
deny(res, 401, "unauthorized");
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
next(err);
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
next();
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function requireRoles(...roles) {
|
|
1028
|
+
return (req, res, next) => {
|
|
1029
|
+
const user = req.user;
|
|
1030
|
+
if (user === void 0) deny(res, 401, "unauthorized");
|
|
1031
|
+
else if (!chunk2PTQBDJ6_cjs.hasAnyRole(user.roles, roles)) deny(res, 403, "forbidden");
|
|
1032
|
+
else next();
|
|
1033
|
+
return Promise.resolve();
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
var ROLES_KEY = "grow:oidc:roles";
|
|
1037
|
+
var PUBLIC_KEY = "grow:oidc:public";
|
|
1038
|
+
var reflect = Reflect;
|
|
1039
|
+
var store = /* @__PURE__ */ new WeakMap();
|
|
1040
|
+
function setMeta(target, key, value) {
|
|
1041
|
+
let entry = store.get(target);
|
|
1042
|
+
if (entry === void 0) {
|
|
1043
|
+
entry = /* @__PURE__ */ new Map();
|
|
1044
|
+
store.set(target, entry);
|
|
1045
|
+
}
|
|
1046
|
+
entry.set(key, value);
|
|
1047
|
+
reflect.defineMetadata?.(key, value, target);
|
|
1048
|
+
}
|
|
1049
|
+
function getMeta(target, key) {
|
|
1050
|
+
if (target === null || typeof target !== "object" && typeof target !== "function")
|
|
1051
|
+
return void 0;
|
|
1052
|
+
const local = store.get(target)?.get(key);
|
|
1053
|
+
return local !== void 0 ? local : reflect.getMetadata?.(key, target);
|
|
1054
|
+
}
|
|
1055
|
+
function metaDecorator(key, value) {
|
|
1056
|
+
return (target, _key, descriptor) => {
|
|
1057
|
+
const holder = descriptor?.value ?? target;
|
|
1058
|
+
setMeta(holder, key, value);
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
function Roles(...roles) {
|
|
1062
|
+
return metaDecorator(ROLES_KEY, roles);
|
|
1063
|
+
}
|
|
1064
|
+
function Public() {
|
|
1065
|
+
return metaDecorator(PUBLIC_KEY, true);
|
|
1066
|
+
}
|
|
1067
|
+
var nestExceptions;
|
|
1068
|
+
function loadNestExceptions() {
|
|
1069
|
+
if (nestExceptions !== void 0) return nestExceptions;
|
|
1070
|
+
try {
|
|
1071
|
+
const appRequire = module$1.createRequire(path.join(process.cwd(), "package.json"));
|
|
1072
|
+
const common = appRequire("@nestjs/common");
|
|
1073
|
+
nestExceptions = {
|
|
1074
|
+
unauthorized: common.UnauthorizedException,
|
|
1075
|
+
forbidden: common.ForbiddenException,
|
|
1076
|
+
unavailable: common.ServiceUnavailableException
|
|
1077
|
+
};
|
|
1078
|
+
} catch {
|
|
1079
|
+
nestExceptions = {};
|
|
1080
|
+
}
|
|
1081
|
+
return nestExceptions;
|
|
1082
|
+
}
|
|
1083
|
+
function resetNestExceptionsForTests(value) {
|
|
1084
|
+
nestExceptions = value;
|
|
1085
|
+
}
|
|
1086
|
+
var HttpStatusError = class extends Error {
|
|
1087
|
+
statusCode;
|
|
1088
|
+
constructor(statusCode, message) {
|
|
1089
|
+
super(message);
|
|
1090
|
+
this.name = "HttpStatusError";
|
|
1091
|
+
this.statusCode = statusCode;
|
|
1092
|
+
}
|
|
1093
|
+
/** Nest `HttpException`-compatible accessor. */
|
|
1094
|
+
getStatus() {
|
|
1095
|
+
return this.statusCode;
|
|
1096
|
+
}
|
|
1097
|
+
};
|
|
1098
|
+
function httpError(status) {
|
|
1099
|
+
const ex = loadNestExceptions();
|
|
1100
|
+
const ctor = status === 401 ? ex.unauthorized : status === 403 ? ex.forbidden : ex.unavailable;
|
|
1101
|
+
const message = status === 401 ? "Unauthorized" : status === 403 ? "Forbidden" : "Service Unavailable";
|
|
1102
|
+
return ctor !== void 0 ? new ctor(message) : new HttpStatusError(status, message);
|
|
1103
|
+
}
|
|
1104
|
+
function isPublic(ctx) {
|
|
1105
|
+
return getMeta(ctx.getHandler(), PUBLIC_KEY) === true || getMeta(ctx.getClass(), PUBLIC_KEY) === true;
|
|
1106
|
+
}
|
|
1107
|
+
var NestAuthGuard = class {
|
|
1108
|
+
#verifier;
|
|
1109
|
+
#optional;
|
|
1110
|
+
constructor(verifier, options = {}) {
|
|
1111
|
+
this.#verifier = verifier;
|
|
1112
|
+
this.#optional = options.optional === true;
|
|
1113
|
+
}
|
|
1114
|
+
/** Nest `CanActivate`. */
|
|
1115
|
+
async canActivate(ctx) {
|
|
1116
|
+
const req = ctx.switchToHttp().getRequest();
|
|
1117
|
+
const token = chunk2PTQBDJ6_cjs.bearerToken(req);
|
|
1118
|
+
if (token === null) {
|
|
1119
|
+
if (this.#optional || isPublic(ctx)) return true;
|
|
1120
|
+
throw httpError(401);
|
|
1121
|
+
}
|
|
1122
|
+
try {
|
|
1123
|
+
req.user = await this.#verifier.verify(token);
|
|
1124
|
+
return true;
|
|
1125
|
+
} catch (err) {
|
|
1126
|
+
if (isPublic(ctx)) return true;
|
|
1127
|
+
if (err instanceof chunk2PTQBDJ6_cjs.UnavailableError) throw httpError(503);
|
|
1128
|
+
if (err instanceof chunk2PTQBDJ6_cjs.OidcError) throw httpError(401);
|
|
1129
|
+
throw err;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
var RolesGuard = class {
|
|
1134
|
+
#roles;
|
|
1135
|
+
constructor(roles) {
|
|
1136
|
+
this.#roles = roles;
|
|
1137
|
+
}
|
|
1138
|
+
/** Nest `CanActivate`. */
|
|
1139
|
+
canActivate(ctx) {
|
|
1140
|
+
const required = this.#roles ?? getMeta(ctx.getHandler(), ROLES_KEY) ?? getMeta(ctx.getClass(), ROLES_KEY);
|
|
1141
|
+
const user = ctx.switchToHttp().getRequest().user;
|
|
1142
|
+
if (user === void 0) {
|
|
1143
|
+
if (required === void 0 || isPublic(ctx)) return true;
|
|
1144
|
+
throw httpError(401);
|
|
1145
|
+
}
|
|
1146
|
+
if (required === void 0 || chunk2PTQBDJ6_cjs.hasAnyRole(user.roles, required)) return true;
|
|
1147
|
+
throw httpError(403);
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
Object.defineProperty(exports, "AuthenticationError", {
|
|
1152
|
+
enumerable: true,
|
|
1153
|
+
get: function () { return chunk2PTQBDJ6_cjs.AuthenticationError; }
|
|
1154
|
+
});
|
|
1155
|
+
Object.defineProperty(exports, "CancelledError", {
|
|
1156
|
+
enumerable: true,
|
|
1157
|
+
get: function () { return chunk2PTQBDJ6_cjs.CancelledError; }
|
|
1158
|
+
});
|
|
1159
|
+
Object.defineProperty(exports, "ConfigError", {
|
|
1160
|
+
enumerable: true,
|
|
1161
|
+
get: function () { return chunk2PTQBDJ6_cjs.ConfigError; }
|
|
1162
|
+
});
|
|
1163
|
+
Object.defineProperty(exports, "ConflictError", {
|
|
1164
|
+
enumerable: true,
|
|
1165
|
+
get: function () { return chunk2PTQBDJ6_cjs.ConflictError; }
|
|
1166
|
+
});
|
|
1167
|
+
Object.defineProperty(exports, "DEFAULT_ALGORITHMS", {
|
|
1168
|
+
enumerable: true,
|
|
1169
|
+
get: function () { return chunk2PTQBDJ6_cjs.DEFAULT_ALGORITHMS; }
|
|
1170
|
+
});
|
|
1171
|
+
Object.defineProperty(exports, "DEFAULT_CLOCK_SKEW_MS", {
|
|
1172
|
+
enumerable: true,
|
|
1173
|
+
get: function () { return chunk2PTQBDJ6_cjs.DEFAULT_CLOCK_SKEW_MS; }
|
|
1174
|
+
});
|
|
1175
|
+
Object.defineProperty(exports, "DEFAULT_HTTP_TIMEOUT_MS", {
|
|
1176
|
+
enumerable: true,
|
|
1177
|
+
get: function () { return chunk2PTQBDJ6_cjs.DEFAULT_HTTP_TIMEOUT_MS; }
|
|
1178
|
+
});
|
|
1179
|
+
Object.defineProperty(exports, "DEFAULT_JWKS_CACHE_TTL_MS", {
|
|
1180
|
+
enumerable: true,
|
|
1181
|
+
get: function () { return chunk2PTQBDJ6_cjs.DEFAULT_JWKS_CACHE_TTL_MS; }
|
|
1182
|
+
});
|
|
1183
|
+
Object.defineProperty(exports, "DEFAULT_JWKS_REFRESH_COOLDOWN_MS", {
|
|
1184
|
+
enumerable: true,
|
|
1185
|
+
get: function () { return chunk2PTQBDJ6_cjs.DEFAULT_JWKS_REFRESH_COOLDOWN_MS; }
|
|
1186
|
+
});
|
|
1187
|
+
Object.defineProperty(exports, "EnvReader", {
|
|
1188
|
+
enumerable: true,
|
|
1189
|
+
get: function () { return chunk2PTQBDJ6_cjs.EnvReader; }
|
|
1190
|
+
});
|
|
1191
|
+
Object.defineProperty(exports, "ErrorCode", {
|
|
1192
|
+
enumerable: true,
|
|
1193
|
+
get: function () { return chunk2PTQBDJ6_cjs.ErrorCode; }
|
|
1194
|
+
});
|
|
1195
|
+
Object.defineProperty(exports, "MIN_SECRET_LENGTH", {
|
|
1196
|
+
enumerable: true,
|
|
1197
|
+
get: function () { return chunk2PTQBDJ6_cjs.MIN_SECRET_LENGTH; }
|
|
1198
|
+
});
|
|
1199
|
+
Object.defineProperty(exports, "NotFoundError", {
|
|
1200
|
+
enumerable: true,
|
|
1201
|
+
get: function () { return chunk2PTQBDJ6_cjs.NotFoundError; }
|
|
1202
|
+
});
|
|
1203
|
+
Object.defineProperty(exports, "OidcError", {
|
|
1204
|
+
enumerable: true,
|
|
1205
|
+
get: function () { return chunk2PTQBDJ6_cjs.OidcError; }
|
|
1206
|
+
});
|
|
1207
|
+
Object.defineProperty(exports, "PermissionDeniedError", {
|
|
1208
|
+
enumerable: true,
|
|
1209
|
+
get: function () { return chunk2PTQBDJ6_cjs.PermissionDeniedError; }
|
|
1210
|
+
});
|
|
1211
|
+
Object.defineProperty(exports, "REDACTED", {
|
|
1212
|
+
enumerable: true,
|
|
1213
|
+
get: function () { return chunk2PTQBDJ6_cjs.REDACTED; }
|
|
1214
|
+
});
|
|
1215
|
+
Object.defineProperty(exports, "RateLimitError", {
|
|
1216
|
+
enumerable: true,
|
|
1217
|
+
get: function () { return chunk2PTQBDJ6_cjs.RateLimitError; }
|
|
1218
|
+
});
|
|
1219
|
+
Object.defineProperty(exports, "SENSITIVE_FIELD_PARTS", {
|
|
1220
|
+
enumerable: true,
|
|
1221
|
+
get: function () { return chunk2PTQBDJ6_cjs.SENSITIVE_FIELD_PARTS; }
|
|
1222
|
+
});
|
|
1223
|
+
Object.defineProperty(exports, "Secret", {
|
|
1224
|
+
enumerable: true,
|
|
1225
|
+
get: function () { return chunk2PTQBDJ6_cjs.Secret; }
|
|
1226
|
+
});
|
|
1227
|
+
Object.defineProperty(exports, "TimeoutError", {
|
|
1228
|
+
enumerable: true,
|
|
1229
|
+
get: function () { return chunk2PTQBDJ6_cjs.TimeoutError; }
|
|
1230
|
+
});
|
|
1231
|
+
Object.defineProperty(exports, "UnavailableError", {
|
|
1232
|
+
enumerable: true,
|
|
1233
|
+
get: function () { return chunk2PTQBDJ6_cjs.UnavailableError; }
|
|
1234
|
+
});
|
|
1235
|
+
Object.defineProperty(exports, "UnsupportedError", {
|
|
1236
|
+
enumerable: true,
|
|
1237
|
+
get: function () { return chunk2PTQBDJ6_cjs.UnsupportedError; }
|
|
1238
|
+
});
|
|
1239
|
+
Object.defineProperty(exports, "ValidationError", {
|
|
1240
|
+
enumerable: true,
|
|
1241
|
+
get: function () { return chunk2PTQBDJ6_cjs.ValidationError; }
|
|
1242
|
+
});
|
|
1243
|
+
Object.defineProperty(exports, "Verifier", {
|
|
1244
|
+
enumerable: true,
|
|
1245
|
+
get: function () { return chunk2PTQBDJ6_cjs.Verifier; }
|
|
1246
|
+
});
|
|
1247
|
+
Object.defineProperty(exports, "bearerToken", {
|
|
1248
|
+
enumerable: true,
|
|
1249
|
+
get: function () { return chunk2PTQBDJ6_cjs.bearerToken; }
|
|
1250
|
+
});
|
|
1251
|
+
Object.defineProperty(exports, "claimAt", {
|
|
1252
|
+
enumerable: true,
|
|
1253
|
+
get: function () { return chunk2PTQBDJ6_cjs.claimAt; }
|
|
1254
|
+
});
|
|
1255
|
+
Object.defineProperty(exports, "codeForStatus", {
|
|
1256
|
+
enumerable: true,
|
|
1257
|
+
get: function () { return chunk2PTQBDJ6_cjs.codeForStatus; }
|
|
1258
|
+
});
|
|
1259
|
+
Object.defineProperty(exports, "errorForCode", {
|
|
1260
|
+
enumerable: true,
|
|
1261
|
+
get: function () { return chunk2PTQBDJ6_cjs.errorForCode; }
|
|
1262
|
+
});
|
|
1263
|
+
Object.defineProperty(exports, "errorForStatus", {
|
|
1264
|
+
enumerable: true,
|
|
1265
|
+
get: function () { return chunk2PTQBDJ6_cjs.errorForStatus; }
|
|
1266
|
+
});
|
|
1267
|
+
Object.defineProperty(exports, "extractRoles", {
|
|
1268
|
+
enumerable: true,
|
|
1269
|
+
get: function () { return chunk2PTQBDJ6_cjs.extractRoles; }
|
|
1270
|
+
});
|
|
1271
|
+
Object.defineProperty(exports, "hasAnyRole", {
|
|
1272
|
+
enumerable: true,
|
|
1273
|
+
get: function () { return chunk2PTQBDJ6_cjs.hasAnyRole; }
|
|
1274
|
+
});
|
|
1275
|
+
Object.defineProperty(exports, "isOidcError", {
|
|
1276
|
+
enumerable: true,
|
|
1277
|
+
get: function () { return chunk2PTQBDJ6_cjs.isOidcError; }
|
|
1278
|
+
});
|
|
1279
|
+
Object.defineProperty(exports, "isSensitiveField", {
|
|
1280
|
+
enumerable: true,
|
|
1281
|
+
get: function () { return chunk2PTQBDJ6_cjs.isSensitiveField; }
|
|
1282
|
+
});
|
|
1283
|
+
Object.defineProperty(exports, "isSensitiveHeader", {
|
|
1284
|
+
enumerable: true,
|
|
1285
|
+
get: function () { return chunk2PTQBDJ6_cjs.isSensitiveHeader; }
|
|
1286
|
+
});
|
|
1287
|
+
Object.defineProperty(exports, "parseBool", {
|
|
1288
|
+
enumerable: true,
|
|
1289
|
+
get: function () { return chunk2PTQBDJ6_cjs.parseBool; }
|
|
1290
|
+
});
|
|
1291
|
+
Object.defineProperty(exports, "parseDuration", {
|
|
1292
|
+
enumerable: true,
|
|
1293
|
+
get: function () { return chunk2PTQBDJ6_cjs.parseDuration; }
|
|
1294
|
+
});
|
|
1295
|
+
Object.defineProperty(exports, "parseInteger", {
|
|
1296
|
+
enumerable: true,
|
|
1297
|
+
get: function () { return chunk2PTQBDJ6_cjs.parseInteger; }
|
|
1298
|
+
});
|
|
1299
|
+
Object.defineProperty(exports, "pollUntil", {
|
|
1300
|
+
enumerable: true,
|
|
1301
|
+
get: function () { return chunk2PTQBDJ6_cjs.pollUntil; }
|
|
1302
|
+
});
|
|
1303
|
+
Object.defineProperty(exports, "reasonForCode", {
|
|
1304
|
+
enumerable: true,
|
|
1305
|
+
get: function () { return chunk2PTQBDJ6_cjs.reasonForCode; }
|
|
1306
|
+
});
|
|
1307
|
+
Object.defineProperty(exports, "redactError", {
|
|
1308
|
+
enumerable: true,
|
|
1309
|
+
get: function () { return chunk2PTQBDJ6_cjs.redactError; }
|
|
1310
|
+
});
|
|
1311
|
+
Object.defineProperty(exports, "redactFields", {
|
|
1312
|
+
enumerable: true,
|
|
1313
|
+
get: function () { return chunk2PTQBDJ6_cjs.redactFields; }
|
|
1314
|
+
});
|
|
1315
|
+
Object.defineProperty(exports, "redactHeaders", {
|
|
1316
|
+
enumerable: true,
|
|
1317
|
+
get: function () { return chunk2PTQBDJ6_cjs.redactHeaders; }
|
|
1318
|
+
});
|
|
1319
|
+
Object.defineProperty(exports, "redactText", {
|
|
1320
|
+
enumerable: true,
|
|
1321
|
+
get: function () { return chunk2PTQBDJ6_cjs.redactText; }
|
|
1322
|
+
});
|
|
1323
|
+
Object.defineProperty(exports, "redactUrl", {
|
|
1324
|
+
enumerable: true,
|
|
1325
|
+
get: function () { return chunk2PTQBDJ6_cjs.redactUrl; }
|
|
1326
|
+
});
|
|
1327
|
+
Object.defineProperty(exports, "sleep", {
|
|
1328
|
+
enumerable: true,
|
|
1329
|
+
get: function () { return chunk2PTQBDJ6_cjs.sleep; }
|
|
1330
|
+
});
|
|
1331
|
+
Object.defineProperty(exports, "throwIfAborted", {
|
|
1332
|
+
enumerable: true,
|
|
1333
|
+
get: function () { return chunk2PTQBDJ6_cjs.throwIfAborted; }
|
|
1334
|
+
});
|
|
1335
|
+
exports.DEFAULT_REQUEST_ID_HEADERS = DEFAULT_REQUEST_ID_HEADERS;
|
|
1336
|
+
exports.DEFAULT_TIMEOUTS = DEFAULT_TIMEOUTS;
|
|
1337
|
+
exports.DISCOVERY_PATH = DISCOVERY_PATH;
|
|
1338
|
+
exports.HttpStatusError = HttpStatusError;
|
|
1339
|
+
exports.HttpTransport = HttpTransport;
|
|
1340
|
+
exports.LANGUAGE = LANGUAGE;
|
|
1341
|
+
exports.MAX_VENDOR_TEXT = MAX_VENDOR_TEXT;
|
|
1342
|
+
exports.NestAuthGuard = NestAuthGuard;
|
|
1343
|
+
exports.OidcClient = OidcClient;
|
|
1344
|
+
exports.OidcConfig = OidcConfig;
|
|
1345
|
+
exports.PACKAGE_KEY = PACKAGE_KEY;
|
|
1346
|
+
exports.PUBLIC_KEY = PUBLIC_KEY;
|
|
1347
|
+
exports.Public = Public;
|
|
1348
|
+
exports.ROLES_KEY = ROLES_KEY;
|
|
1349
|
+
exports.RetryPolicy = RetryPolicy;
|
|
1350
|
+
exports.Roles = Roles;
|
|
1351
|
+
exports.RolesGuard = RolesGuard;
|
|
1352
|
+
exports.SDK_KIT_VERSION = SDK_KIT_VERSION;
|
|
1353
|
+
exports.SDK_VERSION = SDK_VERSION;
|
|
1354
|
+
exports.VENDOR_ENV = VENDOR_ENV;
|
|
1355
|
+
exports.createDispatcher = createDispatcher;
|
|
1356
|
+
exports.definedOnly = definedOnly;
|
|
1357
|
+
exports.describeCommonConfig = describeCommonConfig;
|
|
1358
|
+
exports.expressAuth = expressAuth;
|
|
1359
|
+
exports.healthStatus = healthStatus;
|
|
1360
|
+
exports.isHealthyWord = isHealthyWord;
|
|
1361
|
+
exports.isIdempotentMethod = isIdempotentMethod;
|
|
1362
|
+
exports.isRetryableStatus = isRetryableStatus;
|
|
1363
|
+
exports.mergeOptions = mergeOptions;
|
|
1364
|
+
exports.parseRetryAfter = parseRetryAfter;
|
|
1365
|
+
exports.probeHealth = probeHealth;
|
|
1366
|
+
exports.readCommonEnv = readCommonEnv;
|
|
1367
|
+
exports.redactSecretsInText = redactSecretsInText;
|
|
1368
|
+
exports.relativeEndpoint = relativeEndpoint;
|
|
1369
|
+
exports.requireRoles = requireRoles;
|
|
1370
|
+
exports.resetNestExceptionsForTests = resetNestExceptionsForTests;
|
|
1371
|
+
exports.resolveCommonConfig = resolveCommonConfig;
|
|
1372
|
+
exports.safeCall = safeCall;
|
|
1373
|
+
exports.safeLogger = safeLogger;
|
|
1374
|
+
exports.secretValues = secretValues;
|
|
1375
|
+
exports.silentLogger = silentLogger;
|
|
1376
|
+
exports.validateCommonConfig = validateCommonConfig;
|
|
1377
|
+
//# sourceMappingURL=index.cjs.map
|
|
1378
|
+
//# sourceMappingURL=index.cjs.map
|