@degenerate/endpoints 0.0.2 → 0.0.4

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 (206) hide show
  1. package/dist/endpoints/src/cors/authority/audience/get-set-audiences.d.ts +60 -0
  2. package/dist/endpoints/src/cors/authority/audience/get-set-audiences.d.ts.map +1 -0
  3. package/dist/endpoints/src/cors/authority/audience/get-set-audiences.js +90 -0
  4. package/dist/endpoints/src/cors/authority/jwt/validate-jwt-authorities.d.ts +16 -0
  5. package/dist/endpoints/src/cors/authority/jwt/validate-jwt-authorities.d.ts.map +1 -0
  6. package/dist/endpoints/src/cors/authority/jwt/validate-jwt-authorities.js +34 -0
  7. package/dist/endpoints/src/cors/endpoints/authorities/validate-authorities-transaction.d.ts +30 -0
  8. package/dist/endpoints/src/cors/endpoints/authorities/validate-authorities-transaction.d.ts.map +1 -0
  9. package/dist/endpoints/src/cors/endpoints/authorities/validate-authorities-transaction.js +155 -0
  10. package/dist/endpoints/src/cors/endpoints/helpers/validate-request-body.d.ts +11 -0
  11. package/dist/endpoints/src/cors/endpoints/helpers/validate-request-body.d.ts.map +1 -0
  12. package/dist/endpoints/src/cors/endpoints/helpers/validate-request-body.js +32 -0
  13. package/dist/{cors → endpoints/src/cors}/errors/all-error-handler.d.ts +2 -2
  14. package/dist/endpoints/src/cors/errors/all-error-handler.d.ts.map +1 -0
  15. package/dist/{cors → endpoints/src/cors}/errors/all-error-handler.js +1 -0
  16. package/dist/endpoints/src/cors/errors/bad-request-handler.d.ts +12 -0
  17. package/dist/endpoints/src/cors/errors/bad-request-handler.d.ts.map +1 -0
  18. package/dist/{cors → endpoints/src/cors}/errors/bad-request-handler.js +1 -0
  19. package/dist/endpoints/src/cors/errors/unauthorized-handler.d.ts +12 -0
  20. package/dist/endpoints/src/cors/errors/unauthorized-handler.d.ts.map +1 -0
  21. package/dist/{cors → endpoints/src/cors}/errors/unauthorized-handler.js +1 -0
  22. package/dist/endpoints/src/cors/index.d.ts +9 -0
  23. package/dist/endpoints/src/cors/index.d.ts.map +1 -0
  24. package/dist/{cors → endpoints/src/cors}/index.js +7 -0
  25. package/dist/endpoints/src/cors/routes/authorities.routes.d.ts +2 -0
  26. package/dist/endpoints/src/cors/routes/authorities.routes.d.ts.map +1 -0
  27. package/dist/endpoints/src/cors/routes/authorities.routes.js +69 -0
  28. package/dist/endpoints/src/cors/routes/events.routes.d.ts +2 -0
  29. package/dist/endpoints/src/cors/routes/events.routes.d.ts.map +1 -0
  30. package/dist/endpoints/src/cors/routes/events.routes.js +56 -0
  31. package/dist/endpoints/src/cors/routes/functions.routes.d.ts +2 -0
  32. package/dist/endpoints/src/cors/routes/functions.routes.d.ts.map +1 -0
  33. package/dist/endpoints/src/cors/routes/functions.routes.js +56 -0
  34. package/dist/endpoints/src/cors/routes/rules.routes.d.ts +2 -0
  35. package/dist/endpoints/src/cors/routes/rules.routes.d.ts.map +1 -0
  36. package/dist/endpoints/src/cors/routes/rules.routes.js +56 -0
  37. package/dist/endpoints/src/cors/routes/share-data.routes.d.ts +2 -0
  38. package/dist/endpoints/src/cors/routes/share-data.routes.d.ts.map +1 -0
  39. package/dist/endpoints/src/cors/routes/share-data.routes.js +56 -0
  40. package/dist/endpoints/src/examples/express-server/app.d.ts +3 -0
  41. package/dist/endpoints/src/examples/express-server/app.d.ts.map +1 -0
  42. package/dist/endpoints/src/examples/express-server/app.js +29 -0
  43. package/dist/endpoints/src/examples/express-server/server.d.ts +2 -0
  44. package/dist/endpoints/src/examples/express-server/server.d.ts.map +1 -0
  45. package/dist/endpoints/src/examples/express-server/server.js +9 -0
  46. package/dist/{index.d.ts.map → endpoints/src/index.d.ts.map} +1 -1
  47. package/dist/generic/src/_settings/authorization-settings.d.ts +17 -0
  48. package/dist/generic/src/_settings/authorization-settings.d.ts.map +1 -0
  49. package/dist/generic/src/_settings/authorization-settings.js +20 -0
  50. package/dist/generic/src/authorization/index.d.ts +24 -0
  51. package/dist/generic/src/authorization/index.d.ts.map +1 -0
  52. package/dist/generic/src/authorization/index.js +61 -0
  53. package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.d.ts +9 -0
  54. package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.d.ts.map +1 -0
  55. package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.js +25 -0
  56. package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.d.ts +9 -0
  57. package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.d.ts.map +1 -0
  58. package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.js +24 -0
  59. package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.d.ts +10 -0
  60. package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.d.ts.map +1 -0
  61. package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.js +26 -0
  62. package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.d.ts +12 -0
  63. package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.d.ts.map +1 -0
  64. package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.js +19 -0
  65. package/dist/generic/src/authorization/jwt/sign/create-jwt-options.d.ts +17 -0
  66. package/dist/generic/src/authorization/jwt/sign/create-jwt-options.d.ts.map +1 -0
  67. package/dist/generic/src/authorization/jwt/sign/create-jwt-options.js +43 -0
  68. package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.d.ts +13 -0
  69. package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.d.ts.map +1 -0
  70. package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.js +22 -0
  71. package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts +10 -0
  72. package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts.map +1 -0
  73. package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.js +31 -0
  74. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.d.ts +10 -0
  75. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.d.ts.map +1 -0
  76. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.js +20 -0
  77. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts +9 -0
  78. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts.map +1 -0
  79. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.js +17 -0
  80. package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.d.ts +12 -0
  81. package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.d.ts.map +1 -0
  82. package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.js +34 -0
  83. package/dist/generic/src/authorization/safe/authorization/authorized-authorities.d.ts +42 -0
  84. package/dist/generic/src/authorization/safe/authorization/authorized-authorities.d.ts.map +1 -0
  85. package/dist/generic/src/authorization/safe/authorization/authorized-authorities.js +65 -0
  86. package/dist/generic/src/authorization/safe/request/decode-bearer-token.d.ts +11 -0
  87. package/dist/generic/src/authorization/safe/request/decode-bearer-token.d.ts.map +1 -0
  88. package/dist/generic/src/authorization/safe/request/decode-bearer-token.js +31 -0
  89. package/dist/generic/src/authorization/safe/request/decode-safe-request.d.ts +11 -0
  90. package/dist/generic/src/authorization/safe/request/decode-safe-request.d.ts.map +1 -0
  91. package/dist/generic/src/authorization/safe/request/decode-safe-request.js +30 -0
  92. package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.d.ts +10 -0
  93. package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.d.ts.map +1 -0
  94. package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.js +29 -0
  95. package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts +12 -0
  96. package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts.map +1 -0
  97. package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.js +30 -0
  98. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts +10 -0
  99. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts.map +1 -0
  100. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.js +24 -0
  101. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts +8 -0
  102. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts.map +1 -0
  103. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.js +23 -0
  104. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts +9 -0
  105. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts.map +1 -0
  106. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.js +24 -0
  107. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts +10 -0
  108. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts.map +1 -0
  109. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.js +25 -0
  110. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts +8 -0
  111. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts.map +1 -0
  112. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.js +23 -0
  113. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts +10 -0
  114. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts.map +1 -0
  115. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.js +22 -0
  116. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.d.ts +9 -0
  117. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.d.ts.map +1 -0
  118. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.js +25 -0
  119. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.d.ts +11 -0
  120. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.d.ts.map +1 -0
  121. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.js +30 -0
  122. package/dist/generic/src/errors/audit-log/audit-log-errors.d.ts +20 -0
  123. package/dist/generic/src/errors/audit-log/audit-log-errors.d.ts.map +1 -0
  124. package/dist/generic/src/errors/audit-log/audit-log-errors.js +31 -0
  125. package/dist/generic/src/errors/authorization/authorization-errors.d.ts +106 -0
  126. package/dist/generic/src/errors/authorization/authorization-errors.d.ts.map +1 -0
  127. package/dist/generic/src/errors/authorization/authorization-errors.js +160 -0
  128. package/dist/generic/src/errors/base-error.d.ts +23 -0
  129. package/dist/generic/src/errors/base-error.d.ts.map +1 -0
  130. package/dist/generic/src/errors/base-error.js +34 -0
  131. package/dist/generic/src/errors/database/database-errors.d.ts +24 -0
  132. package/dist/generic/src/errors/database/database-errors.d.ts.map +1 -0
  133. package/dist/generic/src/errors/database/database-errors.js +33 -0
  134. package/dist/generic/src/errors/generic/generic-errors.d.ts +35 -0
  135. package/dist/generic/src/errors/generic/generic-errors.d.ts.map +1 -0
  136. package/dist/generic/src/errors/generic/generic-errors.js +47 -0
  137. package/dist/generic/src/errors/index.d.ts +10 -0
  138. package/dist/generic/src/errors/index.d.ts.map +1 -0
  139. package/dist/generic/src/errors/index.js +26 -0
  140. package/dist/generic/src/errors/request/request-errors.d.ts +98 -0
  141. package/dist/generic/src/errors/request/request-errors.d.ts.map +1 -0
  142. package/dist/generic/src/errors/request/request-errors.js +134 -0
  143. package/dist/generic/src/errors/safe/safe-rules-errors.d.ts +102 -0
  144. package/dist/generic/src/errors/safe/safe-rules-errors.d.ts.map +1 -0
  145. package/dist/generic/src/errors/safe/safe-rules-errors.js +152 -0
  146. package/dist/generic/src/errors/scheduler/scheduler-errors.d.ts +8 -0
  147. package/dist/generic/src/errors/scheduler/scheduler-errors.d.ts.map +1 -0
  148. package/dist/generic/src/errors/scheduler/scheduler-errors.js +14 -0
  149. package/dist/generic/src/errors/share-data/share-data-errors.d.ts +67 -0
  150. package/dist/generic/src/errors/share-data/share-data-errors.d.ts.map +1 -0
  151. package/dist/generic/src/errors/share-data/share-data-errors.js +92 -0
  152. package/dist/generic/src/helpers/crypto/cryptography-helpers.d.ts +37 -0
  153. package/dist/generic/src/helpers/crypto/cryptography-helpers.d.ts.map +1 -0
  154. package/dist/generic/src/helpers/crypto/cryptography-helpers.js +65 -0
  155. package/dist/generic/src/helpers/object-validation-helpers.d.ts +66 -0
  156. package/dist/generic/src/helpers/object-validation-helpers.d.ts.map +1 -0
  157. package/dist/generic/src/helpers/object-validation-helpers.js +254 -0
  158. package/dist/generic/src/models/application/audit-log/application-audit-log-models.d.ts +87 -0
  159. package/dist/generic/src/models/application/audit-log/application-audit-log-models.d.ts.map +1 -0
  160. package/dist/generic/src/models/application/audit-log/application-audit-log-models.js +59 -0
  161. package/dist/generic/src/models/application/database/firestore-models.d.ts +84 -0
  162. package/dist/generic/src/models/application/database/firestore-models.d.ts.map +1 -0
  163. package/dist/generic/src/models/application/database/firestore-models.js +4 -0
  164. package/dist/generic/src/models/authorization/authorization-models.d.ts +81 -0
  165. package/dist/generic/src/models/authorization/authorization-models.d.ts.map +1 -0
  166. package/dist/generic/src/models/authorization/authorization-models.js +33 -0
  167. package/dist/generic/src/models/crypto/crypto-models.d.ts +5 -0
  168. package/dist/generic/src/models/crypto/crypto-models.d.ts.map +1 -0
  169. package/dist/generic/src/models/crypto/crypto-models.js +3 -0
  170. package/dist/generic/src/models/data/data-models.d.ts +24 -0
  171. package/dist/generic/src/models/data/data-models.d.ts.map +1 -0
  172. package/dist/generic/src/models/data/data-models.js +3 -0
  173. package/dist/generic/src/models/dynamic-execution/dynamic-execution-models.d.ts +9 -0
  174. package/dist/generic/src/models/dynamic-execution/dynamic-execution-models.d.ts.map +1 -0
  175. package/dist/generic/src/models/dynamic-execution/dynamic-execution-models.js +2 -0
  176. package/dist/generic/src/models/events/share-event-models.d.ts +65 -0
  177. package/dist/generic/src/models/events/share-event-models.d.ts.map +1 -0
  178. package/dist/generic/src/models/events/share-event-models.js +70 -0
  179. package/dist/generic/src/models/functions/share-data-function-models.d.ts +86 -0
  180. package/dist/generic/src/models/functions/share-data-function-models.d.ts.map +1 -0
  181. package/dist/generic/src/models/functions/share-data-function-models.js +17 -0
  182. package/dist/generic/src/models/generic/request-response-models.d.ts +8 -0
  183. package/dist/generic/src/models/generic/request-response-models.d.ts.map +1 -0
  184. package/dist/generic/src/models/generic/request-response-models.js +2 -0
  185. package/dist/generic/src/models/index.d.ts +13 -0
  186. package/dist/generic/src/models/index.d.ts.map +1 -0
  187. package/dist/generic/src/models/index.js +29 -0
  188. package/dist/generic/src/models/rules/share-rule-models.d.ts +303 -0
  189. package/dist/generic/src/models/rules/share-rule-models.d.ts.map +1 -0
  190. package/dist/generic/src/models/rules/share-rule-models.js +93 -0
  191. package/dist/generic/src/models/safe/safe-transaction-models.d.ts +81 -0
  192. package/dist/generic/src/models/safe/safe-transaction-models.d.ts.map +1 -0
  193. package/dist/generic/src/models/safe/safe-transaction-models.js +26 -0
  194. package/dist/generic/src/models/share-data/share-data.d.ts +56 -0
  195. package/dist/generic/src/models/share-data/share-data.d.ts.map +1 -0
  196. package/dist/generic/src/models/share-data/share-data.js +20 -0
  197. package/package.json +4 -3
  198. package/dist/cors/errors/all-error-handler.d.ts.map +0 -1
  199. package/dist/cors/errors/bad-request-handler.d.ts +0 -12
  200. package/dist/cors/errors/bad-request-handler.d.ts.map +0 -1
  201. package/dist/cors/errors/unauthorized-handler.d.ts +0 -12
  202. package/dist/cors/errors/unauthorized-handler.d.ts.map +0 -1
  203. package/dist/cors/index.d.ts +0 -4
  204. package/dist/cors/index.d.ts.map +0 -1
  205. /package/dist/{index.d.ts → endpoints/src/index.d.ts} +0 -0
  206. /package/dist/{index.js → endpoints/src/index.js} +0 -0
@@ -0,0 +1,56 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.events = void 0;
27
+ const express = __importStar(require("express"));
28
+ const get_set_audiences_1 = require("../authority/audience/get-set-audiences");
29
+ // eslint-disable-next-line new-cap
30
+ const router = express.Router({ mergeParams: true });
31
+ router.use(get_set_audiences_1.setAudienceEvents); // set the audience to events (this will throw an error if the audience is not set)
32
+ /**
33
+ * This creates a new event object.
34
+ */
35
+ router.post('/', async (req, res) => {
36
+ return res.status(200).send({ successful: true });
37
+ });
38
+ /**
39
+ * This gets the event object.
40
+ */
41
+ router.get('/', async (req, res) => {
42
+ return res.status(200).send({ successful: true });
43
+ });
44
+ /**
45
+ * This updates the event object.
46
+ */
47
+ router.patch('/', async (req, res) => {
48
+ return res.status(200).send({ successful: true });
49
+ });
50
+ /**
51
+ * This deletes the event object.
52
+ */
53
+ router.delete('/', async (req, res) => {
54
+ return res.status(200).send({ successful: true });
55
+ });
56
+ exports.events = router;
@@ -0,0 +1,2 @@
1
+ export declare const functions: import("express-serve-static-core").Router;
2
+ //# sourceMappingURL=functions.routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.routes.d.ts","sourceRoot":"","sources":["../../../../../src/cors/routes/functions.routes.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,SAAS,4CAAS,CAAC"}
@@ -0,0 +1,56 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.functions = void 0;
27
+ const express = __importStar(require("express"));
28
+ const get_set_audiences_1 = require("../authority/audience/get-set-audiences");
29
+ // eslint-disable-next-line new-cap
30
+ const router = express.Router({ mergeParams: true });
31
+ router.use(get_set_audiences_1.setAudienceFunctions); // set the audience to share data (this will throw an error if the audience is not set)
32
+ /**
33
+ * This creates a new sharedata object.
34
+ */
35
+ router.post('/', async (req, res) => {
36
+ return res.status(200).send({ successful: true });
37
+ });
38
+ /**
39
+ * This gets the sharedata object.
40
+ */
41
+ router.get('/', async (req, res) => {
42
+ return res.status(200).send({ successful: true });
43
+ });
44
+ /**
45
+ * This updates the sharedata object.
46
+ */
47
+ router.patch('/', async (req, res) => {
48
+ return res.status(200).send({ successful: true });
49
+ });
50
+ /**
51
+ * This deletes the sharedata object.
52
+ */
53
+ router.delete('/', async (req, res) => {
54
+ return res.status(200).send({ successful: true });
55
+ });
56
+ exports.functions = router;
@@ -0,0 +1,2 @@
1
+ export declare const rules: import("express-serve-static-core").Router;
2
+ //# sourceMappingURL=rules.routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.routes.d.ts","sourceRoot":"","sources":["../../../../../src/cors/routes/rules.routes.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,KAAK,4CAAS,CAAC"}
@@ -0,0 +1,56 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.rules = void 0;
27
+ const express = __importStar(require("express"));
28
+ const get_set_audiences_1 = require("../authority/audience/get-set-audiences");
29
+ // eslint-disable-next-line new-cap
30
+ const router = express.Router({ mergeParams: true });
31
+ router.use(get_set_audiences_1.setAudienceRules); // set the audience to share data (this will throw an error if the audience is not set)
32
+ /**
33
+ * This creates a new sharedata object.
34
+ */
35
+ router.post('/', async (req, res) => {
36
+ return res.status(200).send({ successful: true });
37
+ });
38
+ /**
39
+ * This gets the sharedata object.
40
+ */
41
+ router.get('/', async (req, res) => {
42
+ return res.status(200).send({ successful: true });
43
+ });
44
+ /**
45
+ * This updates the sharedata object.
46
+ */
47
+ router.patch('/', async (req, res) => {
48
+ return res.status(200).send({ successful: true });
49
+ });
50
+ /**
51
+ * This deletes the sharedata object.
52
+ */
53
+ router.delete('/', async (req, res) => {
54
+ return res.status(200).send({ successful: true });
55
+ });
56
+ exports.rules = router;
@@ -0,0 +1,2 @@
1
+ export declare const shareData: import("express-serve-static-core").Router;
2
+ //# sourceMappingURL=share-data.routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"share-data.routes.d.ts","sourceRoot":"","sources":["../../../../../src/cors/routes/share-data.routes.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,SAAS,4CAAS,CAAC"}
@@ -0,0 +1,56 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.shareData = void 0;
27
+ const express = __importStar(require("express"));
28
+ const get_set_audiences_1 = require("../authority/audience/get-set-audiences");
29
+ // eslint-disable-next-line new-cap
30
+ const router = express.Router({ mergeParams: true });
31
+ router.use(get_set_audiences_1.setAudienceShareData); // set the audience to share data (this will throw an error if the audience is not set)
32
+ /**
33
+ * This creates a new sharedata object.
34
+ */
35
+ router.post('/', async (req, res) => {
36
+ return res.status(200).send({ successful: true });
37
+ });
38
+ /**
39
+ * This gets the sharedata object.
40
+ */
41
+ router.get('/', async (req, res) => {
42
+ return res.status(200).send({ successful: true });
43
+ });
44
+ /**
45
+ * This updates the sharedata object.
46
+ */
47
+ router.patch('/', async (req, res) => {
48
+ return res.status(200).send({ successful: true });
49
+ });
50
+ /**
51
+ * This deletes the sharedata object.
52
+ */
53
+ router.delete('/', async (req, res) => {
54
+ return res.status(200).send({ successful: true });
55
+ });
56
+ exports.shareData = router;
@@ -0,0 +1,3 @@
1
+ declare const app: import("express-serve-static-core").Express;
2
+ export default app;
3
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../../src/examples/express-server/app.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,GAAG,6CAAY,CAAC;AAiBtB,eAAe,GAAG,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const authorization_1 = require("@degenerate/generic/src/authorization");
7
+ const express_1 = __importDefault(require("express"));
8
+ //#region Route Imports
9
+ const authorities_routes_1 = require("../../cors/routes/authorities.routes");
10
+ const events_routes_1 = require("../../cors/routes/events.routes");
11
+ const functions_routes_1 = require("../../cors/routes/functions.routes");
12
+ const rules_routes_1 = require("../../cors/routes/rules.routes");
13
+ const share_data_routes_1 = require("../../cors/routes/share-data.routes");
14
+ //#endregion Route Imports
15
+ // create the express application
16
+ const app = (0, express_1.default)();
17
+ app.use(express_1.default.json());
18
+ const authorizedAuthorities = new authorization_1.AuthorizedAuthorities();
19
+ // Initialize the authorized authorities here if needed
20
+ // e.g., authorizedAuthorities.addAuthorizedJWTAuthority(...);
21
+ // Make the instance available throughout the app
22
+ app.set('authorizedAuthorities', authorizedAuthorities);
23
+ // Make sure you enable whatever middleware you need here
24
+ app.use('/authorities', authorities_routes_1.authorities); // add the authorities routes
25
+ app.use('/events', events_routes_1.events); // add the events routes
26
+ app.use('/functions', functions_routes_1.functions); // add the functions routes
27
+ app.use('/rules', rules_routes_1.rules); // add the rules routes
28
+ app.use('/share-data', share_data_routes_1.shareData); // add the share data routes
29
+ exports.default = app;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../src/examples/express-server/server.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const app_1 = __importDefault(require("./app"));
7
+ app_1.default.listen(3000, () => {
8
+ console.log('Server is running on port 3000');
9
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This contains the settings for the authorization functions.
3
+ */
4
+ export declare const AuthorizationSettings: {
5
+ JWT: {
6
+ Algorithm: string;
7
+ ExpiresInDefault: string;
8
+ NotBeforeDefault: number;
9
+ EncodingDefault: string;
10
+ MutatePayload: boolean;
11
+ NoTimestamp: boolean;
12
+ AllowInsecureKeySizes: boolean;
13
+ AllowInvalidAsymmetricKeyTypes: boolean;
14
+ HeaderType: string;
15
+ };
16
+ };
17
+ //# sourceMappingURL=authorization-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-settings.d.ts","sourceRoot":"","sources":["../../../../../generic/src/_settings/authorization-settings.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;CAYjC,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // This file contains the settings needed for authorization in the application.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AuthorizationSettings = void 0;
5
+ /**
6
+ * This contains the settings for the authorization functions.
7
+ */
8
+ exports.AuthorizationSettings = {
9
+ JWT: {
10
+ Algorithm: 'ES512', // ECDSA using P-521 curve and SHA-512 hash algorithm
11
+ ExpiresInDefault: '1h', // the expiration time of the jwt token
12
+ NotBeforeDefault: 0, // the not before time of the jwt token
13
+ EncodingDefault: 'utf8', // the encoding to use when converting the payload to a string
14
+ MutatePayload: true, // If true, the payload object will be mutated with the standard claims (iat, exp, etc.). Default is false.
15
+ NoTimestamp: false, // If true, the iat (issued at) claim will not be included in the token.
16
+ AllowInsecureKeySizes: false, // If true, allows the use of insecure key sizes.
17
+ AllowInvalidAsymmetricKeyTypes: false, // If true, allows the use of invalid asymmetric key types
18
+ HeaderType: 'JWT', // the type of the token in the header
19
+ }
20
+ };
@@ -0,0 +1,24 @@
1
+ export * from './jwt/keys/create-secret-key-pem';
2
+ export * from './jwt/keys/create-public-key-pem';
3
+ export * from './jwt/sign/create-authorization-issuer';
4
+ export * from './jwt/sign/create-authorization-subject';
5
+ export * from './jwt/sign/create-jwt-options';
6
+ export * from './jwt/sign/create-jwt-signed-token';
7
+ export * from './jwt/transform/transform-token-payload-to-safe-payload';
8
+ export * from './jwt/verify/get-decoded-jwt-header';
9
+ export * from './jwt/verify/get-decoded-jwt-signed-token-payload';
10
+ export * from './jwt/verify/verify-jwt-signed-token';
11
+ export * from './safe/authorization/authorized-authorities';
12
+ export * from './safe/request/decode-bearer-token';
13
+ export * from './safe/request/decode-safe-request';
14
+ export * from './safe/request/determine-issuer-from-request';
15
+ export * from './safe/request/issuer/determine-issuer-from-bearer-token';
16
+ export * from './safe/validation/jwt/payload/verify-authorization-audience';
17
+ export * from './safe/validation/jwt/payload/verify-authorization-expiration-time';
18
+ export * from './safe/validation/jwt/payload/verify-authorization-issued-at-time';
19
+ export * from './safe/validation/jwt/payload/verify-authorization-issuer';
20
+ export * from './safe/validation/jwt/payload/verify-authorization-not-before-time';
21
+ export * from './safe/validation/jwt/payload/verify-authorization-subject';
22
+ export * from './safe/validation/jwt/verify-token-header';
23
+ export * from './safe/validation/jwt/verify-token-payload';
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../generic/src/authorization/index.ts"],"names":[],"mappings":"AACA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AAIjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AAInD,cAAc,yDAAyD,CAAC;AAIxE,cAAc,qCAAqC,CAAC;AACpD,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AAMrD,cAAc,6CAA6C,CAAC;AAI5D,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAG7D,cAAc,0DAA0D,CAAC;AAWzE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,oEAAoE,CAAC;AACnF,cAAc,mEAAmE,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,oEAAoE,CAAC;AACnF,cAAc,4DAA4D,CAAC;AAI3E,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC"}
@@ -0,0 +1,61 @@
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
+ //#region JWT Key functions
18
+ __exportStar(require("./jwt/keys/create-secret-key-pem"), exports);
19
+ __exportStar(require("./jwt/keys/create-public-key-pem"), exports);
20
+ //#endregion JWT Key functions
21
+ //#region JWT sign
22
+ __exportStar(require("./jwt/sign/create-authorization-issuer"), exports);
23
+ __exportStar(require("./jwt/sign/create-authorization-subject"), exports);
24
+ __exportStar(require("./jwt/sign/create-jwt-options"), exports);
25
+ __exportStar(require("./jwt/sign/create-jwt-signed-token"), exports);
26
+ //#endregion JWT sign
27
+ //#region JWT Transform
28
+ __exportStar(require("./jwt/transform/transform-token-payload-to-safe-payload"), exports);
29
+ //#endregion JWT Transform
30
+ //#region JWT verify
31
+ __exportStar(require("./jwt/verify/get-decoded-jwt-header"), exports);
32
+ __exportStar(require("./jwt/verify/get-decoded-jwt-signed-token-payload"), exports);
33
+ __exportStar(require("./jwt/verify/verify-jwt-signed-token"), exports);
34
+ //#endregion JWT verify
35
+ //#region Safe
36
+ //#region Authorization
37
+ __exportStar(require("./safe/authorization/authorized-authorities"), exports);
38
+ //#endregion Authorization
39
+ //#region Request
40
+ __exportStar(require("./safe/request/decode-bearer-token"), exports);
41
+ __exportStar(require("./safe/request/decode-safe-request"), exports);
42
+ __exportStar(require("./safe/request/determine-issuer-from-request"), exports);
43
+ //#region Issuer
44
+ __exportStar(require("./safe/request/issuer/determine-issuer-from-bearer-token"), exports);
45
+ //#endregion Issuer
46
+ //#endregion Request
47
+ //#region Validation
48
+ //#region JWT
49
+ //#region JWT Payload
50
+ __exportStar(require("./safe/validation/jwt/payload/verify-authorization-audience"), exports);
51
+ __exportStar(require("./safe/validation/jwt/payload/verify-authorization-expiration-time"), exports);
52
+ __exportStar(require("./safe/validation/jwt/payload/verify-authorization-issued-at-time"), exports);
53
+ __exportStar(require("./safe/validation/jwt/payload/verify-authorization-issuer"), exports);
54
+ __exportStar(require("./safe/validation/jwt/payload/verify-authorization-not-before-time"), exports);
55
+ __exportStar(require("./safe/validation/jwt/payload/verify-authorization-subject"), exports);
56
+ //#endregion JWT Payload
57
+ __exportStar(require("./safe/validation/jwt/verify-token-header"), exports);
58
+ __exportStar(require("./safe/validation/jwt/verify-token-payload"), exports);
59
+ //#endregion JWT
60
+ //#endregion Validation
61
+ //#endregion Safe
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This takes a public key in hex or Base64 format and creates a PEM key from it.
3
+ *
4
+ * @param publicKey the public key to create the PEM key from.
5
+ * @returns
6
+ */
7
+ declare const createPublicKeyPem: (publicKey: string) => string;
8
+ export { createPublicKeyPem };
9
+ //# sourceMappingURL=create-public-key-pem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-public-key-pem.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/jwt/keys/create-public-key-pem.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,cAAe,MAAM,KAAG,MAW/C,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPublicKeyPem = void 0;
4
+ const cryptography_helpers_1 = require("../../../helpers/crypto/cryptography-helpers");
5
+ const object_validation_helpers_1 = require("../../../helpers/object-validation-helpers");
6
+ /**
7
+ * This takes a public key in hex or Base64 format and creates a PEM key from it.
8
+ *
9
+ * @param publicKey the public key to create the PEM key from.
10
+ * @returns
11
+ */
12
+ const createPublicKeyPem = (publicKey) => {
13
+ let jwtKey; // the key to return
14
+ const isValidHexString = (0, object_validation_helpers_1.validateStringHex)(publicKey);
15
+ if (isValidHexString) { // check if this is a hex encoded secret key.
16
+ const derKey = (0, cryptography_helpers_1.hexToBase64)(publicKey); // convert the hex to base 64
17
+ jwtKey = (0, cryptography_helpers_1.base64ToPublicPEM)(derKey);
18
+ }
19
+ else {
20
+ // add in the
21
+ jwtKey = (0, cryptography_helpers_1.base64ToPublicPEM)(publicKey);
22
+ }
23
+ return jwtKey;
24
+ };
25
+ exports.createPublicKeyPem = createPublicKeyPem;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This takes a secret key in hex or Base64 format and creates a PEM key from it.
3
+ *
4
+ * @param secretKey the secret key to create the PEM key from.
5
+ * @returns
6
+ */
7
+ declare const createSecretKeyPem: (secretKey: string) => string;
8
+ export { createSecretKeyPem };
9
+ //# sourceMappingURL=create-secret-key-pem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-secret-key-pem.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/jwt/keys/create-secret-key-pem.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,cAAe,MAAM,KAAG,MAU/C,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSecretKeyPem = void 0;
4
+ const cryptography_helpers_1 = require("../../../helpers/crypto/cryptography-helpers");
5
+ const object_validation_helpers_1 = require("../../../helpers/object-validation-helpers");
6
+ /**
7
+ * This takes a secret key in hex or Base64 format and creates a PEM key from it.
8
+ *
9
+ * @param secretKey the secret key to create the PEM key from.
10
+ * @returns
11
+ */
12
+ const createSecretKeyPem = (secretKey) => {
13
+ let jwtKey;
14
+ if ((0, object_validation_helpers_1.validateStringHex)(secretKey)) { // check if this is a hex encoded secret key.
15
+ const derKey = (0, cryptography_helpers_1.hexToBase64)(secretKey); // convert the hex to base 64
16
+ jwtKey = (0, cryptography_helpers_1.base64ToPrivateECPEM)(derKey);
17
+ }
18
+ else {
19
+ // add in the
20
+ jwtKey = (0, cryptography_helpers_1.base64ToPrivateECPEM)(secretKey);
21
+ }
22
+ return jwtKey;
23
+ };
24
+ exports.createSecretKeyPem = createSecretKeyPem;
@@ -0,0 +1,10 @@
1
+ import { IAuthorizationIssuer } from '../../../models/authorization/authorization-models';
2
+ /**
3
+ * This function creates an authorization issuer.
4
+ * @param issuerName the name of the issuer (this should be letters and numbers only)
5
+ * @param publicKey the public key of the issuer (this should be a hex string)
6
+ * @returns
7
+ */
8
+ declare const createAuthorizationIssuer: (issuerName: string, publicKey: string) => IAuthorizationIssuer;
9
+ export { createAuthorizationIssuer };
10
+ //# sourceMappingURL=create-authorization-issuer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-authorization-issuer.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/jwt/sign/create-authorization-issuer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAE1F;;;;;GAKG;AACH,QAAA,MAAM,yBAAyB,eAAgB,MAAM,aAAa,MAAM,KAAG,oBAe1E,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAuthorizationIssuer = void 0;
4
+ const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
5
+ const object_validation_helpers_1 = require("../../../helpers/object-validation-helpers");
6
+ /**
7
+ * This function creates an authorization issuer.
8
+ * @param issuerName the name of the issuer (this should be letters and numbers only)
9
+ * @param publicKey the public key of the issuer (this should be a hex string)
10
+ * @returns
11
+ */
12
+ const createAuthorizationIssuer = (issuerName, publicKey) => {
13
+ // make sure the incoming public key is a hex format
14
+ const publicKeyIsHex = (0, object_validation_helpers_1.validateStringHex)(publicKey);
15
+ if (!publicKeyIsHex) { // if the public key is not a valid hex string
16
+ throw new authorization_errors_1.SafeAuthorizationIssuerPublicKeyNotValidError(issuerName, publicKey);
17
+ }
18
+ if (publicKey.length < 8) { // if the public key is less than 8 characters
19
+ throw new authorization_errors_1.SafeAuthorizationIssuerPublicKeyNotValidError(issuerName, publicKey);
20
+ }
21
+ // get the last 8 characters of the public key
22
+ const publicKeyParse = publicKey.slice(-8);
23
+ const authorizationIssuer = `${issuerName}-${publicKeyParse}`;
24
+ return authorizationIssuer;
25
+ };
26
+ exports.createAuthorizationIssuer = createAuthorizationIssuer;
@@ -0,0 +1,12 @@
1
+ import { AuthorizationSubjectStart, IAuthorizationSubject } from '../../../models/authorization/authorization-models';
2
+ /**
3
+ * This creates an authorization subject.
4
+ *
5
+ * @param subjectType the type of the subject
6
+ * @param subjectId the id of the subject (userid, safenetworkid etc.)
7
+ *
8
+ * @returns
9
+ */
10
+ declare const createAuthorizationSubject: (subjectType: AuthorizationSubjectStart, subjectId: string) => IAuthorizationSubject;
11
+ export { createAuthorizationSubject };
12
+ //# sourceMappingURL=create-authorization-subject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-authorization-subject.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/jwt/sign/create-authorization-subject.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAEtH;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,gBACf,yBAAyB,aAC3B,MAAM,KAClB,qBAKF,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAuthorizationSubject = void 0;
4
+ const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
5
+ /**
6
+ * This creates an authorization subject.
7
+ *
8
+ * @param subjectType the type of the subject
9
+ * @param subjectId the id of the subject (userid, safenetworkid etc.)
10
+ *
11
+ * @returns
12
+ */
13
+ const createAuthorizationSubject = (subjectType, subjectId) => {
14
+ if (!subjectId) {
15
+ throw new authorization_errors_1.SafeAuthorizationSubjectNotValidError(subjectType, subjectId);
16
+ }
17
+ return `${subjectType}:${subjectId}`;
18
+ };
19
+ exports.createAuthorizationSubject = createAuthorizationSubject;
@@ -0,0 +1,17 @@
1
+ import jwt from 'jsonwebtoken';
2
+ import { AuthorizationAudience, IAuthorizationSubject } from '../../../models/authorization/authorization-models';
3
+ /**
4
+ * This function creates the options for the jwt token issuance
5
+ *
6
+ * @param subject the subject of the token
7
+ * @param audience the audience of the token (default is sharedata)
8
+ * @param algorithm the algorithm to use (default is ES512)
9
+ * @param expiresIn the expiration time of the token (default is 1 hour)
10
+ * @param notBefore the not before time of the token (default is 0)
11
+ * @param keyid A unique identifier for the key used to sign the token. This can be used to prevent replay attacks. (optional)
12
+ * @param header An object containing additional header properties to include in the token. (optional)
13
+ * @returns
14
+ */
15
+ declare const createJwtOptions: (subject: IAuthorizationSubject, audience?: AuthorizationAudience | AuthorizationAudience[], algorithm?: jwt.Algorithm, expiresIn?: string | number, notBefore?: string | number, keyid?: string, header?: jwt.JwtHeader) => jwt.SignOptions;
16
+ export { createJwtOptions };
17
+ //# sourceMappingURL=create-jwt-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-jwt-options.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/jwt/sign/create-jwt-options.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAGlH;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,gBAAgB,YACT,qBAAqB,aACpB,qBAAqB,GAAG,qBAAqB,EAAE,cAC9C,GAAG,CAAC,SAAS,cACb,MAAM,GAAG,MAAM,cACf,MAAM,GAAG,MAAM,UAClB,MAAM,WACL,GAAG,CAAC,SAAS,KACvB,GAAG,CAAC,WAkBN,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}