@korajs/auth 1.0.0-beta.0 → 1.0.0-beta.10

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
@@ -1039,6 +1039,17 @@ function createKoraAuthSync(options) {
1039
1039
  }
1040
1040
  return readDeviceIdFromClaims(claims);
1041
1041
  };
1042
+ binding.resolveUserId = async () => {
1043
+ const token = await authClient.getAccessToken();
1044
+ if (!token) {
1045
+ return void 0;
1046
+ }
1047
+ const claims = decodeJwtPayload2(token);
1048
+ if (!claims || typeof claims.sub !== "string" || claims.sub.length === 0) {
1049
+ return void 0;
1050
+ }
1051
+ return claims.sub;
1052
+ };
1042
1053
  if (authClient.onAuthChange) {
1043
1054
  binding.subscribe = (listener) => authClient.onAuthChange?.(() => listener()) ?? (() => {
1044
1055
  });