@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,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyAuthorizationExpirationTime = void 0;
4
+ const authorization_errors_1 = require("../../../../../errors/authorization/authorization-errors");
5
+ /**
6
+ * this function validates the expiration time of the token hasn't passed
7
+ *
8
+ * @param exp the expiration time of the token
9
+ */
10
+ const verifyAuthorizationExpirationTime = (exp) => {
11
+ if (!exp) {
12
+ throw new authorization_errors_1.SafeAuthorizationMissingPropertyError('exp');
13
+ }
14
+ if (typeof exp !== 'number') {
15
+ throw new authorization_errors_1.SafeAuthorizationTokenPropertyDataTypeNotValidError('exp', exp, 'number');
16
+ }
17
+ const currentTime = new Date().getTime() / 1000; // get the current time in unix format
18
+ if (exp < currentTime) {
19
+ throw new authorization_errors_1.SafeAuthorizationPayloadNotValidError();
20
+ }
21
+ return true;
22
+ };
23
+ exports.verifyAuthorizationExpirationTime = verifyAuthorizationExpirationTime;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This function verifies that the issued at time is valid.
3
+ *
4
+ * @param iat the issued at time to verify
5
+ * @returns void (throws an error if the iat is not valid)
6
+ */
7
+ declare const verifyAuthorizationIssuedAtTime: (iat: unknown) => iat is number;
8
+ export { verifyAuthorizationIssuedAtTime };
9
+ //# sourceMappingURL=verify-authorization-issued-at-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-authorization-issued-at-time.d.ts","sourceRoot":"","sources":["../../../../../../../../../generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,QAAA,MAAM,+BAA+B,QAAS,OAAO,KAAG,GAAG,IAAI,MAc9D,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyAuthorizationIssuedAtTime = void 0;
4
+ const authorization_errors_1 = require("../../../../../errors/authorization/authorization-errors");
5
+ /**
6
+ * This function verifies that the issued at time is valid.
7
+ *
8
+ * @param iat the issued at time to verify
9
+ * @returns void (throws an error if the iat is not valid)
10
+ */
11
+ const verifyAuthorizationIssuedAtTime = (iat) => {
12
+ if (!iat) {
13
+ throw new authorization_errors_1.SafeAuthorizationMissingPropertyError('iat');
14
+ }
15
+ if (typeof iat !== 'number') {
16
+ throw new authorization_errors_1.SafeAuthorizationTokenPropertyDataTypeNotValidError('iat', iat, 'number');
17
+ }
18
+ const currentTime = new Date().getTime() / 1000; // get the current time in unix format
19
+ if (iat > currentTime) {
20
+ throw new authorization_errors_1.SafeAuthorizationPayloadNotValidError();
21
+ }
22
+ return true;
23
+ };
24
+ exports.verifyAuthorizationIssuedAtTime = verifyAuthorizationIssuedAtTime;
@@ -0,0 +1,10 @@
1
+ import { IAuthorizationIssuer } from '../../../../../models/authorization/authorization-models';
2
+ /**
3
+ * This function verifies that the incoming object is a valid authorization issuer.
4
+ *
5
+ * @param iss the object to verify
6
+ * @returns
7
+ */
8
+ declare const verifyAuthorizationIssuer: (iss: unknown) => iss is IAuthorizationIssuer;
9
+ export { verifyAuthorizationIssuer };
10
+ //# sourceMappingURL=verify-authorization-issuer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-authorization-issuer.d.ts","sourceRoot":"","sources":["../../../../../../../../../generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAEhG;;;;;GAKG;AACH,QAAA,MAAM,yBAAyB,QAAS,OAAO,KAAG,GAAG,IAAI,oBAexD,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyAuthorizationIssuer = void 0;
4
+ const authorization_errors_1 = require("../../../../../errors/authorization/authorization-errors");
5
+ /**
6
+ * This function verifies that the incoming object is a valid authorization issuer.
7
+ *
8
+ * @param iss the object to verify
9
+ * @returns
10
+ */
11
+ const verifyAuthorizationIssuer = (iss) => {
12
+ if (!iss) {
13
+ throw new authorization_errors_1.SafeAuthorizationMissingPropertyError('iss');
14
+ }
15
+ if (typeof iss !== 'string') {
16
+ throw new authorization_errors_1.SafeAuthorizationTokenPropertyDataTypeNotValidError('iss', iss, 'string');
17
+ }
18
+ const regex = /^[a-zA-Z0-9]+-[0-9a-fA-F]{8}$/; // make sure the incoming object is in the format of the authorization issuer
19
+ const isValidShape = regex.test(iss); // check if the incoming object is in the correct format
20
+ if (!isValidShape) { // if the incoming object is not in the correct format
21
+ return false;
22
+ }
23
+ return true;
24
+ };
25
+ exports.verifyAuthorizationIssuer = verifyAuthorizationIssuer;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This function verifies that the not before time is valid.
3
+ *
4
+ * @param nbf the not before time is the time before which the token is not valid
5
+ */
6
+ declare const verifyAuthorizationNotBeforeTime: (nbf: unknown) => nbf is number;
7
+ export { verifyAuthorizationNotBeforeTime };
8
+ //# sourceMappingURL=verify-authorization-not-before-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-authorization-not-before-time.d.ts","sourceRoot":"","sources":["../../../../../../../../../generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,gCAAgC,QAAS,OAAO,KAAG,GAAG,IAAI,MAc/D,CAAC;AAEF,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyAuthorizationNotBeforeTime = void 0;
4
+ const authorization_errors_1 = require("../../../../../errors/authorization/authorization-errors");
5
+ /**
6
+ * This function verifies that the not before time is valid.
7
+ *
8
+ * @param nbf the not before time is the time before which the token is not valid
9
+ */
10
+ const verifyAuthorizationNotBeforeTime = (nbf) => {
11
+ if (!nbf) {
12
+ throw new authorization_errors_1.SafeAuthorizationMissingPropertyError('nbf');
13
+ }
14
+ if (typeof nbf !== 'number') {
15
+ throw new authorization_errors_1.SafeAuthorizationTokenPropertyDataTypeNotValidError('nbf', nbf, 'number');
16
+ }
17
+ const currentTime = new Date().getTime() / 1000; // get the current time in unix format
18
+ if (nbf > currentTime) {
19
+ throw new authorization_errors_1.SafeAuthorizationPayloadNotValidError();
20
+ }
21
+ return true;
22
+ };
23
+ exports.verifyAuthorizationNotBeforeTime = verifyAuthorizationNotBeforeTime;
@@ -0,0 +1,10 @@
1
+ import { IAuthorizationSubject } from '../../../../../models/authorization/authorization-models';
2
+ /**
3
+ * This function validates that the input string is a valid authorization subject.
4
+ *
5
+ * @param sub The input string to validate.
6
+ * @returns True if the input is a valid authorization subject, false otherwise.
7
+ */
8
+ declare const verifyAuthorizationSubject: (sub: unknown) => sub is IAuthorizationSubject;
9
+ export { verifyAuthorizationSubject };
10
+ //# sourceMappingURL=verify-authorization-subject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-authorization-subject.d.ts","sourceRoot":"","sources":["../../../../../../../../../generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,qBAAqB,EAExB,MAAM,0DAA0D,CAAC;AAElE;;;;;GAKG;AACH,QAAA,MAAM,0BAA0B,QAAS,OAAO,KAAG,GAAG,IAAI,qBASzD,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyAuthorizationSubject = void 0;
4
+ const authorization_errors_1 = require("../../../../../errors/authorization/authorization-errors");
5
+ const authorization_models_1 = require("../../../../../models/authorization/authorization-models");
6
+ /**
7
+ * This function validates that the input string is a valid authorization subject.
8
+ *
9
+ * @param sub The input string to validate.
10
+ * @returns True if the input is a valid authorization subject, false otherwise.
11
+ */
12
+ const verifyAuthorizationSubject = (sub) => {
13
+ if (!sub) {
14
+ throw new authorization_errors_1.SafeAuthorizationMissingPropertyError('sub');
15
+ }
16
+ if (typeof sub !== 'string') {
17
+ throw new authorization_errors_1.SafeAuthorizationTokenPropertyDataTypeNotValidError('sub', sub, 'string');
18
+ }
19
+ const regex = new RegExp(`^(${Object.values(authorization_models_1.AuthorizationSubjectStart).join('|')}):.+$`);
20
+ return regex.test(sub);
21
+ };
22
+ exports.verifyAuthorizationSubject = verifyAuthorizationSubject;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This validates that the header encoding is the expected encoding for the token
3
+ *
4
+ * @param token the token to validate the header of.
5
+ * @returns
6
+ */
7
+ declare const verifyTokenHeader: (token: string) => boolean;
8
+ export { verifyTokenHeader };
9
+ //# sourceMappingURL=verify-token-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-token-header.d.ts","sourceRoot":"","sources":["../../../../../../../../generic/src/authorization/safe/validation/jwt/verify-token-header.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,UAAW,MAAM,KAAG,OAc1C,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyTokenHeader = void 0;
4
+ const authorization_settings_1 = require("../../../../_settings/authorization-settings");
5
+ const authorization_errors_1 = require("../../../../errors/authorization/authorization-errors");
6
+ const get_decoded_jwt_header_1 = require("../../../jwt/verify/get-decoded-jwt-header");
7
+ /**
8
+ * This validates that the header encoding is the expected encoding for the token
9
+ *
10
+ * @param token the token to validate the header of.
11
+ * @returns
12
+ */
13
+ const verifyTokenHeader = (token) => {
14
+ const jwtTokenParts = token.split('.');
15
+ if (jwtTokenParts.length !== 3) {
16
+ throw new authorization_errors_1.SafeAuthorizationTokenNotBase64Error();
17
+ }
18
+ const header = (0, get_decoded_jwt_header_1.getDecodedJwtHeader)(token);
19
+ if (header.alg !== authorization_settings_1.AuthorizationSettings.JWT.Algorithm ||
20
+ header.typ !== authorization_settings_1.AuthorizationSettings.JWT.HeaderType) {
21
+ return false;
22
+ }
23
+ return true;
24
+ };
25
+ exports.verifyTokenHeader = verifyTokenHeader;
@@ -0,0 +1,11 @@
1
+ import jwt from 'jsonwebtoken';
2
+ import { IValidSafeTokenPayload } from '../../../../models/authorization/authorization-models';
3
+ /**
4
+ * This function verifies the payload of the token to have the minimum token information from the decoded token payload.
5
+ *
6
+ * @param payload the payload to verify
7
+ * @returns void (throws an error if the payload is not valid)
8
+ */
9
+ declare const verifyTokenPayload: (payload: jwt.JwtPayload) => payload is IValidSafeTokenPayload;
10
+ export { verifyTokenPayload };
11
+ //# sourceMappingURL=verify-token-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-token-payload.d.ts","sourceRoot":"","sources":["../../../../../../../../generic/src/authorization/safe/validation/jwt/verify-token-payload.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,cAAc,CAAC;AAU/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAE/F;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,YAAa,GAAG,CAAC,UAAU,KAAG,OAAO,IAAI,sBAchE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyTokenPayload = void 0;
4
+ const authorization_errors_1 = require("../../../../errors/authorization/authorization-errors");
5
+ const verify_authorization_issuer_1 = require("./payload/verify-authorization-issuer");
6
+ const verify_authorization_subject_1 = require("./payload/verify-authorization-subject");
7
+ const verify_authorization_audience_1 = require("./payload/verify-authorization-audience");
8
+ const verify_authorization_not_before_time_1 = require("./payload/verify-authorization-not-before-time");
9
+ const verify_authorization_expiration_time_1 = require("./payload/verify-authorization-expiration-time");
10
+ const verify_authorization_issued_at_time_1 = require("./payload/verify-authorization-issued-at-time");
11
+ /**
12
+ * This function verifies the payload of the token to have the minimum token information from the decoded token payload.
13
+ *
14
+ * @param payload the payload to verify
15
+ * @returns void (throws an error if the payload is not valid)
16
+ */
17
+ const verifyTokenPayload = (payload) => {
18
+ if (!payload || typeof payload !== 'object') {
19
+ throw new authorization_errors_1.SafeAuthorizationPayloadNotValidError();
20
+ }
21
+ // make sure the issued at time is a valid
22
+ (0, verify_authorization_issued_at_time_1.verifyAuthorizationIssuedAtTime)(payload.iat);
23
+ (0, verify_authorization_not_before_time_1.verifyAuthorizationNotBeforeTime)(payload.nbf);
24
+ (0, verify_authorization_expiration_time_1.verifyAuthorizationExpirationTime)(payload.exp);
25
+ (0, verify_authorization_subject_1.verifyAuthorizationSubject)(payload.sub);
26
+ (0, verify_authorization_audience_1.verifyAuthorizationAudience)(payload.aud);
27
+ (0, verify_authorization_issuer_1.verifyAuthorizationIssuer)(payload.iss);
28
+ return true;
29
+ };
30
+ exports.verifyTokenPayload = verifyTokenPayload;
@@ -0,0 +1,20 @@
1
+ import { BaseError } from '../base-error';
2
+ /**
3
+ * This is throw when the Audit Log Additional Id's reference id is not provided.
4
+ */
5
+ export declare class AuditLogAlaiIdNotProvidedError extends BaseError {
6
+ /**
7
+ * This is throw when the Additional Log Additional Id's reference id is not provided.
8
+ */
9
+ constructor();
10
+ }
11
+ /**
12
+ * This is throw when the Audit Log Additional Id's query is not provided.
13
+ */
14
+ export declare class AuditLogAlaiQueryNotProvidedError extends BaseError {
15
+ /**
16
+ * This is throw when the Audit Log Additional Id's query is not provided.
17
+ */
18
+ constructor();
19
+ }
20
+ //# sourceMappingURL=audit-log-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-log-errors.d.ts","sourceRoot":"","sources":["../../../../../../generic/src/errors/audit-log/audit-log-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI1C;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,SAAS;IACzD;;OAEG;;CAIN;AAED;;GAEG;AACH,qBAAa,iCAAkC,SAAQ,SAAS;IAC5D;;OAEG;;CAIN"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuditLogAlaiQueryNotProvidedError = exports.AuditLogAlaiIdNotProvidedError = void 0;
4
+ // This file contains the errors for that can occur in the audit log.
5
+ const base_error_1 = require("../base-error");
6
+ //#region Audit Log Additional Id's Errors
7
+ /**
8
+ * This is throw when the Audit Log Additional Id's reference id is not provided.
9
+ */
10
+ class AuditLogAlaiIdNotProvidedError extends base_error_1.BaseError {
11
+ /**
12
+ * This is throw when the Additional Log Additional Id's reference id is not provided.
13
+ */
14
+ constructor() {
15
+ super('Audit Log Additional Id\'s reference id is not provided');
16
+ }
17
+ }
18
+ exports.AuditLogAlaiIdNotProvidedError = AuditLogAlaiIdNotProvidedError;
19
+ /**
20
+ * This is throw when the Audit Log Additional Id's query is not provided.
21
+ */
22
+ class AuditLogAlaiQueryNotProvidedError extends base_error_1.BaseError {
23
+ /**
24
+ * This is throw when the Audit Log Additional Id's query is not provided.
25
+ */
26
+ constructor() {
27
+ super('Audit Log Additional Id\'s query is not provided');
28
+ }
29
+ }
30
+ exports.AuditLogAlaiQueryNotProvidedError = AuditLogAlaiQueryNotProvidedError;
31
+ //#endregion Audit Log Additional Id's Errors
@@ -0,0 +1,106 @@
1
+ import { AuthorityValidationType } from '../../models/authorization/authorization-models';
2
+ import { BaseError } from '../base-error';
3
+ /**
4
+ * This is thrown when the removal of a IJWTAuthority fails because it does not exist.
5
+ */
6
+ export declare class SafeAuthorizationIssuerDoesNotExistError extends BaseError {
7
+ constructor(issuer: string);
8
+ }
9
+ /**
10
+ * This is thrown when a authority validation request is received the type of validation requested is unknown.
11
+ * (this should not happen).
12
+ */
13
+ export declare class SafeAuthorizationAuthorityValidationTypeNotValidError extends BaseError {
14
+ constructor(validationType: AuthorityValidationType);
15
+ }
16
+ /**
17
+ * This is throw when a database records is not found.
18
+ */
19
+ export declare class SafeAuthorizationSubjectNotValidError extends BaseError {
20
+ constructor(subjectType: string, subjectId: string);
21
+ }
22
+ /**
23
+ * This is thrown when the public key given for the issuer is not valid.
24
+ */
25
+ export declare class SafeAuthorizationIssuerPublicKeyNotValidError extends BaseError {
26
+ constructor(issuerName: string, publicKey: string);
27
+ }
28
+ /**
29
+ * This is thrown when the issuer is not valid.
30
+ */
31
+ export declare class SafeAuthorizationIssuerNotValidError extends BaseError {
32
+ constructor(issuer: string);
33
+ }
34
+ /**
35
+ * This is thrown when the JWT token is not the corrent base64 encoding
36
+ */
37
+ export declare class SafeAuthorizationTokenNotBase64Error extends BaseError {
38
+ constructor();
39
+ }
40
+ /**
41
+ * This is thrown when the secret key or public key is not included for token verification.
42
+ */
43
+ export declare class SafeAuthorizationKeyNotIncludedForVerificationError extends BaseError {
44
+ constructor();
45
+ }
46
+ /**
47
+ * This is thrown when the authorization payload is not valid.
48
+ */
49
+ export declare class SafeAuthorizationPayloadNotValidError extends BaseError {
50
+ constructor();
51
+ }
52
+ /**
53
+ * This is thrown when the type of data in a token is not valid
54
+ */
55
+ export declare class SafeAuthorizationTokenPropertyDataTypeNotValidError extends BaseError {
56
+ constructor(property: string, propertyValue: any, expectedDataType: string);
57
+ }
58
+ /**
59
+ * This is thrown when the authorization payload is missing a property
60
+ */
61
+ export declare class SafeAuthorizationMissingPropertyError extends BaseError {
62
+ constructor(property: string);
63
+ }
64
+ /**
65
+ * This is thrown when the issued at time is before the current time
66
+ */
67
+ export declare class SafeAuthorizationTokenIssuedAtTimeNotValidError extends BaseError {
68
+ constructor();
69
+ }
70
+ /**
71
+ * This is thrown not authorization exists on the request.
72
+ */
73
+ export declare class SafeAuthorizationNotExistsError extends BaseError {
74
+ constructor();
75
+ }
76
+ /**
77
+ * This is thrown when the bearer token is not found
78
+ */
79
+ export declare class SafeAuthorizationBearerTokenNotFound extends BaseError {
80
+ constructor();
81
+ }
82
+ /**
83
+ * This is thrown when the authorization request headers are not found.
84
+ */
85
+ export declare class SafeRequestAuthorizationHeadersNotFound extends BaseError {
86
+ constructor();
87
+ }
88
+ /**
89
+ * This is thrown when the authorization is not found in the request headers.
90
+ */
91
+ export declare class SafeRequestAuthorizationHeaderNotFound extends BaseError {
92
+ constructor();
93
+ }
94
+ /**
95
+ * This is thrown when the Issuer does not match the expected issuer.
96
+ */
97
+ export declare class SafeAuthorizationIssuerNotMatchingExpectedError extends BaseError {
98
+ constructor(expectedIssuer: string, actualIssuer: string);
99
+ }
100
+ /**
101
+ * This is thrown when the decoded token null or a string (not an object)
102
+ */
103
+ export declare class SafeAuthorizationTokenNotObjectError extends BaseError {
104
+ constructor();
105
+ }
106
+ //# sourceMappingURL=authorization-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-errors.d.ts","sourceRoot":"","sources":["../../../../../../generic/src/errors/authorization/authorization-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;GAEG;AACH,qBAAa,wCAAyC,SAAQ,SAAS;gBACvD,MAAM,EAAE,MAAM;CAG7B;AAED;;;GAGG;AACH,qBAAa,qDAAsD,SAAQ,SAAS;gBACpE,cAAc,EAAE,uBAAuB;CAGtD;AAED;;GAEG;AACH,qBAAa,qCAAsC,SAAQ,SAAS;gBACpD,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAGrD;AAED;;GAEG;AACH,qBAAa,6CAA8C,SAAQ,SAAS;gBAC5D,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAGpD;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,SAAS;gBACnD,MAAM,EAAE,MAAM;CAG7B;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,SAAS;;CAIlE;AAED;;GAEG;AACH,qBAAa,mDAAoD,SAAQ,SAAS;;CAIjF;AAED;;GAEG;AACH,qBAAa,qCAAsC,SAAQ,SAAS;;CAInE;AAED;;GAEG;AACH,qBAAa,mDAAoD,SAAQ,SAAS;gBAClE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM;CAG7E;AAED;;GAEG;AACH,qBAAa,qCAAsC,SAAQ,SAAS;gBACpD,QAAQ,EAAE,MAAM;CAG/B;AAED;;GAEG;AACH,qBAAa,+CAAgD,SAAQ,SAAS;;CAI7E;AAED;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,SAAS;;CAI7D;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,SAAS;;CAIlE;AAKD;;GAEG;AACH,qBAAa,uCAAwC,SAAQ,SAAS;;CAIrE;AAED;;GAEG;AACH,qBAAa,sCAAuC,SAAQ,SAAS;;CAIpE;AAED;;GAEG;AACH,qBAAa,+CAAgD,SAAQ,SAAS;gBAC9D,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAG3D;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,SAAS;;CAIlE"}
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SafeAuthorizationTokenNotObjectError = exports.SafeAuthorizationIssuerNotMatchingExpectedError = exports.SafeRequestAuthorizationHeaderNotFound = exports.SafeRequestAuthorizationHeadersNotFound = exports.SafeAuthorizationBearerTokenNotFound = exports.SafeAuthorizationNotExistsError = exports.SafeAuthorizationTokenIssuedAtTimeNotValidError = exports.SafeAuthorizationMissingPropertyError = exports.SafeAuthorizationTokenPropertyDataTypeNotValidError = exports.SafeAuthorizationPayloadNotValidError = exports.SafeAuthorizationKeyNotIncludedForVerificationError = exports.SafeAuthorizationTokenNotBase64Error = exports.SafeAuthorizationIssuerNotValidError = exports.SafeAuthorizationIssuerPublicKeyNotValidError = exports.SafeAuthorizationSubjectNotValidError = exports.SafeAuthorizationAuthorityValidationTypeNotValidError = exports.SafeAuthorizationIssuerDoesNotExistError = void 0;
4
+ const base_error_1 = require("../base-error");
5
+ /**
6
+ * This is thrown when the removal of a IJWTAuthority fails because it does not exist.
7
+ */
8
+ class SafeAuthorizationIssuerDoesNotExistError extends base_error_1.BaseError {
9
+ constructor(issuer) {
10
+ super(`The authorization issuer ${issuer} does not exist`);
11
+ }
12
+ }
13
+ exports.SafeAuthorizationIssuerDoesNotExistError = SafeAuthorizationIssuerDoesNotExistError;
14
+ /**
15
+ * This is thrown when a authority validation request is received the type of validation requested is unknown.
16
+ * (this should not happen).
17
+ */
18
+ class SafeAuthorizationAuthorityValidationTypeNotValidError extends base_error_1.BaseError {
19
+ constructor(validationType) {
20
+ super(`The authority validation type is not valid, the type is ${validationType}`);
21
+ }
22
+ }
23
+ exports.SafeAuthorizationAuthorityValidationTypeNotValidError = SafeAuthorizationAuthorityValidationTypeNotValidError;
24
+ /**
25
+ * This is throw when a database records is not found.
26
+ */
27
+ class SafeAuthorizationSubjectNotValidError extends base_error_1.BaseError {
28
+ constructor(subjectType, subjectId) {
29
+ super(`The authorization subject ${subjectType} with id ${subjectId} is not valid`);
30
+ }
31
+ }
32
+ exports.SafeAuthorizationSubjectNotValidError = SafeAuthorizationSubjectNotValidError;
33
+ /**
34
+ * This is thrown when the public key given for the issuer is not valid.
35
+ */
36
+ class SafeAuthorizationIssuerPublicKeyNotValidError extends base_error_1.BaseError {
37
+ constructor(issuerName, publicKey) {
38
+ super(`The authorization issuer ${issuerName} with public key ${publicKey} is not valid`);
39
+ }
40
+ }
41
+ exports.SafeAuthorizationIssuerPublicKeyNotValidError = SafeAuthorizationIssuerPublicKeyNotValidError;
42
+ /**
43
+ * This is thrown when the issuer is not valid.
44
+ */
45
+ class SafeAuthorizationIssuerNotValidError extends base_error_1.BaseError {
46
+ constructor(issuer) {
47
+ super(`The authorization issuer ${issuer} is not valid`);
48
+ }
49
+ }
50
+ exports.SafeAuthorizationIssuerNotValidError = SafeAuthorizationIssuerNotValidError;
51
+ /**
52
+ * This is thrown when the JWT token is not the corrent base64 encoding
53
+ */
54
+ class SafeAuthorizationTokenNotBase64Error extends base_error_1.BaseError {
55
+ constructor() {
56
+ super('The authorization token is not a valid base64 encoding');
57
+ }
58
+ }
59
+ exports.SafeAuthorizationTokenNotBase64Error = SafeAuthorizationTokenNotBase64Error;
60
+ /**
61
+ * This is thrown when the secret key or public key is not included for token verification.
62
+ */
63
+ class SafeAuthorizationKeyNotIncludedForVerificationError extends base_error_1.BaseError {
64
+ constructor() {
65
+ super('The secret of public key is not included for token verification');
66
+ }
67
+ }
68
+ exports.SafeAuthorizationKeyNotIncludedForVerificationError = SafeAuthorizationKeyNotIncludedForVerificationError;
69
+ /**
70
+ * This is thrown when the authorization payload is not valid.
71
+ */
72
+ class SafeAuthorizationPayloadNotValidError extends base_error_1.BaseError {
73
+ constructor() {
74
+ super('The authorization payload is not valid');
75
+ }
76
+ }
77
+ exports.SafeAuthorizationPayloadNotValidError = SafeAuthorizationPayloadNotValidError;
78
+ /**
79
+ * This is thrown when the type of data in a token is not valid
80
+ */
81
+ class SafeAuthorizationTokenPropertyDataTypeNotValidError extends base_error_1.BaseError {
82
+ constructor(property, propertyValue, expectedDataType) {
83
+ super(`The property ${property} with value ${propertyValue} is not a valid ${expectedDataType}`);
84
+ }
85
+ }
86
+ exports.SafeAuthorizationTokenPropertyDataTypeNotValidError = SafeAuthorizationTokenPropertyDataTypeNotValidError;
87
+ /**
88
+ * This is thrown when the authorization payload is missing a property
89
+ */
90
+ class SafeAuthorizationMissingPropertyError extends base_error_1.BaseError {
91
+ constructor(property) {
92
+ super(`The authorization payload is missing the property ${property}`);
93
+ }
94
+ }
95
+ exports.SafeAuthorizationMissingPropertyError = SafeAuthorizationMissingPropertyError;
96
+ /**
97
+ * This is thrown when the issued at time is before the current time
98
+ */
99
+ class SafeAuthorizationTokenIssuedAtTimeNotValidError extends base_error_1.BaseError {
100
+ constructor() {
101
+ super('The issued at time of the token is not valid: ');
102
+ }
103
+ }
104
+ exports.SafeAuthorizationTokenIssuedAtTimeNotValidError = SafeAuthorizationTokenIssuedAtTimeNotValidError;
105
+ /**
106
+ * This is thrown not authorization exists on the request.
107
+ */
108
+ class SafeAuthorizationNotExistsError extends base_error_1.BaseError {
109
+ constructor() {
110
+ super('The authorization does not exist');
111
+ }
112
+ }
113
+ exports.SafeAuthorizationNotExistsError = SafeAuthorizationNotExistsError;
114
+ /**
115
+ * This is thrown when the bearer token is not found
116
+ */
117
+ class SafeAuthorizationBearerTokenNotFound extends base_error_1.BaseError {
118
+ constructor() {
119
+ super('The bearer token is not found');
120
+ }
121
+ }
122
+ exports.SafeAuthorizationBearerTokenNotFound = SafeAuthorizationBearerTokenNotFound;
123
+ //#region Safe Request Authorization Errors
124
+ /**
125
+ * This is thrown when the authorization request headers are not found.
126
+ */
127
+ class SafeRequestAuthorizationHeadersNotFound extends base_error_1.BaseError {
128
+ constructor() {
129
+ super('The authorization request headers are not found');
130
+ }
131
+ }
132
+ exports.SafeRequestAuthorizationHeadersNotFound = SafeRequestAuthorizationHeadersNotFound;
133
+ /**
134
+ * This is thrown when the authorization is not found in the request headers.
135
+ */
136
+ class SafeRequestAuthorizationHeaderNotFound extends base_error_1.BaseError {
137
+ constructor() {
138
+ super('The authorization header is not found');
139
+ }
140
+ }
141
+ exports.SafeRequestAuthorizationHeaderNotFound = SafeRequestAuthorizationHeaderNotFound;
142
+ /**
143
+ * This is thrown when the Issuer does not match the expected issuer.
144
+ */
145
+ class SafeAuthorizationIssuerNotMatchingExpectedError extends base_error_1.BaseError {
146
+ constructor(expectedIssuer, actualIssuer) {
147
+ super(`The expected issuer ${expectedIssuer} does not match the actual issuer ${actualIssuer}`);
148
+ }
149
+ }
150
+ exports.SafeAuthorizationIssuerNotMatchingExpectedError = SafeAuthorizationIssuerNotMatchingExpectedError;
151
+ /**
152
+ * This is thrown when the decoded token null or a string (not an object)
153
+ */
154
+ class SafeAuthorizationTokenNotObjectError extends base_error_1.BaseError {
155
+ constructor() {
156
+ super('The decoded token is not an object');
157
+ }
158
+ }
159
+ exports.SafeAuthorizationTokenNotObjectError = SafeAuthorizationTokenNotObjectError;
160
+ //#endregion Safe Request Authorization Errors
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This is the base error class that all other errors should extend from.
3
+ */
4
+ export declare class BaseError extends Error {
5
+ errorCode?: number;
6
+ /**
7
+ * This is the base error type for the application.
8
+ *
9
+ * @param message the message to include.
10
+ * @param errorCode the error code if we want to include one.
11
+ */
12
+ constructor(message: string, errorCode?: number);
13
+ /**
14
+ * This function returns the error as a JSON object.
15
+ */
16
+ toJSON(): {
17
+ message: string;
18
+ errorType: string;
19
+ errorCode: number | undefined;
20
+ stack: string | undefined;
21
+ };
22
+ }
23
+ //# sourceMappingURL=base-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-error.d.ts","sourceRoot":"","sources":["../../../../../generic/src/errors/base-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAU/C;;OAEG;IACI,MAAM;;;;;;CAQhB"}