feat: allow VC sharing between Android and iOS

This commit is contained in:
Paolo Miguel de Leon
2022-08-05 16:20:41 +08:00
parent 5b5449020d
commit 61f895b6b6
15 changed files with 654 additions and 832 deletions

View File

@@ -1,62 +0,0 @@
import { EmitterSubscription } from 'react-native';
import { BluetoothState } from 'react-native-bluetooth-state-manager';
declare module '@idpass/smartshare-react-native' {
class IdpassSmartshare {
getConnectionParameters: () => string;
setConnectionParameters: (params: string) => void;
getConnectionParametersDebug: () => string;
createConnection: (mode: ConnectionMode, callback: () => void) => void;
destroyConnection: () => void;
send: (message: string, callback: () => void) => void;
handleNearbyEvents: (
callback: (event: NearbyEvent) => void
) => EmitterSubscription;
handleLogEvents: (
callback: (event: NearbyLog) => void
) => EmitterSubscription;
}
export type ConnectionMode = 'dual' | 'advertiser' | 'discoverer';
export type TransferUpdateStatus =
| 'SUCCESS'
| 'FAILURE'
| 'IN_PROGRESS'
| 'CANCELED';
export type NearbyEvent =
| { type: 'msg'; data: string }
| { type: 'transferupdate'; data: TransferUpdateStatus }
| { type: 'onDisconnected'; data: string };
export interface NearbyLog {
log: string;
}
export interface ConnectionParams {
// appId: string;
cid: string;
pk: string;
}
export = new IdpassSmartshare();
}
declare module 'react-native-bluetooth-state-manager' {
type StateChangeCallback = (state: BluetoothState) => void;
type StateChangeEmitter = Pick<EmitterSubscription, 'remove'>;
export function onStateChange(
callback: StateChangeCallback,
emitCurrentState: boolean
): StateChangeEmitter;
}

View File

@@ -0,0 +1,13 @@
import { EmitterSubscription } from 'react-native';
import { BluetoothState } from 'react-native-bluetooth-state-manager';
declare module 'react-native-bluetooth-state-manager' {
type StateChangeCallback = (state: BluetoothState) => void;
type StateChangeEmitter = Pick<EmitterSubscription, 'remove'>;
export function onStateChange(
callback: StateChangeCallback,
emitCurrentState: boolean
): StateChangeEmitter;
}