@decaf-ts/core 0.27.0 → 0.27.1
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/README.md +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/lib/cjs/auth/decorators.cjs +27 -30
- package/lib/cjs/auth/decorators.cjs.map +1 -1
- package/lib/cjs/index.cjs +3 -3
- package/lib/esm/auth/decorators.js +27 -30
- package/lib/esm/auth/decorators.js.map +1 -1
- package/lib/esm/index.js +3 -3
- package/lib/types/index.d.cts +3 -3
- package/lib/types/index.d.mts +3 -3
- package/package.json +1 -1
|
@@ -3,42 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.allowIf = allowIf;
|
|
4
4
|
exports.blockIf = blockIf;
|
|
5
5
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
6
|
+
const errors_js_1 = require("./../persistence/errors.cjs");
|
|
7
|
+
function ensureLogCtx(thisArg, decoratorName, methodName) {
|
|
8
|
+
if (typeof thisArg?.logCtx !== "function") {
|
|
9
|
+
const className = thisArg?.constructor?.name ?? "UnknownClass";
|
|
10
|
+
throw new errors_js_1.UnsupportedError(`${decoratorName} on ${className}.${methodName} requires a logCtx() method`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function createAuthProxy(decoratorName, handler, argz, propertyKey, descriptor) {
|
|
14
|
+
descriptor.value = new Proxy(descriptor.value, {
|
|
15
|
+
async apply(targetFn, thisArg, args) {
|
|
16
|
+
ensureLogCtx(thisArg, decoratorName, String(propertyKey));
|
|
17
|
+
const { ctx, ctxArgs } = await thisArg.logCtx(args, targetFn.name, true);
|
|
18
|
+
let error;
|
|
19
|
+
try {
|
|
20
|
+
error = handler(...args, ...argz, ctx);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new db_decorators_1.InternalError(`Failed to execute auth validation handler: ${e}`);
|
|
24
|
+
}
|
|
25
|
+
if (error)
|
|
26
|
+
throw error;
|
|
27
|
+
return targetFn.call(thisArg, ...ctxArgs);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
6
31
|
function allowIf(handler, ...argz) {
|
|
7
32
|
return function allowIf(target, propertyKey, descriptor) {
|
|
8
|
-
|
|
9
|
-
async apply(target, thisArg, args) {
|
|
10
|
-
const { ctx, ctxArgs } = await thisArg["logCtx"](args, target.name, true);
|
|
11
|
-
let error;
|
|
12
|
-
try {
|
|
13
|
-
error = handler(...args, ...argz, ctx);
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
throw new db_decorators_1.InternalError(`Failed to execute auth validation handler: ${e}`);
|
|
17
|
-
}
|
|
18
|
-
if (error)
|
|
19
|
-
throw error;
|
|
20
|
-
return target.call(thisArg, ...ctxArgs);
|
|
21
|
-
},
|
|
22
|
-
});
|
|
33
|
+
createAuthProxy("allowIf", handler, argz, propertyKey, descriptor);
|
|
23
34
|
};
|
|
24
35
|
}
|
|
25
36
|
function blockIf(handler, ...argz) {
|
|
26
37
|
return function blockIf(target, propertyKey, descriptor) {
|
|
27
|
-
|
|
28
|
-
async apply(target, thisArg, args) {
|
|
29
|
-
const { ctx, ctxArgs } = await thisArg["logCtx"](args, target.name, true);
|
|
30
|
-
let error;
|
|
31
|
-
try {
|
|
32
|
-
error = handler(...args, ...argz, ctx);
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
throw new db_decorators_1.InternalError(`Failed to execute auth validation handler: ${e}`);
|
|
36
|
-
}
|
|
37
|
-
if (error)
|
|
38
|
-
throw error;
|
|
39
|
-
return target.call(thisArg, ...ctxArgs);
|
|
40
|
-
},
|
|
41
|
-
});
|
|
38
|
+
createAuthProxy("blockIf", handler, argz, propertyKey, descriptor);
|
|
42
39
|
};
|
|
43
40
|
}
|
|
44
41
|
//# sourceMappingURL=decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["decorators.js"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["decorators.js"],"names":[],"mappings":";;AA0BA,0BAIC;AACD,0BAIC;AAnCD,2DAAwD;AACxD,0DAA8D;AAC9D,SAAS,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU;IACpD,IAAI,OAAO,OAAO,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,IAAI,cAAc,CAAC;QAC/D,MAAM,IAAI,4BAAgB,CAAC,GAAG,aAAa,OAAO,SAAS,IAAI,UAAU,6BAA6B,CAAC,CAAC;IAC5G,CAAC;AACL,CAAC;AACD,SAAS,eAAe,CAAC,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU;IAC1E,UAAU,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE;QAC3C,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI;YAC/B,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;YAC1D,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACzE,IAAI,KAAK,CAAC;YACV,IAAI,CAAC;gBACD,KAAK,GAAG,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,CAAC,EAAE,CAAC;gBACP,MAAM,IAAI,6BAAa,CAAC,8CAA8C,CAAC,EAAE,CAAC,CAAC;YAC/E,CAAC;YACD,IAAI,KAAK;gBACL,MAAM,KAAK,CAAC;YAChB,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;QAC9C,CAAC;KACJ,CAAC,CAAC;AACP,CAAC;AACD,SAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI;IACpC,OAAO,SAAS,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU;QACnD,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC,CAAC;AACN,CAAC;AACD,SAAgB,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI;IACpC,OAAO,SAAS,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU;QACnD,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC,CAAC;AACN,CAAC;AACD,sCAAsC"}
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -50,21 +50,21 @@ __exportStar(require("./persistence/index.cjs"), exports);
|
|
|
50
50
|
* @const VERSION
|
|
51
51
|
* @memberOf module:core
|
|
52
52
|
*/
|
|
53
|
-
exports.VERSION = "0.
|
|
53
|
+
exports.VERSION = "0.27.0";
|
|
54
54
|
/**
|
|
55
55
|
* @description Represents the current commit hash of the module build.
|
|
56
56
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
57
57
|
* the placeholder with the actual commit hash at publish time.
|
|
58
58
|
* @const COMMIT
|
|
59
59
|
*/
|
|
60
|
-
exports.COMMIT = "
|
|
60
|
+
exports.COMMIT = "ad6f037";
|
|
61
61
|
/**
|
|
62
62
|
* @description Represents the full version string of the module.
|
|
63
63
|
* @summary Stores the semver version and commit hash for the package.
|
|
64
64
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
65
65
|
* @const FULL_VERSION
|
|
66
66
|
*/
|
|
67
|
-
exports.FULL_VERSION = "0.
|
|
67
|
+
exports.FULL_VERSION = "0.27.0-ad6f037";
|
|
68
68
|
/**
|
|
69
69
|
* @description Stores the current package version
|
|
70
70
|
* @summary A constant representing the version of the core package
|
|
@@ -1,40 +1,37 @@
|
|
|
1
1
|
import { InternalError } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { UnsupportedError } from "./../persistence/errors.js";
|
|
3
|
+
function ensureLogCtx(thisArg, decoratorName, methodName) {
|
|
4
|
+
if (typeof thisArg?.logCtx !== "function") {
|
|
5
|
+
const className = thisArg?.constructor?.name ?? "UnknownClass";
|
|
6
|
+
throw new UnsupportedError(`${decoratorName} on ${className}.${methodName} requires a logCtx() method`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function createAuthProxy(decoratorName, handler, argz, propertyKey, descriptor) {
|
|
10
|
+
descriptor.value = new Proxy(descriptor.value, {
|
|
11
|
+
async apply(targetFn, thisArg, args) {
|
|
12
|
+
ensureLogCtx(thisArg, decoratorName, String(propertyKey));
|
|
13
|
+
const { ctx, ctxArgs } = await thisArg.logCtx(args, targetFn.name, true);
|
|
14
|
+
let error;
|
|
15
|
+
try {
|
|
16
|
+
error = handler(...args, ...argz, ctx);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
throw new InternalError(`Failed to execute auth validation handler: ${e}`);
|
|
20
|
+
}
|
|
21
|
+
if (error)
|
|
22
|
+
throw error;
|
|
23
|
+
return targetFn.call(thisArg, ...ctxArgs);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
2
27
|
export function allowIf(handler, ...argz) {
|
|
3
28
|
return function allowIf(target, propertyKey, descriptor) {
|
|
4
|
-
|
|
5
|
-
async apply(target, thisArg, args) {
|
|
6
|
-
const { ctx, ctxArgs } = await thisArg["logCtx"](args, target.name, true);
|
|
7
|
-
let error;
|
|
8
|
-
try {
|
|
9
|
-
error = handler(...args, ...argz, ctx);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
throw new InternalError(`Failed to execute auth validation handler: ${e}`);
|
|
13
|
-
}
|
|
14
|
-
if (error)
|
|
15
|
-
throw error;
|
|
16
|
-
return target.call(thisArg, ...ctxArgs);
|
|
17
|
-
},
|
|
18
|
-
});
|
|
29
|
+
createAuthProxy("allowIf", handler, argz, propertyKey, descriptor);
|
|
19
30
|
};
|
|
20
31
|
}
|
|
21
32
|
export function blockIf(handler, ...argz) {
|
|
22
33
|
return function blockIf(target, propertyKey, descriptor) {
|
|
23
|
-
|
|
24
|
-
async apply(target, thisArg, args) {
|
|
25
|
-
const { ctx, ctxArgs } = await thisArg["logCtx"](args, target.name, true);
|
|
26
|
-
let error;
|
|
27
|
-
try {
|
|
28
|
-
error = handler(...args, ...argz, ctx);
|
|
29
|
-
}
|
|
30
|
-
catch (e) {
|
|
31
|
-
throw new InternalError(`Failed to execute auth validation handler: ${e}`);
|
|
32
|
-
}
|
|
33
|
-
if (error)
|
|
34
|
-
throw error;
|
|
35
|
-
return target.call(thisArg, ...ctxArgs);
|
|
36
|
-
},
|
|
37
|
-
});
|
|
34
|
+
createAuthProxy("blockIf", handler, argz, propertyKey, descriptor);
|
|
38
35
|
};
|
|
39
36
|
}
|
|
40
37
|
//# sourceMappingURL=decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/auth/decorators.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/auth/decorators.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,mCAA8B;AAMzD,SAAS,YAAY,CACnB,OAA+C,EAC/C,aAAqB,EACrB,UAAkB;IAElB,IAAI,OAAQ,OAAe,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;QACnD,MAAM,SAAS,GACZ,OAAe,EAAE,WAAW,EAAE,IA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,EAAE,GAAG,IAAW;IAC1D,OAAO,SAAS,OAAO,CAAC,MAAc,EAAE,WAAiB,EAAE,UAAgB;QACzE,eAAe,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -33,21 +33,21 @@ export * from "./persistence/index.js";
|
|
|
33
33
|
* @const VERSION
|
|
34
34
|
* @memberOf module:core
|
|
35
35
|
*/
|
|
36
|
-
export const VERSION = "0.
|
|
36
|
+
export const VERSION = "0.27.0";
|
|
37
37
|
/**
|
|
38
38
|
* @description Represents the current commit hash of the module build.
|
|
39
39
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
40
40
|
* the placeholder with the actual commit hash at publish time.
|
|
41
41
|
* @const COMMIT
|
|
42
42
|
*/
|
|
43
|
-
export const COMMIT = "
|
|
43
|
+
export const COMMIT = "ad6f037";
|
|
44
44
|
/**
|
|
45
45
|
* @description Represents the full version string of the module.
|
|
46
46
|
* @summary Stores the semver version and commit hash for the package.
|
|
47
47
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
48
48
|
* @const FULL_VERSION
|
|
49
49
|
*/
|
|
50
|
-
export const FULL_VERSION = "0.
|
|
50
|
+
export const FULL_VERSION = "0.27.0-ad6f037";
|
|
51
51
|
/**
|
|
52
52
|
* @description Stores the current package version
|
|
53
53
|
* @summary A constant representing the version of the core package
|
package/lib/types/index.d.cts
CHANGED
|
@@ -24,21 +24,21 @@ export * from "./persistence/index.d.cts";
|
|
|
24
24
|
* @const VERSION
|
|
25
25
|
* @memberOf module:core
|
|
26
26
|
*/
|
|
27
|
-
export declare const VERSION = "0.
|
|
27
|
+
export declare const VERSION = "0.27.0";
|
|
28
28
|
/**
|
|
29
29
|
* @description Represents the current commit hash of the module build.
|
|
30
30
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
31
31
|
* the placeholder with the actual commit hash at publish time.
|
|
32
32
|
* @const COMMIT
|
|
33
33
|
*/
|
|
34
|
-
export declare const COMMIT = "
|
|
34
|
+
export declare const COMMIT = "ad6f037";
|
|
35
35
|
/**
|
|
36
36
|
* @description Represents the full version string of the module.
|
|
37
37
|
* @summary Stores the semver version and commit hash for the package.
|
|
38
38
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
39
39
|
* @const FULL_VERSION
|
|
40
40
|
*/
|
|
41
|
-
export declare const FULL_VERSION = "0.
|
|
41
|
+
export declare const FULL_VERSION = "0.27.0-ad6f037";
|
|
42
42
|
/**
|
|
43
43
|
* @description Stores the current package version
|
|
44
44
|
* @summary A constant representing the version of the core package
|
package/lib/types/index.d.mts
CHANGED
|
@@ -24,21 +24,21 @@ export * from "./persistence/index.d.mts";
|
|
|
24
24
|
* @const VERSION
|
|
25
25
|
* @memberOf module:core
|
|
26
26
|
*/
|
|
27
|
-
export declare const VERSION = "0.
|
|
27
|
+
export declare const VERSION = "0.27.0";
|
|
28
28
|
/**
|
|
29
29
|
* @description Represents the current commit hash of the module build.
|
|
30
30
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
31
31
|
* the placeholder with the actual commit hash at publish time.
|
|
32
32
|
* @const COMMIT
|
|
33
33
|
*/
|
|
34
|
-
export declare const COMMIT = "
|
|
34
|
+
export declare const COMMIT = "ad6f037";
|
|
35
35
|
/**
|
|
36
36
|
* @description Represents the full version string of the module.
|
|
37
37
|
* @summary Stores the semver version and commit hash for the package.
|
|
38
38
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
39
39
|
* @const FULL_VERSION
|
|
40
40
|
*/
|
|
41
|
-
export declare const FULL_VERSION = "0.
|
|
41
|
+
export declare const FULL_VERSION = "0.27.0-ad6f037";
|
|
42
42
|
/**
|
|
43
43
|
* @description Stores the current package version
|
|
44
44
|
* @summary A constant representing the version of the core package
|