@bigso/auth-sdk 0.5.6 → 0.5.7
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/browser/index.js +1 -1
- package/dist/chunk-BXRGCGYR.js +34 -0
- package/dist/node/index.cjs +1 -0
- package/dist/node/index.js +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/utils/jws.ts
|
|
2
|
+
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
3
|
+
async function verifySignedPayload(token, jwksUrl, expectedAudience) {
|
|
4
|
+
const JWKS = createRemoteJWKSet(new URL(jwksUrl));
|
|
5
|
+
const { payload } = await jwtVerify(token, JWKS, {
|
|
6
|
+
audience: expectedAudience
|
|
7
|
+
});
|
|
8
|
+
return payload;
|
|
9
|
+
}
|
|
10
|
+
async function verifyAccessToken(accessToken, jwksUrl) {
|
|
11
|
+
const JWKS = createRemoteJWKSet(new URL(jwksUrl));
|
|
12
|
+
const { payload } = await jwtVerify(accessToken, JWKS);
|
|
13
|
+
if (!payload.sub || !payload.jti) {
|
|
14
|
+
throw new Error("Invalid token structure: missing sub or jti");
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
sub: payload.sub,
|
|
18
|
+
jti: payload.jti,
|
|
19
|
+
iss: payload.iss,
|
|
20
|
+
aud: payload.aud || "",
|
|
21
|
+
exp: payload.exp,
|
|
22
|
+
iat: payload.iat,
|
|
23
|
+
tenants: payload.tenants || [],
|
|
24
|
+
tenantId: payload.tenantId || "",
|
|
25
|
+
systemRole: payload.systemRole || "user",
|
|
26
|
+
scope: payload.scope,
|
|
27
|
+
deviceFingerprint: payload.deviceFingerprint
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
verifySignedPayload,
|
|
33
|
+
verifyAccessToken
|
|
34
|
+
};
|
package/dist/node/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ async function verifyAccessToken(accessToken, jwksUrl) {
|
|
|
47
47
|
exp: payload.exp,
|
|
48
48
|
iat: payload.iat,
|
|
49
49
|
tenants: payload.tenants || [],
|
|
50
|
+
tenantId: payload.tenantId || "",
|
|
50
51
|
systemRole: payload.systemRole || "user",
|
|
51
52
|
scope: payload.scope,
|
|
52
53
|
deviceFingerprint: payload.deviceFingerprint
|
package/dist/node/index.js
CHANGED