@supertokens-plugins/rownd-nodejs 0.3.0-beta.3 → 0.3.0-beta.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/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: GUEST_AUTH_METHOD_ID,
2143
+ auth_level: authLevel,
2140
2144
  is_anonymous: true,
2141
2145
  app_user_id: response.user.id
2142
2146
  },
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: GUEST_AUTH_METHOD_ID,
2120
+ auth_level: authLevel,
2117
2121
  is_anonymous: true,
2118
2122
  app_user_id: response.user.id
2119
2123
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supertokens-plugins/rownd-nodejs",
3
- "version": "0.3.0-beta.3",
3
+ "version": "0.3.0-beta.4",
4
4
  "description": "Rownd User Migration Plugin for SuperTokens",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",