@icanbwell/types 0.33.1 → 0.34.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/package.json +10 -2
- package/src/native-bridge.d.ts +43 -0
- package/src/native-components.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icanbwell/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"typedoc": {
|
|
5
5
|
"entryPoint": "./src/index.ts",
|
|
6
6
|
"tsconfig": "./tsconfig.lib.json"
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"*": {
|
|
10
10
|
"native-components": [
|
|
11
11
|
"src/native-components.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"native-bridge": [
|
|
14
|
+
"src/native-bridge.d.ts"
|
|
12
15
|
]
|
|
13
16
|
}
|
|
14
17
|
},
|
|
@@ -17,6 +20,10 @@
|
|
|
17
20
|
"types": "./src/native-components.d.ts",
|
|
18
21
|
"import": "./native-components.js"
|
|
19
22
|
},
|
|
23
|
+
"./native-bridge": {
|
|
24
|
+
"types": "./src/native-bridge.d.ts",
|
|
25
|
+
"import": "./native-bridge.js"
|
|
26
|
+
},
|
|
20
27
|
".": {
|
|
21
28
|
"types": "./src/index.d.ts",
|
|
22
29
|
"import": "./index.js"
|
|
@@ -27,7 +34,8 @@
|
|
|
27
34
|
"type": "module",
|
|
28
35
|
"types": "./src/index.d.ts",
|
|
29
36
|
"dependencies": {
|
|
30
|
-
"apollo-link-rest": "0.9.0"
|
|
37
|
+
"apollo-link-rest": "0.9.0",
|
|
38
|
+
"react-native-biometrics": "3.0.1"
|
|
31
39
|
},
|
|
32
40
|
"peerDependencies": {}
|
|
33
41
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type rnBiometrics from 'react-native-biometrics';
|
|
2
|
+
import type TypedEmitter from 'typed-emitter';
|
|
3
|
+
import { OnAuthSuccessEventKey, type OnAuthSuccessEventData } from './native-components';
|
|
4
|
+
export type NativeEvents<T = any> = {
|
|
5
|
+
openwebview: (url: string) => void;
|
|
6
|
+
closewebview: (data: T) => void;
|
|
7
|
+
reloadwebview: () => void;
|
|
8
|
+
[OnAuthSuccessEventKey]: (data: OnAuthSuccessEventData) => void;
|
|
9
|
+
};
|
|
10
|
+
export type NativeBridgeEmittableEvents = Pick<NativeEvents, 'onauthsuccess'>;
|
|
11
|
+
export type NativeEventEmitter = TypedEmitter<NativeEvents>;
|
|
12
|
+
export type NativeEmittableEventEmitter = TypedEmitter<NativeBridgeEmittableEvents>;
|
|
13
|
+
type InvokedReturnType<T> = Promise<Awaited<T>>;
|
|
14
|
+
type InvokedWrappedMethod<T extends (...args: any[]) => any> = (...args: Parameters<T>) => InvokedReturnType<ReturnType<T>>;
|
|
15
|
+
export interface IWebview {
|
|
16
|
+
open(url: string): void;
|
|
17
|
+
close<T>(data: T): void;
|
|
18
|
+
reload(): void;
|
|
19
|
+
isWithin: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface IBiometrics {
|
|
22
|
+
isAvailable(): Promise<boolean>;
|
|
23
|
+
biometricKeysExist: InvokedWrappedMethod<rnBiometrics['biometricKeysExist']>;
|
|
24
|
+
createKeys: InvokedWrappedMethod<rnBiometrics['createKeys']>;
|
|
25
|
+
createSignature: InvokedWrappedMethod<rnBiometrics['createSignature']>;
|
|
26
|
+
deleteKeys: InvokedWrappedMethod<rnBiometrics['deleteKeys']>;
|
|
27
|
+
}
|
|
28
|
+
export type IEvents = Pick<NativeEventEmitter, 'emit'>;
|
|
29
|
+
export interface IStorage {
|
|
30
|
+
setItem(key: string, value: string): Promise<void>;
|
|
31
|
+
getItem(key: string): Promise<string | null>;
|
|
32
|
+
removeItem(key: string): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export interface INativeBridge {
|
|
35
|
+
webview: IWebview;
|
|
36
|
+
biometrics: IBiometrics;
|
|
37
|
+
events: IEvents;
|
|
38
|
+
storage: IStorage;
|
|
39
|
+
reloadView(): void;
|
|
40
|
+
}
|
|
41
|
+
export type PluginKeys = Exclude<keyof INativeBridge, 'webview'>;
|
|
42
|
+
export type MethodKeys<T extends PluginKeys> = keyof INativeBridge[T];
|
|
43
|
+
export {};
|
|
@@ -14,7 +14,7 @@ type OnEventData<T extends keyof EventKeyToDataMap> = {
|
|
|
14
14
|
export type ComponentViewBaseProps = {
|
|
15
15
|
clientKey: string;
|
|
16
16
|
initialPath?: string;
|
|
17
|
-
onEvent
|
|
17
|
+
onEvent?: <T extends keyof EventKeyToDataMap>(data: OnEventData<T>) => void;
|
|
18
18
|
} & ({
|
|
19
19
|
/** Supply the auth strategy. Defaults to `jwe` which will require a `userToken` prop.
|
|
20
20
|
*
|