Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3490940
D6690.id22410.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6690.id22410.diff
View Options
diff --git a/keyserver/addons/rust-node-addon/index.js b/keyserver/addons/rust-node-addon/index.js
--- a/keyserver/addons/rust-node-addon/index.js
+++ b/keyserver/addons/rust-node-addon/index.js
@@ -1,5 +1,7 @@
// @flow
+// import type { TunnelbrokerClientClass } from 'lib/types/tunnelbroker-types';
+
const { platform, arch } = process;
type IdentityAPI = {
@@ -34,8 +36,42 @@
throw new Error('Failed to load native binding');
}
- const { registerUser } = nativeBinding.default;
+ const { registerUser } = nativeBinding.registerUser;
return { registerUser };
}
-export { getIdentityRustAPI };
+export interface TunnelbrokerClientClass {
+ new(
+ onReceiveCallback: (err: Error | null, value: string) => any,
+ ): TunnelbrokerClientClass;
+ publish(toDeviceId: string, payload: string): Promise<void>;
+}
+
+async function getTunnelbrokerRustClient(): Promise<TunnelbrokerClientClass> {
+ let nativeBinding = null;
+ if (platform === 'darwin' && arch === 'x64') {
+ // $FlowFixMe
+ nativeBinding = await import('./naupi/rust-node-addon.darwin-x64.node');
+ } else if (platform === 'darwin' && arch === 'arm64') {
+ // $FlowFixMe
+ nativeBinding = await import('./napi/rust-node-addon.darwin-arm64.node');
+ } else if (platform === 'linux' && arch === 'x64') {
+ // $FlowFixMe
+ nativeBinding = await import('./napi/rust-node-addon.linux-x64-gnu.node');
+ } else if (platform === 'linux' && arch === 'arm64') {
+ // $FlowFixMe
+ nativeBinding = await import('./napi/rust-node-addon.linux-arm64-gnu.node');
+ } else {
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
+ }
+
+ if (!nativeBinding) {
+ throw new Error('Failed to load native binding');
+ }
+
+ const { TunnelbrokerClient } = nativeBinding.TunnelbrokerClient;
+ // $FlowFixMe
+ return { TunnelbrokerClient };
+}
+
+export { getIdentityRustAPI, getTunnelbrokerRustClient };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:59 PM (20 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678256
Default Alt Text
D6690.id22410.diff (1 KB)
Attached To
Mode
D6690: [keyserver] Unifying API interface and adding Tunnelbroker types
Attached
Detach File
Event Timeline
Log In to Comment