@getpara/web-sdk 2.0.0-alpha.52 → 2.0.0-alpha.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "./chunk-WLGKV3EF.js";
2
+ import "./chunk-YJOFEY2L.js";
3
3
  class LocalStorage {
4
4
  constructor() {
5
5
  this.get = (key) => {
package/dist/ParaWeb.js CHANGED
@@ -3,10 +3,16 @@ import {
3
3
  __async,
4
4
  __privateAdd,
5
5
  __privateGet,
6
- __privateSet
7
- } from "./chunk-WLGKV3EF.js";
6
+ __privateSet,
7
+ __spreadValues
8
+ } from "./chunk-YJOFEY2L.js";
8
9
  var _isPasskeySupported;
9
- import ParaCore, { getNetworkPrefix } from "@getpara/core-sdk";
10
+ import ParaCore, {
11
+ dispatchEvent,
12
+ getNetworkPrefix,
13
+ OnRampPurchaseStatus,
14
+ ParaEvent
15
+ } from "@getpara/core-sdk";
10
16
  import { WebUtils } from "./WebUtils.js";
11
17
  import { isPasskeySupported } from "./utils/isPasskeySupported.js";
12
18
  import { offRampSend } from "./utils/offrampSend.js";
@@ -17,7 +23,7 @@ class Para extends ParaCore {
17
23
  this.isReady = false;
18
24
  this.isFarcasterMiniApp = false;
19
25
  this.portalEventListener = (event) => __async(this, null, function* () {
20
- var _a, _b, _c;
26
+ var _a, _b, _c, _d, _e, _f;
21
27
  if (!event.data.isPara || event.origin !== (yield this.getPortalURL()) || this.isPortal()) {
22
28
  return;
23
29
  }
@@ -32,10 +38,41 @@ class Para extends ParaCore {
32
38
  payload = { onRampPurchase: (_a = this.onRampPopup) == null ? void 0 : _a.onRampPurchase, onRampConfig };
33
39
  }
34
40
  break;
41
+ case "ONRAMPS__UPDATE_PURCHASE":
42
+ {
43
+ const { updates, depositRequest } = event.data.payload;
44
+ if ((_b = this.onRampPopup) == null ? void 0 : _b.onRampPurchase) {
45
+ this.onRampPopup.onRampPurchase = __spreadValues(__spreadValues({}, (_c = this.onRampPopup) == null ? void 0 : _c.onRampPurchase), updates);
46
+ const onRampPurchase = this.onRampPopup.onRampPurchase;
47
+ if (onRampPurchase.status === OnRampPurchaseStatus.FINISHED) {
48
+ const wallet = this.findWallet((_d = onRampPurchase.externalWalletAddress) != null ? _d : onRampPurchase.walletId);
49
+ if (wallet) {
50
+ const { asset, assetQuantity, network, address } = onRampPurchase;
51
+ if (depositRequest) {
52
+ const { chainId, contractAddress, destinationAddress } = depositRequest;
53
+ dispatchEvent(ParaEvent.ASSET_TRANSFERRED, {
54
+ wallet,
55
+ type: "OUTBOUND",
56
+ asset,
57
+ network,
58
+ quantity: assetQuantity,
59
+ chainId,
60
+ contractAddress,
61
+ sourceAddress: address,
62
+ destinationAddress
63
+ });
64
+ }
65
+ dispatchEvent(ParaEvent.ONRAMP_TRANSACTION_COMPLETE, onRampPurchase);
66
+ }
67
+ }
68
+ payload = { onRampPurchase };
69
+ }
70
+ }
71
+ break;
35
72
  case "ONRAMPS__SIGN_MOONPAY_URL":
36
73
  {
37
74
  const { url } = event.data.payload;
38
- const onRampPurchase = (_b = this.onRampPopup) == null ? void 0 : _b.onRampPurchase;
75
+ const onRampPurchase = (_e = this.onRampPopup) == null ? void 0 : _e.onRampPurchase;
39
76
  const res = yield this.ctx.client.signMoonPayUrl(userId, {
40
77
  url,
41
78
  type: onRampPurchase.walletType,
@@ -47,16 +84,18 @@ class Para extends ParaCore {
47
84
  payload = { signature: res.data.signature };
48
85
  }
49
86
  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;
87
+ case "ONRAMPS__SIGN_DEPOSIT_TX":
88
+ {
89
+ const { depositRequest } = event.data.payload;
90
+ const onRampPurchase = (_f = this.onRampPopup) == null ? void 0 : _f.onRampPurchase;
91
+ try {
92
+ const { txHash, updatedOnRampPurchase } = yield offRampSend(this, onRampPurchase, depositRequest);
93
+ payload = { onRampPurchase: updatedOnRampPurchase, txHash };
94
+ } catch (e) {
95
+ throw e;
96
+ }
58
97
  }
59
- }
98
+ break;
60
99
  }
61
100
  } catch (e) {
62
101
  status = "ERROR";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "./chunk-WLGKV3EF.js";
2
+ import "./chunk-YJOFEY2L.js";
3
3
  class SessionStorage {
4
4
  constructor() {
5
5
  this.get = (key) => {
package/dist/WebUtils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "./chunk-WLGKV3EF.js";
4
+ } from "./chunk-YJOFEY2L.js";
5
5
  import { PopupType } from "@getpara/core-sdk";
6
6
  import { LocalStorage } from "./LocalStorage.js";
7
7
  import { SessionStorage } from "./SessionStorage.js";
@@ -1,7 +1,23 @@
1
1
  "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
2
6
  var __typeError = (msg) => {
3
7
  throw TypeError(msg);
4
8
  };
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
5
21
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
22
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
23
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
@@ -28,6 +44,7 @@ var __async = (__this, __arguments, generator) => {
28
44
  };
29
45
 
30
46
  export {
47
+ __spreadValues,
31
48
  __privateGet,
32
49
  __privateAdd,
33
50
  __privateSet,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import base64url from "base64url";
6
6
  import * as cbor from "cbor-web";
7
7
  import forge from "node-forge";
package/dist/errors.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "./chunk-WLGKV3EF.js";
2
+ import "./chunk-YJOFEY2L.js";
3
3
  class TransactionReviewError extends Error {
4
4
  constructor(transactionReviewUrl) {
5
5
  super("transaction review error");
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from '@getpara/core-sdk';
2
2
  import { Para as ParaWeb } from './ParaWeb.js';
3
3
  import ParaCore from '@getpara/core-sdk';
4
- export { type StorageUtils, type ConstructorOpts, Environment, type OnRampConfig, type OnRampAllowedAssets, } from '@getpara/core-sdk';
4
+ export { type StorageUtils, type ConstructorOpts, Environment, type OnRampConfig, type OnRampAssets, } from '@getpara/core-sdk';
5
5
  export { createCredential, generateSignature, parseCredentialCreationRes } from './cryptography/webAuth.js';
6
6
  export { truncateEthAddress, isPasskeySupported, offRampSend } from './utils/index.js';
7
7
  export * from './utils/isMobile.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "./chunk-WLGKV3EF.js";
2
+ import "./chunk-YJOFEY2L.js";
3
3
  export * from "@getpara/core-sdk";
4
4
  import { Para as ParaWeb } from "./ParaWeb.js";
5
5
  import ParaCore from "@getpara/core-sdk";
@@ -1,13 +1,10 @@
1
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
- };
2
+ import { OfframpDepositRequest } from '@getpara/core-sdk';
7
3
  export type PortalMessageType = 'ONRAMPS__INIT' | 'ONRAMPS__UPDATE_PURCHASE' | 'ONRAMPS__SIGN_MOONPAY_URL' | 'ONRAMPS__SIGN_DEPOSIT_TX';
8
4
  export type PortalMessageStatus = 'ERROR' | 'SUCCESS';
9
5
  export type PortalRequestPayload<T extends PortalMessageType> = T extends 'ONRAMPS__UPDATE_PURCHASE' ? {
10
6
  updates: OnRampPurchaseUpdateParams;
7
+ depositRequest?: OfframpDepositRequest;
11
8
  } : T extends 'ONRAMPS__SIGN_MOONPAY_URL' ? {
12
9
  url: string;
13
10
  } : T extends 'ONRAMPS__SIGN_DEPOSIT_TX' ? {
@@ -54,6 +51,10 @@ export type PortalResponse = {
54
51
  status: 'SUCCESS';
55
52
  type: 'ONRAMPS__INIT';
56
53
  payload: PortalResponsePayload<'ONRAMPS__INIT'>;
54
+ } | {
55
+ status: 'SUCCESS';
56
+ type: 'ONRAMPS__UPDATE_PURCHASE';
57
+ payload: PortalResponsePayload<'ONRAMPS__UPDATE_PURCHASE'>;
57
58
  } | {
58
59
  status: 'SUCCESS';
59
60
  type: 'ONRAMPS__SIGN_MOONPAY_URL';
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-WLGKV3EF.js";
2
+ import "../chunk-YJOFEY2L.js";
3
3
  function getMailtoLink(email, recoveryShare) {
4
4
  const emailBody = `Hello,%0D%0DBelow is your Para Recovery Secret. Keep this safe!%0D%0D${recoveryShare}%0D%0DPlease get in touch via support@getpara.com if you have any questions`;
5
5
  const mailText = `mailto:${email}?subject=Para%20Recovery%20Secret&body=${emailBody}`;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-WLGKV3EF.js";
2
+ import "../chunk-YJOFEY2L.js";
3
3
  function hexStringToBase64(hexString) {
4
4
  if (hexString.substring(0, 2) === "0x") {
5
5
  hexString = hexString.substring(2);
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-WLGKV3EF.js";
2
+ import "../chunk-YJOFEY2L.js";
3
3
  function isAndroid() {
4
4
  return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import { UAParser } from "ua-parser-js";
6
6
  const isPasskeySupported = (userAgent) => __async(void 0, null, function* () {
7
7
  var _a, _b, _c;
@@ -1,5 +1,4 @@
1
- import Para, { OnRampPurchase } from '@getpara/core-sdk';
2
- import { OfframpDepositRequest } from '../types/index.js';
1
+ import Para, { OfframpDepositRequest, OnRampPurchase } from '@getpara/core-sdk';
3
2
  export declare function offRampSend(para: Para, { id: purchaseId, provider, walletId, walletType, address, testMode }: Partial<OnRampPurchase>, { assetQuantity, fiat, fiatQuantity, chainId, destinationAddress, contractAddress }: OfframpDepositRequest): Promise<{
4
3
  txHash: string;
5
4
  updatedOnRampPurchase: OnRampPurchase;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import { hexStringToBase64 } from "@getpara/core-sdk";
6
6
  function offRampSend(_0, _1, _2) {
7
7
  return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, { assetQuantity, fiat, fiatQuantity, chainId, destinationAddress, contractAddress }) {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-WLGKV3EF.js";
2
+ import "../chunk-YJOFEY2L.js";
3
3
  const truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/;
4
4
  const truncateEthAddress = (address) => {
5
5
  const match = address.match(truncateRegex);
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import { setupWorker } from "../workers/workerWrapper.js";
6
6
  import { distributeNewShare, waitUntilTrue } from "@getpara/core-sdk";
7
7
  import * as uuid from "uuid";
@@ -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,
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import { setupWorker } from "../workers/workerWrapper.js";
6
6
  import * as uuid from "uuid";
7
7
  function getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import { setupWorker } from "../workers/workerWrapper.js";
6
6
  import * as uuid from "uuid";
7
7
  function signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  (() => {
6
6
  const enosys = () => {
7
7
  const err = new Error("not implemented");
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import { getBaseMPCNetworkUrl } from "@getpara/core-sdk";
6
6
  import * as uuid from "uuid";
7
7
  const configCGGMPBase = (serverUrl, walletId, id) => `{"ServerUrl":"${serverUrl}", "WalletId": "${walletId}", "Id":"${id}", "Ids":["USER","CAPSULE"], "Threshold":1}`;
@@ -96,7 +96,8 @@ function executeMessage(ctx, message) {
96
96
  }
97
97
  case "GET_PRIVATE_KEY": {
98
98
  const { share, walletId, userId } = params;
99
- return yield walletUtils.getPrivateKey(ctx, share, walletId, userId);
99
+ const privateKey = yield walletUtils.getPrivateKey(ctx, share, walletId, userId);
100
+ return { privateKey };
100
101
  }
101
102
  case "ED25519_KEYGEN": {
102
103
  const { userId } = params;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-WLGKV3EF.js";
4
+ } from "../chunk-YJOFEY2L.js";
5
5
  import { getPortalBaseURL } from "@getpara/core-sdk";
6
6
  import { handleMessage } from "./worker.js";
7
7
  const CLEAR_WORKER_TIMEOUT_MS = 1e3 * 90;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@getpara/web-sdk",
3
- "version": "2.0.0-alpha.52",
3
+ "version": "2.0.0-alpha.54",
4
4
  "dependencies": {
5
- "@getpara/core-sdk": "2.0.0-alpha.52",
6
- "@getpara/user-management-client": "2.0.0-alpha.52",
5
+ "@getpara/core-sdk": "2.0.0-alpha.54",
6
+ "@getpara/user-management-client": "2.0.0-alpha.54",
7
7
  "base64url": "^3.0.1",
8
8
  "buffer": "6.0.3",
9
9
  "cbor-web": "^9.0.2",
@@ -28,7 +28,7 @@
28
28
  "dist",
29
29
  "package.json"
30
30
  ],
31
- "gitHead": "a63dba8c230e9ff2d73b275d3e40091b93aecf1c",
31
+ "gitHead": "680049700f7b36b7ef407cab0fbfadad8c069d74",
32
32
  "main": "dist/index.js",
33
33
  "scripts": {
34
34
  "build": "rm -rf dist && yarn typegen && node ./scripts/build.mjs && yarn post-build",