@otonoma/paranet-client 2.16.0-rc.8 → 2.16.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.
Files changed (52) hide show
  1. package/dist/cjs/client.d.ts +3 -0
  2. package/dist/cjs/client.d.ts.map +1 -1
  3. package/dist/cjs/graphql.d.ts.map +1 -1
  4. package/dist/cjs/index-Dz-_ygkd.cjs +27200 -0
  5. package/dist/cjs/index-Dz-_ygkd.cjs.map +1 -0
  6. package/dist/cjs/index.cjs +40 -3
  7. package/dist/cjs/index.cjs.map +1 -1
  8. package/dist/cjs/index.d.ts.map +1 -1
  9. package/dist/cjs/pncp.d.ts.map +1 -1
  10. package/dist/cjs/proto/broker.grpc.client.d.ts.map +1 -1
  11. package/dist/cjs/proto/broker.grpc.d.ts.map +1 -1
  12. package/dist/cjs/proto/broker_api.d.ts.map +1 -1
  13. package/dist/cjs/proto/google/protobuf/descriptor.d.ts.map +1 -1
  14. package/dist/cjs/proto/google/protobuf/timestamp.d.ts.map +1 -1
  15. package/dist/cjs/proto/grpc/health/v1/health.client.d.ts.map +1 -1
  16. package/dist/cjs/proto/grpc/health/v1/health.d.ts.map +1 -1
  17. package/dist/cjs/proto/identifiers.d.ts.map +1 -1
  18. package/dist/cjs/proto/mediums.d.ts.map +1 -1
  19. package/dist/cjs/proto/observation.d.ts.map +1 -1
  20. package/dist/cjs/proto/otonoma/common/value.d.ts.map +1 -1
  21. package/dist/cjs/proto/pncp.d.ts.map +1 -1
  22. package/dist/cjs/schema/paranet.d.ts.map +1 -1
  23. package/dist/cjs/util.d.ts.map +1 -1
  24. package/dist/client.d.ts +3 -0
  25. package/dist/client.d.ts.map +1 -1
  26. package/dist/client.js +40 -3
  27. package/dist/esm/client.d.ts +3 -0
  28. package/dist/esm/client.d.ts.map +1 -1
  29. package/dist/esm/graphql.d.ts.map +1 -1
  30. package/dist/esm/index-CO5PSAqf.mjs +27198 -0
  31. package/dist/esm/index-CO5PSAqf.mjs.map +1 -0
  32. package/dist/esm/index.d.ts.map +1 -1
  33. package/dist/esm/index.mjs +40 -3
  34. package/dist/esm/index.mjs.map +1 -1
  35. package/dist/esm/pncp.d.ts.map +1 -1
  36. package/dist/esm/proto/broker.grpc.client.d.ts.map +1 -1
  37. package/dist/esm/proto/broker.grpc.d.ts.map +1 -1
  38. package/dist/esm/proto/broker_api.d.ts.map +1 -1
  39. package/dist/esm/proto/google/protobuf/descriptor.d.ts.map +1 -1
  40. package/dist/esm/proto/google/protobuf/timestamp.d.ts.map +1 -1
  41. package/dist/esm/proto/grpc/health/v1/health.client.d.ts.map +1 -1
  42. package/dist/esm/proto/grpc/health/v1/health.d.ts.map +1 -1
  43. package/dist/esm/proto/identifiers.d.ts.map +1 -1
  44. package/dist/esm/proto/mediums.d.ts.map +1 -1
  45. package/dist/esm/proto/observation.d.ts.map +1 -1
  46. package/dist/esm/proto/otonoma/common/value.d.ts.map +1 -1
  47. package/dist/esm/proto/pncp.d.ts.map +1 -1
  48. package/dist/esm/schema/paranet.d.ts.map +1 -1
  49. package/dist/esm/util.d.ts.map +1 -1
  50. package/dist/index.d.cts +3 -0
  51. package/dist/index.d.mts +3 -0
  52. package/package.json +3 -2
@@ -7150,16 +7150,36 @@ class HealthClient {
7150
7150
  }
7151
7151
 
7152
7152
  // Wrapper client around the paranet broker and data service.
7153
+ // undici is loaded dynamically only in Node.js when insecure mode is needed
7154
+ let undiciModule = null;
7155
+ async function getUndici() {
7156
+ if (!undiciModule) {
7157
+ undiciModule = await Promise.resolve().then(function () { return require('./index-Dz-_ygkd.cjs'); }).then(function (n) { return n.index; });
7158
+ }
7159
+ return undiciModule;
7160
+ }
7153
7161
  class PncpClient {
7154
7162
  constructor(init) {
7155
7163
  this.actorId = init.actorId;
7156
7164
  this.endpoint = init.endpoint;
7157
7165
  this.actorVersion = init.actorVersion;
7166
+ var fetchFn = init.fetch;
7167
+ // Note: insecure TLS bypass only works in Node.js with undici
7168
+ // In browser environments, insecure mode is ignored (browsers don't allow TLS bypass)
7169
+ if (!fetchFn && init.insecure && init.endpoint.startsWith("https") && typeof globalThis.process !== 'undefined' && globalThis.process?.versions?.node) {
7170
+ // Synchronously check if undici is already loaded, otherwise load it lazily on first request
7171
+ fetchFn = async (request, options) => {
7172
+ const undici = await getUndici();
7173
+ var fetchOptions = options || {};
7174
+ fetchOptions.dispatcher = new undici.Agent({ connect: { rejectUnauthorized: false } });
7175
+ return undici.fetch(request, fetchOptions);
7176
+ };
7177
+ }
7158
7178
  // TODO: Consider passing in transport config.
7159
7179
  this.transport = new GrpcWebFetchTransport({
7160
7180
  baseUrl: init.endpoint,
7161
7181
  format: "binary",
7162
- fetch: init.fetch,
7182
+ fetch: fetchFn,
7163
7183
  // TODO: Consider other methods here.
7164
7184
  });
7165
7185
  this.inner = new BrokerClient(this.transport);
@@ -7266,6 +7286,9 @@ class PncpClient {
7266
7286
  case "password":
7267
7287
  secret = { oneofKind: "password", password: creds.secret };
7268
7288
  break;
7289
+ case "jwt":
7290
+ secret = { oneofKind: "jwt", jwt: creds.secret };
7291
+ break;
7269
7292
  default:
7270
7293
  throw new Error("Invalid creds type");
7271
7294
  }
@@ -7490,6 +7513,7 @@ class BaseClient {
7490
7513
  constructor(init) {
7491
7514
  this.endpoint = cleanUrl(init.endpoint);
7492
7515
  this.actorId = init.actorId;
7516
+ this.insecure = init.insecure ?? false;
7493
7517
  }
7494
7518
  getEndpoint() {
7495
7519
  return this.endpoint;
@@ -7563,14 +7587,27 @@ class BaseClient {
7563
7587
  }
7564
7588
  async fetch(path, method, body, headers) {
7565
7589
  let url = `${this.endpoint}/${path}`;
7566
- const mkFetch = () => fetch(url, {
7590
+ // Build fetch options, with optional TLS bypass for Node.js
7591
+ let fetchOptions = {
7567
7592
  method,
7568
7593
  body,
7569
7594
  headers: {
7570
7595
  ...(headers || {}),
7571
7596
  ...this.getHeaders(),
7572
7597
  },
7573
- });
7598
+ };
7599
+ // For Node.js: bypass certificate verification if insecure mode is enabled
7600
+ // Must use undici.fetch (not global fetch) for dispatcher option to work
7601
+ // In browser environments, insecure mode is ignored (browsers don't allow TLS bypass)
7602
+ const isNode = typeof globalThis.process !== 'undefined' && globalThis.process?.versions?.node;
7603
+ const mkFetch = async () => {
7604
+ if (this.insecure && isNode) {
7605
+ const undici = await getUndici();
7606
+ fetchOptions.dispatcher = new undici.Agent({ connect: { rejectUnauthorized: false } });
7607
+ return undici.fetch(url, fetchOptions);
7608
+ }
7609
+ return fetch(url, fetchOptions);
7610
+ };
7574
7611
  let response = await mkFetch();
7575
7612
  if (response.status == 401) {
7576
7613
  await this.refreshAuth();