@turnkey/sdk-react 3.0.1 → 3.0.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 +19 -0
- package/README.md +1 -0
- package/dist/components/auth/Auth.d.ts.map +1 -1
- package/dist/components/auth/Auth.js +18 -6
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +50 -33
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.d.ts +1 -1
- package/dist/components/auth/OtpVerification.d.ts.map +1 -1
- package/dist/components/auth/OtpVerification.js +1 -1
- package/dist/components/auth/OtpVerification.js.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +1 -1
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/dist/hooks/use-session.d.ts.map +1 -1
- package/dist/hooks/use-session.js +3 -2
- package/dist/hooks/use-session.js.map +1 -1
- package/dist/hooks/use-session.mjs +2 -1
- package/dist/hooks/use-session.mjs.map +1 -1
- package/dist/hooks/use-turnkey.d.ts.map +1 -1
- package/dist/hooks/use-turnkey.js +1 -0
- package/dist/hooks/use-turnkey.js.map +1 -1
- package/dist/hooks/use-turnkey.mjs +1 -0
- package/dist/hooks/use-turnkey.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @turnkey/sdk-react
|
|
2
2
|
|
|
3
|
+
## 3.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5f6de98: Fix phone number validation issue causing issues with non +1 country codes
|
|
8
|
+
- Updated dependencies [69d2571]
|
|
9
|
+
- Updated dependencies [57f9cb0]
|
|
10
|
+
- @turnkey/sdk-browser@1.13.0
|
|
11
|
+
- @turnkey/sdk-server@2.1.0
|
|
12
|
+
- @turnkey/crypto@2.3.1
|
|
13
|
+
- @turnkey/wallet-stamper@1.0.3
|
|
14
|
+
|
|
15
|
+
## 3.0.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- faa757c: Patch EWK custom session lengths - previously not working as intended (defaulted to 15 minute sessions only) and fix the following useLocalStorage issue when compiling: [Error: useLocalStorage is a client-only hook]
|
|
20
|
+
- a8bd73b: Fix issue with EWK where suborgs were being created on failed fetches
|
|
21
|
+
|
|
3
22
|
## 3.0.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../../src/components/auth/Auth.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../../src/components/auth/Auth.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAqC1D,UAAU,SAAS;IACjB,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,UAAU,EAAE;QACV,YAAY,EAAE,OAAO,CAAC;QACtB,cAAc,EAAE,OAAO,CAAC;QACxB,YAAY,EAAE,OAAO,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;QACtB,eAAe,EAAE,OAAO,CAAC;QACzB,aAAa,EAAE,OAAO,CAAC;QACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CA8lB7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -18,6 +18,7 @@ var OtpVerification = require('./OtpVerification.js');
|
|
|
18
18
|
var useTurnkey = require('../../hooks/use-turnkey.js');
|
|
19
19
|
var constants = require('./constants.js');
|
|
20
20
|
var sdkServer = require('@turnkey/sdk-server');
|
|
21
|
+
var parsePhoneNumberFromString = require('libphonenumber-js');
|
|
21
22
|
|
|
22
23
|
const passkeyIcon = jsxRuntime.jsxs("svg", {
|
|
23
24
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -100,7 +101,10 @@ const Auth = ({
|
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
const isValidEmail = email => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
103
|
-
const isValidPhone = phone =>
|
|
104
|
+
const isValidPhone = phone => {
|
|
105
|
+
const phoneNumber = parsePhoneNumberFromString(phone);
|
|
106
|
+
return phoneNumber?.isValid() ?? false;
|
|
107
|
+
};
|
|
104
108
|
const handleGetOrCreateSuborg = async (filterType, filterValue, additionalData = {}) => {
|
|
105
109
|
let suborgId;
|
|
106
110
|
if (filterType == constants.FilterType.Email || filterType == constants.FilterType.PhoneNumber) {
|
|
@@ -110,6 +114,7 @@ const Auth = ({
|
|
|
110
114
|
});
|
|
111
115
|
if (!getVerifiedSuborgsResponse || !getVerifiedSuborgsResponse.organizationIds) {
|
|
112
116
|
onError(constants.authErrors.suborg.fetchFailed);
|
|
117
|
+
return null;
|
|
113
118
|
}
|
|
114
119
|
suborgId = getVerifiedSuborgsResponse?.organizationIds[0];
|
|
115
120
|
} else {
|
|
@@ -119,6 +124,7 @@ const Auth = ({
|
|
|
119
124
|
});
|
|
120
125
|
if (!getSuborgsResponse || !getSuborgsResponse.organizationIds) {
|
|
121
126
|
onError(constants.authErrors.suborg.fetchFailed);
|
|
127
|
+
return null;
|
|
122
128
|
}
|
|
123
129
|
suborgId = getSuborgsResponse?.organizationIds[0];
|
|
124
130
|
}
|
|
@@ -138,10 +144,10 @@ const Auth = ({
|
|
|
138
144
|
}
|
|
139
145
|
return suborgId;
|
|
140
146
|
};
|
|
141
|
-
const handleAuthSuccess = async credentialBundle => {
|
|
147
|
+
const handleAuthSuccess = async (credentialBundle, expirationSeconds) => {
|
|
142
148
|
if (credentialBundle) {
|
|
143
149
|
await authIframeClient.injectCredentialBundle(credentialBundle);
|
|
144
|
-
await authIframeClient.loginWithAuthBundle(credentialBundle);
|
|
150
|
+
await authIframeClient.loginWithAuthBundle(credentialBundle, expirationSeconds);
|
|
145
151
|
await onAuthSuccess();
|
|
146
152
|
}
|
|
147
153
|
};
|
|
@@ -193,10 +199,13 @@ const Auth = ({
|
|
|
193
199
|
}
|
|
194
200
|
const sessionResponse = await passkeyClient?.createReadWriteSession({
|
|
195
201
|
targetPublicKey: authIframeClient?.iframePublicKey,
|
|
202
|
+
...(authConfig.sessionLengthSeconds !== undefined && {
|
|
203
|
+
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
204
|
+
}),
|
|
196
205
|
organizationId: turnkey$1?.config.defaultOrganizationId ?? process.env.NEXT_PUBLIC_ORGANIZATION_ID
|
|
197
206
|
});
|
|
198
207
|
if (sessionResponse?.credentialBundle) {
|
|
199
|
-
await handleAuthSuccess(sessionResponse.credentialBundle);
|
|
208
|
+
await handleAuthSuccess(sessionResponse.credentialBundle, authConfig.sessionLengthSeconds?.toString());
|
|
200
209
|
} else {
|
|
201
210
|
setPasskeySignupError(constants.authErrors.passkey.loginFailed);
|
|
202
211
|
}
|
|
@@ -208,10 +217,13 @@ const Auth = ({
|
|
|
208
217
|
try {
|
|
209
218
|
const sessionResponse = await passkeyClient?.createReadWriteSession({
|
|
210
219
|
targetPublicKey: authIframeClient?.iframePublicKey,
|
|
220
|
+
...(authConfig.sessionLengthSeconds !== undefined && {
|
|
221
|
+
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
222
|
+
}),
|
|
211
223
|
organizationId: turnkey$1?.config.defaultOrganizationId ?? process.env.NEXT_PUBLIC_ORGANIZATION_ID
|
|
212
224
|
});
|
|
213
225
|
if (sessionResponse?.credentialBundle) {
|
|
214
|
-
await handleAuthSuccess(sessionResponse.credentialBundle);
|
|
226
|
+
await handleAuthSuccess(sessionResponse.credentialBundle, authConfig.sessionLengthSeconds?.toString());
|
|
215
227
|
} else {
|
|
216
228
|
constants.authErrors.passkey.loginFailed;
|
|
217
229
|
}
|
|
@@ -253,7 +265,7 @@ const Auth = ({
|
|
|
253
265
|
sessionLengthSeconds: authConfig.sessionLengthSeconds
|
|
254
266
|
});
|
|
255
267
|
if (oauthResponse && oauthResponse.token) {
|
|
256
|
-
await handleAuthSuccess(oauthResponse.token);
|
|
268
|
+
await handleAuthSuccess(oauthResponse.token, authConfig.sessionLengthSeconds?.toString());
|
|
257
269
|
} else {
|
|
258
270
|
onError(constants.authErrors.oauth.loginFailed);
|
|
259
271
|
}
|