@aloma.io/integration-sdk 3.0.7-rc2 → 3.0.7-rc3

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 (28) hide show
  1. package/build/internal/index.mjs +16 -12
  2. package/build/internal/util/jwe/cli.mjs +1 -2
  3. package/build/internal/util/jwe/index.d.mts +1 -1
  4. package/build/internal/util/jwe/index.mjs +1 -1
  5. package/build/internal/websocket/config.d.mts +3 -2
  6. package/build/internal/websocket/config.mjs +2 -2
  7. package/build/internal/websocket/connection/constants.d.mts +5 -2
  8. package/build/internal/websocket/connection/constants.mjs +1 -2
  9. package/build/internal/websocket/connection/index.mjs +4 -5
  10. package/build/internal/websocket/connection/registration.mjs +3 -4
  11. package/build/internal/websocket/index.mjs +3 -3
  12. package/build/internal/websocket/transport/durable.mjs +1 -1
  13. package/build/internal/websocket/transport/index.mjs +6 -6
  14. package/build/internal/websocket/transport/packet.mjs +2 -2
  15. package/build/internal/websocket/transport/processor.mjs +1 -1
  16. package/package.json +1 -1
  17. package/src/internal/index.mjs +17 -12
  18. package/src/internal/util/jwe/cli.mjs +1 -1
  19. package/src/internal/util/jwe/index.mjs +1 -1
  20. package/src/internal/websocket/config.mjs +2 -2
  21. package/src/internal/websocket/connection/constants.mjs +1 -1
  22. package/src/internal/websocket/connection/index.mjs +4 -4
  23. package/src/internal/websocket/connection/registration.mjs +3 -3
  24. package/src/internal/websocket/index.mjs +3 -3
  25. package/src/internal/websocket/transport/durable.mjs +1 -1
  26. package/src/internal/websocket/transport/index.mjs +7 -6
  27. package/src/internal/websocket/transport/packet.mjs +2 -2
  28. package/src/internal/websocket/transport/processor.mjs +1 -1
@@ -1,14 +1,18 @@
1
1
  // @ts-nocheck
2
- require("dotenv").config();
3
- const fs = require("fs");
4
- const { Config } = require("./websocket/config.mjs");
5
- const { Connection } = require("./websocket/connection/index.mjs");
6
- const { Transport } = require("./websocket/transport/index.mjs");
7
- const { Dispatcher } = require("./dispatcher/index.mjs");
8
- const { WebsocketConnector } = require("./websocket/index.mjs");
9
- const JWE = require("./util/jwe/index.mjs");
10
- const fetch = require("node-fetch");
11
- const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
+ import fs from "node:fs";
5
+ import { Config } from "./websocket/config.mjs";
6
+ import { Connection } from "./websocket/connection/index.mjs";
7
+ import { Transport } from "./websocket/transport/index.mjs";
8
+ import { Dispatcher } from "./dispatcher/index.mjs";
9
+ import { WebsocketConnector } from "./websocket/index.mjs";
10
+ import JWE from "./util/jwe/index.mjs";
11
+ import fetch from "node-fetch";
12
+ import cuid from "@paralleldrive/cuid2";
13
+ import express from 'express';
14
+ import PromClient from 'prom-client';
15
+ cuid.init({ length: 32 });
12
16
  // TODO fetch with retry
13
17
  const handlePacketError = (packet, e, transport) => {
14
18
  if (!packet.cb()) {
@@ -163,7 +167,7 @@ class Connector {
163
167
  async run() {
164
168
  var local = this;
165
169
  const makeMetrics = () => {
166
- const metrics = require("prom-client");
170
+ const metrics = PromClient;
167
171
  const defaultLabels = {
168
172
  service: local.name,
169
173
  connectorId: local.id,
@@ -175,7 +179,7 @@ class Connector {
175
179
  return metrics;
176
180
  };
177
181
  const makeMetricsServer = (metrics) => {
178
- const app = require("express")();
182
+ const app = express();
179
183
  app.get("/metrics", async (request, response, next) => {
180
184
  response.status(200);
181
185
  response.set("Content-type", metrics.contentType);
@@ -1,4 +1,4 @@
1
- const JWE = require("./index.mjs");
1
+ import JWE from "./index.mjs";
2
2
  const main = async () => {
3
3
  const jwe = new JWE({});
4
4
  await jwe.newPair();
@@ -9,4 +9,3 @@ const main = async () => {
9
9
  };
10
10
  setTimeout(() => null, 100);
11
11
  main();
12
- export {};
@@ -29,4 +29,4 @@ declare class JWE {
29
29
  encrypt(what: any, expiration: string | undefined, audience: any, algorithm?: string): Promise<string>;
30
30
  decrypt(what: any, audience: any): Promise<unknown>;
31
31
  }
32
- import jose = require("jose");
32
+ import * as jose from "jose";
@@ -1,4 +1,4 @@
1
- const jose = require("jose");
1
+ import * as jose from "jose";
2
2
  class JWE {
3
3
  constructor({ algorithm = "PS256" }) {
4
4
  this.issuer = "home.aloma.io";
@@ -21,10 +21,10 @@ export class Config {
21
21
  _data: {};
22
22
  _privateKey: any;
23
23
  _publicKey: any;
24
- _jwe: any;
24
+ _jwe: JWE;
25
25
  _introspect: any;
26
26
  _configSchema: any;
27
- validateKeys(algorithm: any): Promise<any>;
27
+ validateKeys(algorithm: any): Promise<JWE>;
28
28
  data(what: any): {};
29
29
  introspect(): any;
30
30
  configSchema(): any;
@@ -38,3 +38,4 @@ export class Config {
38
38
  token(): any;
39
39
  setToken(what: any): void;
40
40
  }
41
+ import JWE from "../util/jwe/index.mjs";
@@ -1,5 +1,5 @@
1
- const C = require("./connection/constants.mjs");
2
- const JWE = require("../util/jwe/index.mjs");
1
+ import C from "./connection/constants.mjs";
2
+ import JWE from "../util/jwe/index.mjs";
3
3
  class Config {
4
4
  constructor({ registrationToken, version, name, id, endpoint, wsEndpoint, privateKey, publicKey, introspect, configSchema, }) {
5
5
  this._token = null;
@@ -1,2 +1,5 @@
1
- export function augmentRequest(what: any, config: any): any;
2
- export function augmentRegistration(what: any, config: any): any;
1
+ declare namespace _default {
2
+ function augmentRequest(what: any, config: any): any;
3
+ function augmentRegistration(what: any, config: any): any;
4
+ }
5
+ export default _default;
@@ -1,5 +1,5 @@
1
1
  const AUTHORIZATION = "Authorization";
2
- module.exports = {
2
+ export default {
3
3
  augmentRequest: (what, config) => {
4
4
  what.headers = {
5
5
  ...what.headers,
@@ -17,4 +17,3 @@ module.exports = {
17
17
  return what;
18
18
  },
19
19
  };
20
- export {};
@@ -1,6 +1,6 @@
1
- const fetch = require("node-fetch");
2
- const { Registration } = require("./registration.cjs");
3
- const C = require("./constants.cjs");
1
+ import fetch from "node-fetch";
2
+ import { Registration } from "./registration.mjs";
3
+ import C from "./constants.mjs";
4
4
  class Connection {
5
5
  constructor({ config, onStart }) {
6
6
  this.config = config;
@@ -48,5 +48,4 @@ class Connection {
48
48
  }
49
49
  }
50
50
  }
51
- module.exports = { Connection };
52
- export {};
51
+ export { Connection };
@@ -1,5 +1,5 @@
1
- const fetch = require("node-fetch");
2
- const C = require("./constants.cjs");
1
+ import fetch from "node-fetch";
2
+ import C from "./constants.mjs";
3
3
  class Registration {
4
4
  constructor(config) {
5
5
  this.config = config;
@@ -26,5 +26,4 @@ class Registration {
26
26
  throw new Error("authentication failed");
27
27
  }
28
28
  }
29
- module.exports = { Registration };
30
- export {};
29
+ export { Registration };
@@ -1,6 +1,6 @@
1
- const WebSocket = require("ws");
2
- const { Connection } = require("./connection/index.mjs");
3
- const { Transport } = require("./transport/index.mjs");
1
+ import WebSocket from "ws";
2
+ import { Connection } from "./connection/index.mjs";
3
+ import { Transport } from "./transport/index.mjs";
4
4
  class WebsocketConnector {
5
5
  constructor({ config, onMessage, onConnect }) {
6
6
  var local = this;
@@ -1,4 +1,4 @@
1
- const WebSocket = require("ws");
1
+ import WebSocket from "ws";
2
2
  class DurableWebsocket {
3
3
  constructor({ endpoint, secret, onConnect, onMessage }) {
4
4
  this.endpoint = endpoint;
@@ -1,9 +1,9 @@
1
- const fetch = require("node-fetch");
2
- const C = require("../connection/constants.mjs");
3
- const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
4
- const { DurableWebsocket } = require("./durable.mjs");
5
- const WebSocket = require("ws");
6
- const { Packet, Callback } = require("./packet.mjs");
1
+ import C from "../connection/constants.mjs";
2
+ import cuid from "@paralleldrive/cuid2";
3
+ cuid.init({ length: 32 });
4
+ import { DurableWebsocket } from "./durable.mjs";
5
+ import WebSocket from "ws";
6
+ import { Packet, Callback } from "./packet.mjs";
7
7
  const cleanInterval = 45 * 1000;
8
8
  const pingInterval = 30 * 1000;
9
9
  class Transport {
@@ -1,5 +1,5 @@
1
- const fetch = require("node-fetch");
2
- const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
1
+ import cuid from "@paralleldrive/cuid2";
2
+ cuid.init({ length: 32 });
3
3
  class Packet {
4
4
  constructor(data = {}) {
5
5
  this.data = data;
@@ -1,4 +1,4 @@
1
- const { Packet, Callback } = require("./packet.mjs");
1
+ import { Packet, Callback } from "./packet.mjs";
2
2
  class Processor {
3
3
  constructor({ transport, processPacket }) {
4
4
  var local = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.7-rc2",
3
+ "version": "3.0.7-rc3",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -1,14 +1,19 @@
1
1
  // @ts-nocheck
2
- require("dotenv").config();
3
- const fs = require("fs");
4
- const { Config } = require("./websocket/config.mjs");
5
- const { Connection } = require("./websocket/connection/index.mjs");
6
- const { Transport } = require("./websocket/transport/index.mjs");
7
- const { Dispatcher } = require("./dispatcher/index.mjs");
8
- const { WebsocketConnector } = require("./websocket/index.mjs");
9
- const JWE = require("./util/jwe/index.mjs");
10
- const fetch = require("node-fetch");
11
- const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
2
+ import dotenv from 'dotenv';
3
+ dotenv.config();
4
+ import fs from "node:fs";
5
+ import { Config } from "./websocket/config.mjs";
6
+ import { Connection } from "./websocket/connection/index.mjs";
7
+ import { Transport } from "./websocket/transport/index.mjs";
8
+ import { Dispatcher } from "./dispatcher/index.mjs";
9
+ import { WebsocketConnector } from "./websocket/index.mjs";
10
+ import JWE from "./util/jwe/index.mjs";
11
+ import fetch from "node-fetch";
12
+ import cuid from "@paralleldrive/cuid2"
13
+ import express from 'express';
14
+ import PromClient from 'prom-client'
15
+
16
+ cuid.init({ length: 32 });
12
17
 
13
18
  // TODO fetch with retry
14
19
 
@@ -209,7 +214,7 @@ class Connector {
209
214
  var local = this;
210
215
 
211
216
  const makeMetrics = () => {
212
- const metrics = require("prom-client");
217
+ const metrics = PromClient;
213
218
 
214
219
  const defaultLabels = {
215
220
  service: local.name,
@@ -224,7 +229,7 @@ class Connector {
224
229
  };
225
230
 
226
231
  const makeMetricsServer = (metrics) => {
227
- const app = require("express")();
232
+ const app = express();
228
233
 
229
234
  app.get("/metrics", async (request, response, next) => {
230
235
  response.status(200);
@@ -1,4 +1,4 @@
1
- const JWE = require("./index.mjs");
1
+ import JWE from "./index.mjs";
2
2
 
3
3
  const main = async () => {
4
4
  const jwe = new JWE({});
@@ -1,4 +1,4 @@
1
- const jose = require("jose");
1
+ import * as jose from "jose";
2
2
 
3
3
  class JWE {
4
4
  constructor({ algorithm = "PS256" }) {
@@ -1,5 +1,5 @@
1
- const C = require("./connection/constants.mjs");
2
- const JWE = require("../util/jwe/index.mjs");
1
+ import C from "./connection/constants.mjs";
2
+ import JWE from "../util/jwe/index.mjs";
3
3
 
4
4
  class Config {
5
5
  constructor({
@@ -1,6 +1,6 @@
1
1
  const AUTHORIZATION = "Authorization";
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  augmentRequest: (what, config) => {
5
5
  what.headers = {
6
6
  ...what.headers,
@@ -1,6 +1,6 @@
1
- const fetch = require("node-fetch");
2
- const { Registration } = require("./registration.cjs");
3
- const C = require("./constants.cjs");
1
+ import fetch from "node-fetch";
2
+ import { Registration } from "./registration.mjs";
3
+ import C from "./constants.mjs";
4
4
 
5
5
  class Connection {
6
6
  constructor({ config, onStart }) {
@@ -67,4 +67,4 @@ class Connection {
67
67
  }
68
68
  }
69
69
 
70
- module.exports = { Connection };
70
+ export { Connection };
@@ -1,5 +1,5 @@
1
- const fetch = require("node-fetch");
2
- const C = require("./constants.cjs");
1
+ import fetch from "node-fetch";
2
+ import C from "./constants.mjs";
3
3
 
4
4
  class Registration {
5
5
  constructor(config) {
@@ -37,4 +37,4 @@ class Registration {
37
37
  }
38
38
  }
39
39
 
40
- module.exports = { Registration };
40
+ export { Registration };
@@ -1,6 +1,6 @@
1
- const WebSocket = require("ws");
2
- const { Connection } = require("./connection/index.mjs");
3
- const { Transport } = require("./transport/index.mjs");
1
+ import WebSocket from "ws";
2
+ import { Connection } from "./connection/index.mjs";
3
+ import { Transport } from "./transport/index.mjs";
4
4
 
5
5
  class WebsocketConnector {
6
6
  constructor({ config, onMessage, onConnect }) {
@@ -1,4 +1,4 @@
1
- const WebSocket = require("ws");
1
+ import WebSocket from "ws";
2
2
 
3
3
  class DurableWebsocket {
4
4
  constructor({ endpoint, secret, onConnect, onMessage }) {
@@ -1,9 +1,10 @@
1
- const fetch = require("node-fetch");
2
- const C = require("../connection/constants.mjs");
3
- const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
4
- const { DurableWebsocket } = require("./durable.mjs");
5
- const WebSocket = require("ws");
6
- const { Packet, Callback } = require("./packet.mjs");
1
+ import C from "../connection/constants.mjs";
2
+ import cuid from "@paralleldrive/cuid2"
3
+ cuid.init({ length: 32 });
4
+
5
+ import { DurableWebsocket } from "./durable.mjs";
6
+ import WebSocket from "ws";
7
+ import { Packet, Callback } from "./packet.mjs";
7
8
 
8
9
  const cleanInterval = 45 * 1000;
9
10
  const pingInterval = 30 * 1000;
@@ -1,5 +1,5 @@
1
- const fetch = require("node-fetch");
2
- const cuid = require("@paralleldrive/cuid2").init({ length: 32 });
1
+ import cuid from "@paralleldrive/cuid2";
2
+ cuid.init({ length: 32 });
3
3
 
4
4
  class Packet {
5
5
  constructor(data = {}) {
@@ -1,4 +1,4 @@
1
- const { Packet, Callback } = require("./packet.mjs");
1
+ import { Packet, Callback } from "./packet.mjs";
2
2
 
3
3
  class Processor {
4
4
  constructor({ transport, processPacket }) {