@0xkey-io/react-native-wallet-kit 0.1.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.
Files changed (61) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +93 -0
  3. package/dist/hooks/use-0xkey.d.ts +3 -0
  4. package/dist/hooks/use-0xkey.d.ts.map +1 -0
  5. package/dist/hooks/use-0xkey.js +15 -0
  6. package/dist/hooks/use-0xkey.js.map +1 -0
  7. package/dist/hooks/use-0xkey.mjs +13 -0
  8. package/dist/hooks/use-0xkey.mjs.map +1 -0
  9. package/dist/index.d.ts +21 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +55 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/index.mjs +6 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/dist/providers/Types.d.ts +275 -0
  16. package/dist/providers/Types.d.ts.map +1 -0
  17. package/dist/providers/Types.js +9 -0
  18. package/dist/providers/Types.js.map +1 -0
  19. package/dist/providers/Types.mjs +7 -0
  20. package/dist/providers/Types.mjs.map +1 -0
  21. package/dist/providers/ZeroXKeyProvider.d.ts +39 -0
  22. package/dist/providers/ZeroXKeyProvider.d.ts.map +1 -0
  23. package/dist/providers/ZeroXKeyProvider.js +1846 -0
  24. package/dist/providers/ZeroXKeyProvider.js.map +1 -0
  25. package/dist/providers/ZeroXKeyProvider.mjs +1844 -0
  26. package/dist/providers/ZeroXKeyProvider.mjs.map +1 -0
  27. package/dist/providers/index.d.ts +4 -0
  28. package/dist/providers/index.d.ts.map +1 -0
  29. package/dist/tests/oauth-test.d.ts +2 -0
  30. package/dist/tests/oauth-test.d.ts.map +1 -0
  31. package/dist/typedoc-entry/index.d.ts +5 -0
  32. package/dist/typedoc-entry/index.d.ts.map +1 -0
  33. package/dist/types/base.d.ts +137 -0
  34. package/dist/types/base.d.ts.map +1 -0
  35. package/dist/types/base.js +48 -0
  36. package/dist/types/base.js.map +1 -0
  37. package/dist/types/base.mjs +48 -0
  38. package/dist/types/base.mjs.map +1 -0
  39. package/dist/types/method-types.d.ts +102 -0
  40. package/dist/types/method-types.d.ts.map +1 -0
  41. package/dist/utils/index.d.ts +4 -0
  42. package/dist/utils/index.d.ts.map +1 -0
  43. package/dist/utils/oauth.d.ts +240 -0
  44. package/dist/utils/oauth.d.ts.map +1 -0
  45. package/dist/utils/oauth.js +340 -0
  46. package/dist/utils/oauth.js.map +1 -0
  47. package/dist/utils/oauth.mjs +319 -0
  48. package/dist/utils/oauth.mjs.map +1 -0
  49. package/dist/utils/timers.d.ts +73 -0
  50. package/dist/utils/timers.d.ts.map +1 -0
  51. package/dist/utils/timers.js +132 -0
  52. package/dist/utils/timers.js.map +1 -0
  53. package/dist/utils/timers.mjs +122 -0
  54. package/dist/utils/timers.mjs.map +1 -0
  55. package/dist/utils/utils.d.ts +27 -0
  56. package/dist/utils/utils.d.ts.map +1 -0
  57. package/dist/utils/utils.js +37 -0
  58. package/dist/utils/utils.js.map +1 -0
  59. package/dist/utils/utils.mjs +33 -0
  60. package/dist/utils/utils.mjs.map +1 -0
  61. package/package.json +80 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timers.mjs","sources":["../../src/utils/timers.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAMO,MAAM,YAAY,GAAG,cAAc;AAE1C;AACA,SAAS,OAAO,CAAC,CAAS,EAAA;IACxB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCG;AACG,SAAU,gBAAgB,CAC9B,EAAc,EACd,OAAe,EAAA;IAEf,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;AAC5C,IAA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AA;IACpC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAChC,QAAA,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI;AACjB,QAAA,OAAO,GAAG,CAAC,CAAC,CAAC;IACf;AACF;AAEA;;;;;;AAMK;AACC,SAAU,qBAAqB,CACnC,GAAa,EACb,GAAW,EACX,EAAc,EACd,OAAe,EAAA;AAEf,IAAA,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AACnD;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAC7B,GAAa,EACb,GAAW,EACX,EAAc,EACd,OAAe,EAAA;AAEf,IAAA,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AACvD;;;;"}
@@ -0,0 +1,27 @@
1
+ import { Session, ZeroXKeyError, ZeroXKeyErrorCodes } from "@0xkey-io/sdk-types";
2
+ export declare const SESSION_WARNING_THRESHOLD_MS: number;
3
+ export declare const authErrors: {
4
+ passkey: {
5
+ createFailed: string;
6
+ loginFailed: string;
7
+ timeoutOrNotAllowed: string;
8
+ };
9
+ otp: {
10
+ sendFailed: string;
11
+ invalidEmail: string;
12
+ invalidPhone: string;
13
+ };
14
+ oauth: {
15
+ loginFailed: string;
16
+ };
17
+ suborg: {
18
+ fetchFailed: string;
19
+ createFailed: string;
20
+ };
21
+ };
22
+ export declare const useDebouncedCallback: <T extends (...args: any[]) => void>(fn: T, wait?: number) => T;
23
+ export declare const isValidSession: (session?: Session | undefined) => boolean;
24
+ export declare function withZeroXKeyErrorHandling<T>(fn: () => Promise<T>, sessionExpireFn: () => Promise<void>, callbacks?: {
25
+ onError?: (error: ZeroXKeyError) => void;
26
+ }, fallbackMessage?: string, fallbackCode?: ZeroXKeyErrorCodes): Promise<T>;
27
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,aAAa,EACb,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,4BAA4B,QAAY,CAAC;AAEtD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;CA0BtB,CAAC;AAEF,eAAO,MAAM,oBAAoB,uBAAwB,GAAG,EAAE,KAAK,IAAI,MACjE,CAAC,oBAEJ,CAeF,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,OAAO,GAAG,SAAS,KAAG,OAE9D,CAAC;AAEF,wBAAsB,yBAAyB,CAAC,CAAC,EAC/C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EACpC,SAAS,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;CAAE,EACxD,eAAe,SAA8B,EAC7C,YAAY,qBAA6B,GACxC,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var sdkTypes = require('@0xkey-io/sdk-types');
4
+ require('react');
5
+
6
+ const SESSION_WARNING_THRESHOLD_MS = 60 * 1000; // 1 minute in milliseconds
7
+ const isValidSession = (session) => {
8
+ return session?.expiry !== undefined && session.expiry * 1000 > Date.now();
9
+ };
10
+ async function withZeroXKeyErrorHandling(fn, sessionExpireFn, callbacks, fallbackMessage = "An unknown error occurred", fallbackCode = sdkTypes.ZeroXKeyErrorCodes.UNKNOWN) {
11
+ try {
12
+ return await fn();
13
+ }
14
+ catch (error) {
15
+ let tkError;
16
+ if (error instanceof sdkTypes.ZeroXKeyError) {
17
+ tkError = error;
18
+ if (tkError.code === sdkTypes.ZeroXKeyErrorCodes.SESSION_EXPIRED) {
19
+ await sessionExpireFn();
20
+ }
21
+ // skip onError for WalletConnect expired errors
22
+ if (tkError.code !== sdkTypes.ZeroXKeyErrorCodes.WALLET_CONNECT_EXPIRED) {
23
+ callbacks?.onError?.(tkError);
24
+ }
25
+ throw tkError;
26
+ }
27
+ // we wrap non-ZeroXKey errors
28
+ tkError = new sdkTypes.ZeroXKeyError(fallbackMessage, fallbackCode, error);
29
+ callbacks?.onError?.(tkError);
30
+ throw tkError;
31
+ }
32
+ }
33
+
34
+ exports.SESSION_WARNING_THRESHOLD_MS = SESSION_WARNING_THRESHOLD_MS;
35
+ exports.isValidSession = isValidSession;
36
+ exports.withZeroXKeyErrorHandling = withZeroXKeyErrorHandling;
37
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../src/utils/utils.ts"],"sourcesContent":[null],"names":["ZeroXKeyErrorCodes","ZeroXKeyError"],"mappings":";;;;;MAOa,4BAA4B,GAAG,EAAE,GAAG,KAAK;AAkD/C,MAAM,cAAc,GAAG,CAAC,OAA6B,KAAa;AACvE,IAAA,OAAO,OAAO,EAAE,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE;AAC5E;AAEO,eAAe,yBAAyB,CAC7C,EAAoB,EACpB,eAAoC,EACpC,SAAwD,EACxD,eAAe,GAAG,2BAA2B,EAC7C,YAAY,GAAGA,2BAAkB,CAAC,OAAO,EAAA;AAEzC,IAAA,IAAI;QACF,OAAO,MAAM,EAAE,EAAE;IACnB;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,OAAsB;AAE1B,QAAA,IAAI,KAAK,YAAYC,sBAAa,EAAE;YAClC,OAAO,GAAG,KAAK;YAEf,IAAI,OAAO,CAAC,IAAI,KAAKD,2BAAkB,CAAC,eAAe,EAAE;gBACvD,MAAM,eAAe,EAAE;YACzB;;YAGA,IAAI,OAAO,CAAC,IAAI,KAAKA,2BAAkB,CAAC,sBAAsB,EAAE;AAC9D,gBAAA,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC;YAC/B;AAEA,YAAA,MAAM,OAAO;QACf;;QAGA,OAAO,GAAG,IAAIC,sBAAa,CAAC,eAAe,EAAE,YAAY,EAAE,KAAK,CAAC;AACjE,QAAA,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC;AAC7B,QAAA,MAAM,OAAO;IACf;AACF;;;;;;"}
@@ -0,0 +1,33 @@
1
+ import { ZeroXKeyErrorCodes, ZeroXKeyError } from '@0xkey-io/sdk-types';
2
+ import 'react';
3
+
4
+ const SESSION_WARNING_THRESHOLD_MS = 60 * 1000; // 1 minute in milliseconds
5
+ const isValidSession = (session) => {
6
+ return session?.expiry !== undefined && session.expiry * 1000 > Date.now();
7
+ };
8
+ async function withZeroXKeyErrorHandling(fn, sessionExpireFn, callbacks, fallbackMessage = "An unknown error occurred", fallbackCode = ZeroXKeyErrorCodes.UNKNOWN) {
9
+ try {
10
+ return await fn();
11
+ }
12
+ catch (error) {
13
+ let tkError;
14
+ if (error instanceof ZeroXKeyError) {
15
+ tkError = error;
16
+ if (tkError.code === ZeroXKeyErrorCodes.SESSION_EXPIRED) {
17
+ await sessionExpireFn();
18
+ }
19
+ // skip onError for WalletConnect expired errors
20
+ if (tkError.code !== ZeroXKeyErrorCodes.WALLET_CONNECT_EXPIRED) {
21
+ callbacks?.onError?.(tkError);
22
+ }
23
+ throw tkError;
24
+ }
25
+ // we wrap non-ZeroXKey errors
26
+ tkError = new ZeroXKeyError(fallbackMessage, fallbackCode, error);
27
+ callbacks?.onError?.(tkError);
28
+ throw tkError;
29
+ }
30
+ }
31
+
32
+ export { SESSION_WARNING_THRESHOLD_MS, isValidSession, withZeroXKeyErrorHandling };
33
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","sources":["../../src/utils/utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;MAOa,4BAA4B,GAAG,EAAE,GAAG,KAAK;AAkD/C,MAAM,cAAc,GAAG,CAAC,OAA6B,KAAa;AACvE,IAAA,OAAO,OAAO,EAAE,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE;AAC5E;AAEO,eAAe,yBAAyB,CAC7C,EAAoB,EACpB,eAAoC,EACpC,SAAwD,EACxD,eAAe,GAAG,2BAA2B,EAC7C,YAAY,GAAG,kBAAkB,CAAC,OAAO,EAAA;AAEzC,IAAA,IAAI;QACF,OAAO,MAAM,EAAE,EAAE;IACnB;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,IAAI,OAAsB;AAE1B,QAAA,IAAI,KAAK,YAAY,aAAa,EAAE;YAClC,OAAO,GAAG,KAAK;YAEf,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,eAAe,EAAE;gBACvD,MAAM,eAAe,EAAE;YACzB;;YAGA,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,sBAAsB,EAAE;AAC9D,gBAAA,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC;YAC/B;AAEA,YAAA,MAAM,OAAO;QACf;;QAGA,OAAO,GAAG,IAAI,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,KAAK,CAAC;AACjE,QAAA,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC;AAC7B,QAAA,MAAM,OAAO;IACf;AACF;;;;"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@0xkey-io/react-native-wallet-kit",
3
+ "version": "0.1.0",
4
+ "description": "The easiest and most powerful way to integrate 0xkey's Embedded Wallets into your React Native applications.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "author": {
16
+ "name": "0xkey",
17
+ "url": "https://0xkey.com/"
18
+ },
19
+ "homepage": "https://github.com/0xkey-io/sdk-js/tree/main/packages/react-native-wallet-kit",
20
+ "bugs": {
21
+ "url": "https://github.com/0xkey-io/sdk-js/issues"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/0xkey-io/sdk-js.git",
26
+ "directory": "packages/react-native-wallet-kit"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md"
31
+ ],
32
+ "keywords": [
33
+ "0xkey",
34
+ "react-native",
35
+ "wallet",
36
+ "embedded-wallets"
37
+ ],
38
+ "license": "MIT",
39
+ "dependencies": {
40
+ "@noble/hashes": "^1.8.0",
41
+ "@react-native-async-storage/async-storage": "^2.2.0",
42
+ "react-native-device-info": "^11.1.0",
43
+ "@0xkey-io/core": "0.1.0",
44
+ "@0xkey-io/crypto": "0.1.0",
45
+ "@0xkey-io/sdk-types": "0.1.0",
46
+ "@0xkey-io/encoding": "0.1.0",
47
+ "@0xkey-io/react-native-passkey-stamper": "0.1.0"
48
+ },
49
+ "devDependencies": {
50
+ "@babel/core": "7.26.9",
51
+ "@rollup/plugin-babel": "5.3.0",
52
+ "typescript": "5.4.3"
53
+ },
54
+ "peerDependencies": {
55
+ "@types/react": ">=16.8.0 <20",
56
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
57
+ "react-native": ">=0.70.0",
58
+ "react-native-gesture-handler": ">=2.0.0",
59
+ "react-native-inappbrowser-reborn": ">=3.7.0",
60
+ "react-native-safe-area-context": ">=4.0.0",
61
+ "react-native-svg": ">=13.0.0"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "@types/react": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "engines": {
69
+ "node": ">=18.0.0"
70
+ },
71
+ "publishConfig": {
72
+ "access": "public"
73
+ },
74
+ "scripts": {
75
+ "build": "rollup -c",
76
+ "clean": "rimraf ./dist ./.cache",
77
+ "typecheck": "tsc -p tsconfig.typecheck.json",
78
+ "test": "jest"
79
+ }
80
+ }