@getpara/react-native-wallet 1.0.2-dev.5 → 1.0.2-dev.7
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/cjs/AsyncStorage.js +47 -0
- package/dist/cjs/KeychainStorage.js +78 -0
- package/dist/cjs/config.js +65 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{react-native → cjs/react-native}/ParaMobile.d.ts +3 -4
- package/dist/cjs/react-native/ParaMobile.js +258 -0
- package/dist/cjs/react-native/ReactNativeUtils.js +174 -0
- package/dist/cjs/shim.js +79 -0
- package/dist/esm/AsyncStorage.d.ts +10 -0
- package/dist/esm/KeychainStorage.d.ts +10 -0
- package/dist/esm/config.d.ts +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/react-native/ParaMobile.d.ts +52 -0
- package/dist/{react-native → esm/react-native}/ParaMobile.js +19 -5
- package/dist/esm/react-native/ReactNativeUtils.d.ts +50 -0
- package/dist/esm/shim.d.ts +1 -0
- package/dist/{shim.js → esm/shim.js} +2 -0
- package/dist/types/AsyncStorage.d.ts +10 -0
- package/dist/types/KeychainStorage.d.ts +10 -0
- package/dist/types/config.d.ts +7 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/react-native/ParaMobile.d.ts +52 -0
- package/dist/types/react-native/ReactNativeUtils.d.ts +50 -0
- package/dist/types/shim.d.ts +1 -0
- package/package.json +18 -8
- package/src/react-native/ParaMobile.ts +8 -5
- package/src/shim.js +3 -0
- /package/dist/{AsyncStorage.d.ts → cjs/AsyncStorage.d.ts} +0 -0
- /package/dist/{KeychainStorage.d.ts → cjs/KeychainStorage.d.ts} +0 -0
- /package/dist/{config.d.ts → cjs/config.d.ts} +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{react-native → cjs/react-native}/ReactNativeUtils.d.ts +0 -0
- /package/dist/{shim.d.ts → cjs/shim.d.ts} +0 -0
- /package/dist/{AsyncStorage.js → esm/AsyncStorage.js} +0 -0
- /package/dist/{KeychainStorage.js → esm/KeychainStorage.js} +0 -0
- /package/dist/{config.js → esm/config.js} +0 -0
- /package/dist/{index.js → esm/index.d.ts} +0 -0
- /package/dist/{react-native → esm/react-native}/ReactNativeUtils.js +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AsyncStorage = void 0;
|
|
16
|
+
const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
17
|
+
/**
|
|
18
|
+
* Implements `StorageUtils` using React Native Async Storage.
|
|
19
|
+
*/
|
|
20
|
+
class AsyncStorage {
|
|
21
|
+
clear(prefix) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const keys = yield async_storage_1.default.getAllKeys();
|
|
24
|
+
for (const key of keys) {
|
|
25
|
+
if (key.startsWith(prefix)) {
|
|
26
|
+
yield async_storage_1.default.removeItem(key);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
get(key) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return async_storage_1.default.getItem(key);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
removeItem(key) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
yield async_storage_1.default.removeItem(key);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
set(key, value) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
yield async_storage_1.default.setItem(key, value);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.AsyncStorage = AsyncStorage;
|
|
@@ -0,0 +1,78 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.KeychainStorage = void 0;
|
|
16
|
+
const react_native_keychain_1 = __importDefault(require("react-native-keychain"));
|
|
17
|
+
const USERNAME = '@CAPSULE';
|
|
18
|
+
const KEYCHAIN_USER_CANCELLED_ERRORS = [
|
|
19
|
+
'user canceled the operation',
|
|
20
|
+
'error: code: 13, msg: cancel',
|
|
21
|
+
'error: code: 10, msg: fingerprint operation canceled by the user',
|
|
22
|
+
];
|
|
23
|
+
function isUserCancelledError(error) {
|
|
24
|
+
return KEYCHAIN_USER_CANCELLED_ERRORS.some(userCancelledError => error.toString().toLowerCase().includes(userCancelledError));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Implements `StorageUtils` using React Native `Keychain`.
|
|
28
|
+
*/
|
|
29
|
+
class KeychainStorage {
|
|
30
|
+
get(key) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
try {
|
|
33
|
+
const item = yield react_native_keychain_1.default.getGenericPassword({
|
|
34
|
+
service: key,
|
|
35
|
+
});
|
|
36
|
+
if (!item) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return item.password;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof Error && !isUserCancelledError(error)) {
|
|
43
|
+
// triggered when biometry verification fails and user cancels the action
|
|
44
|
+
throw new Error('Error retrieving stored item ' + error.message);
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
set(key, value) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const result = yield react_native_keychain_1.default.setGenericPassword(USERNAME, value, {
|
|
53
|
+
service: key,
|
|
54
|
+
accessible: react_native_keychain_1.default.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY,
|
|
55
|
+
securityLevel: react_native_keychain_1.default.SECURITY_LEVEL.ANY,
|
|
56
|
+
});
|
|
57
|
+
if (!result) {
|
|
58
|
+
throw new Error('Failed to store key ' + key);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
removeItem(key) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
yield react_native_keychain_1.default.resetGenericPassword({ service: key });
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
clear(prefix) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const services = yield react_native_keychain_1.default.getAllGenericPasswordServices();
|
|
70
|
+
for (const key of services) {
|
|
71
|
+
if (key && key.startsWith(prefix)) {
|
|
72
|
+
yield react_native_keychain_1.default.resetGenericPassword({ service: key });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.KeychainStorage = KeychainStorage;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEBUG_MODE_ENABLED = exports.mpcNetworkWSServer = exports.portalBase = exports.userManagementServer = void 0;
|
|
4
|
+
exports.getBaseMPCNetworkWSUrl = getBaseMPCNetworkWSUrl;
|
|
5
|
+
exports.setEnv = setEnv;
|
|
6
|
+
const react_native_1 = require("react-native");
|
|
7
|
+
const web_sdk_1 = require("@getpara/web-sdk");
|
|
8
|
+
function getPortalBaseURL(env) {
|
|
9
|
+
switch (env) {
|
|
10
|
+
case web_sdk_1.Environment.DEV:
|
|
11
|
+
return 'http://localhost:3003';
|
|
12
|
+
case web_sdk_1.Environment.SANDBOX:
|
|
13
|
+
return 'https://app.sandbox.usecapsule.com';
|
|
14
|
+
case web_sdk_1.Environment.BETA:
|
|
15
|
+
return 'https://app.beta.usecapsule.com';
|
|
16
|
+
case web_sdk_1.Environment.PROD:
|
|
17
|
+
return 'https://app.usecapsule.com';
|
|
18
|
+
default:
|
|
19
|
+
throw new Error(`env: ${env} not supported`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function getBaseUrl(env) {
|
|
23
|
+
switch (env) {
|
|
24
|
+
case web_sdk_1.Environment.DEV:
|
|
25
|
+
return 'http://localhost:8080/';
|
|
26
|
+
case web_sdk_1.Environment.SANDBOX:
|
|
27
|
+
return 'https://api.sandbox.getpara.com/';
|
|
28
|
+
case web_sdk_1.Environment.BETA:
|
|
29
|
+
return 'https://api.beta.getpara.com/';
|
|
30
|
+
case web_sdk_1.Environment.PROD:
|
|
31
|
+
return 'https://api.getpara.com/';
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`unsupported env: ${env}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function getBaseMPCNetworkWSUrl(env) {
|
|
37
|
+
switch (env) {
|
|
38
|
+
case web_sdk_1.Environment.DEV:
|
|
39
|
+
return `ws://localhost:3000`;
|
|
40
|
+
case web_sdk_1.Environment.SANDBOX:
|
|
41
|
+
return `wss://mpc-network.sandbox.getpara.com`;
|
|
42
|
+
case web_sdk_1.Environment.BETA:
|
|
43
|
+
return `wss://mpc-network.beta.getpara.com`;
|
|
44
|
+
case web_sdk_1.Environment.PROD:
|
|
45
|
+
return `wss://mpc-network.getpara.com`;
|
|
46
|
+
default:
|
|
47
|
+
throw new Error(`unsupported env: ${env}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.userManagementServer = getBaseUrl(web_sdk_1.Environment.BETA);
|
|
51
|
+
exports.portalBase = getPortalBaseURL(web_sdk_1.Environment.BETA);
|
|
52
|
+
exports.mpcNetworkWSServer = getBaseMPCNetworkWSUrl(web_sdk_1.Environment.BETA);
|
|
53
|
+
function setEnv(env) {
|
|
54
|
+
exports.userManagementServer = getBaseUrl(env);
|
|
55
|
+
exports.portalBase = getPortalBaseURL(env);
|
|
56
|
+
exports.mpcNetworkWSServer = getBaseMPCNetworkWSUrl(env);
|
|
57
|
+
init();
|
|
58
|
+
}
|
|
59
|
+
const { ParaSignerModule } = react_native_1.NativeModules;
|
|
60
|
+
exports.DEBUG_MODE_ENABLED = false;
|
|
61
|
+
function init() {
|
|
62
|
+
ParaSignerModule.setServerUrl(exports.userManagementServer);
|
|
63
|
+
ParaSignerModule.setWsServerUrl(exports.mpcNetworkWSServer);
|
|
64
|
+
}
|
|
65
|
+
init();
|
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ParaMobile = void 0;
|
|
18
|
+
__exportStar(require("@getpara/web-sdk"), exports);
|
|
19
|
+
var ParaMobile_js_1 = require("./react-native/ParaMobile.js");
|
|
20
|
+
Object.defineProperty(exports, "ParaMobile", { enumerable: true, get: function () { return ParaMobile_js_1.ParaMobile; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -40,14 +40,13 @@ export declare class ParaMobile extends ParaCore {
|
|
|
40
40
|
* @param {string} biometricsId - The biometrics ID obtained from verification.
|
|
41
41
|
* @returns {Promise<void>}
|
|
42
42
|
*/
|
|
43
|
-
registerPasskey({
|
|
44
|
-
auth: Auth<'email'> | Auth<'phone'>;
|
|
43
|
+
registerPasskey({ biometricsId, ...auth }: {
|
|
45
44
|
biometricsId: string;
|
|
46
|
-
}): Promise<void>;
|
|
45
|
+
} & (Auth<'email'> | Auth<'phone'>)): Promise<void>;
|
|
47
46
|
/**
|
|
48
47
|
* Logs in the user using their authentication credentials.
|
|
49
48
|
* @param {AuthParams} params - The authentication parameters.
|
|
50
49
|
* @returns {Promise<void>}
|
|
51
50
|
*/
|
|
52
|
-
login(auth: Auth<'email'> | Auth<'phone'>): Promise<void>;
|
|
51
|
+
login({ ...auth }: Auth<'email'> | Auth<'phone'>): Promise<void>;
|
|
53
52
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
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;
|
|
@@ -0,0 +1,174 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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");
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
}
|
|
@@ -7,10 +7,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
10
21
|
import { ParaCore, Environment, decryptPrivateKeyAndDecryptShare, encryptPrivateKey, getAsymmetricKeyPair, getDerivedPrivateKeyAndDecrypt, getPublicKeyHex, getSHA256HashHex, parseCredentialCreationRes, } from '@getpara/web-sdk';
|
|
11
22
|
import { ReactNativeUtils } from './ReactNativeUtils.js';
|
|
12
23
|
import { Passkey, } from 'react-native-passkey';
|
|
13
|
-
import { PublicKeyStatus } from '@getpara/user-management-client';
|
|
24
|
+
import { extractAuthInfo, PublicKeyStatus } from '@getpara/user-management-client';
|
|
14
25
|
import { setEnv } from '../config.js';
|
|
15
26
|
import base64url from 'base64url';
|
|
16
27
|
import { webcrypto } from 'crypto';
|
|
@@ -97,14 +108,15 @@ export class ParaMobile extends ParaCore {
|
|
|
97
108
|
* @returns {Promise<void>}
|
|
98
109
|
*/
|
|
99
110
|
registerPasskey(_a) {
|
|
100
|
-
return __awaiter(this,
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
var { biometricsId } = _a, auth = __rest(_a, ["biometricsId"]);
|
|
101
113
|
if (!webcrypto || !webcrypto.getRandomValues) {
|
|
102
114
|
throw new Error('Web crypto is not available. Ensure you have imported the shim from @getpara/react-native-wallet.');
|
|
103
115
|
}
|
|
104
116
|
const userHandle = new Uint8Array(32);
|
|
105
117
|
webcrypto.getRandomValues(userHandle);
|
|
106
118
|
const userHandleEncoded = base64url.encode(userHandle);
|
|
107
|
-
const displayIdentifier =
|
|
119
|
+
const { identifier: displayIdentifier } = extractAuthInfo(auth, { isRequired: true });
|
|
108
120
|
const requestJson = {
|
|
109
121
|
authenticatorSelection: {
|
|
110
122
|
authenticatorAttachment: 'platform',
|
|
@@ -164,10 +176,12 @@ export class ParaMobile extends ParaCore {
|
|
|
164
176
|
* @param {AuthParams} params - The authentication parameters.
|
|
165
177
|
* @returns {Promise<void>}
|
|
166
178
|
*/
|
|
167
|
-
login(
|
|
179
|
+
login(_a) {
|
|
168
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
var auth = __rest(_a, []);
|
|
169
182
|
yield this.logout();
|
|
170
|
-
const
|
|
183
|
+
const authInfo = extractAuthInfo(auth, { isRequired: true });
|
|
184
|
+
const { challenge, allowedPublicKeys } = yield this.ctx.client.getWebChallenge(authInfo.auth);
|
|
171
185
|
const requestJson = {
|
|
172
186
|
challenge,
|
|
173
187
|
timeout: 60000,
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-native-wallet",
|
|
3
|
-
"version": "1.0.2-dev.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"module": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "1.0.2-dev.7",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
10
7
|
"files": [
|
|
11
8
|
"dist",
|
|
12
9
|
"src",
|
|
@@ -17,8 +14,21 @@
|
|
|
17
14
|
"signer.xcframework",
|
|
18
15
|
"signer.aar"
|
|
19
16
|
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"react-native": "./dist/cjs/index.js",
|
|
20
|
+
"default": "./dist/esm/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./shim": {
|
|
23
|
+
"react-native": "./dist/cjs/shim.js",
|
|
24
|
+
"default": "./dist/esm/shim.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
20
27
|
"scripts": {
|
|
21
|
-
"build": "
|
|
28
|
+
"build": "yarn build:cjs && yarn build:esm && yarn build:types",
|
|
29
|
+
"build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
30
|
+
"build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && echo '{\"type\":\"module\"}' > dist/esm/package.json",
|
|
31
|
+
"build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration",
|
|
22
32
|
"compile-signer": "bash ./scripts/compileSigner.sh"
|
|
23
33
|
},
|
|
24
34
|
"dependencies": {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
PasskeyGetRequest,
|
|
21
21
|
PasskeyGetResult,
|
|
22
22
|
} from 'react-native-passkey';
|
|
23
|
-
import { Auth, PublicKeyStatus, WalletScheme } from '@getpara/user-management-client';
|
|
23
|
+
import { Auth, extractAuthInfo, 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';
|
|
@@ -105,7 +105,7 @@ export class ParaMobile extends ParaCore {
|
|
|
105
105
|
* @param {string} biometricsId - The biometrics ID obtained from verification.
|
|
106
106
|
* @returns {Promise<void>}
|
|
107
107
|
*/
|
|
108
|
-
async registerPasskey({
|
|
108
|
+
async registerPasskey({ biometricsId, ...auth }: { biometricsId: string } & (Auth<'email'> | Auth<'phone'>)) {
|
|
109
109
|
if (!webcrypto || !webcrypto.getRandomValues) {
|
|
110
110
|
throw new Error('Web crypto is not available. Ensure you have imported the shim from @getpara/react-native-wallet.');
|
|
111
111
|
}
|
|
@@ -113,7 +113,7 @@ export class ParaMobile extends ParaCore {
|
|
|
113
113
|
webcrypto.getRandomValues(userHandle);
|
|
114
114
|
const userHandleEncoded = base64url.encode(userHandle as any);
|
|
115
115
|
|
|
116
|
-
const displayIdentifier =
|
|
116
|
+
const { identifier: displayIdentifier } = extractAuthInfo(auth, { isRequired: true });
|
|
117
117
|
|
|
118
118
|
const requestJson: PasskeyCreateRequest = {
|
|
119
119
|
authenticatorSelection: {
|
|
@@ -185,9 +185,12 @@ export class ParaMobile extends ParaCore {
|
|
|
185
185
|
* @param {AuthParams} params - The authentication parameters.
|
|
186
186
|
* @returns {Promise<void>}
|
|
187
187
|
*/
|
|
188
|
-
async login(auth: Auth<'email'> | Auth<'phone'>): Promise<void> {
|
|
188
|
+
async login({ ...auth }: Auth<'email'> | Auth<'phone'>): Promise<void> {
|
|
189
189
|
await this.logout();
|
|
190
|
-
|
|
190
|
+
|
|
191
|
+
const authInfo = extractAuthInfo(auth, { isRequired: true });
|
|
192
|
+
|
|
193
|
+
const { challenge, allowedPublicKeys } = await this.ctx.client.getWebChallenge(authInfo.auth);
|
|
191
194
|
|
|
192
195
|
const requestJson: PasskeyGetRequest = {
|
|
193
196
|
challenge,
|
package/src/shim.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|