@frak-labs/core-sdk 0.0.19 → 0.1.0-beta.6e0d8026
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/bundle.js +5 -5
- package/dist/actions.cjs +1 -1
- package/dist/actions.d.cts +154 -73
- package/dist/actions.d.ts +154 -73
- package/dist/actions.js +1 -1
- package/dist/bundle.cjs +2 -2
- package/dist/bundle.d.cts +257 -192
- package/dist/bundle.d.ts +257 -192
- package/dist/bundle.js +2 -2
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +199 -185
- package/dist/index.d.ts +199 -185
- package/dist/index.js +2 -2
- package/package.json +5 -1
package/dist/bundle.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { Address } from 'viem';
|
|
2
2
|
import { Hex } from 'viem';
|
|
3
|
+
import type { LifecycleMessage } from '@frak-labs/frame-connector';
|
|
3
4
|
import type { OpenPanel } from '@openpanel/web';
|
|
4
|
-
import type {
|
|
5
|
-
import
|
|
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
|
-
*
|
|
70
|
-
* @param data
|
|
71
|
-
* @ignore
|
|
71
|
+
* Type of compressed the sso data
|
|
72
72
|
*/
|
|
73
|
-
export declare
|
|
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(
|
|
143
|
-
setLastRequest(event:
|
|
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
|
* Function used to display the Frak embedded wallet popup
|
|
203
187
|
* @param client - The current Frak Client
|
|
@@ -433,34 +417,6 @@ export declare type EmbeddedViewActionSharing = {
|
|
|
433
417
|
|
|
434
418
|
declare type EventProps = Record<string, unknown>;
|
|
435
419
|
|
|
436
|
-
/**
|
|
437
|
-
* Type that extract the possible return type from a RPC Schema
|
|
438
|
-
* @ignore
|
|
439
|
-
*/
|
|
440
|
-
declare type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = Extract<TRpcSchema[number], {
|
|
441
|
-
Method: TMethod;
|
|
442
|
-
}>;
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* Type that extract the possible parameters from a RPC Schema
|
|
446
|
-
* @ignore
|
|
447
|
-
*/
|
|
448
|
-
export declare type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema> = {
|
|
449
|
-
[K in keyof TRpcSchema]: Prettify<{
|
|
450
|
-
method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
|
|
451
|
-
} & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
|
|
452
|
-
params?: never;
|
|
453
|
-
} : {
|
|
454
|
-
params: TRpcSchema[K]["Parameters"];
|
|
455
|
-
} : never)>;
|
|
456
|
-
}[number];
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Type that extract the possible return type from a RPC Schema
|
|
460
|
-
* @ignore
|
|
461
|
-
*/
|
|
462
|
-
export declare type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"];
|
|
463
|
-
|
|
464
420
|
/**
|
|
465
421
|
* The different types of final actions we can display in the final step
|
|
466
422
|
* @group Modal Display
|
|
@@ -497,6 +453,27 @@ export declare type FinalModalStepType = GenericModalStepType<"final", {
|
|
|
497
453
|
autoSkip?: boolean;
|
|
498
454
|
}, object>;
|
|
499
455
|
|
|
456
|
+
/**
|
|
457
|
+
* Find an iframe within window.opener by pathname
|
|
458
|
+
*
|
|
459
|
+
* When a popup is opened via window.open from an iframe, window.opener points to
|
|
460
|
+
* the parent window, not the iframe itself. This utility searches through all frames
|
|
461
|
+
* in window.opener to find an iframe matching the specified pathname.
|
|
462
|
+
*
|
|
463
|
+
* @param pathname - The pathname to search for (default: "/listener")
|
|
464
|
+
* @returns The matching iframe window, or null if not found
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* // Find the default /listener iframe
|
|
469
|
+
* const listenerIframe = findIframeInOpener();
|
|
470
|
+
*
|
|
471
|
+
* // Find a custom iframe
|
|
472
|
+
* const customIframe = findIframeInOpener("/my-custom-iframe");
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
export declare function findIframeInOpener(pathname?: string): Window | null;
|
|
476
|
+
|
|
500
477
|
export declare function formatAmount(amount: number, currency?: Currency): string;
|
|
501
478
|
|
|
502
479
|
/**
|
|
@@ -522,7 +499,7 @@ export declare type FrakContext = {
|
|
|
522
499
|
};
|
|
523
500
|
|
|
524
501
|
/**
|
|
525
|
-
* Export our frak context
|
|
502
|
+
* Export our frak context
|
|
526
503
|
*/
|
|
527
504
|
export declare const FrakContextManager: {
|
|
528
505
|
compress: typeof compress;
|
|
@@ -536,14 +513,9 @@ export declare const FrakContextManager: {
|
|
|
536
513
|
declare type FrakEvent = "share_button_clicked" | "wallet_button_clicked" | "share_modal_error" | "user_referred";
|
|
537
514
|
|
|
538
515
|
/**
|
|
539
|
-
*
|
|
540
|
-
* @ignore
|
|
516
|
+
* Represent an iframe event
|
|
541
517
|
*/
|
|
542
|
-
export declare
|
|
543
|
-
code: number;
|
|
544
|
-
data?: T | undefined;
|
|
545
|
-
constructor(code: number, message: string, data?: T | undefined);
|
|
546
|
-
}
|
|
518
|
+
export declare type FrakLifecycleEvent = IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
547
519
|
|
|
548
520
|
/**
|
|
549
521
|
* Configuration for the Frak Wallet SDK
|
|
@@ -610,6 +582,38 @@ export declare type FullInteractionTypesKey = {
|
|
|
610
582
|
[Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
|
|
611
583
|
}[keyof typeof interactionTypes];
|
|
612
584
|
|
|
585
|
+
/**
|
|
586
|
+
* The full SSO params that will be used for compression
|
|
587
|
+
*/
|
|
588
|
+
export declare type FullSsoParams = Omit<PrepareSsoParamsType, "metadata"> & {
|
|
589
|
+
metadata: AppSpecificSsoMetadata;
|
|
590
|
+
productId: Hex;
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Generate SSO URL with compressed parameters
|
|
595
|
+
* This mirrors the wallet's getOpenSsoLink() function
|
|
596
|
+
*
|
|
597
|
+
* @param walletUrl - Base wallet URL (e.g., "https://wallet.frak.id")
|
|
598
|
+
* @param params - SSO parameters
|
|
599
|
+
* @param productId - Product identifier
|
|
600
|
+
* @param name - Application name
|
|
601
|
+
* @param css - Optional custom CSS
|
|
602
|
+
* @returns Complete SSO URL ready to open in popup or redirect
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* const ssoUrl = generateSsoUrl(
|
|
607
|
+
* "https://wallet.frak.id",
|
|
608
|
+
* { metadata: { logoUrl: "..." }, directExit: true },
|
|
609
|
+
* "0x123...",
|
|
610
|
+
* "My App"
|
|
611
|
+
* );
|
|
612
|
+
* // Returns: https://wallet.frak.id/sso?p=<compressed_base64>
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
export declare function generateSsoUrl(walletUrl: string, params: PrepareSsoParamsType, productId: Hex, name: string, css?: string): string;
|
|
616
|
+
|
|
613
617
|
/**
|
|
614
618
|
* Represent a generic modal step type
|
|
615
619
|
* @ignore
|
|
@@ -710,13 +714,6 @@ declare type HandshakeResponse = {
|
|
|
710
714
|
};
|
|
711
715
|
};
|
|
712
716
|
|
|
713
|
-
/**
|
|
714
|
-
* Compress the given params, and add hash protection to (rapidly) prevent interception modification
|
|
715
|
-
* @param data The params to encode
|
|
716
|
-
* @ignore
|
|
717
|
-
*/
|
|
718
|
-
export declare function hashAndCompressData<T>(data: T): CompressedData;
|
|
719
|
-
|
|
720
717
|
/**
|
|
721
718
|
* The encoded data to send to a client / received by a client
|
|
722
719
|
* @ignore
|
|
@@ -727,6 +724,7 @@ export declare type HashProtectedData<DataType> = Readonly<DataType & {
|
|
|
727
724
|
|
|
728
725
|
declare type HearbeatEvent = {
|
|
729
726
|
clientLifecycle: "heartbeat";
|
|
727
|
+
data?: never;
|
|
730
728
|
};
|
|
731
729
|
|
|
732
730
|
/**
|
|
@@ -764,66 +762,63 @@ declare type HearbeatEvent = {
|
|
|
764
762
|
*/
|
|
765
763
|
export declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
|
|
766
764
|
|
|
767
|
-
/**
|
|
768
|
-
* Represent an iframe event
|
|
769
|
-
*/
|
|
770
|
-
export declare type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
771
|
-
|
|
772
765
|
/**
|
|
773
766
|
* Event related to the iframe lifecycle
|
|
774
767
|
* @ignore
|
|
775
768
|
*/
|
|
776
769
|
export declare type IFrameLifecycleEvent = {
|
|
777
|
-
iframeLifecycle: "connected" | "show" | "hide";
|
|
770
|
+
iframeLifecycle: "connected" | "show" | "hide" | "remove-backup";
|
|
778
771
|
data?: never;
|
|
779
|
-
} | DoBackupEvent |
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
* Represent an iframe rpc event
|
|
783
|
-
*/
|
|
784
|
-
export declare type IFrameRpcEvent = {
|
|
785
|
-
id: string;
|
|
786
|
-
topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
|
|
787
|
-
data: CompressedData;
|
|
788
|
-
};
|
|
772
|
+
} | DoBackupEvent | HandshakeRequestEvent | RedirectRequestEvent;
|
|
789
773
|
|
|
790
774
|
/**
|
|
791
775
|
* RPC interface that's used for the iframe communication
|
|
792
776
|
*
|
|
793
|
-
* Define all the methods available within the iFrame RPC client
|
|
777
|
+
* Define all the methods available within the iFrame RPC client with response type annotations
|
|
794
778
|
*
|
|
795
779
|
* @group RPC Schema
|
|
796
780
|
*
|
|
797
781
|
* @remarks
|
|
798
|
-
*
|
|
782
|
+
* Each method in the schema now includes a ResponseType field that indicates:
|
|
783
|
+
* - "promise": One-shot request that resolves once
|
|
784
|
+
* - "stream": Streaming request that can emit multiple values
|
|
785
|
+
*
|
|
786
|
+
* ### Methods:
|
|
799
787
|
*
|
|
800
|
-
*
|
|
788
|
+
* #### frak_listenToWalletStatus
|
|
801
789
|
* - Params: None
|
|
802
790
|
* - Returns: {@link WalletStatusReturnType}
|
|
791
|
+
* - Response Type: stream (emits updates when wallet status changes)
|
|
803
792
|
*
|
|
804
|
-
*
|
|
805
|
-
* - Params: [{@link ModalRpcStepsInput},
|
|
793
|
+
* #### frak_displayModal
|
|
794
|
+
* - Params: [requests: {@link ModalRpcStepsInput}, metadata?: {@link ModalRpcMetadata}, configMetadata: {@link FrakWalletSdkConfig}["metadata"]]
|
|
806
795
|
* - Returns: {@link ModalRpcStepsResultType}
|
|
796
|
+
* - Response Type: promise (one-shot)
|
|
807
797
|
*
|
|
808
|
-
*
|
|
798
|
+
* #### frak_sendInteraction
|
|
809
799
|
* - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
|
|
810
800
|
* - Returns: {@link SendInteractionReturnType}
|
|
801
|
+
* - Response Type: promise (one-shot)
|
|
811
802
|
*
|
|
812
|
-
*
|
|
813
|
-
* - Params [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
|
|
814
|
-
* - Returns:
|
|
803
|
+
* #### frak_sso
|
|
804
|
+
* - Params: [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
|
|
805
|
+
* - Returns: {@link OpenSsoReturnType}
|
|
806
|
+
* - Response Type: promise (one-shot)
|
|
815
807
|
*
|
|
816
|
-
*
|
|
808
|
+
* #### frak_getProductInformation
|
|
817
809
|
* - Params: None
|
|
818
810
|
* - Returns: {@link GetProductInformationReturnType}
|
|
811
|
+
* - Response Type: promise (one-shot)
|
|
819
812
|
*
|
|
820
|
-
*
|
|
821
|
-
* - Params: [{@link DisplayEmbeddedWalletParamsType}]
|
|
813
|
+
* #### frak_displayEmbeddedWallet
|
|
814
|
+
* - Params: [request: {@link DisplayEmbeddedWalletParamsType}, metadata: {@link FrakWalletSdkConfig}["metadata"]]
|
|
822
815
|
* - Returns: {@link DisplayEmbeddedWalletResultType}
|
|
816
|
+
* - Response Type: promise (one-shot)
|
|
823
817
|
*/
|
|
824
818
|
export declare type IFrameRpcSchema = [
|
|
825
819
|
/**
|
|
826
820
|
* Method used to listen to the wallet status
|
|
821
|
+
* This is a streaming method that emits updates when wallet status changes
|
|
827
822
|
*/
|
|
828
823
|
{
|
|
829
824
|
Method: "frak_listenToWalletStatus";
|
|
@@ -832,6 +827,7 @@ export declare type IFrameRpcSchema = [
|
|
|
832
827
|
},
|
|
833
828
|
/**
|
|
834
829
|
* Method to display a modal with the provided steps
|
|
830
|
+
* This is a one-shot request
|
|
835
831
|
*/
|
|
836
832
|
{
|
|
837
833
|
Method: "frak_displayModal";
|
|
@@ -844,6 +840,7 @@ export declare type IFrameRpcSchema = [
|
|
|
844
840
|
},
|
|
845
841
|
/**
|
|
846
842
|
* Method to transmit a user interaction
|
|
843
|
+
* This is a one-shot request
|
|
847
844
|
*/
|
|
848
845
|
{
|
|
849
846
|
Method: "frak_sendInteraction";
|
|
@@ -855,23 +852,40 @@ export declare type IFrameRpcSchema = [
|
|
|
855
852
|
ReturnType: SendInteractionReturnType;
|
|
856
853
|
},
|
|
857
854
|
/**
|
|
858
|
-
* Method to
|
|
859
|
-
*
|
|
855
|
+
* Method to prepare SSO (generate URL for popup)
|
|
856
|
+
* Returns the SSO URL that should be opened in a popup
|
|
857
|
+
* Only used for popup flows (not redirect flows)
|
|
860
858
|
*/
|
|
861
859
|
{
|
|
862
|
-
Method: "
|
|
860
|
+
Method: "frak_prepareSso";
|
|
861
|
+
Parameters: [
|
|
862
|
+
params: PrepareSsoParamsType,
|
|
863
|
+
name: string,
|
|
864
|
+
customCss?: string
|
|
865
|
+
];
|
|
866
|
+
ReturnType: PrepareSsoReturnType;
|
|
867
|
+
},
|
|
868
|
+
/**
|
|
869
|
+
* Method to open/trigger SSO
|
|
870
|
+
* Either triggers redirect (if openInSameWindow/redirectUrl)
|
|
871
|
+
* Or waits for popup completion (if popup mode)
|
|
872
|
+
* This method handles BOTH redirect and popup flows
|
|
873
|
+
*/
|
|
874
|
+
{
|
|
875
|
+
Method: "frak_openSso";
|
|
863
876
|
Parameters: [
|
|
864
877
|
params: OpenSsoParamsType,
|
|
865
878
|
name: string,
|
|
866
879
|
customCss?: string
|
|
867
880
|
];
|
|
868
|
-
ReturnType:
|
|
881
|
+
ReturnType: OpenSsoReturnType;
|
|
869
882
|
},
|
|
870
883
|
/**
|
|
871
884
|
* Method to get current product information's
|
|
872
885
|
* - Is product minted?
|
|
873
886
|
* - Does it have running campaign?
|
|
874
887
|
* - Estimated reward on actions
|
|
888
|
+
* This is a one-shot request
|
|
875
889
|
*/
|
|
876
890
|
{
|
|
877
891
|
Method: "frak_getProductInformation";
|
|
@@ -880,6 +894,7 @@ export declare type IFrameRpcSchema = [
|
|
|
880
894
|
},
|
|
881
895
|
/**
|
|
882
896
|
* Method to show the embedded wallet, with potential customization
|
|
897
|
+
* This is a one-shot request
|
|
883
898
|
*/
|
|
884
899
|
{
|
|
885
900
|
Method: "frak_displayEmbeddedWallet";
|
|
@@ -906,11 +921,11 @@ export declare type IFrameTransport = {
|
|
|
906
921
|
/**
|
|
907
922
|
* Function used to perform a single request via the iframe transport
|
|
908
923
|
*/
|
|
909
|
-
request:
|
|
924
|
+
request: RpcClient<IFrameRpcSchema, LifecycleMessage>["request"];
|
|
910
925
|
/**
|
|
911
926
|
* Function used to listen to a request response via the iframe transport
|
|
912
927
|
*/
|
|
913
|
-
listenerRequest:
|
|
928
|
+
listenerRequest: RpcClient<IFrameRpcSchema, LifecycleMessage>["listen"];
|
|
914
929
|
/**
|
|
915
930
|
* Function used to destroy the iframe transport
|
|
916
931
|
*/
|
|
@@ -966,12 +981,6 @@ export declare type KeyProvider<DataType> = (value: DataType) => string[];
|
|
|
966
981
|
*/
|
|
967
982
|
export declare type Language = "fr" | "en";
|
|
968
983
|
|
|
969
|
-
/**
|
|
970
|
-
* Type used for a listening request
|
|
971
|
-
* @inline
|
|
972
|
-
*/
|
|
973
|
-
declare type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
974
|
-
|
|
975
984
|
/**
|
|
976
985
|
* Map the currency to the locale
|
|
977
986
|
*/
|
|
@@ -1255,7 +1264,16 @@ export declare type OpenInteractionSessionReturnType = {
|
|
|
1255
1264
|
* @param client - The current Frak Client
|
|
1256
1265
|
* @param args - The SSO parameters
|
|
1257
1266
|
*
|
|
1258
|
-
* @description
|
|
1267
|
+
* @description Two SSO flow modes:
|
|
1268
|
+
*
|
|
1269
|
+
* **Redirect Mode** (openInSameWindow: true):
|
|
1270
|
+
* - Wallet generates URL and triggers redirect
|
|
1271
|
+
* - Used when redirectUrl is provided
|
|
1272
|
+
*
|
|
1273
|
+
* **Popup Mode** (openInSameWindow: false/omitted):
|
|
1274
|
+
* - SDK generates URL client-side (or uses provided ssoPopupUrl)
|
|
1275
|
+
* - Opens popup synchronously (prevents popup blockers)
|
|
1276
|
+
* - Waits for SSO completion via postMessage
|
|
1259
1277
|
*
|
|
1260
1278
|
* @example
|
|
1261
1279
|
* First we build the sso metadata
|
|
@@ -1269,47 +1287,58 @@ export declare type OpenInteractionSessionReturnType = {
|
|
|
1269
1287
|
*
|
|
1270
1288
|
* Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL
|
|
1271
1289
|
* :::code-group
|
|
1272
|
-
* ```ts [
|
|
1273
|
-
* //
|
|
1290
|
+
* ```ts [Popup (default)]
|
|
1291
|
+
* // Opens in popup, SDK generates URL automatically
|
|
1274
1292
|
* await openSso(frakConfig, {
|
|
1275
1293
|
* directExit: true,
|
|
1276
1294
|
* metadata,
|
|
1277
1295
|
* });
|
|
1278
1296
|
* ```
|
|
1279
|
-
* ```ts [
|
|
1280
|
-
* //
|
|
1297
|
+
* ```ts [Redirect]
|
|
1298
|
+
* // Opens in same window with redirect
|
|
1281
1299
|
* await openSso(frakConfig, {
|
|
1282
1300
|
* redirectUrl: "https://my-app.com/frak-sso",
|
|
1283
1301
|
* metadata,
|
|
1302
|
+
* openInSameWindow: true,
|
|
1303
|
+
* });
|
|
1304
|
+
* ```
|
|
1305
|
+
* ```ts [Custom popup URL]
|
|
1306
|
+
* // Advanced: provide custom SSO URL
|
|
1307
|
+
* const { ssoUrl } = await prepareSso(frakConfig, { metadata });
|
|
1308
|
+
* await openSso(frakConfig, {
|
|
1309
|
+
* metadata,
|
|
1310
|
+
* ssoPopupUrl: `${ssoUrl}&custom=param`,
|
|
1284
1311
|
* });
|
|
1285
1312
|
* ```
|
|
1286
1313
|
* :::
|
|
1287
1314
|
*/
|
|
1288
|
-
export declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<
|
|
1315
|
+
export declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<OpenSsoReturnType>;
|
|
1289
1316
|
|
|
1290
1317
|
/**
|
|
1291
1318
|
* Params to start a SSO
|
|
1292
1319
|
* @group RPC Schema
|
|
1293
1320
|
*/
|
|
1294
|
-
export declare type OpenSsoParamsType = {
|
|
1295
|
-
/**
|
|
1296
|
-
* Redirect URL after the SSO (optional)
|
|
1297
|
-
*/
|
|
1298
|
-
redirectUrl?: string;
|
|
1321
|
+
export declare type OpenSsoParamsType = PrepareSsoParamsType & {
|
|
1299
1322
|
/**
|
|
1300
|
-
*
|
|
1301
|
-
*
|
|
1323
|
+
* 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
|
|
1324
|
+
* Note: Default true if redirectUrl is present, otherwise, false
|
|
1302
1325
|
*/
|
|
1303
|
-
|
|
1326
|
+
openInSameWindow?: boolean;
|
|
1304
1327
|
/**
|
|
1305
|
-
*
|
|
1306
|
-
* It will default to the current user language (or "en" if unsupported language)
|
|
1328
|
+
* Custom SSO popup url if user want additionnal customisation
|
|
1307
1329
|
*/
|
|
1308
|
-
|
|
1330
|
+
ssoPopupUrl?: string;
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* Response after an SSO has been openned
|
|
1335
|
+
*/
|
|
1336
|
+
export declare type OpenSsoReturnType = {
|
|
1309
1337
|
/**
|
|
1310
|
-
*
|
|
1338
|
+
* Optional wallet address, returned when SSO completes via postMessage
|
|
1339
|
+
* Note: Only present when SSO flow completes (not immediately on open)
|
|
1311
1340
|
*/
|
|
1312
|
-
|
|
1341
|
+
wallet?: Hex;
|
|
1313
1342
|
};
|
|
1314
1343
|
|
|
1315
1344
|
/**
|
|
@@ -1330,6 +1359,76 @@ export declare type PreparedInteraction = {
|
|
|
1330
1359
|
interactionData: Hex;
|
|
1331
1360
|
};
|
|
1332
1361
|
|
|
1362
|
+
/**
|
|
1363
|
+
* Generate SSO URL without opening popup
|
|
1364
|
+
*
|
|
1365
|
+
* This is a **synchronous**, client-side function that generates the SSO URL
|
|
1366
|
+
* without any RPC calls to the wallet iframe. Use this when you need:
|
|
1367
|
+
* - Custom URL modifications before opening popup
|
|
1368
|
+
* - Pre-generation for advanced popup strategies
|
|
1369
|
+
* - URL inspection/logging before SSO flow
|
|
1370
|
+
*
|
|
1371
|
+
* @param client - The current Frak Client
|
|
1372
|
+
* @param args - The SSO parameters
|
|
1373
|
+
* @returns Object containing the generated ssoUrl
|
|
1374
|
+
*
|
|
1375
|
+
* @example
|
|
1376
|
+
* ```ts
|
|
1377
|
+
* // Generate URL for inspection
|
|
1378
|
+
* const { ssoUrl } = prepareSso(client, {
|
|
1379
|
+
* metadata: { logoUrl: "..." },
|
|
1380
|
+
* directExit: true
|
|
1381
|
+
* });
|
|
1382
|
+
* console.log("Opening SSO:", ssoUrl);
|
|
1383
|
+
*
|
|
1384
|
+
* // Add custom params
|
|
1385
|
+
* const customUrl = `${ssoUrl}&tracking=abc123`;
|
|
1386
|
+
* await openSso(client, { metadata, ssoPopupUrl: customUrl });
|
|
1387
|
+
* ```
|
|
1388
|
+
*
|
|
1389
|
+
* @remarks
|
|
1390
|
+
* For most use cases, just use `openSso()` which handles URL generation automatically.
|
|
1391
|
+
* Only use `prepareSso()` when you need explicit control over the URL.
|
|
1392
|
+
*/
|
|
1393
|
+
export declare function prepareSso(client: FrakClient, args: PrepareSsoParamsType): Promise<PrepareSsoReturnType>;
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* Params for preparing SSO (generating URL)
|
|
1397
|
+
* Same as OpenSsoParamsType but without openInSameWindow (popup-only operation)
|
|
1398
|
+
* @group RPC Schema
|
|
1399
|
+
*/
|
|
1400
|
+
export declare type PrepareSsoParamsType = {
|
|
1401
|
+
/**
|
|
1402
|
+
* Redirect URL after the SSO (optional)
|
|
1403
|
+
*/
|
|
1404
|
+
redirectUrl?: string;
|
|
1405
|
+
/**
|
|
1406
|
+
* If the SSO should directly exit after completion
|
|
1407
|
+
* @defaultValue true
|
|
1408
|
+
*/
|
|
1409
|
+
directExit?: boolean;
|
|
1410
|
+
/**
|
|
1411
|
+
* Language of the SSO page (optional)
|
|
1412
|
+
* It will default to the current user language (or "en" if unsupported language)
|
|
1413
|
+
*/
|
|
1414
|
+
lang?: "en" | "fr";
|
|
1415
|
+
/**
|
|
1416
|
+
* Custom SSO metadata
|
|
1417
|
+
*/
|
|
1418
|
+
metadata?: SsoMetadata;
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* Response after preparing SSO
|
|
1423
|
+
* @group RPC Schema
|
|
1424
|
+
*/
|
|
1425
|
+
export declare type PrepareSsoReturnType = {
|
|
1426
|
+
/**
|
|
1427
|
+
* The SSO URL that should be opened in a popup
|
|
1428
|
+
*/
|
|
1429
|
+
ssoUrl: string;
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1333
1432
|
/**
|
|
1334
1433
|
* Press interactions allow you to track user engagement with articles or other press content on your platform.
|
|
1335
1434
|
* After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
|
|
@@ -1497,7 +1596,8 @@ declare type RedirectRequestEvent = {
|
|
|
1497
1596
|
iframeLifecycle: "redirect";
|
|
1498
1597
|
data: {
|
|
1499
1598
|
/**
|
|
1500
|
-
* The base url to redirect to
|
|
1599
|
+
* The base url to redirect to
|
|
1600
|
+
* If it contain a query param `u`, the client need will suffix the current url to the base url
|
|
1501
1601
|
*/
|
|
1502
1602
|
baseRedirectUrl: string;
|
|
1503
1603
|
};
|
|
@@ -1567,10 +1667,6 @@ declare type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "
|
|
|
1567
1667
|
*/
|
|
1568
1668
|
declare function remove(url: string): string;
|
|
1569
1669
|
|
|
1570
|
-
declare type RemoveBackupEvent = {
|
|
1571
|
-
iframeLifecycle: "remove-backup";
|
|
1572
|
-
};
|
|
1573
|
-
|
|
1574
1670
|
/**
|
|
1575
1671
|
* Replace the current url with the given Frak context
|
|
1576
1672
|
* @param args
|
|
@@ -1582,12 +1678,6 @@ declare function replaceUrl({ url: baseUrl, context, }: {
|
|
|
1582
1678
|
context: Partial<FrakContext> | null;
|
|
1583
1679
|
}): void;
|
|
1584
1680
|
|
|
1585
|
-
/**
|
|
1586
|
-
* Type used for a one shot request function
|
|
1587
|
-
* @inline
|
|
1588
|
-
*/
|
|
1589
|
-
declare type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
|
|
1590
|
-
|
|
1591
1681
|
declare type RestoreBackupEvent = {
|
|
1592
1682
|
clientLifecycle: "restore-backup";
|
|
1593
1683
|
data: {
|
|
@@ -1621,42 +1711,6 @@ export declare const RetailInteractionEncoder: {
|
|
|
1621
1711
|
}): PreparedInteraction;
|
|
1622
1712
|
};
|
|
1623
1713
|
|
|
1624
|
-
/**
|
|
1625
|
-
* The different Frak RPC error codes
|
|
1626
|
-
*/
|
|
1627
|
-
export declare const RpcErrorCodes: {
|
|
1628
|
-
readonly parseError: -32700;
|
|
1629
|
-
readonly invalidRequest: -32600;
|
|
1630
|
-
readonly methodNotFound: -32601;
|
|
1631
|
-
readonly invalidParams: -32602;
|
|
1632
|
-
readonly internalError: -32603;
|
|
1633
|
-
readonly serverError: -32000;
|
|
1634
|
-
readonly clientNotConnected: -32001;
|
|
1635
|
-
readonly configError: -32002;
|
|
1636
|
-
readonly corruptedResponse: -32003;
|
|
1637
|
-
readonly clientAborted: -32004;
|
|
1638
|
-
readonly walletNotConnected: -32005;
|
|
1639
|
-
readonly serverErrorForInteractionDelegation: -32006;
|
|
1640
|
-
};
|
|
1641
|
-
|
|
1642
|
-
/**
|
|
1643
|
-
* Raw response that we will receive after an rpc request
|
|
1644
|
-
* @ignore
|
|
1645
|
-
*/
|
|
1646
|
-
export declare type RpcResponse<TRpcSchema extends RpcSchema, TMethod extends TRpcSchema[number]["Method"] = TRpcSchema[number]["Method"]> = {
|
|
1647
|
-
result: Extract<TRpcSchema[number], {
|
|
1648
|
-
Method: TMethod;
|
|
1649
|
-
}>["ReturnType"];
|
|
1650
|
-
error?: never;
|
|
1651
|
-
} | {
|
|
1652
|
-
result?: never;
|
|
1653
|
-
error: {
|
|
1654
|
-
code: number;
|
|
1655
|
-
message: string;
|
|
1656
|
-
data?: unknown;
|
|
1657
|
-
};
|
|
1658
|
-
};
|
|
1659
|
-
|
|
1660
1714
|
/**
|
|
1661
1715
|
* Function used to send an interaction
|
|
1662
1716
|
* @param client - The current Frak Client
|
|
@@ -1892,6 +1946,17 @@ export declare type SsoMetadata = {
|
|
|
1892
1946
|
homepageLink?: string;
|
|
1893
1947
|
};
|
|
1894
1948
|
|
|
1949
|
+
export declare const ssoPopupFeatures = "menubar=no,status=no,scrollbars=no,fullscreen=no,width=500, height=800";
|
|
1950
|
+
|
|
1951
|
+
export declare const ssoPopupName = "frak-sso";
|
|
1952
|
+
|
|
1953
|
+
declare type SsoRedirectCompleteEvent = {
|
|
1954
|
+
clientLifecycle: "sso-redirect-complete";
|
|
1955
|
+
data: {
|
|
1956
|
+
compressed: string;
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1895
1960
|
/**
|
|
1896
1961
|
* The type for the amount of tokens
|
|
1897
1962
|
*/
|
|
@@ -1982,7 +2047,7 @@ export declare type WalletStatusReturnType = WalletConnected | WalletNotConnecte
|
|
|
1982
2047
|
* Function used to watch the current frak wallet status
|
|
1983
2048
|
* @param client - The current Frak Client
|
|
1984
2049
|
* @param callback - The callback that will receive any wallet status change
|
|
1985
|
-
* @returns A
|
|
2050
|
+
* @returns A promise resolving with the initial wallet status
|
|
1986
2051
|
*
|
|
1987
2052
|
* @description This function will return the current wallet status, and will listen to any change in the wallet status.
|
|
1988
2053
|
*
|