@getpara/web-sdk 2.0.0-dev.3 → 2.0.0-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/ParaWeb.d.ts +5 -2
- package/dist/ParaWeb.js +61 -9
- package/dist/WebUtils.d.ts +2 -1
- package/dist/WebUtils.js +62 -50
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/onRamp.d.ts +65 -0
- package/dist/types/onRamp.js +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/offrampSend.d.ts +6 -0
- package/dist/utils/offrampSend.js +67 -0
- package/dist/wallet/keygen.d.ts +1 -0
- package/dist/wallet/keygen.js +28 -1
- package/dist/workers/worker.js +12 -2
- package/package.json +4 -5
package/dist/ParaWeb.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import ParaCore, { ConstructorOpts, Environment } from '@getpara/core-sdk';
|
|
2
2
|
import { WebUtils } from './WebUtils.js';
|
|
3
|
+
import { PortalRequest } from './types/onRamp.js';
|
|
3
4
|
export declare class Para extends ParaCore {
|
|
4
5
|
#private;
|
|
5
6
|
farcasterSdk: any;
|
|
6
7
|
isReady: boolean;
|
|
7
8
|
isFarcasterMiniApp: boolean;
|
|
8
|
-
constructor(env: Environment, apiKey
|
|
9
|
-
|
|
9
|
+
constructor(env: Environment | undefined, apiKey: string, opts?: ConstructorOpts);
|
|
10
|
+
constructor(apiKey: string, opts?: ConstructorOpts);
|
|
11
|
+
ready(): Promise<void>;
|
|
12
|
+
protected portalEventListener: (event: MessageEvent<PortalRequest>) => Promise<void>;
|
|
10
13
|
protected get toStringAdditions(): {
|
|
11
14
|
isFarcasterMiniApp: boolean;
|
|
12
15
|
};
|
package/dist/ParaWeb.js
CHANGED
|
@@ -6,22 +6,74 @@ import {
|
|
|
6
6
|
__privateSet
|
|
7
7
|
} from "./chunk-WLGKV3EF.js";
|
|
8
8
|
var _isPasskeySupported;
|
|
9
|
-
import
|
|
10
|
-
import ParaCore, { Environment } from "@getpara/core-sdk";
|
|
9
|
+
import ParaCore, { getNetworkPrefix } from "@getpara/core-sdk";
|
|
11
10
|
import { WebUtils } from "./WebUtils.js";
|
|
12
11
|
import { isPasskeySupported } from "./utils/isPasskeySupported.js";
|
|
12
|
+
import { offRampSend } from "./utils/offrampSend.js";
|
|
13
13
|
class Para extends ParaCore {
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
14
|
+
constructor(envOrApiKey, apiKeyOrOpts, opts) {
|
|
15
|
+
super(envOrApiKey, apiKeyOrOpts, opts);
|
|
16
16
|
this.farcasterSdk = void 0;
|
|
17
17
|
this.isReady = false;
|
|
18
18
|
this.isFarcasterMiniApp = false;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
this.portalEventListener = (event) => __async(this, null, function* () {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
if (!event.data.isPara || event.origin !== (yield this.getPortalURL()) || this.isPortal()) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const messagePort = event.ports[0];
|
|
25
|
+
const userId = this.assertUserId();
|
|
26
|
+
let payload, status = "SUCCESS";
|
|
27
|
+
try {
|
|
28
|
+
switch (event.data.type) {
|
|
29
|
+
case "ONRAMPS__INIT":
|
|
30
|
+
{
|
|
31
|
+
const onRampConfig = yield this.ctx.client.getOnRampConfig();
|
|
32
|
+
payload = { onRampPurchase: (_a = this.onRampPopup) == null ? void 0 : _a.onRampPurchase, onRampConfig };
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
case "ONRAMPS__SIGN_MOONPAY_URL":
|
|
36
|
+
{
|
|
37
|
+
const { url } = event.data.payload;
|
|
38
|
+
const onRampPurchase = (_b = this.onRampPopup) == null ? void 0 : _b.onRampPurchase;
|
|
39
|
+
const res = yield this.ctx.client.signMoonPayUrl(userId, {
|
|
40
|
+
url,
|
|
41
|
+
type: onRampPurchase.walletType,
|
|
42
|
+
cosmosPrefix: getNetworkPrefix(onRampPurchase.network),
|
|
43
|
+
testMode: onRampPurchase.testMode,
|
|
44
|
+
walletId: onRampPurchase.walletId,
|
|
45
|
+
externalWalletAddress: onRampPurchase.externalWalletAddress
|
|
46
|
+
});
|
|
47
|
+
payload = { signature: res.data.signature };
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
case "ONRAMPS__SIGN_DEPOSIT_TX": {
|
|
51
|
+
const { depositRequest } = event.data.payload;
|
|
52
|
+
const onRampPurchase = (_c = this.onRampPopup) == null ? void 0 : _c.onRampPurchase;
|
|
53
|
+
try {
|
|
54
|
+
const { txHash, updatedOnRampPurchase } = yield offRampSend(this, onRampPurchase, depositRequest);
|
|
55
|
+
payload = { onRampPurchase: updatedOnRampPurchase, txHash };
|
|
56
|
+
} catch (e) {
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} catch (e) {
|
|
62
|
+
status = "ERROR";
|
|
63
|
+
payload = { error: e.message };
|
|
64
|
+
}
|
|
65
|
+
messagePort == null ? void 0 : messagePort.postMessage({
|
|
66
|
+
id: event.data.id,
|
|
67
|
+
type: event.data.type,
|
|
68
|
+
isPara: true,
|
|
69
|
+
status,
|
|
70
|
+
payload
|
|
24
71
|
});
|
|
72
|
+
messagePort == null ? void 0 : messagePort.close();
|
|
73
|
+
});
|
|
74
|
+
__privateAdd(this, _isPasskeySupported);
|
|
75
|
+
if (typeof window !== "undefined") {
|
|
76
|
+
window.addEventListener("message", this.portalEventListener);
|
|
25
77
|
}
|
|
26
78
|
}
|
|
27
79
|
ready() {
|
package/dist/WebUtils.d.ts
CHANGED
package/dist/WebUtils.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "./chunk-WLGKV3EF.js";
|
|
3
5
|
import { PopupType } from "@getpara/core-sdk";
|
|
4
6
|
import { LocalStorage } from "./LocalStorage.js";
|
|
5
7
|
import { SessionStorage } from "./SessionStorage.js";
|
|
6
|
-
import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen, refresh } from "./wallet/keygen.js";
|
|
8
|
+
import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen, refresh, initializeWorker } from "./wallet/keygen.js";
|
|
7
9
|
import { signMessage, sendTransaction, signTransaction, ed25519Sign } from "./wallet/signing.js";
|
|
8
10
|
import { getPrivateKey } from "./wallet/privateKey.js";
|
|
9
11
|
class WebUtils {
|
|
@@ -49,60 +51,70 @@ class WebUtils {
|
|
|
49
51
|
return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie);
|
|
50
52
|
}
|
|
51
53
|
openPopup(popupUrl, opts) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
return __async(this, null, function* () {
|
|
55
|
+
if (typeof window === "undefined") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let popupWindow = null;
|
|
59
|
+
if (opts) {
|
|
60
|
+
const { type } = opts;
|
|
61
|
+
const popUpWidth = 550;
|
|
62
|
+
let popUpHeight;
|
|
63
|
+
switch (type) {
|
|
64
|
+
case PopupType.LOGIN_PASSKEY: {
|
|
65
|
+
popUpHeight = 798;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case PopupType.CREATE_PASSKEY: {
|
|
69
|
+
popUpHeight = 464;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case PopupType.SIGN_MESSAGE_REVIEW: {
|
|
73
|
+
popUpHeight = 585;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case PopupType.SIGN_TRANSACTION_REVIEW: {
|
|
77
|
+
popUpHeight = 750;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case PopupType.OAUTH:
|
|
81
|
+
default: {
|
|
82
|
+
popUpHeight = 768;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
71
85
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
const dualScreenLeft = window.screenLeft !== void 0 ? window.screenLeft : window.screenX;
|
|
87
|
+
const dualScreenTop = window.screenTop !== void 0 ? window.screenTop : window.screenY;
|
|
88
|
+
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
|
|
89
|
+
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
|
|
90
|
+
const left = (width - popUpWidth) / 2 + dualScreenLeft;
|
|
91
|
+
const top = (height - popUpHeight) / 2 + dualScreenTop;
|
|
92
|
+
const windowFeatures = `toolbar=no, menubar=no, width=${popUpWidth},
|
|
93
|
+
height=${popUpHeight}, top=${top}, left=${left}`;
|
|
94
|
+
popupWindow = window.open(popupUrl, type.toString(), windowFeatures);
|
|
95
|
+
if (!popupWindow) {
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
popupWindow = window.open(popupUrl, "_blank");
|
|
98
|
+
}, 0);
|
|
75
99
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
100
|
+
} else {
|
|
101
|
+
popupWindow = window.open(popupUrl, "popup", "popup=true,width=400,height=500");
|
|
102
|
+
if (!popupWindow) {
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
popupWindow = window.open(popupUrl, "_blank");
|
|
105
|
+
}, 0);
|
|
80
106
|
}
|
|
81
107
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
|
|
85
|
-
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
|
|
86
|
-
const left = (width - popUpWidth) / 2 + dualScreenLeft;
|
|
87
|
-
const top = (height - popUpHeight) / 2 + dualScreenTop;
|
|
88
|
-
const windowFeatures = `toolbar=no, menubar=no, width=${popUpWidth},
|
|
89
|
-
height=${popUpHeight}, top=${top}, left=${left}`;
|
|
90
|
-
let popupWindow = window.open(popupUrl, type.toString(), windowFeatures);
|
|
91
|
-
if (!popupWindow) {
|
|
92
|
-
setTimeout(() => {
|
|
93
|
-
popupWindow = window.open(popupUrl, "_blank");
|
|
94
|
-
}, 0);
|
|
95
|
-
}
|
|
96
|
-
return popupWindow;
|
|
97
|
-
} else {
|
|
98
|
-
const popupWindow = window.open(popupUrl, "popup", "popup=true,width=400,height=500");
|
|
99
|
-
if (!popupWindow) {
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
window.open(popupUrl, "_blank");
|
|
102
|
-
}, 0);
|
|
108
|
+
while (!popupWindow) {
|
|
109
|
+
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
103
110
|
}
|
|
104
111
|
return popupWindow;
|
|
105
|
-
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
initializeWorker(ctx) {
|
|
115
|
+
return __async(this, null, function* () {
|
|
116
|
+
return initializeWorker(ctx);
|
|
117
|
+
});
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
120
|
export {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Para as ParaWeb } from './ParaWeb.js';
|
|
|
3
3
|
import ParaCore from '@getpara/core-sdk';
|
|
4
4
|
export { type StorageUtils, type ConstructorOpts, Environment, type OnRampConfig, type OnRampAllowedAssets, } from '@getpara/core-sdk';
|
|
5
5
|
export { createCredential, generateSignature, parseCredentialCreationRes } from './cryptography/webAuth.js';
|
|
6
|
-
export { truncateEthAddress } from './utils/
|
|
7
|
-
export { isPasskeySupported } from './utils/isPasskeySupported.js';
|
|
6
|
+
export { truncateEthAddress, isPasskeySupported, offRampSend } from './utils/index.js';
|
|
8
7
|
export * from './utils/isMobile.js';
|
|
8
|
+
export * from './types/index.js';
|
|
9
9
|
export { ParaWeb, ParaCore };
|
|
10
10
|
export default ParaWeb;
|
package/dist/index.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
Environment
|
|
8
8
|
} from "@getpara/core-sdk";
|
|
9
9
|
import { createCredential, generateSignature, parseCredentialCreationRes } from "./cryptography/webAuth.js";
|
|
10
|
-
import { truncateEthAddress } from "./utils/
|
|
11
|
-
import { isPasskeySupported } from "./utils/isPasskeySupported.js";
|
|
10
|
+
import { truncateEthAddress, isPasskeySupported, offRampSend } from "./utils/index.js";
|
|
12
11
|
export * from "./utils/isMobile.js";
|
|
12
|
+
export * from "./types/index.js";
|
|
13
13
|
var src_default = ParaWeb;
|
|
14
14
|
export {
|
|
15
15
|
Environment,
|
|
@@ -19,6 +19,7 @@ export {
|
|
|
19
19
|
src_default as default,
|
|
20
20
|
generateSignature,
|
|
21
21
|
isPasskeySupported,
|
|
22
|
+
offRampSend,
|
|
22
23
|
parseCredentialCreationRes,
|
|
23
24
|
truncateEthAddress
|
|
24
25
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './onRamp.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { OnRampConfig, OnRampPurchase, OnRampPurchaseUpdateParams } from '@getpara/user-management-client';
|
|
2
|
+
export type OfframpDepositRequest = OnRampPurchaseUpdateParams & {
|
|
3
|
+
chainId?: string;
|
|
4
|
+
destinationAddress: string;
|
|
5
|
+
contractAddress?: string | null;
|
|
6
|
+
};
|
|
7
|
+
export type PortalMessageType = 'ONRAMPS__INIT' | 'ONRAMPS__UPDATE_PURCHASE' | 'ONRAMPS__SIGN_MOONPAY_URL' | 'ONRAMPS__SIGN_DEPOSIT_TX';
|
|
8
|
+
export type PortalMessageStatus = 'ERROR' | 'SUCCESS';
|
|
9
|
+
export type PortalRequestPayload<T extends PortalMessageType> = T extends 'ONRAMPS__UPDATE_PURCHASE' ? {
|
|
10
|
+
updates: OnRampPurchaseUpdateParams;
|
|
11
|
+
} : T extends 'ONRAMPS__SIGN_MOONPAY_URL' ? {
|
|
12
|
+
url: string;
|
|
13
|
+
} : T extends 'ONRAMPS__SIGN_DEPOSIT_TX' ? {
|
|
14
|
+
depositRequest: OfframpDepositRequest;
|
|
15
|
+
} : never;
|
|
16
|
+
export type PortalRequest = {
|
|
17
|
+
isPara: boolean;
|
|
18
|
+
id: string;
|
|
19
|
+
status?: undefined;
|
|
20
|
+
} & ({
|
|
21
|
+
type: 'ONRAMPS__INIT';
|
|
22
|
+
payload?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'ONRAMPS__UPDATE_PURCHASE';
|
|
25
|
+
payload: PortalRequestPayload<'ONRAMPS__UPDATE_PURCHASE'>;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'ONRAMPS__SIGN_MOONPAY_URL';
|
|
28
|
+
payload: PortalRequestPayload<'ONRAMPS__SIGN_MOONPAY_URL'>;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'ONRAMPS__SIGN_DEPOSIT_TX';
|
|
31
|
+
payload: PortalRequestPayload<'ONRAMPS__SIGN_DEPOSIT_TX'>;
|
|
32
|
+
});
|
|
33
|
+
export type PortalResponsePayload<T extends PortalMessageType> = T extends 'ONRAMPS__INIT' ? {
|
|
34
|
+
onRampPurchase: OnRampPurchase;
|
|
35
|
+
onRampConfig: OnRampConfig;
|
|
36
|
+
} : T extends 'ONRAMPS__UPDATE_PURCHASE' ? {
|
|
37
|
+
onRampPurchase: OnRampPurchase;
|
|
38
|
+
} : T extends 'ONRAMPS__SIGN_MOONPAY_URL' ? {
|
|
39
|
+
signature: string;
|
|
40
|
+
} : T extends 'ONRAMPS__SIGN_DEPOSIT_TX' ? {
|
|
41
|
+
txHash: string;
|
|
42
|
+
onRampPurchase: OnRampPurchase;
|
|
43
|
+
} : never;
|
|
44
|
+
export type PortalResponse = {
|
|
45
|
+
id: string;
|
|
46
|
+
status: PortalMessageStatus;
|
|
47
|
+
type: PortalMessageType;
|
|
48
|
+
} & ({
|
|
49
|
+
status: 'ERROR';
|
|
50
|
+
payload: {
|
|
51
|
+
error: string;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
status: 'SUCCESS';
|
|
55
|
+
type: 'ONRAMPS__INIT';
|
|
56
|
+
payload: PortalResponsePayload<'ONRAMPS__INIT'>;
|
|
57
|
+
} | {
|
|
58
|
+
status: 'SUCCESS';
|
|
59
|
+
type: 'ONRAMPS__SIGN_MOONPAY_URL';
|
|
60
|
+
payload: PortalResponsePayload<'ONRAMPS__SIGN_MOONPAY_URL'>;
|
|
61
|
+
} | {
|
|
62
|
+
status: 'SUCCESS';
|
|
63
|
+
type: 'ONRAMPS__SIGN_DEPOSIT_TX';
|
|
64
|
+
payload: PortalResponsePayload<'ONRAMPS__SIGN_DEPOSIT_TX'>;
|
|
65
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Para, { OnRampPurchase } from '@getpara/core-sdk';
|
|
2
|
+
import { OfframpDepositRequest } from '../types/index.js';
|
|
3
|
+
export declare function offRampSend(para: Para, { id: purchaseId, provider, walletId, walletType, address, testMode }: Partial<OnRampPurchase>, { assetQuantity, fiat, fiatQuantity, chainId, destinationAddress, contractAddress }: OfframpDepositRequest): Promise<{
|
|
4
|
+
txHash: string;
|
|
5
|
+
updatedOnRampPurchase: OnRampPurchase;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../chunk-WLGKV3EF.js";
|
|
5
|
+
import { hexStringToBase64 } from "@getpara/core-sdk";
|
|
6
|
+
function offRampSend(_0, _1, _2) {
|
|
7
|
+
return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, { assetQuantity, fiat, fiatQuantity, chainId, destinationAddress, contractAddress }) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
if (!purchaseId || !walletId || !walletType || !provider) {
|
|
10
|
+
throw new Error("Missing required fields");
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const { tx, message, network, asset } = yield para.ctx.client.generateOffRampTx(para.getUserId(), {
|
|
14
|
+
walletId,
|
|
15
|
+
walletType,
|
|
16
|
+
provider,
|
|
17
|
+
chainId,
|
|
18
|
+
destinationAddress,
|
|
19
|
+
sourceAddress: address,
|
|
20
|
+
contractAddress,
|
|
21
|
+
testMode,
|
|
22
|
+
assetQuantity
|
|
23
|
+
});
|
|
24
|
+
let signature;
|
|
25
|
+
switch (walletType) {
|
|
26
|
+
case "EVM":
|
|
27
|
+
signature = (_a = yield para.signTransaction({
|
|
28
|
+
walletId,
|
|
29
|
+
rlpEncodedTxBase64: hexStringToBase64(tx),
|
|
30
|
+
chainId
|
|
31
|
+
})) == null ? void 0 : _a.signature;
|
|
32
|
+
break;
|
|
33
|
+
case "SOLANA":
|
|
34
|
+
signature = (_b = yield para.signMessage({ walletId, messageBase64: message })) == null ? void 0 : _b.signature;
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(`Unsupported wallet type: ${walletType}`);
|
|
38
|
+
}
|
|
39
|
+
const { txHash } = yield para.ctx.client.sendOffRampTx(para.getUserId(), {
|
|
40
|
+
tx,
|
|
41
|
+
signature: walletType === "EVM" ? `0x${signature}` : signature,
|
|
42
|
+
sourceAddress: address,
|
|
43
|
+
network,
|
|
44
|
+
walletId,
|
|
45
|
+
walletType
|
|
46
|
+
});
|
|
47
|
+
const updatedOnRampPurchase = yield para.ctx.client.updateOnRampPurchase({
|
|
48
|
+
userId: para.getUserId(),
|
|
49
|
+
walletId,
|
|
50
|
+
purchaseId,
|
|
51
|
+
updates: {
|
|
52
|
+
fiat,
|
|
53
|
+
fiatQuantity,
|
|
54
|
+
assetQuantity,
|
|
55
|
+
network,
|
|
56
|
+
asset
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return { txHash, updatedOnRampPurchase };
|
|
60
|
+
} catch (e) {
|
|
61
|
+
throw new Error(((_c = e.response) == null ? void 0 : _c.data) || e.message);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
offRampSend
|
|
67
|
+
};
|
package/dist/wallet/keygen.d.ts
CHANGED
package/dist/wallet/keygen.js
CHANGED
|
@@ -48,7 +48,10 @@ function keygen(ctx, userId, type, secretKey, skipDistribute = false, sessionCoo
|
|
|
48
48
|
userId,
|
|
49
49
|
walletId: res.walletId,
|
|
50
50
|
userShare: res.signer,
|
|
51
|
-
emailProps
|
|
51
|
+
emailProps,
|
|
52
|
+
isEnclaveUser: false,
|
|
53
|
+
walletScheme: "DKLS"
|
|
54
|
+
// since `isEnclaveUser` is false, we can use `DKLS` here as it won't be used
|
|
52
55
|
});
|
|
53
56
|
resolve({
|
|
54
57
|
signer: res.signer,
|
|
@@ -241,9 +244,33 @@ function ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCo
|
|
|
241
244
|
});
|
|
242
245
|
}));
|
|
243
246
|
}
|
|
247
|
+
function initializeWorker(ctx) {
|
|
248
|
+
return __async(this, null, function* () {
|
|
249
|
+
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
250
|
+
const workId = uuid.v4();
|
|
251
|
+
const worker = yield setupWorker(
|
|
252
|
+
ctx,
|
|
253
|
+
() => __async(this, null, function* () {
|
|
254
|
+
resolve();
|
|
255
|
+
}),
|
|
256
|
+
(error) => {
|
|
257
|
+
reject(error);
|
|
258
|
+
},
|
|
259
|
+
workId
|
|
260
|
+
);
|
|
261
|
+
worker.postMessage({
|
|
262
|
+
env: ctx.env,
|
|
263
|
+
apiKey: ctx.apiKey,
|
|
264
|
+
functionType: "INIT",
|
|
265
|
+
workId
|
|
266
|
+
});
|
|
267
|
+
}));
|
|
268
|
+
});
|
|
269
|
+
}
|
|
244
270
|
export {
|
|
245
271
|
ed25519Keygen,
|
|
246
272
|
ed25519PreKeygen,
|
|
273
|
+
initializeWorker,
|
|
247
274
|
keygen,
|
|
248
275
|
preKeygen,
|
|
249
276
|
refresh
|
package/dist/workers/worker.js
CHANGED
|
@@ -20,7 +20,13 @@ var __async = (__this, __arguments, generator) => {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
import * as walletUtils from "./walletUtils.js";
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
getBaseMPCNetworkUrl,
|
|
25
|
+
getPortalBaseURL,
|
|
26
|
+
initClient,
|
|
27
|
+
mpcComputationClient,
|
|
28
|
+
paraVersion
|
|
29
|
+
} from "@getpara/core-sdk";
|
|
24
30
|
let wasmLoaded = false;
|
|
25
31
|
function loadWasm(ctx, wasmOverride) {
|
|
26
32
|
return __async(this, null, function* () {
|
|
@@ -45,6 +51,9 @@ function executeMessage(ctx, message) {
|
|
|
45
51
|
return __async(this, null, function* () {
|
|
46
52
|
const { functionType, params, returnObject } = message;
|
|
47
53
|
switch (functionType) {
|
|
54
|
+
case "INIT": {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
48
57
|
case "KEYGEN": {
|
|
49
58
|
const { userId, secretKey, type = "EVM" } = params;
|
|
50
59
|
const keygenRes = yield walletUtils.keygen(ctx, userId, type, secretKey);
|
|
@@ -171,6 +180,7 @@ function handleMessage(e, postMessage, useFetchAdapter) {
|
|
|
171
180
|
};
|
|
172
181
|
if (!wasmLoaded && (!ctx.offloadMPCComputationURL || ctx.useDKLS)) {
|
|
173
182
|
yield loadWasm(ctx, wasmOverride);
|
|
183
|
+
const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
|
|
174
184
|
if (globalThis.initWasm) {
|
|
175
185
|
yield new Promise(
|
|
176
186
|
(resolve, reject) => {
|
|
@@ -180,7 +190,7 @@ function handleMessage(e, postMessage, useFetchAdapter) {
|
|
|
180
190
|
reject(err);
|
|
181
191
|
}
|
|
182
192
|
resolve(result2);
|
|
183
|
-
});
|
|
193
|
+
}, serverUrl);
|
|
184
194
|
}
|
|
185
195
|
);
|
|
186
196
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/web-sdk",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.7",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/core-sdk": "2.0.0-dev.
|
|
6
|
-
"@getpara/user-management-client": "2.0.0-dev.
|
|
7
|
-
"@sentry/browser": "^9.1.0",
|
|
5
|
+
"@getpara/core-sdk": "2.0.0-dev.7",
|
|
6
|
+
"@getpara/user-management-client": "2.0.0-dev.7",
|
|
8
7
|
"base64url": "^3.0.1",
|
|
9
8
|
"buffer": "6.0.3",
|
|
10
9
|
"cbor-web": "^9.0.2",
|
|
@@ -29,7 +28,7 @@
|
|
|
29
28
|
"dist",
|
|
30
29
|
"package.json"
|
|
31
30
|
],
|
|
32
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "225cd3693edaab4dac81df7285956d2616e5717f",
|
|
33
32
|
"main": "dist/index.js",
|
|
34
33
|
"scripts": {
|
|
35
34
|
"build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",
|