@jcdubs/janus 1.0.1 → 1.2.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.
Files changed (55) hide show
  1. package/README.md +156 -12
  2. package/dist/auth-lambda/auth-lambda.d.ts +2 -2
  3. package/dist/auth-lambda/auth-lambda.js +3 -3
  4. package/dist/auth-lambda/auth-lambda.js.map +1 -1
  5. package/dist/auth-lambda/index.d.ts +1 -1
  6. package/dist/authorization-middleware/authorization-middleware.d.ts +3 -3
  7. package/dist/authorization-middleware/authorization-middleware.js +5 -5
  8. package/dist/authorization-middleware/index.d.ts +1 -1
  9. package/dist/authorization-service/authorization-service.d.ts +4 -4
  10. package/dist/authorization-service/authorization-service.d.ts.map +1 -1
  11. package/dist/authorization-service/authorization-service.js +19 -19
  12. package/dist/authorization-service/authorization-service.js.map +1 -1
  13. package/dist/authorization-service/authorization-tests/config.d.ts +1 -1
  14. package/dist/authorization-service/authorization-tests/config.js +4 -4
  15. package/dist/authorization-service/authorization-tests/create-order-entity.d.ts +1 -1
  16. package/dist/authorization-service/authorization-tests/get-policy.js +2 -2
  17. package/dist/authorization-service/index.d.ts +2 -2
  18. package/dist/authorization-service/policy-parser.d.ts +1 -1
  19. package/dist/authorization-service/policy-parser.js +14 -14
  20. package/dist/entity-builder/entity-builder.d.ts +90 -0
  21. package/dist/entity-builder/entity-builder.d.ts.map +1 -0
  22. package/dist/entity-builder/entity-builder.js +159 -0
  23. package/dist/entity-builder/entity-builder.js.map +1 -0
  24. package/dist/entity-builder/index.d.ts +2 -0
  25. package/dist/entity-builder/index.d.ts.map +1 -0
  26. package/dist/entity-builder/index.js +18 -0
  27. package/dist/entity-builder/index.js.map +1 -0
  28. package/dist/errors/index.d.ts +6 -6
  29. package/dist/errors/missing-authenticated-user-details-error/index.d.ts +1 -1
  30. package/dist/errors/missing-authenticated-user-details-error/missing-authenticated-user-details-error.js +2 -2
  31. package/dist/errors/missing-authorization-action-error/index.d.ts +1 -1
  32. package/dist/errors/missing-authorization-action-error/missing-authorization-action-error.js +2 -2
  33. package/dist/errors/missing-authorization-policy-error/index.d.ts +1 -1
  34. package/dist/errors/missing-authorization-policy-error/missing-authorization-policy-error.js +2 -2
  35. package/dist/errors/missing-authorization-resource-error/index.d.ts +1 -1
  36. package/dist/errors/missing-authorization-resource-error/missing-authorization-resource-error.js +2 -2
  37. package/dist/errors/missing-authorization-schema-error/index.d.ts +1 -1
  38. package/dist/errors/missing-authorization-schema-error/missing-authorization-schema-error.js +2 -2
  39. package/dist/errors/unauthorized-error/index.d.ts +1 -1
  40. package/dist/errors/unauthorized-error/unauthorized-error.js +1 -1
  41. package/dist/file-loader/file-loader.js +1 -1
  42. package/dist/file-loader/index.d.ts +1 -1
  43. package/dist/index.d.ts +7 -5
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +2 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/setupTests.js +5 -5
  48. package/dist/types.d.ts +25 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +3 -0
  51. package/dist/types.js.map +1 -0
  52. package/dist/user-details/index.d.ts +1 -1
  53. package/dist/user-details/user-details-service.d.ts +1 -1
  54. package/dist/user-details/user-details-service.js +9 -9
  55. package/package.json +6 -4
@@ -0,0 +1,90 @@
1
+ import type { AuthorizationConfigType } from '../authorization-service/types';
2
+ import type { EntityJson } from '../types';
3
+ /**
4
+ * Builder for creating Cedar entity JSON objects used in authorization requests.
5
+ *
6
+ * The builder accumulates `uid`, `attrs`, `parents`, and optional `tags`, and
7
+ * returns a fully-formed `EntityJson` via `build()`.
8
+ */
9
+ export declare class EntityBuilder {
10
+ private uid;
11
+ private attrs;
12
+ private parents;
13
+ private tags?;
14
+ private authorizationConfig;
15
+ constructor(id: string, authorizationConfig: AuthorizationConfigType, type?: string);
16
+ /**
17
+ * Add an attribute that references another entity by UID.
18
+ *
19
+ * @param name - Attribute name to set on the entity.
20
+ * @param id - The id of the referenced entity.
21
+ * @param type - The resource type of the referenced entity.
22
+ * @returns The `EntityBuilder` for chaining.
23
+ */
24
+ withAttr(name: string, id: string, type: string): EntityBuilder;
25
+ /**
26
+ * Add an extension attribute (`__extn`) with a function and argument.
27
+ *
28
+ * @param name - Attribute name.
29
+ * @param fn - Extension function name.
30
+ * @param arg - Argument for the extension function.
31
+ * @returns The `EntityBuilder` for chaining.
32
+ */
33
+ withExtnAttr(name: string, fn: string, arg: string): EntityBuilder;
34
+ /**
35
+ * Add a boolean attribute.
36
+ *
37
+ * @param name - Attribute name.
38
+ * @param value - Boolean value to set.
39
+ * @returns The `EntityBuilder` for chaining.
40
+ */
41
+ withBooleanAttr(name: string, value: boolean): EntityBuilder;
42
+ /**
43
+ * Add a numeric attribute.
44
+ *
45
+ * @param name - Attribute name.
46
+ * @param value - Number value to set.
47
+ * @returns The `EntityBuilder` for chaining.
48
+ */
49
+ withNumberAttr(name: string, value: number): EntityBuilder;
50
+ /**
51
+ * Add a string attribute.
52
+ *
53
+ * @param name - Attribute name.
54
+ * @param value - String value to set.
55
+ * @returns The `EntityBuilder` for chaining.
56
+ */
57
+ withStringAttr(name: string, value: string): EntityBuilder;
58
+ /**
59
+ * Add a set attribute (array wrapped in `{ set: [...] }`).
60
+ *
61
+ * @param name - Attribute name.
62
+ * @param value - Array of string values for the set.
63
+ * @returns The `EntityBuilder` for chaining.
64
+ */
65
+ withSetAttr(name: string, value: string[]): EntityBuilder;
66
+ /**
67
+ * Add a parent relationship referencing another entity UID.
68
+ *
69
+ * @param id - Parent entity id.
70
+ * @param type - Parent entity resource type.
71
+ * @returns The `EntityBuilder` for chaining.
72
+ */
73
+ withParent(id: string, type: string): EntityBuilder;
74
+ /**
75
+ * Add a tag to the entity. Initializes the `tags` map lazily.
76
+ *
77
+ * @param name - Tag name.
78
+ * @param id - Tagged entity id.
79
+ * @param type - Optional resource type for the tagged entity.
80
+ * @returns The `EntityBuilder` for chaining.
81
+ */
82
+ withTag(name: string, id: string, type?: string): EntityBuilder;
83
+ /**
84
+ * Build and return the `EntityJson` object.
85
+ *
86
+ * @returns A complete `EntityJson` representation suitable for Cedar requests.
87
+ */
88
+ build(): EntityJson;
89
+ }
90
+ //# sourceMappingURL=entity-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-builder.d.ts","sourceRoot":"","sources":["../../src/entity-builder/entity-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAkB,UAAU,EAAiB,MAAM,UAAU,CAAC;AAE1E;;;;;GAKG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,GAAG,CAAgB;IAC3B,OAAO,CAAC,KAAK,CAAsC;IACnD,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,IAAI,CAAC,CAAiC;IAC9C,OAAO,CAAC,mBAAmB,CAA0B;gBAGpD,EAAE,EAAE,MAAM,EACV,mBAAmB,EAAE,uBAAuB,EAC5C,IAAI,GAAE,MAAyC;IAgBhD;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa;IAU/D;;;;;;;OAOG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa;IAUlE;;;;;;OAMG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa;IAK5D;;;;;;OAMG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa;IAK1D;;;;;;OAMG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa;IAK1D;;;;;;OAMG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa;IAKzD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa;IAUnD;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa;IAa/D;;;;OAIG;IACH,KAAK,IAAI,UAAU;CAWnB"}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityBuilder = void 0;
4
+ /**
5
+ * Builder for creating Cedar entity JSON objects used in authorization requests.
6
+ *
7
+ * The builder accumulates `uid`, `attrs`, `parents`, and optional `tags`, and
8
+ * returns a fully-formed `EntityJson` via `build()`.
9
+ */
10
+ class EntityBuilder {
11
+ constructor(id, authorizationConfig, type = authorizationConfig.resourceType) {
12
+ this.attrs = {};
13
+ this.parents = [];
14
+ /**
15
+ * Create a new `EntityBuilder`.
16
+ *
17
+ * @param id - The entity id portion of the UID.
18
+ * @param authorizationConfig - Authorization configuration providing namespace and defaults.
19
+ * @param type - Optional resource type (defaults to `authorizationConfig.resourceType`).
20
+ */
21
+ this.uid = {
22
+ type: `${authorizationConfig.namespace}${type}`,
23
+ id,
24
+ };
25
+ this.authorizationConfig = authorizationConfig;
26
+ }
27
+ /**
28
+ * Add an attribute that references another entity by UID.
29
+ *
30
+ * @param name - Attribute name to set on the entity.
31
+ * @param id - The id of the referenced entity.
32
+ * @param type - The resource type of the referenced entity.
33
+ * @returns The `EntityBuilder` for chaining.
34
+ */
35
+ withAttr(name, id, type) {
36
+ this.attrs[name] = {
37
+ __entity: {
38
+ type: `${this.authorizationConfig.namespace}${type}`,
39
+ id: id,
40
+ },
41
+ };
42
+ return this;
43
+ }
44
+ /**
45
+ * Add an extension attribute (`__extn`) with a function and argument.
46
+ *
47
+ * @param name - Attribute name.
48
+ * @param fn - Extension function name.
49
+ * @param arg - Argument for the extension function.
50
+ * @returns The `EntityBuilder` for chaining.
51
+ */
52
+ withExtnAttr(name, fn, arg) {
53
+ this.attrs[name] = {
54
+ __extn: {
55
+ fn,
56
+ arg,
57
+ },
58
+ };
59
+ return this;
60
+ }
61
+ /**
62
+ * Add a boolean attribute.
63
+ *
64
+ * @param name - Attribute name.
65
+ * @param value - Boolean value to set.
66
+ * @returns The `EntityBuilder` for chaining.
67
+ */
68
+ withBooleanAttr(name, value) {
69
+ this.attrs[name] = value;
70
+ return this;
71
+ }
72
+ /**
73
+ * Add a numeric attribute.
74
+ *
75
+ * @param name - Attribute name.
76
+ * @param value - Number value to set.
77
+ * @returns The `EntityBuilder` for chaining.
78
+ */
79
+ withNumberAttr(name, value) {
80
+ this.attrs[name] = value;
81
+ return this;
82
+ }
83
+ /**
84
+ * Add a string attribute.
85
+ *
86
+ * @param name - Attribute name.
87
+ * @param value - String value to set.
88
+ * @returns The `EntityBuilder` for chaining.
89
+ */
90
+ withStringAttr(name, value) {
91
+ this.attrs[name] = value;
92
+ return this;
93
+ }
94
+ /**
95
+ * Add a set attribute (array wrapped in `{ set: [...] }`).
96
+ *
97
+ * @param name - Attribute name.
98
+ * @param value - Array of string values for the set.
99
+ * @returns The `EntityBuilder` for chaining.
100
+ */
101
+ withSetAttr(name, value) {
102
+ this.attrs[name] = { set: value };
103
+ return this;
104
+ }
105
+ /**
106
+ * Add a parent relationship referencing another entity UID.
107
+ *
108
+ * @param id - Parent entity id.
109
+ * @param type - Parent entity resource type.
110
+ * @returns The `EntityBuilder` for chaining.
111
+ */
112
+ withParent(id, type) {
113
+ this.parents.push({
114
+ __entity: {
115
+ type: `${this.authorizationConfig.namespace}${type}`,
116
+ id,
117
+ },
118
+ });
119
+ return this;
120
+ }
121
+ /**
122
+ * Add a tag to the entity. Initializes the `tags` map lazily.
123
+ *
124
+ * @param name - Tag name.
125
+ * @param id - Tagged entity id.
126
+ * @param type - Optional resource type for the tagged entity.
127
+ * @returns The `EntityBuilder` for chaining.
128
+ */
129
+ withTag(name, id, type) {
130
+ if (!this.tags) {
131
+ this.tags = {};
132
+ }
133
+ this.tags[name] = {
134
+ __entity: {
135
+ type: `${this.authorizationConfig.namespace}${type}`,
136
+ id,
137
+ },
138
+ };
139
+ return this;
140
+ }
141
+ /**
142
+ * Build and return the `EntityJson` object.
143
+ *
144
+ * @returns A complete `EntityJson` representation suitable for Cedar requests.
145
+ */
146
+ build() {
147
+ const entity = {
148
+ uid: this.uid,
149
+ attrs: this.attrs,
150
+ parents: this.parents,
151
+ };
152
+ if (this.tags) {
153
+ entity.tags = this.tags;
154
+ }
155
+ return entity;
156
+ }
157
+ }
158
+ exports.EntityBuilder = EntityBuilder;
159
+ //# sourceMappingURL=entity-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-builder.js","sourceRoot":"","sources":["../../src/entity-builder/entity-builder.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export * from './entity-builder';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity-builder/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./entity-builder"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entity-builder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -1,7 +1,7 @@
1
- export * from "./missing-authenticated-user-details-error";
2
- export * from "./missing-authorization-action-error";
3
- export * from "./missing-authorization-policy-error";
4
- export * from "./missing-authorization-resource-error";
5
- export * from "./missing-authorization-schema-error";
6
- export * from "./unauthorized-error";
1
+ export * from './missing-authenticated-user-details-error';
2
+ export * from './missing-authorization-action-error';
3
+ export * from './missing-authorization-policy-error';
4
+ export * from './missing-authorization-resource-error';
5
+ export * from './missing-authorization-schema-error';
6
+ export * from './unauthorized-error';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- export * from "./missing-authenticated-user-details-error";
1
+ export * from './missing-authenticated-user-details-error';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -45,8 +45,8 @@ class MissingAuthenticatedUserDetailsError extends Error {
45
45
  * in error handling and logging.
46
46
  */
47
47
  constructor() {
48
- super("Missing authenticated user details");
49
- this.name = "MissingAuthenticatedUserDetailsError";
48
+ super('Missing authenticated user details');
49
+ this.name = 'MissingAuthenticatedUserDetailsError';
50
50
  }
51
51
  }
52
52
  exports.MissingAuthenticatedUserDetailsError = MissingAuthenticatedUserDetailsError;
@@ -1,2 +1,2 @@
1
- export * from "./missing-authorization-action-error";
1
+ export * from './missing-authorization-action-error';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -41,8 +41,8 @@ class MissingAuthorizationActionError extends Error {
41
41
  * in error handling and logging.
42
42
  */
43
43
  constructor() {
44
- super("Missing authorization action details");
45
- this.name = "MissingAuthorizationActionError";
44
+ super('Missing authorization action details');
45
+ this.name = 'MissingAuthorizationActionError';
46
46
  }
47
47
  }
48
48
  exports.MissingAuthorizationActionError = MissingAuthorizationActionError;
@@ -1,2 +1,2 @@
1
- export * from "./missing-authorization-policy-error";
1
+ export * from './missing-authorization-policy-error';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -43,8 +43,8 @@ class MissingAuthorizationPolicyError extends Error {
43
43
  * in error handling and logging.
44
44
  */
45
45
  constructor() {
46
- super("Missing authorization policy details");
47
- this.name = "MissingAuthorizationPolicyError";
46
+ super('Missing authorization policy details');
47
+ this.name = 'MissingAuthorizationPolicyError';
48
48
  }
49
49
  }
50
50
  exports.MissingAuthorizationPolicyError = MissingAuthorizationPolicyError;
@@ -1,2 +1,2 @@
1
- export * from "./missing-authorization-resource-error";
1
+ export * from './missing-authorization-resource-error';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -41,8 +41,8 @@ class MissingAuthorizationResourceError extends Error {
41
41
  * in error handling and logging.
42
42
  */
43
43
  constructor() {
44
- super("Missing authorization resource details");
45
- this.name = "MissingAuthorizationResourceError";
44
+ super('Missing authorization resource details');
45
+ this.name = 'MissingAuthorizationResourceError';
46
46
  }
47
47
  }
48
48
  exports.MissingAuthorizationResourceError = MissingAuthorizationResourceError;
@@ -1,2 +1,2 @@
1
- export * from "./missing-authorization-schema-error";
1
+ export * from './missing-authorization-schema-error';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -43,8 +43,8 @@ class MissingAuthorizationSchemaError extends Error {
43
43
  * in error handling and logging.
44
44
  */
45
45
  constructor() {
46
- super("Missing authorization schema details");
47
- this.name = "MissingAuthorizationSchemaError";
46
+ super('Missing authorization schema details');
47
+ this.name = 'MissingAuthorizationSchemaError';
48
48
  }
49
49
  }
50
50
  exports.MissingAuthorizationSchemaError = MissingAuthorizationSchemaError;
@@ -1,2 +1,2 @@
1
- export * from "./unauthorized-error";
1
+ export * from './unauthorized-error';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -72,7 +72,7 @@ class UnauthorizedError extends Error {
72
72
  */
73
73
  constructor(message) {
74
74
  super(message);
75
- this.name = "UnauthorizedError";
75
+ this.name = 'UnauthorizedError';
76
76
  }
77
77
  }
78
78
  exports.UnauthorizedError = UnauthorizedError;
@@ -64,7 +64,7 @@ const node_path_1 = __importDefault(require("node:path"));
64
64
  const loadFileAsString = (fileName) => {
65
65
  try {
66
66
  const filePath = node_path_1.default.join(__dirname, fileName);
67
- const data = node_fs_1.default.readFileSync(filePath, "utf-8");
67
+ const data = node_fs_1.default.readFileSync(filePath, 'utf-8');
68
68
  return data;
69
69
  }
70
70
  catch (error) {
@@ -1,2 +1,2 @@
1
- export * from "./file-loader";
1
+ export * from './file-loader';
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- export * from "./auth-lambda";
2
- export * from "./authorization-middleware";
3
- export * from "./authorization-service";
4
- export * from "./errors";
5
- export * from "./user-details";
1
+ export * from './auth-lambda';
2
+ export * from './authorization-middleware';
3
+ export * from './authorization-service';
4
+ export * from './entity-builder';
5
+ export * from './errors';
6
+ export * from './types';
7
+ export * from './user-details';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth-lambda"), exports);
18
18
  __exportStar(require("./authorization-middleware"), exports);
19
19
  __exportStar(require("./authorization-service"), exports);
20
+ __exportStar(require("./entity-builder"), exports);
20
21
  __exportStar(require("./errors"), exports);
22
+ __exportStar(require("./types"), exports);
21
23
  __exportStar(require("./user-details"), exports);
22
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,6DAA2C;AAC3C,0DAAwC;AACxC,2CAAyB;AACzB,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,6DAA2C;AAC3C,0DAAwC;AACxC,mDAAiC;AACjC,2CAAyB;AACzB,0CAAwB;AACxB,iDAA+B"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  // Mock AWS Lambda Powertools Logger to avoid initialization issues in tests
3
- jest.mock("@aws-lambda-powertools/logger", () => {
3
+ jest.mock('@aws-lambda-powertools/logger', () => {
4
4
  return {
5
5
  Logger: jest.fn().mockImplementation(() => ({
6
6
  debug: jest.fn(),
@@ -12,8 +12,8 @@ jest.mock("@aws-lambda-powertools/logger", () => {
12
12
  };
13
13
  });
14
14
  // Mock environment variables for AWS Lambda Powertools Logger
15
- process.env.AWS_LAMBDA_FUNCTION_NAME = "test-function";
16
- process.env.AWS_LAMBDA_FUNCTION_VERSION = "$LATEST";
17
- process.env.AWS_REGION = "us-east-1";
18
- process.env.POWERTOOLS_SERVICE_NAME = "test-service";
15
+ process.env.AWS_LAMBDA_FUNCTION_NAME = 'test-function';
16
+ process.env.AWS_LAMBDA_FUNCTION_VERSION = '$LATEST';
17
+ process.env.AWS_REGION = 'us-east-1';
18
+ process.env.POWERTOOLS_SERVICE_NAME = 'test-service';
19
19
  //# sourceMappingURL=setupTests.js.map
@@ -0,0 +1,25 @@
1
+ export interface TypeAndId {
2
+ type: string;
3
+ id: string;
4
+ }
5
+ export type EntityUidJson = {
6
+ __entity: TypeAndId;
7
+ } | TypeAndId;
8
+ export type CedarValueJson = {
9
+ __entity: TypeAndId;
10
+ } | {
11
+ __extn: FnAndArg;
12
+ } | boolean | number | string | CedarValueJson[] | {
13
+ [key: string]: CedarValueJson;
14
+ } | null;
15
+ export interface FnAndArg {
16
+ fn: string;
17
+ arg: CedarValueJson;
18
+ }
19
+ export interface EntityJson {
20
+ uid: EntityUidJson;
21
+ attrs: Record<string, CedarValueJson>;
22
+ parents: EntityUidJson[];
23
+ tags?: Record<string, CedarValueJson>;
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACX;AAED,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAAC;AAEhE,MAAM,MAAM,cAAc,GACvB;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB,OAAO,GACP,MAAM,GACN,MAAM,GACN,cAAc,EAAE,GAChB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE,GACjC,IAAI,CAAC;AAER,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,cAAc,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,aAAa,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACtC"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- export * from "./user-details-service";
1
+ export * from './user-details-service';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { APIGatewayProxyEvent } from "aws-lambda";
1
+ import type { APIGatewayProxyEvent } from 'aws-lambda';
2
2
  /**
3
3
  * Extracts and stores user authentication details from an API Gateway event.
4
4
  *
@@ -5,7 +5,7 @@ exports.getUserName = getUserName;
5
5
  exports.getRoles = getRoles;
6
6
  exports.resetDetails = resetDetails;
7
7
  const logger_1 = require("@aws-lambda-powertools/logger");
8
- const logger = new logger_1.Logger({ serviceName: "user-detail-service" });
8
+ const logger = new logger_1.Logger({ serviceName: 'user-detail-service' });
9
9
  /**
10
10
  * User details service for extracting and managing authenticated user information.
11
11
  *
@@ -91,22 +91,22 @@ let roles;
91
91
  */
92
92
  function setUserDetails(authenticatedEvent) {
93
93
  if (!authenticatedEvent?.requestContext?.authorizer) {
94
- logger.warn("The event is not an authenticated request.");
94
+ logger.warn('The event is not an authenticated request.');
95
95
  return;
96
96
  }
97
- logger.debug("Getting user name...");
97
+ logger.debug('Getting user name...');
98
98
  userName =
99
- authenticatedEvent.requestContext?.authorizer?.claims["cognito:username"];
100
- logger.debug("User name set.", { userName });
101
- if (typeof authenticatedEvent.requestContext?.authorizer?.claims["cognito:groups"] === "string") {
99
+ authenticatedEvent.requestContext?.authorizer?.claims['cognito:username'];
100
+ logger.debug('User name set.', { userName });
101
+ if (typeof authenticatedEvent.requestContext?.authorizer?.claims['cognito:groups'] === 'string') {
102
102
  roles = [];
103
- roles.push(authenticatedEvent.requestContext?.authorizer?.claims["cognito:groups"]);
103
+ roles.push(authenticatedEvent.requestContext?.authorizer?.claims['cognito:groups']);
104
104
  }
105
105
  else {
106
106
  roles =
107
- authenticatedEvent.requestContext?.authorizer?.claims["cognito:groups"];
107
+ authenticatedEvent.requestContext?.authorizer?.claims['cognito:groups'];
108
108
  }
109
- logger.debug("User details set", {
109
+ logger.debug('User details set', {
110
110
  userName,
111
111
  roles,
112
112
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcdubs/janus",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Open source Serverless authentication: A Cedar-based authorisation engine for deterministic, deny-by-default access decisions through a CDK construct and SDK libraries.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,11 +38,11 @@
38
38
  "homepage": "https://github.com/JCDubs/Janus#readme",
39
39
  "license": "MIT",
40
40
  "devDependencies": {
41
- "@aws-lambda-powertools/logger": "2.15.0",
41
+ "@aws-lambda-powertools/logger": "2.30.1",
42
42
  "@biomejs/biome": "^2.3.10",
43
43
  "@commitlint/cli": "20.1.0",
44
44
  "@commitlint/config-conventional": "20.0.0",
45
- "@middy/core": "^6.4.5",
45
+ "@middy/core": "6.4.5",
46
46
  "@semantic-release/changelog": "6.0.3",
47
47
  "@semantic-release/git": "10.0.1",
48
48
  "@swc/jest": "0.2.39",
@@ -60,11 +60,13 @@
60
60
  "typescript": "^5.9.3"
61
61
  },
62
62
  "dependencies": {
63
+ "@aws-lambda-powertools/logger": "2.30.1",
63
64
  "@cedar-policy/cedar-wasm": "4.3.3",
64
65
  "uuid": "^13.0.0"
65
66
  },
66
67
  "peerDependencies": {
67
- "@aws-lambda-powertools/logger": "2.15.0",
68
+ "@aws-lambda-powertools/logger": "2.30.1",
69
+ "@middy/core": "6.4.5",
68
70
  "aws-cdk-lib": "2.219.0",
69
71
  "constructs": "10.4.2"
70
72
  },