@camstack/system 1.2.412 → 1.2.414
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/scoped-token-manager.d.ts +5 -1
- package/dist/auth/user-management-internal.d.ts +16 -0
- package/dist/builtins/local-auth/local-auth.addon.js +31 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +31 -1
- package/dist/builtins/local-auth/oauth-session-manager.d.ts +6 -0
- package/package.json +1 -1
|
@@ -18,7 +18,11 @@ export declare class ScopedTokenManager {
|
|
|
18
18
|
* `protectedProcedure`.
|
|
19
19
|
*/
|
|
20
20
|
matchesScope(token: ScopedToken, addonId?: string, capability?: string): boolean;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Delete the token row. `true` when a row was removed; `false` when the id
|
|
23
|
+
* was already gone (unknown or previously revoked).
|
|
24
|
+
*/
|
|
25
|
+
revoke(tokenId: string): Promise<boolean>;
|
|
22
26
|
listForUser(userId: string): Promise<ScopedToken[]>;
|
|
23
27
|
updateLastUsed(tokenId: string): Promise<void>;
|
|
24
28
|
/**
|
|
@@ -51,9 +51,25 @@ export interface UserManagementInternal {
|
|
|
51
51
|
setPassword(input: SetPasswordInput): Promise<void>;
|
|
52
52
|
/** Admin tokens (`csa_`) — the hub router gates creation (admin + re-auth). */
|
|
53
53
|
readonly adminTokens: AdminTokensInternal;
|
|
54
|
+
/**
|
|
55
|
+
* Scoped tokens (`cst_`) — hub bulk revoke (`auth.revokeCredentials`).
|
|
56
|
+
* `revoke` deletes the row; `false` when the id was already gone.
|
|
57
|
+
*/
|
|
58
|
+
readonly scopedTokens: ScopedTokensInternal;
|
|
59
|
+
/**
|
|
60
|
+
* OAuth account-link sessions — hub bulk revoke. Active → mark revoked;
|
|
61
|
+
* already revoked → delete the row (so "Remove revoked" clears the list).
|
|
62
|
+
*/
|
|
63
|
+
readonly oauthSessions: OauthSessionsInternal;
|
|
54
64
|
/** The authentication audit trail. */
|
|
55
65
|
readonly audit: AuthAuditInternal;
|
|
56
66
|
}
|
|
67
|
+
export interface ScopedTokensInternal {
|
|
68
|
+
revoke(id: string): Promise<boolean>;
|
|
69
|
+
}
|
|
70
|
+
export interface OauthSessionsInternal {
|
|
71
|
+
revoke(id: string): Promise<boolean>;
|
|
72
|
+
}
|
|
57
73
|
export interface AdminTokensInternal {
|
|
58
74
|
create(input: {
|
|
59
75
|
readonly createdBy: string;
|
|
@@ -6349,11 +6349,20 @@ var ScopedTokenManager = class {
|
|
|
6349
6349
|
}
|
|
6350
6350
|
return false;
|
|
6351
6351
|
}
|
|
6352
|
+
/**
|
|
6353
|
+
* Delete the token row. `true` when a row was removed; `false` when the id
|
|
6354
|
+
* was already gone (unknown or previously revoked).
|
|
6355
|
+
*/
|
|
6352
6356
|
async revoke(tokenId) {
|
|
6357
|
+
if ((await this.store.query.query({
|
|
6358
|
+
collection: TOKENS_COLLECTION,
|
|
6359
|
+
filter: { where: { id: tokenId } }
|
|
6360
|
+
})).length === 0) return false;
|
|
6353
6361
|
await this.store.delete.mutate({
|
|
6354
6362
|
collection: TOKENS_COLLECTION,
|
|
6355
6363
|
key: tokenId
|
|
6356
6364
|
});
|
|
6365
|
+
return true;
|
|
6357
6366
|
}
|
|
6358
6367
|
async listForUser(userId) {
|
|
6359
6368
|
return (await this.store.query.query({
|
|
@@ -10642,6 +10651,19 @@ var OauthSessionManager = class {
|
|
|
10642
10651
|
return true;
|
|
10643
10652
|
}
|
|
10644
10653
|
/**
|
|
10654
|
+
* Delete one session row. Used by hub bulk revoke when the link is already
|
|
10655
|
+
* revoked ("Remove revoked"): absence fails closed the same way as a
|
|
10656
|
+
* revoked row, so dropping it only clears the list.
|
|
10657
|
+
*/
|
|
10658
|
+
async remove(id) {
|
|
10659
|
+
if (await this.getById(id) === null) return false;
|
|
10660
|
+
await this.store.delete.mutate({
|
|
10661
|
+
collection: SESSIONS_COLLECTION,
|
|
10662
|
+
key: id
|
|
10663
|
+
});
|
|
10664
|
+
return true;
|
|
10665
|
+
}
|
|
10666
|
+
/**
|
|
10645
10667
|
* Delete sessions revoked longer ago than `horizonMs`.
|
|
10646
10668
|
*
|
|
10647
10669
|
* Safe because an ABSENT session already fails closed exactly like a revoked
|
|
@@ -10900,7 +10922,7 @@ var LocalAuthAddon = class extends require_dist.BaseAddon {
|
|
|
10900
10922
|
},
|
|
10901
10923
|
revokeScopedToken: async (input) => {
|
|
10902
10924
|
if (!this.scopedTokenManager) throw new Error("Scoped token management not available");
|
|
10903
|
-
await this.scopedTokenManager.revoke(input.id);
|
|
10925
|
+
if (!await this.scopedTokenManager.revoke(input.id)) throw new Error(`Scoped token not found: ${input.id}`);
|
|
10904
10926
|
return { success: true };
|
|
10905
10927
|
},
|
|
10906
10928
|
validateScopedToken: async (input) => {
|
|
@@ -11032,6 +11054,14 @@ var LocalAuthAddon = class extends require_dist.BaseAddon {
|
|
|
11032
11054
|
list: async () => this.adminTokens === null ? [] : this.adminTokens.list(),
|
|
11033
11055
|
revoke: async (id) => this.adminTokens === null ? false : this.adminTokens.revoke(id)
|
|
11034
11056
|
},
|
|
11057
|
+
scopedTokens: { revoke: async (id) => this.scopedTokenManager === null ? false : this.scopedTokenManager.revoke(id) },
|
|
11058
|
+
oauthSessions: { revoke: async (id) => {
|
|
11059
|
+
if (this.oauthSessionManager === null) return false;
|
|
11060
|
+
const session = await this.oauthSessionManager.getById(id);
|
|
11061
|
+
if (session === null) return false;
|
|
11062
|
+
if (session.revokedAt !== null) return this.oauthSessionManager.remove(id);
|
|
11063
|
+
return this.oauthSessionManager.markRevoked(id);
|
|
11064
|
+
} },
|
|
11035
11065
|
audit: {
|
|
11036
11066
|
record: async (event) => {
|
|
11037
11067
|
await this.auditLog?.record(event);
|
|
@@ -6339,11 +6339,20 @@ var ScopedTokenManager = class {
|
|
|
6339
6339
|
}
|
|
6340
6340
|
return false;
|
|
6341
6341
|
}
|
|
6342
|
+
/**
|
|
6343
|
+
* Delete the token row. `true` when a row was removed; `false` when the id
|
|
6344
|
+
* was already gone (unknown or previously revoked).
|
|
6345
|
+
*/
|
|
6342
6346
|
async revoke(tokenId) {
|
|
6347
|
+
if ((await this.store.query.query({
|
|
6348
|
+
collection: TOKENS_COLLECTION,
|
|
6349
|
+
filter: { where: { id: tokenId } }
|
|
6350
|
+
})).length === 0) return false;
|
|
6343
6351
|
await this.store.delete.mutate({
|
|
6344
6352
|
collection: TOKENS_COLLECTION,
|
|
6345
6353
|
key: tokenId
|
|
6346
6354
|
});
|
|
6355
|
+
return true;
|
|
6347
6356
|
}
|
|
6348
6357
|
async listForUser(userId) {
|
|
6349
6358
|
return (await this.store.query.query({
|
|
@@ -10632,6 +10641,19 @@ var OauthSessionManager = class {
|
|
|
10632
10641
|
return true;
|
|
10633
10642
|
}
|
|
10634
10643
|
/**
|
|
10644
|
+
* Delete one session row. Used by hub bulk revoke when the link is already
|
|
10645
|
+
* revoked ("Remove revoked"): absence fails closed the same way as a
|
|
10646
|
+
* revoked row, so dropping it only clears the list.
|
|
10647
|
+
*/
|
|
10648
|
+
async remove(id) {
|
|
10649
|
+
if (await this.getById(id) === null) return false;
|
|
10650
|
+
await this.store.delete.mutate({
|
|
10651
|
+
collection: SESSIONS_COLLECTION,
|
|
10652
|
+
key: id
|
|
10653
|
+
});
|
|
10654
|
+
return true;
|
|
10655
|
+
}
|
|
10656
|
+
/**
|
|
10635
10657
|
* Delete sessions revoked longer ago than `horizonMs`.
|
|
10636
10658
|
*
|
|
10637
10659
|
* Safe because an ABSENT session already fails closed exactly like a revoked
|
|
@@ -10890,7 +10912,7 @@ var LocalAuthAddon = class extends BaseAddon {
|
|
|
10890
10912
|
},
|
|
10891
10913
|
revokeScopedToken: async (input) => {
|
|
10892
10914
|
if (!this.scopedTokenManager) throw new Error("Scoped token management not available");
|
|
10893
|
-
await this.scopedTokenManager.revoke(input.id);
|
|
10915
|
+
if (!await this.scopedTokenManager.revoke(input.id)) throw new Error(`Scoped token not found: ${input.id}`);
|
|
10894
10916
|
return { success: true };
|
|
10895
10917
|
},
|
|
10896
10918
|
validateScopedToken: async (input) => {
|
|
@@ -11022,6 +11044,14 @@ var LocalAuthAddon = class extends BaseAddon {
|
|
|
11022
11044
|
list: async () => this.adminTokens === null ? [] : this.adminTokens.list(),
|
|
11023
11045
|
revoke: async (id) => this.adminTokens === null ? false : this.adminTokens.revoke(id)
|
|
11024
11046
|
},
|
|
11047
|
+
scopedTokens: { revoke: async (id) => this.scopedTokenManager === null ? false : this.scopedTokenManager.revoke(id) },
|
|
11048
|
+
oauthSessions: { revoke: async (id) => {
|
|
11049
|
+
if (this.oauthSessionManager === null) return false;
|
|
11050
|
+
const session = await this.oauthSessionManager.getById(id);
|
|
11051
|
+
if (session === null) return false;
|
|
11052
|
+
if (session.revokedAt !== null) return this.oauthSessionManager.remove(id);
|
|
11053
|
+
return this.oauthSessionManager.markRevoked(id);
|
|
11054
|
+
} },
|
|
11025
11055
|
audit: {
|
|
11026
11056
|
record: async (event) => {
|
|
11027
11057
|
await this.auditLog?.record(event);
|
|
@@ -41,6 +41,12 @@ export declare class OauthSessionManager {
|
|
|
41
41
|
*/
|
|
42
42
|
markRevoked(id: string): Promise<boolean>;
|
|
43
43
|
/**
|
|
44
|
+
* Delete one session row. Used by hub bulk revoke when the link is already
|
|
45
|
+
* revoked ("Remove revoked"): absence fails closed the same way as a
|
|
46
|
+
* revoked row, so dropping it only clears the list.
|
|
47
|
+
*/
|
|
48
|
+
remove(id: string): Promise<boolean>;
|
|
49
|
+
/**
|
|
44
50
|
* Delete sessions revoked longer ago than `horizonMs`.
|
|
45
51
|
*
|
|
46
52
|
* Safe because an ABSENT session already fails closed exactly like a revoked
|