@dynamic-labs/sdk-react-core 2.0.0-alpha.31 → 2.0.0-alpha.32

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 (126) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +14 -14
  5. package/src/index.d.ts +1 -1
  6. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +21 -6
  7. package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +16 -1
  8. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +17 -3
  9. package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +15 -1
  10. package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.cjs +19 -4
  11. package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.js +16 -1
  12. package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -17
  13. package/src/lib/context/DynamicContext/DynamicContext.js +3 -3
  14. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +6 -6
  15. package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +5 -5
  16. package/src/lib/context/FundingContext/FundingContext.cjs +6 -6
  17. package/src/lib/context/FundingContext/FundingContext.js +5 -5
  18. package/src/lib/context/PasskeyContext/PasskeyContext.cjs +4 -4
  19. package/src/lib/context/PasskeyContext/PasskeyContext.js +3 -3
  20. package/src/lib/data/api/api.cjs +24 -0
  21. package/src/lib/data/api/api.d.ts +2 -0
  22. package/src/lib/data/api/api.js +20 -0
  23. package/src/lib/data/api/email/email.cjs +118 -0
  24. package/src/lib/data/api/email/email.d.ts +26 -0
  25. package/src/lib/data/api/email/email.js +110 -0
  26. package/src/lib/data/api/email/index.d.ts +1 -0
  27. package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +191 -0
  28. package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +30 -0
  29. package/src/lib/data/api/embeddedWallets/embeddedWallets.js +177 -0
  30. package/src/lib/data/api/embeddedWallets/index.d.ts +2 -0
  31. package/src/lib/data/api/embeddedWallets/types.d.ts +39 -0
  32. package/src/lib/data/api/index.d.ts +10 -0
  33. package/src/lib/data/api/oauth/index.d.ts +1 -0
  34. package/src/lib/data/api/oauth/oauth.cjs +136 -0
  35. package/src/lib/data/api/oauth/oauth.d.ts +11 -0
  36. package/src/lib/data/api/oauth/oauth.js +128 -0
  37. package/src/lib/data/api/onramp/index.d.ts +1 -0
  38. package/src/lib/data/api/onramp/onramp.cjs +22 -0
  39. package/src/lib/data/api/onramp/onramp.d.ts +8 -0
  40. package/src/lib/data/api/onramp/onramp.js +18 -0
  41. package/src/lib/data/api/session/index.d.ts +1 -0
  42. package/src/lib/data/api/session/session.cjs +77 -0
  43. package/src/lib/data/api/session/session.d.ts +17 -0
  44. package/src/lib/data/api/session/session.js +69 -0
  45. package/src/lib/data/api/settings/index.d.ts +1 -0
  46. package/src/lib/data/api/settings/settings.cjs +58 -0
  47. package/src/lib/data/api/settings/settings.d.ts +7 -0
  48. package/src/lib/data/api/settings/settings.js +53 -0
  49. package/src/lib/data/api/sms/index.d.ts +1 -0
  50. package/src/lib/data/api/sms/sms.cjs +102 -0
  51. package/src/lib/data/api/sms/sms.d.ts +32 -0
  52. package/src/lib/data/api/sms/sms.js +95 -0
  53. package/src/lib/data/api/user/index.d.ts +1 -0
  54. package/src/lib/data/api/user/user.cjs +77 -0
  55. package/src/lib/data/api/user/user.d.ts +9 -0
  56. package/src/lib/data/api/user/user.js +71 -0
  57. package/src/lib/data/api/utils.cjs +20 -0
  58. package/src/lib/data/api/utils.d.ts +1 -0
  59. package/src/lib/data/api/utils.js +16 -0
  60. package/src/lib/data/api/wallets/index.d.ts +1 -0
  61. package/src/lib/data/api/wallets/wallets.cjs +137 -0
  62. package/src/lib/data/api/wallets/wallets.d.ts +10 -0
  63. package/src/lib/data/api/wallets/wallets.js +130 -0
  64. package/src/lib/data/index.d.ts +1 -0
  65. package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +3 -4
  66. package/src/lib/shared/types/general.d.ts +1 -0
  67. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs +18 -4
  68. package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js +15 -1
  69. package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +6 -4
  70. package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +5 -3
  71. package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +4 -3
  72. package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.d.ts +3 -3
  73. package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +3 -2
  74. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +4 -2
  75. package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +3 -1
  76. package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +6 -6
  77. package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +3 -3
  78. package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +4 -4
  79. package/src/lib/utils/hooks/useEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +3 -3
  80. package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +4 -4
  81. package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +3 -3
  82. package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.cjs +6 -4
  83. package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.js +3 -1
  84. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +6 -6
  85. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +3 -3
  86. package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.d.ts +4 -4
  87. package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +8 -8
  88. package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +3 -3
  89. package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +9 -6
  90. package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +4 -1
  91. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +4 -4
  92. package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +3 -3
  93. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +7 -7
  94. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +3 -3
  95. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +4 -4
  96. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +3 -3
  97. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +5 -5
  98. package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +3 -3
  99. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +4 -4
  100. package/src/lib/views/EmailUpdate/EmailUpdate.js +3 -3
  101. package/src/lib/views/EmailVerification/EmailVerification.cjs +11 -11
  102. package/src/lib/views/EmailVerification/EmailVerification.js +3 -3
  103. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +4 -2
  104. package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +3 -1
  105. package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +3 -3
  106. package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +2 -2
  107. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +7 -7
  108. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +3 -3
  109. package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.cjs +4 -4
  110. package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.js +3 -3
  111. package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.cjs +4 -2
  112. package/src/lib/views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.js +3 -1
  113. package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs +4 -2
  114. package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js +3 -1
  115. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +11 -8
  116. package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +5 -2
  117. package/src/lib/views/SelectWalletInWalletGroupView/components/WalletGroupItem/index.d.ts +1 -0
  118. package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +4 -4
  119. package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +2 -2
  120. package/src/lib/views/WalletUsedView/WalletUsedView.cjs +4 -4
  121. package/src/lib/views/WalletUsedView/WalletUsedView.js +3 -3
  122. package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.cjs +6 -2
  123. package/src/lib/widgets/DynamicWidget/views/WalletSettingsView/WalletSettingsView.js +6 -2
  124. package/src/lib/data/api.cjs +0 -797
  125. package/src/lib/data/api.d.ts +0 -179
  126. package/src/lib/data/api.js +0 -753
@@ -0,0 +1,177 @@
1
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
+ import { DynamicError } from '@dynamic-labs/utils';
3
+ import { EmbeddedWalletProviderEnum, ChainEnum } from '@dynamic-labs/sdk-api-core';
4
+ import { logger } from '../../../shared/logger.js';
5
+ import '@dynamic-labs/iconic';
6
+ import '@dynamic-labs/wallet-connector-core';
7
+ import 'react/jsx-runtime';
8
+ import '../../../context/ViewContext/ViewContext.js';
9
+ import 'react';
10
+ import '@dynamic-labs/wallet-book';
11
+ import '../../../utils/constants/colors.js';
12
+ import '../../../utils/constants/values.js';
13
+ import '../../../shared/utils/classes/storage/localStorage.js';
14
+ import '../../../shared/consts/index.js';
15
+ import { sdkApi } from '../api.js';
16
+
17
+ const createTurnkeyEmbeddedWallet = ({ attestation, challenge, environmentId, userJwt, chains = [ChainEnum.Evm], passkeyAlias, }) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const embeddedWallets = [
19
+ {
20
+ chains,
21
+ embeddedWalletProvider: EmbeddedWalletProviderEnum.Turnkeyhd,
22
+ isAuthenticatorAttached: false,
23
+ passkeyAlias,
24
+ },
25
+ ];
26
+ if (attestation && challenge) {
27
+ embeddedWallets[0] = Object.assign(Object.assign({}, embeddedWallets[0]), { embeddedWalletSpecificOpts: {
28
+ attestation,
29
+ challenge,
30
+ }, isAuthenticatorAttached: true });
31
+ }
32
+ return sdkApi(userJwt).createEmbeddedWallets({
33
+ createEmbeddedWalletsRequest: {
34
+ embeddedWallets,
35
+ },
36
+ environmentId,
37
+ });
38
+ });
39
+ const initEmbeddedWalletSession = ({ authenticatorType, walletId, publicKey, environmentId, userJwt, }) => __awaiter(void 0, void 0, void 0, function* () {
40
+ if (authenticatorType === 'passkey') {
41
+ return sdkApi(userJwt).initPasskeyRecovery({
42
+ environmentId,
43
+ initPasskeyRecoveryRequest: {
44
+ turnkeyRecoveryTargetPublicKey: publicKey,
45
+ walletId,
46
+ },
47
+ });
48
+ }
49
+ return sdkApi(userJwt).initEmailAuth({
50
+ environmentId,
51
+ initEmailAuthRequest: {
52
+ turnkeyEmailAuthTargetPublicKey: publicKey,
53
+ walletId,
54
+ },
55
+ });
56
+ });
57
+ const completePasskeyRecovery = ({ walletId, attestation, challenge, environmentId, userJwt, }) => __awaiter(void 0, void 0, void 0, function* () {
58
+ return sdkApi(userJwt).completePasskeyRecovery({
59
+ completePasskeyRecoveryRequest: {
60
+ attestation,
61
+ challenge,
62
+ walletId,
63
+ },
64
+ environmentId,
65
+ });
66
+ });
67
+ const updatePasskeyRecoveryEmail = ({ userJwt, environmentId, updateRecoveryEmailRequest, }) => __awaiter(void 0, void 0, void 0, function* () {
68
+ try {
69
+ yield sdkApi(userJwt).updateEmbeddedWalletRecoveryEmail({
70
+ environmentId,
71
+ updateRecoveryEmailRequest,
72
+ });
73
+ }
74
+ catch (e) {
75
+ logger.error('Error while trying to update recovery email: ', e);
76
+ throw new DynamicError('Error updating recovery email');
77
+ }
78
+ });
79
+ const getUserPasskeys = ({ userJwt, environmentId, }) => __awaiter(void 0, void 0, void 0, function* () {
80
+ try {
81
+ const data = yield sdkApi(userJwt).getUserPasskeys({
82
+ environmentId,
83
+ });
84
+ return data;
85
+ }
86
+ catch (e) {
87
+ logger.error(e);
88
+ return {
89
+ count: 0,
90
+ passkeys: [],
91
+ };
92
+ }
93
+ });
94
+ const updateUserPasskey = ({ userJwt, environmentId, id, alias, }) => __awaiter(void 0, void 0, void 0, function* () {
95
+ try {
96
+ const data = yield sdkApi(userJwt).updatePasskey({
97
+ environmentId,
98
+ updateUserPasskeyRequest: { alias, id },
99
+ });
100
+ return data;
101
+ }
102
+ catch (e) {
103
+ logger.error(e);
104
+ return undefined;
105
+ }
106
+ });
107
+ const exportEmbeddedWallet = ({ userJwt, environmentId, walletId, activityId, }) => __awaiter(void 0, void 0, void 0, function* () {
108
+ try {
109
+ const data = yield sdkApi(userJwt).embeddedWalletExport({
110
+ activityId,
111
+ environmentId,
112
+ walletId,
113
+ });
114
+ return data;
115
+ }
116
+ catch (e) {
117
+ logger.error(e);
118
+ return { exportBundle: '' };
119
+ }
120
+ });
121
+ const getWalletAuthToken = ({ environmentId, type, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
122
+ try {
123
+ const authToken = yield sdkApi(userJwt).getAuthToken({
124
+ environmentId,
125
+ type,
126
+ });
127
+ return authToken.token;
128
+ }
129
+ catch (e) {
130
+ return undefined;
131
+ }
132
+ });
133
+ const getEmbeddedWalletBackup = ({ environmentId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
134
+ try {
135
+ const response = yield sdkApi(userJwt).getEmbeddedWalletBackups({
136
+ environmentId,
137
+ });
138
+ return response.secret;
139
+ }
140
+ catch (e) {
141
+ return undefined;
142
+ }
143
+ });
144
+ const getEmbeddedWalletPasscode = ({ environmentId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
145
+ try {
146
+ const response = yield sdkApi(userJwt).getEmbeddedWalletPasscode({
147
+ environmentId,
148
+ });
149
+ return response.secret;
150
+ }
151
+ catch (e) {
152
+ return undefined;
153
+ }
154
+ });
155
+ const claimEmbeddedWallet = ({ environmentId, walletId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
156
+ var _a, _b;
157
+ try {
158
+ const response = yield sdkApi(userJwt).claimEmbeddedWallet({
159
+ embeddedWalletPasscodeClaimRequest: {
160
+ walletId,
161
+ },
162
+ environmentId,
163
+ });
164
+ return response;
165
+ }
166
+ catch (e) {
167
+ logger.error(e);
168
+ // request failed, return unknown error
169
+ const data = yield ((_a = e === null || e === void 0 ? void 0 : e.json) === null || _a === void 0 ? void 0 : _a.call(e));
170
+ if (!((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.code)) {
171
+ return { code: 'unknown_error' };
172
+ }
173
+ throw e;
174
+ }
175
+ });
176
+
177
+ export { claimEmbeddedWallet, completePasskeyRecovery, createTurnkeyEmbeddedWallet, exportEmbeddedWallet, getEmbeddedWalletBackup, getEmbeddedWalletPasscode, getUserPasskeys, getWalletAuthToken, initEmbeddedWalletSession, updatePasskeyRecoveryEmail, updateUserPasskey };
@@ -0,0 +1,2 @@
1
+ export * from './embeddedWallets';
2
+ export * from './types';
@@ -0,0 +1,39 @@
1
+ import { ChainEnum, PasskeyRegistrationCredential, UpdateRecoveryEmailRequest } from '@dynamic-labs/sdk-api-core';
2
+ import { AuthenticatorType } from '@dynamic-labs/wallet-connector-core';
3
+ export type CreateTurnkeyEmbeddedWalletProps = {
4
+ userJwt: string;
5
+ environmentId: string;
6
+ attestation?: PasskeyRegistrationCredential;
7
+ challenge?: string;
8
+ chains?: ChainEnum[];
9
+ passkeyAlias?: string;
10
+ };
11
+ export type InitPasskeyRecoveryProps = {
12
+ authenticatorType: AuthenticatorType;
13
+ userJwt: string;
14
+ environmentId: string;
15
+ walletId: string;
16
+ publicKey: string;
17
+ };
18
+ export type CompletePasskeyRecoveryProps = {
19
+ userJwt: string;
20
+ environmentId: string;
21
+ walletId: string;
22
+ attestation: PasskeyRegistrationCredential;
23
+ challenge: string;
24
+ };
25
+ export type UpdatePasskeyRecoveryEmailProps = {
26
+ userJwt: string;
27
+ environmentId: string;
28
+ updateRecoveryEmailRequest: UpdateRecoveryEmailRequest;
29
+ };
30
+ export type GetUserPasskeysProps = {
31
+ userJwt: string;
32
+ environmentId: string;
33
+ };
34
+ export type UpdateUserPasskeysProps = {
35
+ userJwt: string;
36
+ environmentId: string;
37
+ id: string;
38
+ alias: string;
39
+ };
@@ -0,0 +1,10 @@
1
+ export * from './email';
2
+ export * from './embeddedWallets';
3
+ export * from './oauth';
4
+ export * from './onramp';
5
+ export * from './session';
6
+ export * from './settings';
7
+ export * from './sms';
8
+ export * from './user';
9
+ export * from './utils';
10
+ export * from './wallets';
@@ -0,0 +1 @@
1
+ export * from './oauth';
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
+ var utils = require('@dynamic-labs/utils');
7
+ require('@dynamic-labs/sdk-api-core');
8
+ var logger = require('../../../shared/logger.cjs');
9
+ require('@dynamic-labs/iconic');
10
+ require('@dynamic-labs/wallet-connector-core');
11
+ require('react/jsx-runtime');
12
+ require('../../../context/ViewContext/ViewContext.cjs');
13
+ require('react');
14
+ require('@dynamic-labs/wallet-book');
15
+ require('../../../utils/constants/colors.cjs');
16
+ require('../../../utils/constants/values.cjs');
17
+ require('../../../shared/utils/classes/storage/localStorage.cjs');
18
+ require('../../../shared/consts/index.cjs');
19
+ var api = require('../api.cjs');
20
+
21
+ const verifyOAuth = (environmentId, providerType, { code, codeVerifier, state }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
22
+ const oauthRequest = {
23
+ code,
24
+ codeVerifier,
25
+ state,
26
+ };
27
+ try {
28
+ const response = yield api.sdkApi(userJwt).oauthVerify({
29
+ environmentId,
30
+ oauthRequest,
31
+ providerType,
32
+ });
33
+ return response;
34
+ }
35
+ catch (e) {
36
+ logger.logger.error(e);
37
+ const data = yield e.json();
38
+ if (data.code === 'social_account_already_exists') {
39
+ throw new utils.SocialAccountAlreadyExistsError();
40
+ }
41
+ return undefined;
42
+ }
43
+ });
44
+ const unlinkOAuth = ({ environmentId, primaryWalletId, verifiedCrentialId, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
45
+ try {
46
+ const response = yield api.sdkApi(userJwt).verifyUnlink({
47
+ environmentId,
48
+ verifyUnlinkRequest: {
49
+ primaryWalletId,
50
+ verifiedCrentialId,
51
+ },
52
+ });
53
+ return response;
54
+ }
55
+ catch (e) {
56
+ return undefined;
57
+ }
58
+ });
59
+ const signInOAuth = (environmentId, providerType, { code, codeVerifier, state, captchaToken }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
60
+ var _a;
61
+ const oauthRequest = {
62
+ captchaToken,
63
+ code,
64
+ codeVerifier,
65
+ state,
66
+ };
67
+ try {
68
+ const response = yield api.sdkApi().oauthSignIn({
69
+ environmentId,
70
+ oauthRequest,
71
+ providerType,
72
+ });
73
+ return response;
74
+ }
75
+ catch (e) {
76
+ logger.logger.error(e);
77
+ const data = yield e.json();
78
+ if (data.error.code === 'gate_blocked') {
79
+ throw new utils.GateBlockedError(data.payload.walletPublicKey);
80
+ }
81
+ if (data.error.code === 'missing_from_list') {
82
+ throw new utils.NoAccessError({
83
+ walletPublicKey: (_a = data === null || data === void 0 ? void 0 : data.payload) === null || _a === void 0 ? void 0 : _a.walletPublicKey,
84
+ });
85
+ }
86
+ if (data.code === 'email_associated_with_different_provider') {
87
+ throw new utils.AccountExistsError(data.error, data.payload);
88
+ }
89
+ return undefined;
90
+ }
91
+ });
92
+ const getOAuthResult = (environmentId, providerType, { state }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
93
+ const oauthResultRequest = {
94
+ state,
95
+ };
96
+ try {
97
+ const result = yield api.sdkApi().oauthResult({
98
+ environmentId,
99
+ oauthResultRequest,
100
+ providerType,
101
+ });
102
+ return result;
103
+ }
104
+ catch (e) {
105
+ logger.logger.error(e);
106
+ return undefined;
107
+ }
108
+ });
109
+ const farcasterSignIn = (environmentId, farcasterSignInRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
110
+ try {
111
+ const response = yield api.sdkApi().farcasterSignIn({
112
+ environmentId,
113
+ farcasterSignInRequest,
114
+ });
115
+ return response;
116
+ }
117
+ catch (e) {
118
+ logger.logger.error(e);
119
+ const data = yield e.json();
120
+ if (data.error.code === 'gate_blocked') {
121
+ throw new utils.GateBlockedError(data.payload.walletPublicKey);
122
+ }
123
+ if (data.error.code === 'missing_from_list') {
124
+ throw new utils.NoAccessError({
125
+ walletPublicKey: data.payload.walletPublicKey,
126
+ });
127
+ }
128
+ return undefined;
129
+ }
130
+ });
131
+
132
+ exports.farcasterSignIn = farcasterSignIn;
133
+ exports.getOAuthResult = getOAuthResult;
134
+ exports.signInOAuth = signInOAuth;
135
+ exports.unlinkOAuth = unlinkOAuth;
136
+ exports.verifyOAuth = verifyOAuth;
@@ -0,0 +1,11 @@
1
+ import { FarcasterSignInRequest, OauthRequest, OauthResultRequest, OauthResultResponse, ProviderEnum, VerifyResponse } from '@dynamic-labs/sdk-api-core';
2
+ export declare const getOauthLoginUrl: (environmentId: string, providerType: ProviderEnum, userJwt: string) => Promise<string | undefined>;
3
+ export declare const verifyOAuth: (environmentId: string, providerType: ProviderEnum, { code, codeVerifier, state }: OauthRequest, userJwt: string) => Promise<VerifyResponse | undefined>;
4
+ export declare const unlinkOAuth: ({ environmentId, primaryWalletId, verifiedCrentialId, }: {
5
+ environmentId: string;
6
+ primaryWalletId: string | undefined;
7
+ verifiedCrentialId: string;
8
+ }, userJwt: string) => Promise<VerifyResponse | undefined>;
9
+ export declare const signInOAuth: (environmentId: string, providerType: ProviderEnum, { code, codeVerifier, state, captchaToken }: OauthRequest) => Promise<VerifyResponse | undefined>;
10
+ export declare const getOAuthResult: (environmentId: string, providerType: ProviderEnum, { state }: OauthResultRequest) => Promise<OauthResultResponse | undefined>;
11
+ export declare const farcasterSignIn: (environmentId: string, farcasterSignInRequest: FarcasterSignInRequest) => Promise<VerifyResponse | undefined>;
@@ -0,0 +1,128 @@
1
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
+ import { GateBlockedError, NoAccessError, AccountExistsError, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
3
+ import '@dynamic-labs/sdk-api-core';
4
+ import { logger } from '../../../shared/logger.js';
5
+ import '@dynamic-labs/iconic';
6
+ import '@dynamic-labs/wallet-connector-core';
7
+ import 'react/jsx-runtime';
8
+ import '../../../context/ViewContext/ViewContext.js';
9
+ import 'react';
10
+ import '@dynamic-labs/wallet-book';
11
+ import '../../../utils/constants/colors.js';
12
+ import '../../../utils/constants/values.js';
13
+ import '../../../shared/utils/classes/storage/localStorage.js';
14
+ import '../../../shared/consts/index.js';
15
+ import { sdkApi } from '../api.js';
16
+
17
+ const verifyOAuth = (environmentId, providerType, { code, codeVerifier, state }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const oauthRequest = {
19
+ code,
20
+ codeVerifier,
21
+ state,
22
+ };
23
+ try {
24
+ const response = yield sdkApi(userJwt).oauthVerify({
25
+ environmentId,
26
+ oauthRequest,
27
+ providerType,
28
+ });
29
+ return response;
30
+ }
31
+ catch (e) {
32
+ logger.error(e);
33
+ const data = yield e.json();
34
+ if (data.code === 'social_account_already_exists') {
35
+ throw new SocialAccountAlreadyExistsError();
36
+ }
37
+ return undefined;
38
+ }
39
+ });
40
+ const unlinkOAuth = ({ environmentId, primaryWalletId, verifiedCrentialId, }, userJwt) => __awaiter(void 0, void 0, void 0, function* () {
41
+ try {
42
+ const response = yield sdkApi(userJwt).verifyUnlink({
43
+ environmentId,
44
+ verifyUnlinkRequest: {
45
+ primaryWalletId,
46
+ verifiedCrentialId,
47
+ },
48
+ });
49
+ return response;
50
+ }
51
+ catch (e) {
52
+ return undefined;
53
+ }
54
+ });
55
+ const signInOAuth = (environmentId, providerType, { code, codeVerifier, state, captchaToken }) => __awaiter(void 0, void 0, void 0, function* () {
56
+ var _a;
57
+ const oauthRequest = {
58
+ captchaToken,
59
+ code,
60
+ codeVerifier,
61
+ state,
62
+ };
63
+ try {
64
+ const response = yield sdkApi().oauthSignIn({
65
+ environmentId,
66
+ oauthRequest,
67
+ providerType,
68
+ });
69
+ return response;
70
+ }
71
+ catch (e) {
72
+ logger.error(e);
73
+ const data = yield e.json();
74
+ if (data.error.code === 'gate_blocked') {
75
+ throw new GateBlockedError(data.payload.walletPublicKey);
76
+ }
77
+ if (data.error.code === 'missing_from_list') {
78
+ throw new NoAccessError({
79
+ walletPublicKey: (_a = data === null || data === void 0 ? void 0 : data.payload) === null || _a === void 0 ? void 0 : _a.walletPublicKey,
80
+ });
81
+ }
82
+ if (data.code === 'email_associated_with_different_provider') {
83
+ throw new AccountExistsError(data.error, data.payload);
84
+ }
85
+ return undefined;
86
+ }
87
+ });
88
+ const getOAuthResult = (environmentId, providerType, { state }) => __awaiter(void 0, void 0, void 0, function* () {
89
+ const oauthResultRequest = {
90
+ state,
91
+ };
92
+ try {
93
+ const result = yield sdkApi().oauthResult({
94
+ environmentId,
95
+ oauthResultRequest,
96
+ providerType,
97
+ });
98
+ return result;
99
+ }
100
+ catch (e) {
101
+ logger.error(e);
102
+ return undefined;
103
+ }
104
+ });
105
+ const farcasterSignIn = (environmentId, farcasterSignInRequest) => __awaiter(void 0, void 0, void 0, function* () {
106
+ try {
107
+ const response = yield sdkApi().farcasterSignIn({
108
+ environmentId,
109
+ farcasterSignInRequest,
110
+ });
111
+ return response;
112
+ }
113
+ catch (e) {
114
+ logger.error(e);
115
+ const data = yield e.json();
116
+ if (data.error.code === 'gate_blocked') {
117
+ throw new GateBlockedError(data.payload.walletPublicKey);
118
+ }
119
+ if (data.error.code === 'missing_from_list') {
120
+ throw new NoAccessError({
121
+ walletPublicKey: data.payload.walletPublicKey,
122
+ });
123
+ }
124
+ return undefined;
125
+ }
126
+ });
127
+
128
+ export { farcasterSignIn, getOAuthResult, signInOAuth, unlinkOAuth, verifyOAuth };
@@ -0,0 +1 @@
1
+ export * from './onramp';
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
+ var api = require('../api.cjs');
7
+
8
+ const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddress, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
9
+ const { onramps } = yield api.sdkApi().getSupportedOnramps({
10
+ chain,
11
+ environmentId,
12
+ networkId: networkId ? String(networkId) : undefined,
13
+ token,
14
+ walletAddress,
15
+ });
16
+ if (!onramps || onramps.length === 0) {
17
+ throw new Error('No onramps');
18
+ }
19
+ return onramps;
20
+ });
21
+
22
+ exports.getOnrampProviders = getOnrampProviders;
@@ -0,0 +1,8 @@
1
+ import { OnrampConfiguration } from '@dynamic-labs/sdk-api-core';
2
+ export declare const getOnrampProviders: ({ chain, environmentId, networkId, token, walletAddress, }: {
3
+ chain: string;
4
+ environmentId: string;
5
+ networkId?: string | number | undefined;
6
+ token?: string | undefined;
7
+ walletAddress: string;
8
+ }) => Promise<OnrampConfiguration[]>;
@@ -0,0 +1,18 @@
1
+ import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
+ import { sdkApi } from '../api.js';
3
+
4
+ const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
5
+ const { onramps } = yield sdkApi().getSupportedOnramps({
6
+ chain,
7
+ environmentId,
8
+ networkId: networkId ? String(networkId) : undefined,
9
+ token,
10
+ walletAddress,
11
+ });
12
+ if (!onramps || onramps.length === 0) {
13
+ throw new Error('No onramps');
14
+ }
15
+ return onramps;
16
+ });
17
+
18
+ export { getOnrampProviders };
@@ -0,0 +1 @@
1
+ export * from './session';
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
+ var utils = require('@dynamic-labs/utils');
7
+ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
8
+ var logger = require('../../../shared/logger.cjs');
9
+ require('@dynamic-labs/iconic');
10
+ require('@dynamic-labs/wallet-connector-core');
11
+ require('react/jsx-runtime');
12
+ require('../../../context/ViewContext/ViewContext.cjs');
13
+ require('react');
14
+ require('@dynamic-labs/wallet-book');
15
+ require('../../../utils/constants/colors.cjs');
16
+ require('../../../utils/constants/values.cjs');
17
+ require('../../../shared/utils/classes/storage/localStorage.cjs');
18
+ require('../../../shared/consts/index.cjs');
19
+ var api = require('../api.cjs');
20
+
21
+ const revokeSession = ({ environmentId, sessionId, }, userJwt) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
22
+ try {
23
+ yield api.sdkApi(userJwt).revokeSession({
24
+ environmentId,
25
+ });
26
+ }
27
+ catch (error) {
28
+ const body = yield error.json();
29
+ logger.logger.error(Error(body.error.message));
30
+ }
31
+ });
32
+ const mapChainToChainEnum = (chain) => {
33
+ const foundChain = Object.values(sdkApiCore.ChainEnum).find((value) => value === chain);
34
+ if (!foundChain) {
35
+ throw new utils.DynamicError(`Invalid chain ${chain}`);
36
+ }
37
+ return foundChain;
38
+ };
39
+ const mapProviderToProviderEnum = (provider) => {
40
+ const foundProvider = Object.values(sdkApiCore.WalletProviderEnum).find((value) => value === provider);
41
+ if (!foundProvider) {
42
+ throw new utils.DynamicError(`Invalid provider ${provider}`);
43
+ }
44
+ return foundProvider;
45
+ };
46
+ const mapAuthModeTypeToEnum = (authMode) => {
47
+ const found = Object.values(sdkApiCore.AuthModeEnum).find((value) => value === authMode);
48
+ if (!found) {
49
+ throw new utils.DynamicError(`Invalid authMode ${authMode}`);
50
+ }
51
+ return found;
52
+ };
53
+ const createVisit = ({ authMode, chain, environmentId, walletProvider, publicWalletAddress, walletName, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
54
+ try {
55
+ const connectRequest = {
56
+ address: publicWalletAddress,
57
+ authMode: mapAuthModeTypeToEnum(authMode),
58
+ chain: mapChainToChainEnum(chain),
59
+ provider: mapProviderToProviderEnum(walletProvider),
60
+ walletName,
61
+ };
62
+ yield api.sdkApi().createVisit({
63
+ connectRequest,
64
+ environmentId,
65
+ });
66
+ }
67
+ catch (error) {
68
+ // log error to console, don't do anything else
69
+ logger.logger.error(error);
70
+ }
71
+ });
72
+
73
+ exports.createVisit = createVisit;
74
+ exports.mapAuthModeTypeToEnum = mapAuthModeTypeToEnum;
75
+ exports.mapChainToChainEnum = mapChainToChainEnum;
76
+ exports.mapProviderToProviderEnum = mapProviderToProviderEnum;
77
+ exports.revokeSession = revokeSession;
@@ -0,0 +1,17 @@
1
+ import { ChainEnum, WalletProviderEnum, AuthModeEnum } from '@dynamic-labs/sdk-api-core';
2
+ import { AuthModeType } from '../../../shared/types';
3
+ export declare const revokeSession: ({ environmentId, sessionId, }: {
4
+ environmentId: string;
5
+ sessionId: string;
6
+ }, userJwt: string) => Promise<void>;
7
+ export declare const mapChainToChainEnum: (chain: string) => ChainEnum;
8
+ export declare const mapProviderToProviderEnum: (provider: string) => WalletProviderEnum;
9
+ export declare const mapAuthModeTypeToEnum: (authMode: string) => AuthModeEnum;
10
+ export declare const createVisit: ({ authMode, chain, environmentId, walletProvider, publicWalletAddress, walletName, }: {
11
+ authMode: AuthModeType;
12
+ chain: string;
13
+ environmentId: string;
14
+ publicWalletAddress: string;
15
+ walletName: string;
16
+ walletProvider: string;
17
+ }) => Promise<void | undefined>;