@frak-labs/core-sdk 0.1.0 → 0.1.1-beta.4dfea079

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 (130) hide show
  1. package/README.md +58 -0
  2. package/cdn/bundle.js +3 -8
  3. package/dist/actions.cjs +1 -1
  4. package/dist/actions.d.cts +3 -1400
  5. package/dist/actions.d.ts +3 -1400
  6. package/dist/actions.js +1 -1
  7. package/dist/bundle.cjs +1 -13
  8. package/dist/bundle.d.cts +4 -1927
  9. package/dist/bundle.d.ts +4 -1927
  10. package/dist/bundle.js +1 -13
  11. package/dist/computeLegacyProductId-CscYhyUi.d.cts +525 -0
  12. package/dist/computeLegacyProductId-WbD1gXV9.d.ts +525 -0
  13. package/dist/index.cjs +1 -13
  14. package/dist/index.d.cts +3 -1269
  15. package/dist/index.d.ts +3 -1269
  16. package/dist/index.js +1 -13
  17. package/dist/openSso-CC1-loUk.d.cts +1019 -0
  18. package/dist/openSso-tkqaDQLV.d.ts +1019 -0
  19. package/dist/setupClient-BjIbK6XJ.cjs +13 -0
  20. package/dist/setupClient-D_HId3e2.js +13 -0
  21. package/dist/siweAuthenticate-B_Z2OZmj.cjs +1 -0
  22. package/dist/siweAuthenticate-CQ4OfPuA.js +1 -0
  23. package/dist/siweAuthenticate-CR4Dpji6.d.cts +467 -0
  24. package/dist/siweAuthenticate-udoruuy9.d.ts +467 -0
  25. package/dist/trackEvent-CGIryq5h.cjs +1 -0
  26. package/dist/trackEvent-YfUh4jrx.js +1 -0
  27. package/package.json +24 -30
  28. package/src/actions/displayEmbeddedWallet.test.ts +194 -0
  29. package/src/actions/displayEmbeddedWallet.ts +20 -0
  30. package/src/actions/displayModal.test.ts +388 -0
  31. package/src/actions/displayModal.ts +120 -0
  32. package/src/actions/getMerchantInformation.test.ts +116 -0
  33. package/src/actions/getMerchantInformation.ts +9 -0
  34. package/src/actions/index.ts +29 -0
  35. package/src/actions/openSso.ts +116 -0
  36. package/src/actions/prepareSso.test.ts +223 -0
  37. package/src/actions/prepareSso.ts +48 -0
  38. package/src/actions/referral/processReferral.test.ts +248 -0
  39. package/src/actions/referral/processReferral.ts +232 -0
  40. package/src/actions/referral/referralInteraction.test.ts +147 -0
  41. package/src/actions/referral/referralInteraction.ts +52 -0
  42. package/src/actions/sendInteraction.ts +24 -0
  43. package/src/actions/trackPurchaseStatus.test.ts +287 -0
  44. package/src/actions/trackPurchaseStatus.ts +56 -0
  45. package/src/actions/watchWalletStatus.test.ts +372 -0
  46. package/src/actions/watchWalletStatus.ts +93 -0
  47. package/src/actions/wrapper/modalBuilder.test.ts +239 -0
  48. package/src/actions/wrapper/modalBuilder.ts +203 -0
  49. package/src/actions/wrapper/sendTransaction.test.ts +164 -0
  50. package/src/actions/wrapper/sendTransaction.ts +62 -0
  51. package/src/actions/wrapper/siweAuthenticate.test.ts +290 -0
  52. package/src/actions/wrapper/siweAuthenticate.ts +94 -0
  53. package/src/bundle.ts +2 -0
  54. package/src/clients/DebugInfo.test.ts +418 -0
  55. package/src/clients/DebugInfo.ts +182 -0
  56. package/src/clients/createIFrameFrakClient.ts +289 -0
  57. package/src/clients/index.ts +3 -0
  58. package/src/clients/setupClient.test.ts +343 -0
  59. package/src/clients/setupClient.ts +73 -0
  60. package/src/clients/transports/iframeLifecycleManager.test.ts +558 -0
  61. package/src/clients/transports/iframeLifecycleManager.ts +174 -0
  62. package/src/constants/interactionTypes.ts +15 -0
  63. package/src/constants/locales.ts +14 -0
  64. package/src/index.ts +110 -0
  65. package/src/types/client.ts +14 -0
  66. package/src/types/compression.ts +22 -0
  67. package/src/types/config.ts +117 -0
  68. package/src/types/context.ts +13 -0
  69. package/src/types/index.ts +75 -0
  70. package/src/types/lifecycle/client.ts +69 -0
  71. package/src/types/lifecycle/iframe.ts +41 -0
  72. package/src/types/lifecycle/index.ts +2 -0
  73. package/src/types/rpc/displayModal.ts +82 -0
  74. package/src/types/rpc/embedded/index.ts +68 -0
  75. package/src/types/rpc/embedded/loggedIn.ts +55 -0
  76. package/src/types/rpc/embedded/loggedOut.ts +28 -0
  77. package/src/types/rpc/interaction.ts +30 -0
  78. package/src/types/rpc/merchantInformation.ts +77 -0
  79. package/src/types/rpc/modal/final.ts +46 -0
  80. package/src/types/rpc/modal/generic.ts +46 -0
  81. package/src/types/rpc/modal/index.ts +16 -0
  82. package/src/types/rpc/modal/login.ts +36 -0
  83. package/src/types/rpc/modal/siweAuthenticate.ts +37 -0
  84. package/src/types/rpc/modal/transaction.ts +33 -0
  85. package/src/types/rpc/sso.ts +80 -0
  86. package/src/types/rpc/walletStatus.ts +29 -0
  87. package/src/types/rpc.ts +146 -0
  88. package/src/types/tracking.ts +60 -0
  89. package/src/types/transport.ts +34 -0
  90. package/src/utils/FrakContext.test.ts +407 -0
  91. package/src/utils/FrakContext.ts +158 -0
  92. package/src/utils/backendUrl.test.ts +83 -0
  93. package/src/utils/backendUrl.ts +62 -0
  94. package/src/utils/clientId.test.ts +41 -0
  95. package/src/utils/clientId.ts +40 -0
  96. package/src/utils/compression/b64.test.ts +181 -0
  97. package/src/utils/compression/b64.ts +29 -0
  98. package/src/utils/compression/compress.test.ts +123 -0
  99. package/src/utils/compression/compress.ts +11 -0
  100. package/src/utils/compression/decompress.test.ts +149 -0
  101. package/src/utils/compression/decompress.ts +11 -0
  102. package/src/utils/compression/index.ts +3 -0
  103. package/src/utils/computeLegacyProductId.ts +11 -0
  104. package/src/utils/constants.test.ts +23 -0
  105. package/src/utils/constants.ts +14 -0
  106. package/src/utils/deepLinkWithFallback.test.ts +243 -0
  107. package/src/utils/deepLinkWithFallback.ts +97 -0
  108. package/src/utils/formatAmount.test.ts +113 -0
  109. package/src/utils/formatAmount.ts +18 -0
  110. package/src/utils/getCurrencyAmountKey.test.ts +44 -0
  111. package/src/utils/getCurrencyAmountKey.ts +15 -0
  112. package/src/utils/getSupportedCurrency.test.ts +51 -0
  113. package/src/utils/getSupportedCurrency.ts +14 -0
  114. package/src/utils/getSupportedLocale.test.ts +64 -0
  115. package/src/utils/getSupportedLocale.ts +16 -0
  116. package/src/utils/iframeHelper.test.ts +450 -0
  117. package/src/utils/iframeHelper.ts +147 -0
  118. package/src/utils/index.ts +36 -0
  119. package/src/utils/merchantId.test.ts +564 -0
  120. package/src/utils/merchantId.ts +122 -0
  121. package/src/utils/sso.ts +126 -0
  122. package/src/utils/ssoUrlListener.test.ts +252 -0
  123. package/src/utils/ssoUrlListener.ts +60 -0
  124. package/src/utils/trackEvent.test.ts +180 -0
  125. package/src/utils/trackEvent.ts +31 -0
  126. package/cdn/bundle.js.LICENSE.txt +0 -10
  127. package/dist/interactions.cjs +0 -1
  128. package/dist/interactions.d.cts +0 -182
  129. package/dist/interactions.d.ts +0 -182
  130. package/dist/interactions.js +0 -1
@@ -0,0 +1,82 @@
1
+ import type { InteractionTypeKey } from "../../constants/interactionTypes";
2
+ import type { I18nConfig } from "../config";
3
+ import type {
4
+ FinalModalStepType,
5
+ LoginModalStepType,
6
+ SendTransactionModalStepType,
7
+ SiweAuthenticateModalStepType,
8
+ } from "./modal";
9
+
10
+ /**
11
+ * Generic type of steps we will display in the modal to the end user
12
+ * @group Modal Display
13
+ */
14
+ export type ModalStepTypes =
15
+ | LoginModalStepType
16
+ | SiweAuthenticateModalStepType
17
+ | SendTransactionModalStepType
18
+ | FinalModalStepType;
19
+
20
+ /**
21
+ * Type for the result of a modal request
22
+ * Just the `returns` type of each `ModalStepTypes`
23
+ * @typeParam T - The list of modal steps we expect to have in the modal
24
+ * @group Modal Display
25
+ * @group RPC Schema
26
+ */
27
+ export type ModalRpcStepsResultType<
28
+ T extends ModalStepTypes[] = ModalStepTypes[],
29
+ > = {
30
+ [K in T[number]["key"]]: Extract<T[number], { key: K }>["returns"];
31
+ };
32
+
33
+ /**
34
+ * Type for the RPC input of a modal
35
+ * Just the `params` type of each `ModalStepTypes`
36
+ * @typeParam T - The list of modal steps we expect to have in the modal
37
+ * @group Modal Display
38
+ * @group RPC Schema
39
+ */
40
+ export type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> =
41
+ {
42
+ [K in T[number]["key"]]?: Extract<T[number], { key: K }>["params"];
43
+ };
44
+
45
+ /**
46
+ * RPC metadata for the modal, used on top level modal configuration
47
+ * @group Modal Display
48
+ * @group RPC Schema
49
+ */
50
+ export type ModalRpcMetadata = {
51
+ header?: {
52
+ title?: string;
53
+ icon?: string;
54
+ };
55
+ targetInteraction?: InteractionTypeKey;
56
+ /**
57
+ * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
58
+ */
59
+ i18n?: I18nConfig;
60
+ } & (
61
+ | {
62
+ isDismissible: true;
63
+ /**
64
+ * @deprecated Use `config.customizations.i18n` or `metadata.i18n` instead
65
+ */
66
+ dismissActionTxt?: string;
67
+ }
68
+ | {
69
+ isDismissible?: false;
70
+ dismissActionTxt?: never;
71
+ }
72
+ );
73
+
74
+ /**
75
+ * Params used to display a modal
76
+ * @typeParam T - The list of modal steps we expect to have in the modal
77
+ * @group Modal Display
78
+ */
79
+ export type DisplayModalParamsType<T extends ModalStepTypes[]> = {
80
+ steps: ModalRpcStepsInput<T>;
81
+ metadata?: ModalRpcMetadata;
82
+ };
@@ -0,0 +1,68 @@
1
+ import type { Address } from "viem";
2
+ import type { InteractionTypeKey } from "../../../constants/interactionTypes";
3
+ import type { I18nConfig } from "../../config";
4
+ import type {
5
+ EmbeddedViewActionReferred,
6
+ EmbeddedViewActionSharing,
7
+ LoggedInEmbeddedView,
8
+ } from "./loggedIn";
9
+ import type { LoggedOutEmbeddedView } from "./loggedOut";
10
+
11
+ export type {
12
+ EmbeddedViewActionSharing,
13
+ LoggedInEmbeddedView,
14
+ LoggedOutEmbeddedView,
15
+ EmbeddedViewActionReferred,
16
+ };
17
+
18
+ /**
19
+ * The params used to display the embedded wallet
20
+ *
21
+ * @group Embedded wallet
22
+ */
23
+ export type DisplayEmbeddedWalletParamsType = {
24
+ /**
25
+ * The embedded view to display once the user is logged in
26
+ */
27
+ loggedIn?: LoggedInEmbeddedView;
28
+ /**
29
+ * The embedded view to display once the user is logged out
30
+ */
31
+ loggedOut?: LoggedOutEmbeddedView;
32
+ /**
33
+ * Some metadata to customize the embedded view
34
+ */
35
+ metadata?: {
36
+ /**
37
+ * The logo to display on the embedded wallet
38
+ * If undefined, will default to no logo displayed
39
+ */
40
+ logo?: string;
41
+ /**
42
+ * Link to the homepage of the calling website
43
+ * If undefined, will default to the domain of the calling website
44
+ */
45
+ homepageLink?: string;
46
+ /**
47
+ * The target interaction behind this modal
48
+ */
49
+ targetInteraction?: InteractionTypeKey;
50
+ /**
51
+ * The position of the component
52
+ */
53
+ position?: "left" | "right";
54
+ /**
55
+ * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
56
+ */
57
+ i18n?: I18nConfig;
58
+ };
59
+ };
60
+
61
+ /**
62
+ * The result of the display embedded wallet rpc request
63
+ *
64
+ * @group Embedded wallet
65
+ */
66
+ export type DisplayEmbeddedWalletResultType = {
67
+ wallet: Address;
68
+ };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The different type of action we can have on the embedded view (once the user is logged in)
3
+ *
4
+ * @group Embedded wallet
5
+ */
6
+ export type EmbeddedViewActionSharing = {
7
+ key: "sharing";
8
+
9
+ /**
10
+ * Some sharing options
11
+ */
12
+ options?: {
13
+ /**
14
+ * The title that will be displayed on the system popup once the system sharing window is open
15
+ * @deprecated Use the top level `config.metadata.i18n` instead
16
+ */
17
+ popupTitle?: string;
18
+ /**
19
+ * The text that will be shared alongside the link.
20
+ * Can contain the variable `{LINK}` to specify where the link is placed, otherwise it will be added at the end
21
+ * @deprecated Use the top level `config.metadata.i18n` instead
22
+ */
23
+ text?: string;
24
+ /**
25
+ * The link to be shared (will be suffixed with the Frak sharing context)
26
+ */
27
+ link?: string;
28
+ };
29
+ };
30
+
31
+ /**
32
+ * The action to display on the logged out embedded view when the user is referred
33
+ *
34
+ * @group Embedded wallet
35
+ */
36
+ export type EmbeddedViewActionReferred = {
37
+ key: "referred";
38
+
39
+ /**
40
+ * No options for a referred action
41
+ */
42
+ options?: never;
43
+ };
44
+
45
+ /**
46
+ * Some configuration options for the embedded view
47
+ *
48
+ * @group Embedded wallet
49
+ */
50
+ export type LoggedInEmbeddedView = {
51
+ /**
52
+ * The main action to display on the logged in embedded view
53
+ */
54
+ action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
55
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The view when a user is logged out
3
+ * @group Embedded wallet
4
+ */
5
+ export type LoggedOutEmbeddedView = {
6
+ /**
7
+ * Metadata option when displaying the embedded view
8
+ */
9
+ metadata?: {
10
+ /**
11
+ * The main CTA for the logged out view
12
+ * - can include some variable, available ones are:
13
+ * - `{REWARD}` -> The maximum reward a user can receive when interacting on your website
14
+ * - can be formatted in markdown
15
+ *
16
+ * If not set, it will default to a internationalized message
17
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
18
+ */
19
+ text?: string;
20
+ /**
21
+ * The text that will be displayed on the login button
22
+ *
23
+ * If not set, it will default to a internationalized message
24
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
25
+ */
26
+ buttonText?: string;
27
+ };
28
+ };
@@ -0,0 +1,30 @@
1
+ import type { Address } from "viem";
2
+
3
+ /**
4
+ * Parameters for sending interactions via RPC
5
+ *
6
+ * Note: merchantId and clientId come from WalletRpcContext
7
+ * and are NOT included in the params - they are resolved by the listener
8
+ *
9
+ * @group RPC Schema
10
+ */
11
+ export type SendInteractionParamsType =
12
+ | {
13
+ type: "arrival";
14
+ referrerWallet?: Address;
15
+ landingUrl?: string;
16
+ utmSource?: string;
17
+ utmMedium?: string;
18
+ utmCampaign?: string;
19
+ utmTerm?: string;
20
+ utmContent?: string;
21
+ }
22
+ | {
23
+ type: "sharing";
24
+ }
25
+ | {
26
+ type: "custom";
27
+ customType: string;
28
+ data?: Record<string, unknown>;
29
+ idempotencyKey?: string;
30
+ };
@@ -0,0 +1,77 @@
1
+ import type { Address } from "viem";
2
+ import type { InteractionTypeKey } from "../../constants/interactionTypes";
3
+
4
+ /**
5
+ * The type for the amount of tokens
6
+ */
7
+ export type TokenAmountType = {
8
+ amount: number;
9
+ eurAmount: number;
10
+ usdAmount: number;
11
+ gbpAmount: number;
12
+ };
13
+
14
+ /**
15
+ * A tier definition for tiered rewards
16
+ */
17
+ export type RewardTier = {
18
+ minValue: number;
19
+ maxValue?: number;
20
+ amount: TokenAmountType;
21
+ };
22
+
23
+ /**
24
+ * Estimated reward amount — discriminated union by payout type
25
+ *
26
+ * - `fixed`: A known token amount (with fiat equivalents)
27
+ * - `percentage`: A percent of a purchase field (e.g. 5% of purchase_amount), with optional min/max caps
28
+ * - `tiered`: Amount depends on a field value matching tier brackets
29
+ */
30
+ export type EstimatedReward =
31
+ | {
32
+ payoutType: "fixed";
33
+ amount: TokenAmountType;
34
+ }
35
+ | {
36
+ payoutType: "percentage";
37
+ percent: number;
38
+ percentOf: string;
39
+ maxAmount?: TokenAmountType;
40
+ minAmount?: TokenAmountType;
41
+ }
42
+ | {
43
+ payoutType: "tiered";
44
+ tierField: string;
45
+ tiers: RewardTier[];
46
+ };
47
+
48
+ /**
49
+ * Response of the `frak_getMerchantInformation` RPC method
50
+ * @group RPC Schema
51
+ */
52
+ export type GetMerchantInformationReturnType = {
53
+ /**
54
+ * Current merchant id
55
+ */
56
+ id: string;
57
+ /**
58
+ * Some metadata
59
+ */
60
+ onChainMetadata: {
61
+ /**
62
+ * Name of the merchant on-chain
63
+ */
64
+ name: string;
65
+ /**
66
+ * Domain of the merchant on-chain
67
+ */
68
+ domain: string;
69
+ };
70
+ rewards: {
71
+ token?: Address;
72
+ campaignId: string;
73
+ interactionTypeKey: InteractionTypeKey;
74
+ referrer?: EstimatedReward;
75
+ referee?: EstimatedReward;
76
+ }[];
77
+ };
@@ -0,0 +1,46 @@
1
+ import type { GenericModalStepType, ModalStepMetadata } from "./generic";
2
+
3
+ /**
4
+ * The final modal step type, could be used to display sharing options or a success reward screen.
5
+ *
6
+ * **Input**: What type final step to display?
7
+ * **Output**: None
8
+ *
9
+ * @group Modal Display
10
+ */
11
+ export type FinalModalStepType = GenericModalStepType<
12
+ "final",
13
+ {
14
+ // Custom metadata in the case it was dismissed
15
+ dismissedMetadata?: ModalStepMetadata["metadata"];
16
+ // Action to perform on this final step
17
+ action: FinalActionType;
18
+ // Do we want to auto skip this step (don't display anything to the user, once we reached it we exit)
19
+ autoSkip?: boolean;
20
+ },
21
+ object
22
+ >;
23
+
24
+ /**
25
+ * The different types of final actions we can display in the final step
26
+ * @group Modal Display
27
+ */
28
+ export type FinalActionType =
29
+ | {
30
+ key: "sharing";
31
+ options?: {
32
+ /**
33
+ * @deprecated Use the top level `config.metadata.i18n` instead
34
+ */
35
+ popupTitle?: string;
36
+ /**
37
+ * @deprecated Use the top level `config.metadata.i18n` instead
38
+ */
39
+ text?: string;
40
+ link?: string;
41
+ };
42
+ }
43
+ | {
44
+ key: "reward";
45
+ options?: never;
46
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Represent a generic modal step type
3
+ * @ignore
4
+ * @inline
5
+ */
6
+ export type GenericModalStepType<TKey, TParams, TReturns> = {
7
+ key: TKey;
8
+ params: TParams extends never
9
+ ? ModalStepMetadata
10
+ : ModalStepMetadata & TParams;
11
+ returns: TReturns;
12
+ };
13
+
14
+ /**
15
+ * Metadata that can be used to customize a modal step
16
+ * @group Modal Display
17
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
18
+ */
19
+ export type ModalStepMetadata = {
20
+ metadata?: {
21
+ /**
22
+ * Custom title for the step
23
+ * If none provided, it will use an internationalized text
24
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
25
+ */
26
+ title?: string;
27
+ /**
28
+ * Custom description for the step
29
+ * If none provided, it will use an internationalized text
30
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
31
+ */
32
+ description?: string;
33
+ /**
34
+ * Custom text for the primary action of the step
35
+ * If none provided, it will use an internationalized text
36
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
37
+ */
38
+ primaryActionText?: string;
39
+ /**
40
+ * Custom text for the secondary action of the step
41
+ * If none provided, it will use an internationalized text
42
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
43
+ */
44
+ secondaryActionText?: string;
45
+ };
46
+ };
@@ -0,0 +1,16 @@
1
+ export type {
2
+ FinalActionType,
3
+ FinalModalStepType,
4
+ } from "./final";
5
+ export type { ModalStepMetadata } from "./generic";
6
+ export type { LoginModalStepType } from "./login";
7
+ export type {
8
+ SiweAuthenticateModalStepType,
9
+ SiweAuthenticateReturnType,
10
+ SiweAuthenticationParams,
11
+ } from "./siweAuthenticate";
12
+ export type {
13
+ SendTransactionModalStepType,
14
+ SendTransactionReturnType,
15
+ SendTransactionTxType,
16
+ } from "./transaction";
@@ -0,0 +1,36 @@
1
+ import type { Address, Hex } from "viem";
2
+ import type { SsoMetadata } from "../sso";
3
+ import type { GenericModalStepType } from "./generic";
4
+
5
+ /** @inline */
6
+ type LoginWithSso = {
7
+ allowSso: true;
8
+ // Optional metadata for the SSO (if not provided, will be recomputed from the top level wallet sdk)
9
+ ssoMetadata?: SsoMetadata;
10
+ };
11
+
12
+ /** @inline */
13
+ type LoginWithoutSso = {
14
+ allowSso?: false;
15
+ ssoMetadata?: never;
16
+ };
17
+
18
+ /**
19
+ * The login step for a Modal
20
+ *
21
+ * **Input**: Do we allow SSO or not? Is yes then the SSO metadata
22
+ * **Output**: The logged in wallet address
23
+ *
24
+ * @group Modal Display
25
+ */
26
+ export type LoginModalStepType = GenericModalStepType<
27
+ "login",
28
+ LoginWithSso | LoginWithoutSso,
29
+ {
30
+ wallet: Address;
31
+ webauthnProof?: {
32
+ challenge: Hex;
33
+ authenticatorResponse: string;
34
+ };
35
+ }
36
+ >;
@@ -0,0 +1,37 @@
1
+ import type { Hex } from "viem";
2
+ import type { SiweMessage } from "viem/siwe";
3
+ import type { GenericModalStepType } from "./generic";
4
+
5
+ /**
6
+ * Parameters used send a SIWE rpc request
7
+ */
8
+ export type SiweAuthenticationParams = Omit<
9
+ SiweMessage,
10
+ "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"
11
+ > & {
12
+ expirationTimeTimestamp?: number;
13
+ notBeforeTimestamp?: number;
14
+ };
15
+
16
+ /**
17
+ * Return type of the Siwe transaction rpc request
18
+ * @inline
19
+ */
20
+ export type SiweAuthenticateReturnType = {
21
+ signature: Hex;
22
+ message: string;
23
+ };
24
+
25
+ /**
26
+ * The SIWE authentication step for a Modal
27
+ *
28
+ * **Input**: SIWE message parameters
29
+ * **Output**: SIWE result (message signed and wallet signature)
30
+ *
31
+ * @group Modal Display
32
+ */
33
+ export type SiweAuthenticateModalStepType = GenericModalStepType<
34
+ "siweAuthenticate",
35
+ { siwe: SiweAuthenticationParams },
36
+ SiweAuthenticateReturnType
37
+ >;
@@ -0,0 +1,33 @@
1
+ import type { Address, Hex } from "viem";
2
+ import type { GenericModalStepType } from "./generic";
3
+
4
+ /**
5
+ * Generic format representing a tx to be sent
6
+ */
7
+ export type SendTransactionTxType = {
8
+ to: Address;
9
+ data?: Hex;
10
+ value?: Hex;
11
+ };
12
+
13
+ /**
14
+ * Return type of the send transaction rpc request
15
+ * @inline
16
+ */
17
+ export type SendTransactionReturnType = {
18
+ hash: Hex;
19
+ };
20
+
21
+ /**
22
+ * The send transaction step for a Modal
23
+ *
24
+ * **Input**: Either a single tx or an array of tx to be sent
25
+ * **Output**: The hash of the tx(s) hash (in case of multiple tx, still returns a single hash because it's bundled on the wallet level)
26
+ *
27
+ * @group Modal Display
28
+ */
29
+ export type SendTransactionModalStepType = GenericModalStepType<
30
+ "sendTransaction",
31
+ { tx: SendTransactionTxType | SendTransactionTxType[] },
32
+ SendTransactionReturnType
33
+ >;
@@ -0,0 +1,80 @@
1
+ import type { Hex } from "viem";
2
+
3
+ /**
4
+ * SSO Metadata
5
+ */
6
+ export type SsoMetadata = {
7
+ /**
8
+ * URL to your client, if provided will be displayed in the SSO header
9
+ */
10
+ logoUrl?: string;
11
+ /**
12
+ * Link to your homepage, if referenced your app name will contain a link on the sso page
13
+ */
14
+ homepageLink?: string;
15
+ };
16
+
17
+ /**
18
+ * Params for preparing SSO (generating URL)
19
+ * Same as OpenSsoParamsType but without openInSameWindow (popup-only operation)
20
+ * @group RPC Schema
21
+ */
22
+ export type PrepareSsoParamsType = {
23
+ /**
24
+ * Redirect URL after the SSO (optional)
25
+ */
26
+ redirectUrl?: string;
27
+ /**
28
+ * If the SSO should directly exit after completion
29
+ * @defaultValue true
30
+ */
31
+ directExit?: boolean;
32
+ /**
33
+ * Language of the SSO page (optional)
34
+ * It will default to the current user language (or "en" if unsupported language)
35
+ */
36
+ lang?: "en" | "fr";
37
+ /**
38
+ * Custom SSO metadata
39
+ */
40
+ metadata?: SsoMetadata;
41
+ };
42
+
43
+ /**
44
+ * Response after preparing SSO
45
+ * @group RPC Schema
46
+ */
47
+ export type PrepareSsoReturnType = {
48
+ /**
49
+ * The SSO URL that should be opened in a popup
50
+ */
51
+ ssoUrl: string;
52
+ };
53
+
54
+ /**
55
+ * Response after an SSO has been openned
56
+ */
57
+ export type OpenSsoReturnType = {
58
+ /**
59
+ * Optional wallet address, returned when SSO completes via postMessage
60
+ * Note: Only present when SSO flow completes (not immediately on open)
61
+ */
62
+ wallet?: Hex;
63
+ };
64
+
65
+ /**
66
+ * Params to start a SSO
67
+ * @group RPC Schema
68
+ */
69
+ export type OpenSsoParamsType = PrepareSsoParamsType & {
70
+ /**
71
+ * 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
72
+ * Note: Default true if redirectUrl is present, otherwise, false
73
+ */
74
+ openInSameWindow?: boolean;
75
+
76
+ /**
77
+ * Custom SSO popup url if user want additionnal customisation
78
+ */
79
+ ssoPopupUrl?: string;
80
+ };
@@ -0,0 +1,29 @@
1
+ import type { Address } from "viem";
2
+
3
+ /**
4
+ * RPC Response for the method `frak_listenToWalletStatus`
5
+ * @group RPC Schema
6
+ */
7
+ export type WalletStatusReturnType = WalletConnected | WalletNotConnected;
8
+
9
+ /**
10
+ * @ignore
11
+ * @inline
12
+ */
13
+ export type WalletConnected = {
14
+ key: "connected";
15
+ // The user wallet address
16
+ wallet: Address;
17
+ // The interaction token, used to push interactions to the backend
18
+ interactionToken?: string;
19
+ };
20
+
21
+ /**
22
+ * @ignore
23
+ * @inline
24
+ */
25
+ export type WalletNotConnected = {
26
+ key: "not-connected";
27
+ wallet?: never;
28
+ interactionToken?: never;
29
+ };