@camstack/core 0.1.20 → 0.1.21
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/auth/auth-manager.d.ts +1 -16
- package/dist/auth/auth-manager.d.ts.map +1 -1
- package/dist/builtins/local-auth/local-auth.addon.d.ts.map +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +1 -23
- package/dist/builtins/local-auth/local-auth.addon.js.map +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +1 -23
- package/dist/builtins/local-auth/local-auth.addon.mjs.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ScopedTokenManager } from './scoped-token-manager.js';
|
|
1
|
+
import { UserRole, TokenPayload, IScopedLogger } from '@camstack/types';
|
|
3
2
|
export type { UserRole, TokenPayload };
|
|
4
3
|
export type AuthConfigReader = {
|
|
5
4
|
get<T>(path: string): T;
|
|
@@ -8,7 +7,6 @@ export type AuthConfigReader = {
|
|
|
8
7
|
export declare class AuthManager {
|
|
9
8
|
private readonly config;
|
|
10
9
|
private readonly jwtSecret;
|
|
11
|
-
private scopedTokenManager;
|
|
12
10
|
private readonly logger;
|
|
13
11
|
constructor(config: AuthConfigReader, logger?: IScopedLogger);
|
|
14
12
|
signToken(payload: Omit<TokenPayload, 'iat' | 'exp'>): string;
|
|
@@ -30,18 +28,5 @@ export declare class AuthManager {
|
|
|
30
28
|
readonly role?: string;
|
|
31
29
|
readonly expiresIn?: string;
|
|
32
30
|
}): string;
|
|
33
|
-
/**
|
|
34
|
-
* Set the scoped token manager for the auth chain.
|
|
35
|
-
*/
|
|
36
|
-
setScopedTokenManager(manager: ScopedTokenManager): void;
|
|
37
|
-
/**
|
|
38
|
-
* Validate a scoped token string.
|
|
39
|
-
* Returns the token record if valid, null otherwise.
|
|
40
|
-
*/
|
|
41
|
-
validateScopedToken(rawToken: string): Promise<ScopedToken | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Check whether a scoped token grants access to a given addon/route/capability.
|
|
44
|
-
*/
|
|
45
|
-
matchesScopedTokenScope(token: ScopedToken, addonId?: string, routePath?: string, capability?: string): boolean;
|
|
46
31
|
}
|
|
47
32
|
//# sourceMappingURL=auth-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../src/auth/auth-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../../src/auth/auth-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAY5E,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA;AAEtC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAA;IACvB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC7D,CAAA;AAED,qBAAa,WAAW;IAIV,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAET,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAE,aAA0B;IAczF,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,GAAG,KAAK,CAAC,GAAG,MAAM;IAI7D,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY;IAIlC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/C,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvE,cAAc,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAOjE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;IAK1D;;;OAGG;IACH,kBAAkB,CAAC,IAAI,EAAE;QACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;QACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAC5B,GAAG,MAAM;CAmBX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-auth.addon.d.ts","sourceRoot":"","sources":["../../../src/builtins/local-auth/local-auth.addon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAA2B,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,EAAE,SAAS,EAAoD,MAAM,iBAAiB,CAAA;AA4B7F,UAAU,eAAe;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,qBAAa,cAAe,SAAQ,SAAS,CAAC,eAAe,CAAC;IAC5D,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,kBAAkB,CAAkC;;cAI5C,YAAY,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"local-auth.addon.d.ts","sourceRoot":"","sources":["../../../src/builtins/local-auth/local-auth.addon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAA2B,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,EAAE,SAAS,EAAoD,MAAM,iBAAiB,CAAA;AA4B7F,UAAU,eAAe;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,qBAAa,cAAe,SAAQ,SAAS,CAAC,eAAe,CAAC;IAC5D,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,kBAAkB,CAAkC;;cAI5C,YAAY,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;cA8L/C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAM5C;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -6166,7 +6166,6 @@ var noopLogger = {
|
|
|
6166
6166
|
};
|
|
6167
6167
|
var AuthManager = class {
|
|
6168
6168
|
jwtSecret;
|
|
6169
|
-
scopedTokenManager = null;
|
|
6170
6169
|
logger;
|
|
6171
6170
|
constructor(config, logger = noopLogger) {
|
|
6172
6171
|
this.config = config;
|
|
@@ -6220,27 +6219,6 @@ var AuthManager = class {
|
|
|
6220
6219
|
const expiresIn = opts.expiresIn ?? "24h";
|
|
6221
6220
|
return import_jsonwebtoken.sign(payload, this.jwtSecret, { expiresIn });
|
|
6222
6221
|
}
|
|
6223
|
-
/**
|
|
6224
|
-
* Set the scoped token manager for the auth chain.
|
|
6225
|
-
*/
|
|
6226
|
-
setScopedTokenManager(manager) {
|
|
6227
|
-
this.scopedTokenManager = manager;
|
|
6228
|
-
}
|
|
6229
|
-
/**
|
|
6230
|
-
* Validate a scoped token string.
|
|
6231
|
-
* Returns the token record if valid, null otherwise.
|
|
6232
|
-
*/
|
|
6233
|
-
async validateScopedToken(rawToken) {
|
|
6234
|
-
if (!this.scopedTokenManager) return null;
|
|
6235
|
-
return this.scopedTokenManager.validate(rawToken);
|
|
6236
|
-
}
|
|
6237
|
-
/**
|
|
6238
|
-
* Check whether a scoped token grants access to a given addon/route/capability.
|
|
6239
|
-
*/
|
|
6240
|
-
matchesScopedTokenScope(token, addonId, routePath, capability) {
|
|
6241
|
-
if (!this.scopedTokenManager) return false;
|
|
6242
|
-
return this.scopedTokenManager.matchesScope(token, addonId, routePath, capability);
|
|
6243
|
-
}
|
|
6244
6222
|
};
|
|
6245
6223
|
//#endregion
|
|
6246
6224
|
//#region src/auth/parse-record.ts
|
|
@@ -6848,7 +6826,7 @@ var LocalAuthAddon = class extends _camstack_types.BaseAddon {
|
|
|
6848
6826
|
},
|
|
6849
6827
|
createScopedToken: async (input) => {
|
|
6850
6828
|
if (!this.scopedTokenManager) throw new Error("Scoped token management not available");
|
|
6851
|
-
const { token, record } = await this.scopedTokenManager.create(
|
|
6829
|
+
const { token, record } = await this.scopedTokenManager.create(input.userId, input.name, input.scopes, input.expiresAt);
|
|
6852
6830
|
return {
|
|
6853
6831
|
token,
|
|
6854
6832
|
record
|