@getpara/web-sdk 2.0.0-alpha.5 → 2.0.0-alpha.51

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-M66XENHI.js";
2
+ import "./chunk-WLGKV3EF.js";
3
3
  class LocalStorage {
4
4
  constructor() {
5
5
  this.get = (key) => {
package/dist/ParaWeb.d.ts CHANGED
@@ -1,6 +1,18 @@
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
- constructor(env: Environment, apiKey?: string, opts?: ConstructorOpts);
5
+ #private;
6
+ farcasterSdk: any;
7
+ isReady: boolean;
8
+ isFarcasterMiniApp: boolean;
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>;
13
+ protected get toStringAdditions(): {
14
+ isFarcasterMiniApp: boolean;
15
+ };
5
16
  protected getPlatformUtils(): WebUtils;
17
+ isPasskeySupported(): Promise<boolean>;
6
18
  }
package/dist/ParaWeb.js CHANGED
@@ -1,22 +1,123 @@
1
1
  "use client";
2
- import "./chunk-M66XENHI.js";
3
- import * as Sentry from "@sentry/browser";
4
- import ParaCore, { Environment } from "@getpara/core-sdk";
2
+ import {
3
+ __async,
4
+ __privateAdd,
5
+ __privateGet,
6
+ __privateSet
7
+ } from "./chunk-WLGKV3EF.js";
8
+ var _isPasskeySupported;
9
+ import ParaCore, { getNetworkPrefix } from "@getpara/core-sdk";
5
10
  import { WebUtils } from "./WebUtils.js";
11
+ import { isPasskeySupported } from "./utils/isPasskeySupported.js";
12
+ import { offRampSend } from "./utils/offrampSend.js";
6
13
  class Para extends ParaCore {
7
- constructor(env, apiKey, opts) {
8
- super(env, apiKey, opts);
9
- if (env !== Environment.PROD && env !== Environment.DEV) {
10
- Sentry.init({
11
- environment: env.toLowerCase(),
12
- dsn: "https://38f27d4836da617ab9e95cf66b9611d9@o4504568036720640.ingest.us.sentry.io/4508850812944384"
14
+ constructor(envOrApiKey, apiKeyOrOpts, opts) {
15
+ super(envOrApiKey, apiKeyOrOpts, opts);
16
+ this.farcasterSdk = void 0;
17
+ this.isReady = false;
18
+ this.isFarcasterMiniApp = false;
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
13
71
  });
72
+ messagePort == null ? void 0 : messagePort.close();
73
+ });
74
+ __privateAdd(this, _isPasskeySupported);
75
+ if (typeof window !== "undefined") {
76
+ window.addEventListener("message", this.portalEventListener);
14
77
  }
15
78
  }
79
+ ready() {
80
+ return __async(this, null, function* () {
81
+ var _a, _b, _c, _d;
82
+ if (!this.isReady) {
83
+ try {
84
+ this.farcasterSdk = (_b = (_a = yield import("@farcaster/miniapp-sdk")) == null ? void 0 : _a.sdk) != null ? _b : void 0;
85
+ if (!((_c = this.farcasterSdk) == null ? void 0 : _c.isInMiniApp)) {
86
+ throw new Error("Farcaster SDK not detected or failed to load");
87
+ }
88
+ this.devLog("Farcaster SDK detected and loaded successfully.", this.farcasterSdk);
89
+ } catch (e) {
90
+ this.devLog(e);
91
+ }
92
+ if (!!((_d = this.farcasterSdk) == null ? void 0 : _d.isInMiniApp)) {
93
+ this.devLog("Initializing Farcaster SDK...");
94
+ this.isFarcasterMiniApp = yield this.farcasterSdk.isInMiniApp();
95
+ if (this.isFarcasterMiniApp) {
96
+ this.externalWalletConnectionOnly = true;
97
+ }
98
+ }
99
+ this.isReady = true;
100
+ }
101
+ });
102
+ }
103
+ get toStringAdditions() {
104
+ return {
105
+ isFarcasterMiniApp: this.isFarcasterMiniApp
106
+ };
107
+ }
16
108
  getPlatformUtils() {
17
109
  return new WebUtils();
18
110
  }
111
+ isPasskeySupported() {
112
+ return __async(this, null, function* () {
113
+ if (__privateGet(this, _isPasskeySupported) === void 0) {
114
+ __privateSet(this, _isPasskeySupported, yield isPasskeySupported());
115
+ }
116
+ return __privateGet(this, _isPasskeySupported);
117
+ });
118
+ }
19
119
  }
120
+ _isPasskeySupported = new WeakMap();
20
121
  export {
21
122
  Para
22
123
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "./chunk-M66XENHI.js";
2
+ import "./chunk-WLGKV3EF.js";
3
3
  class SessionStorage {
4
4
  constructor() {
5
5
  this.get = (key) => {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Ctx, PlatformUtils, SignatureRes, PopupType } from '@getpara/core-sdk';
3
2
  import { LocalStorage } from './LocalStorage.js';
4
3
  import { SessionStorage } from './SessionStorage.js';
@@ -44,5 +43,6 @@ export declare class WebUtils implements PlatformUtils {
44
43
  disableProviderModal: boolean;
45
44
  openPopup(popupUrl: string, opts?: {
46
45
  type: PopupType;
47
- }): Window;
46
+ }): Promise<Window>;
47
+ initializeWorker(ctx: Ctx): Promise<void>;
48
48
  }
package/dist/WebUtils.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use client";
2
- import "./chunk-M66XENHI.js";
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
- if (typeof window === "undefined") {
53
- return;
54
- }
55
- if (opts) {
56
- const { type } = opts;
57
- const popUpWidth = 550;
58
- let popUpHeight;
59
- switch (type) {
60
- case PopupType.LOGIN_PASSKEY: {
61
- popUpHeight = 798;
62
- break;
63
- }
64
- case PopupType.CREATE_PASSKEY: {
65
- popUpHeight = 464;
66
- break;
67
- }
68
- case PopupType.SIGN_MESSAGE_REVIEW: {
69
- popUpHeight = 585;
70
- break;
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
- case PopupType.SIGN_TRANSACTION_REVIEW: {
73
- popUpHeight = 750;
74
- break;
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
- case PopupType.OAUTH:
77
- default: {
78
- popUpHeight = 768;
79
- break;
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
- const dualScreenLeft = window.screenLeft !== void 0 ? window.screenLeft : window.screenX;
83
- const dualScreenTop = window.screenTop !== void 0 ? window.screenTop : window.screenY;
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 {
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
+ 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);
8
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
9
+ var __async = (__this, __arguments, generator) => {
10
+ return new Promise((resolve, reject) => {
11
+ var fulfilled = (value) => {
12
+ try {
13
+ step(generator.next(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ };
18
+ var rejected = (value) => {
19
+ try {
20
+ step(generator.throw(value));
21
+ } catch (e) {
22
+ reject(e);
23
+ }
24
+ };
25
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
26
+ step((generator = generator.apply(__this, __arguments)).next());
27
+ });
28
+ };
29
+
30
+ export {
31
+ __privateGet,
32
+ __privateAdd,
33
+ __privateSet,
34
+ __async
35
+ };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  __async
4
- } from "../chunk-M66XENHI.js";
4
+ } from "../chunk-WLGKV3EF.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-M66XENHI.js";
2
+ import "./chunk-WLGKV3EF.js";
3
3
  class TransactionReviewError extends Error {
4
4
  constructor(transactionReviewUrl) {
5
5
  super("transaction review error");
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/truncateEthAddress.js';
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
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "./chunk-M66XENHI.js";
2
+ import "./chunk-WLGKV3EF.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";
@@ -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/truncateEthAddress.js";
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,2 @@
1
+ "use client";
2
+ 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";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-M66XENHI.js";
2
+ import "../chunk-WLGKV3EF.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-M66XENHI.js";
2
+ import "../chunk-WLGKV3EF.js";
3
3
  function hexStringToBase64(hexString) {
4
4
  if (hexString.substring(0, 2) === "0x") {
5
5
  hexString = hexString.substring(2);
@@ -0,0 +1,5 @@
1
+ export * from './emailUtils.js';
2
+ export * from './formattingUtils.js';
3
+ export * from './isPasskeySupported.js';
4
+ export * from './offrampSend.js';
5
+ export * from './truncateEthAddress.js';
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ export * from "./emailUtils.js";
3
+ export * from "./formattingUtils.js";
4
+ export * from "./isPasskeySupported.js";
5
+ export * from "./offrampSend.js";
6
+ export * from "./truncateEthAddress.js";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-M66XENHI.js";
2
+ import "../chunk-WLGKV3EF.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-M66XENHI.js";
4
+ } from "../chunk-WLGKV3EF.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;
@@ -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
+ };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import "../chunk-M66XENHI.js";
2
+ import "../chunk-WLGKV3EF.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);
@@ -24,3 +24,4 @@ export declare function ed25519PreKeygen(ctx: Ctx, pregenIdentifier: string, pre
24
24
  walletId: string;
25
25
  recoveryShare: string | null;
26
26
  }>;
27
+ export declare function initializeWorker(ctx: Ctx): Promise<void>;