@getpara/react-native-wallet 2.0.0-dev.3 → 2.0.0-dev.6

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.
@@ -11,13 +11,14 @@ 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);
20
- protected ready(): Promise<void>;
19
+ constructor(env: Environment | undefined, apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts);
20
+ constructor(apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts);
21
+ ready(): Promise<void>;
21
22
  protected getPlatformUtils(): PlatformUtils;
22
23
  isPasskeySupported(): Promise<boolean>;
23
24
  /**
@@ -24,14 +24,59 @@ const RS256_ALGORITHM = -257;
24
24
  * const para = new ParaMobile(Environment.BETA, "api_key");
25
25
  */
26
26
  export class ParaMobile extends ParaCore {
27
- /**
28
- * Creates an instance of ParaMobile.
29
- * @param {Environment} env - The environment to use (DEV, SANDBOX, BETA, or PROD).
30
- * @param {string} [apiKey] - The API key for authentication.
31
- * @param {string} [relyingPartyId] - The relying party ID for WebAuthn.
32
- * @param {ConstructorOpts} [opts] - Additional constructor options.
33
- */
34
- constructor(env, apiKey, relyingPartyId, opts) {
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
35
80
  super(env, apiKey, opts);
36
81
  this.isNativePasskey = true;
37
82
  setEnv(env);
@@ -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
  }
@@ -168,4 +168,9 @@ export class ReactNativeUtils {
168
168
  return { signature: base64Sig };
169
169
  });
170
170
  }
171
+ initializeWorker(_ctx) {
172
+ return __awaiter(this, void 0, void 0, function* () {
173
+ return;
174
+ });
175
+ }
171
176
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@getpara/react-native-wallet",
3
3
  "description": "Para Wallet for React Native",
4
- "version": "2.0.0-dev.3",
4
+ "version": "2.0.0-dev.6",
5
5
  "author": "Para Team <hello@getpara.com> (https://getpara.com)",
6
6
  "dependencies": {
7
- "@getpara/core-sdk": "2.0.0-dev.3",
8
- "@getpara/user-management-client": "2.0.0-dev.3",
9
- "@getpara/web-sdk": "2.0.0-dev.3",
7
+ "@getpara/core-sdk": "2.0.0-dev.6",
8
+ "@getpara/user-management-client": "2.0.0-dev.6",
9
+ "@getpara/web-sdk": "2.0.0-dev.6",
10
10
  "@peculiar/webcrypto": "^1.5.0",
11
11
  "@ungap/structured-clone": "1.3.0",
12
12
  "node-forge": "1.3.1",
@@ -93,5 +93,5 @@
93
93
  ]
94
94
  }
95
95
  },
96
- "gitHead": "ffe34f7d8df2dd3c2327ca1f35bcc9764e0a68a2"
96
+ "gitHead": "c2125e37c73a19f11978031f5aa2eab39b978c56"
97
97
  }
@@ -43,12 +43,70 @@ export class ParaMobile extends ParaCore {
43
43
  private relyingPartyId: string;
44
44
  /**
45
45
  * Creates an instance of ParaMobile.
46
- * @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.
47
47
  * @param {string} [apiKey] - The API key for authentication.
48
48
  * @param {string} [relyingPartyId] - The relying party ID for WebAuthn.
49
49
  * @param {ConstructorOpts} [opts] - Additional constructor options.
50
50
  */
51
- constructor(env: Environment, apiKey: string, relyingPartyId?: string, opts?: ConstructorOpts) {
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
+ };
65
+
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;
106
+ }
107
+
108
+ env = ParaCore.resolveEnvironment(env, apiKey); // Ensure the environment is resolved before calling super
109
+
52
110
  super(env, apiKey, opts);
53
111
 
54
112
  setEnv(env);
@@ -72,7 +130,7 @@ export class ParaMobile extends ParaCore {
72
130
  }
73
131
  }
74
132
 
75
- protected async ready() {
133
+ async ready() {
76
134
  this.isReady = true;
77
135
  }
78
136
 
@@ -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
  }