@stateworks/integration 1.0.0 → 3.0.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/sdk.d.ts +3 -1
- package/dist/sdk.js +1 -1
- package/dist/types.d.ts +21 -0
- package/package.json +1 -1
package/dist/sdk.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Client } from './client';
|
|
2
|
+
import { Configuration } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Sdk
|
|
4
5
|
*/
|
|
@@ -7,6 +8,7 @@ export declare class Sdk {
|
|
|
7
8
|
* Connect
|
|
8
9
|
*
|
|
9
10
|
* @param url The URL of the server
|
|
11
|
+
* @param configuration The Configuration used on client
|
|
10
12
|
*/
|
|
11
|
-
connect(url: string): Promise<Client>;
|
|
13
|
+
connect(url: string, configuration?: Configuration): Promise<Client>;
|
|
12
14
|
}
|
package/dist/sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Sdk=void 0;const isomorphic_ws_1=__importDefault(require("isomorphic-ws")),fs_1=__importDefault(require("fs")),https_1=__importDefault(require("https")),client_1=require("./client");class Sdk{async connect(e,s={}){return new Promise((a,t)=>{const r=new https_1.default.Agent({ca:fs_1.default.readFileSync(s.ca_file??"ca.crt"),cert:fs_1.default.readFileSync(s.cert_file??"client.crt"),key:fs_1.default.readFileSync(s.key_file??"client.key"),rejectUnauthorized:!0,passphrase:s.passphrase??"d96ab300"}),n=new isomorphic_ws_1.default(e,{agent:r}),c=new client_1.Client(n);c.ws.onerror=t,c.ws.onopen=()=>{},c.ws.onmessage=e=>{const s=JSON.parse(e.data);c.id=s.data.client_id,c.ws.onmessage=e=>{const s=JSON.parse(e.data);switch(s.action){case"ack":if(c.promises.has(s.transaction_id)){const e=c.promises.get(s.transaction_id);"success"==s.status?e.on_success(s):e.on_error(s)}if(c.handlers.has("ack")){c.handlers.get("ack")(s)}break;case"broadcast":if(c.handlers.has("broadcast")){c.handlers.get("broadcast")(s)}break;case"send":if(c.handlers.has("send")){c.handlers.get("send")(s)}break;case"publish":if(c.handlers.has("publish")){c.handlers.get("publish")(s)}const e=s;if(c.channels.has(e.params.channel)){c.channels.get(e.params.channel)(s)}}},a(c)}})}}exports.Sdk=Sdk;
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,27 @@ export type Statuses = 'success' | 'failed';
|
|
|
14
14
|
* Statuses
|
|
15
15
|
*/
|
|
16
16
|
export type Messages = 'ok' | 'no effect' | 'unprocessable entity' | 'pong';
|
|
17
|
+
/**
|
|
18
|
+
* Configuration
|
|
19
|
+
*/
|
|
20
|
+
export interface Configuration {
|
|
21
|
+
/**
|
|
22
|
+
* CA File
|
|
23
|
+
*/
|
|
24
|
+
ca_file?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Cert File
|
|
27
|
+
*/
|
|
28
|
+
cert_file?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Key File
|
|
31
|
+
*/
|
|
32
|
+
key_file?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Passphrase
|
|
35
|
+
*/
|
|
36
|
+
passphrase?: string;
|
|
37
|
+
}
|
|
17
38
|
/**
|
|
18
39
|
* Event
|
|
19
40
|
*/
|