signal-bridge 1.0.10 → 1.0.14
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/README.md +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.global.js +24 -19
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -285,7 +285,7 @@ npm install signal-bridge
|
|
|
285
285
|
<div id="app"></div>
|
|
286
286
|
|
|
287
287
|
<script>
|
|
288
|
-
const bridge = window.signalBridge.
|
|
288
|
+
const bridge = window.signalBridge.initBridge('my-laravel-app', {
|
|
289
289
|
allowedHostOrigins: ['https://host-app.example.com'],
|
|
290
290
|
debug: true,
|
|
291
291
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -21,26 +21,26 @@ interface BridgeOptions {
|
|
|
21
21
|
declare function createBridge(appId: string, options: BridgeOptions): {
|
|
22
22
|
init(): void;
|
|
23
23
|
listen(handler: Listener): void;
|
|
24
|
-
emit(type: string, payload: any):
|
|
24
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
25
25
|
destroy(): void;
|
|
26
26
|
};
|
|
27
27
|
declare function resetBridge(): void;
|
|
28
28
|
declare function signalBridge(): {
|
|
29
29
|
init(): void;
|
|
30
30
|
listen(handler: Listener): void;
|
|
31
|
-
emit(type: string, payload: any):
|
|
31
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
32
32
|
destroy(): void;
|
|
33
33
|
};
|
|
34
34
|
declare function setupBridge(appId: string, options: BridgeOptions): {
|
|
35
35
|
init(): void;
|
|
36
36
|
listen(handler: Listener): void;
|
|
37
|
-
emit(type: string, payload: any):
|
|
37
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
38
38
|
destroy(): void;
|
|
39
39
|
};
|
|
40
40
|
declare function initBridge(appId: string, options: BridgeOptions): {
|
|
41
41
|
init(): void;
|
|
42
42
|
listen(handler: Listener): void;
|
|
43
|
-
emit(type: string, payload: any):
|
|
43
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
44
44
|
destroy(): void;
|
|
45
45
|
};
|
|
46
46
|
|
package/dist/index.d.ts
CHANGED
|
@@ -21,26 +21,26 @@ interface BridgeOptions {
|
|
|
21
21
|
declare function createBridge(appId: string, options: BridgeOptions): {
|
|
22
22
|
init(): void;
|
|
23
23
|
listen(handler: Listener): void;
|
|
24
|
-
emit(type: string, payload: any):
|
|
24
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
25
25
|
destroy(): void;
|
|
26
26
|
};
|
|
27
27
|
declare function resetBridge(): void;
|
|
28
28
|
declare function signalBridge(): {
|
|
29
29
|
init(): void;
|
|
30
30
|
listen(handler: Listener): void;
|
|
31
|
-
emit(type: string, payload: any):
|
|
31
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
32
32
|
destroy(): void;
|
|
33
33
|
};
|
|
34
34
|
declare function setupBridge(appId: string, options: BridgeOptions): {
|
|
35
35
|
init(): void;
|
|
36
36
|
listen(handler: Listener): void;
|
|
37
|
-
emit(type: string, payload: any):
|
|
37
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
38
38
|
destroy(): void;
|
|
39
39
|
};
|
|
40
40
|
declare function initBridge(appId: string, options: BridgeOptions): {
|
|
41
41
|
init(): void;
|
|
42
42
|
listen(handler: Listener): void;
|
|
43
|
-
emit(type: string, payload: any):
|
|
43
|
+
emit(type: string, payload: any, txn?: string): string;
|
|
44
44
|
destroy(): void;
|
|
45
45
|
};
|
|
46
46
|
|
package/dist/index.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var _signalBridgeLib = (() => {
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -51,39 +51,39 @@ var signalBridge = (() => {
|
|
|
51
51
|
}
|
|
52
52
|
})(exports, function() {
|
|
53
53
|
var CryptoJS2 = CryptoJS2 || (function(Math2, undefined2) {
|
|
54
|
-
var
|
|
54
|
+
var crypto2;
|
|
55
55
|
if (typeof window !== "undefined" && window.crypto) {
|
|
56
|
-
|
|
56
|
+
crypto2 = window.crypto;
|
|
57
57
|
}
|
|
58
58
|
if (typeof self !== "undefined" && self.crypto) {
|
|
59
|
-
|
|
59
|
+
crypto2 = self.crypto;
|
|
60
60
|
}
|
|
61
61
|
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
|
62
|
-
|
|
62
|
+
crypto2 = globalThis.crypto;
|
|
63
63
|
}
|
|
64
|
-
if (!
|
|
65
|
-
|
|
64
|
+
if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
|
|
65
|
+
crypto2 = window.msCrypto;
|
|
66
66
|
}
|
|
67
|
-
if (!
|
|
68
|
-
|
|
67
|
+
if (!crypto2 && typeof global !== "undefined" && global.crypto) {
|
|
68
|
+
crypto2 = global.crypto;
|
|
69
69
|
}
|
|
70
|
-
if (!
|
|
70
|
+
if (!crypto2 && typeof __require === "function") {
|
|
71
71
|
try {
|
|
72
|
-
|
|
72
|
+
crypto2 = __require("crypto");
|
|
73
73
|
} catch (err) {
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
var cryptoSecureRandomInt = function() {
|
|
77
|
-
if (
|
|
78
|
-
if (typeof
|
|
77
|
+
if (crypto2) {
|
|
78
|
+
if (typeof crypto2.getRandomValues === "function") {
|
|
79
79
|
try {
|
|
80
|
-
return
|
|
80
|
+
return crypto2.getRandomValues(new Uint32Array(1))[0];
|
|
81
81
|
} catch (err) {
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
if (typeof
|
|
84
|
+
if (typeof crypto2.randomBytes === "function") {
|
|
85
85
|
try {
|
|
86
|
-
return
|
|
86
|
+
return crypto2.randomBytes(4).readInt32LE();
|
|
87
87
|
} catch (err) {
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -6738,14 +6738,18 @@ var signalBridge = (() => {
|
|
|
6738
6738
|
window.addEventListener("message", messageHandler);
|
|
6739
6739
|
function emitToHost(type, payload, txn) {
|
|
6740
6740
|
let finalPayload = payload;
|
|
6741
|
+
const resolvedTxn = txn || crypto.randomUUID();
|
|
6741
6742
|
if (cryptoKey) {
|
|
6742
6743
|
finalPayload = encrypt(payload, cryptoKey);
|
|
6743
6744
|
}
|
|
6745
|
+
if (!txn) {
|
|
6746
|
+
finalPayload = encrypt(payload, resolvedTxn);
|
|
6747
|
+
}
|
|
6744
6748
|
const message = {
|
|
6745
6749
|
app_id: appId,
|
|
6746
6750
|
type,
|
|
6747
6751
|
payload: finalPayload,
|
|
6748
|
-
txn:
|
|
6752
|
+
txn: resolvedTxn,
|
|
6749
6753
|
__origin: window.location.origin,
|
|
6750
6754
|
__source: "remote"
|
|
6751
6755
|
};
|
|
@@ -6754,6 +6758,7 @@ var signalBridge = (() => {
|
|
|
6754
6758
|
window.parent.postMessage(message, origin);
|
|
6755
6759
|
});
|
|
6756
6760
|
}
|
|
6761
|
+
return resolvedTxn;
|
|
6757
6762
|
}
|
|
6758
6763
|
function emitReadyOnce() {
|
|
6759
6764
|
if (isInitialized) return;
|
|
@@ -6772,8 +6777,8 @@ var signalBridge = (() => {
|
|
|
6772
6777
|
listen(handler) {
|
|
6773
6778
|
listeners.push(handler);
|
|
6774
6779
|
},
|
|
6775
|
-
emit(type, payload) {
|
|
6776
|
-
emitToHost(type, payload);
|
|
6780
|
+
emit(type, payload, txn) {
|
|
6781
|
+
return emitToHost(type, payload, txn);
|
|
6777
6782
|
},
|
|
6778
6783
|
destroy() {
|
|
6779
6784
|
window.removeEventListener("message", messageHandler);
|