@account-kit/react-native-signer 4.1.8-alpha
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/.github/actions/setup/action.yml +27 -0
- package/.github/workflows/ci.yml +157 -0
- package/.npmrc +1 -0
- package/.turbo/turbo-prepare.log +21 -0
- package/.watchmanconfig +1 -0
- package/README.md +37 -0
- package/account-kit-react-native-signer.podspec +41 -0
- package/android/build.gradle +132 -0
- package/android/generated/java/com/accountkit/reactnativesigner/NativeTEKStamperSpec.java +55 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/NativeTEKStamperSpec-generated.cpp +56 -0
- package/android/generated/jni/NativeTEKStamperSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/EventEmitters.cpp +16 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/EventEmitters.h +17 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/NativeTEKStamperSpecJSI-generated.cpp +54 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/NativeTEKStamperSpecJSI.h +150 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/Props.cpp +19 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/Props.h +18 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/States.h +19 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/KeyExtensions.kt +77 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/NativeTEKStamperModule.kt +234 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/ReactNativeSignerPackage.kt +33 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/TEKManager.kt +88 -0
- package/babel.config.js +5 -0
- package/example/.bundle/config +2 -0
- package/example/.watchmanconfig +1 -0
- package/example/Gemfile +9 -0
- package/example/README.md +79 -0
- package/example/android/app/build.gradle +133 -0
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +10 -0
- package/example/android/app/src/debug/AndroidManifest.xml +9 -0
- package/example/android/app/src/main/AndroidManifest.xml +17 -0
- package/example/android/app/src/main/java/accountkit/reactnativesigner/example/MainActivity.kt +27 -0
- package/example/android/app/src/main/java/accountkit/reactnativesigner/example/MainApplication.kt +48 -0
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +3 -0
- package/example/android/app/src/main/res/values/styles.xml +9 -0
- package/example/android/build.gradle +21 -0
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/example/android/gradle.properties +41 -0
- package/example/android/gradlew +252 -0
- package/example/android/gradlew.bat +94 -0
- package/example/android/settings.gradle +6 -0
- package/example/app.json +4 -0
- package/example/babel.config.js +12 -0
- package/example/index.js +6 -0
- package/example/ios/.xcode.env +11 -0
- package/example/ios/File.swift +6 -0
- package/example/ios/Podfile +47 -0
- package/example/ios/ReactNativeSignerExample/AppDelegate.h +6 -0
- package/example/ios/ReactNativeSignerExample/AppDelegate.mm +31 -0
- package/example/ios/ReactNativeSignerExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/example/ios/ReactNativeSignerExample/Images.xcassets/Contents.json +6 -0
- package/example/ios/ReactNativeSignerExample/Info.plist +52 -0
- package/example/ios/ReactNativeSignerExample/LaunchScreen.storyboard +47 -0
- package/example/ios/ReactNativeSignerExample/PrivacyInfo.xcprivacy +37 -0
- package/example/ios/ReactNativeSignerExample/main.m +10 -0
- package/example/ios/ReactNativeSignerExample-Bridging-Header.h +3 -0
- package/example/ios/ReactNativeSignerExample.xcodeproj/project.pbxproj +690 -0
- package/example/ios/ReactNativeSignerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeSignerExample.xcscheme +98 -0
- package/example/ios/ReactNativeSignerExampleTests/Info.plist +24 -0
- package/example/ios/ReactNativeSignerExampleTests/ReactNativeSignerExampleTests.m +66 -0
- package/example/jest.config.js +3 -0
- package/example/metro.config.js +22 -0
- package/example/package.json +56 -0
- package/example/react-native.config.js +15 -0
- package/example/redirect-server/index.ts +19 -0
- package/example/src/App.tsx +30 -0
- package/example/src/screens/Home.tsx +149 -0
- package/example/turbo.json +38 -0
- package/ios/ReactNativeSigner.h +12 -0
- package/ios/ReactNativeSigner.mm +21 -0
- package/ios/generated/NativeTEKStamperSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/NativeTEKStamperSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/NativeTEKStamperSpec/EventEmitters.cpp +16 -0
- package/ios/generated/NativeTEKStamperSpec/EventEmitters.h +17 -0
- package/ios/generated/NativeTEKStamperSpec/NativeTEKStamperSpec-generated.mm +67 -0
- package/ios/generated/NativeTEKStamperSpec/NativeTEKStamperSpec.h +68 -0
- package/ios/generated/NativeTEKStamperSpec/Props.cpp +19 -0
- package/ios/generated/NativeTEKStamperSpec/Props.h +18 -0
- package/ios/generated/NativeTEKStamperSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/NativeTEKStamperSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/NativeTEKStamperSpec/ShadowNodes.h +23 -0
- package/ios/generated/NativeTEKStamperSpec/States.cpp +16 -0
- package/ios/generated/NativeTEKStamperSpec/States.h +19 -0
- package/ios/generated/NativeTEKStamperSpecJSI-generated.cpp +54 -0
- package/ios/generated/NativeTEKStamperSpecJSI.h +150 -0
- package/lib/commonjs/NativeTEKStamper.js +9 -0
- package/lib/commonjs/NativeTEKStamper.js.map +1 -0
- package/lib/commonjs/client.js +103 -0
- package/lib/commonjs/client.js.map +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/signer.js +39 -0
- package/lib/commonjs/signer.js.map +1 -0
- package/lib/commonjs/utils/mmkv-localstorage-polyfill.js +38 -0
- package/lib/commonjs/utils/mmkv-localstorage-polyfill.js.map +1 -0
- package/lib/module/NativeTEKStamper.js +5 -0
- package/lib/module/NativeTEKStamper.js.map +1 -0
- package/lib/module/client.js +96 -0
- package/lib/module/client.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/signer.js +33 -0
- package/lib/module/signer.js.map +1 -0
- package/lib/module/utils/mmkv-localstorage-polyfill.js +38 -0
- package/lib/module/utils/mmkv-localstorage-polyfill.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeTEKStamper.d.ts +34 -0
- package/lib/typescript/commonjs/src/NativeTEKStamper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/client.d.ts +107 -0
- package/lib/typescript/commonjs/src/client.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/signer.d.ts +185 -0
- package/lib/typescript/commonjs/src/signer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/mmkv-localstorage-polyfill.d.ts +2 -0
- package/lib/typescript/commonjs/src/utils/mmkv-localstorage-polyfill.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeTEKStamper.d.ts +34 -0
- package/lib/typescript/module/src/NativeTEKStamper.d.ts.map +1 -0
- package/lib/typescript/module/src/client.d.ts +107 -0
- package/lib/typescript/module/src/client.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +2 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/signer.d.ts +185 -0
- package/lib/typescript/module/src/signer.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/mmkv-localstorage-polyfill.d.ts +2 -0
- package/lib/typescript/module/src/utils/mmkv-localstorage-polyfill.d.ts.map +1 -0
- package/package.json +153 -0
- package/react-native.config.js +11 -0
- package/src/NativeTEKStamper.ts +42 -0
- package/src/client.ts +128 -0
- package/src/index.tsx +2 -0
- package/src/signer.ts +39 -0
- package/src/utils/mmkv-localstorage-polyfill.ts +41 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +30 -0
- package/turbo.json +9 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import "./utils/mmkv-localstorage-polyfill";
|
|
2
|
+
import { BaseSignerClient, type AlchemySignerClientEvents, type AuthenticatingEventMetadata, type CreateAccountParams, type EmailAuthParams, type GetWebAuthnAttestationResult, type OauthConfig, type OauthParams, type SignupResponse, type User } from "@account-kit/signer";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
5
|
+
connection: z.ZodType<{
|
|
6
|
+
apiKey: string;
|
|
7
|
+
rpcUrl?: undefined;
|
|
8
|
+
jwt?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
jwt: string;
|
|
11
|
+
rpcUrl?: undefined;
|
|
12
|
+
apiKey?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
rpcUrl: string;
|
|
15
|
+
apiKey?: undefined;
|
|
16
|
+
jwt?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
rpcUrl: string;
|
|
19
|
+
jwt: string;
|
|
20
|
+
apiKey?: undefined;
|
|
21
|
+
}, z.ZodTypeDef, {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
rpcUrl?: undefined;
|
|
24
|
+
jwt?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
jwt: string;
|
|
27
|
+
rpcUrl?: undefined;
|
|
28
|
+
apiKey?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
rpcUrl: string;
|
|
31
|
+
apiKey?: undefined;
|
|
32
|
+
jwt?: undefined;
|
|
33
|
+
} | {
|
|
34
|
+
rpcUrl: string;
|
|
35
|
+
jwt: string;
|
|
36
|
+
apiKey?: undefined;
|
|
37
|
+
}>;
|
|
38
|
+
rootOrgId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
connection: {
|
|
41
|
+
apiKey: string;
|
|
42
|
+
rpcUrl?: undefined;
|
|
43
|
+
jwt?: undefined;
|
|
44
|
+
} | {
|
|
45
|
+
jwt: string;
|
|
46
|
+
rpcUrl?: undefined;
|
|
47
|
+
apiKey?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
rpcUrl: string;
|
|
50
|
+
apiKey?: undefined;
|
|
51
|
+
jwt?: undefined;
|
|
52
|
+
} | {
|
|
53
|
+
rpcUrl: string;
|
|
54
|
+
jwt: string;
|
|
55
|
+
apiKey?: undefined;
|
|
56
|
+
};
|
|
57
|
+
rootOrgId?: string | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
connection: {
|
|
60
|
+
apiKey: string;
|
|
61
|
+
rpcUrl?: undefined;
|
|
62
|
+
jwt?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
jwt: string;
|
|
65
|
+
rpcUrl?: undefined;
|
|
66
|
+
apiKey?: undefined;
|
|
67
|
+
} | {
|
|
68
|
+
rpcUrl: string;
|
|
69
|
+
apiKey?: undefined;
|
|
70
|
+
jwt?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
rpcUrl: string;
|
|
73
|
+
jwt: string;
|
|
74
|
+
apiKey?: undefined;
|
|
75
|
+
};
|
|
76
|
+
rootOrgId?: string | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
export type RNSignerClientParams = z.input<typeof RNSignerClientParamsSchema>;
|
|
79
|
+
export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
80
|
+
private stamper;
|
|
81
|
+
constructor(params: RNSignerClientParams);
|
|
82
|
+
createAccount(params: CreateAccountParams): Promise<SignupResponse>;
|
|
83
|
+
initEmailAuth(params: Omit<EmailAuthParams, "targetPublicKey">): Promise<{
|
|
84
|
+
orgId: string;
|
|
85
|
+
}>;
|
|
86
|
+
completeAuthWithBundle(params: {
|
|
87
|
+
bundle: string;
|
|
88
|
+
orgId: string;
|
|
89
|
+
connectedEventName: keyof AlchemySignerClientEvents;
|
|
90
|
+
authenticatingType: AuthenticatingEventMetadata["type"];
|
|
91
|
+
idToken?: string;
|
|
92
|
+
}): Promise<User>;
|
|
93
|
+
oauthWithRedirect(_args: Extract<OauthParams, {
|
|
94
|
+
mode: "redirect";
|
|
95
|
+
}>): Promise<never>;
|
|
96
|
+
oauthWithPopup(_args: Extract<OauthParams, {
|
|
97
|
+
mode: "popup";
|
|
98
|
+
}>): Promise<User>;
|
|
99
|
+
disconnect(): Promise<void>;
|
|
100
|
+
exportWallet(_params: unknown): Promise<boolean>;
|
|
101
|
+
lookupUserWithPasskey(_user?: User): Promise<User>;
|
|
102
|
+
protected getOauthConfig(): Promise<OauthConfig>;
|
|
103
|
+
protected getWebAuthnAttestation(_options: CredentialCreationOptions, _userDetails?: {
|
|
104
|
+
username: string;
|
|
105
|
+
}): Promise<GetWebAuthnAttestationResult>;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EACL,gBAAgB,EAChB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,qBAAa,cAAe,SAAQ,gBAAgB,CAAC,SAAS,CAAC;IAC7D,OAAO,CAAC,OAAO,CAAoB;gBACvB,MAAM,EAAE,oBAAoB;IAUzB,aAAa,CAC1B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,cAAc,CAAC;IAmBX,aAAa,CAC1B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,GAC/C,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAUd,sBAAsB,CAAC,MAAM,EAAE;QAC5C,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;QACpD,kBAAkB,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACxD,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBR,iBAAiB,CACxB,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,GAChD,OAAO,CAAC,KAAK,CAAC;IAGR,cAAc,CACrB,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,GAC7C,OAAO,CAAC,IAAI,CAAC;IAID,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAGhD,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;cAGxC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;cAGtC,sBAAsB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClC,OAAO,CAAC,4BAA4B,CAAC;CAGzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseAlchemySigner } from "@account-kit/signer";
|
|
3
|
+
import { RNSignerClient } from "./client";
|
|
4
|
+
declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
5
|
+
client: z.ZodUnion<[z.ZodType<RNSignerClient, z.ZodTypeDef, RNSignerClient>, z.ZodObject<{
|
|
6
|
+
connection: z.ZodType<{
|
|
7
|
+
apiKey: string;
|
|
8
|
+
rpcUrl?: undefined;
|
|
9
|
+
jwt?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
jwt: string;
|
|
12
|
+
rpcUrl?: undefined;
|
|
13
|
+
apiKey?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
rpcUrl: string;
|
|
16
|
+
apiKey?: undefined;
|
|
17
|
+
jwt?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
rpcUrl: string;
|
|
20
|
+
jwt: string;
|
|
21
|
+
apiKey?: undefined;
|
|
22
|
+
}, z.ZodTypeDef, {
|
|
23
|
+
apiKey: string;
|
|
24
|
+
rpcUrl?: undefined;
|
|
25
|
+
jwt?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
jwt: string;
|
|
28
|
+
rpcUrl?: undefined;
|
|
29
|
+
apiKey?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
rpcUrl: string;
|
|
32
|
+
apiKey?: undefined;
|
|
33
|
+
jwt?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
rpcUrl: string;
|
|
36
|
+
jwt: string;
|
|
37
|
+
apiKey?: undefined;
|
|
38
|
+
}>;
|
|
39
|
+
rootOrgId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
connection: {
|
|
42
|
+
apiKey: string;
|
|
43
|
+
rpcUrl?: undefined;
|
|
44
|
+
jwt?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
jwt: string;
|
|
47
|
+
rpcUrl?: undefined;
|
|
48
|
+
apiKey?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
rpcUrl: string;
|
|
51
|
+
apiKey?: undefined;
|
|
52
|
+
jwt?: undefined;
|
|
53
|
+
} | {
|
|
54
|
+
rpcUrl: string;
|
|
55
|
+
jwt: string;
|
|
56
|
+
apiKey?: undefined;
|
|
57
|
+
};
|
|
58
|
+
rootOrgId?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
connection: {
|
|
61
|
+
apiKey: string;
|
|
62
|
+
rpcUrl?: undefined;
|
|
63
|
+
jwt?: undefined;
|
|
64
|
+
} | {
|
|
65
|
+
jwt: string;
|
|
66
|
+
rpcUrl?: undefined;
|
|
67
|
+
apiKey?: undefined;
|
|
68
|
+
} | {
|
|
69
|
+
rpcUrl: string;
|
|
70
|
+
apiKey?: undefined;
|
|
71
|
+
jwt?: undefined;
|
|
72
|
+
} | {
|
|
73
|
+
rpcUrl: string;
|
|
74
|
+
jwt: string;
|
|
75
|
+
apiKey?: undefined;
|
|
76
|
+
};
|
|
77
|
+
rootOrgId?: string | undefined;
|
|
78
|
+
}>]>;
|
|
79
|
+
sessionConfig: z.ZodOptional<z.ZodObject<Omit<{
|
|
80
|
+
sessionKey: z.ZodDefault<z.ZodString>;
|
|
81
|
+
storage: z.ZodUnion<[z.ZodDefault<z.ZodEnum<["localStorage", "sessionStorage"]>>, z.ZodType<Storage, z.ZodTypeDef, Storage>]>;
|
|
82
|
+
expirationTimeMs: z.ZodDefault<z.ZodNumber>;
|
|
83
|
+
client: z.ZodType<import("@account-kit/signer").BaseSignerClient<unknown>, z.ZodTypeDef, import("@account-kit/signer").BaseSignerClient<unknown>>;
|
|
84
|
+
}, "client" | "storage">, "strip", z.ZodTypeAny, {
|
|
85
|
+
sessionKey: string;
|
|
86
|
+
expirationTimeMs: number;
|
|
87
|
+
}, {
|
|
88
|
+
sessionKey?: string | undefined;
|
|
89
|
+
expirationTimeMs?: number | undefined;
|
|
90
|
+
}>>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
client: ({
|
|
93
|
+
connection: {
|
|
94
|
+
apiKey: string;
|
|
95
|
+
rpcUrl?: undefined;
|
|
96
|
+
jwt?: undefined;
|
|
97
|
+
} | {
|
|
98
|
+
jwt: string;
|
|
99
|
+
rpcUrl?: undefined;
|
|
100
|
+
apiKey?: undefined;
|
|
101
|
+
} | {
|
|
102
|
+
rpcUrl: string;
|
|
103
|
+
apiKey?: undefined;
|
|
104
|
+
jwt?: undefined;
|
|
105
|
+
} | {
|
|
106
|
+
rpcUrl: string;
|
|
107
|
+
jwt: string;
|
|
108
|
+
apiKey?: undefined;
|
|
109
|
+
};
|
|
110
|
+
rootOrgId?: string | undefined;
|
|
111
|
+
} | RNSignerClient) & ({
|
|
112
|
+
connection: {
|
|
113
|
+
apiKey: string;
|
|
114
|
+
rpcUrl?: undefined;
|
|
115
|
+
jwt?: undefined;
|
|
116
|
+
} | {
|
|
117
|
+
jwt: string;
|
|
118
|
+
rpcUrl?: undefined;
|
|
119
|
+
apiKey?: undefined;
|
|
120
|
+
} | {
|
|
121
|
+
rpcUrl: string;
|
|
122
|
+
apiKey?: undefined;
|
|
123
|
+
jwt?: undefined;
|
|
124
|
+
} | {
|
|
125
|
+
rpcUrl: string;
|
|
126
|
+
jwt: string;
|
|
127
|
+
apiKey?: undefined;
|
|
128
|
+
};
|
|
129
|
+
rootOrgId?: string | undefined;
|
|
130
|
+
} | RNSignerClient | undefined);
|
|
131
|
+
sessionConfig?: {
|
|
132
|
+
sessionKey: string;
|
|
133
|
+
expirationTimeMs: number;
|
|
134
|
+
} | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
client: ({
|
|
137
|
+
connection: {
|
|
138
|
+
apiKey: string;
|
|
139
|
+
rpcUrl?: undefined;
|
|
140
|
+
jwt?: undefined;
|
|
141
|
+
} | {
|
|
142
|
+
jwt: string;
|
|
143
|
+
rpcUrl?: undefined;
|
|
144
|
+
apiKey?: undefined;
|
|
145
|
+
} | {
|
|
146
|
+
rpcUrl: string;
|
|
147
|
+
apiKey?: undefined;
|
|
148
|
+
jwt?: undefined;
|
|
149
|
+
} | {
|
|
150
|
+
rpcUrl: string;
|
|
151
|
+
jwt: string;
|
|
152
|
+
apiKey?: undefined;
|
|
153
|
+
};
|
|
154
|
+
rootOrgId?: string | undefined;
|
|
155
|
+
} | RNSignerClient) & ({
|
|
156
|
+
connection: {
|
|
157
|
+
apiKey: string;
|
|
158
|
+
rpcUrl?: undefined;
|
|
159
|
+
jwt?: undefined;
|
|
160
|
+
} | {
|
|
161
|
+
jwt: string;
|
|
162
|
+
rpcUrl?: undefined;
|
|
163
|
+
apiKey?: undefined;
|
|
164
|
+
} | {
|
|
165
|
+
rpcUrl: string;
|
|
166
|
+
apiKey?: undefined;
|
|
167
|
+
jwt?: undefined;
|
|
168
|
+
} | {
|
|
169
|
+
rpcUrl: string;
|
|
170
|
+
jwt: string;
|
|
171
|
+
apiKey?: undefined;
|
|
172
|
+
};
|
|
173
|
+
rootOrgId?: string | undefined;
|
|
174
|
+
} | RNSignerClient | undefined);
|
|
175
|
+
sessionConfig?: {
|
|
176
|
+
sessionKey?: string | undefined;
|
|
177
|
+
expirationTimeMs?: number | undefined;
|
|
178
|
+
} | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;
|
|
181
|
+
export declare class RNAlchemySigner extends BaseAlchemySigner<RNSignerClient> {
|
|
182
|
+
constructor(params: RNAlchemySignerParams);
|
|
183
|
+
}
|
|
184
|
+
export {};
|
|
185
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AAEtE,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEgC,EAAG,UAElE,CAAC,EAAE,SACH;iBAAe,EAAG,QAAQ,EAAE,EAAE,UAAU,CAAC,EAAE,OAAO,uCAEnC,EACb,OAAE,UAAS,EACb,UAEA;0BAAmC,EAAG,UAAU,CAAC,EAAE,SAAS;gBAAc,EAAG,OAE3E,0DAA2B,EAAG,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAJxC,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,qBAAa,eAAgB,SAAQ,iBAAiB,CAAC,cAAc,CAAC;gBACxD,MAAM,EAAE,qBAAqB;CAgB1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mmkv-localstorage-polyfill.d.ts","sourceRoot":"","sources":["../../../../../src/utils/mmkv-localstorage-polyfill.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@account-kit/react-native-signer",
|
|
3
|
+
"version": "4.1.8-alpha",
|
|
4
|
+
"description": "React Native compatible Account Kit signer",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
6
|
+
"main": "./lib/commonjs/index.js",
|
|
7
|
+
"module": "./lib/module/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./lib/typescript/module/src/index.d.ts",
|
|
12
|
+
"default": "./lib/module/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
16
|
+
"default": "./lib/commonjs/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"lib",
|
|
23
|
+
"android",
|
|
24
|
+
"ios",
|
|
25
|
+
"cpp",
|
|
26
|
+
"*.podspec",
|
|
27
|
+
"react-native.config.json",
|
|
28
|
+
"!ios/build",
|
|
29
|
+
"!android/build",
|
|
30
|
+
"!android/gradle",
|
|
31
|
+
"!android/gradlew",
|
|
32
|
+
"!android/gradlew.bat",
|
|
33
|
+
"!android/local.properties",
|
|
34
|
+
"!**/__tests__",
|
|
35
|
+
"!**/__fixtures__",
|
|
36
|
+
"!**/__mocks__",
|
|
37
|
+
"!**/.*"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"typecheck": "tsc",
|
|
42
|
+
"build:rn": "bob build && yarn typecheck && yarn turbo run build:android",
|
|
43
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
44
|
+
"prepare": "bob build"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"react-native",
|
|
48
|
+
"ios",
|
|
49
|
+
"android"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/alchemyplatform/aa-sdk.git"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public",
|
|
61
|
+
"registry": "https://registry.npmjs.org/"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
65
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
66
|
+
"@react-native-community/cli": "15.0.0",
|
|
67
|
+
"@react-native/eslint-config": "^0.73.1",
|
|
68
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
69
|
+
"@types/jest": "^29.5.5",
|
|
70
|
+
"@types/react": "^18.2.44",
|
|
71
|
+
"commitlint": "^17.0.2",
|
|
72
|
+
"del-cli": "^5.1.0",
|
|
73
|
+
"eslint": "^8.51.0",
|
|
74
|
+
"eslint-config-prettier": "^9.0.0",
|
|
75
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"prettier": "^3.0.3",
|
|
78
|
+
"react": "18.3.1",
|
|
79
|
+
"react-native": "0.76.1",
|
|
80
|
+
"react-native-builder-bob": "^0.30.3",
|
|
81
|
+
"react-native-mmkv": "^3.1.0",
|
|
82
|
+
"release-it": "^15.0.0",
|
|
83
|
+
"turbo": "^1.10.7",
|
|
84
|
+
"typescript": "^5.2.2",
|
|
85
|
+
"typescript-template": "*"
|
|
86
|
+
},
|
|
87
|
+
"resolutions": {
|
|
88
|
+
"@types/react": "^18.2.44"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"react": "*",
|
|
92
|
+
"react-native": "*",
|
|
93
|
+
"react-native-config": "1.5.3",
|
|
94
|
+
"react-native-gesture-handler": "2.21.2",
|
|
95
|
+
"react-native-mmkv": "^3.1.0"
|
|
96
|
+
},
|
|
97
|
+
"jest": {
|
|
98
|
+
"preset": "react-native",
|
|
99
|
+
"modulePathIgnorePatterns": [
|
|
100
|
+
"<rootDir>/example/node_modules",
|
|
101
|
+
"<rootDir>/lib/"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"react-native-builder-bob": {
|
|
105
|
+
"source": "src",
|
|
106
|
+
"output": "lib",
|
|
107
|
+
"targets": [
|
|
108
|
+
"codegen",
|
|
109
|
+
[
|
|
110
|
+
"commonjs",
|
|
111
|
+
{
|
|
112
|
+
"esm": true
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
"module",
|
|
117
|
+
{
|
|
118
|
+
"esm": true
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"typescript",
|
|
123
|
+
{
|
|
124
|
+
"project": "tsconfig.build.json",
|
|
125
|
+
"esm": true
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"codegenConfig": {
|
|
131
|
+
"name": "NativeTEKStamperSpec",
|
|
132
|
+
"type": "all",
|
|
133
|
+
"jsSrcsDir": "src",
|
|
134
|
+
"outputDir": {
|
|
135
|
+
"ios": "ios/generated",
|
|
136
|
+
"android": "android/generated"
|
|
137
|
+
},
|
|
138
|
+
"android": {
|
|
139
|
+
"javaPackageName": "com.accountkit.reactnativesigner"
|
|
140
|
+
},
|
|
141
|
+
"includesGeneratedCode": true
|
|
142
|
+
},
|
|
143
|
+
"create-react-native-library": {
|
|
144
|
+
"type": "module-new",
|
|
145
|
+
"languages": "kotlin-objc",
|
|
146
|
+
"version": "0.42.2"
|
|
147
|
+
},
|
|
148
|
+
"dependencies": {
|
|
149
|
+
"@aa-sdk/core": "^4.3.0",
|
|
150
|
+
"@account-kit/signer": "^4.3.0",
|
|
151
|
+
"viem": "^2.21.40"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { TurboModule } from "react-native";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
type TStamp = {
|
|
5
|
+
stampHeaderName: string;
|
|
6
|
+
stampHeaderValue: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface Spec extends TurboModule {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of the stamper and returns the public key of TEK
|
|
12
|
+
*/
|
|
13
|
+
init(): Promise<string>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Clears the stored bundle and TEK
|
|
17
|
+
*/
|
|
18
|
+
clear(): void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the public key, or `null` if the stamper isn't properly initialized.
|
|
22
|
+
*/
|
|
23
|
+
publicKey(): string | null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Function to inject a new credential into the iframe
|
|
27
|
+
* The bundle should be encrypted to the stamper's initial public key
|
|
28
|
+
* Encryption should be performed with HPKE (RFC 9180).
|
|
29
|
+
* This is used during recovery and auth flows.
|
|
30
|
+
*/
|
|
31
|
+
injectCredentialBundle(bundle: string): Promise<boolean>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Function to sign a payload with the underlying credential bundle
|
|
35
|
+
* Should throw an error if the bundle was never injected
|
|
36
|
+
*/
|
|
37
|
+
stamp(payload: string): Promise<TStamp>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
41
|
+
"NativeTEKStamper"
|
|
42
|
+
) as Spec;
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/* eslint-disable import/extensions */
|
|
2
|
+
import "./utils/mmkv-localstorage-polyfill";
|
|
3
|
+
import { type ConnectionConfig } from "@aa-sdk/core";
|
|
4
|
+
import {
|
|
5
|
+
BaseSignerClient,
|
|
6
|
+
type AlchemySignerClientEvents,
|
|
7
|
+
type AuthenticatingEventMetadata,
|
|
8
|
+
type CreateAccountParams,
|
|
9
|
+
type EmailAuthParams,
|
|
10
|
+
type GetWebAuthnAttestationResult,
|
|
11
|
+
type OauthConfig,
|
|
12
|
+
type OauthParams,
|
|
13
|
+
type SignupResponse,
|
|
14
|
+
type User,
|
|
15
|
+
} from "@account-kit/signer";
|
|
16
|
+
import NativeTEKStamper from "./NativeTEKStamper";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
|
|
19
|
+
export const RNSignerClientParamsSchema = z.object({
|
|
20
|
+
connection: z.custom<ConnectionConfig>(),
|
|
21
|
+
rootOrgId: z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export type RNSignerClientParams = z.input<typeof RNSignerClientParamsSchema>;
|
|
25
|
+
|
|
26
|
+
// TODO: need to emit events
|
|
27
|
+
export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
28
|
+
private stamper = NativeTEKStamper;
|
|
29
|
+
constructor(params: RNSignerClientParams) {
|
|
30
|
+
const { connection, rootOrgId } = RNSignerClientParamsSchema.parse(params);
|
|
31
|
+
|
|
32
|
+
super({
|
|
33
|
+
stamper: NativeTEKStamper,
|
|
34
|
+
rootOrgId: rootOrgId ?? "24c1acf5-810f-41e0-a503-d5d13fa8e830",
|
|
35
|
+
connection,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override async createAccount(
|
|
40
|
+
params: CreateAccountParams
|
|
41
|
+
): Promise<SignupResponse> {
|
|
42
|
+
if (params.type !== "email") {
|
|
43
|
+
throw new Error("Only email account creation is supported");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.eventEmitter.emit("authenticating", { type: "email" });
|
|
47
|
+
const { email, expirationSeconds } = params;
|
|
48
|
+
const publicKey = await this.stamper.init();
|
|
49
|
+
|
|
50
|
+
const response = await this.request("/v1/signup", {
|
|
51
|
+
email,
|
|
52
|
+
targetPublicKey: publicKey,
|
|
53
|
+
expirationSeconds,
|
|
54
|
+
redirectParams: params.redirectParams?.toString(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override async initEmailAuth(
|
|
61
|
+
params: Omit<EmailAuthParams, "targetPublicKey">
|
|
62
|
+
): Promise<{ orgId: string }> {
|
|
63
|
+
this.eventEmitter.emit("authenticating", { type: "email" });
|
|
64
|
+
let targetPublicKey = await this.stamper.init();
|
|
65
|
+
|
|
66
|
+
return this.request("/v1/auth", {
|
|
67
|
+
email: params.email,
|
|
68
|
+
targetPublicKey,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
override async completeAuthWithBundle(params: {
|
|
73
|
+
bundle: string;
|
|
74
|
+
orgId: string;
|
|
75
|
+
connectedEventName: keyof AlchemySignerClientEvents;
|
|
76
|
+
authenticatingType: AuthenticatingEventMetadata["type"];
|
|
77
|
+
idToken?: string;
|
|
78
|
+
}): Promise<User> {
|
|
79
|
+
if (params.authenticatingType !== "email") {
|
|
80
|
+
throw new Error("Unsupported authenticating type");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.eventEmitter.emit("authenticating", { type: "email" });
|
|
84
|
+
await this.stamper.init();
|
|
85
|
+
|
|
86
|
+
const result = await this.stamper.injectCredentialBundle(params.bundle);
|
|
87
|
+
|
|
88
|
+
if (!result) {
|
|
89
|
+
throw new Error("Failed to inject credential bundle");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const user = await this.whoami(params.orgId, params.idToken);
|
|
93
|
+
|
|
94
|
+
this.eventEmitter.emit(params.connectedEventName, user, params.bundle);
|
|
95
|
+
return user;
|
|
96
|
+
}
|
|
97
|
+
override oauthWithRedirect(
|
|
98
|
+
_args: Extract<OauthParams, { mode: "redirect" }>
|
|
99
|
+
): Promise<never> {
|
|
100
|
+
throw new Error("Method not implemented.");
|
|
101
|
+
}
|
|
102
|
+
override oauthWithPopup(
|
|
103
|
+
_args: Extract<OauthParams, { mode: "popup" }>
|
|
104
|
+
): Promise<User> {
|
|
105
|
+
throw new Error("Method not implemented.");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
override async disconnect(): Promise<void> {
|
|
109
|
+
this.user = undefined;
|
|
110
|
+
this.stamper.clear();
|
|
111
|
+
await this.stamper.init();
|
|
112
|
+
}
|
|
113
|
+
override exportWallet(_params: unknown): Promise<boolean> {
|
|
114
|
+
throw new Error("Method not implemented.");
|
|
115
|
+
}
|
|
116
|
+
override lookupUserWithPasskey(_user?: User): Promise<User> {
|
|
117
|
+
throw new Error("Method not implemented.");
|
|
118
|
+
}
|
|
119
|
+
protected override getOauthConfig(): Promise<OauthConfig> {
|
|
120
|
+
throw new Error("Method not implemented.");
|
|
121
|
+
}
|
|
122
|
+
protected override getWebAuthnAttestation(
|
|
123
|
+
_options: CredentialCreationOptions,
|
|
124
|
+
_userDetails?: { username: string }
|
|
125
|
+
): Promise<GetWebAuthnAttestationResult> {
|
|
126
|
+
throw new Error("Method not implemented.");
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/index.tsx
ADDED
package/src/signer.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
BaseAlchemySigner,
|
|
4
|
+
SessionManagerParamsSchema,
|
|
5
|
+
} from "@account-kit/signer";
|
|
6
|
+
// eslint-disable-next-line import/extensions
|
|
7
|
+
import { RNSignerClient, RNSignerClientParamsSchema } from "./client";
|
|
8
|
+
|
|
9
|
+
const RNAlchemySignerParamsSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
client: z.custom<RNSignerClient>().or(RNSignerClientParamsSchema),
|
|
12
|
+
})
|
|
13
|
+
.extend({
|
|
14
|
+
sessionConfig: SessionManagerParamsSchema.omit({
|
|
15
|
+
client: true,
|
|
16
|
+
storage: true,
|
|
17
|
+
}).optional(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;
|
|
21
|
+
|
|
22
|
+
export class RNAlchemySigner extends BaseAlchemySigner<RNSignerClient> {
|
|
23
|
+
constructor(params: RNAlchemySignerParams) {
|
|
24
|
+
const { sessionConfig, ...params_ } =
|
|
25
|
+
RNAlchemySignerParamsSchema.parse(params);
|
|
26
|
+
|
|
27
|
+
let client: RNSignerClient;
|
|
28
|
+
|
|
29
|
+
if ("connection" in params_.client) {
|
|
30
|
+
client = new RNSignerClient(params_.client);
|
|
31
|
+
} else {
|
|
32
|
+
client = params_.client;
|
|
33
|
+
}
|
|
34
|
+
super({
|
|
35
|
+
client,
|
|
36
|
+
sessionConfig,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|