@frak-labs/core-sdk 0.0.9 → 0.0.11

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/dist/index.d.ts CHANGED
@@ -4,6 +4,20 @@ import type { Prettify } from 'viem/chains';
4
4
  import type { RpcSchema } from 'viem';
5
5
  import type { SiweMessage } from 'viem/siwe';
6
6
 
7
+ /**
8
+ * Decode a base64url encoded string
9
+ * @param value The value to decode
10
+ * @returns The decoded value
11
+ */
12
+ export declare function base64urlDecode(value: string): Uint8Array;
13
+
14
+ /**
15
+ * Encode a buffer to a base64url encoded string
16
+ * @param buffer The buffer to encode
17
+ * @returns The encoded string
18
+ */
19
+ export declare function base64urlEncode(buffer: Uint8Array): string;
20
+
7
21
  /**
8
22
  * Base props for the iframe
9
23
  * @ignore
@@ -11,6 +25,7 @@ import type { SiweMessage } from 'viem/siwe';
11
25
  export declare const baseIframeProps: {
12
26
  id: string;
13
27
  name: string;
28
+ title: string;
14
29
  allow: string;
15
30
  style: {
16
31
  width: string;
@@ -27,7 +42,7 @@ export declare const baseIframeProps: {
27
42
  * Event related to the iframe lifecycle
28
43
  * @ignore
29
44
  */
30
- export declare type ClientLifecycleEvent = CustomCssEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse;
45
+ export declare type ClientLifecycleEvent = CustomCssEvent | CustomI18nEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse;
31
46
 
32
47
  /** @ignore */
33
48
  export declare class ClientNotFound extends FrakRpcError {
@@ -46,17 +61,21 @@ declare function compress(context?: Partial<FrakContext>): string | undefined;
46
61
  * -> The encoded should contain a HashProtectedData once decoded
47
62
  * @ignore
48
63
  */
49
- export declare type CompressedData = Readonly<{
50
- compressed: string;
51
- compressedHash: string;
52
- }>;
64
+ export declare type CompressedData = Uint8Array;
65
+
66
+ /**
67
+ * Compress json data
68
+ * @param data
69
+ * @ignore
70
+ */
71
+ export declare function compressJson(data: unknown): Uint8Array;
53
72
 
54
73
  /**
55
74
  * Compress json data
56
75
  * @param data
57
76
  * @ignore
58
77
  */
59
- export declare function compressJson(data: unknown): Promise<string>;
78
+ export declare function compressJsonToB64(data: unknown): string;
60
79
 
61
80
  /**
62
81
  * Create the Frak iframe
@@ -92,6 +111,7 @@ export declare function createIFrameFrakClient({ config, iframe, }: {
92
111
 
93
112
  /**
94
113
  * All the currencies available
114
+ * @category Config
95
115
  */
96
116
  export declare type Currency = "eur" | "usd" | "gbp";
97
117
 
@@ -102,6 +122,13 @@ declare type CustomCssEvent = {
102
122
  };
103
123
  };
104
124
 
125
+ declare type CustomI18nEvent = {
126
+ clientLifecycle: "modal-i18n";
127
+ data: {
128
+ i18n: I18nConfig;
129
+ };
130
+ };
131
+
105
132
  /** @ignore */
106
133
  export declare class DebugInfoGatherer {
107
134
  private config?;
@@ -139,14 +166,21 @@ declare function decompress(context?: string): FrakContext | undefined;
139
166
  * @param compressedData The params to encode
140
167
  * @ignore
141
168
  */
142
- export declare function decompressDataAndCheckHash<T>(compressedData: CompressedData): Promise<HashProtectedData<T>>;
169
+ export declare function decompressDataAndCheckHash<T>(compressedData: CompressedData): HashProtectedData<T>;
170
+
171
+ /**
172
+ * Decompress json data
173
+ * @param data
174
+ * @ignore
175
+ */
176
+ export declare function decompressJson<T>(data: Uint8Array): T | null;
143
177
 
144
178
  /**
145
179
  * Decompress json data
146
180
  * @param data
147
181
  * @ignore
148
182
  */
149
- export declare function decompressJson<T>(data: string): Promise<T | null>;
183
+ export declare function decompressJsonFromB64<T>(data: string): T | null;
150
184
 
151
185
  /**
152
186
  * Simple deferred promise wrapper
@@ -163,31 +197,31 @@ export declare class Deferred<T> {
163
197
  }
164
198
 
165
199
  /**
166
- * The params used to display the embeded wallet
200
+ * The params used to display the embedded wallet
167
201
  *
168
- * @group Embeded wallet
202
+ * @group Embedded wallet
169
203
  */
170
204
  export declare type DisplayEmbededWalletParamsType = {
171
205
  /**
172
- * The embeded view to display once the user is logged in
206
+ * The embedded view to display once the user is logged in
173
207
  */
174
208
  loggedIn?: LoggedInEmbededView;
175
209
  /**
176
- * The embeded view to display once the user is logged out
210
+ * The embedded view to display once the user is logged out
177
211
  */
178
212
  loggedOut?: LoggedOutEmbededView;
179
213
  /**
180
- * Some metadata to customise the embeded view
214
+ * Some metadata to customize the embedded view
181
215
  */
182
216
  metadata?: {
183
217
  /**
184
- * The logo to display on the embeded wallet
218
+ * The logo to display on the embedded wallet
185
219
  * If undefined, will default to no logo displayed
186
220
  */
187
221
  logo?: string;
188
222
  /**
189
223
  * Link to the homepage of the calling website
190
- * If unedfined, will default to the domain of the calling website
224
+ * If undefined, will default to the domain of the calling website
191
225
  */
192
226
  homepageLink?: string;
193
227
  /**
@@ -198,6 +232,10 @@ export declare type DisplayEmbededWalletParamsType = {
198
232
  * The position of the component
199
233
  */
200
234
  position?: "left" | "right";
235
+ /**
236
+ * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
237
+ */
238
+ i18n?: I18nConfig;
201
239
  };
202
240
  };
203
241
 
@@ -219,9 +257,9 @@ declare type DoBackupEvent = {
219
257
  };
220
258
 
221
259
  /**
222
- * The different type of action we can have on the embeded view (once the user is logged in)
260
+ * The different type of action we can have on the embedded view (once the user is logged in)
223
261
  *
224
- * @group Embeded wallet
262
+ * @group Embedded wallet
225
263
  */
226
264
  export declare type EmbededViewAction = {
227
265
  key: "sharing";
@@ -231,11 +269,13 @@ export declare type EmbededViewAction = {
231
269
  options?: {
232
270
  /**
233
271
  * The title that will be displayed on the system popup once the system sharing window is open
272
+ * @deprecated Use the top level `config.metadata.i18n` instead
234
273
  */
235
274
  popupTitle?: string;
236
275
  /**
237
276
  * The text that will be shared alongside the link.
238
277
  * Can contain the variable {LINK} to specify where the link is placed, otherwise it will be added at the end
278
+ * @deprecated Use the top level `config.metadata.i18n` instead
239
279
  */
240
280
  text?: string;
241
281
  /**
@@ -280,7 +320,13 @@ export declare type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TPa
280
320
  export declare type FinalActionType = {
281
321
  key: "sharing";
282
322
  options?: {
323
+ /**
324
+ * @deprecated Use the top level `config.metadata.i18n` instead
325
+ */
283
326
  popupTitle?: string;
327
+ /**
328
+ * @deprecated Use the top level `config.metadata.i18n` instead
329
+ */
284
330
  text?: string;
285
331
  link?: string;
286
332
  };
@@ -319,6 +365,8 @@ export declare type FrakClient = {
319
365
  * The current Frak Context
320
366
  *
321
367
  * For now, only contain a referrer address.
368
+ *
369
+ * @ignore
322
370
  */
323
371
  export declare type FrakContext = {
324
372
  r: Address;
@@ -347,7 +395,8 @@ export declare class FrakRpcError<T = undefined> extends Error {
347
395
  }
348
396
 
349
397
  /**
350
- * Configuration for the Nexus Wallet SDK
398
+ * Configuration for the Frak Wallet SDK
399
+ * @category Config
351
400
  */
352
401
  export declare type FrakWalletSdkConfig = {
353
402
  /**
@@ -363,20 +412,37 @@ export declare type FrakWalletSdkConfig = {
363
412
  * Your application name (will be displayed in a few modals and in SSO)
364
413
  */
365
414
  name: string;
366
- /**
367
- * Custom CSS styles to apply to the modals and components
368
- */
369
- css?: string;
370
415
  /**
371
416
  * Language to display in the modal
372
417
  * If undefined, will default to the browser language
373
418
  */
374
- lang?: "fr" | "en";
419
+ lang?: Language;
375
420
  /**
376
421
  * The currency to display in the modal
377
422
  * @defaultValue `"eur"`
378
423
  */
379
424
  currency?: Currency;
425
+ /**
426
+ * The logo URL that will be displayed in a few components
427
+ */
428
+ logoUrl?: string;
429
+ /**
430
+ * The homepage link that could be displayed in a few components
431
+ */
432
+ homepageLink?: string;
433
+ };
434
+ /**
435
+ * Some customization for the modal
436
+ */
437
+ customizations?: {
438
+ /**
439
+ * Custom CSS styles to apply to the modals and components
440
+ */
441
+ css?: `${string}.css`;
442
+ /**
443
+ * Custom i18n configuration for the modal
444
+ */
445
+ i18n?: I18nConfig;
380
446
  };
381
447
  /**
382
448
  * The domain name of your application
@@ -491,7 +557,7 @@ declare type HandshakeResponse = {
491
557
  * @param data The params to encode
492
558
  * @ignore
493
559
  */
494
- export declare function hashAndCompressData<T>(data: T): Promise<CompressedData>;
560
+ export declare function hashAndCompressData<T>(data: T): CompressedData;
495
561
 
496
562
  /**
497
563
  * The encoded data to send to a client / received by a client
@@ -505,6 +571,41 @@ declare type HearbeatEvent = {
505
571
  clientLifecycle: "heartbeat";
506
572
  };
507
573
 
574
+ /**
575
+ * Custom i18n configuration for the modal
576
+ * See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
577
+ *
578
+ * Available variables
579
+ * - `{{ productName }}` : The name of your website (`metadata.name`)
580
+ * - `{{ productOrigin }}` : The origin url of your website
581
+ * - `{{ estimatedReward }}` : The estimated reward for the user (based on the specific `targetInteraction` you can specify, or the max referrer reward if no target interaction is specified)
582
+ *
583
+ * Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
584
+ * - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
585
+ * - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
586
+ *
587
+ * @example
588
+ * ```ts
589
+ * // Multi language config
590
+ * const multiI18n = {
591
+ * fr: {
592
+ * "sdk.modal.title": "Titre de modal",
593
+ * "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
594
+ * },
595
+ * en: "https://example.com/en.json"
596
+ * }
597
+ *
598
+ * // Single language config
599
+ * const singleI18n = {
600
+ * "sdk.modal.title": "Modal title",
601
+ * "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
602
+ * }
603
+ * ```
604
+ *
605
+ * @category Config
606
+ */
607
+ export declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
608
+
508
609
  /**
509
610
  * Represent an iframe event
510
611
  */
@@ -525,10 +626,7 @@ export declare type IFrameLifecycleEvent = {
525
626
  export declare type IFrameRpcEvent = {
526
627
  id: string;
527
628
  topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
528
- data: {
529
- compressed: string;
530
- compressedHash: string;
531
- };
629
+ data: CompressedData;
532
630
  };
533
631
 
534
632
  /**
@@ -581,7 +679,8 @@ export declare type IFrameRpcSchema = [
581
679
  Method: "frak_displayModal";
582
680
  Parameters: [
583
681
  requests: ModalRpcStepsInput,
584
- metadata: FrakWalletSdkConfig["metadata"] & ModalRpcMetadata
682
+ metadata: ModalRpcMetadata | undefined,
683
+ configMetadata: FrakWalletSdkConfig["metadata"]
585
684
  ];
586
685
  ReturnType: ModalRpcStepsResultType;
587
686
  },
@@ -622,12 +721,12 @@ export declare type IFrameRpcSchema = [
622
721
  ReturnType: GetProductInformationReturnType;
623
722
  },
624
723
  /**
625
- * Method to show the embeded wallet, with potential customisation
724
+ * Method to show the embedded wallet, with potential customization
626
725
  */
627
726
  {
628
727
  Method: "frak_displayEmbededWallet";
629
728
  Parameters: [
630
- DisplayEmbededWalletParamsType,
729
+ request: DisplayEmbededWalletParamsType,
631
730
  metadata: FrakWalletSdkConfig["metadata"]
632
731
  ];
633
732
  ReturnType: undefined;
@@ -703,6 +802,12 @@ export declare type InteractionTypesKey = {
703
802
  */
704
803
  export declare type KeyProvider<DataType> = (value: DataType) => string[];
705
804
 
805
+ /**
806
+ * All the languages available
807
+ * @category Config
808
+ */
809
+ export declare type Language = "fr" | "en";
810
+
706
811
  /**
707
812
  * Type used for a listening request
708
813
  * @inline
@@ -725,13 +830,21 @@ export declare const locales: {
725
830
  export declare type LocalesKey = keyof typeof locales;
726
831
 
727
832
  /**
728
- * Some configuration options for the embeded view
833
+ * A localized i18n config
834
+ * @category Config
835
+ */
836
+ export declare type LocalizedI18nConfig = `${string}.css` | {
837
+ [key: string]: string;
838
+ };
839
+
840
+ /**
841
+ * Some configuration options for the embedded view
729
842
  *
730
- * @group Embeded wallet
843
+ * @group Embedded wallet
731
844
  */
732
845
  export declare type LoggedInEmbededView = {
733
846
  /**
734
- * The main action to display on the logged in embeded view
847
+ * The main action to display on the logged in embedded view
735
848
  * If none specified, the user will see his wallet with the activation button
736
849
  */
737
850
  action?: EmbededViewAction;
@@ -739,26 +852,28 @@ export declare type LoggedInEmbededView = {
739
852
 
740
853
  /**
741
854
  * The view when a user is logged out
742
- * @group Embeded wallet
855
+ * @group Embedded wallet
743
856
  */
744
857
  export declare type LoggedOutEmbededView = {
745
858
  /**
746
- * Metadata option when displaying the embeded view
859
+ * Metadata option when displaying the embedded view
747
860
  */
748
861
  metadata?: {
749
862
  /**
750
863
  * The main CTA for the logged out view
751
864
  * - can include some variable, available ones are:
752
- * - {REWARD} -> The maximum reward a user can receive when itneracting on your website
865
+ * - {REWARD} -> The maximum reward a user can receive when interacting on your website
753
866
  * - can be formatted in markdown
754
867
  *
755
- * If not sert, it will default to a internalised message
868
+ * If not set, it will default to a internationalized message
869
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
756
870
  */
757
871
  text?: string;
758
872
  /**
759
873
  * The text that will be displayed on the login button
760
874
  *
761
- * If not set, it will default to a internalised message
875
+ * If not set, it will default to a internationalized message
876
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
762
877
  */
763
878
  buttonText?: string;
764
879
  };
@@ -785,7 +900,7 @@ declare type LoginWithoutSso = {
785
900
  /** @inline */
786
901
  declare type LoginWithSso = {
787
902
  allowSso: true;
788
- ssoMetadata: SsoMetadata;
903
+ ssoMetadata?: SsoMetadata;
789
904
  };
790
905
 
791
906
  /**
@@ -798,10 +913,16 @@ export declare type ModalRpcMetadata = {
798
913
  title?: string;
799
914
  icon?: string;
800
915
  };
801
- context?: string;
802
916
  targetInteraction?: FullInteractionTypesKey;
917
+ /**
918
+ * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
919
+ */
920
+ i18n?: I18nConfig;
803
921
  } & ({
804
922
  isDismissible: true;
923
+ /**
924
+ * @deprecated Use `config.customizations.i18n` or `metadata.i18n` instead
925
+ */
805
926
  dismissActionTxt?: string;
806
927
  } | {
807
928
  isDismissible?: false;
@@ -835,29 +956,34 @@ export declare type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalSt
835
956
  };
836
957
 
837
958
  /**
838
- * Metadata that can be used to customise a modal step
959
+ * Metadata that can be used to customize a modal step
839
960
  * @group Modal Display
961
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
840
962
  */
841
963
  export declare type ModalStepMetadata = {
842
964
  metadata?: {
843
965
  /**
844
966
  * Custom title for the step
845
- * If none provided, it will use an internationalised text
967
+ * If none provided, it will use an internationalized text
968
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
846
969
  */
847
970
  title?: string;
848
971
  /**
849
972
  * Custom description for the step
850
- * If none provided, it will use an internationalised text
973
+ * If none provided, it will use an internationalized text
974
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
851
975
  */
852
976
  description?: string;
853
977
  /**
854
978
  * Custom text for the primary action of the step
855
- * If none provided, it will use an internationalised text
979
+ * If none provided, it will use an internationalized text
980
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
856
981
  */
857
982
  primaryActionText?: string;
858
983
  /**
859
984
  * Custom text for the secondary action of the step
860
- * If none provided, it will use an internationalised text
985
+ * If none provided, it will use an internationalized text
986
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
861
987
  */
862
988
  secondaryActionText?: string;
863
989
  };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import*as e from"async-lz-string";import*as t from"js-sha256";import*as n from"viem";class r extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}}class a extends r{constructor(e){super(s.internalError,e)}}class o extends r{constructor(){super(s.clientNotConnected,"Client not found")}}let s={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};class i{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){this.lastResponse={event:e.data,origin:e.origin,timestamp:Date.now()}}setLastRequest(e,t){this.lastRequest={event:e,target:t,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?+("complete"===this.iframe.contentDocument.readyState):-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(),n=this.getNavigatorInfo(),a="Unknown";return e instanceof r?a=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?a=e.message:"string"==typeof e&&(a=e),{timestamp:new Date().toISOString(),encodedUrl:btoa(window.location.href),encodedConfig:this.config?this.base64Encode(this.config):"no-config",navigatorInfo:n?this.base64Encode(n):"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:a}}static empty(){return new i}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
1
+ import*as e from"@jsonjoy.com/json-pack/lib/cbor";import*as t from"viem";class n extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n}}class r extends n{constructor(e){super(a.internalError,e)}}class o extends n{constructor(){super(a.clientNotConnected,"Client not found")}}let a={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,serverError:-32e3,clientNotConnected:-32001,configError:-32002,corruptedResponse:-32003,clientAborted:-32004,walletNotConnected:-32005,serverErrorForInteractionDelegation:-32006};class i{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}function s(e){return btoa(Array.from(e,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function c(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}let l=new e.CborEncoder;function d(e){let t={...e,validationHash:p(e)};return l.encode(t)}function u(e){return l.encode(e)}function f(e){return s(u(e))}function p(e){return(0,t.sha256)(l.encode(e))}let h=new e.CborDecoder;function m(e){if(!e.length)throw new n(a.corruptedResponse,"Missing compressed data");let t=g(e);if(!t)throw new n(a.corruptedResponse,"Invalid compressed data");if(!t?.validationHash)throw new n(a.corruptedResponse,"Missing validation hash");let{validationHash:r,...o}=t;if(p(o)!==t.validationHash)throw new n(a.corruptedResponse,"Invalid data validation hash");return t}function g(e){try{return h.decode(e)}catch(t){return console.error("Invalid compressed data",{e:t,data:e}),null}}function w(e){return g(c(e))}let y="nexus-wallet-backup";class b{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){this.lastResponse={event:e.data,origin:e.origin,timestamp:Date.now()}}setLastRequest(e,t){this.lastRequest={event:e,target:t,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?+("complete"===this.iframe.contentDocument.readyState):-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(),o="Unknown";return e instanceof n?o=`FrakRpcError: ${e.code} '${e.message}'`:e instanceof Error?o=e.message:"string"==typeof e&&(o=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:o}}static empty(){return new b}formatDebugInfo(e){let t=this.gatherDebugInfo(e);return`
2
2
  Debug Information:
3
3
  -----------------
4
4
  Timestamp: ${t.timestamp}
@@ -10,4 +10,4 @@ import*as e from"async-lz-string";import*as t from"js-sha256";import*as n from"v
10
10
  Last Response: ${t.lastResponse}
11
11
  Client Status: ${t.clientStatus}
12
12
  Error: ${t.error}
13
- `.trim()}}class c{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve=e=>{this._resolve?.(e)};reject=e=>{this._reject?.(e)}}async function l(e){if(!(e?.compressed&&e?.compressedHash))throw new r(s.corruptedResponse,"Missing compressed data");let n=await d(e.compressed);if(!n)throw new r(s.corruptedResponse,"Invalid compressed data");if(!n?.validationHash)throw new r(s.corruptedResponse,"Missing validation hash");if((0,t.sha256)(e.compressed)!==e.compressedHash)throw new r(s.corruptedResponse,"Invalid compressed hash");let{validationHash:a,...o}=n;if((0,t.sha256)(JSON.stringify(o))!==n.validationHash)throw new r(s.corruptedResponse,"Invalid data validation hash");return n}async function d(t){let n=await (0,e.decompressFromBase64)(t);try{return JSON.parse(n)}catch(e){return console.error("Invalid compressed data",{e,decompressed:n}),null}}async function u(e){let n=(0,t.sha256)(JSON.stringify(e)),r={...e,validationHash:n},a=await f(r),o=(0,t.sha256)(a);return{compressed:a,compressedHash:o}}async function f(t){return(0,e.compressToBase64)(JSON.stringify(t))}let p="nexus-wallet-backup",h={id:"nexus-wallet",name:"nexus-wallet",allow:"publickey-credentials-get *; clipboard-write; web-share *",style:{width:"0",height:"0",border:"0",position:"absolute",zIndex:2000001,top:"-1000px",left:"-1000px"}};function m({walletBaseUrl:e,config:t}){let n=document.querySelector("#nexus-wallet");n&&n.remove();let r=document.createElement("iframe");return r.id=h.id,r.name=h.name,r.allow=h.allow,r.style.zIndex=h.style.zIndex.toString(),g({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 g({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 w({config:e,iframe:t}){let n=function(){let e=new Map;return{createChannel:t=>{let n=Math.random().toString(36).substring(7);return e.set(n,t),n},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),o=function({iframe:e}){let t=new c;return{handleEvent:async n=>{switch(n.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":n.data.backup?localStorage.setItem(p,n.data.backup):localStorage.removeItem(p);break;case"remove-backup":localStorage.removeItem(p);break;case"show":case"hide":g({iframe:e,isVisible:"show"===n.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:n.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:t}),d=new i(e,t),f=function({frakWalletUrl:e,iframe:t,channelManager:n,iframeLifecycleManager:a,debugInfo:o}){if("undefined"==typeof window)throw new r(s.configError,"iframe client should be used in the browser");if(!t.contentWindow)throw new r(s.configError,"The iframe does not have a product window");let i=t.contentWindow;async function c(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(o.setLastResponse(t),"iframeLifecycle"in t.data){await a.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let r=t.data.id,s=n.getRpcResolver(r);s&&await s(t.data)}return window.addEventListener("message",c),{sendEvent:function(t){i.postMessage(t,{targetOrigin:e}),o.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",c)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:t,channelManager:n,iframeLifecycleManager:o,debugInfo:d}),h=async e=>{if(!await o.isConnected)throw new r(s.clientNotConnected,"The iframe provider isn't connected yet");let t=new c,a=n.createChannel(async e=>{let o=await l(e.data);o.error?t.reject(new r(o.error.code,o.error.message,o.error?.data)):t.resolve(o.result),n.removeChannel(a)}),i=await u(e);return f.sendEvent({id:a,topic:e.method,data:i}),t.promise},m=async(e,t)=>{if(!await o.isConnected)throw new r(s.clientNotConnected,"The iframe provider isn't connected yet");let i=n.createChannel(async e=>{let n=await l(e.data);if(n.result)t(n.result);else throw new a("No valid result in the response")}),c=await u(e);f.sendEvent({id:i,topic:e.method,data:c})},w=function(e,t){let n,r;let a=()=>e.sendEvent({clientLifecycle:"heartbeat"});function o(){n&&clearInterval(n),r&&clearTimeout(r)}return async function(){a(),n=setInterval(a,100),r=setTimeout(()=>{o(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,o()}(),o}(f,o),b=async()=>{w(),n.destroy(),f.cleanup(),t.remove()},v=y({config:e,messageHandler:f,lifecycleManager:o}).then(()=>d.updateSetupStatus(!0));return{config:e,debugInfo:d,waitForConnection:o.isConnected,waitForSetup:v,request:h,listenerRequest:m,destroy:b}}async function y({config:e,messageHandler:t,lifecycleManager:n}){await n.isConnected;let r=async()=>{let n=e.metadata.css;n&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:n}})},a=async()=>{if("undefined"==typeof window)return;let e=window.localStorage.getItem(p);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})};await Promise.all([r(),a()])}let b={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function v(e){return e&&e in b?e:"eur"}async function S({config:e}){let t=function(e){let t=v(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),n=await m({config:t});if(!n){console.error("Failed to create iframe");return}let r=w({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error("Failed to connect to client");return}return r}function C(e){return e?b[e]??b.eur:b.eur}function R(e,t){let n=C(t),r=v(t);return e.toLocaleString(n,{style:"currency",currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}function x(e){return e?`${e}Amount`:"eurAmount"}let E="fCtx";function I(e){if(e?.r)try{var t;return t=(0,n.hexToBytes)(e.r),btoa(Array.from(t,e=>String.fromCharCode(e)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function k(e){if(e&&0!==e.length)try{let t=function(e){let t=e.length%4;return Uint8Array.from(atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(0===t?0:4-t),"=")),e=>e.charCodeAt(0))}(e);return{r:(0,n.bytesToHex)(t,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function L({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(E);return t?k(t):null}function F({url:e,context:t}){if(!e)return null;let n=L({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let a=I(r);if(!a)return null;let o=new URL(e);return o.searchParams.set(E,a),o.toString()}function D(e){let t=new URL(e);return t.searchParams.delete(E),t.toString()}let N={compress:I,decompress:k,parse:L,update:F,remove:D,replaceUrl:function({url:e,context:t}){let n;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let r=e??window.location.href;(n=null!==t?F({url:r,context:t}):D(r))&&window.history.replaceState(null,"",n.toString())}},U={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},A=Object.entries(U).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),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"}};export{o as ClientNotFound,i as DebugInfoGatherer,c as Deferred,N as FrakContextManager,r as FrakRpcError,s as RpcErrorCodes,h as baseIframeProps,f as compressJson,w as createIFrameFrakClient,m as createIframe,l as decompressDataAndCheckHash,d as decompressJson,R as formatAmount,x as getCurrencyAmountKey,v as getSupportedCurrency,C as getSupportedLocale,u as hashAndCompressData,$ as interactionTypes,b as locales,U as productTypes,A as productTypesMask,S as setupClient};
13
+ `.trim()}}let v={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"}};function C({walletBaseUrl:e,config:t}){let n=document.querySelector("#frak-wallet");n&&n.remove();let r=document.createElement("iframe");return r.id=v.id,r.name=v.name,r.allow=v.allow,r.style.zIndex=v.style.zIndex.toString(),R({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 R({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 S({config:e,iframe:t}){let o=function(){let e=new Map;return{createChannel:t=>{let n=Math.random().toString(36).substring(7);return e.set(n,t),n},getRpcResolver:t=>e.get(t),removeChannel:t=>e.delete(t),destroy:()=>e.clear()}}(),s=function({iframe:e}){let t=new i;return{handleEvent:async n=>{switch(n.iframeLifecycle){case"connected":t.resolve(!0);break;case"do-backup":n.data.backup?localStorage.setItem(y,n.data.backup):localStorage.removeItem(y);break;case"remove-backup":localStorage.removeItem(y);break;case"show":case"hide":R({iframe:e,isVisible:"show"===n.iframeLifecycle});break;case"handshake":e.contentWindow?.postMessage({clientLifecycle:"handshake-response",data:{token:n.data.token,currentUrl:window.location.href}},"*")}},isConnected:t.promise}}({iframe:t}),c=new b(e,t),l=function({frakWalletUrl:e,iframe:t,channelManager:r,iframeLifecycleManager:o,debugInfo:i}){if("undefined"==typeof window)throw new n(a.configError,"iframe client should be used in the browser");if(!t.contentWindow)throw new n(a.configError,"The iframe does not have a product window");let s=t.contentWindow;async function c(t){if(!t.origin)return;try{if(new URL(t.origin).origin.toLowerCase()!==new URL(e).origin.toLowerCase())return}catch(e){console.log("Unable to check frak msg origin",e);return}if("object"!=typeof t.data)return;if(i.setLastResponse(t),"iframeLifecycle"in t.data){await o.handleEvent(t.data);return}if("clientLifecycle"in t.data){console.error("Client lifecycle event received on the client side, dismissing it");return}let n=t.data.id,a=r.getRpcResolver(n);a&&a(t.data)}return window.addEventListener("message",c),{sendEvent:function(t){s.postMessage(t,{targetOrigin:e}),i.setLastRequest(t,e)},cleanup:function(){window.removeEventListener("message",c)}}}({frakWalletUrl:e?.walletUrl??"https://wallet.frak.id",iframe:t,channelManager:o,iframeLifecycleManager:s,debugInfo:c}),u=async e=>{if(!await s.isConnected)throw new n(a.clientNotConnected,"The iframe provider isn't connected yet");let t=new i,r=o.createChannel(e=>{let a=m(e.data);a.error?t.reject(new n(a.error.code,a.error.message,a.error?.data)):t.resolve(a.result),o.removeChannel(r)}),c=d(e);return l.sendEvent({id:r,topic:e.method,data:c}),t.promise},f=async(e,t)=>{if(!await s.isConnected)throw new n(a.clientNotConnected,"The iframe provider isn't connected yet");let i=o.createChannel(e=>{let n=m(e.data);if(n.result)t(n.result);else throw new r("No valid result in the response")}),c=d(e);l.sendEvent({id:i,topic:e.method,data:c})},p=function(e,t){let n,r;let o=()=>e.sendEvent({clientLifecycle:"heartbeat"});function a(){n&&clearInterval(n),r&&clearTimeout(r)}return async function(){o(),n=setInterval(o,100),r=setTimeout(()=>{a(),console.log("Heartbeat timeout: connection failed")},3e4),await t.isConnected,a()}(),a}(l,s),h=async()=>{p(),o.destroy(),l.cleanup(),t.remove()},g=E({config:e,messageHandler:l,lifecycleManager:s}).then(()=>c.updateSetupStatus(!0));return{config:e,debugInfo:c,waitForConnection:s.isConnected,waitForSetup:g,request:u,listenerRequest:f,destroy:h}}async function E({config:e,messageHandler:t,lifecycleManager:n}){async function r(){let n=e.customizations?.css;n&&t.sendEvent({clientLifecycle:"modal-css",data:{cssLink:n}})}async function o(){let n=e.customizations?.i18n;n&&t.sendEvent({clientLifecycle:"modal-i18n",data:{i18n:n}})}async function a(){if("undefined"==typeof window)return;let e=window.localStorage.getItem(y);e&&t.sendEvent({clientLifecycle:"restore-backup",data:{backup:e}})}await n.isConnected,await Promise.all([r(),o(),a()])}let k={eur:"fr-FR",usd:"en-US",gbp:"en-GB"};function x(e){return e&&e in k?e:"eur"}async function I({config:e}){let t=function(e){let t=x(e.metadata?.currency);return{...e,metadata:{...e.metadata,currency:t}}}(e),n=await C({config:t});if(!n){console.error("Failed to create iframe");return}let r=S({config:t,iframe:n});if(await r.waitForSetup,!await r.waitForConnection){console.error("Failed to connect to client");return}return r}function L(e){return e?`${e}Amount`:"eurAmount"}let F="fCtx";function D(e){if(e?.r)try{let n=(0,t.hexToBytes)(e.r);return s(n)}catch(t){console.error("Error compressing Frak context",{e:t,context:e})}}function U(e){if(e&&0!==e.length)try{let n=c(e);return{r:(0,t.bytesToHex)(n,{size:20})}}catch(t){console.error("Error decompressing Frak context",{e:t,context:e})}}function A({url:e}){if(!e)return null;let t=new URL(e).searchParams.get(F);return t?U(t):null}function N({url:e,context:t}){if(!e)return null;let n=A({url:e}),r=n?{...n,...t}:t;if(!r.r)return null;let o=D(r);if(!o)return null;let a=new URL(e);return a.searchParams.set(F,o),a.toString()}function $(e){let t=new URL(e);return t.searchParams.delete(F),t.toString()}let q={compress:D,decompress:U,parse:A,update:N,remove:$,replaceUrl:function({url:e,context:t}){let n;if(!window.location?.href||"undefined"==typeof window){console.error("No window found, can't update context");return}let r=e??window.location.href;(n=null!==t?N({url:r,context:t}):$(r))&&window.history.replaceState(null,"",n.toString())}};function T(e){return e?k[e]??k.eur:k.eur}function j(e,t){let n=T(t),r=x(t);return e.toLocaleString(n,{style:"currency",currency:r,minimumFractionDigits:0,maximumFractionDigits:2})}let _={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},M=Object.entries(_).reduce((e,[t,n])=>(e[t]=BigInt(1)<<BigInt(n),e),{}),P={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"}};export{o as ClientNotFound,b as DebugInfoGatherer,i as Deferred,q as FrakContextManager,n as FrakRpcError,a as RpcErrorCodes,c as base64urlDecode,s as base64urlEncode,v as baseIframeProps,u as compressJson,f as compressJsonToB64,S as createIFrameFrakClient,C as createIframe,m as decompressDataAndCheckHash,g as decompressJson,w as decompressJsonFromB64,j as formatAmount,L as getCurrencyAmountKey,x as getSupportedCurrency,T as getSupportedLocale,d as hashAndCompressData,P as interactionTypes,k as locales,_ as productTypes,M as productTypesMask,I as setupClient};
@@ -1 +1 @@
1
- "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ReferralInteractionEncoder:()=>ReferralInteractionEncoder,PressInteractionEncoder:()=>PressInteractionEncoder,PurchaseInteractionEncoder:()=>PurchaseInteractionEncoder,RetailInteractionEncoder:()=>RetailInteractionEncoder,WebShopInteractionEncoder:()=>WebShopInteractionEncoder});let external_viem_namespaceObject=require("viem"),interactionTypes={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"}},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),PressInteractionEncoder={openArticle({articleId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.press.openArticle,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.press),interactionData:r}},readArticle({articleId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.press.readArticle,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.press),interactionData:r}}},ReferralInteractionEncoder={createLink:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:interactionTypes.referral.createLink}),referred({referrer:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.referral.referred,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:r}}},PurchaseInteractionEncoder={startPurchase({purchaseId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.started,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:r}},completedPurchase({purchaseId:e,proof:r}){let t=(0,external_viem_namespaceObject.encodeAbiParameters)([{type:"uint256"},{type:"bytes32[]"}],[BigInt(e),r]),a=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.completed,t]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:a}},unsafeCompletedPurchase({purchaseId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.unsafeCompleted,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:r}}},WebShopInteractionEncoder={open:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.webshop),interactionData:interactionTypes.webshop.open})},RetailInteractionEncoder={customerMeeting({agencyId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.retail.customerMeeting,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.retail),interactionData:r}}};var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
1
+ "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ReferralInteractionEncoder:()=>ReferralInteractionEncoder,PressInteractionEncoder:()=>PressInteractionEncoder,PurchaseInteractionEncoder:()=>PurchaseInteractionEncoder,RetailInteractionEncoder:()=>RetailInteractionEncoder,WebShopInteractionEncoder:()=>WebShopInteractionEncoder});let external_viem_namespaceObject=require("viem"),interactionTypes={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"}},productTypes={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31},productTypesMask=Object.entries(productTypes).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{}),PressInteractionEncoder={openArticle({articleId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.press.openArticle,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.press),interactionData:r}},readArticle({articleId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.press.readArticle,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.press),interactionData:r}}},ReferralInteractionEncoder={createLink:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:interactionTypes.referral.createLink}),referred({referrer:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.referral.referred,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.referral),interactionData:r}}},PurchaseInteractionEncoder={startPurchase({purchaseId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.started,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:r}},completedPurchase({purchaseId:e,proof:r}){let t=(0,external_viem_namespaceObject.encodeAbiParameters)([{type:"uint256"},{type:"bytes32[]"}],[BigInt(e),r]),a=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.completed,t]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:a}},unsafeCompletedPurchase({purchaseId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.purchase.unsafeCompleted,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.purchase),interactionData:r}}},WebShopInteractionEncoder={open:()=>({handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.webshop),interactionData:interactionTypes.webshop.open})},RetailInteractionEncoder={customerMeeting({agencyId:e}){let r=(0,external_viem_namespaceObject.concatHex)([interactionTypes.retail.customerMeeting,(0,external_viem_namespaceObject.pad)(e,{size:32})]);return{handlerTypeDenominator:(0,external_viem_namespaceObject.toHex)(productTypes.retail),interactionData:r}}};var __webpack_export_target__=exports;for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__]=__webpack_exports__[__webpack_i__];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0});
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "url": "https://twitter.com/QNivelais"
12
12
  }
13
13
  ],
14
- "version": "0.0.9",
14
+ "version": "0.0.11",
15
15
  "description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
16
16
  "repository": {
17
17
  "url": "https://github.com/frak-id/wallet",
@@ -82,19 +82,17 @@
82
82
  "publish": "echo 'Publishing core...'"
83
83
  },
84
84
  "peerDependencies": {
85
- "viem": "^2.x"
85
+ "viem": "^2.23.14"
86
86
  },
87
87
  "dependencies": {
88
- "async-lz-string": "^1.1.0",
89
- "js-sha256": "^0.11.0"
88
+ "@jsonjoy.com/json-pack": "^1.2.0"
90
89
  },
91
90
  "devDependencies": {
92
91
  "@arethetypeswrong/cli": "^0.17.4",
93
92
  "@microsoft/api-extractor": "^7.52.1",
94
- "@rslib/core": "^0.5.4",
95
- "@types/node": "^22",
96
- "ts-checker-rspack-plugin": "^1.1.1",
97
- "typescript": "^5"
93
+ "@rslib/core": "^0.5.5",
94
+ "@types/node": "^22.13.13",
95
+ "typescript": "^5.8.2"
98
96
  },
99
97
  "browserslist": [
100
98
  "extends @frak-labs/browserslist-config"