@getpara/react-native-wallet 1.0.2-dev.4 → 1.0.2-dev.5

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.
@@ -1,4 +1,5 @@
1
1
  import { ConstructorOpts, ParaCore, Environment, PlatformUtils } from '@getpara/web-sdk';
2
+ import { Auth } from '@getpara/user-management-client';
2
3
  /**
3
4
  * Represents a mobile implementation of the Para SDK.
4
5
  * @extends ParaCore
@@ -35,26 +36,18 @@ export declare class ParaMobile extends ParaCore {
35
36
  }): Promise<string>;
36
37
  /**
37
38
  * Registers a passkey for the user.
38
- * @param {string} identifier - The user's email or phone number.
39
+ * @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
39
40
  * @param {string} biometricsId - The biometrics ID obtained from verification.
40
- * @param {'email' | 'phone'} [identifierType='email'] - The type of identifier used.
41
41
  * @returns {Promise<void>}
42
42
  */
43
- registerPasskey({ identifier, biometricsId, identifierType, countryCode, }: {
44
- identifier: string;
43
+ registerPasskey({ auth, biometricsId }: {
44
+ auth: Auth<'email'> | Auth<'phone'>;
45
45
  biometricsId: string;
46
- identifierType?: 'email' | 'phone';
47
- countryCode?: string;
48
46
  }): Promise<void>;
49
47
  /**
50
- * Logs in the user using either email or phone number.
51
- * @param {string} [email] - The user's email address.
52
- * @param {string} [phone] - The user's phone number.
53
- * @returns {Promise<Wallet[]>} An array of user wallets.
48
+ * Logs in the user using their authentication credentials.
49
+ * @param {AuthParams} params - The authentication parameters.
50
+ * @returns {Promise<void>}
54
51
  */
55
- login({ email, phone, countryCode }: {
56
- email?: string;
57
- phone?: string;
58
- countryCode?: string;
59
- }): Promise<void>;
52
+ login(auth: Auth<'email'> | Auth<'phone'>): Promise<void>;
60
53
  }
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { ParaCore, Environment, decryptPrivateKeyAndDecryptShare, encryptPrivateKey, getAsymmetricKeyPair, getDerivedPrivateKeyAndDecrypt, getPublicKeyHex, getSHA256HashHex, parseCredentialCreationRes, } from '@getpara/web-sdk';
11
11
  import { ReactNativeUtils } from './ReactNativeUtils.js';
12
12
  import { Passkey, } from 'react-native-passkey';
13
- import { extractAuthInfo, PublicKeyStatus } from '@getpara/user-management-client';
13
+ import { PublicKeyStatus } from '@getpara/user-management-client';
14
14
  import { setEnv } from '../config.js';
15
15
  import base64url from 'base64url';
16
16
  import { webcrypto } from 'crypto';
@@ -92,20 +92,19 @@ export class ParaMobile extends ParaCore {
92
92
  }
93
93
  /**
94
94
  * Registers a passkey for the user.
95
- * @param {string} identifier - The user's email or phone number.
95
+ * @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
96
96
  * @param {string} biometricsId - The biometrics ID obtained from verification.
97
- * @param {'email' | 'phone'} [identifierType='email'] - The type of identifier used.
98
97
  * @returns {Promise<void>}
99
98
  */
100
99
  registerPasskey(_a) {
101
- return __awaiter(this, arguments, void 0, function* ({ identifier, biometricsId, identifierType = 'email', countryCode, }) {
100
+ return __awaiter(this, arguments, void 0, function* ({ auth, biometricsId }) {
102
101
  if (!webcrypto || !webcrypto.getRandomValues) {
103
102
  throw new Error('Web crypto is not available. Ensure you have imported the shim from @getpara/react-native-wallet.');
104
103
  }
105
104
  const userHandle = new Uint8Array(32);
106
105
  webcrypto.getRandomValues(userHandle);
107
106
  const userHandleEncoded = base64url.encode(userHandle);
108
- const displayIdentifier = identifierType === 'email' ? identifier : `${countryCode}${identifier}`;
107
+ const displayIdentifier = 'email' in auth ? auth.email : `${auth.countryCode}${auth.phone}`;
109
108
  const requestJson = {
110
109
  authenticatorSelection: {
111
110
  authenticatorAttachment: 'platform',
@@ -161,19 +160,13 @@ export class ParaMobile extends ParaCore {
161
160
  });
162
161
  }
163
162
  /**
164
- * Logs in the user using either email or phone number.
165
- * @param {string} [email] - The user's email address.
166
- * @param {string} [phone] - The user's phone number.
167
- * @returns {Promise<Wallet[]>} An array of user wallets.
163
+ * Logs in the user using their authentication credentials.
164
+ * @param {AuthParams} params - The authentication parameters.
165
+ * @returns {Promise<void>}
168
166
  */
169
- login(_a) {
170
- return __awaiter(this, arguments, void 0, function* ({ email, phone, countryCode }) {
171
- var _b;
167
+ login(auth) {
168
+ return __awaiter(this, void 0, void 0, function* () {
172
169
  yield this.logout();
173
- const auth = (_b = extractAuthInfo({ email, phone, countryCode })) === null || _b === void 0 ? void 0 : _b.auth;
174
- if (!auth) {
175
- throw new Error('No auth provided');
176
- }
177
170
  const { challenge, allowedPublicKeys } = yield this.ctx.client.getWebChallenge(auth);
178
171
  const requestJson = {
179
172
  challenge,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-native-wallet",
3
- "version": "1.0.2-dev.4",
3
+ "version": "1.0.2-dev.5",
4
4
  "description": "Para Wallet for React Native",
5
5
  "homepage": "https://getpara.com",
6
6
  "author": "Para Team <hello@getpara.com> (https://getpara.com)",
@@ -20,7 +20,7 @@ import {
20
20
  PasskeyGetRequest,
21
21
  PasskeyGetResult,
22
22
  } from 'react-native-passkey';
23
- import { extractAuthInfo, PublicKeyStatus, WalletScheme } from '@getpara/user-management-client';
23
+ import { Auth, PublicKeyStatus, WalletScheme } from '@getpara/user-management-client';
24
24
  import { setEnv } from '../config.js';
25
25
  import base64url from 'base64url';
26
26
  import { webcrypto } from 'crypto';
@@ -99,25 +99,13 @@ export class ParaMobile extends ParaCore {
99
99
 
100
100
  return biometricsId;
101
101
  }
102
-
103
102
  /**
104
103
  * Registers a passkey for the user.
105
- * @param {string} identifier - The user's email or phone number.
104
+ * @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
106
105
  * @param {string} biometricsId - The biometrics ID obtained from verification.
107
- * @param {'email' | 'phone'} [identifierType='email'] - The type of identifier used.
108
106
  * @returns {Promise<void>}
109
107
  */
110
- async registerPasskey({
111
- identifier,
112
- biometricsId,
113
- identifierType = 'email',
114
- countryCode,
115
- }: {
116
- identifier: string;
117
- biometricsId: string;
118
- identifierType?: 'email' | 'phone';
119
- countryCode?: string;
120
- }) {
108
+ async registerPasskey({ auth, biometricsId }: { auth: Auth<'email'> | Auth<'phone'>; biometricsId: string }) {
121
109
  if (!webcrypto || !webcrypto.getRandomValues) {
122
110
  throw new Error('Web crypto is not available. Ensure you have imported the shim from @getpara/react-native-wallet.');
123
111
  }
@@ -125,7 +113,7 @@ export class ParaMobile extends ParaCore {
125
113
  webcrypto.getRandomValues(userHandle);
126
114
  const userHandleEncoded = base64url.encode(userHandle as any);
127
115
 
128
- const displayIdentifier = identifierType === 'email' ? identifier : `${countryCode}${identifier}`;
116
+ const displayIdentifier = 'email' in auth ? auth.email : `${auth.countryCode}${auth.phone}`;
129
117
 
130
118
  const requestJson: PasskeyCreateRequest = {
131
119
  authenticatorSelection: {
@@ -193,19 +181,12 @@ export class ParaMobile extends ParaCore {
193
181
  }
194
182
 
195
183
  /**
196
- * Logs in the user using either email or phone number.
197
- * @param {string} [email] - The user's email address.
198
- * @param {string} [phone] - The user's phone number.
199
- * @returns {Promise<Wallet[]>} An array of user wallets.
184
+ * Logs in the user using their authentication credentials.
185
+ * @param {AuthParams} params - The authentication parameters.
186
+ * @returns {Promise<void>}
200
187
  */
201
- async login({ email, phone, countryCode }: { email?: string; phone?: string; countryCode?: string }): Promise<void> {
188
+ async login(auth: Auth<'email'> | Auth<'phone'>): Promise<void> {
202
189
  await this.logout();
203
- const auth = extractAuthInfo({ email, phone, countryCode })?.auth;
204
-
205
- if (!auth) {
206
- throw new Error('No auth provided');
207
- }
208
-
209
190
  const { challenge, allowedPublicKeys } = await this.ctx.client.getWebChallenge(auth);
210
191
 
211
192
  const requestJson: PasskeyGetRequest = {