@cryptforge/key-exchange 0.1.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/README.md +108 -0
- package/dist/electron-main.d.mts +41 -0
- package/dist/electron-main.d.ts +41 -0
- package/dist/electron-main.js +806 -0
- package/dist/electron-main.mjs +768 -0
- package/dist/electron-preload.d.mts +3 -0
- package/dist/electron-preload.d.ts +3 -0
- package/dist/electron-preload.js +114 -0
- package/dist/electron-preload.mjs +87 -0
- package/dist/electron-renderer.d.mts +74 -0
- package/dist/electron-renderer.d.ts +74 -0
- package/dist/electron-renderer.js +108 -0
- package/dist/electron-renderer.mjs +80 -0
- package/dist/index.d.mts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +586 -0
- package/dist/index.mjs +572 -0
- package/dist/server.d.mts +46 -0
- package/dist/server.d.ts +46 -0
- package/dist/server.js +940 -0
- package/dist/server.mjs +902 -0
- package/package.json +93 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/electron-preload.ts
|
|
21
|
+
var electron_preload_exports = {};
|
|
22
|
+
__export(electron_preload_exports, {
|
|
23
|
+
setupKeyExchangePreloadAPI: () => setupKeyExchangePreloadAPI
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(electron_preload_exports);
|
|
26
|
+
|
|
27
|
+
// src/electron/preload/setupExchangePreload.ts
|
|
28
|
+
var import_electron = require("electron");
|
|
29
|
+
|
|
30
|
+
// src/types/messages.ts
|
|
31
|
+
var MESSAGES = {
|
|
32
|
+
enableBroadcast: "admin:broadcast:enable",
|
|
33
|
+
connect: "client:topic:connect",
|
|
34
|
+
onClientConnection: "admin:topic:connected",
|
|
35
|
+
requestKeystore: "client:keystore:request",
|
|
36
|
+
onKeystoreRequestInvalidPIN: "admin:pin:invalid",
|
|
37
|
+
onKeystoreRequestValidPIN: "admin:pin:valid",
|
|
38
|
+
onKeystoreRequest: "admin:request:received",
|
|
39
|
+
approveRequest: "admin:request:approve",
|
|
40
|
+
onClientApproval: "client:request:approved",
|
|
41
|
+
denyRequest: "admin:request:deny",
|
|
42
|
+
onClientDenial: "client:request:denied",
|
|
43
|
+
onCompletion: "server:link:complete",
|
|
44
|
+
disableBroadcast: "admin:broadcast:disable",
|
|
45
|
+
onBroadcastDisable: "client:broadcast:disabled",
|
|
46
|
+
getDeviceInfo: "client:request:deviceInfo",
|
|
47
|
+
getHostname: "client:request:hostname",
|
|
48
|
+
// Presence/Network messages
|
|
49
|
+
connectPresence: "network:connect",
|
|
50
|
+
broadcastClientState: "network:broadcast",
|
|
51
|
+
onClientStateRequest: "network:request",
|
|
52
|
+
onClientStateUpdate: "network:update"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/electron/preload/setupExchangePreload.ts
|
|
56
|
+
var setupKeyExchangePreloadAPI = () => {
|
|
57
|
+
import_electron.contextBridge.exposeInMainWorld("keyExchangeElectronAPI", {
|
|
58
|
+
// sync setup
|
|
59
|
+
enableBroadcast: () => import_electron.ipcRenderer.invoke(MESSAGES.enableBroadcast),
|
|
60
|
+
connect: (topic, name, app) => import_electron.ipcRenderer.invoke(MESSAGES.connect, topic, name, app),
|
|
61
|
+
onClientConnection: (callback) => import_electron.ipcRenderer.on(
|
|
62
|
+
MESSAGES.onClientConnection,
|
|
63
|
+
(_event, response) => callback(response)
|
|
64
|
+
),
|
|
65
|
+
requestKeystore: (pin) => import_electron.ipcRenderer.invoke(MESSAGES.requestKeystore, pin),
|
|
66
|
+
onKeystoreRequestInvalidPIN: (callback) => import_electron.ipcRenderer.on(
|
|
67
|
+
MESSAGES.onKeystoreRequestInvalidPIN,
|
|
68
|
+
(_event, response) => callback(response)
|
|
69
|
+
),
|
|
70
|
+
onKeystoreRequestValidPIN: (callback) => import_electron.ipcRenderer.on(
|
|
71
|
+
MESSAGES.onKeystoreRequestValidPIN,
|
|
72
|
+
(_event, response) => callback(response)
|
|
73
|
+
),
|
|
74
|
+
onKeystoreRequest: (callback) => import_electron.ipcRenderer.on(
|
|
75
|
+
MESSAGES.onKeystoreRequest,
|
|
76
|
+
(_event, response) => callback(response)
|
|
77
|
+
),
|
|
78
|
+
approveRequest: (data) => import_electron.ipcRenderer.invoke(MESSAGES.approveRequest, data),
|
|
79
|
+
onClientApproval: (callback) => import_electron.ipcRenderer.on(
|
|
80
|
+
MESSAGES.onClientApproval,
|
|
81
|
+
(_event, response) => callback(response)
|
|
82
|
+
),
|
|
83
|
+
denyRequest: () => import_electron.ipcRenderer.invoke(MESSAGES.denyRequest),
|
|
84
|
+
onClientDenial: (callback) => import_electron.ipcRenderer.on(
|
|
85
|
+
MESSAGES.onClientDenial,
|
|
86
|
+
(_event, response) => callback(response)
|
|
87
|
+
),
|
|
88
|
+
onCompletion: (callback) => import_electron.ipcRenderer.on(
|
|
89
|
+
MESSAGES.onCompletion,
|
|
90
|
+
(_event, response) => callback(response)
|
|
91
|
+
),
|
|
92
|
+
disableBroadcast: () => import_electron.ipcRenderer.invoke(MESSAGES.disableBroadcast),
|
|
93
|
+
onBroadcastDisable: (callback) => import_electron.ipcRenderer.on(
|
|
94
|
+
MESSAGES.onBroadcastDisable,
|
|
95
|
+
(_event, response) => callback(response)
|
|
96
|
+
),
|
|
97
|
+
getDeviceInfo: () => import_electron.ipcRenderer.invoke(MESSAGES.getDeviceInfo),
|
|
98
|
+
getHostname: () => import_electron.ipcRenderer.invoke(MESSAGES.getHostname),
|
|
99
|
+
connectPresence: (topic) => import_electron.ipcRenderer.invoke(MESSAGES.connectPresence, topic),
|
|
100
|
+
broadcastClientState: (id, state) => import_electron.ipcRenderer.invoke(MESSAGES.broadcastClientState, id, state),
|
|
101
|
+
onClientStateRequest: (callback) => import_electron.ipcRenderer.on(
|
|
102
|
+
MESSAGES.onClientStateRequest,
|
|
103
|
+
(_event) => callback()
|
|
104
|
+
),
|
|
105
|
+
onClientStateUpdate: (callback) => import_electron.ipcRenderer.on(
|
|
106
|
+
MESSAGES.onClientStateUpdate,
|
|
107
|
+
(_event, response) => callback(response)
|
|
108
|
+
)
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
setupKeyExchangePreloadAPI
|
|
114
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/electron/preload/setupExchangePreload.ts
|
|
2
|
+
import { ipcRenderer, contextBridge } from "electron";
|
|
3
|
+
|
|
4
|
+
// src/types/messages.ts
|
|
5
|
+
var MESSAGES = {
|
|
6
|
+
enableBroadcast: "admin:broadcast:enable",
|
|
7
|
+
connect: "client:topic:connect",
|
|
8
|
+
onClientConnection: "admin:topic:connected",
|
|
9
|
+
requestKeystore: "client:keystore:request",
|
|
10
|
+
onKeystoreRequestInvalidPIN: "admin:pin:invalid",
|
|
11
|
+
onKeystoreRequestValidPIN: "admin:pin:valid",
|
|
12
|
+
onKeystoreRequest: "admin:request:received",
|
|
13
|
+
approveRequest: "admin:request:approve",
|
|
14
|
+
onClientApproval: "client:request:approved",
|
|
15
|
+
denyRequest: "admin:request:deny",
|
|
16
|
+
onClientDenial: "client:request:denied",
|
|
17
|
+
onCompletion: "server:link:complete",
|
|
18
|
+
disableBroadcast: "admin:broadcast:disable",
|
|
19
|
+
onBroadcastDisable: "client:broadcast:disabled",
|
|
20
|
+
getDeviceInfo: "client:request:deviceInfo",
|
|
21
|
+
getHostname: "client:request:hostname",
|
|
22
|
+
// Presence/Network messages
|
|
23
|
+
connectPresence: "network:connect",
|
|
24
|
+
broadcastClientState: "network:broadcast",
|
|
25
|
+
onClientStateRequest: "network:request",
|
|
26
|
+
onClientStateUpdate: "network:update"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// src/electron/preload/setupExchangePreload.ts
|
|
30
|
+
var setupKeyExchangePreloadAPI = () => {
|
|
31
|
+
contextBridge.exposeInMainWorld("keyExchangeElectronAPI", {
|
|
32
|
+
// sync setup
|
|
33
|
+
enableBroadcast: () => ipcRenderer.invoke(MESSAGES.enableBroadcast),
|
|
34
|
+
connect: (topic, name, app) => ipcRenderer.invoke(MESSAGES.connect, topic, name, app),
|
|
35
|
+
onClientConnection: (callback) => ipcRenderer.on(
|
|
36
|
+
MESSAGES.onClientConnection,
|
|
37
|
+
(_event, response) => callback(response)
|
|
38
|
+
),
|
|
39
|
+
requestKeystore: (pin) => ipcRenderer.invoke(MESSAGES.requestKeystore, pin),
|
|
40
|
+
onKeystoreRequestInvalidPIN: (callback) => ipcRenderer.on(
|
|
41
|
+
MESSAGES.onKeystoreRequestInvalidPIN,
|
|
42
|
+
(_event, response) => callback(response)
|
|
43
|
+
),
|
|
44
|
+
onKeystoreRequestValidPIN: (callback) => ipcRenderer.on(
|
|
45
|
+
MESSAGES.onKeystoreRequestValidPIN,
|
|
46
|
+
(_event, response) => callback(response)
|
|
47
|
+
),
|
|
48
|
+
onKeystoreRequest: (callback) => ipcRenderer.on(
|
|
49
|
+
MESSAGES.onKeystoreRequest,
|
|
50
|
+
(_event, response) => callback(response)
|
|
51
|
+
),
|
|
52
|
+
approveRequest: (data) => ipcRenderer.invoke(MESSAGES.approveRequest, data),
|
|
53
|
+
onClientApproval: (callback) => ipcRenderer.on(
|
|
54
|
+
MESSAGES.onClientApproval,
|
|
55
|
+
(_event, response) => callback(response)
|
|
56
|
+
),
|
|
57
|
+
denyRequest: () => ipcRenderer.invoke(MESSAGES.denyRequest),
|
|
58
|
+
onClientDenial: (callback) => ipcRenderer.on(
|
|
59
|
+
MESSAGES.onClientDenial,
|
|
60
|
+
(_event, response) => callback(response)
|
|
61
|
+
),
|
|
62
|
+
onCompletion: (callback) => ipcRenderer.on(
|
|
63
|
+
MESSAGES.onCompletion,
|
|
64
|
+
(_event, response) => callback(response)
|
|
65
|
+
),
|
|
66
|
+
disableBroadcast: () => ipcRenderer.invoke(MESSAGES.disableBroadcast),
|
|
67
|
+
onBroadcastDisable: (callback) => ipcRenderer.on(
|
|
68
|
+
MESSAGES.onBroadcastDisable,
|
|
69
|
+
(_event, response) => callback(response)
|
|
70
|
+
),
|
|
71
|
+
getDeviceInfo: () => ipcRenderer.invoke(MESSAGES.getDeviceInfo),
|
|
72
|
+
getHostname: () => ipcRenderer.invoke(MESSAGES.getHostname),
|
|
73
|
+
connectPresence: (topic) => ipcRenderer.invoke(MESSAGES.connectPresence, topic),
|
|
74
|
+
broadcastClientState: (id, state) => ipcRenderer.invoke(MESSAGES.broadcastClientState, id, state),
|
|
75
|
+
onClientStateRequest: (callback) => ipcRenderer.on(
|
|
76
|
+
MESSAGES.onClientStateRequest,
|
|
77
|
+
(_event) => callback()
|
|
78
|
+
),
|
|
79
|
+
onClientStateUpdate: (callback) => ipcRenderer.on(
|
|
80
|
+
MESSAGES.onClientStateUpdate,
|
|
81
|
+
(_event, response) => callback(response)
|
|
82
|
+
)
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
setupKeyExchangePreloadAPI
|
|
87
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { StoredIdentity, ClientConnectionState, KeyTransportAdapter } from '@cryptforge/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type definitions for Electron key exchange API
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
interface KeyExchangeElectronAPI {
|
|
8
|
+
enableBroadcast: () => Promise<string>;
|
|
9
|
+
connect: (topic: string, name: string, app: string) => Promise<void>;
|
|
10
|
+
onClientConnection: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
11
|
+
requestKeystore: (pin: string) => Promise<void>;
|
|
12
|
+
onKeystoreRequestInvalidPIN: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
13
|
+
onKeystoreRequestValidPIN: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
14
|
+
onKeystoreRequest: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
15
|
+
approveRequest: (data: {
|
|
16
|
+
identity: StoredIdentity;
|
|
17
|
+
appId: number;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
onClientApproval: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
20
|
+
denyRequest: () => Promise<void>;
|
|
21
|
+
onClientDenial: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
22
|
+
onCompletion: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
23
|
+
disableBroadcast: () => Promise<void>;
|
|
24
|
+
onBroadcastDisable: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
25
|
+
getDeviceInfo: () => Promise<Record<string, any>>;
|
|
26
|
+
getHostname: () => Promise<string>;
|
|
27
|
+
connectPresence: (topic: string) => Promise<void>;
|
|
28
|
+
broadcastClientState: (id: string, state: ClientConnectionState) => Promise<void>;
|
|
29
|
+
onClientStateRequest: (callback: () => void) => Promise<() => void>;
|
|
30
|
+
onClientStateUpdate: (callback: (response: {
|
|
31
|
+
id: string;
|
|
32
|
+
state: ClientConnectionState;
|
|
33
|
+
}) => void) => Promise<() => void>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare global {
|
|
37
|
+
interface Window {
|
|
38
|
+
keyExchangeElectronAPI: KeyExchangeElectronAPI;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
declare class KeyTransportRenderer implements KeyTransportAdapter {
|
|
42
|
+
private peers;
|
|
43
|
+
constructor();
|
|
44
|
+
enableBroadcast: () => Promise<string>;
|
|
45
|
+
connect: (_topic: string, _name: string, _app: string) => Promise<void>;
|
|
46
|
+
onClientConnection: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
47
|
+
requestKeystore: (_pin: string) => Promise<void>;
|
|
48
|
+
onKeystoreRequestInvalidPIN: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
49
|
+
onKeystoreRequestValidPIN: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
50
|
+
onKeystoreRequest: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
51
|
+
approveRequest: (data: {
|
|
52
|
+
identity: StoredIdentity;
|
|
53
|
+
appId: number;
|
|
54
|
+
}) => Promise<void>;
|
|
55
|
+
onClientApproval: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
56
|
+
denyRequest: () => Promise<void>;
|
|
57
|
+
onClientDenial: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
58
|
+
onCompletion: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
59
|
+
disableBroadcast: () => Promise<void>;
|
|
60
|
+
onBroadcastDisable: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
61
|
+
getDeviceInfo: () => Promise<Record<string, any>>;
|
|
62
|
+
getHostname: () => Promise<string>;
|
|
63
|
+
connectPresence: (topic: string) => Promise<void>;
|
|
64
|
+
broadcastClientState: (id: string, state: ClientConnectionState) => Promise<void>;
|
|
65
|
+
onClientStateRequest: (callback: () => void) => Promise<() => void>;
|
|
66
|
+
onClientStateUpdate: (callback: (response: {
|
|
67
|
+
id: string;
|
|
68
|
+
state: ClientConnectionState;
|
|
69
|
+
}) => void) => Promise<() => void>;
|
|
70
|
+
getPeerState: (id: string) => ClientConnectionState | undefined;
|
|
71
|
+
getAllPeers: () => ReadonlyMap<string, ClientConnectionState>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { KeyTransportRenderer as ElectronKeyTransport, type KeyExchangeElectronAPI, KeyTransportRenderer };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { StoredIdentity, ClientConnectionState, KeyTransportAdapter } from '@cryptforge/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type definitions for Electron key exchange API
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
interface KeyExchangeElectronAPI {
|
|
8
|
+
enableBroadcast: () => Promise<string>;
|
|
9
|
+
connect: (topic: string, name: string, app: string) => Promise<void>;
|
|
10
|
+
onClientConnection: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
11
|
+
requestKeystore: (pin: string) => Promise<void>;
|
|
12
|
+
onKeystoreRequestInvalidPIN: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
13
|
+
onKeystoreRequestValidPIN: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
14
|
+
onKeystoreRequest: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
15
|
+
approveRequest: (data: {
|
|
16
|
+
identity: StoredIdentity;
|
|
17
|
+
appId: number;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
onClientApproval: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
20
|
+
denyRequest: () => Promise<void>;
|
|
21
|
+
onClientDenial: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
22
|
+
onCompletion: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
23
|
+
disableBroadcast: () => Promise<void>;
|
|
24
|
+
onBroadcastDisable: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
25
|
+
getDeviceInfo: () => Promise<Record<string, any>>;
|
|
26
|
+
getHostname: () => Promise<string>;
|
|
27
|
+
connectPresence: (topic: string) => Promise<void>;
|
|
28
|
+
broadcastClientState: (id: string, state: ClientConnectionState) => Promise<void>;
|
|
29
|
+
onClientStateRequest: (callback: () => void) => Promise<() => void>;
|
|
30
|
+
onClientStateUpdate: (callback: (response: {
|
|
31
|
+
id: string;
|
|
32
|
+
state: ClientConnectionState;
|
|
33
|
+
}) => void) => Promise<() => void>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare global {
|
|
37
|
+
interface Window {
|
|
38
|
+
keyExchangeElectronAPI: KeyExchangeElectronAPI;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
declare class KeyTransportRenderer implements KeyTransportAdapter {
|
|
42
|
+
private peers;
|
|
43
|
+
constructor();
|
|
44
|
+
enableBroadcast: () => Promise<string>;
|
|
45
|
+
connect: (_topic: string, _name: string, _app: string) => Promise<void>;
|
|
46
|
+
onClientConnection: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
47
|
+
requestKeystore: (_pin: string) => Promise<void>;
|
|
48
|
+
onKeystoreRequestInvalidPIN: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
49
|
+
onKeystoreRequestValidPIN: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
50
|
+
onKeystoreRequest: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
51
|
+
approveRequest: (data: {
|
|
52
|
+
identity: StoredIdentity;
|
|
53
|
+
appId: number;
|
|
54
|
+
}) => Promise<void>;
|
|
55
|
+
onClientApproval: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
56
|
+
denyRequest: () => Promise<void>;
|
|
57
|
+
onClientDenial: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
58
|
+
onCompletion: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
59
|
+
disableBroadcast: () => Promise<void>;
|
|
60
|
+
onBroadcastDisable: (_callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
61
|
+
getDeviceInfo: () => Promise<Record<string, any>>;
|
|
62
|
+
getHostname: () => Promise<string>;
|
|
63
|
+
connectPresence: (topic: string) => Promise<void>;
|
|
64
|
+
broadcastClientState: (id: string, state: ClientConnectionState) => Promise<void>;
|
|
65
|
+
onClientStateRequest: (callback: () => void) => Promise<() => void>;
|
|
66
|
+
onClientStateUpdate: (callback: (response: {
|
|
67
|
+
id: string;
|
|
68
|
+
state: ClientConnectionState;
|
|
69
|
+
}) => void) => Promise<() => void>;
|
|
70
|
+
getPeerState: (id: string) => ClientConnectionState | undefined;
|
|
71
|
+
getAllPeers: () => ReadonlyMap<string, ClientConnectionState>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { KeyTransportRenderer as ElectronKeyTransport, type KeyExchangeElectronAPI, KeyTransportRenderer };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/electron-renderer.ts
|
|
21
|
+
var electron_renderer_exports = {};
|
|
22
|
+
__export(electron_renderer_exports, {
|
|
23
|
+
ElectronKeyTransport: () => KeyTransportRenderer,
|
|
24
|
+
KeyTransportRenderer: () => KeyTransportRenderer
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(electron_renderer_exports);
|
|
27
|
+
|
|
28
|
+
// src/electron/renderer/keyTransportRenderer.ts
|
|
29
|
+
var KeyTransportRenderer = class {
|
|
30
|
+
peers = /* @__PURE__ */ new Map();
|
|
31
|
+
constructor() {
|
|
32
|
+
}
|
|
33
|
+
enableBroadcast = async () => {
|
|
34
|
+
return window.keyExchangeElectronAPI.enableBroadcast();
|
|
35
|
+
};
|
|
36
|
+
connect = async (_topic, _name, _app) => {
|
|
37
|
+
return window.keyExchangeElectronAPI.connect(_topic, _name, _app);
|
|
38
|
+
};
|
|
39
|
+
onClientConnection = async (_callback) => {
|
|
40
|
+
return window.keyExchangeElectronAPI.onClientConnection(_callback);
|
|
41
|
+
};
|
|
42
|
+
requestKeystore = async (_pin) => {
|
|
43
|
+
return window.keyExchangeElectronAPI.requestKeystore(_pin);
|
|
44
|
+
};
|
|
45
|
+
onKeystoreRequestInvalidPIN = async (_callback) => {
|
|
46
|
+
return window.keyExchangeElectronAPI.onKeystoreRequestInvalidPIN(_callback);
|
|
47
|
+
};
|
|
48
|
+
onKeystoreRequestValidPIN = async (_callback) => {
|
|
49
|
+
return window.keyExchangeElectronAPI.onKeystoreRequestValidPIN(_callback);
|
|
50
|
+
};
|
|
51
|
+
onKeystoreRequest = async (_callback) => {
|
|
52
|
+
return window.keyExchangeElectronAPI.onKeystoreRequest(_callback);
|
|
53
|
+
};
|
|
54
|
+
approveRequest = async (data) => {
|
|
55
|
+
return window.keyExchangeElectronAPI.approveRequest(data);
|
|
56
|
+
};
|
|
57
|
+
onClientApproval = async (_callback) => {
|
|
58
|
+
return window.keyExchangeElectronAPI.onClientApproval(_callback);
|
|
59
|
+
};
|
|
60
|
+
denyRequest = async () => {
|
|
61
|
+
return window.keyExchangeElectronAPI.denyRequest();
|
|
62
|
+
};
|
|
63
|
+
onClientDenial = async (_callback) => {
|
|
64
|
+
return window.keyExchangeElectronAPI.onClientDenial(_callback);
|
|
65
|
+
};
|
|
66
|
+
onCompletion = async (_callback) => {
|
|
67
|
+
return window.keyExchangeElectronAPI.onCompletion(_callback);
|
|
68
|
+
};
|
|
69
|
+
disableBroadcast = async () => {
|
|
70
|
+
return window.keyExchangeElectronAPI.disableBroadcast();
|
|
71
|
+
};
|
|
72
|
+
onBroadcastDisable = async (_callback) => {
|
|
73
|
+
return window.keyExchangeElectronAPI.onBroadcastDisable(_callback);
|
|
74
|
+
};
|
|
75
|
+
getDeviceInfo = async () => {
|
|
76
|
+
return window.keyExchangeElectronAPI.getDeviceInfo();
|
|
77
|
+
};
|
|
78
|
+
getHostname = async () => {
|
|
79
|
+
return window.keyExchangeElectronAPI.getHostname();
|
|
80
|
+
};
|
|
81
|
+
connectPresence = async (topic) => {
|
|
82
|
+
return window.keyExchangeElectronAPI.connectPresence(topic);
|
|
83
|
+
};
|
|
84
|
+
broadcastClientState = async (id, state) => {
|
|
85
|
+
return window.keyExchangeElectronAPI.broadcastClientState(id, state);
|
|
86
|
+
};
|
|
87
|
+
onClientStateRequest = async (callback) => {
|
|
88
|
+
return window.keyExchangeElectronAPI.onClientStateRequest(callback);
|
|
89
|
+
};
|
|
90
|
+
onClientStateUpdate = async (callback) => {
|
|
91
|
+
const wrappedCallback = (response) => {
|
|
92
|
+
this.peers.set(response.id, response.state);
|
|
93
|
+
callback(response);
|
|
94
|
+
};
|
|
95
|
+
return window.keyExchangeElectronAPI.onClientStateUpdate(wrappedCallback);
|
|
96
|
+
};
|
|
97
|
+
getPeerState = (id) => {
|
|
98
|
+
return this.peers.get(id);
|
|
99
|
+
};
|
|
100
|
+
getAllPeers = () => {
|
|
101
|
+
return this.peers;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
ElectronKeyTransport,
|
|
107
|
+
KeyTransportRenderer
|
|
108
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/electron/renderer/keyTransportRenderer.ts
|
|
2
|
+
var KeyTransportRenderer = class {
|
|
3
|
+
peers = /* @__PURE__ */ new Map();
|
|
4
|
+
constructor() {
|
|
5
|
+
}
|
|
6
|
+
enableBroadcast = async () => {
|
|
7
|
+
return window.keyExchangeElectronAPI.enableBroadcast();
|
|
8
|
+
};
|
|
9
|
+
connect = async (_topic, _name, _app) => {
|
|
10
|
+
return window.keyExchangeElectronAPI.connect(_topic, _name, _app);
|
|
11
|
+
};
|
|
12
|
+
onClientConnection = async (_callback) => {
|
|
13
|
+
return window.keyExchangeElectronAPI.onClientConnection(_callback);
|
|
14
|
+
};
|
|
15
|
+
requestKeystore = async (_pin) => {
|
|
16
|
+
return window.keyExchangeElectronAPI.requestKeystore(_pin);
|
|
17
|
+
};
|
|
18
|
+
onKeystoreRequestInvalidPIN = async (_callback) => {
|
|
19
|
+
return window.keyExchangeElectronAPI.onKeystoreRequestInvalidPIN(_callback);
|
|
20
|
+
};
|
|
21
|
+
onKeystoreRequestValidPIN = async (_callback) => {
|
|
22
|
+
return window.keyExchangeElectronAPI.onKeystoreRequestValidPIN(_callback);
|
|
23
|
+
};
|
|
24
|
+
onKeystoreRequest = async (_callback) => {
|
|
25
|
+
return window.keyExchangeElectronAPI.onKeystoreRequest(_callback);
|
|
26
|
+
};
|
|
27
|
+
approveRequest = async (data) => {
|
|
28
|
+
return window.keyExchangeElectronAPI.approveRequest(data);
|
|
29
|
+
};
|
|
30
|
+
onClientApproval = async (_callback) => {
|
|
31
|
+
return window.keyExchangeElectronAPI.onClientApproval(_callback);
|
|
32
|
+
};
|
|
33
|
+
denyRequest = async () => {
|
|
34
|
+
return window.keyExchangeElectronAPI.denyRequest();
|
|
35
|
+
};
|
|
36
|
+
onClientDenial = async (_callback) => {
|
|
37
|
+
return window.keyExchangeElectronAPI.onClientDenial(_callback);
|
|
38
|
+
};
|
|
39
|
+
onCompletion = async (_callback) => {
|
|
40
|
+
return window.keyExchangeElectronAPI.onCompletion(_callback);
|
|
41
|
+
};
|
|
42
|
+
disableBroadcast = async () => {
|
|
43
|
+
return window.keyExchangeElectronAPI.disableBroadcast();
|
|
44
|
+
};
|
|
45
|
+
onBroadcastDisable = async (_callback) => {
|
|
46
|
+
return window.keyExchangeElectronAPI.onBroadcastDisable(_callback);
|
|
47
|
+
};
|
|
48
|
+
getDeviceInfo = async () => {
|
|
49
|
+
return window.keyExchangeElectronAPI.getDeviceInfo();
|
|
50
|
+
};
|
|
51
|
+
getHostname = async () => {
|
|
52
|
+
return window.keyExchangeElectronAPI.getHostname();
|
|
53
|
+
};
|
|
54
|
+
connectPresence = async (topic) => {
|
|
55
|
+
return window.keyExchangeElectronAPI.connectPresence(topic);
|
|
56
|
+
};
|
|
57
|
+
broadcastClientState = async (id, state) => {
|
|
58
|
+
return window.keyExchangeElectronAPI.broadcastClientState(id, state);
|
|
59
|
+
};
|
|
60
|
+
onClientStateRequest = async (callback) => {
|
|
61
|
+
return window.keyExchangeElectronAPI.onClientStateRequest(callback);
|
|
62
|
+
};
|
|
63
|
+
onClientStateUpdate = async (callback) => {
|
|
64
|
+
const wrappedCallback = (response) => {
|
|
65
|
+
this.peers.set(response.id, response.state);
|
|
66
|
+
callback(response);
|
|
67
|
+
};
|
|
68
|
+
return window.keyExchangeElectronAPI.onClientStateUpdate(wrappedCallback);
|
|
69
|
+
};
|
|
70
|
+
getPeerState = (id) => {
|
|
71
|
+
return this.peers.get(id);
|
|
72
|
+
};
|
|
73
|
+
getAllPeers = () => {
|
|
74
|
+
return this.peers;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
KeyTransportRenderer as ElectronKeyTransport,
|
|
79
|
+
KeyTransportRenderer
|
|
80
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { KeyTransportAdapter, StoredIdentity, ClientConnectionState } from '@cryptforge/core';
|
|
2
|
+
|
|
3
|
+
declare class KeyTransportClient implements KeyTransportAdapter {
|
|
4
|
+
private emitter;
|
|
5
|
+
private ws;
|
|
6
|
+
private serverUrl;
|
|
7
|
+
private pendingRequests;
|
|
8
|
+
private requestTimeout;
|
|
9
|
+
private requestCounter;
|
|
10
|
+
private connectionPromise;
|
|
11
|
+
private connectionResolver;
|
|
12
|
+
private peers;
|
|
13
|
+
constructor(serverUrl?: string);
|
|
14
|
+
private connectWebSocket;
|
|
15
|
+
private generateRequestId;
|
|
16
|
+
private handleRequestResponse;
|
|
17
|
+
private rejectAllPendingRequests;
|
|
18
|
+
/**
|
|
19
|
+
* Send a request and wait for response
|
|
20
|
+
*/
|
|
21
|
+
private sendRequest;
|
|
22
|
+
private receiveMessage;
|
|
23
|
+
enableBroadcast: () => Promise<string>;
|
|
24
|
+
connect: (topic: string, name: string, app: string) => Promise<void>;
|
|
25
|
+
requestKeystore: (pin: string) => Promise<void>;
|
|
26
|
+
approveRequest: (data: {
|
|
27
|
+
identity: StoredIdentity;
|
|
28
|
+
appId: number;
|
|
29
|
+
}) => Promise<void>;
|
|
30
|
+
denyRequest: () => Promise<void>;
|
|
31
|
+
disableBroadcast: () => Promise<void>;
|
|
32
|
+
onClientConnection: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
33
|
+
onKeystoreRequestInvalidPIN: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
34
|
+
onKeystoreRequestValidPIN: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
35
|
+
onKeystoreRequest: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
36
|
+
onClientApproval: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
37
|
+
onClientDenial: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
38
|
+
onCompletion: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
39
|
+
onBroadcastDisable: (callback: (response: Record<string, any>) => void) => Promise<() => void>;
|
|
40
|
+
getDeviceInfo: () => Promise<Record<string, any>>;
|
|
41
|
+
getHostname: () => Promise<string>;
|
|
42
|
+
connectPresence: (topic: string) => Promise<void>;
|
|
43
|
+
broadcastClientState: (id: string, state: ClientConnectionState) => Promise<void>;
|
|
44
|
+
onClientStateRequest: (callback: () => void) => Promise<() => void>;
|
|
45
|
+
onClientStateUpdate: (callback: (response: {
|
|
46
|
+
id: string;
|
|
47
|
+
state: ClientConnectionState;
|
|
48
|
+
}) => void) => Promise<() => void>;
|
|
49
|
+
getPeerState: (id: string) => ClientConnectionState | undefined;
|
|
50
|
+
getAllPeers: () => ReadonlyMap<string, ClientConnectionState>;
|
|
51
|
+
/**
|
|
52
|
+
* Reconnect to the WebSocket server
|
|
53
|
+
*/
|
|
54
|
+
reconnect: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Close the WebSocket connection
|
|
57
|
+
*/
|
|
58
|
+
disconnect: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Check if WebSocket is connected
|
|
61
|
+
*/
|
|
62
|
+
isConnected: () => boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { KeyTransportClient };
|