@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/chunk-PO6YSB4Q.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -74,11 +76,9 @@ var interactionTypes = {
|
|
|
74
76
|
}
|
|
75
77
|
};
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.__publicField = __publicField; exports.productTypes = productTypes; exports.productTypesMask = productTypesMask; exports.interactionTypes = interactionTypes;
|
|
79
|
+
exports.__commonJS = __commonJS;
|
|
80
|
+
exports.__publicField = __publicField;
|
|
81
|
+
exports.__toESM = __toESM;
|
|
82
|
+
exports.interactionTypes = interactionTypes;
|
|
83
|
+
exports.productTypes = productTypes;
|
|
84
|
+
exports.productTypesMask = productTypesMask;
|
package/dist/chunk-RMOFMRZR.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
productTypes
|
|
4
|
-
} from "./chunk-GDH3M5ZC.js";
|
|
1
|
+
import { interactionTypes, productTypes } from './chunk-GDH3M5ZC.js';
|
|
2
|
+
import { concatHex, pad, toHex, encodeAbiParameters } from 'viem';
|
|
5
3
|
|
|
6
|
-
// src/interactions/pressEncoder.ts
|
|
7
|
-
import { concatHex, pad, toHex } from "viem";
|
|
8
4
|
var PressInteractionEncoder = {
|
|
9
5
|
/**
|
|
10
6
|
* Encode an open article interaction
|
|
@@ -37,16 +33,13 @@ var PressInteractionEncoder = {
|
|
|
37
33
|
};
|
|
38
34
|
}
|
|
39
35
|
};
|
|
40
|
-
|
|
41
|
-
// src/interactions/referralEncoder.ts
|
|
42
|
-
import { concatHex as concatHex2, pad as pad2, toHex as toHex2 } from "viem";
|
|
43
36
|
var ReferralInteractionEncoder = {
|
|
44
37
|
/**
|
|
45
38
|
* Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
|
|
46
39
|
*/
|
|
47
40
|
createLink() {
|
|
48
41
|
return {
|
|
49
|
-
handlerTypeDenominator:
|
|
42
|
+
handlerTypeDenominator: toHex(productTypes.referral),
|
|
50
43
|
interactionData: interactionTypes.referral.createLink
|
|
51
44
|
};
|
|
52
45
|
},
|
|
@@ -56,19 +49,16 @@ var ReferralInteractionEncoder = {
|
|
|
56
49
|
* @param args.referrer - The Ethereum address of the user who made the referral
|
|
57
50
|
*/
|
|
58
51
|
referred({ referrer }) {
|
|
59
|
-
const interactionData =
|
|
52
|
+
const interactionData = concatHex([
|
|
60
53
|
interactionTypes.referral.referred,
|
|
61
|
-
|
|
54
|
+
pad(referrer, { size: 32 })
|
|
62
55
|
]);
|
|
63
56
|
return {
|
|
64
|
-
handlerTypeDenominator:
|
|
57
|
+
handlerTypeDenominator: toHex(productTypes.referral),
|
|
65
58
|
interactionData
|
|
66
59
|
};
|
|
67
60
|
}
|
|
68
61
|
};
|
|
69
|
-
|
|
70
|
-
// src/interactions/purchaseEncoder.ts
|
|
71
|
-
import { concatHex as concatHex3, encodeAbiParameters, pad as pad3, toHex as toHex3 } from "viem";
|
|
72
62
|
var PurchaseInteractionEncoder = {
|
|
73
63
|
/**
|
|
74
64
|
* Encode a start purchase interaction
|
|
@@ -76,12 +66,12 @@ var PurchaseInteractionEncoder = {
|
|
|
76
66
|
* @param args.purchaseId - The id of the purchase that is being started.
|
|
77
67
|
*/
|
|
78
68
|
startPurchase({ purchaseId }) {
|
|
79
|
-
const interactionData =
|
|
69
|
+
const interactionData = concatHex([
|
|
80
70
|
interactionTypes.purchase.started,
|
|
81
|
-
|
|
71
|
+
pad(purchaseId, { size: 32 })
|
|
82
72
|
]);
|
|
83
73
|
return {
|
|
84
|
-
handlerTypeDenominator:
|
|
74
|
+
handlerTypeDenominator: toHex(productTypes.purchase),
|
|
85
75
|
interactionData
|
|
86
76
|
};
|
|
87
77
|
},
|
|
@@ -99,12 +89,12 @@ var PurchaseInteractionEncoder = {
|
|
|
99
89
|
[{ type: "uint256" }, { type: "bytes32[]" }],
|
|
100
90
|
[BigInt(purchaseId), proof]
|
|
101
91
|
);
|
|
102
|
-
const interactionData =
|
|
92
|
+
const interactionData = concatHex([
|
|
103
93
|
interactionTypes.purchase.completed,
|
|
104
94
|
innerData
|
|
105
95
|
]);
|
|
106
96
|
return {
|
|
107
|
-
handlerTypeDenominator:
|
|
97
|
+
handlerTypeDenominator: toHex(productTypes.purchase),
|
|
108
98
|
interactionData
|
|
109
99
|
};
|
|
110
100
|
},
|
|
@@ -116,33 +106,27 @@ var PurchaseInteractionEncoder = {
|
|
|
116
106
|
unsafeCompletedPurchase({
|
|
117
107
|
purchaseId
|
|
118
108
|
}) {
|
|
119
|
-
const interactionData =
|
|
109
|
+
const interactionData = concatHex([
|
|
120
110
|
interactionTypes.purchase.unsafeCompleted,
|
|
121
|
-
|
|
111
|
+
pad(purchaseId, { size: 32 })
|
|
122
112
|
]);
|
|
123
113
|
return {
|
|
124
|
-
handlerTypeDenominator:
|
|
114
|
+
handlerTypeDenominator: toHex(productTypes.purchase),
|
|
125
115
|
interactionData
|
|
126
116
|
};
|
|
127
117
|
}
|
|
128
118
|
};
|
|
129
|
-
|
|
130
|
-
// src/interactions/webshopEncoder.ts
|
|
131
|
-
import { toHex as toHex4 } from "viem";
|
|
132
119
|
var WebShopInteractionEncoder = {
|
|
133
120
|
/**
|
|
134
121
|
* Encode an open webshop interaction
|
|
135
122
|
*/
|
|
136
123
|
open() {
|
|
137
124
|
return {
|
|
138
|
-
handlerTypeDenominator:
|
|
125
|
+
handlerTypeDenominator: toHex(productTypes.webshop),
|
|
139
126
|
interactionData: interactionTypes.webshop.open
|
|
140
127
|
};
|
|
141
128
|
}
|
|
142
129
|
};
|
|
143
|
-
|
|
144
|
-
// src/interactions/retailEncoder.ts
|
|
145
|
-
import { concatHex as concatHex4, pad as pad4, toHex as toHex5 } from "viem";
|
|
146
130
|
var RetailInteractionEncoder = {
|
|
147
131
|
/**
|
|
148
132
|
* Encode a customer meeting retail interaction
|
|
@@ -151,21 +135,15 @@ var RetailInteractionEncoder = {
|
|
|
151
135
|
*
|
|
152
136
|
*/
|
|
153
137
|
customerMeeting({ agencyId }) {
|
|
154
|
-
const interactionData =
|
|
138
|
+
const interactionData = concatHex([
|
|
155
139
|
interactionTypes.retail.customerMeeting,
|
|
156
|
-
|
|
140
|
+
pad(agencyId, { size: 32 })
|
|
157
141
|
]);
|
|
158
142
|
return {
|
|
159
|
-
handlerTypeDenominator:
|
|
143
|
+
handlerTypeDenominator: toHex(productTypes.retail),
|
|
160
144
|
interactionData
|
|
161
145
|
};
|
|
162
146
|
}
|
|
163
147
|
};
|
|
164
148
|
|
|
165
|
-
export {
|
|
166
|
-
PressInteractionEncoder,
|
|
167
|
-
ReferralInteractionEncoder,
|
|
168
|
-
PurchaseInteractionEncoder,
|
|
169
|
-
WebShopInteractionEncoder,
|
|
170
|
-
RetailInteractionEncoder
|
|
171
|
-
};
|
|
149
|
+
export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__toESM
|
|
5
|
-
} from "./chunk-GDH3M5ZC.js";
|
|
1
|
+
import { __commonJS, __toESM, __publicField } from './chunk-GDH3M5ZC.js';
|
|
2
|
+
import { sha256 } from 'js-sha256';
|
|
3
|
+
import { hexToBytes, bytesToHex } from 'viem';
|
|
6
4
|
|
|
7
5
|
// ../../node_modules/async-lz-string/libs/async-lz-string.js
|
|
8
6
|
var require_async_lz_string = __commonJS({
|
|
9
7
|
"../../node_modules/async-lz-string/libs/async-lz-string.js"(exports, module) {
|
|
10
|
-
"use strict";
|
|
11
8
|
!function(t, e) {
|
|
12
9
|
if ("object" == typeof exports && "object" == typeof module) module.exports = e();
|
|
13
10
|
else if ("function" == typeof define && define.amd) define([], e);
|
|
@@ -16,7 +13,6 @@ var require_async_lz_string = __commonJS({
|
|
|
16
13
|
for (var r in n) ("object" == typeof exports ? exports : t)[r] = n[r];
|
|
17
14
|
}
|
|
18
15
|
}(exports, () => (() => {
|
|
19
|
-
"use strict";
|
|
20
16
|
var t = { 48: function(t2, e2, n) {
|
|
21
17
|
var r = this && this.__awaiter || function(t3, e3, n2, r2) {
|
|
22
18
|
return new (n2 || (n2 = Promise))(function(a2, o2) {
|
|
@@ -96,15 +92,15 @@ var require_async_lz_string = __commonJS({
|
|
|
96
92
|
n2 = a2 = 0;
|
|
97
93
|
}
|
|
98
94
|
if (5 & s4[0]) throw s4[1];
|
|
99
|
-
return { value: s4[0] ? s4[1] :
|
|
95
|
+
return { value: s4[0] ? s4[1] : undefined, done: true };
|
|
100
96
|
}([s3, u2]);
|
|
101
97
|
};
|
|
102
98
|
}
|
|
103
99
|
};
|
|
104
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.decompressFromUTF16 = e2.compressToUTF16 = e2.decompressFromBase64 = e2.compressToBase64 =
|
|
100
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.decompressFromUTF16 = e2.compressToUTF16 = e2.decompressFromBase64 = e2.compressToBase64 = undefined;
|
|
105
101
|
var o = n(304), i = n(134), s = new o.CompressorImpl(), u = new i.DecompressorImpl(), c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", l = {};
|
|
106
102
|
e2.compressToBase64 = function(t3) {
|
|
107
|
-
return r(this,
|
|
103
|
+
return r(this, undefined, undefined, function() {
|
|
108
104
|
var e3;
|
|
109
105
|
return a(this, function(n2) {
|
|
110
106
|
switch (n2.label) {
|
|
@@ -129,7 +125,7 @@ var require_async_lz_string = __commonJS({
|
|
|
129
125
|
});
|
|
130
126
|
});
|
|
131
127
|
}, e2.decompressFromBase64 = function(t3) {
|
|
132
|
-
return r(this,
|
|
128
|
+
return r(this, undefined, undefined, function() {
|
|
133
129
|
return a(this, function(e3) {
|
|
134
130
|
switch (e3.label) {
|
|
135
131
|
case 0:
|
|
@@ -148,7 +144,7 @@ var require_async_lz_string = __commonJS({
|
|
|
148
144
|
});
|
|
149
145
|
});
|
|
150
146
|
}, e2.compressToUTF16 = function(t3) {
|
|
151
|
-
return r(this,
|
|
147
|
+
return r(this, undefined, undefined, function() {
|
|
152
148
|
return a(this, function(e3) {
|
|
153
149
|
switch (e3.label) {
|
|
154
150
|
case 0:
|
|
@@ -161,7 +157,7 @@ var require_async_lz_string = __commonJS({
|
|
|
161
157
|
});
|
|
162
158
|
});
|
|
163
159
|
}, e2.decompressFromUTF16 = function(t3) {
|
|
164
|
-
return r(this,
|
|
160
|
+
return r(this, undefined, undefined, function() {
|
|
165
161
|
return a(this, function(e3) {
|
|
166
162
|
switch (e3.label) {
|
|
167
163
|
case 0:
|
|
@@ -253,12 +249,12 @@ var require_async_lz_string = __commonJS({
|
|
|
253
249
|
n2 = a2 = 0;
|
|
254
250
|
}
|
|
255
251
|
if (5 & s4[0]) throw s4[1];
|
|
256
|
-
return { value: s4[0] ? s4[1] :
|
|
252
|
+
return { value: s4[0] ? s4[1] : undefined, done: true };
|
|
257
253
|
}([s3, u]);
|
|
258
254
|
};
|
|
259
255
|
}
|
|
260
256
|
};
|
|
261
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.CompressorImpl =
|
|
257
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.CompressorImpl = undefined;
|
|
262
258
|
var o = n(658), i = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15], s = function() {
|
|
263
259
|
function t3() {
|
|
264
260
|
}
|
|
@@ -278,7 +274,7 @@ var require_async_lz_string = __commonJS({
|
|
|
278
274
|
}, t3.prototype.compress = function(e3, n2, i2) {
|
|
279
275
|
var s2 = this;
|
|
280
276
|
return new Promise(function(u) {
|
|
281
|
-
return r(s2,
|
|
277
|
+
return r(s2, undefined, undefined, function() {
|
|
282
278
|
var r2, s3;
|
|
283
279
|
return a(this, function(a2) {
|
|
284
280
|
switch (a2.label) {
|
|
@@ -379,19 +375,19 @@ var require_async_lz_string = __commonJS({
|
|
|
379
375
|
n2 = a2 = 0;
|
|
380
376
|
}
|
|
381
377
|
if (5 & s3[0]) throw s3[1];
|
|
382
|
-
return { value: s3[0] ? s3[1] :
|
|
378
|
+
return { value: s3[0] ? s3[1] : undefined, done: true };
|
|
383
379
|
}([s2, u]);
|
|
384
380
|
};
|
|
385
381
|
}
|
|
386
382
|
};
|
|
387
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.DecompressorImpl =
|
|
383
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.DecompressorImpl = undefined;
|
|
388
384
|
var o = n(658), i = function() {
|
|
389
385
|
function t3() {
|
|
390
386
|
}
|
|
391
387
|
return t3.prototype.decompress = function(t4, e3, n2) {
|
|
392
388
|
var i2 = this;
|
|
393
389
|
return new Promise(function(s) {
|
|
394
|
-
return r(i2,
|
|
390
|
+
return r(i2, undefined, undefined, function() {
|
|
395
391
|
var r2, i3, u;
|
|
396
392
|
return a(this, function(a2) {
|
|
397
393
|
switch (a2.label) {
|
|
@@ -524,13 +520,13 @@ var require_async_lz_string = __commonJS({
|
|
|
524
520
|
n2 = a = 0;
|
|
525
521
|
}
|
|
526
522
|
if (5 & s3[0]) throw s3[1];
|
|
527
|
-
return { value: s3[0] ? s3[1] :
|
|
523
|
+
return { value: s3[0] ? s3[1] : undefined, done: true };
|
|
528
524
|
}([s2, u]);
|
|
529
525
|
};
|
|
530
526
|
}
|
|
531
527
|
};
|
|
532
|
-
Object.defineProperty(e2, "__esModule", { value: true }), e2.wait =
|
|
533
|
-
return n(this,
|
|
528
|
+
Object.defineProperty(e2, "__esModule", { value: true }), e2.wait = undefined, e2.wait = function() {
|
|
529
|
+
return n(this, undefined, undefined, function() {
|
|
534
530
|
return r(this, function(t3) {
|
|
535
531
|
return [2, new Promise(function(t4) {
|
|
536
532
|
setTimeout(t4, 0);
|
|
@@ -541,7 +537,7 @@ var require_async_lz_string = __commonJS({
|
|
|
541
537
|
} }, e = {};
|
|
542
538
|
return function n(r) {
|
|
543
539
|
var a = e[r];
|
|
544
|
-
if (
|
|
540
|
+
if (undefined !== a) return a.exports;
|
|
545
541
|
var o = e[r] = { exports: {} };
|
|
546
542
|
return t[r].call(o.exports, o, o.exports, n), o.exports;
|
|
547
543
|
}(48);
|
|
@@ -591,10 +587,12 @@ var Deferred = class {
|
|
|
591
587
|
__publicField(this, "_resolve");
|
|
592
588
|
__publicField(this, "_reject");
|
|
593
589
|
__publicField(this, "resolve", (value) => {
|
|
594
|
-
|
|
590
|
+
var _a;
|
|
591
|
+
(_a = this._resolve) == null ? undefined : _a.call(this, value);
|
|
595
592
|
});
|
|
596
593
|
__publicField(this, "reject", (reason) => {
|
|
597
|
-
|
|
594
|
+
var _a;
|
|
595
|
+
(_a = this._reject) == null ? undefined : _a.call(this, reason);
|
|
598
596
|
});
|
|
599
597
|
this._promise = new Promise((resolve, reject) => {
|
|
600
598
|
this._resolve = resolve;
|
|
@@ -608,7 +606,6 @@ var Deferred = class {
|
|
|
608
606
|
|
|
609
607
|
// src/utils/compression/compress.ts
|
|
610
608
|
var import_async_lz_string = __toESM(require_async_lz_string(), 1);
|
|
611
|
-
import { sha256 } from "js-sha256";
|
|
612
609
|
async function hashAndCompressData(data) {
|
|
613
610
|
const validationHash = sha256(JSON.stringify(data));
|
|
614
611
|
const hashProtectedData = {
|
|
@@ -628,9 +625,8 @@ async function compressJson(data) {
|
|
|
628
625
|
|
|
629
626
|
// src/utils/compression/decompress.ts
|
|
630
627
|
var import_async_lz_string2 = __toESM(require_async_lz_string(), 1);
|
|
631
|
-
import { sha256 as sha2562 } from "js-sha256";
|
|
632
628
|
async function decompressDataAndCheckHash(compressedData) {
|
|
633
|
-
if (!(compressedData
|
|
629
|
+
if (!((compressedData == null ? undefined : compressedData.compressed) && (compressedData == null ? undefined : compressedData.compressedHash))) {
|
|
634
630
|
throw new FrakRpcError(
|
|
635
631
|
RpcErrorCodes.corruptedResponse,
|
|
636
632
|
"Missing compressed data"
|
|
@@ -645,13 +641,13 @@ async function decompressDataAndCheckHash(compressedData) {
|
|
|
645
641
|
"Invalid compressed data"
|
|
646
642
|
);
|
|
647
643
|
}
|
|
648
|
-
if (!parsedData
|
|
644
|
+
if (!(parsedData == null ? undefined : parsedData.validationHash)) {
|
|
649
645
|
throw new FrakRpcError(
|
|
650
646
|
RpcErrorCodes.corruptedResponse,
|
|
651
647
|
"Missing validation hash"
|
|
652
648
|
);
|
|
653
649
|
}
|
|
654
|
-
const expectedCompressedHash =
|
|
650
|
+
const expectedCompressedHash = sha256(compressedData.compressed);
|
|
655
651
|
if (expectedCompressedHash !== compressedData.compressedHash) {
|
|
656
652
|
throw new FrakRpcError(
|
|
657
653
|
RpcErrorCodes.corruptedResponse,
|
|
@@ -659,7 +655,7 @@ async function decompressDataAndCheckHash(compressedData) {
|
|
|
659
655
|
);
|
|
660
656
|
}
|
|
661
657
|
const { validationHash: _, ...rawResultData } = parsedData;
|
|
662
|
-
const expectedValidationHash =
|
|
658
|
+
const expectedValidationHash = sha256(JSON.stringify(rawResultData));
|
|
663
659
|
if (expectedValidationHash !== parsedData.validationHash) {
|
|
664
660
|
throw new FrakRpcError(
|
|
665
661
|
RpcErrorCodes.corruptedResponse,
|
|
@@ -709,8 +705,9 @@ function createIframe({
|
|
|
709
705
|
changeIframeVisibility({ iframe, isVisible: false });
|
|
710
706
|
document.body.appendChild(iframe);
|
|
711
707
|
return new Promise((resolve) => {
|
|
712
|
-
|
|
713
|
-
iframe
|
|
708
|
+
var _a, _b;
|
|
709
|
+
iframe == null ? undefined : iframe.addEventListener("load", () => resolve(iframe));
|
|
710
|
+
iframe.src = `${(_b = (_a = config == null ? undefined : config.walletUrl) != null ? _a : walletBaseUrl) != null ? _b : "https://wallet.frak.id"}/listener`;
|
|
714
711
|
});
|
|
715
712
|
}
|
|
716
713
|
function changeIframeVisibility({
|
|
@@ -733,9 +730,6 @@ function changeIframeVisibility({
|
|
|
733
730
|
iframe.style.height = "100%";
|
|
734
731
|
iframe.style.pointerEvents = "auto";
|
|
735
732
|
}
|
|
736
|
-
|
|
737
|
-
// src/utils/FrakContext.ts
|
|
738
|
-
import { bytesToHex, hexToBytes } from "viem";
|
|
739
733
|
var contextKey = "fCtx";
|
|
740
734
|
function base64url_encode(buffer) {
|
|
741
735
|
return btoa(Array.from(buffer, (b) => String.fromCharCode(b)).join("")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
@@ -750,14 +744,14 @@ function base64url_decode(value) {
|
|
|
750
744
|
);
|
|
751
745
|
}
|
|
752
746
|
function compress(context) {
|
|
753
|
-
if (!context
|
|
747
|
+
if (!(context == null ? undefined : context.r)) return;
|
|
754
748
|
try {
|
|
755
749
|
const bytes = hexToBytes(context.r);
|
|
756
750
|
return base64url_encode(bytes);
|
|
757
751
|
} catch (e) {
|
|
758
752
|
console.error("Error compressing Frak context", { e, context });
|
|
759
753
|
}
|
|
760
|
-
return
|
|
754
|
+
return undefined;
|
|
761
755
|
}
|
|
762
756
|
function decompress(context) {
|
|
763
757
|
if (!context || context.length === 0) return;
|
|
@@ -767,7 +761,7 @@ function decompress(context) {
|
|
|
767
761
|
} catch (e) {
|
|
768
762
|
console.error("Error decompressing Frak context", { e, context });
|
|
769
763
|
}
|
|
770
|
-
return
|
|
764
|
+
return undefined;
|
|
771
765
|
}
|
|
772
766
|
function parse({ url }) {
|
|
773
767
|
if (!url) return null;
|
|
@@ -799,11 +793,12 @@ function replaceUrl({
|
|
|
799
793
|
url: baseUrl,
|
|
800
794
|
context
|
|
801
795
|
}) {
|
|
802
|
-
|
|
796
|
+
var _a;
|
|
797
|
+
if (!((_a = window.location) == null ? undefined : _a.href) || typeof window === "undefined") {
|
|
803
798
|
console.error("No window found, can't update context");
|
|
804
799
|
return;
|
|
805
800
|
}
|
|
806
|
-
const url = baseUrl
|
|
801
|
+
const url = baseUrl != null ? baseUrl : window.location.href;
|
|
807
802
|
let newUrl;
|
|
808
803
|
if (context !== null) {
|
|
809
804
|
newUrl = update({
|
|
@@ -825,18 +820,4 @@ var FrakContextManager = {
|
|
|
825
820
|
replaceUrl
|
|
826
821
|
};
|
|
827
822
|
|
|
828
|
-
export {
|
|
829
|
-
FrakRpcError,
|
|
830
|
-
InternalError,
|
|
831
|
-
ClientNotFound,
|
|
832
|
-
RpcErrorCodes,
|
|
833
|
-
Deferred,
|
|
834
|
-
hashAndCompressData,
|
|
835
|
-
compressJson,
|
|
836
|
-
decompressDataAndCheckHash,
|
|
837
|
-
decompressJson,
|
|
838
|
-
baseIframeProps,
|
|
839
|
-
createIframe,
|
|
840
|
-
changeIframeVisibility,
|
|
841
|
-
FrakContextManager
|
|
842
|
-
};
|
|
823
|
+
export { ClientNotFound, Deferred, FrakContextManager, FrakRpcError, InternalError, RpcErrorCodes, baseIframeProps, changeIframeVisibility, compressJson, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData };
|
package/dist/chunk-ZDGHKI3S.cjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkPO6YSB4Q_cjs = require('./chunk-PO6YSB4Q.cjs');
|
|
4
|
+
var viem = require('viem');
|
|
3
5
|
|
|
4
|
-
var _chunkPO6YSB4Qcjs = require('./chunk-PO6YSB4Q.cjs');
|
|
5
|
-
|
|
6
|
-
// src/interactions/pressEncoder.ts
|
|
7
|
-
var _viem = require('viem');
|
|
8
6
|
var PressInteractionEncoder = {
|
|
9
7
|
/**
|
|
10
8
|
* Encode an open article interaction
|
|
@@ -12,12 +10,12 @@ var PressInteractionEncoder = {
|
|
|
12
10
|
* @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
|
|
13
11
|
*/
|
|
14
12
|
openArticle({ articleId }) {
|
|
15
|
-
const interactionData =
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const interactionData = viem.concatHex([
|
|
14
|
+
chunkPO6YSB4Q_cjs.interactionTypes.press.openArticle,
|
|
15
|
+
viem.pad(articleId, { size: 32 })
|
|
18
16
|
]);
|
|
19
17
|
return {
|
|
20
|
-
handlerTypeDenominator:
|
|
18
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.press),
|
|
21
19
|
interactionData
|
|
22
20
|
};
|
|
23
21
|
},
|
|
@@ -27,27 +25,24 @@ var PressInteractionEncoder = {
|
|
|
27
25
|
* @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
|
|
28
26
|
*/
|
|
29
27
|
readArticle({ articleId }) {
|
|
30
|
-
const interactionData =
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const interactionData = viem.concatHex([
|
|
29
|
+
chunkPO6YSB4Q_cjs.interactionTypes.press.readArticle,
|
|
30
|
+
viem.pad(articleId, { size: 32 })
|
|
33
31
|
]);
|
|
34
32
|
return {
|
|
35
|
-
handlerTypeDenominator:
|
|
33
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.press),
|
|
36
34
|
interactionData
|
|
37
35
|
};
|
|
38
36
|
}
|
|
39
37
|
};
|
|
40
|
-
|
|
41
|
-
// src/interactions/referralEncoder.ts
|
|
42
|
-
|
|
43
38
|
var ReferralInteractionEncoder = {
|
|
44
39
|
/**
|
|
45
40
|
* Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
|
|
46
41
|
*/
|
|
47
42
|
createLink() {
|
|
48
43
|
return {
|
|
49
|
-
handlerTypeDenominator:
|
|
50
|
-
interactionData:
|
|
44
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.referral),
|
|
45
|
+
interactionData: chunkPO6YSB4Q_cjs.interactionTypes.referral.createLink
|
|
51
46
|
};
|
|
52
47
|
},
|
|
53
48
|
/**
|
|
@@ -56,19 +51,16 @@ var ReferralInteractionEncoder = {
|
|
|
56
51
|
* @param args.referrer - The Ethereum address of the user who made the referral
|
|
57
52
|
*/
|
|
58
53
|
referred({ referrer }) {
|
|
59
|
-
const interactionData =
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const interactionData = viem.concatHex([
|
|
55
|
+
chunkPO6YSB4Q_cjs.interactionTypes.referral.referred,
|
|
56
|
+
viem.pad(referrer, { size: 32 })
|
|
62
57
|
]);
|
|
63
58
|
return {
|
|
64
|
-
handlerTypeDenominator:
|
|
59
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.referral),
|
|
65
60
|
interactionData
|
|
66
61
|
};
|
|
67
62
|
}
|
|
68
63
|
};
|
|
69
|
-
|
|
70
|
-
// src/interactions/purchaseEncoder.ts
|
|
71
|
-
|
|
72
64
|
var PurchaseInteractionEncoder = {
|
|
73
65
|
/**
|
|
74
66
|
* Encode a start purchase interaction
|
|
@@ -76,12 +68,12 @@ var PurchaseInteractionEncoder = {
|
|
|
76
68
|
* @param args.purchaseId - The id of the purchase that is being started.
|
|
77
69
|
*/
|
|
78
70
|
startPurchase({ purchaseId }) {
|
|
79
|
-
const interactionData =
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
const interactionData = viem.concatHex([
|
|
72
|
+
chunkPO6YSB4Q_cjs.interactionTypes.purchase.started,
|
|
73
|
+
viem.pad(purchaseId, { size: 32 })
|
|
82
74
|
]);
|
|
83
75
|
return {
|
|
84
|
-
handlerTypeDenominator:
|
|
76
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.purchase),
|
|
85
77
|
interactionData
|
|
86
78
|
};
|
|
87
79
|
},
|
|
@@ -95,16 +87,16 @@ var PurchaseInteractionEncoder = {
|
|
|
95
87
|
purchaseId,
|
|
96
88
|
proof
|
|
97
89
|
}) {
|
|
98
|
-
const innerData =
|
|
90
|
+
const innerData = viem.encodeAbiParameters(
|
|
99
91
|
[{ type: "uint256" }, { type: "bytes32[]" }],
|
|
100
92
|
[BigInt(purchaseId), proof]
|
|
101
93
|
);
|
|
102
|
-
const interactionData =
|
|
103
|
-
|
|
94
|
+
const interactionData = viem.concatHex([
|
|
95
|
+
chunkPO6YSB4Q_cjs.interactionTypes.purchase.completed,
|
|
104
96
|
innerData
|
|
105
97
|
]);
|
|
106
98
|
return {
|
|
107
|
-
handlerTypeDenominator:
|
|
99
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.purchase),
|
|
108
100
|
interactionData
|
|
109
101
|
};
|
|
110
102
|
},
|
|
@@ -116,33 +108,27 @@ var PurchaseInteractionEncoder = {
|
|
|
116
108
|
unsafeCompletedPurchase({
|
|
117
109
|
purchaseId
|
|
118
110
|
}) {
|
|
119
|
-
const interactionData =
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
const interactionData = viem.concatHex([
|
|
112
|
+
chunkPO6YSB4Q_cjs.interactionTypes.purchase.unsafeCompleted,
|
|
113
|
+
viem.pad(purchaseId, { size: 32 })
|
|
122
114
|
]);
|
|
123
115
|
return {
|
|
124
|
-
handlerTypeDenominator:
|
|
116
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.purchase),
|
|
125
117
|
interactionData
|
|
126
118
|
};
|
|
127
119
|
}
|
|
128
120
|
};
|
|
129
|
-
|
|
130
|
-
// src/interactions/webshopEncoder.ts
|
|
131
|
-
|
|
132
121
|
var WebShopInteractionEncoder = {
|
|
133
122
|
/**
|
|
134
123
|
* Encode an open webshop interaction
|
|
135
124
|
*/
|
|
136
125
|
open() {
|
|
137
126
|
return {
|
|
138
|
-
handlerTypeDenominator:
|
|
139
|
-
interactionData:
|
|
127
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.webshop),
|
|
128
|
+
interactionData: chunkPO6YSB4Q_cjs.interactionTypes.webshop.open
|
|
140
129
|
};
|
|
141
130
|
}
|
|
142
131
|
};
|
|
143
|
-
|
|
144
|
-
// src/interactions/retailEncoder.ts
|
|
145
|
-
|
|
146
132
|
var RetailInteractionEncoder = {
|
|
147
133
|
/**
|
|
148
134
|
* Encode a customer meeting retail interaction
|
|
@@ -151,21 +137,19 @@ var RetailInteractionEncoder = {
|
|
|
151
137
|
*
|
|
152
138
|
*/
|
|
153
139
|
customerMeeting({ agencyId }) {
|
|
154
|
-
const interactionData =
|
|
155
|
-
|
|
156
|
-
|
|
140
|
+
const interactionData = viem.concatHex([
|
|
141
|
+
chunkPO6YSB4Q_cjs.interactionTypes.retail.customerMeeting,
|
|
142
|
+
viem.pad(agencyId, { size: 32 })
|
|
157
143
|
]);
|
|
158
144
|
return {
|
|
159
|
-
handlerTypeDenominator:
|
|
145
|
+
handlerTypeDenominator: viem.toHex(chunkPO6YSB4Q_cjs.productTypes.retail),
|
|
160
146
|
interactionData
|
|
161
147
|
};
|
|
162
148
|
}
|
|
163
149
|
};
|
|
164
150
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
exports.PressInteractionEncoder = PressInteractionEncoder; exports.ReferralInteractionEncoder = ReferralInteractionEncoder; exports.PurchaseInteractionEncoder = PurchaseInteractionEncoder; exports.WebShopInteractionEncoder = WebShopInteractionEncoder; exports.RetailInteractionEncoder = RetailInteractionEncoder;
|
|
151
|
+
exports.PressInteractionEncoder = PressInteractionEncoder;
|
|
152
|
+
exports.PurchaseInteractionEncoder = PurchaseInteractionEncoder;
|
|
153
|
+
exports.ReferralInteractionEncoder = ReferralInteractionEncoder;
|
|
154
|
+
exports.RetailInteractionEncoder = RetailInteractionEncoder;
|
|
155
|
+
exports.WebShopInteractionEncoder = WebShopInteractionEncoder;
|