@frak-labs/core-sdk 0.0.19 → 0.1.0-beta.8d103039

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 (85) hide show
  1. package/cdn/bundle.js +5 -5
  2. package/dist/actions.cjs +1 -1
  3. package/dist/actions.d.cts +154 -73
  4. package/dist/actions.d.ts +154 -73
  5. package/dist/actions.js +1 -1
  6. package/dist/bundle.cjs +2 -2
  7. package/dist/bundle.d.cts +257 -192
  8. package/dist/bundle.d.ts +257 -192
  9. package/dist/bundle.js +2 -2
  10. package/dist/index.cjs +11 -11
  11. package/dist/index.d.cts +199 -185
  12. package/dist/index.d.ts +199 -185
  13. package/dist/index.js +2 -2
  14. package/package.json +7 -2
  15. package/src/actions/displayEmbeddedWallet.ts +20 -0
  16. package/src/actions/displayModal.ts +131 -0
  17. package/src/actions/getProductInformation.ts +14 -0
  18. package/src/actions/index.ts +29 -0
  19. package/src/actions/openSso.ts +116 -0
  20. package/src/actions/prepareSso.ts +48 -0
  21. package/src/actions/referral/processReferral.ts +230 -0
  22. package/src/actions/referral/referralInteraction.ts +57 -0
  23. package/src/actions/sendInteraction.ts +32 -0
  24. package/src/actions/trackPurchaseStatus.ts +53 -0
  25. package/src/actions/watchWalletStatus.ts +94 -0
  26. package/src/actions/wrapper/modalBuilder.ts +212 -0
  27. package/src/actions/wrapper/sendTransaction.ts +62 -0
  28. package/src/actions/wrapper/siweAuthenticate.ts +94 -0
  29. package/src/bundle.ts +3 -0
  30. package/src/clients/DebugInfo.ts +182 -0
  31. package/src/clients/createIFrameFrakClient.ts +287 -0
  32. package/src/clients/index.ts +3 -0
  33. package/src/clients/setupClient.ts +71 -0
  34. package/src/clients/transports/iframeLifecycleManager.ts +88 -0
  35. package/src/constants/interactionTypes.ts +44 -0
  36. package/src/constants/locales.ts +14 -0
  37. package/src/constants/productTypes.ts +33 -0
  38. package/src/index.ts +103 -0
  39. package/src/interactions/index.ts +5 -0
  40. package/src/interactions/pressEncoder.ts +53 -0
  41. package/src/interactions/purchaseEncoder.ts +94 -0
  42. package/src/interactions/referralEncoder.ts +47 -0
  43. package/src/interactions/retailEncoder.ts +37 -0
  44. package/src/interactions/webshopEncoder.ts +30 -0
  45. package/src/types/client.ts +14 -0
  46. package/src/types/compression.ts +22 -0
  47. package/src/types/config.ts +111 -0
  48. package/src/types/context.ts +13 -0
  49. package/src/types/index.ts +70 -0
  50. package/src/types/lifecycle/client.ts +46 -0
  51. package/src/types/lifecycle/iframe.ts +35 -0
  52. package/src/types/lifecycle/index.ts +2 -0
  53. package/src/types/rpc/displayModal.ts +84 -0
  54. package/src/types/rpc/embedded/index.ts +68 -0
  55. package/src/types/rpc/embedded/loggedIn.ts +55 -0
  56. package/src/types/rpc/embedded/loggedOut.ts +28 -0
  57. package/src/types/rpc/interaction.ts +43 -0
  58. package/src/types/rpc/modal/final.ts +46 -0
  59. package/src/types/rpc/modal/generic.ts +46 -0
  60. package/src/types/rpc/modal/index.ts +20 -0
  61. package/src/types/rpc/modal/login.ts +32 -0
  62. package/src/types/rpc/modal/openSession.ts +25 -0
  63. package/src/types/rpc/modal/siweAuthenticate.ts +37 -0
  64. package/src/types/rpc/modal/transaction.ts +33 -0
  65. package/src/types/rpc/productInformation.ts +59 -0
  66. package/src/types/rpc/sso.ts +80 -0
  67. package/src/types/rpc/walletStatus.ts +35 -0
  68. package/src/types/rpc.ts +158 -0
  69. package/src/types/transport.ts +34 -0
  70. package/src/utils/FrakContext.ts +152 -0
  71. package/src/utils/compression/b64.ts +29 -0
  72. package/src/utils/compression/compress.ts +11 -0
  73. package/src/utils/compression/decompress.ts +11 -0
  74. package/src/utils/compression/index.ts +3 -0
  75. package/src/utils/computeProductId.ts +11 -0
  76. package/src/utils/constants.ts +4 -0
  77. package/src/utils/formatAmount.ts +18 -0
  78. package/src/utils/getCurrencyAmountKey.ts +15 -0
  79. package/src/utils/getSupportedCurrency.ts +14 -0
  80. package/src/utils/getSupportedLocale.ts +16 -0
  81. package/src/utils/iframeHelper.ts +142 -0
  82. package/src/utils/index.ts +21 -0
  83. package/src/utils/sso.ts +119 -0
  84. package/src/utils/ssoUrlListener.ts +60 -0
  85. package/src/utils/trackEvent.ts +26 -0
package/dist/index.d.ts CHANGED
@@ -1,10 +1,17 @@
1
1
  import type { Address } from 'viem';
2
2
  import type { Hex } from 'viem';
3
+ import type { LifecycleMessage } from '@frak-labs/frame-connector';
3
4
  import type { OpenPanel } from '@openpanel/web';
4
- import type { Prettify } from 'viem/chains';
5
- import type { RpcSchema } from 'viem';
5
+ import type { RpcClient } from '@frak-labs/frame-connector';
6
+ import { RpcMessage } from '@frak-labs/frame-connector';
7
+ import { RpcResponse } from '@frak-labs/frame-connector';
6
8
  import type { SiweMessage } from 'viem/siwe';
7
9
 
10
+ export declare type AppSpecificSsoMetadata = SsoMetadata & {
11
+ name: string;
12
+ css?: string;
13
+ };
14
+
8
15
  /**
9
16
  * Decode a base64url encoded string
10
17
  * @param value The value to decode
@@ -44,12 +51,7 @@ export declare const baseIframeProps: {
44
51
  * Event related to the iframe lifecycle
45
52
  * @ignore
46
53
  */
47
- export declare type ClientLifecycleEvent = CustomCssEvent | CustomI18nEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse;
48
-
49
- /** @ignore */
50
- export declare class ClientNotFound extends FrakRpcError {
51
- constructor();
52
- }
54
+ export declare type ClientLifecycleEvent = CustomCssEvent | CustomI18nEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse | SsoRedirectCompleteEvent;
53
55
 
54
56
  /**
55
57
  * Compress the current Frak context
@@ -66,11 +68,21 @@ declare function compress(context?: Partial<FrakContext>): string | undefined;
66
68
  export declare type CompressedData = Uint8Array;
67
69
 
68
70
  /**
69
- * Compress json data
70
- * @param data
71
- * @ignore
71
+ * Type of compressed the sso data
72
72
  */
73
- export declare function compressJson(data: unknown): Uint8Array;
73
+ export declare type CompressedSsoData = {
74
+ id?: Hex;
75
+ r?: string;
76
+ d?: boolean;
77
+ l?: "en" | "fr";
78
+ p: Hex;
79
+ m: {
80
+ n: string;
81
+ css?: string;
82
+ l?: string;
83
+ h?: string;
84
+ };
85
+ };
74
86
 
75
87
  /**
76
88
  * Compress json data
@@ -139,8 +151,8 @@ export declare class DebugInfoGatherer {
139
151
  private lastResponse;
140
152
  private lastRequest;
141
153
  constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement);
142
- setLastResponse(event: MessageEvent<IFrameEvent>): void;
143
- setLastRequest(event: IFrameEvent, target: string): void;
154
+ setLastResponse(message: RpcMessage, response: RpcResponse): void;
155
+ setLastRequest(event: RpcMessage): void;
144
156
  updateSetupStatus(status: boolean): void;
145
157
  private base64Encode;
146
158
  /**
@@ -163,20 +175,6 @@ export declare class DebugInfoGatherer {
163
175
  */
164
176
  declare function decompress(context?: string): FrakContext | undefined;
165
177
 
166
- /**
167
- * Decompress the given string
168
- * @param compressedData The params to encode
169
- * @ignore
170
- */
171
- export declare function decompressDataAndCheckHash<T>(compressedData: CompressedData): HashProtectedData<T>;
172
-
173
- /**
174
- * Decompress json data
175
- * @param data
176
- * @ignore
177
- */
178
- export declare function decompressJson<T>(data: Uint8Array): T | null;
179
-
180
178
  /**
181
179
  * Decompress json data
182
180
  * @param data
@@ -184,20 +182,6 @@ export declare function decompressJson<T>(data: Uint8Array): T | null;
184
182
  */
185
183
  export declare function decompressJsonFromB64<T>(data: string): T | null;
186
184
 
187
- /**
188
- * Simple deferred promise wrapper
189
- * @ignore
190
- */
191
- export declare class Deferred<T> {
192
- private readonly _promise;
193
- private _resolve;
194
- private _reject;
195
- constructor();
196
- get promise(): Promise<T>;
197
- resolve: (value: T | PromiseLike<T>) => void;
198
- reject: (reason?: unknown) => void;
199
- }
200
-
201
185
  /**
202
186
  * The params used to display the embedded wallet
203
187
  *
@@ -311,34 +295,6 @@ export declare type EmbeddedViewActionSharing = {
311
295
 
312
296
  declare type EventProps = Record<string, unknown>;
313
297
 
314
- /**
315
- * Type that extract the possible return type from a RPC Schema
316
- * @ignore
317
- */
318
- declare type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = Extract<TRpcSchema[number], {
319
- Method: TMethod;
320
- }>;
321
-
322
- /**
323
- * Type that extract the possible parameters from a RPC Schema
324
- * @ignore
325
- */
326
- export declare type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema> = {
327
- [K in keyof TRpcSchema]: Prettify<{
328
- method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
329
- } & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
330
- params?: never;
331
- } : {
332
- params: TRpcSchema[K]["Parameters"];
333
- } : never)>;
334
- }[number];
335
-
336
- /**
337
- * Type that extract the possible return type from a RPC Schema
338
- * @ignore
339
- */
340
- export declare type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"];
341
-
342
298
  /**
343
299
  * The different types of final actions we can display in the final step
344
300
  * @group Modal Display
@@ -375,6 +331,27 @@ export declare type FinalModalStepType = GenericModalStepType<"final", {
375
331
  autoSkip?: boolean;
376
332
  }, object>;
377
333
 
334
+ /**
335
+ * Find an iframe within window.opener by pathname
336
+ *
337
+ * When a popup is opened via window.open from an iframe, window.opener points to
338
+ * the parent window, not the iframe itself. This utility searches through all frames
339
+ * in window.opener to find an iframe matching the specified pathname.
340
+ *
341
+ * @param pathname - The pathname to search for (default: "/listener")
342
+ * @returns The matching iframe window, or null if not found
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * // Find the default /listener iframe
347
+ * const listenerIframe = findIframeInOpener();
348
+ *
349
+ * // Find a custom iframe
350
+ * const customIframe = findIframeInOpener("/my-custom-iframe");
351
+ * ```
352
+ */
353
+ export declare function findIframeInOpener(pathname?: string): Window | null;
354
+
378
355
  export declare function formatAmount(amount: number, currency?: Currency): string;
379
356
 
380
357
  /**
@@ -400,7 +377,7 @@ export declare type FrakContext = {
400
377
  };
401
378
 
402
379
  /**
403
- * Export our frak context "class"
380
+ * Export our frak context
404
381
  */
405
382
  export declare const FrakContextManager: {
406
383
  compress: typeof compress;
@@ -414,14 +391,9 @@ export declare const FrakContextManager: {
414
391
  declare type FrakEvent = "share_button_clicked" | "wallet_button_clicked" | "share_modal_error" | "user_referred";
415
392
 
416
393
  /**
417
- * Generic Frak RPC error
418
- * @ignore
394
+ * Represent an iframe event
419
395
  */
420
- export declare class FrakRpcError<T = undefined> extends Error {
421
- code: number;
422
- data?: T | undefined;
423
- constructor(code: number, message: string, data?: T | undefined);
424
- }
396
+ export declare type FrakLifecycleEvent = IFrameLifecycleEvent | ClientLifecycleEvent;
425
397
 
426
398
  /**
427
399
  * Configuration for the Frak Wallet SDK
@@ -488,6 +460,38 @@ export declare type FullInteractionTypesKey = {
488
460
  [Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
489
461
  }[keyof typeof interactionTypes];
490
462
 
463
+ /**
464
+ * The full SSO params that will be used for compression
465
+ */
466
+ export declare type FullSsoParams = Omit<PrepareSsoParamsType, "metadata"> & {
467
+ metadata: AppSpecificSsoMetadata;
468
+ productId: Hex;
469
+ };
470
+
471
+ /**
472
+ * Generate SSO URL with compressed parameters
473
+ * This mirrors the wallet's getOpenSsoLink() function
474
+ *
475
+ * @param walletUrl - Base wallet URL (e.g., "https://wallet.frak.id")
476
+ * @param params - SSO parameters
477
+ * @param productId - Product identifier
478
+ * @param name - Application name
479
+ * @param css - Optional custom CSS
480
+ * @returns Complete SSO URL ready to open in popup or redirect
481
+ *
482
+ * @example
483
+ * ```ts
484
+ * const ssoUrl = generateSsoUrl(
485
+ * "https://wallet.frak.id",
486
+ * { metadata: { logoUrl: "..." }, directExit: true },
487
+ * "0x123...",
488
+ * "My App"
489
+ * );
490
+ * // Returns: https://wallet.frak.id/sso?p=<compressed_base64>
491
+ * ```
492
+ */
493
+ export declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, productId: Hex, name: string, css?: string): string;
494
+
491
495
  /**
492
496
  * Represent a generic modal step type
493
497
  * @ignore
@@ -581,13 +585,6 @@ declare type HandshakeResponse = {
581
585
  };
582
586
  };
583
587
 
584
- /**
585
- * Compress the given params, and add hash protection to (rapidly) prevent interception modification
586
- * @param data The params to encode
587
- * @ignore
588
- */
589
- export declare function hashAndCompressData<T>(data: T): CompressedData;
590
-
591
588
  /**
592
589
  * The encoded data to send to a client / received by a client
593
590
  * @ignore
@@ -598,6 +595,7 @@ export declare type HashProtectedData<DataType> = Readonly<DataType & {
598
595
 
599
596
  declare type HearbeatEvent = {
600
597
  clientLifecycle: "heartbeat";
598
+ data?: never;
601
599
  };
602
600
 
603
601
  /**
@@ -635,66 +633,63 @@ declare type HearbeatEvent = {
635
633
  */
636
634
  export declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
637
635
 
638
- /**
639
- * Represent an iframe event
640
- */
641
- export declare type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
642
-
643
636
  /**
644
637
  * Event related to the iframe lifecycle
645
638
  * @ignore
646
639
  */
647
640
  export declare type IFrameLifecycleEvent = {
648
- iframeLifecycle: "connected" | "show" | "hide";
641
+ iframeLifecycle: "connected" | "show" | "hide" | "remove-backup";
649
642
  data?: never;
650
- } | DoBackupEvent | RemoveBackupEvent | HandshakeRequestEvent | RedirectRequestEvent;
651
-
652
- /**
653
- * Represent an iframe rpc event
654
- */
655
- export declare type IFrameRpcEvent = {
656
- id: string;
657
- topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
658
- data: CompressedData;
659
- };
643
+ } | DoBackupEvent | HandshakeRequestEvent | RedirectRequestEvent;
660
644
 
661
645
  /**
662
646
  * RPC interface that's used for the iframe communication
663
647
  *
664
- * Define all the methods available within the iFrame RPC client
648
+ * Define all the methods available within the iFrame RPC client with response type annotations
665
649
  *
666
650
  * @group RPC Schema
667
651
  *
668
652
  * @remarks
669
- * Here is the list of methods available:
653
+ * Each method in the schema now includes a ResponseType field that indicates:
654
+ * - "promise": One-shot request that resolves once
655
+ * - "stream": Streaming request that can emit multiple values
656
+ *
657
+ * ### Methods:
670
658
  *
671
- * ### frak_listenToWalletStatus
659
+ * #### frak_listenToWalletStatus
672
660
  * - Params: None
673
661
  * - Returns: {@link WalletStatusReturnType}
662
+ * - Response Type: stream (emits updates when wallet status changes)
674
663
  *
675
- * ### frak_displayModal
676
- * - Params: [{@link ModalRpcStepsInput}, name: string, metadata?: {@link ModalRpcMetadata}]
664
+ * #### frak_displayModal
665
+ * - Params: [requests: {@link ModalRpcStepsInput}, metadata?: {@link ModalRpcMetadata}, configMetadata: {@link FrakWalletSdkConfig}["metadata"]]
677
666
  * - Returns: {@link ModalRpcStepsResultType}
667
+ * - Response Type: promise (one-shot)
678
668
  *
679
- * ### frak_sendInteraction
669
+ * #### frak_sendInteraction
680
670
  * - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
681
671
  * - Returns: {@link SendInteractionReturnType}
672
+ * - Response Type: promise (one-shot)
682
673
  *
683
- * ### frak_sso
684
- * - Params [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
685
- * - Returns: undefined
674
+ * #### frak_sso
675
+ * - Params: [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
676
+ * - Returns: {@link OpenSsoReturnType}
677
+ * - Response Type: promise (one-shot)
686
678
  *
687
- * ### frak_getProductInformation
679
+ * #### frak_getProductInformation
688
680
  * - Params: None
689
681
  * - Returns: {@link GetProductInformationReturnType}
682
+ * - Response Type: promise (one-shot)
690
683
  *
691
- * ### frak_displayEmbeddedWallet
692
- * - Params: [{@link DisplayEmbeddedWalletParamsType}]
684
+ * #### frak_displayEmbeddedWallet
685
+ * - Params: [request: {@link DisplayEmbeddedWalletParamsType}, metadata: {@link FrakWalletSdkConfig}["metadata"]]
693
686
  * - Returns: {@link DisplayEmbeddedWalletResultType}
687
+ * - Response Type: promise (one-shot)
694
688
  */
695
689
  export declare type IFrameRpcSchema = [
696
690
  /**
697
691
  * Method used to listen to the wallet status
692
+ * This is a streaming method that emits updates when wallet status changes
698
693
  */
699
694
  {
700
695
  Method: "frak_listenToWalletStatus";
@@ -703,6 +698,7 @@ export declare type IFrameRpcSchema = [
703
698
  },
704
699
  /**
705
700
  * Method to display a modal with the provided steps
701
+ * This is a one-shot request
706
702
  */
707
703
  {
708
704
  Method: "frak_displayModal";
@@ -715,6 +711,7 @@ export declare type IFrameRpcSchema = [
715
711
  },
716
712
  /**
717
713
  * Method to transmit a user interaction
714
+ * This is a one-shot request
718
715
  */
719
716
  {
720
717
  Method: "frak_sendInteraction";
@@ -726,23 +723,40 @@ export declare type IFrameRpcSchema = [
726
723
  ReturnType: SendInteractionReturnType;
727
724
  },
728
725
  /**
729
- * Method to start a SSO
730
- * todo: Should also support direct tracking via a consumeKey
726
+ * Method to prepare SSO (generate URL for popup)
727
+ * Returns the SSO URL that should be opened in a popup
728
+ * Only used for popup flows (not redirect flows)
731
729
  */
732
730
  {
733
- Method: "frak_sso";
731
+ Method: "frak_prepareSso";
732
+ Parameters: [
733
+ params: PrepareSsoParamsType,
734
+ name: string,
735
+ customCss?: string
736
+ ];
737
+ ReturnType: PrepareSsoReturnType;
738
+ },
739
+ /**
740
+ * Method to open/trigger SSO
741
+ * Either triggers redirect (if openInSameWindow/redirectUrl)
742
+ * Or waits for popup completion (if popup mode)
743
+ * This method handles BOTH redirect and popup flows
744
+ */
745
+ {
746
+ Method: "frak_openSso";
734
747
  Parameters: [
735
748
  params: OpenSsoParamsType,
736
749
  name: string,
737
750
  customCss?: string
738
751
  ];
739
- ReturnType: undefined;
752
+ ReturnType: OpenSsoReturnType;
740
753
  },
741
754
  /**
742
755
  * Method to get current product information's
743
756
  * - Is product minted?
744
757
  * - Does it have running campaign?
745
758
  * - Estimated reward on actions
759
+ * This is a one-shot request
746
760
  */
747
761
  {
748
762
  Method: "frak_getProductInformation";
@@ -751,6 +765,7 @@ export declare type IFrameRpcSchema = [
751
765
  },
752
766
  /**
753
767
  * Method to show the embedded wallet, with potential customization
768
+ * This is a one-shot request
754
769
  */
755
770
  {
756
771
  Method: "frak_displayEmbeddedWallet";
@@ -777,11 +792,11 @@ export declare type IFrameTransport = {
777
792
  /**
778
793
  * Function used to perform a single request via the iframe transport
779
794
  */
780
- request: RequestFn<IFrameRpcSchema>;
795
+ request: RpcClient<IFrameRpcSchema, LifecycleMessage>["request"];
781
796
  /**
782
797
  * Function used to listen to a request response via the iframe transport
783
798
  */
784
- listenerRequest: ListenerRequestFn<IFrameRpcSchema>;
799
+ listenerRequest: RpcClient<IFrameRpcSchema, LifecycleMessage>["listen"];
785
800
  /**
786
801
  * Function used to destroy the iframe transport
787
802
  */
@@ -837,12 +852,6 @@ export declare type KeyProvider<DataType> = (value: DataType) => string[];
837
852
  */
838
853
  export declare type Language = "fr" | "en";
839
854
 
840
- /**
841
- * Type used for a listening request
842
- * @inline
843
- */
844
- declare type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
845
-
846
855
  /**
847
856
  * Map the currency to the locale
848
857
  */
@@ -1047,25 +1056,27 @@ export declare type OpenInteractionSessionReturnType = {
1047
1056
  * Params to start a SSO
1048
1057
  * @group RPC Schema
1049
1058
  */
1050
- export declare type OpenSsoParamsType = {
1059
+ export declare type OpenSsoParamsType = PrepareSsoParamsType & {
1051
1060
  /**
1052
- * Redirect URL after the SSO (optional)
1061
+ * Indicate whether we want todo the flow within the same window context, or if we want to do it with an external popup window openned
1062
+ * Note: Default true if redirectUrl is present, otherwise, false
1053
1063
  */
1054
- redirectUrl?: string;
1064
+ openInSameWindow?: boolean;
1055
1065
  /**
1056
- * If the SSO should directly exit after completion
1057
- * @defaultValue true
1066
+ * Custom SSO popup url if user want additionnal customisation
1058
1067
  */
1059
- directExit?: boolean;
1060
- /**
1061
- * Language of the SSO page (optional)
1062
- * It will default to the current user language (or "en" if unsupported language)
1063
- */
1064
- lang?: "en" | "fr";
1068
+ ssoPopupUrl?: string;
1069
+ };
1070
+
1071
+ /**
1072
+ * Response after an SSO has been openned
1073
+ */
1074
+ export declare type OpenSsoReturnType = {
1065
1075
  /**
1066
- * Custom SSO metadata
1076
+ * Optional wallet address, returned when SSO completes via postMessage
1077
+ * Note: Only present when SSO flow completes (not immediately on open)
1067
1078
  */
1068
- metadata: SsoMetadata;
1079
+ wallet?: Hex;
1069
1080
  };
1070
1081
 
1071
1082
  /**
@@ -1086,6 +1097,43 @@ export declare type PreparedInteraction = {
1086
1097
  interactionData: Hex;
1087
1098
  };
1088
1099
 
1100
+ /**
1101
+ * Params for preparing SSO (generating URL)
1102
+ * Same as OpenSsoParamsType but without openInSameWindow (popup-only operation)
1103
+ * @group RPC Schema
1104
+ */
1105
+ export declare type PrepareSsoParamsType = {
1106
+ /**
1107
+ * Redirect URL after the SSO (optional)
1108
+ */
1109
+ redirectUrl?: string;
1110
+ /**
1111
+ * If the SSO should directly exit after completion
1112
+ * @defaultValue true
1113
+ */
1114
+ directExit?: boolean;
1115
+ /**
1116
+ * Language of the SSO page (optional)
1117
+ * It will default to the current user language (or "en" if unsupported language)
1118
+ */
1119
+ lang?: "en" | "fr";
1120
+ /**
1121
+ * Custom SSO metadata
1122
+ */
1123
+ metadata?: SsoMetadata;
1124
+ };
1125
+
1126
+ /**
1127
+ * Response after preparing SSO
1128
+ * @group RPC Schema
1129
+ */
1130
+ export declare type PrepareSsoReturnType = {
1131
+ /**
1132
+ * The SSO URL that should be opened in a popup
1133
+ */
1134
+ ssoUrl: string;
1135
+ };
1136
+
1089
1137
  /**
1090
1138
  * List of the product types per denominator
1091
1139
  */
@@ -1113,7 +1161,8 @@ declare type RedirectRequestEvent = {
1113
1161
  iframeLifecycle: "redirect";
1114
1162
  data: {
1115
1163
  /**
1116
- * The base url to redirect to (contain a query param `u`, the client need to suffix the current url to the base url)
1164
+ * The base url to redirect to
1165
+ * If it contain a query param `u`, the client need will suffix the current url to the base url
1117
1166
  */
1118
1167
  baseRedirectUrl: string;
1119
1168
  };
@@ -1126,10 +1175,6 @@ declare type RedirectRequestEvent = {
1126
1175
  */
1127
1176
  declare function remove(url: string): string;
1128
1177
 
1129
- declare type RemoveBackupEvent = {
1130
- iframeLifecycle: "remove-backup";
1131
- };
1132
-
1133
1178
  /**
1134
1179
  * Replace the current url with the given Frak context
1135
1180
  * @param args
@@ -1141,12 +1186,6 @@ declare function replaceUrl({ url: baseUrl, context, }: {
1141
1186
  context: Partial<FrakContext> | null;
1142
1187
  }): void;
1143
1188
 
1144
- /**
1145
- * Type used for a one shot request function
1146
- * @inline
1147
- */
1148
- declare type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
1149
-
1150
1189
  declare type RestoreBackupEvent = {
1151
1190
  clientLifecycle: "restore-backup";
1152
1191
  data: {
@@ -1154,42 +1193,6 @@ declare type RestoreBackupEvent = {
1154
1193
  };
1155
1194
  };
1156
1195
 
1157
- /**
1158
- * The different Frak RPC error codes
1159
- */
1160
- export declare const RpcErrorCodes: {
1161
- readonly parseError: -32700;
1162
- readonly invalidRequest: -32600;
1163
- readonly methodNotFound: -32601;
1164
- readonly invalidParams: -32602;
1165
- readonly internalError: -32603;
1166
- readonly serverError: -32000;
1167
- readonly clientNotConnected: -32001;
1168
- readonly configError: -32002;
1169
- readonly corruptedResponse: -32003;
1170
- readonly clientAborted: -32004;
1171
- readonly walletNotConnected: -32005;
1172
- readonly serverErrorForInteractionDelegation: -32006;
1173
- };
1174
-
1175
- /**
1176
- * Raw response that we will receive after an rpc request
1177
- * @ignore
1178
- */
1179
- export declare type RpcResponse<TRpcSchema extends RpcSchema, TMethod extends TRpcSchema[number]["Method"] = TRpcSchema[number]["Method"]> = {
1180
- result: Extract<TRpcSchema[number], {
1181
- Method: TMethod;
1182
- }>["ReturnType"];
1183
- error?: never;
1184
- } | {
1185
- result?: never;
1186
- error: {
1187
- code: number;
1188
- message: string;
1189
- data?: unknown;
1190
- };
1191
- };
1192
-
1193
1196
  /**
1194
1197
  * Parameters that will be used to send an interaction to the blockchain
1195
1198
  * @inline
@@ -1315,6 +1318,17 @@ export declare type SsoMetadata = {
1315
1318
  homepageLink?: string;
1316
1319
  };
1317
1320
 
1321
+ export declare const ssoPopupFeatures = "menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800";
1322
+
1323
+ export declare const ssoPopupName = "frak-sso";
1324
+
1325
+ declare type SsoRedirectCompleteEvent = {
1326
+ clientLifecycle: "sso-redirect-complete";
1327
+ data: {
1328
+ compressed: string;
1329
+ };
1330
+ };
1331
+
1318
1332
  /**
1319
1333
  * The type for the amount of tokens
1320
1334
  */