@frak-labs/core-sdk 0.0.4 → 0.0.5
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/cdn/bundle.js +18 -6
- package/dist/actions/index.cjs +65 -63
- package/dist/actions/index.d.cts +11 -13
- package/dist/actions/index.d.ts +11 -13
- package/dist/actions/index.js +42 -53
- package/dist/chunk-GDH3M5ZC.js +1 -8
- package/dist/{chunk-HDFNBQ4E.cjs → chunk-IVQL5N55.cjs} +62 -67
- package/dist/chunk-PO6YSB4Q.cjs +9 -9
- package/dist/chunk-RMOFMRZR.js +19 -41
- package/dist/{chunk-AFLVOY5H.js → chunk-XDZMP74U.js} +37 -56
- package/dist/chunk-ZDGHKI3S.cjs +40 -56
- package/dist/{context-BjKowynW.d.cts → context-C7RkT8hA.d.cts} +205 -23
- package/dist/{context-DjVVznrf.d.ts → context-CJ5ByAXa.d.ts} +205 -23
- package/dist/index.cjs +238 -68
- package/dist/index.d.cts +49 -67
- package/dist/index.d.ts +49 -67
- package/dist/index.js +164 -52
- package/dist/interactions/index.cjs +26 -15
- package/dist/interactions/index.js +1 -15
- package/package.json +10 -3
package/dist/actions/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FrakClient, W as WalletStatusReturnType, M as ModalStepTypes,
|
|
1
|
+
import { a as FrakClient, W as WalletStatusReturnType, M as ModalStepTypes, j as DisplayModalParamsType, l as ModalRpcStepsResultType, D as DisplayEmbededWalletParamsType, O as OpenSsoParamsType, G as GetProductInformationReturnType, q as SiweAuthenticationParams, h as ModalRpcMetadata, r as SiweAuthenticateReturnType, t as SendTransactionModalStepType, u as SendTransactionReturnType, x as FinalModalStepType, y as FinalActionType, n as LoginModalStepType, w as OpenInteractionSessionModalStepType, b as FrakContext } from '../context-C7RkT8hA.cjs';
|
|
2
2
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-CTQ5-kqe.cjs';
|
|
3
3
|
import { Hex } from 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
@@ -105,11 +105,6 @@ declare function sendInteraction(client: FrakClient, { productId, interaction, v
|
|
|
105
105
|
* ssoMetadata: {
|
|
106
106
|
* logoUrl: "https://my-app.com/logo.png",
|
|
107
107
|
* homepageLink: "https://my-app.com",
|
|
108
|
-
* links: {
|
|
109
|
-
* confidentialityLink: "https://my-app.com/confidentiality",
|
|
110
|
-
* helpLink: "https://my-app.com/help",
|
|
111
|
-
* cguLink: "https://my-app.com/cgu",
|
|
112
|
-
* },
|
|
113
108
|
* },
|
|
114
109
|
* metadata: {
|
|
115
110
|
* // Modal title on desktop
|
|
@@ -181,6 +176,13 @@ declare function sendInteraction(client: FrakClient, { productId, interaction, v
|
|
|
181
176
|
*/
|
|
182
177
|
declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: FrakClient, { steps, metadata }: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
|
|
183
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Function used to display the Frak embeded wallet popup
|
|
181
|
+
* @param client - The current Frak Client
|
|
182
|
+
* @param params - The parameter used to customise the embeded wallet
|
|
183
|
+
*/
|
|
184
|
+
declare function displayEmbededWallet(client: FrakClient, params: DisplayEmbededWalletParamsType): Promise<void>;
|
|
185
|
+
|
|
184
186
|
/**
|
|
185
187
|
* Function used to open the SSO
|
|
186
188
|
* @param client - The current Frak Client
|
|
@@ -195,11 +197,6 @@ declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(cli
|
|
|
195
197
|
* const metadata: SsoMetadata = {
|
|
196
198
|
* logoUrl: "https://my-app.com/logo.png",
|
|
197
199
|
* homepageLink: "https://my-app.com",
|
|
198
|
-
* links: {
|
|
199
|
-
* confidentialityLink: "https://my-app.com/confidentiality",
|
|
200
|
-
* helpLink: "https://my-app.com/help",
|
|
201
|
-
* cguLink: "https://my-app.com/cgu",
|
|
202
|
-
* },
|
|
203
200
|
* };
|
|
204
201
|
* ```
|
|
205
202
|
*
|
|
@@ -377,8 +374,9 @@ type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
|
377
374
|
}>["options"], options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
|
|
378
375
|
/**
|
|
379
376
|
* Display the modal
|
|
377
|
+
* @param metadataOverride - Function returning optional metadata to override the current modal metadata
|
|
380
378
|
*/
|
|
381
|
-
display: () => Promise<ModalRpcStepsResultType<Steps>>;
|
|
379
|
+
display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined) => Promise<ModalRpcStepsResultType<Steps>>;
|
|
382
380
|
};
|
|
383
381
|
/**
|
|
384
382
|
* Represent the output type of the modal builder
|
|
@@ -500,4 +498,4 @@ declare function referralInteraction(client: FrakClient, { productId, modalConfi
|
|
|
500
498
|
options?: ProcessReferralOptions;
|
|
501
499
|
}): Promise<("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral") | undefined>;
|
|
502
500
|
|
|
503
|
-
export { type ModalBuilder, type ModalStepBuilder, type ProcessReferralOptions, type SendTransactionParams, type SiweAuthenticateModalParams, displayModal, getProductInformation, modalBuilder, openSso, processReferral, referralInteraction, sendInteraction, sendTransaction, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
|
|
501
|
+
export { type ModalBuilder, type ModalStepBuilder, type ProcessReferralOptions, type SendTransactionParams, type SiweAuthenticateModalParams, displayEmbededWallet, displayModal, getProductInformation, modalBuilder, openSso, processReferral, referralInteraction, sendInteraction, sendTransaction, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FrakClient, W as WalletStatusReturnType, M as ModalStepTypes,
|
|
1
|
+
import { a as FrakClient, W as WalletStatusReturnType, M as ModalStepTypes, j as DisplayModalParamsType, l as ModalRpcStepsResultType, D as DisplayEmbededWalletParamsType, O as OpenSsoParamsType, G as GetProductInformationReturnType, q as SiweAuthenticationParams, h as ModalRpcMetadata, r as SiweAuthenticateReturnType, t as SendTransactionModalStepType, u as SendTransactionReturnType, x as FinalModalStepType, y as FinalActionType, n as LoginModalStepType, w as OpenInteractionSessionModalStepType, b as FrakContext } from '../context-CJ5ByAXa.js';
|
|
2
2
|
import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../interaction-CTQ5-kqe.js';
|
|
3
3
|
import { Hex } from 'viem';
|
|
4
4
|
import 'viem/chains';
|
|
@@ -105,11 +105,6 @@ declare function sendInteraction(client: FrakClient, { productId, interaction, v
|
|
|
105
105
|
* ssoMetadata: {
|
|
106
106
|
* logoUrl: "https://my-app.com/logo.png",
|
|
107
107
|
* homepageLink: "https://my-app.com",
|
|
108
|
-
* links: {
|
|
109
|
-
* confidentialityLink: "https://my-app.com/confidentiality",
|
|
110
|
-
* helpLink: "https://my-app.com/help",
|
|
111
|
-
* cguLink: "https://my-app.com/cgu",
|
|
112
|
-
* },
|
|
113
108
|
* },
|
|
114
109
|
* metadata: {
|
|
115
110
|
* // Modal title on desktop
|
|
@@ -181,6 +176,13 @@ declare function sendInteraction(client: FrakClient, { productId, interaction, v
|
|
|
181
176
|
*/
|
|
182
177
|
declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: FrakClient, { steps, metadata }: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
|
|
183
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Function used to display the Frak embeded wallet popup
|
|
181
|
+
* @param client - The current Frak Client
|
|
182
|
+
* @param params - The parameter used to customise the embeded wallet
|
|
183
|
+
*/
|
|
184
|
+
declare function displayEmbededWallet(client: FrakClient, params: DisplayEmbededWalletParamsType): Promise<void>;
|
|
185
|
+
|
|
184
186
|
/**
|
|
185
187
|
* Function used to open the SSO
|
|
186
188
|
* @param client - The current Frak Client
|
|
@@ -195,11 +197,6 @@ declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(cli
|
|
|
195
197
|
* const metadata: SsoMetadata = {
|
|
196
198
|
* logoUrl: "https://my-app.com/logo.png",
|
|
197
199
|
* homepageLink: "https://my-app.com",
|
|
198
|
-
* links: {
|
|
199
|
-
* confidentialityLink: "https://my-app.com/confidentiality",
|
|
200
|
-
* helpLink: "https://my-app.com/help",
|
|
201
|
-
* cguLink: "https://my-app.com/cgu",
|
|
202
|
-
* },
|
|
203
200
|
* };
|
|
204
201
|
* ```
|
|
205
202
|
*
|
|
@@ -377,8 +374,9 @@ type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
|
377
374
|
}>["options"], options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
|
|
378
375
|
/**
|
|
379
376
|
* Display the modal
|
|
377
|
+
* @param metadataOverride - Function returning optional metadata to override the current modal metadata
|
|
380
378
|
*/
|
|
381
|
-
display: () => Promise<ModalRpcStepsResultType<Steps>>;
|
|
379
|
+
display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined) => Promise<ModalRpcStepsResultType<Steps>>;
|
|
382
380
|
};
|
|
383
381
|
/**
|
|
384
382
|
* Represent the output type of the modal builder
|
|
@@ -500,4 +498,4 @@ declare function referralInteraction(client: FrakClient, { productId, modalConfi
|
|
|
500
498
|
options?: ProcessReferralOptions;
|
|
501
499
|
}): Promise<("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral") | undefined>;
|
|
502
500
|
|
|
503
|
-
export { type ModalBuilder, type ModalStepBuilder, type ProcessReferralOptions, type SendTransactionParams, type SiweAuthenticateModalParams, displayModal, getProductInformation, modalBuilder, openSso, processReferral, referralInteraction, sendInteraction, sendTransaction, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
|
|
501
|
+
export { type ModalBuilder, type ModalStepBuilder, type ProcessReferralOptions, type SendTransactionParams, type SiweAuthenticateModalParams, displayEmbededWallet, displayModal, getProductInformation, modalBuilder, openSso, processReferral, referralInteraction, sendInteraction, sendTransaction, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
|
package/dist/actions/index.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
RpcErrorCodes
|
|
6
|
-
} from "../chunk-AFLVOY5H.js";
|
|
7
|
-
import {
|
|
8
|
-
ReferralInteractionEncoder
|
|
9
|
-
} from "../chunk-RMOFMRZR.js";
|
|
10
|
-
import "../chunk-GDH3M5ZC.js";
|
|
1
|
+
import { Deferred, FrakContextManager, FrakRpcError, RpcErrorCodes } from '../chunk-XDZMP74U.js';
|
|
2
|
+
import { ReferralInteractionEncoder } from '../chunk-RMOFMRZR.js';
|
|
3
|
+
import { isAddressEqual, keccak256, toHex } from 'viem';
|
|
4
|
+
import { generateSiweNonce } from 'viem/siwe';
|
|
11
5
|
|
|
12
6
|
// src/actions/watchWalletStatus.ts
|
|
13
7
|
function watchWalletStatus(client, callback) {
|
|
@@ -46,17 +40,14 @@ function savePotentialToken(interactionToken) {
|
|
|
46
40
|
window.sessionStorage.removeItem("frak.interaction-token");
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
// src/utils/computeProductId.ts
|
|
51
|
-
import { keccak256, toHex } from "viem";
|
|
52
43
|
function computeProductId({ domain }) {
|
|
53
|
-
const effectiveDomain = domain
|
|
44
|
+
const effectiveDomain = domain != null ? domain : window.location.host;
|
|
54
45
|
return keccak256(toHex(effectiveDomain));
|
|
55
46
|
}
|
|
56
47
|
|
|
57
48
|
// src/actions/sendInteraction.ts
|
|
58
49
|
async function sendInteraction(client, { productId, interaction, validation }) {
|
|
59
|
-
const pId = productId
|
|
50
|
+
const pId = productId != null ? productId : computeProductId(client.config);
|
|
60
51
|
return await client.request({
|
|
61
52
|
method: "frak_sendInteraction",
|
|
62
53
|
params: [pId, interaction, validation]
|
|
@@ -71,6 +62,14 @@ async function displayModal(client, { steps, metadata }) {
|
|
|
71
62
|
});
|
|
72
63
|
}
|
|
73
64
|
|
|
65
|
+
// src/actions/displayEmbededWallet.ts
|
|
66
|
+
async function displayEmbededWallet(client, params) {
|
|
67
|
+
await client.request({
|
|
68
|
+
method: "frak_displayEmbededWallet",
|
|
69
|
+
params: [params, client.config.metadata.name]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
74
73
|
// src/actions/openSso.ts
|
|
75
74
|
async function openSso(client, args) {
|
|
76
75
|
const { metadata } = client.config;
|
|
@@ -110,18 +109,16 @@ async function trackPurchaseStatus(args) {
|
|
|
110
109
|
body: JSON.stringify(args)
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
|
-
|
|
114
|
-
// src/actions/wrapper/siweAuthenticate.ts
|
|
115
|
-
import { generateSiweNonce } from "viem/siwe";
|
|
116
112
|
async function siweAuthenticate(client, { siwe, metadata }) {
|
|
117
|
-
|
|
118
|
-
const
|
|
113
|
+
var _a, _b, _c, _d, _e, _f;
|
|
114
|
+
const effectiveDomain = (_b = (_a = client.config) == null ? undefined : _a.domain) != null ? _b : window.location.host;
|
|
115
|
+
const realStatement = (_c = siwe == null ? undefined : siwe.statement) != null ? _c : `I confirm that I want to use my Frak wallet on: ${client.config.metadata.name}`;
|
|
119
116
|
const builtSiwe = {
|
|
120
117
|
...siwe,
|
|
121
118
|
statement: realStatement,
|
|
122
|
-
nonce: siwe
|
|
123
|
-
uri: siwe
|
|
124
|
-
version: siwe
|
|
119
|
+
nonce: (_d = siwe == null ? undefined : siwe.nonce) != null ? _d : generateSiweNonce(),
|
|
120
|
+
uri: (_e = siwe == null ? undefined : siwe.uri) != null ? _e : `https://${effectiveDomain}`,
|
|
121
|
+
version: (_f = siwe == null ? undefined : siwe.version) != null ? _f : "1",
|
|
125
122
|
domain: effectiveDomain
|
|
126
123
|
};
|
|
127
124
|
const result = await displayModal(client, {
|
|
@@ -156,8 +153,8 @@ function modalBuilder(client, {
|
|
|
156
153
|
}) {
|
|
157
154
|
const baseParams = {
|
|
158
155
|
steps: {
|
|
159
|
-
login: login
|
|
160
|
-
openSession: openSession
|
|
156
|
+
login: login != null ? login : {},
|
|
157
|
+
openSession: openSession != null ? openSession : {}
|
|
161
158
|
},
|
|
162
159
|
metadata
|
|
163
160
|
};
|
|
@@ -203,7 +200,11 @@ function modalStepsBuilder(client, params) {
|
|
|
203
200
|
}
|
|
204
201
|
);
|
|
205
202
|
}
|
|
206
|
-
async function display() {
|
|
203
|
+
async function display(metadataOverride) {
|
|
204
|
+
var _a;
|
|
205
|
+
if (metadataOverride) {
|
|
206
|
+
params.metadata = metadataOverride((_a = params.metadata) != null ? _a : {});
|
|
207
|
+
}
|
|
207
208
|
return await displayModal(client, params);
|
|
208
209
|
}
|
|
209
210
|
return {
|
|
@@ -217,9 +218,6 @@ function modalStepsBuilder(client, params) {
|
|
|
217
218
|
display
|
|
218
219
|
};
|
|
219
220
|
}
|
|
220
|
-
|
|
221
|
-
// src/actions/referral/processReferral.ts
|
|
222
|
-
import { isAddressEqual } from "viem";
|
|
223
221
|
async function processReferral(client, {
|
|
224
222
|
walletStatus,
|
|
225
223
|
frakContext,
|
|
@@ -227,6 +225,7 @@ async function processReferral(client, {
|
|
|
227
225
|
productId,
|
|
228
226
|
options
|
|
229
227
|
}) {
|
|
228
|
+
var _a, _b;
|
|
230
229
|
let walletRequest = false;
|
|
231
230
|
async function getFreshWalletStatus() {
|
|
232
231
|
if (walletRequest) {
|
|
@@ -252,15 +251,15 @@ async function processReferral(client, {
|
|
|
252
251
|
frakContext
|
|
253
252
|
});
|
|
254
253
|
FrakContextManager.replaceUrl({
|
|
255
|
-
url: window.location
|
|
256
|
-
context: options
|
|
254
|
+
url: (_a = window.location) == null ? undefined : _a.href,
|
|
255
|
+
context: (options == null ? undefined : options.alwaysAppendUrl) ? { r: currentWallet } : null
|
|
257
256
|
});
|
|
258
257
|
return status;
|
|
259
258
|
} catch (error) {
|
|
260
259
|
console.log("Error processing referral", { error });
|
|
261
260
|
FrakContextManager.replaceUrl({
|
|
262
|
-
url: window.location
|
|
263
|
-
context: options
|
|
261
|
+
url: (_b = window.location) == null ? undefined : _b.href,
|
|
262
|
+
context: (options == null ? undefined : options.alwaysAppendUrl) ? { r: walletStatus == null ? undefined : walletStatus.wallet } : null
|
|
264
263
|
});
|
|
265
264
|
return mapErrorToState(error);
|
|
266
265
|
}
|
|
@@ -271,8 +270,8 @@ async function processReferralLogic({
|
|
|
271
270
|
pushReferralInteraction,
|
|
272
271
|
frakContext
|
|
273
272
|
}) {
|
|
274
|
-
let currentWallet = initialWalletStatus
|
|
275
|
-
if (!frakContext
|
|
273
|
+
let currentWallet = initialWalletStatus == null ? undefined : initialWalletStatus.wallet;
|
|
274
|
+
if (!(frakContext == null ? undefined : frakContext.r)) {
|
|
276
275
|
return { status: "no-referrer", currentWallet };
|
|
277
276
|
}
|
|
278
277
|
if (!currentWallet) {
|
|
@@ -281,7 +280,7 @@ async function processReferralLogic({
|
|
|
281
280
|
if (currentWallet && isAddressEqual(frakContext.r, currentWallet)) {
|
|
282
281
|
return { status: "self-referral", currentWallet };
|
|
283
282
|
}
|
|
284
|
-
if (!initialWalletStatus
|
|
283
|
+
if (!(initialWalletStatus == null ? undefined : initialWalletStatus.interactionSession)) {
|
|
285
284
|
currentWallet = await getFreshWalletStatus();
|
|
286
285
|
}
|
|
287
286
|
await pushReferralInteraction(frakContext.r);
|
|
@@ -291,14 +290,15 @@ async function ensureWalletConnected(client, {
|
|
|
291
290
|
modalConfig,
|
|
292
291
|
walletStatus
|
|
293
292
|
}) {
|
|
294
|
-
|
|
293
|
+
var _a, _b, _c;
|
|
294
|
+
if (!(walletStatus == null ? undefined : walletStatus.interactionSession)) {
|
|
295
295
|
if (!modalConfig) {
|
|
296
|
-
return
|
|
296
|
+
return undefined;
|
|
297
297
|
}
|
|
298
298
|
const result = await displayModal(client, modalConfig);
|
|
299
|
-
return result
|
|
299
|
+
return (_b = (_a = result == null ? undefined : result.login) == null ? undefined : _a.wallet) != null ? _b : undefined;
|
|
300
300
|
}
|
|
301
|
-
return walletStatus.wallet
|
|
301
|
+
return (_c = walletStatus.wallet) != null ? _c : undefined;
|
|
302
302
|
}
|
|
303
303
|
function mapErrorToState(error) {
|
|
304
304
|
if (error instanceof FrakRpcError) {
|
|
@@ -337,16 +337,5 @@ async function referralInteraction(client, {
|
|
|
337
337
|
}
|
|
338
338
|
return;
|
|
339
339
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
getProductInformation,
|
|
343
|
-
modalBuilder,
|
|
344
|
-
openSso,
|
|
345
|
-
processReferral,
|
|
346
|
-
referralInteraction,
|
|
347
|
-
sendInteraction,
|
|
348
|
-
sendTransaction,
|
|
349
|
-
siweAuthenticate,
|
|
350
|
-
trackPurchaseStatus,
|
|
351
|
-
watchWalletStatus
|
|
352
|
-
};
|
|
340
|
+
|
|
341
|
+
export { displayEmbededWallet, displayModal, getProductInformation, modalBuilder, openSso, processReferral, referralInteraction, sendInteraction, sendTransaction, siweAuthenticate, trackPurchaseStatus, watchWalletStatus };
|
package/dist/chunk-GDH3M5ZC.js
CHANGED
|
@@ -74,11 +74,4 @@ var interactionTypes = {
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
export {
|
|
78
|
-
__commonJS,
|
|
79
|
-
__toESM,
|
|
80
|
-
__publicField,
|
|
81
|
-
productTypes,
|
|
82
|
-
productTypesMask,
|
|
83
|
-
interactionTypes
|
|
84
|
-
};
|
|
77
|
+
export { __commonJS, __publicField, __toESM, interactionTypes, productTypes, productTypesMask };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
3
|
+
var chunkPO6YSB4Q_cjs = require('./chunk-PO6YSB4Q.cjs');
|
|
4
|
+
var jsSha256 = require('js-sha256');
|
|
5
|
+
var viem = require('viem');
|
|
6
6
|
|
|
7
7
|
// ../../node_modules/async-lz-string/libs/async-lz-string.js
|
|
8
|
-
var require_async_lz_string =
|
|
8
|
+
var require_async_lz_string = chunkPO6YSB4Q_cjs.__commonJS({
|
|
9
9
|
"../../node_modules/async-lz-string/libs/async-lz-string.js"(exports, module) {
|
|
10
|
-
"use strict";
|
|
11
10
|
!function(t, e) {
|
|
12
11
|
if ("object" == typeof exports && "object" == typeof module) module.exports = e();
|
|
13
12
|
else if ("function" == typeof define && define.amd) define([], e);
|
|
@@ -16,7 +15,6 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
16
15
|
for (var r in n) ("object" == typeof exports ? exports : t)[r] = n[r];
|
|
17
16
|
}
|
|
18
17
|
}(exports, () => (() => {
|
|
19
|
-
"use strict";
|
|
20
18
|
var t = { 48: function(t2, e2, n) {
|
|
21
19
|
var r = this && this.__awaiter || function(t3, e3, n2, r2) {
|
|
22
20
|
return new (n2 || (n2 = Promise))(function(a2, o2) {
|
|
@@ -96,15 +94,15 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
96
94
|
n2 = a2 = 0;
|
|
97
95
|
}
|
|
98
96
|
if (5 & s4[0]) throw s4[1];
|
|
99
|
-
return { value: s4[0] ? s4[1] :
|
|
97
|
+
return { value: s4[0] ? s4[1] : undefined, done: true };
|
|
100
98
|
}([s3, u2]);
|
|
101
99
|
};
|
|
102
100
|
}
|
|
103
101
|
};
|
|
104
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.decompressFromUTF16 = e2.compressToUTF16 = e2.decompressFromBase64 = e2.compressToBase64 =
|
|
102
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.decompressFromUTF16 = e2.compressToUTF16 = e2.decompressFromBase64 = e2.compressToBase64 = undefined;
|
|
105
103
|
var o = n(304), i = n(134), s = new o.CompressorImpl(), u = new i.DecompressorImpl(), c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", l = {};
|
|
106
104
|
e2.compressToBase64 = function(t3) {
|
|
107
|
-
return r(this,
|
|
105
|
+
return r(this, undefined, undefined, function() {
|
|
108
106
|
var e3;
|
|
109
107
|
return a(this, function(n2) {
|
|
110
108
|
switch (n2.label) {
|
|
@@ -129,7 +127,7 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
129
127
|
});
|
|
130
128
|
});
|
|
131
129
|
}, e2.decompressFromBase64 = function(t3) {
|
|
132
|
-
return r(this,
|
|
130
|
+
return r(this, undefined, undefined, function() {
|
|
133
131
|
return a(this, function(e3) {
|
|
134
132
|
switch (e3.label) {
|
|
135
133
|
case 0:
|
|
@@ -148,7 +146,7 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
148
146
|
});
|
|
149
147
|
});
|
|
150
148
|
}, e2.compressToUTF16 = function(t3) {
|
|
151
|
-
return r(this,
|
|
149
|
+
return r(this, undefined, undefined, function() {
|
|
152
150
|
return a(this, function(e3) {
|
|
153
151
|
switch (e3.label) {
|
|
154
152
|
case 0:
|
|
@@ -161,7 +159,7 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
161
159
|
});
|
|
162
160
|
});
|
|
163
161
|
}, e2.decompressFromUTF16 = function(t3) {
|
|
164
|
-
return r(this,
|
|
162
|
+
return r(this, undefined, undefined, function() {
|
|
165
163
|
return a(this, function(e3) {
|
|
166
164
|
switch (e3.label) {
|
|
167
165
|
case 0:
|
|
@@ -253,12 +251,12 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
253
251
|
n2 = a2 = 0;
|
|
254
252
|
}
|
|
255
253
|
if (5 & s4[0]) throw s4[1];
|
|
256
|
-
return { value: s4[0] ? s4[1] :
|
|
254
|
+
return { value: s4[0] ? s4[1] : undefined, done: true };
|
|
257
255
|
}([s3, u]);
|
|
258
256
|
};
|
|
259
257
|
}
|
|
260
258
|
};
|
|
261
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.CompressorImpl =
|
|
259
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.CompressorImpl = undefined;
|
|
262
260
|
var o = n(658), i = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15], s = function() {
|
|
263
261
|
function t3() {
|
|
264
262
|
}
|
|
@@ -278,7 +276,7 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
278
276
|
}, t3.prototype.compress = function(e3, n2, i2) {
|
|
279
277
|
var s2 = this;
|
|
280
278
|
return new Promise(function(u) {
|
|
281
|
-
return r(s2,
|
|
279
|
+
return r(s2, undefined, undefined, function() {
|
|
282
280
|
var r2, s3;
|
|
283
281
|
return a(this, function(a2) {
|
|
284
282
|
switch (a2.label) {
|
|
@@ -379,19 +377,19 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
379
377
|
n2 = a2 = 0;
|
|
380
378
|
}
|
|
381
379
|
if (5 & s3[0]) throw s3[1];
|
|
382
|
-
return { value: s3[0] ? s3[1] :
|
|
380
|
+
return { value: s3[0] ? s3[1] : undefined, done: true };
|
|
383
381
|
}([s2, u]);
|
|
384
382
|
};
|
|
385
383
|
}
|
|
386
384
|
};
|
|
387
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.DecompressorImpl =
|
|
385
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.DecompressorImpl = undefined;
|
|
388
386
|
var o = n(658), i = function() {
|
|
389
387
|
function t3() {
|
|
390
388
|
}
|
|
391
389
|
return t3.prototype.decompress = function(t4, e3, n2) {
|
|
392
390
|
var i2 = this;
|
|
393
391
|
return new Promise(function(s) {
|
|
394
|
-
return r(i2,
|
|
392
|
+
return r(i2, undefined, undefined, function() {
|
|
395
393
|
var r2, i3, u;
|
|
396
394
|
return a(this, function(a2) {
|
|
397
395
|
switch (a2.label) {
|
|
@@ -524,13 +522,13 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
524
522
|
n2 = a = 0;
|
|
525
523
|
}
|
|
526
524
|
if (5 & s3[0]) throw s3[1];
|
|
527
|
-
return { value: s3[0] ? s3[1] :
|
|
525
|
+
return { value: s3[0] ? s3[1] : undefined, done: true };
|
|
528
526
|
}([s2, u]);
|
|
529
527
|
};
|
|
530
528
|
}
|
|
531
529
|
};
|
|
532
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.wait =
|
|
533
|
-
return n(this,
|
|
530
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.wait = undefined, e2.wait = function() {
|
|
531
|
+
return n(this, undefined, undefined, function() {
|
|
534
532
|
return r(this, function(t3) {
|
|
535
533
|
return [2, new Promise(function(t4) {
|
|
536
534
|
setTimeout(t4, 0);
|
|
@@ -541,7 +539,7 @@ var require_async_lz_string = _chunkPO6YSB4Qcjs.__commonJS.call(void 0, {
|
|
|
541
539
|
} }, e = {};
|
|
542
540
|
return function n(r) {
|
|
543
541
|
var a = e[r];
|
|
544
|
-
if (
|
|
542
|
+
if (undefined !== a) return a.exports;
|
|
545
543
|
var o = e[r] = { exports: {} };
|
|
546
544
|
return t[r].call(o.exports, o, o.exports, n), o.exports;
|
|
547
545
|
}(48);
|
|
@@ -587,14 +585,16 @@ var RpcErrorCodes = {
|
|
|
587
585
|
// src/utils/Deferred.ts
|
|
588
586
|
var Deferred = class {
|
|
589
587
|
constructor() {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
588
|
+
chunkPO6YSB4Q_cjs.__publicField(this, "_promise");
|
|
589
|
+
chunkPO6YSB4Q_cjs.__publicField(this, "_resolve");
|
|
590
|
+
chunkPO6YSB4Q_cjs.__publicField(this, "_reject");
|
|
591
|
+
chunkPO6YSB4Q_cjs.__publicField(this, "resolve", (value) => {
|
|
592
|
+
var _a;
|
|
593
|
+
(_a = this._resolve) == null ? undefined : _a.call(this, value);
|
|
595
594
|
});
|
|
596
|
-
|
|
597
|
-
|
|
595
|
+
chunkPO6YSB4Q_cjs.__publicField(this, "reject", (reason) => {
|
|
596
|
+
var _a;
|
|
597
|
+
(_a = this._reject) == null ? undefined : _a.call(this, reason);
|
|
598
598
|
});
|
|
599
599
|
this._promise = new Promise((resolve, reject) => {
|
|
600
600
|
this._resolve = resolve;
|
|
@@ -607,16 +607,15 @@ var Deferred = class {
|
|
|
607
607
|
};
|
|
608
608
|
|
|
609
609
|
// src/utils/compression/compress.ts
|
|
610
|
-
var import_async_lz_string =
|
|
611
|
-
var _jssha256 = require('js-sha256');
|
|
610
|
+
var import_async_lz_string = chunkPO6YSB4Q_cjs.__toESM(require_async_lz_string(), 1);
|
|
612
611
|
async function hashAndCompressData(data) {
|
|
613
|
-
const validationHash =
|
|
612
|
+
const validationHash = jsSha256.sha256(JSON.stringify(data));
|
|
614
613
|
const hashProtectedData = {
|
|
615
614
|
...data,
|
|
616
615
|
validationHash
|
|
617
616
|
};
|
|
618
617
|
const compressed = await compressJson(hashProtectedData);
|
|
619
|
-
const compressedHash =
|
|
618
|
+
const compressedHash = jsSha256.sha256(compressed);
|
|
620
619
|
return {
|
|
621
620
|
compressed,
|
|
622
621
|
compressedHash
|
|
@@ -627,10 +626,9 @@ async function compressJson(data) {
|
|
|
627
626
|
}
|
|
628
627
|
|
|
629
628
|
// src/utils/compression/decompress.ts
|
|
630
|
-
var import_async_lz_string2 =
|
|
631
|
-
|
|
629
|
+
var import_async_lz_string2 = chunkPO6YSB4Q_cjs.__toESM(require_async_lz_string(), 1);
|
|
632
630
|
async function decompressDataAndCheckHash(compressedData) {
|
|
633
|
-
if (!(
|
|
631
|
+
if (!((compressedData == null ? undefined : compressedData.compressed) && (compressedData == null ? undefined : compressedData.compressedHash))) {
|
|
634
632
|
throw new FrakRpcError(
|
|
635
633
|
RpcErrorCodes.corruptedResponse,
|
|
636
634
|
"Missing compressed data"
|
|
@@ -645,13 +643,13 @@ async function decompressDataAndCheckHash(compressedData) {
|
|
|
645
643
|
"Invalid compressed data"
|
|
646
644
|
);
|
|
647
645
|
}
|
|
648
|
-
if (!
|
|
646
|
+
if (!(parsedData == null ? undefined : parsedData.validationHash)) {
|
|
649
647
|
throw new FrakRpcError(
|
|
650
648
|
RpcErrorCodes.corruptedResponse,
|
|
651
649
|
"Missing validation hash"
|
|
652
650
|
);
|
|
653
651
|
}
|
|
654
|
-
const expectedCompressedHash =
|
|
652
|
+
const expectedCompressedHash = jsSha256.sha256(compressedData.compressed);
|
|
655
653
|
if (expectedCompressedHash !== compressedData.compressedHash) {
|
|
656
654
|
throw new FrakRpcError(
|
|
657
655
|
RpcErrorCodes.corruptedResponse,
|
|
@@ -659,7 +657,7 @@ async function decompressDataAndCheckHash(compressedData) {
|
|
|
659
657
|
);
|
|
660
658
|
}
|
|
661
659
|
const { validationHash: _, ...rawResultData } = parsedData;
|
|
662
|
-
const expectedValidationHash =
|
|
660
|
+
const expectedValidationHash = jsSha256.sha256(JSON.stringify(rawResultData));
|
|
663
661
|
if (expectedValidationHash !== parsedData.validationHash) {
|
|
664
662
|
throw new FrakRpcError(
|
|
665
663
|
RpcErrorCodes.corruptedResponse,
|
|
@@ -709,8 +707,9 @@ function createIframe({
|
|
|
709
707
|
changeIframeVisibility({ iframe, isVisible: false });
|
|
710
708
|
document.body.appendChild(iframe);
|
|
711
709
|
return new Promise((resolve) => {
|
|
712
|
-
|
|
713
|
-
iframe
|
|
710
|
+
var _a, _b;
|
|
711
|
+
iframe == null ? undefined : iframe.addEventListener("load", () => resolve(iframe));
|
|
712
|
+
iframe.src = `${(_b = (_a = config == null ? undefined : config.walletUrl) != null ? _a : walletBaseUrl) != null ? _b : "https://wallet.frak.id"}/listener`;
|
|
714
713
|
});
|
|
715
714
|
}
|
|
716
715
|
function changeIframeVisibility({
|
|
@@ -733,9 +732,6 @@ function changeIframeVisibility({
|
|
|
733
732
|
iframe.style.height = "100%";
|
|
734
733
|
iframe.style.pointerEvents = "auto";
|
|
735
734
|
}
|
|
736
|
-
|
|
737
|
-
// src/utils/FrakContext.ts
|
|
738
|
-
var _viem = require('viem');
|
|
739
735
|
var contextKey = "fCtx";
|
|
740
736
|
function base64url_encode(buffer) {
|
|
741
737
|
return btoa(Array.from(buffer, (b) => String.fromCharCode(b)).join("")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
@@ -750,24 +746,24 @@ function base64url_decode(value) {
|
|
|
750
746
|
);
|
|
751
747
|
}
|
|
752
748
|
function compress(context) {
|
|
753
|
-
if (!
|
|
749
|
+
if (!(context == null ? undefined : context.r)) return;
|
|
754
750
|
try {
|
|
755
|
-
const bytes =
|
|
751
|
+
const bytes = viem.hexToBytes(context.r);
|
|
756
752
|
return base64url_encode(bytes);
|
|
757
753
|
} catch (e) {
|
|
758
754
|
console.error("Error compressing Frak context", { e, context });
|
|
759
755
|
}
|
|
760
|
-
return
|
|
756
|
+
return undefined;
|
|
761
757
|
}
|
|
762
758
|
function decompress(context) {
|
|
763
759
|
if (!context || context.length === 0) return;
|
|
764
760
|
try {
|
|
765
761
|
const bytes = base64url_decode(context);
|
|
766
|
-
return { r:
|
|
762
|
+
return { r: viem.bytesToHex(bytes, { size: 20 }) };
|
|
767
763
|
} catch (e) {
|
|
768
764
|
console.error("Error decompressing Frak context", { e, context });
|
|
769
765
|
}
|
|
770
|
-
return
|
|
766
|
+
return undefined;
|
|
771
767
|
}
|
|
772
768
|
function parse({ url }) {
|
|
773
769
|
if (!url) return null;
|
|
@@ -799,11 +795,12 @@ function replaceUrl({
|
|
|
799
795
|
url: baseUrl,
|
|
800
796
|
context
|
|
801
797
|
}) {
|
|
802
|
-
|
|
798
|
+
var _a;
|
|
799
|
+
if (!((_a = window.location) == null ? undefined : _a.href) || typeof window === "undefined") {
|
|
803
800
|
console.error("No window found, can't update context");
|
|
804
801
|
return;
|
|
805
802
|
}
|
|
806
|
-
const url =
|
|
803
|
+
const url = baseUrl != null ? baseUrl : window.location.href;
|
|
807
804
|
let newUrl;
|
|
808
805
|
if (context !== null) {
|
|
809
806
|
newUrl = update({
|
|
@@ -825,18 +822,16 @@ var FrakContextManager = {
|
|
|
825
822
|
replaceUrl
|
|
826
823
|
};
|
|
827
824
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
exports.FrakRpcError = FrakRpcError; exports.InternalError = InternalError; exports.ClientNotFound = ClientNotFound; exports.RpcErrorCodes = RpcErrorCodes; exports.Deferred = Deferred; exports.hashAndCompressData = hashAndCompressData; exports.compressJson = compressJson; exports.decompressDataAndCheckHash = decompressDataAndCheckHash; exports.decompressJson = decompressJson; exports.baseIframeProps = baseIframeProps; exports.createIframe = createIframe; exports.changeIframeVisibility = changeIframeVisibility; exports.FrakContextManager = FrakContextManager;
|
|
825
|
+
exports.ClientNotFound = ClientNotFound;
|
|
826
|
+
exports.Deferred = Deferred;
|
|
827
|
+
exports.FrakContextManager = FrakContextManager;
|
|
828
|
+
exports.FrakRpcError = FrakRpcError;
|
|
829
|
+
exports.InternalError = InternalError;
|
|
830
|
+
exports.RpcErrorCodes = RpcErrorCodes;
|
|
831
|
+
exports.baseIframeProps = baseIframeProps;
|
|
832
|
+
exports.changeIframeVisibility = changeIframeVisibility;
|
|
833
|
+
exports.compressJson = compressJson;
|
|
834
|
+
exports.createIframe = createIframe;
|
|
835
|
+
exports.decompressDataAndCheckHash = decompressDataAndCheckHash;
|
|
836
|
+
exports.decompressJson = decompressJson;
|
|
837
|
+
exports.hashAndCompressData = hashAndCompressData;
|