@korajs/auth 1.0.0-beta.7 → 1.0.0-beta.9
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.cjs +11 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1239,6 +1239,17 @@ function createKoraAuthSync(options) {
|
|
|
1239
1239
|
}
|
|
1240
1240
|
return readDeviceIdFromClaims(claims);
|
|
1241
1241
|
};
|
|
1242
|
+
binding.resolveUserId = async () => {
|
|
1243
|
+
const token = await authClient.getAccessToken();
|
|
1244
|
+
if (!token) {
|
|
1245
|
+
return void 0;
|
|
1246
|
+
}
|
|
1247
|
+
const claims = decodeJwtPayload2(token);
|
|
1248
|
+
if (!claims || typeof claims.sub !== "string" || claims.sub.length === 0) {
|
|
1249
|
+
return void 0;
|
|
1250
|
+
}
|
|
1251
|
+
return claims.sub;
|
|
1252
|
+
};
|
|
1242
1253
|
if (authClient.onAuthChange) {
|
|
1243
1254
|
binding.subscribe = (listener) => authClient.onAuthChange?.(() => listener()) ?? (() => {
|
|
1244
1255
|
});
|