@dynamic-labs/sdk-react-core 2.2.0-alpha.2 → 2.2.0-alpha.3
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/CHANGELOG.md +12 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +14 -14
- package/src/lib/data/api/oauth/oauth.cjs +14 -0
- package/src/lib/data/api/oauth/oauth.d.ts +2 -1
- package/src/lib/data/api/oauth/oauth.js +15 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +13 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +14 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.cjs +5 -3
- package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.js +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.2.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.2...v2.2.0-alpha.3) (2024-06-05)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* farcaster linking ([#5869](https://github.com/dynamic-labs/DynamicAuth/issues/5869)) ([191d1d2](https://github.com/dynamic-labs/DynamicAuth/commit/191d1d29e436e7d453d533c9c330ac5cef2e2a1c))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* phone number in kyc step ([#5875](https://github.com/dynamic-labs/DynamicAuth/issues/5875)) ([d73f3b1](https://github.com/dynamic-labs/DynamicAuth/commit/d73f3b158e794727e7bed5d558a43d937951ce56))
|
|
13
|
+
|
|
2
14
|
## [2.2.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.2.0-alpha.1...v2.2.0-alpha.2) (2024-06-05)
|
|
3
15
|
|
|
4
16
|
|
package/package.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "2.2.0-alpha.
|
|
6
|
+
var version = "2.2.0-alpha.3";
|
|
7
7
|
var dependencies = {
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "0.0.460",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
10
10
|
"country-list": "2.3.0",
|
|
11
11
|
formik: "2.2.9",
|
package/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "2.2.0-alpha.
|
|
2
|
+
var version = "2.2.0-alpha.3";
|
|
3
3
|
var dependencies = {
|
|
4
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
4
|
+
"@dynamic-labs/sdk-api-core": "0.0.460",
|
|
5
5
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
6
6
|
"country-list": "2.3.0",
|
|
7
7
|
formik: "2.2.9",
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
7
7
|
"directory": "packages/sdk-react-core"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
10
|
+
"@dynamic-labs/sdk-api-core": "0.0.460",
|
|
11
11
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
12
12
|
"country-list": "2.3.0",
|
|
13
13
|
"formik": "2.2.9",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "2.2.0-alpha.
|
|
21
|
-
"@dynamic-labs/logger": "2.2.0-alpha.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "2.2.0-alpha.
|
|
23
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.2.0-alpha.
|
|
24
|
-
"@dynamic-labs/rpc-provider-solana": "2.2.0-alpha.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "2.2.0-alpha.
|
|
26
|
-
"@dynamic-labs/store": "2.2.0-alpha.
|
|
27
|
-
"@dynamic-labs/types": "2.2.0-alpha.
|
|
28
|
-
"@dynamic-labs/utils": "2.2.0-alpha.
|
|
29
|
-
"@dynamic-labs/viem-utils": "2.2.0-alpha.
|
|
30
|
-
"@dynamic-labs/wallet-book": "2.2.0-alpha.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "2.2.0-alpha.
|
|
20
|
+
"@dynamic-labs/iconic": "2.2.0-alpha.3",
|
|
21
|
+
"@dynamic-labs/logger": "2.2.0-alpha.3",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.2.0-alpha.3",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.2.0-alpha.3",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.2.0-alpha.3",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.2.0-alpha.3",
|
|
26
|
+
"@dynamic-labs/store": "2.2.0-alpha.3",
|
|
27
|
+
"@dynamic-labs/types": "2.2.0-alpha.3",
|
|
28
|
+
"@dynamic-labs/utils": "2.2.0-alpha.3",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.2.0-alpha.3",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.2.0-alpha.3",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.2.0-alpha.3",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -134,8 +134,22 @@ const farcasterSignIn = (environmentId, farcasterSignInRequest) => _tslib.__awai
|
|
|
134
134
|
return undefined;
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
|
+
const farcasterVerify = (farcasterVerifyRequest) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
+
try {
|
|
139
|
+
const response = yield api.sdkApi().farcasterVerify(farcasterVerifyRequest);
|
|
140
|
+
const user = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
141
|
+
return user;
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
if (e.status === 422) {
|
|
145
|
+
throw new utils.SocialAccountAlreadyExistsError();
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
137
150
|
|
|
138
151
|
exports.farcasterSignIn = farcasterSignIn;
|
|
152
|
+
exports.farcasterVerify = farcasterVerify;
|
|
139
153
|
exports.getOAuthResult = getOAuthResult;
|
|
140
154
|
exports.signInOAuth = signInOAuth;
|
|
141
155
|
exports.unlinkOAuth = unlinkOAuth;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FarcasterSignInRequest, OauthRequest, OauthResultRequest, OauthResultResponse, ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
1
|
+
import { FarcasterSignInRequest, OauthRequest, OauthResultRequest, OauthResultResponse, ProviderEnum, FarcasterVerifyRequest } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { UserProfile } from '../../../..';
|
|
3
3
|
export declare const getOauthLoginUrl: (environmentId: string, providerType: ProviderEnum) => Promise<string | undefined>;
|
|
4
4
|
export declare const verifyOAuth: (environmentId: string, providerType: ProviderEnum, { code, codeVerifier, state }: OauthRequest) => Promise<UserProfile | undefined>;
|
|
@@ -10,3 +10,4 @@ export declare const unlinkOAuth: ({ environmentId, primaryWalletId, verifiedCre
|
|
|
10
10
|
export declare const signInOAuth: (environmentId: string, providerType: ProviderEnum, { code, codeVerifier, state, captchaToken }: OauthRequest) => Promise<UserProfile | undefined>;
|
|
11
11
|
export declare const getOAuthResult: (environmentId: string, providerType: ProviderEnum, { state }: OauthResultRequest) => Promise<OauthResultResponse | undefined>;
|
|
12
12
|
export declare const farcasterSignIn: (environmentId: string, farcasterSignInRequest: FarcasterSignInRequest) => Promise<UserProfile | undefined>;
|
|
13
|
+
export declare const farcasterVerify: (farcasterVerifyRequest: FarcasterVerifyRequest) => Promise<UserProfile | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { GateBlockedError, NoAccessError, AccountExistsError
|
|
3
|
+
import { SocialAccountAlreadyExistsError, GateBlockedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
4
4
|
import '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { logger } from '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
@@ -130,5 +130,18 @@ const farcasterSignIn = (environmentId, farcasterSignInRequest) => __awaiter(voi
|
|
|
130
130
|
return undefined;
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
+
const farcasterVerify = (farcasterVerifyRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
|
+
try {
|
|
135
|
+
const response = yield sdkApi().farcasterVerify(farcasterVerifyRequest);
|
|
136
|
+
const user = storeAuthTokenAndUser(response);
|
|
137
|
+
return user;
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
if (e.status === 422) {
|
|
141
|
+
throw new SocialAccountAlreadyExistsError();
|
|
142
|
+
}
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
133
146
|
|
|
134
|
-
export { farcasterSignIn, getOAuthResult, signInOAuth, unlinkOAuth, verifyOAuth };
|
|
147
|
+
export { farcasterSignIn, farcasterVerify, getOAuthResult, signInOAuth, unlinkOAuth, verifyOAuth };
|
|
@@ -419,7 +419,19 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
419
419
|
yield signInAccount(sdkApiCore.ProviderEnum.Farcaster, apiCall);
|
|
420
420
|
}
|
|
421
421
|
else {
|
|
422
|
-
|
|
422
|
+
const apiCall = () => oauth.farcasterVerify({
|
|
423
|
+
environmentId,
|
|
424
|
+
farcasterSignInRequest: {
|
|
425
|
+
address,
|
|
426
|
+
captchaToken,
|
|
427
|
+
domain,
|
|
428
|
+
message,
|
|
429
|
+
nonce,
|
|
430
|
+
signature,
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
yield linkAccount(sdkApiCore.ProviderEnum.Farcaster, apiCall);
|
|
434
|
+
setShowAuthFlow(false, { clearErrors: false });
|
|
423
435
|
}
|
|
424
436
|
setIsProcessing(false);
|
|
425
437
|
});
|
|
@@ -30,7 +30,7 @@ import 'viem';
|
|
|
30
30
|
import 'viem/chains';
|
|
31
31
|
import '../../../config/ApiEndpoint.js';
|
|
32
32
|
import '@dynamic-labs/store';
|
|
33
|
-
import { getOAuthResult, signInOAuth, farcasterSignIn,
|
|
33
|
+
import { getOAuthResult, signInOAuth, verifyOAuth, farcasterSignIn, farcasterVerify } from '../../../data/api/oauth/oauth.js';
|
|
34
34
|
import '../../../locale/locale.js';
|
|
35
35
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
36
36
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -415,7 +415,19 @@ const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, })
|
|
|
415
415
|
yield signInAccount(ProviderEnum.Farcaster, apiCall);
|
|
416
416
|
}
|
|
417
417
|
else {
|
|
418
|
-
|
|
418
|
+
const apiCall = () => farcasterVerify({
|
|
419
|
+
environmentId,
|
|
420
|
+
farcasterSignInRequest: {
|
|
421
|
+
address,
|
|
422
|
+
captchaToken,
|
|
423
|
+
domain,
|
|
424
|
+
message,
|
|
425
|
+
nonce,
|
|
426
|
+
signature,
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
yield linkAccount(ProviderEnum.Farcaster, apiCall);
|
|
430
|
+
setShowAuthFlow(false, { clearErrors: false });
|
|
419
431
|
}
|
|
420
432
|
setIsProcessing(false);
|
|
421
433
|
});
|
|
@@ -33,6 +33,7 @@ require('../../../../config/ApiEndpoint.cjs');
|
|
|
33
33
|
require('@dynamic-labs/store');
|
|
34
34
|
require('../../../../locale/locale.cjs');
|
|
35
35
|
var getSupportedCountriesForVerificationFromProjectSettings = require('../../../../utils/functions/getSupportedCountriesForVerificationFromProjectSettings/getSupportedCountriesForVerificationFromProjectSettings.cjs');
|
|
36
|
+
var getDefaultCountriesIfEmpty = require('../../../../utils/functions/getDefaultCountriesIfEmpty/getDefaultCountriesIfEmpty.cjs');
|
|
36
37
|
require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
37
38
|
require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
38
39
|
require('../../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -92,9 +93,10 @@ const UserPhoneField = ({ onChange, value: phone, onBlur, disabled, label, requi
|
|
|
92
93
|
target: { name, value: newPhone },
|
|
93
94
|
});
|
|
94
95
|
};
|
|
95
|
-
const countries = React.useMemo(() =>
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const countries = React.useMemo(() => {
|
|
97
|
+
const enabledCountries = getSupportedCountriesForVerificationFromProjectSettings.getSupportedCountriesForVerificationFromProjectSettings(projectSettings);
|
|
98
|
+
return getCustomCountries.getCustomCountries(verify ? getDefaultCountriesIfEmpty.getDefaultCountriesIfEmpty(enabledCountries) : undefined);
|
|
99
|
+
}, [verify, projectSettings]);
|
|
98
100
|
return (jsxRuntime.jsx(PhoneNumberField.PhoneNumberField, { countries: countries, initialPhone: phone, disabled: disabled, onUpdate: handleUpdate, onBlur: onBlur, label: label, appendRight: !disabled && !required ? (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'user-phone-field__optional-label', children: "Optional" })) : undefined, error: error }));
|
|
99
101
|
};
|
|
100
102
|
|
|
@@ -29,6 +29,7 @@ import '../../../../config/ApiEndpoint.js';
|
|
|
29
29
|
import '@dynamic-labs/store';
|
|
30
30
|
import '../../../../locale/locale.js';
|
|
31
31
|
import { getSupportedCountriesForVerificationFromProjectSettings } from '../../../../utils/functions/getSupportedCountriesForVerificationFromProjectSettings/getSupportedCountriesForVerificationFromProjectSettings.js';
|
|
32
|
+
import { getDefaultCountriesIfEmpty } from '../../../../utils/functions/getDefaultCountriesIfEmpty/getDefaultCountriesIfEmpty.js';
|
|
32
33
|
import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
34
|
import '../../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
35
|
import '../../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -88,9 +89,10 @@ const UserPhoneField = ({ onChange, value: phone, onBlur, disabled, label, requi
|
|
|
88
89
|
target: { name, value: newPhone },
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
|
-
const countries = useMemo(() =>
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const countries = useMemo(() => {
|
|
93
|
+
const enabledCountries = getSupportedCountriesForVerificationFromProjectSettings(projectSettings);
|
|
94
|
+
return getCustomCountries(verify ? getDefaultCountriesIfEmpty(enabledCountries) : undefined);
|
|
95
|
+
}, [verify, projectSettings]);
|
|
94
96
|
return (jsx(PhoneNumberField, { countries: countries, initialPhone: phone, disabled: disabled, onUpdate: handleUpdate, onBlur: onBlur, label: label, appendRight: !disabled && !required ? (jsx(Typography, { variant: 'body_small', color: 'secondary', className: 'user-phone-field__optional-label', children: "Optional" })) : undefined, error: error }));
|
|
95
97
|
};
|
|
96
98
|
|