@getpara/react-native-wallet 1.0.2-dev.8 → 1.0.2-dev.9
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/shim.js +88 -0
- package/package.json +5 -18
- package/src/shim.js +86 -52
- package/dist/cjs/AsyncStorage.js +0 -47
- package/dist/cjs/KeychainStorage.js +0 -78
- package/dist/cjs/config.js +0 -65
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/react-native/ParaMobile.js +0 -258
- package/dist/cjs/react-native/ReactNativeUtils.js +0 -174
- package/dist/cjs/shim.js +0 -79
- package/dist/esm/AsyncStorage.d.ts +0 -10
- package/dist/esm/KeychainStorage.d.ts +0 -10
- package/dist/esm/config.d.ts +0 -7
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/package.json +0 -1
- package/dist/esm/react-native/ParaMobile.d.ts +0 -52
- package/dist/esm/react-native/ReactNativeUtils.d.ts +0 -50
- package/dist/esm/shim.d.ts +0 -1
- package/dist/esm/shim.js +0 -51
- package/dist/types/AsyncStorage.d.ts +0 -10
- package/dist/types/KeychainStorage.d.ts +0 -10
- package/dist/types/config.d.ts +0 -7
- package/dist/types/index.d.ts +0 -2
- package/dist/types/react-native/ParaMobile.d.ts +0 -52
- package/dist/types/react-native/ReactNativeUtils.d.ts +0 -50
- package/dist/types/shim.d.ts +0 -1
- /package/dist/{cjs/AsyncStorage.d.ts → AsyncStorage.d.ts} +0 -0
- /package/dist/{esm/AsyncStorage.js → AsyncStorage.js} +0 -0
- /package/dist/{cjs/KeychainStorage.d.ts → KeychainStorage.d.ts} +0 -0
- /package/dist/{esm/KeychainStorage.js → KeychainStorage.js} +0 -0
- /package/dist/{cjs/config.d.ts → config.d.ts} +0 -0
- /package/dist/{esm/config.js → config.js} +0 -0
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dist/{esm/index.js → index.js} +0 -0
- /package/dist/{cjs/react-native → react-native}/ParaMobile.d.ts +0 -0
- /package/dist/{esm/react-native → react-native}/ParaMobile.js +0 -0
- /package/dist/{cjs/react-native → react-native}/ReactNativeUtils.d.ts +0 -0
- /package/dist/{esm/react-native → react-native}/ReactNativeUtils.js +0 -0
- /package/dist/{cjs/shim.d.ts → shim.d.ts} +0 -0
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ParaMobile = void 0;
|
|
27
|
-
const web_sdk_1 = require("@getpara/web-sdk");
|
|
28
|
-
const ReactNativeUtils_js_1 = require("./ReactNativeUtils.js");
|
|
29
|
-
const react_native_passkey_1 = require("react-native-passkey");
|
|
30
|
-
const user_management_client_1 = require("@getpara/user-management-client");
|
|
31
|
-
const config_js_1 = require("../config.js");
|
|
32
|
-
const base64url_1 = __importDefault(require("base64url"));
|
|
33
|
-
const crypto_1 = require("crypto");
|
|
34
|
-
const ES256_ALGORITHM = -7;
|
|
35
|
-
const RS256_ALGORITHM = -257;
|
|
36
|
-
/**
|
|
37
|
-
* Represents a mobile implementation of the Para SDK.
|
|
38
|
-
* @extends ParaCore
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* const para = new ParaMobile(Environment.BETA, "api_key");
|
|
42
|
-
*/
|
|
43
|
-
class ParaMobile extends web_sdk_1.ParaCore {
|
|
44
|
-
/**
|
|
45
|
-
* Creates an instance of ParaMobile.
|
|
46
|
-
* @param {Environment} env - The environment to use (DEV, SANDBOX, BETA, or PROD).
|
|
47
|
-
* @param {string} [apiKey] - The API key for authentication.
|
|
48
|
-
* @param {string} [relyingPartyId] - The relying party ID for WebAuthn.
|
|
49
|
-
* @param {ConstructorOpts} [opts] - Additional constructor options.
|
|
50
|
-
*/
|
|
51
|
-
constructor(env, apiKey, relyingPartyId, opts) {
|
|
52
|
-
super(env, apiKey, opts);
|
|
53
|
-
(0, config_js_1.setEnv)(env);
|
|
54
|
-
if (relyingPartyId) {
|
|
55
|
-
this.relyingPartyId = relyingPartyId;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
switch (env) {
|
|
59
|
-
case web_sdk_1.Environment.DEV:
|
|
60
|
-
throw new Error('relyingPartyId is required');
|
|
61
|
-
case web_sdk_1.Environment.SANDBOX:
|
|
62
|
-
this.relyingPartyId = 'app.sandbox.usecapsule.com';
|
|
63
|
-
break;
|
|
64
|
-
case web_sdk_1.Environment.BETA:
|
|
65
|
-
this.relyingPartyId = 'app.beta.usecapsule.com';
|
|
66
|
-
break;
|
|
67
|
-
case web_sdk_1.Environment.PROD:
|
|
68
|
-
this.relyingPartyId = 'app.usecapsule.com';
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
getPlatformUtils() {
|
|
74
|
-
return new ReactNativeUtils_js_1.ReactNativeUtils();
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Verifies an email and returns the biometrics ID.
|
|
78
|
-
* @param {string} verificationCode - The verification code sent to the email.
|
|
79
|
-
* @returns {Promise<string>} The biometrics ID.
|
|
80
|
-
*/
|
|
81
|
-
verifyEmailBiometricsId(_a) {
|
|
82
|
-
const _super = Object.create(null, {
|
|
83
|
-
verifyEmail: { get: () => super.verifyEmail }
|
|
84
|
-
});
|
|
85
|
-
return __awaiter(this, arguments, void 0, function* ({ verificationCode }) {
|
|
86
|
-
const webAuthCreateUrl = yield _super.verifyEmail.call(this, { verificationCode });
|
|
87
|
-
const segments = webAuthCreateUrl.split('/');
|
|
88
|
-
const segments2 = segments[segments.length - 1].split('?');
|
|
89
|
-
const biometricsId = segments2[0];
|
|
90
|
-
return biometricsId;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Verifies a phone number and returns the biometrics ID.
|
|
95
|
-
* @param {string} verificationCode - The verification code sent to the phone.
|
|
96
|
-
* @returns {Promise<string>} The biometrics ID.
|
|
97
|
-
*/
|
|
98
|
-
verifyPhoneBiometricsId(_a) {
|
|
99
|
-
const _super = Object.create(null, {
|
|
100
|
-
verifyPhone: { get: () => super.verifyPhone }
|
|
101
|
-
});
|
|
102
|
-
return __awaiter(this, arguments, void 0, function* ({ verificationCode }) {
|
|
103
|
-
const webAuthCreateUrl = yield _super.verifyPhone.call(this, { verificationCode });
|
|
104
|
-
const segments = webAuthCreateUrl.split('/');
|
|
105
|
-
const segments2 = segments[segments.length - 1].split('?');
|
|
106
|
-
const biometricsId = segments2[0];
|
|
107
|
-
return biometricsId;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Registers a passkey for the user.
|
|
112
|
-
* @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
|
|
113
|
-
* @param {string} biometricsId - The biometrics ID obtained from verification.
|
|
114
|
-
* @returns {Promise<void>}
|
|
115
|
-
*/
|
|
116
|
-
registerPasskey(_a) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
var { biometricsId } = _a, auth = __rest(_a, ["biometricsId"]);
|
|
119
|
-
if (!crypto_1.webcrypto || !crypto_1.webcrypto.getRandomValues) {
|
|
120
|
-
throw new Error('Web crypto is not available. Ensure you have imported the shim from @getpara/react-native-wallet.');
|
|
121
|
-
}
|
|
122
|
-
const userHandle = new Uint8Array(32);
|
|
123
|
-
crypto_1.webcrypto.getRandomValues(userHandle);
|
|
124
|
-
const userHandleEncoded = base64url_1.default.encode(userHandle);
|
|
125
|
-
const { identifier: displayIdentifier } = (0, user_management_client_1.extractAuthInfo)(auth, { isRequired: true });
|
|
126
|
-
const requestJson = {
|
|
127
|
-
authenticatorSelection: {
|
|
128
|
-
authenticatorAttachment: 'platform',
|
|
129
|
-
requireResidentKey: true,
|
|
130
|
-
residentKey: 'required',
|
|
131
|
-
userVerification: 'required',
|
|
132
|
-
},
|
|
133
|
-
rp: {
|
|
134
|
-
id: this.relyingPartyId,
|
|
135
|
-
name: 'Para',
|
|
136
|
-
},
|
|
137
|
-
user: {
|
|
138
|
-
id: userHandleEncoded,
|
|
139
|
-
name: displayIdentifier,
|
|
140
|
-
displayName: displayIdentifier,
|
|
141
|
-
},
|
|
142
|
-
pubKeyCredParams: [
|
|
143
|
-
{
|
|
144
|
-
type: 'public-key',
|
|
145
|
-
alg: ES256_ALGORITHM,
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
type: 'public-key',
|
|
149
|
-
alg: RS256_ALGORITHM,
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
attestation: 'direct',
|
|
153
|
-
timeout: 60000,
|
|
154
|
-
challenge: base64url_1.default.encode('somechallenge'),
|
|
155
|
-
};
|
|
156
|
-
const result = yield react_native_passkey_1.Passkey.create(requestJson);
|
|
157
|
-
let resultJson;
|
|
158
|
-
if (typeof result === 'string') {
|
|
159
|
-
resultJson = JSON.parse(result);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
resultJson = result;
|
|
163
|
-
}
|
|
164
|
-
const { cosePublicKey, clientDataJSON } = (0, web_sdk_1.parseCredentialCreationRes)(resultJson, ES256_ALGORITHM);
|
|
165
|
-
const keyPair = yield (0, web_sdk_1.getAsymmetricKeyPair)(this.ctx);
|
|
166
|
-
const publicKeyHex = (0, web_sdk_1.getPublicKeyHex)(keyPair);
|
|
167
|
-
const encryptionKeyHash = (0, web_sdk_1.getSHA256HashHex)(userHandleEncoded);
|
|
168
|
-
const encryptedPrivateKeyHex = yield (0, web_sdk_1.encryptPrivateKey)(keyPair, userHandleEncoded);
|
|
169
|
-
const session = yield this.ctx.client.touchSession();
|
|
170
|
-
yield this.ctx.client.patchSessionPublicKey(session.data.partnerId, this.getUserId(), biometricsId, {
|
|
171
|
-
publicKey: resultJson.id,
|
|
172
|
-
sigDerivedPublicKey: publicKeyHex,
|
|
173
|
-
cosePublicKey,
|
|
174
|
-
clientDataJSON,
|
|
175
|
-
status: user_management_client_1.PublicKeyStatus.COMPLETE,
|
|
176
|
-
});
|
|
177
|
-
yield this.ctx.client.uploadEncryptedWalletPrivateKey(this.getUserId(), encryptedPrivateKeyHex, encryptionKeyHash, resultJson.id);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Logs in the user using their authentication credentials.
|
|
182
|
-
* @param {AuthParams} params - The authentication parameters.
|
|
183
|
-
* @returns {Promise<void>}
|
|
184
|
-
*/
|
|
185
|
-
login(_a) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
var auth = __rest(_a, []);
|
|
188
|
-
yield this.logout();
|
|
189
|
-
const authInfo = (0, user_management_client_1.extractAuthInfo)(auth, { isRequired: true });
|
|
190
|
-
const { challenge, allowedPublicKeys } = yield this.ctx.client.getWebChallenge(authInfo.auth);
|
|
191
|
-
const requestJson = {
|
|
192
|
-
challenge,
|
|
193
|
-
timeout: 60000,
|
|
194
|
-
rpId: this.relyingPartyId,
|
|
195
|
-
allowCredentials: (allowedPublicKeys === null || allowedPublicKeys === void 0 ? void 0 : allowedPublicKeys[0]) ? [{ type: 'public-key', id: allowedPublicKeys[0] }] : [],
|
|
196
|
-
};
|
|
197
|
-
const result = yield react_native_passkey_1.Passkey.get(requestJson);
|
|
198
|
-
let resultJson;
|
|
199
|
-
if (typeof result === 'string') {
|
|
200
|
-
resultJson = JSON.parse(result);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
resultJson = result;
|
|
204
|
-
}
|
|
205
|
-
const session = yield this.ctx.client.touchSession();
|
|
206
|
-
const publicKey = resultJson.id;
|
|
207
|
-
const verifyWebChallengeResult = yield this.ctx.client.verifyWebChallenge(session.data.partnerId, {
|
|
208
|
-
publicKey,
|
|
209
|
-
signature: {
|
|
210
|
-
clientDataJSON: resultJson.response.clientDataJSON,
|
|
211
|
-
authenticatorData: resultJson.response.authenticatorData,
|
|
212
|
-
signature: resultJson.response.signature,
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
const userId = verifyWebChallengeResult.data.userId;
|
|
216
|
-
yield this.setUserId(userId);
|
|
217
|
-
const { user } = yield this.ctx.client.getUser(userId);
|
|
218
|
-
if (user.phone) {
|
|
219
|
-
yield this.setPhoneNumber(user.phone.number, user.phone.countryCode);
|
|
220
|
-
}
|
|
221
|
-
if (user.email) {
|
|
222
|
-
yield this.setEmail(user.email);
|
|
223
|
-
}
|
|
224
|
-
if (user.farcasterUsername) {
|
|
225
|
-
yield this.setFarcasterUsername(user.farcasterUsername);
|
|
226
|
-
}
|
|
227
|
-
const encryptedSharesResult = yield this.ctx.client.getBiometricKeyshares(userId, resultJson.id);
|
|
228
|
-
const encryptionKeyHash = (0, web_sdk_1.getSHA256HashHex)(resultJson.response.userHandle);
|
|
229
|
-
const { encryptedPrivateKeys } = yield this.ctx.client.getEncryptedWalletPrivateKeys(userId, encryptionKeyHash);
|
|
230
|
-
let decryptedShares;
|
|
231
|
-
if (encryptedPrivateKeys.length === 0) {
|
|
232
|
-
decryptedShares = yield (0, web_sdk_1.getDerivedPrivateKeyAndDecrypt)(this.ctx, resultJson.response.userHandle, encryptedSharesResult.data.keyShares);
|
|
233
|
-
const keyPair = yield (0, web_sdk_1.getAsymmetricKeyPair)(this.ctx, resultJson.response.userHandle);
|
|
234
|
-
const encryptedPrivateKeyHex = yield (0, web_sdk_1.encryptPrivateKey)(keyPair, resultJson.response.userHandle);
|
|
235
|
-
yield this.ctx.client.uploadEncryptedWalletPrivateKey(userId, encryptedPrivateKeyHex, encryptionKeyHash, resultJson.id);
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
decryptedShares = yield (0, web_sdk_1.decryptPrivateKeyAndDecryptShare)(resultJson.response.userHandle, encryptedSharesResult.data.keyShares, encryptedPrivateKeys[0].encryptedPrivateKey);
|
|
239
|
-
}
|
|
240
|
-
const walletsRes = yield this.ctx.client.getWallets(userId);
|
|
241
|
-
const desiredWallets = walletsRes.data.wallets;
|
|
242
|
-
const walletsToInsert = {};
|
|
243
|
-
for (let desiredWallet of desiredWallets) {
|
|
244
|
-
const decryptedShare = decryptedShares.find(share => share.walletId === desiredWallet.id);
|
|
245
|
-
walletsToInsert[decryptedShare.walletId] = {
|
|
246
|
-
id: decryptedShare.walletId,
|
|
247
|
-
signer: decryptedShare.signer,
|
|
248
|
-
address: desiredWallet.address || undefined,
|
|
249
|
-
publicKey: desiredWallet.publicKey || undefined,
|
|
250
|
-
scheme: desiredWallet.scheme,
|
|
251
|
-
type: desiredWallet.type || undefined,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
yield this.setWallets(walletsToInsert);
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
exports.ParaMobile = ParaMobile;
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ReactNativeUtils = void 0;
|
|
13
|
-
const user_management_client_1 = require("@getpara/user-management-client");
|
|
14
|
-
const react_native_1 = require("react-native");
|
|
15
|
-
const AsyncStorage_js_1 = require("../AsyncStorage.js");
|
|
16
|
-
const KeychainStorage_js_1 = require("../KeychainStorage.js");
|
|
17
|
-
const { ParaSignerModule } = react_native_1.NativeModules;
|
|
18
|
-
function keygenRequest(ctx, userId, walletId, protocolId) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const { data } = yield ctx.mpcComputationClient.post('/wallets', {
|
|
21
|
-
userId,
|
|
22
|
-
walletId,
|
|
23
|
-
protocolId,
|
|
24
|
-
});
|
|
25
|
-
return data;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function signMessageRequest(ctx, userId, walletId, protocolId, message, signer) {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const { data } = yield ctx.mpcComputationClient.post(`/wallets/${walletId}/messages/sign`, {
|
|
31
|
-
userId,
|
|
32
|
-
protocolId,
|
|
33
|
-
message,
|
|
34
|
-
signer,
|
|
35
|
-
});
|
|
36
|
-
return data;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function sendTransactionRequest(ctx, userId, walletId, protocolId, transaction, signer, chainId) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const { data } = yield ctx.mpcComputationClient.post(`/wallets/${walletId}/transactions/send`, {
|
|
42
|
-
userId,
|
|
43
|
-
protocolId,
|
|
44
|
-
transaction,
|
|
45
|
-
signer,
|
|
46
|
-
chainId,
|
|
47
|
-
});
|
|
48
|
-
return data;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
class ReactNativeUtils {
|
|
52
|
-
constructor() {
|
|
53
|
-
this.localStorage = new AsyncStorage_js_1.AsyncStorage();
|
|
54
|
-
this.sessionStorage = new AsyncStorage_js_1.AsyncStorage();
|
|
55
|
-
this.secureStorage = new KeychainStorage_js_1.KeychainStorage();
|
|
56
|
-
this.isSyncStorage = false;
|
|
57
|
-
}
|
|
58
|
-
// only used in web for now, can implement functionality if ever needed for mobile
|
|
59
|
-
generateBlumPrimes(_ctx) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
throw new Error('method not implemented');
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
keygen(ctx, userId, type, _secretKey, _sessionCookie, _emailProps) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
|
|
67
|
-
type,
|
|
68
|
-
useTwoSigners: true,
|
|
69
|
-
scheme: ctx.useDKLS ? user_management_client_1.WalletScheme.DKLS : user_management_client_1.WalletScheme.CGGMP,
|
|
70
|
-
});
|
|
71
|
-
if (ctx.mpcComputationClient && !ctx.useDKLS) {
|
|
72
|
-
const { signer } = yield keygenRequest(ctx, userId, walletId, protocolId);
|
|
73
|
-
return { signer, walletId };
|
|
74
|
-
}
|
|
75
|
-
const createAccountFn = !ctx.useDKLS ? ParaSignerModule.createAccount : ParaSignerModule.dklsCreateAccount;
|
|
76
|
-
const signer = yield createAccountFn(walletId, protocolId, user_management_client_1.KeyShareType.USER, userId);
|
|
77
|
-
return { signer, walletId };
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
refresh(_ctx, _sessionCookie, _userId, _walletId, _share, _oldPartnerId, _newPartnerId) {
|
|
81
|
-
throw new Error('Method not implemented.');
|
|
82
|
-
}
|
|
83
|
-
preKeygen(_ctx, _partnerId, _email, _secretKey, _sessionCookie) {
|
|
84
|
-
throw new Error('Method not implemented.');
|
|
85
|
-
}
|
|
86
|
-
getPrivateKey(_ctx, _userId, _walletId, _share, _sessionCookie) {
|
|
87
|
-
throw new Error('Method not implemented.');
|
|
88
|
-
}
|
|
89
|
-
openPopup(_popupUrl) {
|
|
90
|
-
throw new Error('Method not implemented.');
|
|
91
|
-
}
|
|
92
|
-
baseSignTransaction(ctx, userId, walletId, protocolId, share, rlpEncodedTxBase64, chainId, isDKLS) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
if (ctx.mpcComputationClient && !isDKLS) {
|
|
95
|
-
const signature = (yield sendTransactionRequest(ctx, userId, walletId, protocolId, rlpEncodedTxBase64, share, chainId))
|
|
96
|
-
.signature;
|
|
97
|
-
return { signature };
|
|
98
|
-
}
|
|
99
|
-
const sendTransactionFn = isDKLS ? ParaSignerModule.dklsSendTransaction : ParaSignerModule.sendTransaction;
|
|
100
|
-
const signature = yield sendTransactionFn(protocolId, share, rlpEncodedTxBase64, userId);
|
|
101
|
-
return { signature: signature.slice(2) };
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
sendTransaction(ctx, userId, walletId, share, rlpEncodedTxBase64, chainId, _sessionCookie, isDKLS) {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
const { protocolId } = (yield ctx.client.sendTransaction(userId, walletId, {
|
|
107
|
-
transaction: rlpEncodedTxBase64,
|
|
108
|
-
chainId,
|
|
109
|
-
})).data;
|
|
110
|
-
return this.baseSignTransaction(ctx, userId, walletId, protocolId, share, rlpEncodedTxBase64, chainId, isDKLS);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
signHash(_address, _hash) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
throw new Error('not implemented');
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
signMessage(ctx, userId, walletId, share, messageBase64, // base64 message
|
|
119
|
-
_sessionCookie, isDKLS) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
const res = yield ctx.client.preSignMessage(userId, walletId, messageBase64);
|
|
122
|
-
if (ctx.mpcComputationClient && !isDKLS) {
|
|
123
|
-
const signature = (yield signMessageRequest(ctx, userId, walletId, res.protocolId, messageBase64, share)).signature;
|
|
124
|
-
return { signature };
|
|
125
|
-
}
|
|
126
|
-
const signMessageFn = isDKLS ? ParaSignerModule.dklsSignMessage : ParaSignerModule.signMessage;
|
|
127
|
-
const signature = yield signMessageFn(res.protocolId, share, messageBase64, userId);
|
|
128
|
-
if (signature.startsWith('0x')) {
|
|
129
|
-
return { signature: signature.slice(2) };
|
|
130
|
-
}
|
|
131
|
-
return { signature };
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
signTransaction(ctx, userId, walletId, share, rlpEncodedTxBase64, // base64 encoding of rlp encoded tx
|
|
135
|
-
chainId, _sessionCookie, isDKLS) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
const { protocolId } = (yield ctx.client.signTransaction(userId, walletId, {
|
|
138
|
-
transaction: rlpEncodedTxBase64,
|
|
139
|
-
chainId,
|
|
140
|
-
})).data;
|
|
141
|
-
return this.baseSignTransaction(ctx, userId, walletId, protocolId, share, rlpEncodedTxBase64, chainId, isDKLS);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
ed25519Keygen(ctx, userId, _sessionCookie, _emailProps) {
|
|
145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
const { walletId, protocolId } = yield ctx.client.createWallet(userId, {
|
|
147
|
-
scheme: user_management_client_1.WalletScheme.ED25519,
|
|
148
|
-
type: user_management_client_1.WalletType.SOLANA,
|
|
149
|
-
});
|
|
150
|
-
const signer = yield ParaSignerModule.ed25519CreateAccount(walletId, protocolId);
|
|
151
|
-
return { signer, walletId };
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, _sessionCookie) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const { walletId, protocolId } = yield ctx.client.createPregenWallet({
|
|
157
|
-
pregenIdentifier,
|
|
158
|
-
pregenIdentifierType,
|
|
159
|
-
scheme: user_management_client_1.WalletScheme.ED25519,
|
|
160
|
-
type: user_management_client_1.WalletType.SOLANA,
|
|
161
|
-
});
|
|
162
|
-
const signer = yield ParaSignerModule.ed25519CreateAccount(walletId, protocolId);
|
|
163
|
-
return { signer, walletId };
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
ed25519Sign(ctx, userId, walletId, share, base64Bytes, _sessionCookie) {
|
|
167
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const { protocolId } = yield ctx.client.preSignMessage(userId, walletId, base64Bytes, user_management_client_1.WalletScheme.ED25519);
|
|
169
|
-
const base64Sig = yield ParaSignerModule.ed25519Sign(protocolId, share, base64Bytes);
|
|
170
|
-
return { signature: base64Sig };
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
exports.ReactNativeUtils = ReactNativeUtils;
|
package/dist/cjs/shim.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
// 1) Node-like crypto + Web Crypto API (subtle + getRandomValues)
|
|
30
|
-
const react_native_quick_crypto_1 = __importDefault(require("react-native-quick-crypto"));
|
|
31
|
-
const crypto_1 = require("crypto");
|
|
32
|
-
const webcrypto_1 = require("@peculiar/webcrypto");
|
|
33
|
-
if (typeof global.crypto === 'undefined') {
|
|
34
|
-
// Attach Node-style crypto for randomFillSync, createHash, etc.
|
|
35
|
-
global.crypto = react_native_quick_crypto_1.default;
|
|
36
|
-
}
|
|
37
|
-
// If `crypto.subtle` is missing, patch it with `@peculiar/webcrypto`
|
|
38
|
-
if (!global.crypto.subtle) {
|
|
39
|
-
const peculiarCrypto = new webcrypto_1.Crypto();
|
|
40
|
-
global.crypto.subtle = peculiarCrypto.subtle;
|
|
41
|
-
global.crypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
|
|
42
|
-
}
|
|
43
|
-
// Add getRandomValues to webcrypto from peculiar
|
|
44
|
-
const peculiarCrypto = new webcrypto_1.Crypto();
|
|
45
|
-
crypto_1.webcrypto.getRandomValues = peculiarCrypto.getRandomValues.bind(peculiarCrypto);
|
|
46
|
-
// 2) Provide TextEncoder / TextDecoder
|
|
47
|
-
const FSTED = __importStar(require("fastestsmallesttextencoderdecoder"));
|
|
48
|
-
if (typeof global.TextEncoder === 'undefined') {
|
|
49
|
-
global.TextEncoder = FSTED.TextEncoder;
|
|
50
|
-
}
|
|
51
|
-
if (typeof global.TextDecoder === 'undefined') {
|
|
52
|
-
global.TextDecoder = FSTED.TextDecoder;
|
|
53
|
-
}
|
|
54
|
-
// 3) Provide atob / btoa via react-native-quick-base64
|
|
55
|
-
const react_native_quick_base64_1 = require("react-native-quick-base64");
|
|
56
|
-
if (typeof global.atob === 'undefined') {
|
|
57
|
-
global.atob = react_native_quick_base64_1.atob;
|
|
58
|
-
}
|
|
59
|
-
if (typeof global.btoa === 'undefined') {
|
|
60
|
-
global.btoa = react_native_quick_base64_1.btoa;
|
|
61
|
-
}
|
|
62
|
-
// 4) Patch node-forge with react-native-modpow for faster RSA ops
|
|
63
|
-
const node_forge_1 = __importDefault(require("node-forge"));
|
|
64
|
-
const react_native_modpow_1 = __importDefault(require("react-native-modpow"));
|
|
65
|
-
node_forge_1.default.jsbn.BigInteger.prototype.modPow = function nativeModPow(e, m) {
|
|
66
|
-
const result = (0, react_native_modpow_1.default)({
|
|
67
|
-
target: this.toString(16),
|
|
68
|
-
value: e.toString(16),
|
|
69
|
-
modifier: m.toString(16),
|
|
70
|
-
});
|
|
71
|
-
return new node_forge_1.default.jsbn.BigInteger(result, 16);
|
|
72
|
-
};
|
|
73
|
-
// 5) Provide global Buffer
|
|
74
|
-
const react_native_buffer_1 = require("@craftzdog/react-native-buffer");
|
|
75
|
-
if (typeof global.Buffer === 'undefined') {
|
|
76
|
-
global.Buffer = react_native_buffer_1.Buffer;
|
|
77
|
-
}
|
|
78
|
-
// 6) React Native URL polyfill
|
|
79
|
-
require("react-native-url-polyfill/auto");
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { StorageUtils } from '@getpara/web-sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Implements `StorageUtils` using React Native Async Storage.
|
|
4
|
-
*/
|
|
5
|
-
export declare class AsyncStorage implements StorageUtils {
|
|
6
|
-
clear(prefix: string): Promise<void>;
|
|
7
|
-
get(key: string): Promise<string | null>;
|
|
8
|
-
removeItem(key: string): Promise<void>;
|
|
9
|
-
set(key: string, value: string): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { StorageUtils } from '@getpara/web-sdk';
|
|
2
|
-
/**
|
|
3
|
-
* Implements `StorageUtils` using React Native `Keychain`.
|
|
4
|
-
*/
|
|
5
|
-
export declare class KeychainStorage implements StorageUtils {
|
|
6
|
-
get(key: string): Promise<string | null>;
|
|
7
|
-
set(key: string, value: string): Promise<void>;
|
|
8
|
-
removeItem(key: string): Promise<void>;
|
|
9
|
-
clear(prefix: string): Promise<void>;
|
|
10
|
-
}
|
package/dist/esm/config.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Environment } from '@getpara/web-sdk';
|
|
2
|
-
export declare function getBaseMPCNetworkWSUrl(env: Environment): string;
|
|
3
|
-
export declare let userManagementServer: string;
|
|
4
|
-
export declare let portalBase: string;
|
|
5
|
-
export declare let mpcNetworkWSServer: string;
|
|
6
|
-
export declare function setEnv(env: Environment): void;
|
|
7
|
-
export declare const DEBUG_MODE_ENABLED = false;
|
package/dist/esm/index.d.ts
DELETED
package/dist/esm/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ConstructorOpts, ParaCore, Environment, PlatformUtils } from '@getpara/web-sdk';
|
|
2
|
-
import { Auth } from '@getpara/user-management-client';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a mobile implementation of the Para SDK.
|
|
5
|
-
* @extends ParaCore
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const para = new ParaMobile(Environment.BETA, "api_key");
|
|
9
|
-
*/
|
|
10
|
-
export declare class ParaMobile extends ParaCore {
|
|
11
|
-
private relyingPartyId;
|
|
12
|
-
/**
|
|
13
|
-
* Creates an instance of ParaMobile.
|
|
14
|
-
* @param {Environment} env - The environment to use (DEV, SANDBOX, BETA, or PROD).
|
|
15
|
-
* @param {string} [apiKey] - The API key for authentication.
|
|
16
|
-
* @param {string} [relyingPartyId] - The relying party ID for WebAuthn.
|
|
17
|
-
* @param {ConstructorOpts} [opts] - Additional constructor options.
|
|
18
|
-
*/
|
|
19
|
-
constructor(env: Environment, apiKey?: string, relyingPartyId?: string, opts?: ConstructorOpts);
|
|
20
|
-
protected getPlatformUtils(): PlatformUtils;
|
|
21
|
-
/**
|
|
22
|
-
* Verifies an email and returns the biometrics ID.
|
|
23
|
-
* @param {string} verificationCode - The verification code sent to the email.
|
|
24
|
-
* @returns {Promise<string>} The biometrics ID.
|
|
25
|
-
*/
|
|
26
|
-
verifyEmailBiometricsId({ verificationCode }: {
|
|
27
|
-
verificationCode: string;
|
|
28
|
-
}): Promise<string>;
|
|
29
|
-
/**
|
|
30
|
-
* Verifies a phone number and returns the biometrics ID.
|
|
31
|
-
* @param {string} verificationCode - The verification code sent to the phone.
|
|
32
|
-
* @returns {Promise<string>} The biometrics ID.
|
|
33
|
-
*/
|
|
34
|
-
verifyPhoneBiometricsId({ verificationCode }: {
|
|
35
|
-
verificationCode: string;
|
|
36
|
-
}): Promise<string>;
|
|
37
|
-
/**
|
|
38
|
-
* Registers a passkey for the user.
|
|
39
|
-
* @param {Auth<'email'> | Auth<'phone'>} auth - The user's authentication details
|
|
40
|
-
* @param {string} biometricsId - The biometrics ID obtained from verification.
|
|
41
|
-
* @returns {Promise<void>}
|
|
42
|
-
*/
|
|
43
|
-
registerPasskey({ biometricsId, ...auth }: {
|
|
44
|
-
biometricsId: string;
|
|
45
|
-
} & (Auth<'email'> | Auth<'phone'>)): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Logs in the user using their authentication credentials.
|
|
48
|
-
* @param {AuthParams} params - The authentication parameters.
|
|
49
|
-
* @returns {Promise<void>}
|
|
50
|
-
*/
|
|
51
|
-
login({ ...auth }: Auth<'email'> | Auth<'phone'>): Promise<void>;
|
|
52
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { PlatformUtils, TPregenIdentifierType } from '@getpara/web-sdk';
|
|
2
|
-
import { Ctx } from '@getpara/web-sdk';
|
|
3
|
-
import { SignatureRes } from '@getpara/web-sdk';
|
|
4
|
-
import { BackupKitEmailProps, WalletType } from '@getpara/user-management-client';
|
|
5
|
-
import { AsyncStorage } from '../AsyncStorage.js';
|
|
6
|
-
import { KeychainStorage } from '../KeychainStorage.js';
|
|
7
|
-
export declare class ReactNativeUtils implements PlatformUtils {
|
|
8
|
-
disableProviderModal?: boolean | undefined;
|
|
9
|
-
localStorage: AsyncStorage;
|
|
10
|
-
sessionStorage: AsyncStorage;
|
|
11
|
-
secureStorage: KeychainStorage;
|
|
12
|
-
isSyncStorage: boolean;
|
|
13
|
-
generateBlumPrimes(_ctx: Ctx): Promise<{
|
|
14
|
-
p: string;
|
|
15
|
-
q: string;
|
|
16
|
-
}>;
|
|
17
|
-
keygen(ctx: Ctx, userId: string, type: Exclude<WalletType, WalletType.SOLANA>, _secretKey: string | null, _sessionCookie: string, _emailProps?: BackupKitEmailProps | undefined): Promise<{
|
|
18
|
-
signer: string;
|
|
19
|
-
walletId: string;
|
|
20
|
-
}>;
|
|
21
|
-
refresh(_ctx: Ctx, _sessionCookie: string, _userId: string, _walletId: string, _share: string, _oldPartnerId?: string, _newPartnerId?: string): Promise<{
|
|
22
|
-
signer: string;
|
|
23
|
-
}>;
|
|
24
|
-
preKeygen(_ctx: Ctx, _partnerId: string, _email: string, _secretKey: string | null, _sessionCookie: string): Promise<{
|
|
25
|
-
signer: string;
|
|
26
|
-
walletId: string;
|
|
27
|
-
}>;
|
|
28
|
-
getPrivateKey(_ctx: Ctx, _userId: string, _walletId: string, _share: string, _sessionCookie: string): Promise<string>;
|
|
29
|
-
openPopup(_popupUrl: string): any;
|
|
30
|
-
private baseSignTransaction;
|
|
31
|
-
sendTransaction(ctx: Ctx, userId: string, walletId: string, share: string, rlpEncodedTxBase64: string, chainId: string, _sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
32
|
-
signHash(_address: string, _hash: string): Promise<{
|
|
33
|
-
v: number;
|
|
34
|
-
r: Buffer;
|
|
35
|
-
s: Buffer;
|
|
36
|
-
}>;
|
|
37
|
-
signMessage(ctx: Ctx, userId: string, walletId: string, share: string, messageBase64: string, // base64 message
|
|
38
|
-
_sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
39
|
-
signTransaction(ctx: Ctx, userId: string, walletId: string, share: string, rlpEncodedTxBase64: string, // base64 encoding of rlp encoded tx
|
|
40
|
-
chainId: string, _sessionCookie: string, isDKLS?: boolean): Promise<SignatureRes>;
|
|
41
|
-
ed25519Keygen(ctx: Ctx, userId: string, _sessionCookie: string, _emailProps?: BackupKitEmailProps): Promise<{
|
|
42
|
-
signer: string;
|
|
43
|
-
walletId: string;
|
|
44
|
-
}>;
|
|
45
|
-
ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pregenIdentifierType: TPregenIdentifierType, _sessionCookie: string): Promise<{
|
|
46
|
-
signer: string;
|
|
47
|
-
walletId: string;
|
|
48
|
-
}>;
|
|
49
|
-
ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, _sessionCookie: string): Promise<SignatureRes>;
|
|
50
|
-
}
|
package/dist/esm/shim.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|