axiam-sdk 1.0.0-alpha21 → 1.0.0-alpha23
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/dist/{client-Dn1fs5MH.d.ts → client-Bvq888vU.d.ts} +1 -1
- package/dist/{client-B_FqmZ0i.d.cts → client-jcu7cvt2.d.cts} +1 -1
- package/dist/{cookieJar-Cl8Lq9dL.d.ts → cookieJar-BNQRJ1-1.d.ts} +28 -5
- package/dist/{cookieJar-BTDnjjbL.d.cts → cookieJar-pfVRO-Vj.d.cts} +28 -5
- package/dist/grpc/index.d.cts +4 -4
- package/dist/grpc/index.d.ts +4 -4
- package/dist/grpc/index.js +36 -13
- package/dist/grpc/index.js.map +1 -1
- package/dist/grpc/index.mjs +36 -13
- package/dist/grpc/index.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -7
- package/dist/index.mjs.map +1 -1
- package/dist/middleware/index.d.cts +3 -3
- package/dist/middleware/index.d.ts +3 -3
- package/dist/node/index.d.cts +4 -4
- package/dist/node/index.d.ts +4 -4
- package/dist/node/index.js +36 -13
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +36 -13
- package/dist/node/index.mjs.map +1 -1
- package/dist/{oidcState-CkFuCjpM.d.ts → oidcState-BXrGx6Qu.d.ts} +1 -1
- package/dist/{oidcState-BGxqWUun.d.cts → oidcState-BeB2oC6X.d.cts} +1 -1
- package/dist/rest/index.d.cts +2 -2
- package/dist/rest/index.d.ts +2 -2
- package/dist/rest/index.js +26 -7
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/index.mjs +26 -7
- package/dist/rest/index.mjs.map +1 -1
- package/dist/{session-BWUWhhyB.d.cts → session-9-H_BWCN.d.cts} +9 -1
- package/dist/{session-BWUWhhyB.d.ts → session-9-H_BWCN.d.ts} +9 -1
- package/package.json +2 -2
package/dist/node/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { CookieJar } from 'tough-cookie';
|
|
3
|
-
import {
|
|
3
|
+
import { HttpCookieAgent, HttpsCookieAgent } from 'http-cookie-agent/http';
|
|
4
4
|
import { randomBytes, createHash, timingSafeEqual } from 'crypto';
|
|
5
5
|
|
|
6
6
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -373,7 +373,20 @@ function resolveTenantHeaderValue(options) {
|
|
|
373
373
|
"AxiamClient construction requires a tenant: provide either tenantSlug or tenantId (CONTRACT.md \xA75)."
|
|
374
374
|
);
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function loadNodeHttps() {
|
|
377
|
+
const getBuiltinModule = process.getBuiltinModule;
|
|
378
|
+
if (typeof getBuiltinModule === "function") {
|
|
379
|
+
return getBuiltinModule.call(process, "node:https");
|
|
380
|
+
}
|
|
381
|
+
try {
|
|
382
|
+
return __require("https");
|
|
383
|
+
} catch {
|
|
384
|
+
throw new Error(
|
|
385
|
+
`customCa and clientCert require Node's https module, which this ESM build cannot load on Node ${process.version}: process.getBuiltinModule is unavailable (added in Node 20.16 / 22.3) and \`require\` does not exist in an ES module. Upgrade Node to >= 20.16, or load the CommonJS build (CONTRACT.md \xA76 / \xA76.1).`
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function tlsOptionsFrom(customCa, identity) {
|
|
377
390
|
if (!customCa) {
|
|
378
391
|
if (!identity) {
|
|
379
392
|
return void 0;
|
|
@@ -383,15 +396,24 @@ function maybeBuildHttpsAgent(customCa, identity) {
|
|
|
383
396
|
'customCa must be a PEM-encoded certificate (expected to contain "-----BEGIN CERTIFICATE-----") (CONTRACT.md \xA76).'
|
|
384
397
|
);
|
|
385
398
|
}
|
|
399
|
+
return {
|
|
400
|
+
...customCa ? { ca: customCa } : {},
|
|
401
|
+
...identity ? { cert: identity.cert, key: identity.key.expose() } : {}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function resolveNodeTlsOptions(options) {
|
|
405
|
+
return tlsOptionsFrom(options.customCa, resolveClientIdentity(options));
|
|
406
|
+
}
|
|
407
|
+
function maybeBuildHttpsAgent(customCa, identity) {
|
|
408
|
+
const tls = tlsOptionsFrom(customCa, identity);
|
|
409
|
+
if (!tls) {
|
|
410
|
+
return void 0;
|
|
411
|
+
}
|
|
386
412
|
if (typeof process === "undefined") {
|
|
387
413
|
return void 0;
|
|
388
414
|
}
|
|
389
|
-
const https =
|
|
390
|
-
return new https.Agent(
|
|
391
|
-
...customCa ? { ca: customCa } : {},
|
|
392
|
-
// rejectUnauthorized is intentionally left at its secure default (true).
|
|
393
|
-
...identity ? { cert: identity.cert, key: identity.key.expose() } : {}
|
|
394
|
-
});
|
|
415
|
+
const https = loadNodeHttps();
|
|
416
|
+
return new https.Agent(tls);
|
|
395
417
|
}
|
|
396
418
|
function createSession(options) {
|
|
397
419
|
const tenantHeaderValue = resolveTenantHeaderValue(options);
|
|
@@ -714,10 +736,11 @@ var CSRF_COOKIE = "axiam_csrf";
|
|
|
714
736
|
function createJar() {
|
|
715
737
|
return new CookieJar();
|
|
716
738
|
}
|
|
717
|
-
function wrapAxios(instance, jar) {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
739
|
+
function wrapAxios(instance, jar, tls) {
|
|
740
|
+
const cookies = { jar };
|
|
741
|
+
instance.defaults.httpAgent = new HttpCookieAgent({ cookies });
|
|
742
|
+
instance.defaults.httpsAgent = new HttpsCookieAgent({ cookies, ...tls ?? {} });
|
|
743
|
+
return instance;
|
|
721
744
|
}
|
|
722
745
|
async function extractCookieValue(jar, url, name) {
|
|
723
746
|
const cookies = await jar.getCookies(url);
|
|
@@ -1015,7 +1038,7 @@ var NodeSession = class extends SharedSession {
|
|
|
1015
1038
|
function createNodeSession(options) {
|
|
1016
1039
|
const base = createSession(options);
|
|
1017
1040
|
const jar = createJar();
|
|
1018
|
-
wrapAxios(base.axios, jar);
|
|
1041
|
+
wrapAxios(base.axios, jar, resolveNodeTlsOptions(options));
|
|
1019
1042
|
const tokenManager = new TokenManager(jar, options.baseUrl, base.tenantHeaderValue);
|
|
1020
1043
|
const jwksVerifier = createVerifier(options.baseUrl);
|
|
1021
1044
|
return new NodeSession(options, base, tokenManager, jwksVerifier, jar);
|