@oneidentity/safeguard 8.1.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -2
- package/dist/browser.js.map +1 -1
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +0 -1
- package/dist/events.d.cts.map +1 -1
- package/dist/events.d.ts +0 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.cjs +66 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +33 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ interface HttpResponse {
|
|
|
15
15
|
headers: Record<string, string>;
|
|
16
16
|
body: string;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Supported TLS protocol versions for {@link TlsOptions.minVersion} /
|
|
20
|
+
* {@link TlsOptions.maxVersion}. Matches Node's `tls` `SecureVersion` strings.
|
|
21
|
+
*/
|
|
22
|
+
type TlsVersion = 'TLSv1.3' | 'TLSv1.2' | 'TLSv1.1' | 'TLSv1';
|
|
18
23
|
interface TlsOptions {
|
|
19
24
|
/** Custom CA certificate (PEM). */
|
|
20
25
|
ca?: string | Buffer;
|
|
@@ -22,10 +27,31 @@ interface TlsOptions {
|
|
|
22
27
|
cert?: string | Buffer;
|
|
23
28
|
/** Client private key (PEM) for mTLS. */
|
|
24
29
|
key?: string | Buffer;
|
|
25
|
-
/**
|
|
30
|
+
/** Client certificate in PFX/PKCS12 format for mTLS (alternative to cert+key). */
|
|
31
|
+
pfx?: string | Buffer;
|
|
32
|
+
/** Passphrase for encrypted private key or PFX. */
|
|
26
33
|
passphrase?: string;
|
|
27
34
|
/** Whether to verify server certificate. Default: true. */
|
|
28
35
|
rejectUnauthorized?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Minimum TLS version to negotiate (opt-in). Default: unset — Node negotiates
|
|
38
|
+
* from its default floor (TLS 1.2). Pin to `'TLSv1.3'` to require TLS 1.3,
|
|
39
|
+
* e.g. for certificate auth against a Safeguard Cert SNI hostname on SPP 9.0.
|
|
40
|
+
*/
|
|
41
|
+
minVersion?: TlsVersion;
|
|
42
|
+
/**
|
|
43
|
+
* Maximum TLS version to negotiate (opt-in). Default: unset — Node negotiates
|
|
44
|
+
* up to its default ceiling (TLS 1.3).
|
|
45
|
+
*
|
|
46
|
+
* Special case: when a client certificate (`cert`/`key`/`pfx`) is present and
|
|
47
|
+
* **neither** `minVersion` nor `maxVersion` is set, the connection is capped
|
|
48
|
+
* at `'TLSv1.2'`. Node cannot present a client certificate via TLS 1.3
|
|
49
|
+
* post-handshake authentication, so capping at TLS 1.2 lets the certificate be
|
|
50
|
+
* requested in-handshake and keeps certificate/A2A auth working by default on
|
|
51
|
+
* SPP 9.0's Standard binding. Setting either bound explicitly disables this
|
|
52
|
+
* auto-cap.
|
|
53
|
+
*/
|
|
54
|
+
maxVersion?: TlsVersion;
|
|
29
55
|
}
|
|
30
56
|
/**
|
|
31
57
|
* Abstract HTTP client interface.
|
|
@@ -673,6 +699,11 @@ declare class A2AClient {
|
|
|
673
699
|
retrieveApiKeySecret(apiKey: string): Promise<SecretValue>;
|
|
674
700
|
/**
|
|
675
701
|
* Get the list of retrievable accounts available to this certificate.
|
|
702
|
+
*
|
|
703
|
+
* Retrievable accounts live under the Core service and are authorized by the
|
|
704
|
+
* client certificate alone (no per-account API key). Enumerate every A2A
|
|
705
|
+
* registration bound to the certificate, then collect each registration's
|
|
706
|
+
* retrievable accounts.
|
|
676
707
|
*/
|
|
677
708
|
getRetrievableAccounts(): Promise<RetrievableAccount[]>;
|
|
678
709
|
/**
|
|
@@ -697,5 +728,5 @@ declare class A2AClient {
|
|
|
697
728
|
brokerAccessRequest(apiKey: string, request: BrokeredAccessRequest): Promise<BrokeredAccessResponse>;
|
|
698
729
|
}
|
|
699
730
|
//#endregion
|
|
700
|
-
export { A2AClient, type A2AClientOptions, AnonymousAuth, ApiError, type ApiErrorBody, type Auth, AuthenticationError, AuthorizationError, type BrokeredAccessRequest, BrokeredAccessRequestType, type BrokeredAccessResponse, BrowserHttpClient, BrowserSessionStorage, CertificateAuth, type CertificateAuthOptions, ConfigurationError, DeviceCodeAuth, type DeviceCodeAuthOptions, type DeviceCodeInfo, type HttpClient, HttpMethod, type HttpRequestOptions, type HttpResponse, MemoryStorage, NodeHttpClient, NotFoundError, PasswordAuth, type PasswordAuthOptions, PkceAuth, type PkceAuthOptions, type PkceCallbackResult, PkceNonInteractiveAuth, type PkceNonInteractiveAuthOptions, type RequestOptions, type RetrievableAccount, SafeguardClient, type SafeguardClientOptions, SafeguardError, type SafeguardResponse, SecretValue, Service, SshKeyFormat, StorageKeys, type StorageProvider, type TlsOptions, TokenAuth, type TokenAuthOptions, type TokenSet, TransportError, base64UrlEncode, buildRequestUrl, buildServiceUrl, generateCodeChallenge, generateCodeVerifier, generateState, handlePkceCallback, validateHost };
|
|
731
|
+
export { A2AClient, type A2AClientOptions, AnonymousAuth, ApiError, type ApiErrorBody, type Auth, AuthenticationError, AuthorizationError, type BrokeredAccessRequest, BrokeredAccessRequestType, type BrokeredAccessResponse, BrowserHttpClient, BrowserSessionStorage, CertificateAuth, type CertificateAuthOptions, ConfigurationError, DeviceCodeAuth, type DeviceCodeAuthOptions, type DeviceCodeInfo, type HttpClient, HttpMethod, type HttpRequestOptions, type HttpResponse, MemoryStorage, NodeHttpClient, NotFoundError, PasswordAuth, type PasswordAuthOptions, PkceAuth, type PkceAuthOptions, type PkceCallbackResult, PkceNonInteractiveAuth, type PkceNonInteractiveAuthOptions, type RequestOptions, type RetrievableAccount, SafeguardClient, type SafeguardClientOptions, SafeguardError, type SafeguardResponse, SecretValue, Service, SshKeyFormat, StorageKeys, type StorageProvider, type TlsOptions, type TlsVersion, TokenAuth, type TokenAuthOptions, type TokenSet, TransportError, base64UrlEncode, buildRequestUrl, buildServiceUrl, generateCodeChallenge, generateCodeVerifier, generateState, handlePkceCallback, validateHost };
|
|
701
732
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/http/types.ts","../src/storage/types.ts","../src/secret.ts","../src/auth/types.ts","../src/types.ts","../src/errors.ts","../src/utils.ts","../src/storage/memory.ts","../src/storage/session.ts","../src/http/node.ts","../src/http/browser.ts","../src/auth/password.ts","../src/auth/certificate.ts","../src/auth/pkce.ts","../src/auth/pkce-noninteractive.ts","../src/auth/device-code.ts","../src/auth/pkce-callback.ts","../src/auth/token.ts","../src/auth/anonymous.ts","../src/client.ts","../src/a2a/types.ts","../src/a2a/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/http/types.ts","../src/storage/types.ts","../src/secret.ts","../src/auth/types.ts","../src/types.ts","../src/errors.ts","../src/utils.ts","../src/storage/memory.ts","../src/storage/session.ts","../src/http/node.ts","../src/http/browser.ts","../src/auth/password.ts","../src/auth/certificate.ts","../src/auth/pkce.ts","../src/auth/pkce-noninteractive.ts","../src/auth/device-code.ts","../src/auth/pkce-callback.ts","../src/auth/token.ts","../src/auth/anonymous.ts","../src/client.ts","../src/a2a/types.ts","../src/a2a/index.ts"],"mappings":";;;;UAIiB;EACf;EACA;EACA,UAAU;EACV,gBAAgB;EAChB,SAAS;EACT;;UAGe;EACf;EACA,SAAS;EACT;;;;;;KAOU;UAEK;;EAEf,cAAc;;EAEd,gBAAgB;;EAEhB,eAAe;;EAEf,eAAe;;EAEf;;EAEA;;;;;;EAMA,aAAa;;;;;;;;;;;;;EAab,aAAa;;;;;;UAOE;EACf,QAAQ,SAAS,qBAAqB,QAAQ;EAC9C;;;;;;;UC9De;EACf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Ac,SAAS;;MAW/B;;MAKA,eAAe;;MAKf;;MAKA,QAAQ;;;;EAOZ,cAAc,YAAY;;;;;EASpB,iBAAiB,iBAAiB,QAAQ;;;;;;EAY1C,mBAAmB,gBAAgB,SAAS,eAAe,QAAQ;;;;;EAgBnE,qBAAqB,iBAAiB,QAAQ;;;;;;;;;EAa9C,0BAA0B,QAAQ;;;;;;EAwClC,YAAY,gBAAgB,mBAAmB;;;;;;;;EAyB/C,cACJ,gBACA,aACA,qBACA,SAAS,eACR;;;;;;EA+BG,oBACJ,gBACA,SAAS,wBACR,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -217,7 +217,7 @@ function base64UrlEncode(bytes) {
|
|
|
217
217
|
* Returns a 43-character base64url string (32 random bytes).
|
|
218
218
|
*/
|
|
219
219
|
function generateCodeVerifier() {
|
|
220
|
-
const bytes = new Uint8Array(32);
|
|
220
|
+
const bytes = /* @__PURE__ */ new Uint8Array(32);
|
|
221
221
|
crypto.getRandomValues(bytes);
|
|
222
222
|
return base64UrlEncode(bytes);
|
|
223
223
|
}
|
|
@@ -234,7 +234,7 @@ async function generateCodeChallenge(verifier) {
|
|
|
234
234
|
* Generates a random state parameter for OAuth flows.
|
|
235
235
|
*/
|
|
236
236
|
function generateState() {
|
|
237
|
-
const bytes = new Uint8Array(16);
|
|
237
|
+
const bytes = /* @__PURE__ */ new Uint8Array(16);
|
|
238
238
|
crypto.getRandomValues(bytes);
|
|
239
239
|
return base64UrlEncode(bytes);
|
|
240
240
|
}
|
|
@@ -307,19 +307,46 @@ const StorageKeys = {
|
|
|
307
307
|
//#endregion
|
|
308
308
|
//#region src/http/node.ts
|
|
309
309
|
/**
|
|
310
|
+
* Resolve the undici Agent `connect` (TLS) options from {@link TlsOptions}.
|
|
311
|
+
*
|
|
312
|
+
* Applies the opt-in `minVersion`/`maxVersion` pins. When a client certificate
|
|
313
|
+
* is present and the caller has pinned neither bound, the connection is capped
|
|
314
|
+
* at TLS 1.2: Node has no client-side TLS 1.3 post-handshake authentication
|
|
315
|
+
* (see https://github.com/nodejs/node/issues/46120), so on TLS 1.3 the client
|
|
316
|
+
* never presents its certificate and cert/A2A auth fails (error 60094) on the
|
|
317
|
+
* appliance's Standard binding. Capping at TLS 1.2 keeps the cert request
|
|
318
|
+
* in-handshake so it works by default. Setting either bound explicitly (for
|
|
319
|
+
* example `minVersion: 'TLSv1.3'` when targeting a Cert SNI hostname) disables
|
|
320
|
+
* the auto-cap. Password/token connections carry no certificate and keep
|
|
321
|
+
* negotiating up to TLS 1.3.
|
|
322
|
+
*/
|
|
323
|
+
function resolveTlsConnectOptions(tlsOptions) {
|
|
324
|
+
const connect = {
|
|
325
|
+
ca: tlsOptions?.ca,
|
|
326
|
+
cert: tlsOptions?.cert,
|
|
327
|
+
key: tlsOptions?.key,
|
|
328
|
+
pfx: tlsOptions?.pfx,
|
|
329
|
+
passphrase: tlsOptions?.passphrase,
|
|
330
|
+
rejectUnauthorized: tlsOptions?.rejectUnauthorized ?? true
|
|
331
|
+
};
|
|
332
|
+
const hasClientCert = Boolean(tlsOptions?.cert ?? tlsOptions?.key ?? tlsOptions?.pfx);
|
|
333
|
+
if (tlsOptions?.minVersion) connect.minVersion = tlsOptions.minVersion;
|
|
334
|
+
if (tlsOptions?.maxVersion) connect.maxVersion = tlsOptions.maxVersion;
|
|
335
|
+
else if (hasClientCert && !tlsOptions?.minVersion) connect.maxVersion = "TLSv1.2";
|
|
336
|
+
return connect;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
310
339
|
* Node.js HTTP client using undici for full TLS control.
|
|
311
340
|
* Creates a per-instance Agent — no global state mutation.
|
|
312
341
|
*/
|
|
313
342
|
var NodeHttpClient = class {
|
|
314
343
|
#agent;
|
|
315
344
|
constructor(tlsOptions) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
rejectUnauthorized: tlsOptions?.rejectUnauthorized ?? true
|
|
322
|
-
} });
|
|
345
|
+
const hasClientCert = Boolean(tlsOptions?.cert ?? tlsOptions?.key ?? tlsOptions?.pfx);
|
|
346
|
+
this.#agent = new Agent({
|
|
347
|
+
connect: resolveTlsConnectOptions(tlsOptions),
|
|
348
|
+
...hasClientCert ? { allowH2: false } : {}
|
|
349
|
+
});
|
|
323
350
|
}
|
|
324
351
|
async request(options) {
|
|
325
352
|
const { url, method, headers, body, signal, timeout } = options;
|
|
@@ -1255,7 +1282,8 @@ var A2AClient = class {
|
|
|
1255
1282
|
* @param apiKey - The API key for the retrievable account
|
|
1256
1283
|
*/
|
|
1257
1284
|
async retrievePassword(apiKey) {
|
|
1258
|
-
|
|
1285
|
+
const body = await this.#a2aRequest(apiKey, "GET", "Credentials", { type: "Password" });
|
|
1286
|
+
return new SecretValue(JSON.parse(body));
|
|
1259
1287
|
}
|
|
1260
1288
|
/**
|
|
1261
1289
|
* Retrieve an SSH private key credential via A2A.
|
|
@@ -1264,10 +1292,11 @@ var A2AClient = class {
|
|
|
1264
1292
|
*/
|
|
1265
1293
|
async retrievePrivateKey(apiKey, format) {
|
|
1266
1294
|
const keyType = format ?? "OpenSsh";
|
|
1267
|
-
|
|
1268
|
-
type: "
|
|
1295
|
+
const body = await this.#a2aRequest(apiKey, "GET", "Credentials", {
|
|
1296
|
+
type: "PrivateKey",
|
|
1269
1297
|
keyFormat: keyType
|
|
1270
|
-
})
|
|
1298
|
+
});
|
|
1299
|
+
return new SecretValue(JSON.parse(body));
|
|
1271
1300
|
}
|
|
1272
1301
|
/**
|
|
1273
1302
|
* Retrieve an API key secret credential via A2A.
|
|
@@ -1278,16 +1307,32 @@ var A2AClient = class {
|
|
|
1278
1307
|
}
|
|
1279
1308
|
/**
|
|
1280
1309
|
* Get the list of retrievable accounts available to this certificate.
|
|
1310
|
+
*
|
|
1311
|
+
* Retrievable accounts live under the Core service and are authorized by the
|
|
1312
|
+
* client certificate alone (no per-account API key). Enumerate every A2A
|
|
1313
|
+
* registration bound to the certificate, then collect each registration's
|
|
1314
|
+
* retrievable accounts.
|
|
1281
1315
|
*/
|
|
1282
1316
|
async getRetrievableAccounts() {
|
|
1283
1317
|
this.#ensureHttpClient();
|
|
1284
|
-
const
|
|
1285
|
-
url: `https://${this.#host}/service/
|
|
1318
|
+
const regResponse = await this.#httpClient.request({
|
|
1319
|
+
url: `https://${this.#host}/service/core/${this.#apiVersion}/A2ARegistrations`,
|
|
1286
1320
|
method: "GET",
|
|
1287
1321
|
headers: { Accept: "application/json" }
|
|
1288
1322
|
});
|
|
1289
|
-
if (
|
|
1290
|
-
|
|
1323
|
+
if (regResponse.status !== 200) throw ApiError.fromResponse(regResponse.status, regResponse.body);
|
|
1324
|
+
const registrations = JSON.parse(regResponse.body);
|
|
1325
|
+
const accounts = [];
|
|
1326
|
+
for (const reg of registrations) {
|
|
1327
|
+
const acctResponse = await this.#httpClient.request({
|
|
1328
|
+
url: `https://${this.#host}/service/core/${this.#apiVersion}/A2ARegistrations/${reg.Id}/RetrievableAccounts`,
|
|
1329
|
+
method: "GET",
|
|
1330
|
+
headers: { Accept: "application/json" }
|
|
1331
|
+
});
|
|
1332
|
+
if (acctResponse.status !== 200) throw ApiError.fromResponse(acctResponse.status, acctResponse.body);
|
|
1333
|
+
accounts.push(...JSON.parse(acctResponse.body));
|
|
1334
|
+
}
|
|
1335
|
+
return accounts;
|
|
1291
1336
|
}
|
|
1292
1337
|
/**
|
|
1293
1338
|
* Set a password on a managed account via A2A.
|
|
@@ -1297,7 +1342,7 @@ var A2AClient = class {
|
|
|
1297
1342
|
async setPassword(apiKey, password) {
|
|
1298
1343
|
this.#ensureHttpClient();
|
|
1299
1344
|
const response = await this.#httpClient.request({
|
|
1300
|
-
url: `https://${this.#host}/service/a2a/${this.#apiVersion}/Credentials
|
|
1345
|
+
url: `https://${this.#host}/service/a2a/${this.#apiVersion}/Credentials/Password`,
|
|
1301
1346
|
method: "PUT",
|
|
1302
1347
|
headers: {
|
|
1303
1348
|
Authorization: `A2A ${apiKey}`,
|
|
@@ -1317,13 +1362,11 @@ var A2AClient = class {
|
|
|
1317
1362
|
*/
|
|
1318
1363
|
async setPrivateKey(apiKey, key, passphrase, format) {
|
|
1319
1364
|
this.#ensureHttpClient();
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1322
|
-
KeyFormat: format ?? "OpenSsh"
|
|
1323
|
-
};
|
|
1365
|
+
const keyFormat = format ?? "OpenSsh";
|
|
1366
|
+
const payload = { PrivateKey: key };
|
|
1324
1367
|
if (passphrase) payload["Passphrase"] = passphrase;
|
|
1325
1368
|
const response = await this.#httpClient.request({
|
|
1326
|
-
url: `https://${this.#host}/service/a2a/${this.#apiVersion}/Credentials?
|
|
1369
|
+
url: `https://${this.#host}/service/a2a/${this.#apiVersion}/Credentials/SshKey?keyFormat=${keyFormat}`,
|
|
1327
1370
|
method: "PUT",
|
|
1328
1371
|
headers: {
|
|
1329
1372
|
Authorization: `A2A ${apiKey}`,
|