diff --git a/keyserver/addons/rust-node-addon/index.js b/keyserver/addons/rust-node-addon/index.js index 0827bcf82..eca3e1f82 100644 --- a/keyserver/addons/rust-node-addon/index.js +++ b/keyserver/addons/rust-node-addon/index.js @@ -1,39 +1,39 @@ // @flow import invariant from 'invariant'; import { createRequire } from 'module'; -import type { RustNativeBindingAPI } from 'lib/types/rust-binding-types.js'; +import type { RustNativeBindingAPI } from './rust-binding-types.js'; const { platform, arch } = process; const importMetaURL = import.meta.url; invariant(importMetaURL, 'import.meta.url should be set'); const require = createRequire(importMetaURL); async function getRustAPI(): Promise { let nativeBinding = null; if (platform === 'darwin' && arch === 'x64') { // $FlowFixMe nativeBinding = require('./napi/rust-node-addon.darwin-x64.node'); } else if (platform === 'darwin' && arch === 'arm64') { // $FlowFixMe nativeBinding = require('./napi/rust-node-addon.darwin-arm64.node'); } else if (platform === 'linux' && arch === 'x64') { // $FlowFixMe nativeBinding = require('./napi/rust-node-addon.linux-x64-gnu.node'); } else if (platform === 'linux' && arch === 'arm64') { // $FlowFixMe nativeBinding = require('./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 Rust native binding'); } return nativeBinding; } export { getRustAPI }; diff --git a/lib/types/rust-binding-types.js b/keyserver/addons/rust-node-addon/rust-binding-types.js similarity index 95% rename from lib/types/rust-binding-types.js rename to keyserver/addons/rust-node-addon/rust-binding-types.js index 367c6cc4b..fe0dfbf9d 100644 --- a/lib/types/rust-binding-types.js +++ b/keyserver/addons/rust-node-addon/rust-binding-types.js @@ -1,53 +1,53 @@ // @flow -import type { SignedIdentityKeysBlob } from './crypto-types.js'; +import type { SignedIdentityKeysBlob } from 'lib/types/crypto-types.js'; type tunnelbrokerOnReceiveCallback = ( err: Error | null, payload: string, ) => mixed; declare class TunnelbrokerClientClass { constructor( deviceId: string, onReceiveCallback: tunnelbrokerOnReceiveCallback, ): TunnelbrokerClientClass; publish(toDeviceId: string, payload: string): Promise; } type UserComparisonResult = { +usersMissingFromKeyserver: $ReadOnlyArray, +usersMissingFromIdentity: $ReadOnlyArray, }; type RustNativeBindingAPI = { +registerUser: ( userId: string, signingPublicKey: string, username: string, password: string, sessionInitializationInfo: SignedIdentityKeysBlob, ) => Promise, +loginUserPake: ( userId: string, signingPublicKey: string, password: string, sessionInitializationInfo: SignedIdentityKeysBlob, ) => Promise, +loginUserWallet: ( userId: string, signingPublicKey: string, siweMessage: string, siweSignature: string, sessionInitializationInfo: SignedIdentityKeysBlob, socialProof: string, ) => Promise, +deleteUser: (userId: string) => Promise, +updateUser: (userId: string, password: string) => Promise, +compareUsers: ( userIds: $ReadOnlyArray, ) => Promise, +TunnelbrokerClient: Class, }; export type { RustNativeBindingAPI };