@frak-labs/core-sdk 0.0.19-beta.f259d7fc → 0.1.0-beta.afa252b0
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 +114 -33
- package/dist/actions.d.ts +114 -33
- package/dist/actions.js +1 -1
- package/dist/bundle.cjs +2 -2
- package/dist/bundle.d.cts +193 -33
- package/dist/bundle.d.ts +193 -33
- package/dist/bundle.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +140 -22
- package/dist/index.d.ts +140 -22
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/bundle.d.cts
CHANGED
|
@@ -7,6 +7,11 @@ import { RpcMessage } from '@frak-labs/frame-connector';
|
|
|
7
7
|
import { RpcResponse } from '@frak-labs/frame-connector';
|
|
8
8
|
import type { SiweMessage } from 'viem/siwe';
|
|
9
9
|
|
|
10
|
+
export declare type AppSpecificSsoMetadata = SsoMetadata & {
|
|
11
|
+
name: string;
|
|
12
|
+
css?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Decode a base64url encoded string
|
|
12
17
|
* @param value The value to decode
|
|
@@ -62,6 +67,23 @@ declare function compress(context?: Partial<FrakContext>): string | undefined;
|
|
|
62
67
|
*/
|
|
63
68
|
export declare type CompressedData = Uint8Array;
|
|
64
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Type of compressed the sso data
|
|
72
|
+
*/
|
|
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
|
+
};
|
|
86
|
+
|
|
65
87
|
/**
|
|
66
88
|
* Compress json data
|
|
67
89
|
* @param data
|
|
@@ -431,6 +453,27 @@ export declare type FinalModalStepType = GenericModalStepType<"final", {
|
|
|
431
453
|
autoSkip?: boolean;
|
|
432
454
|
}, object>;
|
|
433
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
|
+
|
|
434
477
|
export declare function formatAmount(amount: number, currency?: Currency): string;
|
|
435
478
|
|
|
436
479
|
/**
|
|
@@ -539,6 +582,38 @@ export declare type FullInteractionTypesKey = {
|
|
|
539
582
|
[Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
|
|
540
583
|
}[keyof typeof interactionTypes];
|
|
541
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
|
+
|
|
542
617
|
/**
|
|
543
618
|
* Represent a generic modal step type
|
|
544
619
|
* @ignore
|
|
@@ -777,11 +852,27 @@ export declare type IFrameRpcSchema = [
|
|
|
777
852
|
ReturnType: SendInteractionReturnType;
|
|
778
853
|
},
|
|
779
854
|
/**
|
|
780
|
-
* Method to
|
|
781
|
-
*
|
|
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)
|
|
782
858
|
*/
|
|
783
859
|
{
|
|
784
|
-
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";
|
|
785
876
|
Parameters: [
|
|
786
877
|
params: OpenSsoParamsType,
|
|
787
878
|
name: string,
|
|
@@ -1173,7 +1264,16 @@ export declare type OpenInteractionSessionReturnType = {
|
|
|
1173
1264
|
* @param client - The current Frak Client
|
|
1174
1265
|
* @param args - The SSO parameters
|
|
1175
1266
|
*
|
|
1176
|
-
* @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
|
|
1177
1277
|
*
|
|
1178
1278
|
* @example
|
|
1179
1279
|
* First we build the sso metadata
|
|
@@ -1187,28 +1287,28 @@ export declare type OpenInteractionSessionReturnType = {
|
|
|
1187
1287
|
*
|
|
1188
1288
|
* Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL
|
|
1189
1289
|
* :::code-group
|
|
1190
|
-
* ```ts [
|
|
1191
|
-
* //
|
|
1290
|
+
* ```ts [Popup (default)]
|
|
1291
|
+
* // Opens in popup, SDK generates URL automatically
|
|
1192
1292
|
* await openSso(frakConfig, {
|
|
1193
1293
|
* directExit: true,
|
|
1194
1294
|
* metadata,
|
|
1195
1295
|
* });
|
|
1196
1296
|
* ```
|
|
1197
|
-
* ```ts [
|
|
1198
|
-
* //
|
|
1297
|
+
* ```ts [Redirect]
|
|
1298
|
+
* // Opens in same window with redirect
|
|
1199
1299
|
* await openSso(frakConfig, {
|
|
1200
1300
|
* redirectUrl: "https://my-app.com/frak-sso",
|
|
1201
1301
|
* metadata,
|
|
1302
|
+
* openInSameWindow: true,
|
|
1202
1303
|
* });
|
|
1203
1304
|
* ```
|
|
1204
|
-
* ```ts [
|
|
1205
|
-
* //
|
|
1206
|
-
* const
|
|
1207
|
-
*
|
|
1208
|
-
* generateConsumeKey: true,
|
|
1305
|
+
* ```ts [Custom popup URL]
|
|
1306
|
+
* // Advanced: provide custom SSO URL
|
|
1307
|
+
* const { ssoUrl } = await prepareSso(frakConfig, { metadata });
|
|
1308
|
+
* await openSso(frakConfig, {
|
|
1209
1309
|
* metadata,
|
|
1310
|
+
* ssoPopupUrl: `${ssoUrl}&custom=param`,
|
|
1210
1311
|
* });
|
|
1211
|
-
* console.log(result.consumeKey); // Use this to track SSO status
|
|
1212
1312
|
* ```
|
|
1213
1313
|
* :::
|
|
1214
1314
|
*/
|
|
@@ -1218,30 +1318,16 @@ export declare function openSso(client: FrakClient, args: OpenSsoParamsType): Pr
|
|
|
1218
1318
|
* Params to start a SSO
|
|
1219
1319
|
* @group RPC Schema
|
|
1220
1320
|
*/
|
|
1221
|
-
export declare type OpenSsoParamsType = {
|
|
1321
|
+
export declare type OpenSsoParamsType = PrepareSsoParamsType & {
|
|
1222
1322
|
/**
|
|
1223
|
-
*
|
|
1224
|
-
|
|
1225
|
-
redirectUrl?: string;
|
|
1226
|
-
/**
|
|
1227
|
-
* If the SSO should directly exit after completion
|
|
1228
|
-
* @defaultValue true
|
|
1229
|
-
*/
|
|
1230
|
-
directExit?: boolean;
|
|
1231
|
-
/**
|
|
1232
|
-
* If true, opens SSO in same window instead of popup
|
|
1233
|
-
* Defaults to true when redirectUrl is provided, false otherwise
|
|
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
|
|
1234
1325
|
*/
|
|
1235
1326
|
openInSameWindow?: boolean;
|
|
1236
1327
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
* It will default to the current user language (or "en" if unsupported language)
|
|
1328
|
+
* Custom SSO popup url if user want additionnal customisation
|
|
1239
1329
|
*/
|
|
1240
|
-
|
|
1241
|
-
/**
|
|
1242
|
-
* Custom SSO metadata
|
|
1243
|
-
*/
|
|
1244
|
-
metadata: SsoMetadata;
|
|
1330
|
+
ssoPopupUrl?: string;
|
|
1245
1331
|
};
|
|
1246
1332
|
|
|
1247
1333
|
/**
|
|
@@ -1273,6 +1359,76 @@ export declare type PreparedInteraction = {
|
|
|
1273
1359
|
interactionData: Hex;
|
|
1274
1360
|
};
|
|
1275
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
|
+
|
|
1276
1432
|
/**
|
|
1277
1433
|
* Press interactions allow you to track user engagement with articles or other press content on your platform.
|
|
1278
1434
|
* After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
|
|
@@ -1790,6 +1946,10 @@ export declare type SsoMetadata = {
|
|
|
1790
1946
|
homepageLink?: string;
|
|
1791
1947
|
};
|
|
1792
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
|
+
|
|
1793
1953
|
declare type SsoRedirectCompleteEvent = {
|
|
1794
1954
|
clientLifecycle: "sso-redirect-complete";
|
|
1795
1955
|
data: {
|
package/dist/bundle.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ import { RpcMessage } from '@frak-labs/frame-connector';
|
|
|
7
7
|
import { RpcResponse } from '@frak-labs/frame-connector';
|
|
8
8
|
import type { SiweMessage } from 'viem/siwe';
|
|
9
9
|
|
|
10
|
+
export declare type AppSpecificSsoMetadata = SsoMetadata & {
|
|
11
|
+
name: string;
|
|
12
|
+
css?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Decode a base64url encoded string
|
|
12
17
|
* @param value The value to decode
|
|
@@ -62,6 +67,23 @@ declare function compress(context?: Partial<FrakContext>): string | undefined;
|
|
|
62
67
|
*/
|
|
63
68
|
export declare type CompressedData = Uint8Array;
|
|
64
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Type of compressed the sso data
|
|
72
|
+
*/
|
|
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
|
+
};
|
|
86
|
+
|
|
65
87
|
/**
|
|
66
88
|
* Compress json data
|
|
67
89
|
* @param data
|
|
@@ -431,6 +453,27 @@ export declare type FinalModalStepType = GenericModalStepType<"final", {
|
|
|
431
453
|
autoSkip?: boolean;
|
|
432
454
|
}, object>;
|
|
433
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
|
+
|
|
434
477
|
export declare function formatAmount(amount: number, currency?: Currency): string;
|
|
435
478
|
|
|
436
479
|
/**
|
|
@@ -539,6 +582,38 @@ export declare type FullInteractionTypesKey = {
|
|
|
539
582
|
[Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
|
|
540
583
|
}[keyof typeof interactionTypes];
|
|
541
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
|
+
|
|
542
617
|
/**
|
|
543
618
|
* Represent a generic modal step type
|
|
544
619
|
* @ignore
|
|
@@ -777,11 +852,27 @@ export declare type IFrameRpcSchema = [
|
|
|
777
852
|
ReturnType: SendInteractionReturnType;
|
|
778
853
|
},
|
|
779
854
|
/**
|
|
780
|
-
* Method to
|
|
781
|
-
*
|
|
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)
|
|
782
858
|
*/
|
|
783
859
|
{
|
|
784
|
-
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";
|
|
785
876
|
Parameters: [
|
|
786
877
|
params: OpenSsoParamsType,
|
|
787
878
|
name: string,
|
|
@@ -1173,7 +1264,16 @@ export declare type OpenInteractionSessionReturnType = {
|
|
|
1173
1264
|
* @param client - The current Frak Client
|
|
1174
1265
|
* @param args - The SSO parameters
|
|
1175
1266
|
*
|
|
1176
|
-
* @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
|
|
1177
1277
|
*
|
|
1178
1278
|
* @example
|
|
1179
1279
|
* First we build the sso metadata
|
|
@@ -1187,28 +1287,28 @@ export declare type OpenInteractionSessionReturnType = {
|
|
|
1187
1287
|
*
|
|
1188
1288
|
* Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL
|
|
1189
1289
|
* :::code-group
|
|
1190
|
-
* ```ts [
|
|
1191
|
-
* //
|
|
1290
|
+
* ```ts [Popup (default)]
|
|
1291
|
+
* // Opens in popup, SDK generates URL automatically
|
|
1192
1292
|
* await openSso(frakConfig, {
|
|
1193
1293
|
* directExit: true,
|
|
1194
1294
|
* metadata,
|
|
1195
1295
|
* });
|
|
1196
1296
|
* ```
|
|
1197
|
-
* ```ts [
|
|
1198
|
-
* //
|
|
1297
|
+
* ```ts [Redirect]
|
|
1298
|
+
* // Opens in same window with redirect
|
|
1199
1299
|
* await openSso(frakConfig, {
|
|
1200
1300
|
* redirectUrl: "https://my-app.com/frak-sso",
|
|
1201
1301
|
* metadata,
|
|
1302
|
+
* openInSameWindow: true,
|
|
1202
1303
|
* });
|
|
1203
1304
|
* ```
|
|
1204
|
-
* ```ts [
|
|
1205
|
-
* //
|
|
1206
|
-
* const
|
|
1207
|
-
*
|
|
1208
|
-
* generateConsumeKey: true,
|
|
1305
|
+
* ```ts [Custom popup URL]
|
|
1306
|
+
* // Advanced: provide custom SSO URL
|
|
1307
|
+
* const { ssoUrl } = await prepareSso(frakConfig, { metadata });
|
|
1308
|
+
* await openSso(frakConfig, {
|
|
1209
1309
|
* metadata,
|
|
1310
|
+
* ssoPopupUrl: `${ssoUrl}&custom=param`,
|
|
1210
1311
|
* });
|
|
1211
|
-
* console.log(result.consumeKey); // Use this to track SSO status
|
|
1212
1312
|
* ```
|
|
1213
1313
|
* :::
|
|
1214
1314
|
*/
|
|
@@ -1218,30 +1318,16 @@ export declare function openSso(client: FrakClient, args: OpenSsoParamsType): Pr
|
|
|
1218
1318
|
* Params to start a SSO
|
|
1219
1319
|
* @group RPC Schema
|
|
1220
1320
|
*/
|
|
1221
|
-
export declare type OpenSsoParamsType = {
|
|
1321
|
+
export declare type OpenSsoParamsType = PrepareSsoParamsType & {
|
|
1222
1322
|
/**
|
|
1223
|
-
*
|
|
1224
|
-
|
|
1225
|
-
redirectUrl?: string;
|
|
1226
|
-
/**
|
|
1227
|
-
* If the SSO should directly exit after completion
|
|
1228
|
-
* @defaultValue true
|
|
1229
|
-
*/
|
|
1230
|
-
directExit?: boolean;
|
|
1231
|
-
/**
|
|
1232
|
-
* If true, opens SSO in same window instead of popup
|
|
1233
|
-
* Defaults to true when redirectUrl is provided, false otherwise
|
|
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
|
|
1234
1325
|
*/
|
|
1235
1326
|
openInSameWindow?: boolean;
|
|
1236
1327
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
* It will default to the current user language (or "en" if unsupported language)
|
|
1328
|
+
* Custom SSO popup url if user want additionnal customisation
|
|
1239
1329
|
*/
|
|
1240
|
-
|
|
1241
|
-
/**
|
|
1242
|
-
* Custom SSO metadata
|
|
1243
|
-
*/
|
|
1244
|
-
metadata: SsoMetadata;
|
|
1330
|
+
ssoPopupUrl?: string;
|
|
1245
1331
|
};
|
|
1246
1332
|
|
|
1247
1333
|
/**
|
|
@@ -1273,6 +1359,76 @@ export declare type PreparedInteraction = {
|
|
|
1273
1359
|
interactionData: Hex;
|
|
1274
1360
|
};
|
|
1275
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
|
+
|
|
1276
1432
|
/**
|
|
1277
1433
|
* Press interactions allow you to track user engagement with articles or other press content on your platform.
|
|
1278
1434
|
* After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
|
|
@@ -1790,6 +1946,10 @@ export declare type SsoMetadata = {
|
|
|
1790
1946
|
homepageLink?: string;
|
|
1791
1947
|
};
|
|
1792
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
|
+
|
|
1793
1953
|
declare type SsoRedirectCompleteEvent = {
|
|
1794
1954
|
clientLifecycle: "sso-redirect-complete";
|
|
1795
1955
|
data: {
|