@degenerate/endpoints 0.0.5 → 0.0.6

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 (84) hide show
  1. package/dist/endpoints/src/examples/express-server/app.d.ts.map +1 -1
  2. package/dist/endpoints/src/examples/express-server/app.js +2 -2
  3. package/package.json +2 -2
  4. package/dist/generic/src/_settings/authorization-settings.d.ts +0 -17
  5. package/dist/generic/src/_settings/authorization-settings.d.ts.map +0 -1
  6. package/dist/generic/src/_settings/authorization-settings.js +0 -20
  7. package/dist/generic/src/authorization/index.d.ts +0 -24
  8. package/dist/generic/src/authorization/index.d.ts.map +0 -1
  9. package/dist/generic/src/authorization/index.js +0 -61
  10. package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.d.ts +0 -9
  11. package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.d.ts.map +0 -1
  12. package/dist/generic/src/authorization/jwt/keys/create-public-key-pem.js +0 -25
  13. package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.d.ts +0 -9
  14. package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.d.ts.map +0 -1
  15. package/dist/generic/src/authorization/jwt/keys/create-secret-key-pem.js +0 -24
  16. package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.d.ts +0 -10
  17. package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.d.ts.map +0 -1
  18. package/dist/generic/src/authorization/jwt/sign/create-authorization-issuer.js +0 -26
  19. package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.d.ts +0 -12
  20. package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.d.ts.map +0 -1
  21. package/dist/generic/src/authorization/jwt/sign/create-authorization-subject.js +0 -19
  22. package/dist/generic/src/authorization/jwt/sign/create-jwt-options.d.ts +0 -17
  23. package/dist/generic/src/authorization/jwt/sign/create-jwt-options.d.ts.map +0 -1
  24. package/dist/generic/src/authorization/jwt/sign/create-jwt-options.js +0 -43
  25. package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.d.ts +0 -13
  26. package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.d.ts.map +0 -1
  27. package/dist/generic/src/authorization/jwt/sign/create-jwt-signed-token.js +0 -22
  28. package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts +0 -10
  29. package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts.map +0 -1
  30. package/dist/generic/src/authorization/jwt/transform/transform-token-payload-to-safe-payload.js +0 -31
  31. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.d.ts +0 -10
  32. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.d.ts.map +0 -1
  33. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-header.js +0 -20
  34. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts +0 -9
  35. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts.map +0 -1
  36. package/dist/generic/src/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.js +0 -17
  37. package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.d.ts +0 -12
  38. package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.d.ts.map +0 -1
  39. package/dist/generic/src/authorization/jwt/verify/verify-jwt-signed-token.js +0 -34
  40. package/dist/generic/src/authorization/safe/authorization/authorized-authorities.d.ts +0 -42
  41. package/dist/generic/src/authorization/safe/authorization/authorized-authorities.d.ts.map +0 -1
  42. package/dist/generic/src/authorization/safe/authorization/authorized-authorities.js +0 -65
  43. package/dist/generic/src/authorization/safe/request/decode-bearer-token.d.ts +0 -11
  44. package/dist/generic/src/authorization/safe/request/decode-bearer-token.d.ts.map +0 -1
  45. package/dist/generic/src/authorization/safe/request/decode-bearer-token.js +0 -31
  46. package/dist/generic/src/authorization/safe/request/decode-safe-request.d.ts +0 -11
  47. package/dist/generic/src/authorization/safe/request/decode-safe-request.d.ts.map +0 -1
  48. package/dist/generic/src/authorization/safe/request/decode-safe-request.js +0 -30
  49. package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.d.ts +0 -10
  50. package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.d.ts.map +0 -1
  51. package/dist/generic/src/authorization/safe/request/determine-issuer-from-request.js +0 -29
  52. package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts +0 -12
  53. package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts.map +0 -1
  54. package/dist/generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.js +0 -30
  55. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts +0 -10
  56. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts.map +0 -1
  57. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.js +0 -24
  58. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts +0 -8
  59. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts.map +0 -1
  60. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.js +0 -23
  61. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts +0 -9
  62. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts.map +0 -1
  63. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.js +0 -24
  64. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts +0 -10
  65. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts.map +0 -1
  66. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-issuer.js +0 -25
  67. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts +0 -8
  68. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts.map +0 -1
  69. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.js +0 -23
  70. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts +0 -10
  71. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts.map +0 -1
  72. package/dist/generic/src/authorization/safe/validation/jwt/payload/verify-authorization-subject.js +0 -22
  73. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.d.ts +0 -9
  74. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.d.ts.map +0 -1
  75. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-header.js +0 -25
  76. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.d.ts +0 -11
  77. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.d.ts.map +0 -1
  78. package/dist/generic/src/authorization/safe/validation/jwt/verify-token-payload.js +0 -30
  79. package/dist/generic/src/helpers/crypto/cryptography-helpers.d.ts +0 -37
  80. package/dist/generic/src/helpers/crypto/cryptography-helpers.d.ts.map +0 -1
  81. package/dist/generic/src/helpers/crypto/cryptography-helpers.js +0 -65
  82. package/dist/generic/src/helpers/object-validation-helpers.d.ts +0 -66
  83. package/dist/generic/src/helpers/object-validation-helpers.d.ts.map +0 -1
  84. package/dist/generic/src/helpers/object-validation-helpers.js +0 -254
@@ -1,42 +0,0 @@
1
- import { AuthorizationAudience, IAuthorizationIssuer } from '../../../models/authorization/authorization-models';
2
- /**
3
- * This class is used to keep and maintain the authorized authorities in the SAFE system.
4
- */
5
- export declare class AuthorizedAuthorities {
6
- private _authorizedJWTAuthorities;
7
- private _currentJWTAuthoritiesHash;
8
- constructor();
9
- /**
10
- * This adds a JWT authority to the authorized authorities for the given audience.
11
- *
12
- * @param audience the audience the authority is for
13
- * @param authorizationIssuer the authority to add
14
- * @param publicKey the public key
15
- */
16
- addAuthorizedJWTAuthority(audience: AuthorizationAudience, authorizationIssuer: IAuthorizationIssuer, publicKey: string): void;
17
- /**
18
- * This removes a JWT authority from the authorized authorities for the given audience.
19
- *
20
- * @param authority the authority to remove
21
- */
22
- removeAuthorizedJWTAuthority(audience: AuthorizationAudience, authority: IAuthorizationIssuer): void;
23
- /**
24
- * This gets the public key for the given authority for the given audience.
25
- *
26
- * @param authority the authority to get the public key for
27
- * @returns
28
- */
29
- getAuthorizedJWTAuthorityPublicKey(audience: AuthorizationAudience, authority: IAuthorizationIssuer): string | undefined;
30
- /**
31
- * this gets the authorized JWT authorities for the given audience.
32
- * @param audience the audience to get the authorized authorities for
33
- * @returns
34
- */
35
- getAuthorizedJWTAuthorities(audience: AuthorizationAudience): Map<IAuthorizationIssuer, string>;
36
- /**
37
- * This gets the number of authorized JWT providers for the given audience.
38
- * @returns
39
- */
40
- getAuthorizedJWTAuthoritiesCount(audience: AuthorizationAudience): number;
41
- }
42
- //# sourceMappingURL=authorized-authorities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authorized-authorities.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/safe/authorization/authorized-authorities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAiB,MAAM,oDAAoD,CAAC;AAEhI;;GAEG;AACH,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,yBAAyB,CAAgE;IAEjG,OAAO,CAAC,0BAA0B,CAAqC;;IAYtE;;;;;;MAME;IACI,yBAAyB,CAC5B,QAAQ,EAAE,qBAAqB,EAC/B,mBAAmB,EAAE,oBAAoB,EACzC,SAAS,EAAE,MAAM,GAClB,IAAI;IAKP;;;;OAIG;IACI,4BAA4B,CAAC,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAO3G;;;;;OAKG;IACI,kCAAkC,CAAC,QAAQ,EAAE,qBAAqB,EAAE,SAAS,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS;IAI/H;;;;OAIG;IACI,2BAA2B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAItG;;;OAGG;IACI,gCAAgC,CAAC,QAAQ,EAAE,qBAAqB,GAAG,MAAM;CAGnF"}
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthorizedAuthorities = 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 class is used to keep and maintain the authorized authorities in the SAFE system.
8
- */
9
- class AuthorizedAuthorities {
10
- constructor() {
11
- this._authorizedJWTAuthorities = new Map();
12
- this._currentJWTAuthoritiesHash = new Map();
13
- Object.values(authorization_models_1.AuthorizationAudience).forEach(audience => {
14
- this._authorizedJWTAuthorities.set(audience, new Map());
15
- this._currentJWTAuthoritiesHash.set(audience, '');
16
- });
17
- }
18
- /**
19
- * This adds a JWT authority to the authorized authorities for the given audience.
20
- *
21
- * @param audience the audience the authority is for
22
- * @param authorizationIssuer the authority to add
23
- * @param publicKey the public key
24
- */
25
- addAuthorizedJWTAuthority(audience, authorizationIssuer, publicKey) {
26
- const audienceMap = this._authorizedJWTAuthorities.get(audience);
27
- audienceMap?.set(authorizationIssuer, publicKey);
28
- }
29
- /**
30
- * This removes a JWT authority from the authorized authorities for the given audience.
31
- *
32
- * @param authority the authority to remove
33
- */
34
- removeAuthorizedJWTAuthority(audience, authority) {
35
- const removed = this._authorizedJWTAuthorities.get(audience)?.delete(authority);
36
- if (!removed) {
37
- throw new authorization_errors_1.SafeAuthorizationIssuerDoesNotExistError(authority);
38
- }
39
- }
40
- /**
41
- * This gets the public key for the given authority for the given audience.
42
- *
43
- * @param authority the authority to get the public key for
44
- * @returns
45
- */
46
- getAuthorizedJWTAuthorityPublicKey(audience, authority) {
47
- return this._authorizedJWTAuthorities.get(audience)?.get(authority);
48
- }
49
- /**
50
- * this gets the authorized JWT authorities for the given audience.
51
- * @param audience the audience to get the authorized authorities for
52
- * @returns
53
- */
54
- getAuthorizedJWTAuthorities(audience) {
55
- return this._authorizedJWTAuthorities.get(audience) || new Map();
56
- }
57
- /**
58
- * This gets the number of authorized JWT providers for the given audience.
59
- * @returns
60
- */
61
- getAuthorizedJWTAuthoritiesCount(audience) {
62
- return this._authorizedJWTAuthorities.get(audience)?.size || 0;
63
- }
64
- }
65
- exports.AuthorizedAuthorities = AuthorizedAuthorities;
@@ -1,11 +0,0 @@
1
- import { IDecodedJwtToken } from '../../../models/authorization/authorization-models';
2
- /**
3
- * This function decodes the bearer token and verifies the issuer is as expected.
4
- *
5
- * @param bearerToken the bearer token to decode
6
- * @param verificationKey the key to verify the token with
7
- * @param issuerExpected the expected issuer of the token
8
- */
9
- declare const decodeBearerToken: (bearerToken: string, verificationKey: string, issuerExpected: string) => IDecodedJwtToken;
10
- export { decodeBearerToken };
11
- //# sourceMappingURL=decode-bearer-token.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decode-bearer-token.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/safe/request/decode-bearer-token.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAKtF;;;;;;GAMG;AACH,QAAA,MAAM,iBAAiB,gBAAiB,MAAM,mBAAmB,MAAM,kBAAkB,MAAM,KAAG,gBAkBjG,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeBearerToken = void 0;
4
- const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
5
- const transform_token_payload_to_safe_payload_1 = require("../../jwt/transform/transform-token-payload-to-safe-payload");
6
- const verify_jwt_signed_token_1 = require("../../jwt/verify/verify-jwt-signed-token");
7
- const verify_token_payload_1 = require("../validation/jwt/verify-token-payload");
8
- /**
9
- * This function decodes the bearer token and verifies the issuer is as expected.
10
- *
11
- * @param bearerToken the bearer token to decode
12
- * @param verificationKey the key to verify the token with
13
- * @param issuerExpected the expected issuer of the token
14
- */
15
- const decodeBearerToken = (bearerToken, verificationKey, issuerExpected) => {
16
- const decodedToken = (0, verify_jwt_signed_token_1.verifyJwtSignedToken)(bearerToken, verificationKey);
17
- if (!decodedToken || typeof decodedToken === 'string') {
18
- throw new authorization_errors_1.SafeAuthorizationTokenNotObjectError();
19
- }
20
- if (issuerExpected !== decodedToken.iss) {
21
- throw new authorization_errors_1.SafeAuthorizationIssuerNotMatchingExpectedError(issuerExpected, decodedToken.iss.toString());
22
- }
23
- // validate the token payload
24
- if (!(0, verify_token_payload_1.verifyTokenPayload)(decodedToken)) {
25
- throw new authorization_errors_1.SafeAuthorizationPayloadNotValidError();
26
- }
27
- // transform the token payload to a safe payload
28
- const decodedTokenPayload = (0, transform_token_payload_to_safe_payload_1.transformTokenPayloadToSafePayload)(decodedToken);
29
- return decodedTokenPayload;
30
- };
31
- exports.decodeBearerToken = decodeBearerToken;
@@ -1,11 +0,0 @@
1
- import { IDecodedJwtToken } from '../../../models/authorization/authorization-models';
2
- /**
3
- * This function decodes the safe request and returns the decoded token.
4
- * This will throw an error if the request is not authorized.
5
- *
6
- * @param req the request to ensure authorization exists on.
7
- * @returns
8
- */
9
- declare const decodeSafeRequest: (req: any, verificationKey: string, issuerExpected: string) => IDecodedJwtToken;
10
- export { decodeSafeRequest };
11
- //# sourceMappingURL=decode-safe-request.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decode-safe-request.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/safe/request/decode-safe-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAEtF;;;;;;GAMG;AACH,QAAA,MAAM,iBAAiB,QAAS,GAAG,mBAAmB,MAAM,kBAAkB,MAAM,KAAG,gBAatF,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeSafeRequest = void 0;
4
- const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
5
- const decode_bearer_token_1 = require("./decode-bearer-token");
6
- /**
7
- * This function decodes the safe request and returns the decoded token.
8
- * This will throw an error if the request is not authorized.
9
- *
10
- * @param req the request to ensure authorization exists on.
11
- * @returns
12
- */
13
- const decodeSafeRequest = (req, verificationKey, issuerExpected) => {
14
- if (!req.headers)
15
- throw new authorization_errors_1.SafeRequestAuthorizationHeadersNotFound();
16
- if (!req.headers.authorization)
17
- throw new authorization_errors_1.SafeRequestAuthorizationHeaderNotFound();
18
- if (typeof req.headers.authorization === 'string' && req.headers.authorization.startsWith('Bearer ')) {
19
- const bearerToken = req.headers.authorization.split('Bearer ')[1];
20
- if (!bearerToken) {
21
- throw new authorization_errors_1.SafeAuthorizationBearerTokenNotFound();
22
- }
23
- const decodedToken = (0, decode_bearer_token_1.decodeBearerToken)(bearerToken, verificationKey, issuerExpected);
24
- return decodedToken;
25
- }
26
- else {
27
- throw new authorization_errors_1.SafeAuthorizationBearerTokenNotFound();
28
- }
29
- };
30
- exports.decodeSafeRequest = decodeSafeRequest;
@@ -1,10 +0,0 @@
1
- import { IAuthorizationIssuer } from '../../../models/authorization/authorization-models';
2
- /**
3
- * This function determines the issuer from the request.
4
- *
5
- * @param req the request to determine the issuer from
6
- * @returns
7
- */
8
- declare const determineIssuerFromRequest: (req: any) => IAuthorizationIssuer;
9
- export { determineIssuerFromRequest };
10
- //# sourceMappingURL=determine-issuer-from-request.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"determine-issuer-from-request.d.ts","sourceRoot":"","sources":["../../../../../../../generic/src/authorization/safe/request/determine-issuer-from-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAG1F;;;;;GAKG;AACH,QAAA,MAAM,0BAA0B,QAAS,GAAG,KAAG,oBAa9C,CAAA;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.determineIssuerFromRequest = void 0;
4
- const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
5
- const determine_issuer_from_bearer_token_1 = require("./issuer/determine-issuer-from-bearer-token");
6
- /**
7
- * This function determines the issuer from the request.
8
- *
9
- * @param req the request to determine the issuer from
10
- * @returns
11
- */
12
- const determineIssuerFromRequest = (req) => {
13
- if (!req.headers)
14
- throw new authorization_errors_1.SafeRequestAuthorizationHeadersNotFound();
15
- if (!req.headers.authorization)
16
- throw new authorization_errors_1.SafeRequestAuthorizationHeaderNotFound();
17
- if (typeof req.headers.authorization === 'string' && req.headers.authorization.startsWith('Bearer ')) {
18
- const bearerToken = req.headers.authorization.split('Bearer ')[1];
19
- if (!bearerToken) {
20
- throw new authorization_errors_1.SafeAuthorizationBearerTokenNotFound();
21
- }
22
- const issuer = (0, determine_issuer_from_bearer_token_1.determineIssuerFromBearerToken)(bearerToken);
23
- return issuer;
24
- }
25
- else {
26
- throw new authorization_errors_1.SafeAuthorizationBearerTokenNotFound();
27
- }
28
- };
29
- exports.determineIssuerFromRequest = determineIssuerFromRequest;
@@ -1,12 +0,0 @@
1
- import { IAuthorizationIssuer } from '../../../../models/authorization/authorization-models';
2
- /**
3
- * This function determines the issuer from the bearer token (if it exists).
4
- * doesn't validate the signature of the token, just that the shape is correct and
5
- * can be used to determine the signature to use to validate the token.
6
- *
7
- * @param bearerToken the bearer token to determine the issuer from
8
- * @returns
9
- */
10
- declare const determineIssuerFromBearerToken: (bearerToken: string) => IAuthorizationIssuer;
11
- export { determineIssuerFromBearerToken };
12
- //# sourceMappingURL=determine-issuer-from-bearer-token.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"determine-issuer-from-bearer-token.d.ts","sourceRoot":"","sources":["../../../../../../../../generic/src/authorization/safe/request/issuer/determine-issuer-from-bearer-token.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAI7F;;;;;;;GAOG;AACH,QAAA,MAAM,8BAA8B,gBAAiB,MAAM,KAAG,oBAiB7D,CAAC;AAEF,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.determineIssuerFromBearerToken = void 0;
4
- const authorization_errors_1 = require("../../../../errors/authorization/authorization-errors");
5
- const get_decoded_jwt_signed_token_payload_1 = require("../../../jwt/verify/get-decoded-jwt-signed-token-payload");
6
- const verify_authorization_issuer_1 = require("../../validation/jwt/payload/verify-authorization-issuer");
7
- /**
8
- * This function determines the issuer from the bearer token (if it exists).
9
- * doesn't validate the signature of the token, just that the shape is correct and
10
- * can be used to determine the signature to use to validate the token.
11
- *
12
- * @param bearerToken the bearer token to determine the issuer from
13
- * @returns
14
- */
15
- const determineIssuerFromBearerToken = (bearerToken) => {
16
- const decodedToken = (0, get_decoded_jwt_signed_token_payload_1.getDecodedJwtSignedTokenPayload)(bearerToken); // get the payload from the token
17
- if (decodedToken === null || typeof decodedToken === 'string') {
18
- throw new authorization_errors_1.SafeAuthorizationTokenNotObjectError();
19
- }
20
- // make sure the iss property exists
21
- if (!decodedToken.iss) {
22
- throw new authorization_errors_1.SafeAuthorizationTokenPropertyDataTypeNotValidError('iss', decodedToken.iss, 'string');
23
- }
24
- // make sure the type is an issuer
25
- if (!(0, verify_authorization_issuer_1.verifyAuthorizationIssuer)(decodedToken.iss)) {
26
- throw new authorization_errors_1.SafeAuthorizationIssuerNotValidError(decodedToken.iss);
27
- }
28
- return decodedToken.iss;
29
- };
30
- exports.determineIssuerFromBearerToken = determineIssuerFromBearerToken;
@@ -1,10 +0,0 @@
1
- import { AuthorizationAudience } from '../../../../../models/authorization/authorization-models';
2
- /**
3
- * This verifiies the audience of the token
4
- *
5
- * @param aud the audience to verify
6
- * @returns
7
- */
8
- declare const verifyAuthorizationAudience: (aud: unknown) => aud is AuthorizationAudience;
9
- export { verifyAuthorizationAudience };
10
- //# sourceMappingURL=verify-authorization-audience.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-authorization-audience.d.ts","sourceRoot":"","sources":["../../../../../../../../../generic/src/authorization/safe/validation/jwt/payload/verify-authorization-audience.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0DAA0D,CAAC;AAEjG;;;;;GAKG;AACH,QAAA,MAAM,2BAA2B,QAAS,OAAO,KAAG,GAAG,IAAI,qBAc1D,CAAA;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyAuthorizationAudience = 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 verifiies the audience of the token
8
- *
9
- * @param aud the audience to verify
10
- * @returns
11
- */
12
- const verifyAuthorizationAudience = (aud) => {
13
- if (!aud) {
14
- throw new authorization_errors_1.SafeAuthorizationMissingPropertyError('aud');
15
- }
16
- if (typeof aud !== 'string') {
17
- throw new authorization_errors_1.SafeAuthorizationTokenPropertyDataTypeNotValidError('aud', aud, 'string');
18
- }
19
- if (!Object.values(authorization_models_1.AuthorizationAudience).includes(aud)) {
20
- throw new authorization_errors_1.SafeAuthorizationPayloadNotValidError();
21
- }
22
- return true;
23
- };
24
- exports.verifyAuthorizationAudience = verifyAuthorizationAudience;
@@ -1,8 +0,0 @@
1
- /**
2
- * this function validates the expiration time of the token hasn't passed
3
- *
4
- * @param exp the expiration time of the token
5
- */
6
- declare const verifyAuthorizationExpirationTime: (exp: unknown) => exp is number;
7
- export { verifyAuthorizationExpirationTime };
8
- //# sourceMappingURL=verify-authorization-expiration-time.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-authorization-expiration-time.d.ts","sourceRoot":"","sources":["../../../../../../../../../generic/src/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,QAAA,MAAM,iCAAiC,QAAS,OAAO,KAAG,GAAG,IAAI,MAchE,CAAC;AAEF,OAAO,EAAE,iCAAiC,EAAE,CAAC"}
@@ -1,23 +0,0 @@
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;
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,24 +0,0 @@
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;
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,25 +0,0 @@
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;
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,23 +0,0 @@
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;
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,22 +0,0 @@
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;
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,25 +0,0 @@
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;
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
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"}