@frak-labs/core-sdk 0.1.1 → 0.2.0

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.
Files changed (125) hide show
  1. package/README.md +58 -0
  2. package/cdn/bundle.js +14 -0
  3. package/dist/actions.cjs +1 -1
  4. package/dist/actions.d.cts +3 -3
  5. package/dist/actions.d.ts +3 -3
  6. package/dist/actions.js +1 -1
  7. package/dist/bundle.cjs +1 -1
  8. package/dist/bundle.d.cts +4 -6
  9. package/dist/bundle.d.ts +4 -6
  10. package/dist/bundle.js +1 -1
  11. package/dist/{index-CRsQWnTs.d.cts → computeLegacyProductId-BkyJ4rEY.d.ts} +197 -10
  12. package/dist/{index-Ck1hudEi.d.ts → computeLegacyProductId-Raks6FXg.d.cts} +197 -10
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.d.cts +3 -4
  15. package/dist/index.d.ts +3 -4
  16. package/dist/index.js +1 -1
  17. package/dist/{openSso-D--Airj6.d.cts → openSso-BCJGchIb.d.cts} +135 -131
  18. package/dist/{openSso-DsKJ4y0j.d.ts → openSso-DG-_9CED.d.ts} +135 -131
  19. package/dist/setupClient-CQrMDGyZ.js +13 -0
  20. package/dist/setupClient-Ccv3XxwL.cjs +13 -0
  21. package/dist/{index-d8xS4ryI.d.ts → siweAuthenticate-BH7Dn7nZ.d.cts} +90 -65
  22. package/dist/siweAuthenticate-BJHbtty4.js +1 -0
  23. package/dist/{index-C6FxkWPC.d.cts → siweAuthenticate-Btem4QHs.d.ts} +90 -65
  24. package/dist/siweAuthenticate-Cwj3HP0m.cjs +1 -0
  25. package/dist/trackEvent-M2RLTQ2p.js +1 -0
  26. package/dist/trackEvent-T_R9ER2S.cjs +1 -0
  27. package/package.json +11 -22
  28. package/src/actions/displayEmbeddedWallet.ts +1 -0
  29. package/src/actions/displayModal.test.ts +12 -11
  30. package/src/actions/displayModal.ts +7 -18
  31. package/src/actions/ensureIdentity.ts +68 -0
  32. package/src/actions/{getProductInformation.test.ts → getMerchantInformation.test.ts} +33 -50
  33. package/src/actions/getMerchantInformation.ts +16 -0
  34. package/src/actions/index.ts +3 -2
  35. package/src/actions/openSso.ts +4 -2
  36. package/src/actions/referral/processReferral.test.ts +42 -151
  37. package/src/actions/referral/processReferral.ts +18 -42
  38. package/src/actions/referral/referralInteraction.test.ts +1 -7
  39. package/src/actions/referral/referralInteraction.ts +1 -6
  40. package/src/actions/sendInteraction.ts +46 -22
  41. package/src/actions/trackPurchaseStatus.test.ts +354 -141
  42. package/src/actions/trackPurchaseStatus.ts +48 -11
  43. package/src/actions/watchWalletStatus.ts +2 -3
  44. package/src/actions/wrapper/modalBuilder.test.ts +0 -14
  45. package/src/actions/wrapper/modalBuilder.ts +3 -12
  46. package/src/bundle.ts +0 -1
  47. package/src/clients/createIFrameFrakClient.ts +10 -5
  48. package/src/clients/transports/iframeLifecycleManager.test.ts +163 -4
  49. package/src/clients/transports/iframeLifecycleManager.ts +172 -33
  50. package/src/constants/interactionTypes.ts +12 -41
  51. package/src/index.ts +24 -16
  52. package/src/types/config.ts +6 -0
  53. package/src/types/index.ts +13 -10
  54. package/src/types/lifecycle/client.ts +24 -1
  55. package/src/types/lifecycle/iframe.ts +6 -0
  56. package/src/types/rpc/displayModal.ts +2 -4
  57. package/src/types/rpc/embedded/index.ts +2 -2
  58. package/src/types/rpc/interaction.ts +26 -39
  59. package/src/types/rpc/merchantInformation.ts +77 -0
  60. package/src/types/rpc/modal/index.ts +0 -4
  61. package/src/types/rpc/modal/login.ts +5 -1
  62. package/src/types/rpc/walletStatus.ts +1 -7
  63. package/src/types/rpc.ts +22 -30
  64. package/src/types/tracking.ts +60 -0
  65. package/src/utils/backendUrl.test.ts +83 -0
  66. package/src/utils/backendUrl.ts +62 -0
  67. package/src/utils/clientId.test.ts +41 -0
  68. package/src/utils/clientId.ts +43 -0
  69. package/src/utils/compression/compress.test.ts +1 -1
  70. package/src/utils/compression/compress.ts +2 -2
  71. package/src/utils/compression/decompress.test.ts +8 -4
  72. package/src/utils/compression/decompress.ts +2 -2
  73. package/src/utils/{computeProductId.ts → computeLegacyProductId.ts} +2 -2
  74. package/src/utils/constants.ts +5 -0
  75. package/src/utils/deepLinkWithFallback.test.ts +243 -0
  76. package/src/utils/deepLinkWithFallback.ts +103 -0
  77. package/src/utils/formatAmount.ts +6 -0
  78. package/src/utils/iframeHelper.test.ts +18 -5
  79. package/src/utils/iframeHelper.ts +10 -3
  80. package/src/utils/index.ts +16 -1
  81. package/src/utils/merchantId.test.ts +653 -0
  82. package/src/utils/merchantId.ts +143 -0
  83. package/src/utils/sso.ts +18 -11
  84. package/src/utils/trackEvent.test.ts +23 -5
  85. package/src/utils/trackEvent.ts +13 -0
  86. package/cdn/bundle.iife.js +0 -14
  87. package/dist/actions-B5j-i1p0.cjs +0 -1
  88. package/dist/actions-q090Z0oR.js +0 -1
  89. package/dist/index-7OZ39x1U.d.ts +0 -195
  90. package/dist/index-zDq-VlKx.d.cts +0 -195
  91. package/dist/interaction-DMJ3ZfaF.d.cts +0 -45
  92. package/dist/interaction-KX1h9a7V.d.ts +0 -45
  93. package/dist/interactions-DnfM3oe0.js +0 -1
  94. package/dist/interactions-EIXhNLf6.cjs +0 -1
  95. package/dist/interactions.cjs +0 -1
  96. package/dist/interactions.d.cts +0 -2
  97. package/dist/interactions.d.ts +0 -2
  98. package/dist/interactions.js +0 -1
  99. package/dist/productTypes-BUkXJKZ7.cjs +0 -1
  100. package/dist/productTypes-CGb1MmBF.js +0 -1
  101. package/dist/src-1LQ4eLq5.js +0 -13
  102. package/dist/src-hW71KjPN.cjs +0 -13
  103. package/dist/trackEvent-CHnYa85W.js +0 -1
  104. package/dist/trackEvent-GuQm_1Nm.cjs +0 -1
  105. package/src/actions/getProductInformation.ts +0 -14
  106. package/src/actions/openSso.test.ts +0 -407
  107. package/src/actions/sendInteraction.test.ts +0 -219
  108. package/src/constants/interactionTypes.test.ts +0 -128
  109. package/src/constants/productTypes.test.ts +0 -130
  110. package/src/constants/productTypes.ts +0 -33
  111. package/src/interactions/index.ts +0 -5
  112. package/src/interactions/pressEncoder.test.ts +0 -215
  113. package/src/interactions/pressEncoder.ts +0 -53
  114. package/src/interactions/purchaseEncoder.test.ts +0 -291
  115. package/src/interactions/purchaseEncoder.ts +0 -99
  116. package/src/interactions/referralEncoder.test.ts +0 -170
  117. package/src/interactions/referralEncoder.ts +0 -47
  118. package/src/interactions/retailEncoder.test.ts +0 -107
  119. package/src/interactions/retailEncoder.ts +0 -37
  120. package/src/interactions/webshopEncoder.test.ts +0 -56
  121. package/src/interactions/webshopEncoder.ts +0 -30
  122. package/src/types/rpc/modal/openSession.ts +0 -25
  123. package/src/types/rpc/productInformation.ts +0 -59
  124. package/src/utils/computeProductId.test.ts +0 -80
  125. package/src/utils/sso.test.ts +0 -361
@@ -1,195 +0,0 @@
1
- import { t as PreparedInteraction } from "./interaction-KX1h9a7V.js";
2
- import { Address, Hex } from "viem";
3
-
4
- //#region src/interactions/pressEncoder.d.ts
5
-
6
- /**
7
- * Press interactions allow you to track user engagement with articles or other press content on your platform.
8
- * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
9
- *
10
- * :::info
11
- * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
12
- * :::
13
- *
14
- * @description Encode press related user interactions
15
- *
16
- * @group Interactions Encoder
17
- *
18
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
19
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
20
- */
21
- declare const PressInteractionEncoder: {
22
- /**
23
- * Encode an open article interaction
24
- * @param args
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
26
- */
27
- openArticle({
28
- articleId
29
- }: {
30
- articleId: Hex;
31
- }): PreparedInteraction;
32
- /**
33
- * Encode a read article interaction
34
- * @param args
35
- * @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
36
- */
37
- readArticle({
38
- articleId
39
- }: {
40
- articleId: Hex;
41
- }): PreparedInteraction;
42
- };
43
- //#endregion
44
- //#region src/interactions/purchaseEncoder.d.ts
45
- /**
46
- * Purchase interactions allow you to track user purchases on your platform.
47
- * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
48
- *
49
- * :::info
50
- * To properly handle purchase interactions, ensure that the "Purchase" product type is enabled in your Business dashboard, and that you have set up everything correctly in the `Purchasetracker` section.
51
- * :::
52
- *
53
- * :::note
54
- * The `purchaseId` is used on both interactions. It can be computed like this:
55
- *
56
- * ```ts
57
- * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
58
- * ```
59
- *
60
- * With:
61
- * - `productId`: The id of your product, you can find it in the product dashboard.
62
- * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
63
- * :::
64
- *
65
- * @description Encode purchase related user interactions
66
- *
67
- * @group Interactions Encoder
68
- *
69
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
70
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
71
- * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
72
- * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
73
- * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
74
- */
75
- declare const PurchaseInteractionEncoder: {
76
- /**
77
- * Encode a start purchase interaction
78
- * @param args
79
- * @param args.purchaseId - The id of the purchase that is being started.
80
- */
81
- startPurchase({
82
- purchaseId
83
- }: {
84
- purchaseId: Hex;
85
- }): PreparedInteraction;
86
- /**
87
- * Encode a complete purchase interaction
88
- * @param args
89
- * @param args.purchaseId - The id of the purchase that is being completed.
90
- * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
91
- */
92
- completedPurchase({
93
- purchaseId,
94
- proof
95
- }: {
96
- purchaseId: Hex;
97
- proof: Hex[];
98
- }): PreparedInteraction;
99
- /**
100
- * Encode an unsafe complete purchase interaction (when we can't provide the proof)
101
- * @param args
102
- * @param args.purchaseId - The id of the purchase that is being completed.
103
- */
104
- unsafeCompletedPurchase({
105
- purchaseId
106
- }: {
107
- purchaseId: Hex;
108
- }): PreparedInteraction;
109
- };
110
- //#endregion
111
- //#region src/interactions/referralEncoder.d.ts
112
- /**
113
- * Referral interactions allow you to track user sharing activities.
114
- * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
115
- *
116
- * :::info
117
- * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
118
- * :::
119
- *
120
- * @description Encode referral related user interactions
121
- *
122
- * @group Interactions Encoder
123
- *
124
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
125
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
126
- */
127
- declare const ReferralInteractionEncoder: {
128
- /**
129
- * 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.
130
- */
131
- createLink(): PreparedInteraction;
132
- /**
133
- * Encode a referred interaction
134
- * @param args
135
- * @param args.referrer - The Ethereum address of the user who made the referral
136
- */
137
- referred({
138
- referrer
139
- }: {
140
- referrer: Address;
141
- }): PreparedInteraction;
142
- };
143
- //#endregion
144
- //#region src/interactions/retailEncoder.d.ts
145
- /**
146
- * Retail interactions allow you to track user activities on your retails products.
147
- *
148
- * :::info
149
- * To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
150
- * :::
151
- *
152
- * @description Encode retail related user interactions
153
- *
154
- * @group Interactions Encoder
155
- *
156
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
157
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
158
- */
159
- declare const RetailInteractionEncoder: {
160
- /**
161
- * Encode a customer meeting retail interaction
162
- * @param args
163
- * @param args.agencyId - The id of the agency that the customer is meeting with
164
- *
165
- */
166
- customerMeeting({
167
- agencyId
168
- }: {
169
- agencyId: Hex;
170
- }): PreparedInteraction;
171
- };
172
- //#endregion
173
- //#region src/interactions/webshopEncoder.d.ts
174
- /**
175
- * Webshop interactions allow you to track user activities on your webshop.
176
- *
177
- * :::info
178
- * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
179
- * :::
180
- *
181
- * @description Encode webshop related user interactions
182
- *
183
- * @group Interactions Encoder
184
- *
185
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
186
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
187
- */
188
- declare const WebShopInteractionEncoder: {
189
- /**
190
- * Encode an open webshop interaction
191
- */
192
- open(): PreparedInteraction;
193
- };
194
- //#endregion
195
- export { PressInteractionEncoder as a, PurchaseInteractionEncoder as i, RetailInteractionEncoder as n, ReferralInteractionEncoder as r, WebShopInteractionEncoder as t };
@@ -1,195 +0,0 @@
1
- import { t as PreparedInteraction } from "./interaction-DMJ3ZfaF.cjs";
2
- import { Address, Hex } from "viem";
3
-
4
- //#region src/interactions/pressEncoder.d.ts
5
-
6
- /**
7
- * Press interactions allow you to track user engagement with articles or other press content on your platform.
8
- * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
9
- *
10
- * :::info
11
- * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
12
- * :::
13
- *
14
- * @description Encode press related user interactions
15
- *
16
- * @group Interactions Encoder
17
- *
18
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
19
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
20
- */
21
- declare const PressInteractionEncoder: {
22
- /**
23
- * Encode an open article interaction
24
- * @param args
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
26
- */
27
- openArticle({
28
- articleId
29
- }: {
30
- articleId: Hex;
31
- }): PreparedInteraction;
32
- /**
33
- * Encode a read article interaction
34
- * @param args
35
- * @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
36
- */
37
- readArticle({
38
- articleId
39
- }: {
40
- articleId: Hex;
41
- }): PreparedInteraction;
42
- };
43
- //#endregion
44
- //#region src/interactions/purchaseEncoder.d.ts
45
- /**
46
- * Purchase interactions allow you to track user purchases on your platform.
47
- * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
48
- *
49
- * :::info
50
- * To properly handle purchase interactions, ensure that the "Purchase" product type is enabled in your Business dashboard, and that you have set up everything correctly in the `Purchasetracker` section.
51
- * :::
52
- *
53
- * :::note
54
- * The `purchaseId` is used on both interactions. It can be computed like this:
55
- *
56
- * ```ts
57
- * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
58
- * ```
59
- *
60
- * With:
61
- * - `productId`: The id of your product, you can find it in the product dashboard.
62
- * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
63
- * :::
64
- *
65
- * @description Encode purchase related user interactions
66
- *
67
- * @group Interactions Encoder
68
- *
69
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
70
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
71
- * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
72
- * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
73
- * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
74
- */
75
- declare const PurchaseInteractionEncoder: {
76
- /**
77
- * Encode a start purchase interaction
78
- * @param args
79
- * @param args.purchaseId - The id of the purchase that is being started.
80
- */
81
- startPurchase({
82
- purchaseId
83
- }: {
84
- purchaseId: Hex;
85
- }): PreparedInteraction;
86
- /**
87
- * Encode a complete purchase interaction
88
- * @param args
89
- * @param args.purchaseId - The id of the purchase that is being completed.
90
- * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
91
- */
92
- completedPurchase({
93
- purchaseId,
94
- proof
95
- }: {
96
- purchaseId: Hex;
97
- proof: Hex[];
98
- }): PreparedInteraction;
99
- /**
100
- * Encode an unsafe complete purchase interaction (when we can't provide the proof)
101
- * @param args
102
- * @param args.purchaseId - The id of the purchase that is being completed.
103
- */
104
- unsafeCompletedPurchase({
105
- purchaseId
106
- }: {
107
- purchaseId: Hex;
108
- }): PreparedInteraction;
109
- };
110
- //#endregion
111
- //#region src/interactions/referralEncoder.d.ts
112
- /**
113
- * Referral interactions allow you to track user sharing activities.
114
- * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
115
- *
116
- * :::info
117
- * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
118
- * :::
119
- *
120
- * @description Encode referral related user interactions
121
- *
122
- * @group Interactions Encoder
123
- *
124
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
125
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
126
- */
127
- declare const ReferralInteractionEncoder: {
128
- /**
129
- * 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.
130
- */
131
- createLink(): PreparedInteraction;
132
- /**
133
- * Encode a referred interaction
134
- * @param args
135
- * @param args.referrer - The Ethereum address of the user who made the referral
136
- */
137
- referred({
138
- referrer
139
- }: {
140
- referrer: Address;
141
- }): PreparedInteraction;
142
- };
143
- //#endregion
144
- //#region src/interactions/retailEncoder.d.ts
145
- /**
146
- * Retail interactions allow you to track user activities on your retails products.
147
- *
148
- * :::info
149
- * To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
150
- * :::
151
- *
152
- * @description Encode retail related user interactions
153
- *
154
- * @group Interactions Encoder
155
- *
156
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
157
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
158
- */
159
- declare const RetailInteractionEncoder: {
160
- /**
161
- * Encode a customer meeting retail interaction
162
- * @param args
163
- * @param args.agencyId - The id of the agency that the customer is meeting with
164
- *
165
- */
166
- customerMeeting({
167
- agencyId
168
- }: {
169
- agencyId: Hex;
170
- }): PreparedInteraction;
171
- };
172
- //#endregion
173
- //#region src/interactions/webshopEncoder.d.ts
174
- /**
175
- * Webshop interactions allow you to track user activities on your webshop.
176
- *
177
- * :::info
178
- * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
179
- * :::
180
- *
181
- * @description Encode webshop related user interactions
182
- *
183
- * @group Interactions Encoder
184
- *
185
- * @see {@link PreparedInteraction} The prepared interaction object that can be sent
186
- * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
187
- */
188
- declare const WebShopInteractionEncoder: {
189
- /**
190
- * Encode an open webshop interaction
191
- */
192
- open(): PreparedInteraction;
193
- };
194
- //#endregion
195
- export { PressInteractionEncoder as a, PurchaseInteractionEncoder as i, RetailInteractionEncoder as n, ReferralInteractionEncoder as r, WebShopInteractionEncoder as t };
@@ -1,45 +0,0 @@
1
- import { Hex } from "viem";
2
-
3
- //#region src/types/rpc/interaction.d.ts
4
-
5
- /**
6
- * Represent a prepared user interaction, ready to be sent on-chain via the wallet
7
- */
8
- type PreparedInteraction = {
9
- handlerTypeDenominator: Hex;
10
- interactionData: Hex;
11
- };
12
- /**
13
- * Parameters that will be used to send an interaction to the blockchain
14
- * @inline
15
- */
16
- type SendInteractionParamsType = {
17
- /**
18
- * The product id where this interaction has been made
19
- * @defaultValue keccak256(toHex(window.location.host))
20
- */
21
- productId?: Hex;
22
- /**
23
- * The prepared interaction, built from an Interaction Encoder
24
- */
25
- interaction: PreparedInteraction;
26
- /**
27
- * A pre-computed interaction signature
28
- * If none provided, the delegated interaction validator of your product will sign it (you can manage it in the business dashboard)
29
- *
30
- * @defaultValue undefined
31
- */
32
- validation?: Hex;
33
- };
34
- /**
35
- * Return type of the send interaction rpc request
36
- * @group RPC Schema
37
- */
38
- type SendInteractionReturnType = {
39
- /**
40
- * The id of the interaction in the interaction pool
41
- */
42
- delegationId: string;
43
- };
44
- //#endregion
45
- export { SendInteractionParamsType as n, SendInteractionReturnType as r, PreparedInteraction as t };
@@ -1,45 +0,0 @@
1
- import { Hex } from "viem";
2
-
3
- //#region src/types/rpc/interaction.d.ts
4
-
5
- /**
6
- * Represent a prepared user interaction, ready to be sent on-chain via the wallet
7
- */
8
- type PreparedInteraction = {
9
- handlerTypeDenominator: Hex;
10
- interactionData: Hex;
11
- };
12
- /**
13
- * Parameters that will be used to send an interaction to the blockchain
14
- * @inline
15
- */
16
- type SendInteractionParamsType = {
17
- /**
18
- * The product id where this interaction has been made
19
- * @defaultValue keccak256(toHex(window.location.host))
20
- */
21
- productId?: Hex;
22
- /**
23
- * The prepared interaction, built from an Interaction Encoder
24
- */
25
- interaction: PreparedInteraction;
26
- /**
27
- * A pre-computed interaction signature
28
- * If none provided, the delegated interaction validator of your product will sign it (you can manage it in the business dashboard)
29
- *
30
- * @defaultValue undefined
31
- */
32
- validation?: Hex;
33
- };
34
- /**
35
- * Return type of the send interaction rpc request
36
- * @group RPC Schema
37
- */
38
- type SendInteractionReturnType = {
39
- /**
40
- * The id of the interaction in the interaction pool
41
- */
42
- delegationId: string;
43
- };
44
- //#endregion
45
- export { SendInteractionParamsType as n, SendInteractionReturnType as r, PreparedInteraction as t };
@@ -1 +0,0 @@
1
- import{r as e,t}from"./productTypes-CGb1MmBF.js";import{concatHex as n,encodeAbiParameters as r,pad as i,toHex as a}from"viem";const o={openArticle({articleId:r}){let o=n([e.press.openArticle,i(r,{size:32})]);return{handlerTypeDenominator:a(t.press),interactionData:o}},readArticle({articleId:r}){let o=n([e.press.readArticle,i(r,{size:32})]);return{handlerTypeDenominator:a(t.press),interactionData:o}}},s={startPurchase({purchaseId:r}){let o=n([e.purchase.started,i(r,{size:32})]);return{handlerTypeDenominator:a(t.purchase),interactionData:o}},completedPurchase({purchaseId:i,proof:o}){let s=r([{type:`uint256`},{type:`bytes32[]`}],[BigInt(i),o]),c=n([e.purchase.completed,s]);return{handlerTypeDenominator:a(t.purchase),interactionData:c}},unsafeCompletedPurchase({purchaseId:r}){let o=n([e.purchase.unsafeCompleted,i(r,{size:32})]);return{handlerTypeDenominator:a(t.purchase),interactionData:o}}},c={createLink(){return{handlerTypeDenominator:a(t.referral),interactionData:e.referral.createLink}},referred({referrer:r}){let o=n([e.referral.referred,i(r,{size:32})]);return{handlerTypeDenominator:a(t.referral),interactionData:o}}},l={customerMeeting({agencyId:r}){let o=n([e.retail.customerMeeting,i(r,{size:32})]);return{handlerTypeDenominator:a(t.retail),interactionData:o}}},u={open(){return{handlerTypeDenominator:a(t.webshop),interactionData:e.webshop.open}}};export{o as a,s as i,l as n,c as r,u as t};
@@ -1 +0,0 @@
1
- const e=require(`./productTypes-BUkXJKZ7.cjs`);let t=require(`viem`);const n={openArticle({articleId:n}){let r=(0,t.concatHex)([e.r.press.openArticle,(0,t.pad)(n,{size:32})]);return{handlerTypeDenominator:(0,t.toHex)(e.t.press),interactionData:r}},readArticle({articleId:n}){let r=(0,t.concatHex)([e.r.press.readArticle,(0,t.pad)(n,{size:32})]);return{handlerTypeDenominator:(0,t.toHex)(e.t.press),interactionData:r}}},r={startPurchase({purchaseId:n}){let r=(0,t.concatHex)([e.r.purchase.started,(0,t.pad)(n,{size:32})]);return{handlerTypeDenominator:(0,t.toHex)(e.t.purchase),interactionData:r}},completedPurchase({purchaseId:n,proof:r}){let i=(0,t.encodeAbiParameters)([{type:`uint256`},{type:`bytes32[]`}],[BigInt(n),r]),a=(0,t.concatHex)([e.r.purchase.completed,i]);return{handlerTypeDenominator:(0,t.toHex)(e.t.purchase),interactionData:a}},unsafeCompletedPurchase({purchaseId:n}){let r=(0,t.concatHex)([e.r.purchase.unsafeCompleted,(0,t.pad)(n,{size:32})]);return{handlerTypeDenominator:(0,t.toHex)(e.t.purchase),interactionData:r}}},i={createLink(){return{handlerTypeDenominator:(0,t.toHex)(e.t.referral),interactionData:e.r.referral.createLink}},referred({referrer:n}){let r=(0,t.concatHex)([e.r.referral.referred,(0,t.pad)(n,{size:32})]);return{handlerTypeDenominator:(0,t.toHex)(e.t.referral),interactionData:r}}},a={customerMeeting({agencyId:n}){let r=(0,t.concatHex)([e.r.retail.customerMeeting,(0,t.pad)(n,{size:32})]);return{handlerTypeDenominator:(0,t.toHex)(e.t.retail),interactionData:r}}},o={open(){return{handlerTypeDenominator:(0,t.toHex)(e.t.webshop),interactionData:e.r.webshop.open}}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
@@ -1 +0,0 @@
1
- const e=require(`./interactions-EIXhNLf6.cjs`);exports.PressInteractionEncoder=e.a,exports.PurchaseInteractionEncoder=e.i,exports.ReferralInteractionEncoder=e.r,exports.RetailInteractionEncoder=e.n,exports.WebShopInteractionEncoder=e.t;
@@ -1,2 +0,0 @@
1
- import { a as PressInteractionEncoder, i as PurchaseInteractionEncoder, n as RetailInteractionEncoder, r as ReferralInteractionEncoder, t as WebShopInteractionEncoder } from "./index-zDq-VlKx.cjs";
2
- export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder };
@@ -1,2 +0,0 @@
1
- import { a as PressInteractionEncoder, i as PurchaseInteractionEncoder, n as RetailInteractionEncoder, r as ReferralInteractionEncoder, t as WebShopInteractionEncoder } from "./index-7OZ39x1U.js";
2
- export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder };
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"./interactions-DnfM3oe0.js";export{e as PressInteractionEncoder,t as PurchaseInteractionEncoder,r as ReferralInteractionEncoder,n as RetailInteractionEncoder,i as WebShopInteractionEncoder};
@@ -1 +0,0 @@
1
- const e={press:{openArticle:`0xc0a24ffb`,readArticle:`0xd5bd0fbe`},dapp:{proofVerifiableStorageUpdate:`0x2ab2aeef`,callableVerifiableStorageUpdate:`0xa07da986`},webshop:{open:`0xb311798f`},referral:{referred:`0x010cc3b9`,createLink:`0xb2c0f17c`},purchase:{started:`0xd87e90c3`,completed:`0x8403aeb4`,unsafeCompleted:`0x4d5b14e0`},retail:{customerMeeting:`0x74489004`}},t={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},n=Object.entries(t).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
@@ -1 +0,0 @@
1
- const e={press:{openArticle:`0xc0a24ffb`,readArticle:`0xd5bd0fbe`},dapp:{proofVerifiableStorageUpdate:`0x2ab2aeef`,callableVerifiableStorageUpdate:`0xa07da986`},webshop:{open:`0xb311798f`},referral:{referred:`0x010cc3b9`,createLink:`0xb2c0f17c`},purchase:{started:`0xd87e90c3`,completed:`0x8403aeb4`,unsafeCompleted:`0x4d5b14e0`},retail:{customerMeeting:`0x74489004`}},t={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},n=Object.entries(t).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{});export{n,e as r,t};
@@ -1,13 +0,0 @@
1
- import{c as e}from"./trackEvent-CHnYa85W.js";import{Deferred as t,FrakRpcError as n,RpcErrorCodes as r,createRpcClient as i,decompressJson as a}from"@frak-labs/frame-connector";import{createClientCompressionMiddleware as o}from"@frak-labs/frame-connector/middleware";import{OpenPanel as s}from"@openpanel/web";const c=`nexus-wallet-backup`;function l(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var u=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let t=this.getIframeStatus(),r=this.getNavigatorInfo(),i=`Unknown`;return e instanceof n?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:r?this.base64Encode(r):`no-navigator`,iframeStatus:t?this.base64Encode(t):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
- Debug Information:
3
- -----------------
4
- Timestamp: ${t.timestamp}
5
- URL: ${t.encodedUrl}
6
- Config: ${t.encodedConfig}
7
- Navigator Info: ${t.navigatorInfo}
8
- IFrame Status: ${t.iframeStatus}
9
- Last Request: ${t.lastRequest}
10
- Last Response: ${t.lastResponse}
11
- Client Status: ${t.clientStatus}
12
- Error: ${t.error}
13
- `.trim()}};const d={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function f({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=d.id,r.name=d.name,r.allow=d.allow,r.style.zIndex=d.style.zIndex.toString(),p({iframe:r,isVisible:!1}),document.body.appendChild(r),new Promise(n=>{r?.addEventListener(`load`,()=>n(r)),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`})}function p({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function m(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function h({iframe:e}){let n=new t;return{handleEvent:async t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:r,data:i}=t;switch(r){case`connected`:n.resolve(!0);break;case`do-backup`:i.backup?localStorage.setItem(c,i.backup):localStorage.removeItem(c);break;case`remove-backup`:localStorage.removeItem(c);break;case`show`:case`hide`:p({iframe:e,isVisible:r===`show`});break;case`handshake`:e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:i.token,currentUrl:window.location.href}},`*`);break;case`redirect`:{let e=new URL(i.baseRedirectUrl);e.searchParams.has(`u`)?(e.searchParams.delete(`u`),e.searchParams.append(`u`,window.location.href),window.location.href=e.toString()):window.location.href=i.baseRedirectUrl;break}}},isConnected:n.promise}}function g({config:e,iframe:t}){let a=e?.walletUrl??`https://wallet.frak.id`,c=h({iframe:t}),l=new u(e,t);if(!t.contentWindow)throw new n(r.configError,`The iframe does not have a content window`);let d=i({emittingTransport:t.contentWindow,listeningTransport:window,targetOrigin:a,middleware:[{async onRequest(e,t){if(!await c.isConnected)throw new n(r.clientNotConnected,`The iframe provider isn't connected yet`);return t}},o(),{onRequest(e,t){return l.setLastRequest(e),t},onResponse(e,t){return l.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await c.handleEvent(e)}}}),f=_(d,c),p=async()=>{f(),d.cleanup(),t.remove()},m;console.log(`[Frak SDK] Initializing OpenPanel`),m=new s({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`}),!0)}),m.setGlobalProperties({sdkVersion:`0.1.1`}),m.init();let g=v({config:e,rpcClient:d,lifecycleManager:c}).then(()=>l.updateSetupStatus(!0));return{config:e,debugInfo:l,waitForConnection:c.isConnected,waitForSetup:g,request:d.request,listenerRequest:d.listen,destroy:p,openPanel:m}}function _(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function v({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,l(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function i(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function a(){if(typeof window>`u`)return;let e=window.localStorage.getItem(c);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),i(),a()])}function y(t){return a(e(t))}const b={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function x(e){return e&&e in b?e:`eur`}function S(e){return e?b[e]??b.eur:b.eur}function C(e,t){let n=S(t),r=x(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function w(e){return e?`${e}Amount`:`eurAmount`}async function T({config:e}){let t=E(e),n=await f({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=g({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function E(e){let t=x(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}export{x as a,g as c,m as d,u as f,S as i,d as l,w as n,b as o,C as r,y as s,T as t,f as u};
@@ -1,13 +0,0 @@
1
- const e=require(`./trackEvent-GuQm_1Nm.cjs`);let t=require(`@frak-labs/frame-connector`),n=require(`@frak-labs/frame-connector/middleware`),r=require(`@openpanel/web`);const i=`nexus-wallet-backup`;function a(e,t){if(typeof window>`u`)return;let n=new URL(window.location.href),r=n.searchParams.get(`sso`);r&&(t.then(()=>{e.sendLifecycle({clientLifecycle:`sso-redirect-complete`,data:{compressed:r}}),console.log(`[SSO URL Listener] Forwarded compressed SSO data to iframe`)}).catch(e=>{console.error(`[SSO URL Listener] Failed to forward SSO data:`,e)}),n.searchParams.delete(`sso`),window.history.replaceState({},``,n.toString()),console.log(`[SSO URL Listener] SSO parameter detected and URL cleaned`))}var o=class e{config;iframe;isSetupDone=!1;lastResponse=null;lastRequest=null;constructor(e,t){this.config=e,this.iframe=t,this.lastRequest=null,this.lastResponse=null}setLastResponse(e,t){this.lastResponse={message:e,response:t,timestamp:Date.now()}}setLastRequest(e){this.lastRequest={event:e,timestamp:Date.now()}}updateSetupStatus(e){this.isSetupDone=e}base64Encode(e){try{return btoa(JSON.stringify(e))}catch(e){return console.warn(`Failed to encode debug data`,e),btoa(`Failed to encode data`)}}getIframeStatus(){return this.iframe?{loading:this.iframe.hasAttribute(`loading`),url:this.iframe.src,readyState:this.iframe.contentDocument?.readyState?this.iframe.contentDocument.readyState===`complete`?1:0:-1,contentWindow:!!this.iframe.contentWindow,isConnected:this.iframe.isConnected}:null}getNavigatorInfo(){return navigator?{userAgent:navigator.userAgent,language:navigator.language,onLine:navigator.onLine,screenWidth:window.screen.width,screenHeight:window.screen.height,pixelRatio:window.devicePixelRatio}:null}gatherDebugInfo(e){let n=this.getIframeStatus(),r=this.getNavigatorInfo(),i=`Unknown`;return e instanceof t.FrakRpcError?i=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?i=e.message:typeof e==`string`&&(i=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):`no-config`,navigatorInfo:r?this.base64Encode(r):`no-navigator`,iframeStatus:n?this.base64Encode(n):`not-iframe`,lastRequest:this.lastRequest?this.base64Encode(this.lastRequest):`No Frak request logged`,lastResponse:this.lastResponse?this.base64Encode(this.lastResponse):`No Frak response logged`,clientStatus:this.isSetupDone?`setup`:`not-setup`,error:i}}static empty(){return new e}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
- Debug Information:
3
- -----------------
4
- Timestamp: ${t.timestamp}
5
- URL: ${t.encodedUrl}
6
- Config: ${t.encodedConfig}
7
- Navigator Info: ${t.navigatorInfo}
8
- IFrame Status: ${t.iframeStatus}
9
- Last Request: ${t.lastRequest}
10
- Last Response: ${t.lastResponse}
11
- Client Status: ${t.clientStatus}
12
- Error: ${t.error}
13
- `.trim()}};const s={id:`frak-wallet`,name:`frak-wallet`,title:`Frak Wallet`,allow:`publickey-credentials-get *; clipboard-write; web-share *`,style:{width:`0`,height:`0`,border:`0`,position:`absolute`,zIndex:2000001,top:`-1000px`,left:`-1000px`,colorScheme:`auto`}};function c({walletBaseUrl:e,config:t}){let n=document.querySelector(`#frak-wallet`);n&&n.remove();let r=document.createElement(`iframe`);return r.id=s.id,r.name=s.name,r.allow=s.allow,r.style.zIndex=s.style.zIndex.toString(),l({iframe:r,isVisible:!1}),document.body.appendChild(r),new Promise(n=>{r?.addEventListener(`load`,()=>n(r)),r.src=`${t?.walletUrl??e??`https://wallet.frak.id`}/listener`})}function l({iframe:e,isVisible:t}){if(!t){e.style.width=`0`,e.style.height=`0`,e.style.border=`0`,e.style.position=`fixed`,e.style.top=`-1000px`,e.style.left=`-1000px`;return}e.style.position=`fixed`,e.style.top=`0`,e.style.left=`0`,e.style.width=`100%`,e.style.height=`100%`,e.style.pointerEvents=`auto`}function u(e=`/listener`){if(!window.opener)return null;let t=t=>{try{return t.location.origin===window.location.origin&&t.location.pathname===e}catch{return!1}};if(t(window.opener))return window.opener;try{let e=window.opener.frames;for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}catch(t){return console.error(`[findIframeInOpener] Error finding iframe with pathname ${e}:`,t),null}}function d({iframe:e}){let n=new t.Deferred;return{handleEvent:async t=>{if(!(`iframeLifecycle`in t))return;let{iframeLifecycle:r,data:a}=t;switch(r){case`connected`:n.resolve(!0);break;case`do-backup`:a.backup?localStorage.setItem(i,a.backup):localStorage.removeItem(i);break;case`remove-backup`:localStorage.removeItem(i);break;case`show`:case`hide`:l({iframe:e,isVisible:r===`show`});break;case`handshake`:e.contentWindow?.postMessage({clientLifecycle:`handshake-response`,data:{token:a.token,currentUrl:window.location.href}},`*`);break;case`redirect`:{let e=new URL(a.baseRedirectUrl);e.searchParams.has(`u`)?(e.searchParams.delete(`u`),e.searchParams.append(`u`,window.location.href),window.location.href=e.toString()):window.location.href=a.baseRedirectUrl;break}}},isConnected:n.promise}}function f({config:e,iframe:i}){let a=e?.walletUrl??`https://wallet.frak.id`,s=d({iframe:i}),c=new o(e,i);if(!i.contentWindow)throw new t.FrakRpcError(t.RpcErrorCodes.configError,`The iframe does not have a content window`);let l=(0,t.createRpcClient)({emittingTransport:i.contentWindow,listeningTransport:window,targetOrigin:a,middleware:[{async onRequest(e,n){if(!await s.isConnected)throw new t.FrakRpcError(t.RpcErrorCodes.clientNotConnected,`The iframe provider isn't connected yet`);return n}},(0,n.createClientCompressionMiddleware)(),{onRequest(e,t){return c.setLastRequest(e),t},onResponse(e,t){return c.setLastResponse(e,t),t}}],lifecycleHandlers:{iframeLifecycle:async(e,t)=>{await s.handleEvent(e)}}}),u=p(l,s),f=async()=>{u(),l.cleanup(),i.remove()},h;console.log(`[Frak SDK] Initializing OpenPanel`),h=new r.OpenPanel({apiUrl:`https://op-api.gcp.frak.id`,clientId:`f305d11d-b93b-487c-80d4-92deb7903e98`,trackScreenViews:!0,trackOutgoingLinks:!0,trackAttributes:!1,filter:({type:e,payload:t})=>(e!==`track`||!t?.properties||`sdkVersion`in t.properties||(t.properties={...t.properties,sdkVersion:`0.1.1`}),!0)}),h.setGlobalProperties({sdkVersion:`0.1.1`}),h.init();let g=m({config:e,rpcClient:l,lifecycleManager:s}).then(()=>c.updateSetupStatus(!0));return{config:e,debugInfo:c,waitForConnection:s.isConnected,waitForSetup:g,request:l.request,listenerRequest:l.listen,destroy:f,openPanel:h}}function p(e,t){let n,r,i=()=>e.sendLifecycle({clientLifecycle:`heartbeat`});async function a(){i(),n=setInterval(i,1e3),r=setTimeout(()=>{o(),console.log(`Heartbeat timeout: connection failed`)},3e4),await t.isConnected,o()}function o(){n&&clearInterval(n),r&&clearTimeout(r)}return a(),o}async function m({config:e,rpcClient:t,lifecycleManager:n}){await n.isConnected,a(t,n.isConnected);async function r(){let n=e.customizations?.css;if(!n)return;let r={clientLifecycle:`modal-css`,data:{cssLink:n}};t.sendLifecycle(r)}async function o(){let n=e.customizations?.i18n;if(!n)return;let r={clientLifecycle:`modal-i18n`,data:{i18n:n}};t.sendLifecycle(r)}async function s(){if(typeof window>`u`)return;let e=window.localStorage.getItem(i);if(!e)return;let n={clientLifecycle:`restore-backup`,data:{backup:e}};t.sendLifecycle(n)}await Promise.allSettled([r(),o(),s()])}function h(n){return(0,t.decompressJson)(e.c(n))}const g={eur:`fr-FR`,usd:`en-US`,gbp:`en-GB`};function _(e){return e&&e in g?e:`eur`}function v(e){return e?g[e]??g.eur:g.eur}function y(e,t){let n=v(t),r=_(t);return e.toLocaleString(n,{style:`currency`,currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function b(e){return e?`${e}Amount`:`eurAmount`}async function x({config:e}){let t=S(e),n=await c({config:t});if(!n){console.error(`Failed to create iframe`);return}let r=f({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error(`Failed to connect to client`);return}return r}function S(e){let t=_(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return c}});
@@ -1 +0,0 @@
1
- import{bytesToHex as e,hexToBytes as t,keccak256 as n,toHex as r}from"viem";import{compressJson as i}from"@frak-labs/frame-connector";function a({domain:e}={}){return n(r((e??window.location.host).replace(`www.`,``)))}function o(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function s(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function c(e){return o(i(e))}function l(e,t,n,r,i){let a=c(u({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,productId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink}})),o=new URL(e);return o.pathname=`/sso`,o.searchParams.set(`p`,a),o.toString()}function u(e){return{r:e.redirectUrl,d:e.directExit,l:e.lang,p:e.productId,m:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const d=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,f=`frak-sso`;async function p(e,t){let{metadata:n,customizations:r,walletUrl:i}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]});let o=t.ssoPopupUrl??l(i??`https://wallet.frak.id`,t,a(),n.name,r?.css),s=window.open(o,f,d);if(!s)throw Error(`Popup was blocked. Please allow popups for this site.`);return s.focus(),await e.request({method:`frak_openSso`,params:[t,n.name,r?.css]})??{}}const m=`fCtx`;function h(e){if(e?.r)try{return o(t(e.r))}catch(t){console.error(`Error compressing Frak context`,{e:t,context:e})}}function g(t){if(!(!t||t.length===0))try{return{r:e(s(t),{size:20})}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function _({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(m);return t?g(t):null}function v({url:e,context:t}){if(!e)return null;let n=_({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=h(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(m,i),a.toString()}function y(e){let t=new URL(e);return t.searchParams.delete(m),t.toString()}function b({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?y(n):v({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const x={compress:h,decompress:g,parse:_,update:v,remove:y,replaceUrl:b};function S(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}export{f as a,s as c,d as i,o as l,x as n,l as o,p as r,c as s,S as t,a as u};
@@ -1 +0,0 @@
1
- let e=require(`viem`),t=require(`@frak-labs/frame-connector`);function n({domain:t}={}){return(0,e.keccak256)((0,e.toHex)((t??window.location.host).replace(`www.`,``)))}function r(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join(``)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function i(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(e.length+(t===0?0:4-t),`=`)),e=>e.charCodeAt(0))}function a(e){return r((0,t.compressJson)(e))}function o(e,t,n,r,i){let o=a(s({redirectUrl:t.redirectUrl,directExit:t.directExit,lang:t.lang,productId:n,metadata:{name:r,css:i,logoUrl:t.metadata?.logoUrl,homepageLink:t.metadata?.homepageLink}})),c=new URL(e);return c.pathname=`/sso`,c.searchParams.set(`p`,o),c.toString()}function s(e){return{r:e.redirectUrl,d:e.directExit,l:e.lang,p:e.productId,m:{n:e.metadata?.name,css:e.metadata?.css,l:e.metadata?.logoUrl,h:e.metadata?.homepageLink}}}const c=`menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800`,l=`frak-sso`;async function u(e,t){let{metadata:r,customizations:i,walletUrl:a}=e.config;if(t.openInSameWindow??!!t.redirectUrl)return await e.request({method:`frak_openSso`,params:[t,r.name,i?.css]});let s=t.ssoPopupUrl??o(a??`https://wallet.frak.id`,t,n(),r.name,i?.css),u=window.open(s,l,c);if(!u)throw Error(`Popup was blocked. Please allow popups for this site.`);return u.focus(),await e.request({method:`frak_openSso`,params:[t,r.name,i?.css]})??{}}const d=`fCtx`;function f(t){if(t?.r)try{return r((0,e.hexToBytes)(t.r))}catch(e){console.error(`Error compressing Frak context`,{e,context:t})}}function p(t){if(!(!t||t.length===0))try{return{r:(0,e.bytesToHex)(i(t),{size:20})}}catch(e){console.error(`Error decompressing Frak context`,{e,context:t})}}function m({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(d);return t?p(t):null}function h({url:e,context:t}){if(!e)return null;let n=m({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let i=f(r);if(!i)return null;let a=new URL(e);return a.searchParams.set(d,i),a.toString()}function g(e){let t=new URL(e);return t.searchParams.delete(d),t.toString()}function _({url:e,context:t}){if(!window.location?.href||typeof window>`u`){console.error(`No window found, can't update context`);return}let n=e??window.location.href,r;r=t===null?g(n):h({url:n,context:t}),r&&window.history.replaceState(null,``,r.toString())}const v={compress:f,decompress:p,parse:m,update:h,remove:g,replaceUrl:_};function y(e,t,n={}){if(!e){console.debug(`[Frak] No client provided, skipping event tracking`);return}try{e.openPanel?.track(t,n)}catch(e){console.debug(`[Frak] Failed to track event:`,t,e)}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return n}});
@@ -1,14 +0,0 @@
1
- import type { FrakClient, GetProductInformationReturnType } from "../types";
2
-
3
- /**
4
- * Function used to get the current product information
5
- * @param client - The current Frak Client
6
- * @returns The product information in a promise
7
- */
8
- export async function getProductInformation(
9
- client: FrakClient
10
- ): Promise<GetProductInformationReturnType> {
11
- return await client.request({
12
- method: "frak_getProductInformation",
13
- });
14
- }