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.
Files changed (35) hide show
  1. package/dist/{client-Dn1fs5MH.d.ts → client-Bvq888vU.d.ts} +1 -1
  2. package/dist/{client-B_FqmZ0i.d.cts → client-jcu7cvt2.d.cts} +1 -1
  3. package/dist/{cookieJar-Cl8Lq9dL.d.ts → cookieJar-BNQRJ1-1.d.ts} +28 -5
  4. package/dist/{cookieJar-BTDnjjbL.d.cts → cookieJar-pfVRO-Vj.d.cts} +28 -5
  5. package/dist/grpc/index.d.cts +4 -4
  6. package/dist/grpc/index.d.ts +4 -4
  7. package/dist/grpc/index.js +36 -13
  8. package/dist/grpc/index.js.map +1 -1
  9. package/dist/grpc/index.mjs +36 -13
  10. package/dist/grpc/index.mjs.map +1 -1
  11. package/dist/index.d.cts +2 -2
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.js +26 -7
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +26 -7
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/middleware/index.d.cts +3 -3
  18. package/dist/middleware/index.d.ts +3 -3
  19. package/dist/node/index.d.cts +4 -4
  20. package/dist/node/index.d.ts +4 -4
  21. package/dist/node/index.js +36 -13
  22. package/dist/node/index.js.map +1 -1
  23. package/dist/node/index.mjs +36 -13
  24. package/dist/node/index.mjs.map +1 -1
  25. package/dist/{oidcState-CkFuCjpM.d.ts → oidcState-BXrGx6Qu.d.ts} +1 -1
  26. package/dist/{oidcState-BGxqWUun.d.cts → oidcState-BeB2oC6X.d.cts} +1 -1
  27. package/dist/rest/index.d.cts +2 -2
  28. package/dist/rest/index.d.ts +2 -2
  29. package/dist/rest/index.js +26 -7
  30. package/dist/rest/index.js.map +1 -1
  31. package/dist/rest/index.mjs +26 -7
  32. package/dist/rest/index.mjs.map +1 -1
  33. package/dist/{session-BWUWhhyB.d.cts → session-9-H_BWCN.d.cts} +9 -1
  34. package/dist/{session-BWUWhhyB.d.ts → session-9-H_BWCN.d.ts} +9 -1
  35. package/package.json +2 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  var axios = require('axios');
4
4
  var toughCookie = require('tough-cookie');
5
- var axiosCookiejarSupport = require('axios-cookiejar-support');
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 maybeBuildHttpsAgent(customCa, identity) {
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 = __require("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 wrapped = axiosCookiejarSupport.wrapper(instance);
725
- wrapped.defaults.jar = jar;
726
- return wrapped;
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);