@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.
- package/dist/cjs/client.d.ts +3 -0
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/graphql.d.ts.map +1 -1
- package/dist/cjs/index-Dz-_ygkd.cjs +27200 -0
- package/dist/cjs/index-Dz-_ygkd.cjs.map +1 -0
- package/dist/cjs/index.cjs +40 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/pncp.d.ts.map +1 -1
- package/dist/cjs/proto/broker.grpc.client.d.ts.map +1 -1
- package/dist/cjs/proto/broker.grpc.d.ts.map +1 -1
- package/dist/cjs/proto/broker_api.d.ts.map +1 -1
- package/dist/cjs/proto/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/cjs/proto/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/cjs/proto/grpc/health/v1/health.client.d.ts.map +1 -1
- package/dist/cjs/proto/grpc/health/v1/health.d.ts.map +1 -1
- package/dist/cjs/proto/identifiers.d.ts.map +1 -1
- package/dist/cjs/proto/mediums.d.ts.map +1 -1
- package/dist/cjs/proto/observation.d.ts.map +1 -1
- package/dist/cjs/proto/otonoma/common/value.d.ts.map +1 -1
- package/dist/cjs/proto/pncp.d.ts.map +1 -1
- package/dist/cjs/schema/paranet.d.ts.map +1 -1
- package/dist/cjs/util.d.ts.map +1 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +40 -3
- package/dist/esm/client.d.ts +3 -0
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/graphql.d.ts.map +1 -1
- package/dist/esm/index-CO5PSAqf.mjs +27198 -0
- package/dist/esm/index-CO5PSAqf.mjs.map +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +40 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/pncp.d.ts.map +1 -1
- package/dist/esm/proto/broker.grpc.client.d.ts.map +1 -1
- package/dist/esm/proto/broker.grpc.d.ts.map +1 -1
- package/dist/esm/proto/broker_api.d.ts.map +1 -1
- package/dist/esm/proto/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/esm/proto/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/esm/proto/grpc/health/v1/health.client.d.ts.map +1 -1
- package/dist/esm/proto/grpc/health/v1/health.d.ts.map +1 -1
- package/dist/esm/proto/identifiers.d.ts.map +1 -1
- package/dist/esm/proto/mediums.d.ts.map +1 -1
- package/dist/esm/proto/observation.d.ts.map +1 -1
- package/dist/esm/proto/otonoma/common/value.d.ts.map +1 -1
- package/dist/esm/proto/pncp.d.ts.map +1 -1
- package/dist/esm/schema/paranet.d.ts.map +1 -1
- package/dist/esm/util.d.ts.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/package.json +3 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
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();
|