@schemavaults/jwt 0.13.13 → 0.14.0
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AppId } from "@schemavaults/app-definitions";
|
|
2
|
+
import { type UserData } from "@schemavaults/auth-common";
|
|
2
3
|
import type { CustomJWTPayload } from "./payload_data";
|
|
3
|
-
export declare function customJwtPayloadToUserData(payload: CustomJWTPayload): UserData;
|
|
4
|
+
export declare function customJwtPayloadToUserData(payload: CustomJWTPayload, auth_server_app_id?: AppId): UserData;
|
|
4
5
|
/**
|
|
5
6
|
* Extracts the granted scope claim from a decoded custom-JWT payload, to be
|
|
6
7
|
* carried alongside the UserData. Returns null when the token has no scope
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { getAuthServerAppId } from "@schemavaults/app-definitions";
|
|
2
|
+
import { formatOidcSubClaim } from "@schemavaults/auth-common";
|
|
1
3
|
// Maps a decoded custom-JWT payload to the canonical UserData. The token's
|
|
2
4
|
// granted `scope` is deliberately NOT folded in here — it is threaded
|
|
3
5
|
// ALONGSIDE the user data (see `getScopeFromCustomJwtPayload` and the
|
|
4
6
|
// `{ user, scope }` record in @schemavaults/auth-server-sdk's
|
|
5
7
|
// decodeJWTsWithKeyManager) so route guards can enforce `required_scopes`
|
|
6
8
|
// without polluting the user identity type.
|
|
7
|
-
|
|
9
|
+
//
|
|
10
|
+
// The token payload keeps `sub === uid` on the wire (resource servers on
|
|
11
|
+
// older SDKs verify that), while UserData.sub is the OIDC subject
|
|
12
|
+
// `<auth_server_app_id>|<uid>`, so the subject is rebuilt here from the uid.
|
|
13
|
+
export function customJwtPayloadToUserData(payload, auth_server_app_id = getAuthServerAppId()) {
|
|
8
14
|
return {
|
|
9
15
|
uid: payload.uid,
|
|
10
|
-
sub: payload.
|
|
16
|
+
sub: formatOidcSubClaim(auth_server_app_id, payload.uid),
|
|
11
17
|
email: payload.email,
|
|
12
18
|
email_verified: payload.email_verified,
|
|
13
19
|
admin: payload.admin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-jwt-payload-to-user-data.js","sourceRoot":"","sources":["../../src/jwt/custom-jwt-payload-to-user-data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-jwt-payload-to-user-data.js","sourceRoot":"","sources":["../../src/jwt/custom-jwt-payload-to-user-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAc,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAiB,MAAM,2BAA2B,CAAC;AAG9E,2EAA2E;AAC3E,sEAAsE;AACtE,sEAAsE;AACtE,8DAA8D;AAC9D,0EAA0E;AAC1E,4CAA4C;AAC5C,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,6EAA6E;AAC7E,MAAM,UAAU,0BAA0B,CACxC,OAAyB,EACzB,qBAA4B,kBAAkB,EAAE;IAEhD,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE,kBAAkB,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,CAAC;QACxD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,GAAG,CAAC,OAAO,CAAC,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAyB;IAEzB,OAAO,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAClE,CAAC,CAAC,OAAO,CAAC,KAAK;QACf,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemavaults/jwt",
|
|
3
3
|
"description": "Utility functions for authentication and authorization for use from the auth server or a resource server",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"zod": "4.4.3",
|
|
18
18
|
"jose": "6.1.3",
|
|
19
|
-
"@schemavaults/auth-common": "0.
|
|
19
|
+
"@schemavaults/auth-common": "0.31.0",
|
|
20
20
|
"@schemavaults/app-definitions": "0.14.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|