@supertokens-plugins/rownd-nodejs 0.3.0-beta.3 → 0.3.0-beta.5
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/dist/index.js +20 -12
- package/dist/index.mjs +20 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1492,7 +1492,7 @@ function buildRowndSessionClaimPayload(input) {
|
|
|
1492
1492
|
const verifiedData = originalRowndUser?.verified_data;
|
|
1493
1493
|
const authLevel = getEffectiveAuthLevel(
|
|
1494
1494
|
input.user,
|
|
1495
|
-
originalRowndUser?.auth_level,
|
|
1495
|
+
typeof currentPayload.auth_level === "string" ? currentPayload.auth_level : originalRowndUser?.auth_level,
|
|
1496
1496
|
verifiedData
|
|
1497
1497
|
);
|
|
1498
1498
|
const appUserId = getRowndAppUserId(
|
|
@@ -1501,7 +1501,7 @@ function buildRowndSessionClaimPayload(input) {
|
|
|
1501
1501
|
currentPayload,
|
|
1502
1502
|
input.metadata
|
|
1503
1503
|
);
|
|
1504
|
-
const isAnonymous = authLevel === GUEST_AUTH_METHOD_ID;
|
|
1504
|
+
const isAnonymous = currentPayload.is_anonymous === true || authLevel === GUEST_AUTH_METHOD_ID || authLevel === ANONYMOUS_AUTH_METHOD_ID;
|
|
1505
1505
|
const anonymousId = getAnonymousId(input.userId, input.user, input.metadata);
|
|
1506
1506
|
const isVerifiedUser = authLevel !== "unverified";
|
|
1507
1507
|
const audience = buildRowndAudience(currentPayload, input.appVariantId);
|
|
@@ -1617,6 +1617,9 @@ function hasVerifiedRealLoginMethod(user) {
|
|
|
1617
1617
|
});
|
|
1618
1618
|
}
|
|
1619
1619
|
function getEffectiveAuthLevel(user, originalAuthLevel, verifiedData) {
|
|
1620
|
+
if (originalAuthLevel === ANONYMOUS_AUTH_METHOD_ID) {
|
|
1621
|
+
return ANONYMOUS_AUTH_METHOD_ID;
|
|
1622
|
+
}
|
|
1620
1623
|
if (hasVerifiedRealLoginMethod(user)) {
|
|
1621
1624
|
return "verified";
|
|
1622
1625
|
}
|
|
@@ -2115,6 +2118,7 @@ function handleGuestLogin(deps) {
|
|
|
2115
2118
|
assertRowndAppVariantIsConfigured(appVariantId);
|
|
2116
2119
|
const thirdPartyId = body.authLevel === ANONYMOUS_AUTH_METHOD_ID ? ANONYMOUS_AUTH_METHOD_ID : GUEST_AUTH_METHOD_ID;
|
|
2117
2120
|
const thirdPartyUserId = thirdPartyId === ANONYMOUS_AUTH_METHOD_ID ? `anon_${(0, import_crypto.randomUUID)()}` : guestId;
|
|
2121
|
+
const authLevel = thirdPartyId === ANONYMOUS_AUTH_METHOD_ID ? ANONYMOUS_AUTH_METHOD_ID : GUEST_AUTH_METHOD_ID;
|
|
2118
2122
|
const response = await import_thirdparty.default.manuallyCreateOrUpdateUser(
|
|
2119
2123
|
PUBLIC_TENANT_ID,
|
|
2120
2124
|
thirdPartyId,
|
|
@@ -2136,7 +2140,7 @@ function handleGuestLogin(deps) {
|
|
|
2136
2140
|
response.recipeUserId,
|
|
2137
2141
|
{
|
|
2138
2142
|
...buildRowndAudience({}, appVariantId),
|
|
2139
|
-
auth_level:
|
|
2143
|
+
auth_level: authLevel,
|
|
2140
2144
|
is_anonymous: true,
|
|
2141
2145
|
app_user_id: response.user.id
|
|
2142
2146
|
},
|
|
@@ -2195,16 +2199,14 @@ function handleMigrate(deps) {
|
|
|
2195
2199
|
if (!user) {
|
|
2196
2200
|
const stUserImport = mapRowndUserToSuperTokens(rowndUser);
|
|
2197
2201
|
try {
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
)
|
|
2202
|
-
|
|
2203
|
-
if (importedUser.loginMethods[0]?.recipeUserId) {
|
|
2204
|
-
recipeUserId = import_supertokens_node3.default.convertToRecipeUserId(
|
|
2205
|
-
importedUser.loginMethods[0].recipeUserId
|
|
2206
|
-
);
|
|
2202
|
+
await importUser(stUserImport, deps.stConfig.supertokens);
|
|
2203
|
+
clearSuperTokensCoreCallCache(userContext);
|
|
2204
|
+
user = await import_supertokens_node3.default.getUser(rowndUserId, userContext);
|
|
2205
|
+
if (!user) {
|
|
2206
|
+
throw new Error("Imported user could not be resolved");
|
|
2207
2207
|
}
|
|
2208
|
+
superTokensUserId = user.id;
|
|
2209
|
+
recipeUserId = user.loginMethods[0]?.recipeUserId;
|
|
2208
2210
|
} catch (err) {
|
|
2209
2211
|
user = await import_supertokens_node3.default.getUser(rowndUserId, userContext);
|
|
2210
2212
|
if (!user) {
|
|
@@ -2270,6 +2272,12 @@ function handleMigrate(deps) {
|
|
|
2270
2272
|
}
|
|
2271
2273
|
};
|
|
2272
2274
|
}
|
|
2275
|
+
function clearSuperTokensCoreCallCache(userContext) {
|
|
2276
|
+
const cacheContext = userContext;
|
|
2277
|
+
if (cacheContext._default?.coreCallCache) {
|
|
2278
|
+
cacheContext._default.coreCallCache = {};
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2273
2281
|
function handleGetUser() {
|
|
2274
2282
|
return async (_req, _res, session) => {
|
|
2275
2283
|
const user = await getUserById(session.getUserId());
|
package/dist/index.mjs
CHANGED
|
@@ -1469,7 +1469,7 @@ function buildRowndSessionClaimPayload(input) {
|
|
|
1469
1469
|
const verifiedData = originalRowndUser?.verified_data;
|
|
1470
1470
|
const authLevel = getEffectiveAuthLevel(
|
|
1471
1471
|
input.user,
|
|
1472
|
-
originalRowndUser?.auth_level,
|
|
1472
|
+
typeof currentPayload.auth_level === "string" ? currentPayload.auth_level : originalRowndUser?.auth_level,
|
|
1473
1473
|
verifiedData
|
|
1474
1474
|
);
|
|
1475
1475
|
const appUserId = getRowndAppUserId(
|
|
@@ -1478,7 +1478,7 @@ function buildRowndSessionClaimPayload(input) {
|
|
|
1478
1478
|
currentPayload,
|
|
1479
1479
|
input.metadata
|
|
1480
1480
|
);
|
|
1481
|
-
const isAnonymous = authLevel === GUEST_AUTH_METHOD_ID;
|
|
1481
|
+
const isAnonymous = currentPayload.is_anonymous === true || authLevel === GUEST_AUTH_METHOD_ID || authLevel === ANONYMOUS_AUTH_METHOD_ID;
|
|
1482
1482
|
const anonymousId = getAnonymousId(input.userId, input.user, input.metadata);
|
|
1483
1483
|
const isVerifiedUser = authLevel !== "unverified";
|
|
1484
1484
|
const audience = buildRowndAudience(currentPayload, input.appVariantId);
|
|
@@ -1594,6 +1594,9 @@ function hasVerifiedRealLoginMethod(user) {
|
|
|
1594
1594
|
});
|
|
1595
1595
|
}
|
|
1596
1596
|
function getEffectiveAuthLevel(user, originalAuthLevel, verifiedData) {
|
|
1597
|
+
if (originalAuthLevel === ANONYMOUS_AUTH_METHOD_ID) {
|
|
1598
|
+
return ANONYMOUS_AUTH_METHOD_ID;
|
|
1599
|
+
}
|
|
1597
1600
|
if (hasVerifiedRealLoginMethod(user)) {
|
|
1598
1601
|
return "verified";
|
|
1599
1602
|
}
|
|
@@ -2092,6 +2095,7 @@ function handleGuestLogin(deps) {
|
|
|
2092
2095
|
assertRowndAppVariantIsConfigured(appVariantId);
|
|
2093
2096
|
const thirdPartyId = body.authLevel === ANONYMOUS_AUTH_METHOD_ID ? ANONYMOUS_AUTH_METHOD_ID : GUEST_AUTH_METHOD_ID;
|
|
2094
2097
|
const thirdPartyUserId = thirdPartyId === ANONYMOUS_AUTH_METHOD_ID ? `anon_${randomUUID()}` : guestId;
|
|
2098
|
+
const authLevel = thirdPartyId === ANONYMOUS_AUTH_METHOD_ID ? ANONYMOUS_AUTH_METHOD_ID : GUEST_AUTH_METHOD_ID;
|
|
2095
2099
|
const response = await ThirdParty.manuallyCreateOrUpdateUser(
|
|
2096
2100
|
PUBLIC_TENANT_ID,
|
|
2097
2101
|
thirdPartyId,
|
|
@@ -2113,7 +2117,7 @@ function handleGuestLogin(deps) {
|
|
|
2113
2117
|
response.recipeUserId,
|
|
2114
2118
|
{
|
|
2115
2119
|
...buildRowndAudience({}, appVariantId),
|
|
2116
|
-
auth_level:
|
|
2120
|
+
auth_level: authLevel,
|
|
2117
2121
|
is_anonymous: true,
|
|
2118
2122
|
app_user_id: response.user.id
|
|
2119
2123
|
},
|
|
@@ -2172,16 +2176,14 @@ function handleMigrate(deps) {
|
|
|
2172
2176
|
if (!user) {
|
|
2173
2177
|
const stUserImport = mapRowndUserToSuperTokens(rowndUser);
|
|
2174
2178
|
try {
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
)
|
|
2179
|
-
|
|
2180
|
-
if (importedUser.loginMethods[0]?.recipeUserId) {
|
|
2181
|
-
recipeUserId = SuperTokens3.convertToRecipeUserId(
|
|
2182
|
-
importedUser.loginMethods[0].recipeUserId
|
|
2183
|
-
);
|
|
2179
|
+
await importUser(stUserImport, deps.stConfig.supertokens);
|
|
2180
|
+
clearSuperTokensCoreCallCache(userContext);
|
|
2181
|
+
user = await SuperTokens3.getUser(rowndUserId, userContext);
|
|
2182
|
+
if (!user) {
|
|
2183
|
+
throw new Error("Imported user could not be resolved");
|
|
2184
2184
|
}
|
|
2185
|
+
superTokensUserId = user.id;
|
|
2186
|
+
recipeUserId = user.loginMethods[0]?.recipeUserId;
|
|
2185
2187
|
} catch (err) {
|
|
2186
2188
|
user = await SuperTokens3.getUser(rowndUserId, userContext);
|
|
2187
2189
|
if (!user) {
|
|
@@ -2247,6 +2249,12 @@ function handleMigrate(deps) {
|
|
|
2247
2249
|
}
|
|
2248
2250
|
};
|
|
2249
2251
|
}
|
|
2252
|
+
function clearSuperTokensCoreCallCache(userContext) {
|
|
2253
|
+
const cacheContext = userContext;
|
|
2254
|
+
if (cacheContext._default?.coreCallCache) {
|
|
2255
|
+
cacheContext._default.coreCallCache = {};
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2250
2258
|
function handleGetUser() {
|
|
2251
2259
|
return async (_req, _res, session) => {
|
|
2252
2260
|
const user = await getUserById(session.getUserId());
|