@onkernel/sdk 0.149.0 → 0.151.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 +25 -0
- package/client.d.mts +29 -4
- package/client.d.mts.map +1 -1
- package/client.d.ts +29 -4
- package/client.d.ts.map +1 -1
- package/client.js +32 -3
- package/client.js.map +1 -1
- package/client.mjs +32 -3
- package/client.mjs.map +1 -1
- package/lib/credentials/client-auth.d.mts +88 -0
- package/lib/credentials/client-auth.d.mts.map +1 -0
- package/lib/credentials/client-auth.d.ts +88 -0
- package/lib/credentials/client-auth.d.ts.map +1 -0
- package/lib/credentials/client-auth.js +166 -0
- package/lib/credentials/client-auth.js.map +1 -0
- package/lib/credentials/client-auth.mjs +162 -0
- package/lib/credentials/client-auth.mjs.map +1 -0
- package/lib/credentials/credential-chain.d.mts +20 -0
- package/lib/credentials/credential-chain.d.mts.map +1 -0
- package/lib/credentials/credential-chain.d.ts +20 -0
- package/lib/credentials/credential-chain.d.ts.map +1 -0
- package/lib/credentials/credential-chain.js +81 -0
- package/lib/credentials/credential-chain.js.map +1 -0
- package/lib/credentials/credential-chain.mjs +77 -0
- package/lib/credentials/credential-chain.mjs.map +1 -0
- package/lib/credentials/identity-token.d.mts +59 -0
- package/lib/credentials/identity-token.d.mts.map +1 -0
- package/lib/credentials/identity-token.d.ts +59 -0
- package/lib/credentials/identity-token.d.ts.map +1 -0
- package/lib/credentials/identity-token.js +243 -0
- package/lib/credentials/identity-token.js.map +1 -0
- package/lib/credentials/identity-token.mjs +202 -0
- package/lib/credentials/identity-token.mjs.map +1 -0
- package/lib/credentials/oidc-federation.d.mts +65 -0
- package/lib/credentials/oidc-federation.d.mts.map +1 -0
- package/lib/credentials/oidc-federation.d.ts +65 -0
- package/lib/credentials/oidc-federation.d.ts.map +1 -0
- package/lib/credentials/oidc-federation.js +200 -0
- package/lib/credentials/oidc-federation.js.map +1 -0
- package/lib/credentials/oidc-federation.mjs +196 -0
- package/lib/credentials/oidc-federation.mjs.map +1 -0
- package/lib/credentials/token-cache.d.mts +64 -0
- package/lib/credentials/token-cache.d.mts.map +1 -0
- package/lib/credentials/token-cache.d.ts +64 -0
- package/lib/credentials/token-cache.d.ts.map +1 -0
- package/lib/credentials/token-cache.js +147 -0
- package/lib/credentials/token-cache.js.map +1 -0
- package/lib/credentials/token-cache.mjs +143 -0
- package/lib/credentials/token-cache.mjs.map +1 -0
- package/lib/credentials/types.d.mts +126 -0
- package/lib/credentials/types.d.mts.map +1 -0
- package/lib/credentials/types.d.ts +126 -0
- package/lib/credentials/types.d.ts.map +1 -0
- package/lib/credentials/types.js +182 -0
- package/lib/credentials/types.js.map +1 -0
- package/lib/credentials/types.mjs +169 -0
- package/lib/credentials/types.mjs.map +1 -0
- package/lib/credentials.d.mts +6 -0
- package/lib/credentials.d.mts.map +1 -0
- package/lib/credentials.d.ts +6 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +19 -0
- package/lib/credentials.js.map +1 -0
- package/lib/credentials.mjs +6 -0
- package/lib/credentials.mjs.map +1 -0
- package/package.json +9 -1
- package/resources/api-keys.d.mts +192 -16
- package/resources/api-keys.d.mts.map +1 -1
- package/resources/api-keys.d.ts +192 -16
- package/resources/api-keys.d.ts.map +1 -1
- package/resources/api-keys.js +19 -7
- package/resources/api-keys.js.map +1 -1
- package/resources/api-keys.mjs +19 -7
- package/resources/api-keys.mjs.map +1 -1
- package/resources/auth/auth.d.mts +2 -2
- package/resources/auth/auth.d.mts.map +1 -1
- package/resources/auth/auth.d.ts +2 -2
- package/resources/auth/auth.d.ts.map +1 -1
- package/resources/auth/auth.js.map +1 -1
- package/resources/auth/auth.mjs.map +1 -1
- package/resources/auth/connections.d.mts +16 -2
- package/resources/auth/connections.d.mts.map +1 -1
- package/resources/auth/connections.d.ts +16 -2
- package/resources/auth/connections.d.ts.map +1 -1
- package/resources/auth/context.d.mts +69 -3
- package/resources/auth/context.d.mts.map +1 -1
- package/resources/auth/context.d.ts +69 -3
- package/resources/auth/context.d.ts.map +1 -1
- package/resources/auth/index.d.mts +1 -1
- package/resources/auth/index.d.mts.map +1 -1
- package/resources/auth/index.d.ts +1 -1
- package/resources/auth/index.d.ts.map +1 -1
- package/resources/auth/index.js.map +1 -1
- package/resources/auth/index.mjs.map +1 -1
- package/resources/browser-pools.d.mts +41 -6
- package/resources/browser-pools.d.mts.map +1 -1
- package/resources/browser-pools.d.ts +41 -6
- package/resources/browser-pools.d.ts.map +1 -1
- package/resources/browsers/browsers.d.mts +105 -45
- package/resources/browsers/browsers.d.mts.map +1 -1
- package/resources/browsers/browsers.d.ts +105 -45
- package/resources/browsers/browsers.d.ts.map +1 -1
- package/resources/browsers/browsers.js.map +1 -1
- package/resources/browsers/browsers.mjs.map +1 -1
- package/resources/browsers/index.d.mts +1 -1
- package/resources/browsers/index.d.mts.map +1 -1
- package/resources/browsers/index.d.ts +1 -1
- package/resources/browsers/index.d.ts.map +1 -1
- package/resources/browsers/index.js.map +1 -1
- package/resources/browsers/index.mjs.map +1 -1
- package/resources/browsers/telemetry.d.mts +4 -4
- package/resources/browsers/telemetry.d.mts.map +1 -1
- package/resources/browsers/telemetry.d.ts +4 -4
- package/resources/browsers/telemetry.d.ts.map +1 -1
- package/resources/index.d.mts +6 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +9 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -1
- package/resources/invocations.d.mts +13 -1
- package/resources/invocations.d.mts.map +1 -1
- package/resources/invocations.d.ts +13 -1
- package/resources/invocations.d.ts.map +1 -1
- package/resources/service-accounts.d.mts +73 -0
- package/resources/service-accounts.d.mts.map +1 -0
- package/resources/service-accounts.d.ts +73 -0
- package/resources/service-accounts.d.ts.map +1 -0
- package/resources/service-accounts.js +50 -0
- package/resources/service-accounts.js.map +1 -0
- package/resources/service-accounts.mjs +46 -0
- package/resources/service-accounts.mjs.map +1 -0
- package/resources/vaults/items.d.mts +68 -2
- package/resources/vaults/items.d.mts.map +1 -1
- package/resources/vaults/items.d.ts +68 -2
- package/resources/vaults/items.d.ts.map +1 -1
- package/resources/workload-identity-authentication-events.d.mts +36 -0
- package/resources/workload-identity-authentication-events.d.mts.map +1 -0
- package/resources/workload-identity-authentication-events.d.ts +36 -0
- package/resources/workload-identity-authentication-events.d.ts.map +1 -0
- package/resources/workload-identity-authentication-events.js +16 -0
- package/resources/workload-identity-authentication-events.js.map +1 -0
- package/resources/workload-identity-authentication-events.mjs +12 -0
- package/resources/workload-identity-authentication-events.mjs.map +1 -0
- package/resources/workload-identity-federation-rules.d.mts +194 -0
- package/resources/workload-identity-federation-rules.d.mts.map +1 -0
- package/resources/workload-identity-federation-rules.d.ts +194 -0
- package/resources/workload-identity-federation-rules.d.ts.map +1 -0
- package/resources/workload-identity-federation-rules.js +47 -0
- package/resources/workload-identity-federation-rules.js.map +1 -0
- package/resources/workload-identity-federation-rules.mjs +43 -0
- package/resources/workload-identity-federation-rules.mjs.map +1 -0
- package/resources/workload-identity-issuers.d.mts +169 -0
- package/resources/workload-identity-issuers.d.mts.map +1 -0
- package/resources/workload-identity-issuers.d.ts +169 -0
- package/resources/workload-identity-issuers.d.ts.map +1 -0
- package/resources/workload-identity-issuers.js +54 -0
- package/resources/workload-identity-issuers.js.map +1 -0
- package/resources/workload-identity-issuers.mjs +50 -0
- package/resources/workload-identity-issuers.mjs.map +1 -0
- package/src/client.ts +134 -1
- package/src/lib/credentials/client-auth.ts +194 -0
- package/src/lib/credentials/credential-chain.ts +95 -0
- package/src/lib/credentials/identity-token.ts +284 -0
- package/src/lib/credentials/oidc-federation.ts +304 -0
- package/src/lib/credentials/token-cache.ts +172 -0
- package/src/lib/credentials/types.ts +267 -0
- package/src/lib/credentials.ts +30 -0
- package/src/resources/api-keys.ts +217 -15
- package/src/resources/auth/auth.ts +6 -2
- package/src/resources/auth/connections.ts +17 -2
- package/src/resources/auth/context.ts +81 -3
- package/src/resources/auth/index.ts +1 -1
- package/src/resources/browser-pools.ts +46 -6
- package/src/resources/browsers/browsers.ts +115 -44
- package/src/resources/browsers/index.ts +1 -0
- package/src/resources/browsers/telemetry.ts +4 -3
- package/src/resources/index.ts +42 -0
- package/src/resources/invocations.ts +15 -1
- package/src/resources/service-accounts.ts +128 -0
- package/src/resources/vaults/items.ts +80 -2
- package/src/resources/workload-identity-authentication-events.ts +72 -0
- package/src/resources/workload-identity-federation-rules.ts +314 -0
- package/src/resources/workload-identity-issuers.ts +273 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkloadIdentityError = exports.DEFAULT_CREDENTIALS_TIMEOUT_IN_MS = exports.MAX_TOKEN_RESPONSE_BYTES = exports.MAX_ASSERTION_BYTES = exports.ADVISORY_REFRESH_BACKOFF_IN_SECONDS = exports.MANDATORY_REFRESH_LIFETIME_FRACTION = exports.MANDATORY_REFRESH_THRESHOLD_IN_SECONDS = exports.ADVISORY_REFRESH_LIFETIME_FRACTION = exports.ADVISORY_REFRESH_THRESHOLD_IN_SECONDS = exports.DEFAULT_AUTH_BASE_URL = exports.DEFAULT_API_BASE_URL = exports.TOKEN_ENDPOINT = exports.GRANT_TYPE_JWT_BEARER = void 0;
|
|
4
|
+
exports.nowAsSeconds = nowAsSeconds;
|
|
5
|
+
exports.requireSecureTokenEndpoint = requireSecureTokenEndpoint;
|
|
6
|
+
exports.resolveAuthBaseURL = resolveAuthBaseURL;
|
|
7
|
+
exports.resolveResource = resolveResource;
|
|
8
|
+
exports.redactSensitive = redactSensitive;
|
|
9
|
+
exports.describeFailure = describeFailure;
|
|
10
|
+
exports.scrubSecrets = scrubSecrets;
|
|
11
|
+
exports.readLimitedText = readLimitedText;
|
|
12
|
+
exports.withTimeout = withTimeout;
|
|
13
|
+
const error_1 = require("../../core/error.js");
|
|
14
|
+
const env_1 = require("../../internal/utils/env.js");
|
|
15
|
+
exports.GRANT_TYPE_JWT_BEARER = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
|
|
16
|
+
exports.TOKEN_ENDPOINT = '/token';
|
|
17
|
+
exports.DEFAULT_API_BASE_URL = 'https://api.onkernel.com';
|
|
18
|
+
exports.DEFAULT_AUTH_BASE_URL = 'https://auth.onkernel.com';
|
|
19
|
+
exports.ADVISORY_REFRESH_THRESHOLD_IN_SECONDS = 120;
|
|
20
|
+
exports.ADVISORY_REFRESH_LIFETIME_FRACTION = 0.4;
|
|
21
|
+
exports.MANDATORY_REFRESH_THRESHOLD_IN_SECONDS = 30;
|
|
22
|
+
exports.MANDATORY_REFRESH_LIFETIME_FRACTION = 0.1;
|
|
23
|
+
exports.ADVISORY_REFRESH_BACKOFF_IN_SECONDS = 5;
|
|
24
|
+
exports.MAX_ASSERTION_BYTES = 16 * 1024;
|
|
25
|
+
exports.MAX_TOKEN_RESPONSE_BYTES = 1 << 20;
|
|
26
|
+
exports.DEFAULT_CREDENTIALS_TIMEOUT_IN_MS = 30000;
|
|
27
|
+
function nowAsSeconds() {
|
|
28
|
+
return Date.now() / 1000;
|
|
29
|
+
}
|
|
30
|
+
class WorkloadIdentityError extends error_1.KernelError {
|
|
31
|
+
constructor(message, { statusCode = null, errorCode = null, errorDescription = null, requestId = null, body = null, cause, } = {}) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = 'WorkloadIdentityError';
|
|
34
|
+
this.statusCode = statusCode;
|
|
35
|
+
this.errorCode = errorCode;
|
|
36
|
+
this.errorDescription = errorDescription;
|
|
37
|
+
this.requestId = requestId;
|
|
38
|
+
this.body = body;
|
|
39
|
+
// in some environments the 'cause' property is already declared
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
if (cause !== undefined)
|
|
42
|
+
this.cause = cause;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.WorkloadIdentityError = WorkloadIdentityError;
|
|
46
|
+
/**
|
|
47
|
+
* Rejects token endpoints that would send an identity token over cleartext
|
|
48
|
+
* HTTP. Loopback hosts are allowed for local development.
|
|
49
|
+
*/
|
|
50
|
+
function requireSecureTokenEndpoint(baseURL) {
|
|
51
|
+
let url;
|
|
52
|
+
try {
|
|
53
|
+
url = new URL(baseURL);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new WorkloadIdentityError(`Invalid auth base URL "${baseURL}"`);
|
|
57
|
+
}
|
|
58
|
+
if (url.protocol === 'https:')
|
|
59
|
+
return;
|
|
60
|
+
// URL.hostname keeps the brackets around an IPv6 address.
|
|
61
|
+
const host = url.hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
62
|
+
if (url.protocol === 'http:' && (host === 'localhost' || host === '127.0.0.1' || host === '::1')) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw new WorkloadIdentityError(`Refusing to send an identity token to non-https auth base URL "${baseURL}"`);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The host that exchanges identity tokens: the explicit value, else
|
|
69
|
+
* `KERNEL_AUTH_BASE_URL`, else production when the API base URL is the
|
|
70
|
+
* production default. A custom API base URL never falls back to production.
|
|
71
|
+
*/
|
|
72
|
+
function resolveAuthBaseURL(explicit, apiBaseURL) {
|
|
73
|
+
const configured = explicit || (0, env_1.readEnv)('KERNEL_AUTH_BASE_URL');
|
|
74
|
+
if (configured)
|
|
75
|
+
return configured.replace(/\/+$/, '');
|
|
76
|
+
const api = resolveAPIBaseURL(apiBaseURL);
|
|
77
|
+
if (api.replace(/\/+$/, '') === exports.DEFAULT_API_BASE_URL)
|
|
78
|
+
return exports.DEFAULT_AUTH_BASE_URL;
|
|
79
|
+
throw new WorkloadIdentityError(`Cannot determine the auth base URL for the custom API base URL "${api}". Set the KERNEL_AUTH_BASE_URL environment variable or the authBaseURL option.`);
|
|
80
|
+
}
|
|
81
|
+
/** The `resource` an access token is requested for: the origin of the API base URL. */
|
|
82
|
+
function resolveResource(explicit, apiBaseURL) {
|
|
83
|
+
if (explicit)
|
|
84
|
+
return explicit;
|
|
85
|
+
const api = resolveAPIBaseURL(apiBaseURL);
|
|
86
|
+
try {
|
|
87
|
+
return new URL(api).origin;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
throw new WorkloadIdentityError(`Invalid API base URL "${api}"`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function resolveAPIBaseURL(apiBaseURL) {
|
|
94
|
+
return apiBaseURL || (0, env_1.readEnv)('KERNEL_BASE_URL') || exports.DEFAULT_API_BASE_URL;
|
|
95
|
+
}
|
|
96
|
+
// RFC 6749 section 5.2 error fields. A token endpoint may echo anything else
|
|
97
|
+
// it was sent, including the assertion, so every other field is dropped.
|
|
98
|
+
const SAFE_ERROR_KEYS = new Set(['error', 'error_description', 'error_uri']);
|
|
99
|
+
/**
|
|
100
|
+
* Reduces a token endpoint error body to what is safe to put in an error:
|
|
101
|
+
* the RFC 6749 error fields that are strings. Anything that is not a JSON
|
|
102
|
+
* object, such as a proxy's error page, is discarded. Pass every credential
|
|
103
|
+
* that was sent as `secrets`, so a server that echoes one back does not
|
|
104
|
+
* leak it.
|
|
105
|
+
*/
|
|
106
|
+
function redactSensitive(body, secrets = []) {
|
|
107
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body))
|
|
108
|
+
return null;
|
|
109
|
+
const out = {};
|
|
110
|
+
for (const [key, value] of Object.entries(body)) {
|
|
111
|
+
if (SAFE_ERROR_KEYS.has(key) && typeof value === 'string')
|
|
112
|
+
out[key] = scrubSecrets(value, secrets);
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Describes an error thrown while a credential was in flight, with its
|
|
118
|
+
* causes and without the credential. Use the result in place of attaching
|
|
119
|
+
* the error as a `cause`, which loggers print in full.
|
|
120
|
+
*/
|
|
121
|
+
function describeFailure(err, secrets) {
|
|
122
|
+
const parts = [];
|
|
123
|
+
for (let current = err; current != null && parts.length < 3; current = current.cause) {
|
|
124
|
+
parts.push(String(current));
|
|
125
|
+
}
|
|
126
|
+
return scrubSecrets(parts.join(': '), secrets);
|
|
127
|
+
}
|
|
128
|
+
/** Replaces every occurrence of each secret, plain or URL-encoded, in text that came from outside the SDK. */
|
|
129
|
+
function scrubSecrets(text, secrets) {
|
|
130
|
+
for (const secret of secrets) {
|
|
131
|
+
if (!secret)
|
|
132
|
+
continue;
|
|
133
|
+
for (const form of new Set([secret, encodeURIComponent(secret)])) {
|
|
134
|
+
text = text.split(form).join('[redacted]');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return text;
|
|
138
|
+
}
|
|
139
|
+
/** Reads at most `maxBytes` of a response body as UTF-8 text. */
|
|
140
|
+
async function readLimitedText(response, maxBytes = exports.MAX_TOKEN_RESPONSE_BYTES) {
|
|
141
|
+
if (!response.body)
|
|
142
|
+
return '';
|
|
143
|
+
const reader = response.body.getReader();
|
|
144
|
+
const chunks = [];
|
|
145
|
+
let received = 0;
|
|
146
|
+
for (;;) {
|
|
147
|
+
const { done, value } = await reader.read();
|
|
148
|
+
if (done)
|
|
149
|
+
break;
|
|
150
|
+
if (received + value.length > maxBytes) {
|
|
151
|
+
chunks.push(value.subarray(0, maxBytes - received));
|
|
152
|
+
received = maxBytes;
|
|
153
|
+
await reader.cancel();
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
chunks.push(value);
|
|
157
|
+
received += value.length;
|
|
158
|
+
}
|
|
159
|
+
const merged = new Uint8Array(received);
|
|
160
|
+
let offset = 0;
|
|
161
|
+
for (const chunk of chunks) {
|
|
162
|
+
merged.set(chunk, offset);
|
|
163
|
+
offset += chunk.length;
|
|
164
|
+
}
|
|
165
|
+
return new TextDecoder('utf-8').decode(merged);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Runs `fn` with an abort signal that fires after `timeoutMs`. The timer
|
|
169
|
+
* covers everything `fn` awaits, so it bounds reading the body as well as
|
|
170
|
+
* waiting for the headers.
|
|
171
|
+
*/
|
|
172
|
+
async function withTimeout(timeoutMs, fn) {
|
|
173
|
+
const controller = new AbortController();
|
|
174
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
175
|
+
try {
|
|
176
|
+
return await fn(controller.signal);
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/credentials/types.ts"],"names":[],"mappings":";;;AA6EA,oCAEC;AAgDD,gEAgBC;AAOD,gDAQC;AAGD,0CAQC;AAiBD,0CAOC;AAOD,0CAUC;AAGD,oCAQC;AAGD,0CA2BC;AAOD,kCAQC;AA1QD,+CAA+C;AAE/C,qDAAmD;AA4DtC,QAAA,qBAAqB,GAAG,6CAA6C,CAAC;AACtE,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,oBAAoB,GAAG,0BAA0B,CAAC;AAClD,QAAA,qBAAqB,GAAG,2BAA2B,CAAC;AAEpD,QAAA,qCAAqC,GAAG,GAAG,CAAC;AAC5C,QAAA,kCAAkC,GAAG,GAAG,CAAC;AACzC,QAAA,sCAAsC,GAAG,EAAE,CAAC;AAC5C,QAAA,mCAAmC,GAAG,GAAG,CAAC;AAC1C,QAAA,mCAAmC,GAAG,CAAC,CAAC;AAExC,QAAA,mBAAmB,GAAG,EAAE,GAAG,IAAI,CAAC;AAChC,QAAA,wBAAwB,GAAG,CAAC,IAAI,EAAE,CAAC;AACnC,QAAA,iCAAiC,GAAG,KAAM,CAAC;AAExD,SAAgB,YAAY;IAC1B,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,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AAI,SAAiB,EAAE,EAAuC;IAC7F,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { KernelError } from "../../core/error.mjs";
|
|
2
|
+
import { readEnv } from "../../internal/utils/env.mjs";
|
|
3
|
+
export const GRANT_TYPE_JWT_BEARER = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
|
|
4
|
+
export const TOKEN_ENDPOINT = '/token';
|
|
5
|
+
export const DEFAULT_API_BASE_URL = 'https://api.onkernel.com';
|
|
6
|
+
export const DEFAULT_AUTH_BASE_URL = 'https://auth.onkernel.com';
|
|
7
|
+
export const ADVISORY_REFRESH_THRESHOLD_IN_SECONDS = 120;
|
|
8
|
+
export const ADVISORY_REFRESH_LIFETIME_FRACTION = 0.4;
|
|
9
|
+
export const MANDATORY_REFRESH_THRESHOLD_IN_SECONDS = 30;
|
|
10
|
+
export const MANDATORY_REFRESH_LIFETIME_FRACTION = 0.1;
|
|
11
|
+
export const ADVISORY_REFRESH_BACKOFF_IN_SECONDS = 5;
|
|
12
|
+
export const MAX_ASSERTION_BYTES = 16 * 1024;
|
|
13
|
+
export const MAX_TOKEN_RESPONSE_BYTES = 1 << 20;
|
|
14
|
+
export const DEFAULT_CREDENTIALS_TIMEOUT_IN_MS = 30000;
|
|
15
|
+
export function nowAsSeconds() {
|
|
16
|
+
return Date.now() / 1000;
|
|
17
|
+
}
|
|
18
|
+
export class WorkloadIdentityError extends KernelError {
|
|
19
|
+
constructor(message, { statusCode = null, errorCode = null, errorDescription = null, requestId = null, body = null, cause, } = {}) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'WorkloadIdentityError';
|
|
22
|
+
this.statusCode = statusCode;
|
|
23
|
+
this.errorCode = errorCode;
|
|
24
|
+
this.errorDescription = errorDescription;
|
|
25
|
+
this.requestId = requestId;
|
|
26
|
+
this.body = body;
|
|
27
|
+
// in some environments the 'cause' property is already declared
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
if (cause !== undefined)
|
|
30
|
+
this.cause = cause;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rejects token endpoints that would send an identity token over cleartext
|
|
35
|
+
* HTTP. Loopback hosts are allowed for local development.
|
|
36
|
+
*/
|
|
37
|
+
export function requireSecureTokenEndpoint(baseURL) {
|
|
38
|
+
let url;
|
|
39
|
+
try {
|
|
40
|
+
url = new URL(baseURL);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new WorkloadIdentityError(`Invalid auth base URL "${baseURL}"`);
|
|
44
|
+
}
|
|
45
|
+
if (url.protocol === 'https:')
|
|
46
|
+
return;
|
|
47
|
+
// URL.hostname keeps the brackets around an IPv6 address.
|
|
48
|
+
const host = url.hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
49
|
+
if (url.protocol === 'http:' && (host === 'localhost' || host === '127.0.0.1' || host === '::1')) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
throw new WorkloadIdentityError(`Refusing to send an identity token to non-https auth base URL "${baseURL}"`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The host that exchanges identity tokens: the explicit value, else
|
|
56
|
+
* `KERNEL_AUTH_BASE_URL`, else production when the API base URL is the
|
|
57
|
+
* production default. A custom API base URL never falls back to production.
|
|
58
|
+
*/
|
|
59
|
+
export function resolveAuthBaseURL(explicit, apiBaseURL) {
|
|
60
|
+
const configured = explicit || readEnv('KERNEL_AUTH_BASE_URL');
|
|
61
|
+
if (configured)
|
|
62
|
+
return configured.replace(/\/+$/, '');
|
|
63
|
+
const api = resolveAPIBaseURL(apiBaseURL);
|
|
64
|
+
if (api.replace(/\/+$/, '') === DEFAULT_API_BASE_URL)
|
|
65
|
+
return DEFAULT_AUTH_BASE_URL;
|
|
66
|
+
throw new WorkloadIdentityError(`Cannot determine the auth base URL for the custom API base URL "${api}". Set the KERNEL_AUTH_BASE_URL environment variable or the authBaseURL option.`);
|
|
67
|
+
}
|
|
68
|
+
/** The `resource` an access token is requested for: the origin of the API base URL. */
|
|
69
|
+
export function resolveResource(explicit, apiBaseURL) {
|
|
70
|
+
if (explicit)
|
|
71
|
+
return explicit;
|
|
72
|
+
const api = resolveAPIBaseURL(apiBaseURL);
|
|
73
|
+
try {
|
|
74
|
+
return new URL(api).origin;
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new WorkloadIdentityError(`Invalid API base URL "${api}"`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function resolveAPIBaseURL(apiBaseURL) {
|
|
81
|
+
return apiBaseURL || readEnv('KERNEL_BASE_URL') || DEFAULT_API_BASE_URL;
|
|
82
|
+
}
|
|
83
|
+
// RFC 6749 section 5.2 error fields. A token endpoint may echo anything else
|
|
84
|
+
// it was sent, including the assertion, so every other field is dropped.
|
|
85
|
+
const SAFE_ERROR_KEYS = new Set(['error', 'error_description', 'error_uri']);
|
|
86
|
+
/**
|
|
87
|
+
* Reduces a token endpoint error body to what is safe to put in an error:
|
|
88
|
+
* the RFC 6749 error fields that are strings. Anything that is not a JSON
|
|
89
|
+
* object, such as a proxy's error page, is discarded. Pass every credential
|
|
90
|
+
* that was sent as `secrets`, so a server that echoes one back does not
|
|
91
|
+
* leak it.
|
|
92
|
+
*/
|
|
93
|
+
export function redactSensitive(body, secrets = []) {
|
|
94
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body))
|
|
95
|
+
return null;
|
|
96
|
+
const out = {};
|
|
97
|
+
for (const [key, value] of Object.entries(body)) {
|
|
98
|
+
if (SAFE_ERROR_KEYS.has(key) && typeof value === 'string')
|
|
99
|
+
out[key] = scrubSecrets(value, secrets);
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Describes an error thrown while a credential was in flight, with its
|
|
105
|
+
* causes and without the credential. Use the result in place of attaching
|
|
106
|
+
* the error as a `cause`, which loggers print in full.
|
|
107
|
+
*/
|
|
108
|
+
export function describeFailure(err, secrets) {
|
|
109
|
+
const parts = [];
|
|
110
|
+
for (let current = err; current != null && parts.length < 3; current = current.cause) {
|
|
111
|
+
parts.push(String(current));
|
|
112
|
+
}
|
|
113
|
+
return scrubSecrets(parts.join(': '), secrets);
|
|
114
|
+
}
|
|
115
|
+
/** Replaces every occurrence of each secret, plain or URL-encoded, in text that came from outside the SDK. */
|
|
116
|
+
export function scrubSecrets(text, secrets) {
|
|
117
|
+
for (const secret of secrets) {
|
|
118
|
+
if (!secret)
|
|
119
|
+
continue;
|
|
120
|
+
for (const form of new Set([secret, encodeURIComponent(secret)])) {
|
|
121
|
+
text = text.split(form).join('[redacted]');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return text;
|
|
125
|
+
}
|
|
126
|
+
/** Reads at most `maxBytes` of a response body as UTF-8 text. */
|
|
127
|
+
export async function readLimitedText(response, maxBytes = MAX_TOKEN_RESPONSE_BYTES) {
|
|
128
|
+
if (!response.body)
|
|
129
|
+
return '';
|
|
130
|
+
const reader = response.body.getReader();
|
|
131
|
+
const chunks = [];
|
|
132
|
+
let received = 0;
|
|
133
|
+
for (;;) {
|
|
134
|
+
const { done, value } = await reader.read();
|
|
135
|
+
if (done)
|
|
136
|
+
break;
|
|
137
|
+
if (received + value.length > maxBytes) {
|
|
138
|
+
chunks.push(value.subarray(0, maxBytes - received));
|
|
139
|
+
received = maxBytes;
|
|
140
|
+
await reader.cancel();
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
chunks.push(value);
|
|
144
|
+
received += value.length;
|
|
145
|
+
}
|
|
146
|
+
const merged = new Uint8Array(received);
|
|
147
|
+
let offset = 0;
|
|
148
|
+
for (const chunk of chunks) {
|
|
149
|
+
merged.set(chunk, offset);
|
|
150
|
+
offset += chunk.length;
|
|
151
|
+
}
|
|
152
|
+
return new TextDecoder('utf-8').decode(merged);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Runs `fn` with an abort signal that fires after `timeoutMs`. The timer
|
|
156
|
+
* covers everything `fn` awaits, so it bounds reading the body as well as
|
|
157
|
+
* waiting for the headers.
|
|
158
|
+
*/
|
|
159
|
+
export async function withTimeout(timeoutMs, fn) {
|
|
160
|
+
const controller = new AbortController();
|
|
161
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
162
|
+
try {
|
|
163
|
+
return await fn(controller.signal);
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
clearTimeout(timer);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/lib/credentials/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAE/C,OAAO,EAAE,OAAO,EAAE,qCAAiC;AA4DnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,6CAA6C,CAAC;AACnF,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAC/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEjE,MAAM,CAAC,MAAM,qCAAqC,GAAG,GAAG,CAAC;AACzD,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAC;AACtD,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,mCAAmC,GAA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AAC;IACxC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAI,SAAiB,EAAE,EAAuC;IAC7F,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { type AccessToken, type AccessTokenProvider, type AccessTokenProviderOptions, type CredentialsClientContext, type FederationAccessToken, type FederationPrincipal, type FederationTokenDetails, type IdentityTokenProvider, type IdentityTokenRequest, WorkloadIdentityError, } from "./credentials/types.mjs";
|
|
2
|
+
export { TokenCache } from "./credentials/token-cache.mjs";
|
|
3
|
+
export { type FederationAssertionExchangeParams, type FederationExchangeResult, type OIDCFederationConfig, exchangeFederationAssertion, oidcFederationProvider, } from "./credentials/oidc-federation.mjs";
|
|
4
|
+
export { type AWSSTSIdentityTokenOptions, type IdentityTokenSourceOptions, identityTokenFromAWSSTS, identityTokenFromFile, identityTokenFromGCPMetadata, identityTokenFromGitHubActions, identityTokenFromValue, } from "./credentials/identity-token.mjs";
|
|
5
|
+
export { type IdentityTokenSource, federationCredentialsFromEnv } from "./credentials/credential-chain.mjs";
|
|
6
|
+
//# sourceMappingURL=credentials.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.mts","sourceRoot":"","sources":["../src/lib/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,qBAAqB,GACtB,gCAA4B;AAC7B,OAAO,EAAE,UAAU,EAAE,sCAAkC;AACvD,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,2BAA2B,EAC3B,sBAAsB,GACvB,0CAAsC;AACvC,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,uBAAuB,EACvB,qBAAqB,EACrB,4BAA4B,EAC5B,8BAA8B,EAC9B,sBAAsB,GACvB,yCAAqC;AACtC,OAAO,EAAE,KAAK,mBAAmB,EAAE,4BAA4B,EAAE,2CAAuC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { type AccessToken, type AccessTokenProvider, type AccessTokenProviderOptions, type CredentialsClientContext, type FederationAccessToken, type FederationPrincipal, type FederationTokenDetails, type IdentityTokenProvider, type IdentityTokenRequest, WorkloadIdentityError, } from "./credentials/types.js";
|
|
2
|
+
export { TokenCache } from "./credentials/token-cache.js";
|
|
3
|
+
export { type FederationAssertionExchangeParams, type FederationExchangeResult, type OIDCFederationConfig, exchangeFederationAssertion, oidcFederationProvider, } from "./credentials/oidc-federation.js";
|
|
4
|
+
export { type AWSSTSIdentityTokenOptions, type IdentityTokenSourceOptions, identityTokenFromAWSSTS, identityTokenFromFile, identityTokenFromGCPMetadata, identityTokenFromGitHubActions, identityTokenFromValue, } from "./credentials/identity-token.js";
|
|
5
|
+
export { type IdentityTokenSource, federationCredentialsFromEnv } from "./credentials/credential-chain.js";
|
|
6
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/lib/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,qBAAqB,GACtB,+BAA4B;AAC7B,OAAO,EAAE,UAAU,EAAE,qCAAkC;AACvD,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,2BAA2B,EAC3B,sBAAsB,GACvB,yCAAsC;AACvC,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,uBAAuB,EACvB,qBAAqB,EACrB,4BAA4B,EAC5B,8BAA8B,EAC9B,sBAAsB,GACvB,wCAAqC;AACtC,OAAO,EAAE,KAAK,mBAAmB,EAAE,4BAA4B,EAAE,0CAAuC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.federationCredentialsFromEnv = exports.identityTokenFromValue = exports.identityTokenFromGitHubActions = exports.identityTokenFromGCPMetadata = exports.identityTokenFromFile = exports.identityTokenFromAWSSTS = exports.oidcFederationProvider = exports.exchangeFederationAssertion = exports.TokenCache = exports.WorkloadIdentityError = void 0;
|
|
4
|
+
var types_1 = require("./credentials/types.js");
|
|
5
|
+
Object.defineProperty(exports, "WorkloadIdentityError", { enumerable: true, get: function () { return types_1.WorkloadIdentityError; } });
|
|
6
|
+
var token_cache_1 = require("./credentials/token-cache.js");
|
|
7
|
+
Object.defineProperty(exports, "TokenCache", { enumerable: true, get: function () { return token_cache_1.TokenCache; } });
|
|
8
|
+
var oidc_federation_1 = require("./credentials/oidc-federation.js");
|
|
9
|
+
Object.defineProperty(exports, "exchangeFederationAssertion", { enumerable: true, get: function () { return oidc_federation_1.exchangeFederationAssertion; } });
|
|
10
|
+
Object.defineProperty(exports, "oidcFederationProvider", { enumerable: true, get: function () { return oidc_federation_1.oidcFederationProvider; } });
|
|
11
|
+
var identity_token_1 = require("./credentials/identity-token.js");
|
|
12
|
+
Object.defineProperty(exports, "identityTokenFromAWSSTS", { enumerable: true, get: function () { return identity_token_1.identityTokenFromAWSSTS; } });
|
|
13
|
+
Object.defineProperty(exports, "identityTokenFromFile", { enumerable: true, get: function () { return identity_token_1.identityTokenFromFile; } });
|
|
14
|
+
Object.defineProperty(exports, "identityTokenFromGCPMetadata", { enumerable: true, get: function () { return identity_token_1.identityTokenFromGCPMetadata; } });
|
|
15
|
+
Object.defineProperty(exports, "identityTokenFromGitHubActions", { enumerable: true, get: function () { return identity_token_1.identityTokenFromGitHubActions; } });
|
|
16
|
+
Object.defineProperty(exports, "identityTokenFromValue", { enumerable: true, get: function () { return identity_token_1.identityTokenFromValue; } });
|
|
17
|
+
var credential_chain_1 = require("./credentials/credential-chain.js");
|
|
18
|
+
Object.defineProperty(exports, "federationCredentialsFromEnv", { enumerable: true, get: function () { return credential_chain_1.federationCredentialsFromEnv; } });
|
|
19
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/lib/credentials.ts"],"names":[],"mappings":";;;AAAA,gDAW6B;AAD3B,8GAAA,qBAAqB,OAAA;AAEvB,4DAAuD;AAA9C,yGAAA,UAAU,OAAA;AACnB,oEAMuC;AAFrC,8HAAA,2BAA2B,OAAA;AAC3B,yHAAA,sBAAsB,OAAA;AAExB,kEAQsC;AALpC,yHAAA,uBAAuB,OAAA;AACvB,uHAAA,qBAAqB,OAAA;AACrB,8HAAA,4BAA4B,OAAA;AAC5B,gIAAA,8BAA8B,OAAA;AAC9B,wHAAA,sBAAsB,OAAA;AAExB,sEAAwG;AAArE,gIAAA,4BAA4B,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { WorkloadIdentityError, } from "./credentials/types.mjs";
|
|
2
|
+
export { TokenCache } from "./credentials/token-cache.mjs";
|
|
3
|
+
export { exchangeFederationAssertion, oidcFederationProvider, } from "./credentials/oidc-federation.mjs";
|
|
4
|
+
export { identityTokenFromAWSSTS, identityTokenFromFile, identityTokenFromGCPMetadata, identityTokenFromGitHubActions, identityTokenFromValue, } from "./credentials/identity-token.mjs";
|
|
5
|
+
export { federationCredentialsFromEnv } from "./credentials/credential-chain.mjs";
|
|
6
|
+
//# sourceMappingURL=credentials.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.mjs","sourceRoot":"","sources":["../src/lib/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,qBAAqB,GACtB,gCAA4B;AAC7B,OAAO,EAAE,UAAU,EAAE,sCAAkC;AACvD,OAAO,EAIL,2BAA2B,EAC3B,sBAAsB,GACvB,0CAAsC;AACvC,OAAO,EAGL,uBAAuB,EACvB,qBAAqB,EACrB,4BAA4B,EAC5B,8BAA8B,EAC9B,sBAAsB,GACvB,yCAAqC;AACtC,OAAO,EAA4B,4BAA4B,EAAE,2CAAuC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onkernel/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.151.0",
|
|
4
4
|
"description": "The official TypeScript library for the Kernel API",
|
|
5
5
|
"author": "Kernel <>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -25,6 +25,14 @@
|
|
|
25
25
|
"lint": "./scripts/lint",
|
|
26
26
|
"fix": "./scripts/format"
|
|
27
27
|
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@aws-sdk/client-sts": ">=3.935.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"@aws-sdk/client-sts": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
28
36
|
"overrides": {
|
|
29
37
|
"minimatch": "^9.0.5"
|
|
30
38
|
},
|