@turnkey/sdk-react 3.0.3 → 3.0.4
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 +13 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs +84 -102
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -1
- package/dist/components/auth/Apple.d.ts +4 -2
- package/dist/components/auth/Apple.d.ts.map +1 -1
- package/dist/components/auth/Apple.js +66 -41
- package/dist/components/auth/Apple.js.map +1 -1
- package/dist/components/auth/Apple.mjs +66 -41
- package/dist/components/auth/Apple.mjs.map +1 -1
- package/dist/components/auth/Auth.d.ts.map +1 -1
- package/dist/components/auth/Auth.js +25 -45
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +119 -174
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/Facebook.js.map +1 -1
- package/dist/components/auth/Facebook.mjs +3 -3
- package/dist/components/auth/Facebook.mjs.map +1 -1
- package/dist/components/auth/Google.js.map +1 -1
- package/dist/components/auth/Google.mjs +1 -1
- package/dist/components/auth/Google.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +2 -2
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/dist/components/auth/PhoneInput.js.map +1 -1
- package/dist/components/auth/facebookUtils.mjs +2 -2
- package/dist/components/auth/facebookUtils.mjs.map +1 -1
- package/dist/components/auth/otp.js.map +1 -1
- package/dist/components/export/Export.mjs +4 -4
- package/dist/components/export/Export.mjs.map +1 -1
- package/dist/components/import/Import.mjs +3 -3
- package/dist/components/import/Import.mjs.map +1 -1
- package/dist/contexts/TurnkeyContext.mjs +3 -3
- package/dist/contexts/TurnkeyContext.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -105,45 +105,6 @@ const Auth = ({
|
|
|
105
105
|
const phoneNumber = parsePhoneNumberFromString(phone);
|
|
106
106
|
return phoneNumber?.isValid() ?? false;
|
|
107
107
|
};
|
|
108
|
-
const handleGetOrCreateSuborg = async (filterType, filterValue, additionalData = {}) => {
|
|
109
|
-
let suborgId;
|
|
110
|
-
if (filterType == constants.FilterType.Email || filterType == constants.FilterType.PhoneNumber) {
|
|
111
|
-
const getVerifiedSuborgsResponse = await sdkServer.server.getVerifiedSuborgs({
|
|
112
|
-
filterType,
|
|
113
|
-
filterValue
|
|
114
|
-
});
|
|
115
|
-
if (!getVerifiedSuborgsResponse || !getVerifiedSuborgsResponse.organizationIds) {
|
|
116
|
-
onError(constants.authErrors.suborg.fetchFailed);
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
suborgId = getVerifiedSuborgsResponse?.organizationIds[0];
|
|
120
|
-
} else {
|
|
121
|
-
const getSuborgsResponse = await sdkServer.server.getSuborgs({
|
|
122
|
-
filterType,
|
|
123
|
-
filterValue
|
|
124
|
-
});
|
|
125
|
-
if (!getSuborgsResponse || !getSuborgsResponse.organizationIds) {
|
|
126
|
-
onError(constants.authErrors.suborg.fetchFailed);
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
suborgId = getSuborgsResponse?.organizationIds[0];
|
|
130
|
-
}
|
|
131
|
-
if (!suborgId) {
|
|
132
|
-
const createSuborgData = {
|
|
133
|
-
...additionalData
|
|
134
|
-
};
|
|
135
|
-
if (filterType === constants.FilterType.Email) createSuborgData.email = filterValue;else if (filterType === constants.FilterType.PhoneNumber) createSuborgData.phoneNumber = filterValue;
|
|
136
|
-
if (customAccounts) {
|
|
137
|
-
createSuborgData.customAccounts = customAccounts;
|
|
138
|
-
}
|
|
139
|
-
const createSuborgResponse = await sdkServer.server.createSuborg(createSuborgData);
|
|
140
|
-
if (!createSuborgResponse || !createSuborgResponse.subOrganizationId) {
|
|
141
|
-
onError(constants.authErrors.suborg.createFailed);
|
|
142
|
-
}
|
|
143
|
-
suborgId = createSuborgResponse?.subOrganizationId;
|
|
144
|
-
}
|
|
145
|
-
return suborgId;
|
|
146
|
-
};
|
|
147
108
|
const handleAuthSuccess = async (credentialBundle, expirationSeconds) => {
|
|
148
109
|
if (credentialBundle) {
|
|
149
110
|
await authIframeClient.injectCredentialBundle(credentialBundle);
|
|
@@ -232,7 +193,16 @@ const Auth = ({
|
|
|
232
193
|
}
|
|
233
194
|
};
|
|
234
195
|
const handleOtpLogin = async (type, value, otpType) => {
|
|
235
|
-
const
|
|
196
|
+
const resp = await sdkServer.server.getOrCreateSuborg({
|
|
197
|
+
filterType: type,
|
|
198
|
+
filterValue: value
|
|
199
|
+
});
|
|
200
|
+
const suborgIds = resp?.subOrganizationIds;
|
|
201
|
+
if (!suborgIds || suborgIds.length === 0) {
|
|
202
|
+
onError(constants.authErrors.oauth.loginFailed);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const suborgId = suborgIds[0];
|
|
236
206
|
const initAuthResponse = await sdkServer.server.sendOtp({
|
|
237
207
|
suborgID: suborgId,
|
|
238
208
|
otpType,
|
|
@@ -252,12 +222,22 @@ const Auth = ({
|
|
|
252
222
|
};
|
|
253
223
|
const handleOAuthLogin = async (credential, providerName) => {
|
|
254
224
|
setOauthLoading(providerName);
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
225
|
+
const resp = await sdkServer.server.getOrCreateSuborg({
|
|
226
|
+
filterType: constants.FilterType.OidcToken,
|
|
227
|
+
filterValue: credential,
|
|
228
|
+
additionalData: {
|
|
229
|
+
oauthProviders: [{
|
|
230
|
+
providerName,
|
|
231
|
+
oidcToken: credential
|
|
232
|
+
}]
|
|
233
|
+
}
|
|
260
234
|
});
|
|
235
|
+
const suborgIds = resp?.subOrganizationIds;
|
|
236
|
+
if (!suborgIds || suborgIds.length === 0) {
|
|
237
|
+
onError(constants.authErrors.oauth.loginFailed);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const suborgId = suborgIds[0];
|
|
261
241
|
const oauthResponse = await sdkServer.server.oauth({
|
|
262
242
|
suborgID: suborgId,
|
|
263
243
|
oidcToken: credential,
|