@mxtommy/kip 4.5.2 → 4.6.0-beta.2
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/package.json +1 -3
- package/plugin/history-series.service.js +14 -24
- package/plugin/index.js +139 -95
- package/plugin/{duckdb-parquet-storage.service.js → sqlite-history-storage.service.js} +330 -503
- package/public/{chunk-KQEEYPK3.js → chunk-BEQKBGLG.js} +1 -1
- package/public/{chunk-CD5TQSCS.js → chunk-BJEHRCYP.js} +1 -1
- package/public/{chunk-IH4CEW4C.js → chunk-FZSLNGBK.js} +8 -8
- package/public/{chunk-VXTTEFRP.js → chunk-J6EEFXKZ.js} +1 -1
- package/public/{chunk-I4SJ5UNN.js → chunk-KWTS7JF7.js} +1 -1
- package/public/{chunk-ISF5E3CX.js → chunk-RFNZ4AQG.js} +1 -1
- package/public/index.html +1 -1
- package/public/{main-B6TXB3EB.js → main-TZOV3JCT.js} +1 -1
- package/plugin/plugin-auth.service.js +0 -75
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeUserScope = normalizeUserScope;
|
|
4
|
-
exports.resolveAuthenticatedUserScope = resolveAuthenticatedUserScope;
|
|
5
|
-
exports.resolveReadUserScope = resolveReadUserScope;
|
|
6
|
-
exports.resolveWriteUserScopeOrReject = resolveWriteUserScopeOrReject;
|
|
7
|
-
/**
|
|
8
|
-
* Normalizes a candidate user scope value.
|
|
9
|
-
*
|
|
10
|
-
* @param {unknown} value Candidate scope value.
|
|
11
|
-
* @returns {string | null} Trimmed scope or null when empty.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* const scope = normalizeUserScope(' demo-user ');
|
|
15
|
-
*/
|
|
16
|
-
function normalizeUserScope(value) {
|
|
17
|
-
const normalized = typeof value === 'string' ? value.trim() : '';
|
|
18
|
-
return normalized.length > 0 ? normalized : null;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Resolves authenticated user scope from request identity fields.
|
|
22
|
-
*
|
|
23
|
-
* @param {Request} req Incoming Express request.
|
|
24
|
-
* @returns {string | null} Resolved scope or null when unavailable.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* const scope = resolveAuthenticatedUserScope(req);
|
|
28
|
-
*/
|
|
29
|
-
function resolveAuthenticatedUserScope(req) {
|
|
30
|
-
// Check for skPrincipal.identifier as the primary method for authenticated scope resolution
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
const skPrincipal = req.skPrincipal;
|
|
33
|
-
if (skPrincipal && typeof skPrincipal === 'object') {
|
|
34
|
-
const skPrincipalId = normalizeUserScope(skPrincipal.identifier);
|
|
35
|
-
if (skPrincipalId) {
|
|
36
|
-
return skPrincipalId;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Resolves user scope for read operations, returning a fallback when unauthenticated.
|
|
43
|
-
*
|
|
44
|
-
* @param {Request} req Incoming Express request.
|
|
45
|
-
* @param {string} [fallback='anonymous'] Fallback scope value.
|
|
46
|
-
* @returns {string} Resolved or fallback scope.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* const scope = resolveReadUserScope(req);
|
|
50
|
-
*/
|
|
51
|
-
function resolveReadUserScope(req, fallback = 'anonymous') {
|
|
52
|
-
return resolveAuthenticatedUserScope(req) ?? fallback;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Resolves user scope for write operations and rejects the request when unresolved.
|
|
56
|
-
*
|
|
57
|
-
* @param {Request} req Incoming Express request.
|
|
58
|
-
* @param {Response} res Express response used for rejection.
|
|
59
|
-
* @param {string} operation Operation label for diagnostics.
|
|
60
|
-
* @param {(message: string) => void} errorLogger Logger callback for refusal messages.
|
|
61
|
-
* @param {TAuthFailureResponder} sendFail Response helper callback.
|
|
62
|
-
* @returns {string | null} Resolved scope or null when rejected.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* const scope = resolveWriteUserScopeOrReject(req, res, 'PUT /series/:seriesId', console.error, sendFail);
|
|
66
|
-
*/
|
|
67
|
-
function resolveWriteUserScopeOrReject(req, res, operation, errorLogger, sendFail) {
|
|
68
|
-
const userScope = resolveAuthenticatedUserScope(req);
|
|
69
|
-
if (userScope) {
|
|
70
|
-
return userScope;
|
|
71
|
-
}
|
|
72
|
-
errorLogger(`[SERIES AUTH] Refused ${operation}: unresolved authenticated user scope method=${req.method} path=${req.path} ip=${req.ip}`);
|
|
73
|
-
sendFail(res, 403, 'Authenticated user scope is required for series write operations');
|
|
74
|
-
return null;
|
|
75
|
-
}
|