@getpara/react-native-wallet 2.0.0-alpha.5 → 2.0.0-alpha.50
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/dist/config.d.ts +3 -0
- package/dist/config.js +1 -0
- package/dist/react-native/ParaMobile.d.ts +5 -2
- package/dist/react-native/ParaMobile.js +63 -17
- package/dist/react-native/ReactNativeUtils.d.ts +1 -0
- package/dist/react-native/ReactNativeUtils.js +5 -0
- package/package.json +58 -25
- package/src/config.ts +2 -0
- package/src/react-native/ParaMobile.ts +68 -12
- package/src/react-native/ReactNativeUtils.ts +4 -0
- /package/src/{index.tsx → index.ts} +0 -0
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Environment } from '@getpara/web-sdk';
|
|
2
|
+
declare function getPortalBaseURL(env: Environment): "http://localhost:3003" | "https://app.sandbox.usecapsule.com" | "https://app.beta.usecapsule.com" | "https://app.usecapsule.com";
|
|
3
|
+
declare function getBaseUrl(env: Environment): string;
|
|
2
4
|
export declare function getBaseMPCNetworkWSUrl(env: Environment): string;
|
|
3
5
|
export declare let userManagementServer: string;
|
|
4
6
|
export declare let portalBase: string;
|
|
5
7
|
export declare let mpcNetworkWSServer: string;
|
|
6
8
|
export declare function setEnv(env: Environment): void;
|
|
7
9
|
export declare const DEBUG_MODE_ENABLED = false;
|
|
10
|
+
export { getBaseUrl, getPortalBaseURL };
|
package/dist/config.js
CHANGED
|
@@ -11,13 +11,16 @@ export declare class ParaMobile extends ParaCore {
|
|
|
11
11
|
private relyingPartyId;
|
|
12
12
|
/**
|
|
13
13
|
* Creates an instance of ParaMobile.
|
|
14
|
-
* @param {Environment} env - The environment to use (DEV, SANDBOX, BETA, or PROD).
|
|
14
|
+
* @param {Environment} env - The environment to use (DEV, SANDBOX, BETA, or PROD). Optional if the apiKey contains an environment prefix (e.g., "prod_your_api_key"). Updated API keys can be found at https://developer.getpara.com.
|
|
15
15
|
* @param {string} [apiKey] - The API key for authentication.
|
|
16
16
|
* @param {string} [relyingPartyId] - The relying party ID for WebAuthn.
|
|
17
17
|
* @param {ConstructorOpts} [opts] - Additional constructor options.
|
|
18
18
|
*/
|
|
19
|
-
constructor(env: Environment, apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts);
|
|
19
|
+
constructor(env: Environment | undefined, apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts);
|
|
20
|
+
constructor(apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts);
|
|
21
|
+
ready(): Promise<void>;
|
|
20
22
|
protected getPlatformUtils(): PlatformUtils;
|
|
23
|
+
isPasskeySupported(): Promise<boolean>;
|
|
21
24
|
/**
|
|
22
25
|
* Registers a passkey for the user.
|
|
23
26
|
* @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
|
|
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { ParaCore, Environment, decryptPrivateKeyAndDecryptShare, encryptPrivateKey, getAsymmetricKeyPair, getDerivedPrivateKeyAndDecrypt, getPublicKeyHex, getSHA256HashHex, parseCredentialCreationRes, } from '@getpara/web-sdk';
|
|
11
|
-
import * as Sentry from '@sentry/react-native';
|
|
12
11
|
import { ReactNativeUtils } from './ReactNativeUtils.js';
|
|
13
12
|
import { Passkey, } from 'react-native-passkey';
|
|
14
13
|
import { PublicKeyStatus } from '@getpara/user-management-client';
|
|
@@ -25,24 +24,61 @@ const RS256_ALGORITHM = -257;
|
|
|
25
24
|
* const para = new ParaMobile(Environment.BETA, "api_key");
|
|
26
25
|
*/
|
|
27
26
|
export class ParaMobile extends ParaCore {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
constructor(envOrApiKey, apiKeyOrRelyingPartyId, relyingPartyIdOrOpts, optsArg) {
|
|
28
|
+
let env, apiKey, relyingPartyId, opts;
|
|
29
|
+
// Helper function to check if value is a valid Environment
|
|
30
|
+
const isEnvironment = (value) => {
|
|
31
|
+
return Object.values(Environment).includes(value);
|
|
32
|
+
};
|
|
33
|
+
if (arguments.length === 1) {
|
|
34
|
+
// 1-parameter case: (apiKey)
|
|
35
|
+
env = undefined;
|
|
36
|
+
apiKey = envOrApiKey;
|
|
37
|
+
relyingPartyId = undefined;
|
|
38
|
+
opts = undefined;
|
|
39
|
+
}
|
|
40
|
+
else if (arguments.length === 2) {
|
|
41
|
+
if (isEnvironment(envOrApiKey)) {
|
|
42
|
+
// 2-parameter case: (env, apiKey)
|
|
43
|
+
env = envOrApiKey;
|
|
44
|
+
apiKey = apiKeyOrRelyingPartyId;
|
|
45
|
+
relyingPartyId = undefined;
|
|
46
|
+
opts = undefined;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// 2-parameter case: (apiKey, relyingPartyId)
|
|
50
|
+
env = undefined;
|
|
51
|
+
apiKey = envOrApiKey;
|
|
52
|
+
relyingPartyId = apiKeyOrRelyingPartyId;
|
|
53
|
+
opts = undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (arguments.length === 3) {
|
|
57
|
+
if (isEnvironment(envOrApiKey)) {
|
|
58
|
+
// 3-parameter case: (env, apiKey, relyingPartyId)
|
|
59
|
+
env = envOrApiKey;
|
|
60
|
+
apiKey = apiKeyOrRelyingPartyId;
|
|
61
|
+
relyingPartyId = relyingPartyIdOrOpts;
|
|
62
|
+
opts = undefined;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// 3-parameter case: (apiKey, relyingPartyId, opts)
|
|
66
|
+
env = undefined;
|
|
67
|
+
apiKey = envOrApiKey;
|
|
68
|
+
relyingPartyId = apiKeyOrRelyingPartyId;
|
|
69
|
+
opts = relyingPartyIdOrOpts;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// 4-parameter case: (env, apiKey, relyingPartyId, opts)
|
|
74
|
+
env = envOrApiKey;
|
|
75
|
+
apiKey = apiKeyOrRelyingPartyId;
|
|
76
|
+
relyingPartyId = relyingPartyIdOrOpts;
|
|
77
|
+
opts = optsArg;
|
|
78
|
+
}
|
|
79
|
+
env = ParaCore.resolveEnvironment(env, apiKey); // Ensure the environment is resolved before calling super
|
|
36
80
|
super(env, apiKey, opts);
|
|
37
81
|
this.isNativePasskey = true;
|
|
38
|
-
// starting with non-prod to see what kind of errors we get and if sensitive data is tracked
|
|
39
|
-
// will turn on in prod after monitoring
|
|
40
|
-
if (env !== Environment.PROD && env !== Environment.DEV) {
|
|
41
|
-
Sentry.init({
|
|
42
|
-
environment: env.toLowerCase(),
|
|
43
|
-
dsn: 'https://59cea0cfbbb30a646c4e9f2feea06da4@o4504568036720640.ingest.us.sentry.io/4508850922323968',
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
82
|
setEnv(env);
|
|
47
83
|
if (relyingPartyId) {
|
|
48
84
|
this.relyingPartyId = relyingPartyId;
|
|
@@ -63,9 +99,19 @@ export class ParaMobile extends ParaCore {
|
|
|
63
99
|
}
|
|
64
100
|
}
|
|
65
101
|
}
|
|
102
|
+
ready() {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
this.isReady = true;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
66
107
|
getPlatformUtils() {
|
|
67
108
|
return new ReactNativeUtils();
|
|
68
109
|
}
|
|
110
|
+
isPasskeySupported() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
return Passkey.isSupported();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
69
115
|
/**
|
|
70
116
|
* Registers a passkey for the user.
|
|
71
117
|
* @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
|
|
@@ -48,4 +48,5 @@ export declare class ReactNativeUtils implements PlatformUtils {
|
|
|
48
48
|
walletId: string;
|
|
49
49
|
}>;
|
|
50
50
|
ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, _sessionCookie: string): Promise<SignatureRes>;
|
|
51
|
+
initializeWorker(_ctx: Ctx): Promise<void>;
|
|
51
52
|
}
|
package/package.json
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-native-wallet",
|
|
3
|
-
"version": "2.0.0-alpha.5",
|
|
4
3
|
"description": "Para Wallet for React Native",
|
|
5
|
-
"
|
|
4
|
+
"version": "2.0.0-alpha.50",
|
|
6
5
|
"author": "Para Team <hello@getpara.com> (https://getpara.com)",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"module": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist",
|
|
12
|
-
"src",
|
|
13
|
-
"ios",
|
|
14
|
-
"android",
|
|
15
|
-
"cpp",
|
|
16
|
-
"*.podspec",
|
|
17
|
-
"signer.xcframework",
|
|
18
|
-
"signer.aar"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "rm -rf dist && tsc",
|
|
22
|
-
"compile-signer": "bash ./scripts/compileSigner.sh"
|
|
23
|
-
},
|
|
24
6
|
"dependencies": {
|
|
25
|
-
"@getpara/core-sdk": "2.0.0-alpha.
|
|
26
|
-
"@getpara/user-management-client": "2.0.0-alpha.
|
|
27
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
7
|
+
"@getpara/core-sdk": "2.0.0-alpha.50",
|
|
8
|
+
"@getpara/user-management-client": "2.0.0-alpha.50",
|
|
9
|
+
"@getpara/web-sdk": "2.0.0-alpha.50",
|
|
28
10
|
"@peculiar/webcrypto": "^1.5.0",
|
|
29
|
-
"@
|
|
11
|
+
"@ungap/structured-clone": "1.3.0",
|
|
30
12
|
"node-forge": "1.3.1",
|
|
31
13
|
"react-native-url-polyfill": "2.0.0",
|
|
32
14
|
"text-encoding": "0.7.0"
|
|
@@ -43,8 +25,32 @@
|
|
|
43
25
|
"react-native-passkey": "3.1.0",
|
|
44
26
|
"react-native-quick-base64": "2.1.2",
|
|
45
27
|
"react-native-quick-crypto": "0.7.12",
|
|
46
|
-
"typescript": "^5.
|
|
28
|
+
"typescript": "^5.8.3"
|
|
47
29
|
},
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./shim": {
|
|
35
|
+
"default": "./dist/shim.js"
|
|
36
|
+
},
|
|
37
|
+
"./dist/shim.js": {
|
|
38
|
+
"default": "./dist/shim.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"src",
|
|
44
|
+
"ios",
|
|
45
|
+
"android",
|
|
46
|
+
"cpp",
|
|
47
|
+
"*.podspec",
|
|
48
|
+
"signer.xcframework",
|
|
49
|
+
"signer.aar"
|
|
50
|
+
],
|
|
51
|
+
"homepage": "https://getpara.com",
|
|
52
|
+
"main": "./dist/index.js",
|
|
53
|
+
"module": "./dist/index.js",
|
|
48
54
|
"peerDependencies": {
|
|
49
55
|
"@craftzdog/react-native-buffer": "*",
|
|
50
56
|
"@react-native-async-storage/async-storage": "*",
|
|
@@ -60,5 +66,32 @@
|
|
|
60
66
|
"publishConfig": {
|
|
61
67
|
"access": "public"
|
|
62
68
|
},
|
|
63
|
-
"
|
|
69
|
+
"react-native": {
|
|
70
|
+
".": "./dist/index.js",
|
|
71
|
+
"./shim": "./dist/shim.js",
|
|
72
|
+
"./dist/shim.js": "./dist/shim.js"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"build": "rm -rf dist && tsc",
|
|
76
|
+
"compile-signer": "bash ./scripts/compileSigner.sh",
|
|
77
|
+
"test": "vitest run --coverage"
|
|
78
|
+
},
|
|
79
|
+
"sideEffects": [
|
|
80
|
+
"./dist/shim.js"
|
|
81
|
+
],
|
|
82
|
+
"types": "./dist/index.d.ts",
|
|
83
|
+
"typesVersions": {
|
|
84
|
+
"*": {
|
|
85
|
+
"shim": [
|
|
86
|
+
"./dist/shim.d.ts"
|
|
87
|
+
],
|
|
88
|
+
"dist/shim.js": [
|
|
89
|
+
"./dist/shim.d.ts"
|
|
90
|
+
],
|
|
91
|
+
"*": [
|
|
92
|
+
"./dist/index.d.ts"
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"gitHead": "688b92a7ca207593a4a3be09cb5cc580092614fc"
|
|
64
97
|
}
|
package/src/config.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
getSHA256HashHex,
|
|
14
14
|
parseCredentialCreationRes,
|
|
15
15
|
} from '@getpara/web-sdk';
|
|
16
|
-
import * as Sentry from '@sentry/react-native';
|
|
17
16
|
|
|
18
17
|
import { ReactNativeUtils } from './ReactNativeUtils.js';
|
|
19
18
|
import {
|
|
@@ -44,23 +43,72 @@ export class ParaMobile extends ParaCore {
|
|
|
44
43
|
private relyingPartyId: string;
|
|
45
44
|
/**
|
|
46
45
|
* Creates an instance of ParaMobile.
|
|
47
|
-
* @param {Environment} env - The environment to use (DEV, SANDBOX, BETA, or PROD).
|
|
46
|
+
* @param {Environment} env - The environment to use (DEV, SANDBOX, BETA, or PROD). Optional if the apiKey contains an environment prefix (e.g., "prod_your_api_key"). Updated API keys can be found at https://developer.getpara.com.
|
|
48
47
|
* @param {string} [apiKey] - The API key for authentication.
|
|
49
48
|
* @param {string} [relyingPartyId] - The relying party ID for WebAuthn.
|
|
50
49
|
* @param {ConstructorOpts} [opts] - Additional constructor options.
|
|
51
50
|
*/
|
|
52
|
-
constructor(env: Environment, apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts)
|
|
53
|
-
|
|
51
|
+
constructor(env: Environment | undefined, apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts);
|
|
52
|
+
constructor(apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts);
|
|
53
|
+
constructor(
|
|
54
|
+
envOrApiKey: Environment | undefined | string,
|
|
55
|
+
apiKeyOrRelyingPartyId?: string,
|
|
56
|
+
relyingPartyIdOrOpts?: string | ConstructorOpts,
|
|
57
|
+
optsArg?: ConstructorOpts,
|
|
58
|
+
) {
|
|
59
|
+
let env: Environment | undefined, apiKey: string, relyingPartyId: string | undefined, opts: ConstructorOpts | undefined;
|
|
60
|
+
|
|
61
|
+
// Helper function to check if value is a valid Environment
|
|
62
|
+
const isEnvironment = (value: any): value is Environment => {
|
|
63
|
+
return Object.values(Environment).includes(value);
|
|
64
|
+
};
|
|
54
65
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
if (arguments.length === 1) {
|
|
67
|
+
// 1-parameter case: (apiKey)
|
|
68
|
+
env = undefined;
|
|
69
|
+
apiKey = envOrApiKey as string;
|
|
70
|
+
relyingPartyId = undefined;
|
|
71
|
+
opts = undefined;
|
|
72
|
+
} else if (arguments.length === 2) {
|
|
73
|
+
if (isEnvironment(envOrApiKey)) {
|
|
74
|
+
// 2-parameter case: (env, apiKey)
|
|
75
|
+
env = envOrApiKey;
|
|
76
|
+
apiKey = apiKeyOrRelyingPartyId as string;
|
|
77
|
+
relyingPartyId = undefined;
|
|
78
|
+
opts = undefined;
|
|
79
|
+
} else {
|
|
80
|
+
// 2-parameter case: (apiKey, relyingPartyId)
|
|
81
|
+
env = undefined;
|
|
82
|
+
apiKey = envOrApiKey as string;
|
|
83
|
+
relyingPartyId = apiKeyOrRelyingPartyId;
|
|
84
|
+
opts = undefined;
|
|
85
|
+
}
|
|
86
|
+
} else if (arguments.length === 3) {
|
|
87
|
+
if (isEnvironment(envOrApiKey)) {
|
|
88
|
+
// 3-parameter case: (env, apiKey, relyingPartyId)
|
|
89
|
+
env = envOrApiKey;
|
|
90
|
+
apiKey = apiKeyOrRelyingPartyId as string;
|
|
91
|
+
relyingPartyId = relyingPartyIdOrOpts as string;
|
|
92
|
+
opts = undefined;
|
|
93
|
+
} else {
|
|
94
|
+
// 3-parameter case: (apiKey, relyingPartyId, opts)
|
|
95
|
+
env = undefined;
|
|
96
|
+
apiKey = envOrApiKey as string;
|
|
97
|
+
relyingPartyId = apiKeyOrRelyingPartyId;
|
|
98
|
+
opts = relyingPartyIdOrOpts as ConstructorOpts;
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
// 4-parameter case: (env, apiKey, relyingPartyId, opts)
|
|
102
|
+
env = envOrApiKey as Environment | undefined;
|
|
103
|
+
apiKey = apiKeyOrRelyingPartyId as string;
|
|
104
|
+
relyingPartyId = relyingPartyIdOrOpts as string | undefined;
|
|
105
|
+
opts = optsArg;
|
|
62
106
|
}
|
|
63
107
|
|
|
108
|
+
env = ParaCore.resolveEnvironment(env, apiKey); // Ensure the environment is resolved before calling super
|
|
109
|
+
|
|
110
|
+
super(env, apiKey, opts);
|
|
111
|
+
|
|
64
112
|
setEnv(env);
|
|
65
113
|
|
|
66
114
|
if (relyingPartyId) {
|
|
@@ -82,10 +130,18 @@ export class ParaMobile extends ParaCore {
|
|
|
82
130
|
}
|
|
83
131
|
}
|
|
84
132
|
|
|
133
|
+
async ready() {
|
|
134
|
+
this.isReady = true;
|
|
135
|
+
}
|
|
136
|
+
|
|
85
137
|
protected getPlatformUtils(): PlatformUtils {
|
|
86
138
|
return new ReactNativeUtils();
|
|
87
139
|
}
|
|
88
140
|
|
|
141
|
+
async isPasskeySupported(): Promise<boolean> {
|
|
142
|
+
return Passkey.isSupported();
|
|
143
|
+
}
|
|
144
|
+
|
|
89
145
|
/**
|
|
90
146
|
* Registers a passkey for the user.
|
|
91
147
|
* @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
|
|
@@ -234,7 +290,7 @@ export class ParaMobile extends ParaCore {
|
|
|
234
290
|
decryptedShares = await decryptPrivateKeyAndDecryptShare(
|
|
235
291
|
resultJson.response.userHandle,
|
|
236
292
|
encryptedSharesResult.data.keyShares,
|
|
237
|
-
encryptedPrivateKeys[0]
|
|
293
|
+
encryptedPrivateKeys[0]!.encryptedPrivateKey,
|
|
238
294
|
);
|
|
239
295
|
}
|
|
240
296
|
|
|
@@ -262,4 +262,8 @@ export class ReactNativeUtils implements PlatformUtils {
|
|
|
262
262
|
const base64Sig = await ParaSignerModule.ed25519Sign(protocolId, share, base64Bytes);
|
|
263
263
|
return { signature: base64Sig };
|
|
264
264
|
}
|
|
265
|
+
|
|
266
|
+
async initializeWorker(_ctx: Ctx): Promise<void> {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
265
269
|
}
|
|
File without changes
|