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.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
var toughCookie = require('tough-cookie');
|
|
5
|
-
var
|
|
5
|
+
var http = require('http-cookie-agent/http');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -379,7 +379,20 @@ function resolveTenantHeaderValue(options) {
|
|
|
379
379
|
"AxiamClient construction requires a tenant: provide either tenantSlug or tenantId (CONTRACT.md \xA75)."
|
|
380
380
|
);
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function loadNodeHttps() {
|
|
383
|
+
const getBuiltinModule = process.getBuiltinModule;
|
|
384
|
+
if (typeof getBuiltinModule === "function") {
|
|
385
|
+
return getBuiltinModule.call(process, "node:https");
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
return __require("https");
|
|
389
|
+
} catch {
|
|
390
|
+
throw new Error(
|
|
391
|
+
`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).`
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function tlsOptionsFrom(customCa, identity) {
|
|
383
396
|
if (!customCa) {
|
|
384
397
|
if (!identity) {
|
|
385
398
|
return void 0;
|
|
@@ -389,15 +402,24 @@ function maybeBuildHttpsAgent(customCa, identity) {
|
|
|
389
402
|
'customCa must be a PEM-encoded certificate (expected to contain "-----BEGIN CERTIFICATE-----") (CONTRACT.md \xA76).'
|
|
390
403
|
);
|
|
391
404
|
}
|
|
405
|
+
return {
|
|
406
|
+
...customCa ? { ca: customCa } : {},
|
|
407
|
+
...identity ? { cert: identity.cert, key: identity.key.expose() } : {}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function resolveNodeTlsOptions(options) {
|
|
411
|
+
return tlsOptionsFrom(options.customCa, resolveClientIdentity(options));
|
|
412
|
+
}
|
|
413
|
+
function maybeBuildHttpsAgent(customCa, identity) {
|
|
414
|
+
const tls = tlsOptionsFrom(customCa, identity);
|
|
415
|
+
if (!tls) {
|
|
416
|
+
return void 0;
|
|
417
|
+
}
|
|
392
418
|
if (typeof process === "undefined") {
|
|
393
419
|
return void 0;
|
|
394
420
|
}
|
|
395
|
-
const https =
|
|
396
|
-
return new https.Agent(
|
|
397
|
-
...customCa ? { ca: customCa } : {},
|
|
398
|
-
// rejectUnauthorized is intentionally left at its secure default (true).
|
|
399
|
-
...identity ? { cert: identity.cert, key: identity.key.expose() } : {}
|
|
400
|
-
});
|
|
421
|
+
const https = loadNodeHttps();
|
|
422
|
+
return new https.Agent(tls);
|
|
401
423
|
}
|
|
402
424
|
function createSession(options) {
|
|
403
425
|
const tenantHeaderValue = resolveTenantHeaderValue(options);
|
|
@@ -720,10 +742,11 @@ var CSRF_COOKIE = "axiam_csrf";
|
|
|
720
742
|
function createJar() {
|
|
721
743
|
return new toughCookie.CookieJar();
|
|
722
744
|
}
|
|
723
|
-
function wrapAxios(instance, jar) {
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
|
|
745
|
+
function wrapAxios(instance, jar, tls) {
|
|
746
|
+
const cookies = { jar };
|
|
747
|
+
instance.defaults.httpAgent = new http.HttpCookieAgent({ cookies });
|
|
748
|
+
instance.defaults.httpsAgent = new http.HttpsCookieAgent({ cookies, ...tls ?? {} });
|
|
749
|
+
return instance;
|
|
727
750
|
}
|
|
728
751
|
async function extractCookieValue(jar, url, name) {
|
|
729
752
|
const cookies = await jar.getCookies(url);
|
|
@@ -1021,7 +1044,7 @@ var NodeSession = class extends SharedSession {
|
|
|
1021
1044
|
function createNodeSession(options) {
|
|
1022
1045
|
const base = createSession(options);
|
|
1023
1046
|
const jar = createJar();
|
|
1024
|
-
wrapAxios(base.axios, jar);
|
|
1047
|
+
wrapAxios(base.axios, jar, resolveNodeTlsOptions(options));
|
|
1025
1048
|
const tokenManager = new TokenManager(jar, options.baseUrl, base.tenantHeaderValue);
|
|
1026
1049
|
const jwksVerifier = createVerifier(options.baseUrl);
|
|
1027
1050
|
return new NodeSession(options, base, tokenManager, jwksVerifier, jar);
|