@axium/core 0.10.0 → 0.11.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.
- package/dist/access.d.ts +17 -1
- package/dist/access.js +3 -2
- package/dist/api.d.ts +3 -5
- package/dist/node/plugins.js +9 -2
- package/package.json +1 -1
package/dist/access.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
1
2
|
import type { User } from './user.js';
|
|
2
3
|
export interface AccessControl {
|
|
3
4
|
itemId: string;
|
|
@@ -13,7 +14,7 @@ declare const _Permission: {
|
|
|
13
14
|
readonly Edit: 3;
|
|
14
15
|
readonly Manage: 5;
|
|
15
16
|
};
|
|
16
|
-
export declare const Permission:
|
|
17
|
+
export declare const Permission: z.ZodEnum<{
|
|
17
18
|
readonly None: 0;
|
|
18
19
|
readonly Read: 1;
|
|
19
20
|
readonly Comment: 2;
|
|
@@ -39,5 +40,20 @@ export interface AccessControllable {
|
|
|
39
40
|
publicPermission: Permission;
|
|
40
41
|
acl?: AccessControl[];
|
|
41
42
|
}
|
|
43
|
+
export declare const AccessMap: z.ZodRecord<z.ZodUnion<readonly [z.ZodUUID, z.ZodLiteral<"public">]>, z.ZodEnum<{
|
|
44
|
+
readonly None: 0;
|
|
45
|
+
readonly Read: 1;
|
|
46
|
+
readonly Comment: 2;
|
|
47
|
+
readonly Edit: 3;
|
|
48
|
+
readonly Manage: 5;
|
|
49
|
+
}> & {
|
|
50
|
+
readonly None: 0;
|
|
51
|
+
readonly Read: 1;
|
|
52
|
+
readonly Comment: 2;
|
|
53
|
+
readonly Edit: 3;
|
|
54
|
+
readonly Manage: 5;
|
|
55
|
+
}>;
|
|
56
|
+
export interface AccessMap extends z.infer<typeof AccessMap> {
|
|
57
|
+
}
|
|
42
58
|
export declare function hasPermission(item: AccessControllable, userId: string | undefined, permission: Permission): boolean;
|
|
43
59
|
export {};
|
package/dist/access.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from 'zod';
|
|
2
2
|
const _Permission = {
|
|
3
3
|
None: 0,
|
|
4
4
|
Read: 1,
|
|
@@ -6,7 +6,7 @@ const _Permission = {
|
|
|
6
6
|
Edit: 3,
|
|
7
7
|
Manage: 5,
|
|
8
8
|
};
|
|
9
|
-
export const Permission = Object.assign(
|
|
9
|
+
export const Permission = Object.assign(z.enum(_Permission), _Permission);
|
|
10
10
|
export const permissionNames = {
|
|
11
11
|
[Permission.None]: 'No Permissions',
|
|
12
12
|
[Permission.Read]: 'Reader',
|
|
@@ -14,6 +14,7 @@ export const permissionNames = {
|
|
|
14
14
|
[Permission.Edit]: 'Editor',
|
|
15
15
|
[Permission.Manage]: 'Manager',
|
|
16
16
|
};
|
|
17
|
+
export const AccessMap = z.record(z.union([z.uuid(), z.literal('public')]), Permission);
|
|
17
18
|
export function hasPermission(item, userId, permission) {
|
|
18
19
|
if (item.publicPermission >= permission)
|
|
19
20
|
return true;
|
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
|
|
2
2
|
import type z from 'zod';
|
|
3
|
-
import type { AccessControl } from './access.js';
|
|
3
|
+
import type { AccessControl, AccessMap } from './access.js';
|
|
4
4
|
import type { App } from './apps.js';
|
|
5
5
|
import type { AuditEvent, AuditFilter, Severity } from './audit.js';
|
|
6
6
|
import type { NewSessionResponse, Session, Verification } from './auth.js';
|
|
@@ -94,10 +94,8 @@ export interface $API {
|
|
|
94
94
|
}];
|
|
95
95
|
};
|
|
96
96
|
'acl/:itemType/:itemId': {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
permission: number;
|
|
100
|
-
}, AccessControl];
|
|
97
|
+
GET: AccessControl[];
|
|
98
|
+
POST: [AccessMap, AccessControl[]];
|
|
101
99
|
};
|
|
102
100
|
'admin/summary': {
|
|
103
101
|
GET: AdminSummary;
|
package/dist/node/plugins.js
CHANGED
|
@@ -20,8 +20,14 @@ export function* pluginText(plugin) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
function _locatePlugin(specifier, _loadedBy) {
|
|
23
|
-
if (specifier[0] == '/' ||
|
|
24
|
-
|
|
23
|
+
if (specifier[0] == '/' || ['.', '..'].includes(specifier.split('/')[0])) {
|
|
24
|
+
const path = resolve(dirname(_loadedBy), specifier);
|
|
25
|
+
const stats = fs.statSync(path);
|
|
26
|
+
if (stats.isFile())
|
|
27
|
+
return path;
|
|
28
|
+
if (!stats.isDirectory())
|
|
29
|
+
throw new Error('Can not resolve plugin path: ' + path);
|
|
30
|
+
return join(path, 'package.json');
|
|
25
31
|
}
|
|
26
32
|
let packageDir = dirname(fileURLToPath(import.meta.resolve(specifier)));
|
|
27
33
|
for (; !fs.existsSync(join(packageDir, 'package.json')); packageDir = dirname(packageDir))
|
|
@@ -31,6 +37,7 @@ function _locatePlugin(specifier, _loadedBy) {
|
|
|
31
37
|
export async function loadPlugin(mode, specifier, _loadedBy, safeMode = false) {
|
|
32
38
|
try {
|
|
33
39
|
const path = _locatePlugin(specifier, _loadedBy);
|
|
40
|
+
io.debug(`Loading plugin at ${path} (from ${_loadedBy})`);
|
|
34
41
|
let imported;
|
|
35
42
|
try {
|
|
36
43
|
imported = JSON.parse(fs.readFileSync(path, 'utf8'));
|