@degenerate/generic 0.1.4 → 0.1.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.
@@ -1,39 +1,42 @@
1
- import { IAuthorizationIssuer, IJWTAuthority } from '../../../models/authorization/authorization-models';
1
+ import { AuthorizationAudience, IAuthorizationIssuer } from '../../../models/authorization/authorization-models';
2
2
  /**
3
3
  * This class is used to keep and maintain the authorized authorities in the SAFE system.
4
4
  */
5
5
  export declare class AuthorizedAuthorities {
6
- private _authorizedJWTProviders;
7
- private _currentJWTProvidersHash;
6
+ private _authorizedJWTAuthorities;
7
+ private _currentJWTAuthoritiesHash;
8
8
  constructor();
9
9
  /**
10
- * This adds a JWT authority to the authorized authorities.
11
- * @param authority the authority to add
12
- * @param publicKey the public key for the authority
13
- */
14
- addJWTAuthority(authority: IAuthorizationIssuer, publicKey: string): void;
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;
15
17
  /**
16
- * This removes a JWT authority from the authorized authorities.
18
+ * This removes a JWT authority from the authorized authorities for the given audience.
17
19
  *
18
20
  * @param authority the authority to remove
19
21
  */
20
- removeJWTAuthority(authority: IAuthorizationIssuer): void;
22
+ removeAuthorizedJWTAuthority(audience: AuthorizationAudience, authority: IAuthorizationIssuer): void;
21
23
  /**
22
- * This gets the public key for the given authority.
24
+ * This gets the public key for the given authority for the given audience.
23
25
  *
24
26
  * @param authority the authority to get the public key for
25
27
  * @returns
26
28
  */
27
- getJWTAuthorityPublicKey(authority: IAuthorizationIssuer): string | undefined;
29
+ getAuthorizedJWTAuthorityPublicKey(audience: AuthorizationAudience, authority: IAuthorizationIssuer): string | undefined;
28
30
  /**
29
- * This gets all the authorized JWT providers.
31
+ * this gets the authorized JWT authorities for the given audience.
32
+ * @param audience the audience to get the authorized authorities for
30
33
  * @returns
31
34
  */
32
- getJWTProviders(): IJWTAuthority;
35
+ getAuthorizedJWTAuthorities(audience: AuthorizationAudience): Map<IAuthorizationIssuer, string>;
33
36
  /**
34
- * This gets the number of authorized JWT providers.
37
+ * This gets the number of authorized JWT providers for the given audience.
35
38
  * @returns
36
39
  */
37
- getJWTProviderCount(): number;
40
+ getAuthorizedJWTAuthoritiesCount(audience: AuthorizationAudience): number;
38
41
  }
39
42
  //# sourceMappingURL=authorized-authorities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorized-authorities.d.ts","sourceRoot":"","sources":["../../../../src/authorization/safe/authorization/authorized-authorities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AAEzG;;GAEG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,uBAAuB,CAAgB;IAC/C,OAAO,CAAC,wBAAwB,CAAS;;IAOzC;;;;OAIG;IACI,eAAe,CAAC,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAIhF;;;;OAIG;IACI,kBAAkB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAOhE;;;;;OAKG;IACI,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS;IAIpF;;;OAGG;IACI,eAAe,IAAI,aAAa;IAIvC;;;OAGG;IACI,mBAAmB,IAAI,MAAM;CAMvC"}
1
+ {"version":3,"file":"authorized-authorities.d.ts","sourceRoot":"","sources":["../../../../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"}
@@ -2,55 +2,64 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthorizedAuthorities = void 0;
4
4
  const authorization_errors_1 = require("../../../errors/authorization/authorization-errors");
5
+ const authorization_models_1 = require("../../../models/authorization/authorization-models");
5
6
  /**
6
7
  * This class is used to keep and maintain the authorized authorities in the SAFE system.
7
8
  */
8
9
  class AuthorizedAuthorities {
9
10
  constructor() {
10
- this._authorizedJWTProviders = new Map();
11
- this._currentJWTProvidersHash = '';
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
+ });
12
17
  }
13
18
  /**
14
- * This adds a JWT authority to the authorized authorities.
15
- * @param authority the authority to add
16
- * @param publicKey the public key for the authority
17
- */
18
- addJWTAuthority(authority, publicKey) {
19
- this._authorizedJWTProviders.set(authority, publicKey);
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);
20
28
  }
21
29
  /**
22
- * This removes a JWT authority from the authorized authorities.
30
+ * This removes a JWT authority from the authorized authorities for the given audience.
23
31
  *
24
32
  * @param authority the authority to remove
25
33
  */
26
- removeJWTAuthority(authority) {
27
- const removed = this._authorizedJWTProviders.delete(authority);
34
+ removeAuthorizedJWTAuthority(audience, authority) {
35
+ const removed = this._authorizedJWTAuthorities.get(audience)?.delete(authority);
28
36
  if (!removed) {
29
37
  throw new authorization_errors_1.SafeAuthorizationIssuerDoesNotExistError(authority);
30
38
  }
31
39
  }
32
40
  /**
33
- * This gets the public key for the given authority.
41
+ * This gets the public key for the given authority for the given audience.
34
42
  *
35
43
  * @param authority the authority to get the public key for
36
44
  * @returns
37
45
  */
38
- getJWTAuthorityPublicKey(authority) {
39
- return this._authorizedJWTProviders.get(authority);
46
+ getAuthorizedJWTAuthorityPublicKey(audience, authority) {
47
+ return this._authorizedJWTAuthorities.get(audience)?.get(authority);
40
48
  }
41
49
  /**
42
- * This gets all the authorized JWT providers.
50
+ * this gets the authorized JWT authorities for the given audience.
51
+ * @param audience the audience to get the authorized authorities for
43
52
  * @returns
44
53
  */
45
- getJWTProviders() {
46
- return this._authorizedJWTProviders;
54
+ getAuthorizedJWTAuthorities(audience) {
55
+ return this._authorizedJWTAuthorities.get(audience) || new Map();
47
56
  }
48
57
  /**
49
- * This gets the number of authorized JWT providers.
58
+ * This gets the number of authorized JWT providers for the given audience.
50
59
  * @returns
51
60
  */
52
- getJWTProviderCount() {
53
- return this._authorizedJWTProviders.size;
61
+ getAuthorizedJWTAuthoritiesCount(audience) {
62
+ return this._authorizedJWTAuthorities.get(audience)?.size || 0;
54
63
  }
55
64
  }
56
65
  exports.AuthorizedAuthorities = AuthorizedAuthorities;
@@ -86,4 +86,13 @@ export declare class RequestParamNotValidError extends BaseError {
86
86
  */
87
87
  constructor(paramName: string, paramValue: any, expectedType: string, allParams: any);
88
88
  }
89
+ /**
90
+ * This is thrown when the request is not authorized.
91
+ */
92
+ export declare class RequestNotAuthorizedError extends BaseError {
93
+ /**
94
+ * This is thrown when the request is not authorized.
95
+ */
96
+ constructor(errorMessage?: string);
97
+ }
89
98
  //# sourceMappingURL=request-errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/request/request-errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI1C;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D;;;;OAIG;gBACS,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAGtF;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,SAAS;IAC9D;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAG7G;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAG7G;AAED;;GAEG;AACH,qBAAa,2CAA4C,SAAQ,SAAS;IACtE;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM;CAGlH;AAED;;GAEG;AACH,qBAAa,6CAA8C,SAAQ,SAAS;IACxE;;;;;;OAMG;gBACS,mBAAmB,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG;CAGzH;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACpD;;;;;OAKG;gBACS,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM;CAG7E;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACpD;;;;;OAKG;gBACS,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;CAGvF"}
1
+ {"version":3,"file":"request-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/request/request-errors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI1C;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D;;;;OAIG;gBACS,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAGtF;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,SAAS;IAC9D;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAG7G;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,SAAS;IAC7D;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAG7G;AAED;;GAEG;AACH,qBAAa,2CAA4C,SAAQ,SAAS;IACtE;;;;;;OAMG;gBACS,gBAAgB,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM;CAGlH;AAED;;GAEG;AACH,qBAAa,6CAA8C,SAAQ,SAAS;IACxE;;;;;;OAMG;gBACS,mBAAmB,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG;CAGzH;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACpD;;;;;OAKG;gBACS,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM;CAG7E;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACpD;;;;;OAKG;gBACS,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG;CAGvF;AAMD;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,SAAS;IACpD;;OAEG;gBACS,YAAY,SAAiB;CAG5C"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RequestParamNotValidError = exports.RequestQueryNotValidError = exports.RequestObjectPropertyNotMatchingParamProperty = exports.RequestObjectShouldOnlyHaveXPropertiesError = exports.RequestObjectTooFewPropertiesError = exports.RequestObjectTooManyPropertiesError = exports.RequestObjectValidationFailedError = void 0;
3
+ exports.RequestNotAuthorizedError = exports.RequestParamNotValidError = exports.RequestQueryNotValidError = exports.RequestObjectPropertyNotMatchingParamProperty = exports.RequestObjectShouldOnlyHaveXPropertiesError = exports.RequestObjectTooFewPropertiesError = exports.RequestObjectTooManyPropertiesError = exports.RequestObjectValidationFailedError = void 0;
4
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
5
5
  // This file contains the errors that are thrown when the request object is not valid.
6
6
  const base_error_1 = require("../base-error");
@@ -15,7 +15,7 @@ class RequestObjectValidationFailedError extends base_error_1.BaseError {
15
15
  * @param validationType the type of validation that failed
16
16
  */
17
17
  constructor(objectToValidate, validationObject, validationType) {
18
- super(`The object ${objectToValidate} in the node ${validationObject} is not a valid ${validationType}`);
18
+ super(`The object ${objectToValidate} in the node ${validationObject} is not a valid ${validationType}`, 400);
19
19
  }
20
20
  }
21
21
  exports.RequestObjectValidationFailedError = RequestObjectValidationFailedError;
@@ -31,7 +31,7 @@ class RequestObjectTooManyPropertiesError extends base_error_1.BaseError {
31
31
  * @param maxProperties the max properties allowed on the object
32
32
  */
33
33
  constructor(objectToValidate, validationOject, totalProperties, maxProperties) {
34
- super(`The object ${objectToValidate} which is property ${validationOject} has too many properties. It has ${totalProperties} and the max is ${maxProperties}`);
34
+ super(`The object ${objectToValidate} which is property ${validationOject} has too many properties. It has ${totalProperties} and the max is ${maxProperties}`, 400);
35
35
  }
36
36
  }
37
37
  exports.RequestObjectTooManyPropertiesError = RequestObjectTooManyPropertiesError;
@@ -47,7 +47,7 @@ class RequestObjectTooFewPropertiesError extends base_error_1.BaseError {
47
47
  * @param minProperties the min properties allowed on the object
48
48
  */
49
49
  constructor(objectToValidate, validationOject, totalProperties, minProperties) {
50
- super(`The object ${objectToValidate} which is property ${validationOject} has too few properties. It has ${totalProperties} and the min is ${minProperties}`);
50
+ super(`The object ${objectToValidate} which is property ${validationOject} has too few properties. It has ${totalProperties} and the min is ${minProperties}`, 400);
51
51
  }
52
52
  }
53
53
  exports.RequestObjectTooFewPropertiesError = RequestObjectTooFewPropertiesError;
@@ -63,7 +63,7 @@ class RequestObjectShouldOnlyHaveXPropertiesError extends base_error_1.BaseError
63
63
  * @param expectedProperties the expected properties on the object
64
64
  */
65
65
  constructor(objectToValidate, validationOject, totalProperties, expectedProperties) {
66
- super(`The object ${objectToValidate} which is property ${validationOject} should only have ${expectedProperties} properties. It has ${totalProperties}`);
66
+ super(`The object ${objectToValidate} which is property ${validationOject} should only have ${expectedProperties} properties. It has ${totalProperties}`, 400);
67
67
  }
68
68
  }
69
69
  exports.RequestObjectShouldOnlyHaveXPropertiesError = RequestObjectShouldOnlyHaveXPropertiesError;
@@ -79,7 +79,7 @@ class RequestObjectPropertyNotMatchingParamProperty extends base_error_1.BaseErr
79
79
  * @param paramPropertyValue the value of the property in the param object
80
80
  */
81
81
  constructor(requestPropertyName, requestPropertyValue, paramPropertyName, paramPropertyValue) {
82
- super(`The request object property ${requestPropertyName} with value ${requestPropertyValue} does not match the param property ${paramPropertyName} with value ${paramPropertyValue}`);
82
+ super(`The request object property ${requestPropertyName} with value ${requestPropertyValue} does not match the param property ${paramPropertyName} with value ${paramPropertyValue}`, 400);
83
83
  }
84
84
  }
85
85
  exports.RequestObjectPropertyNotMatchingParamProperty = RequestObjectPropertyNotMatchingParamProperty;
@@ -96,7 +96,7 @@ class RequestQueryNotValidError extends base_error_1.BaseError {
96
96
  * @param expectedType the expected type of the query object
97
97
  */
98
98
  constructor(queryObjectName, queryValue, expectedType) {
99
- super(`The query object ${queryObjectName} with value ${queryValue} is not a valid ${expectedType}`);
99
+ super(`The query object ${queryObjectName} with value ${queryValue} is not a valid ${expectedType}`, 400);
100
100
  }
101
101
  }
102
102
  exports.RequestQueryNotValidError = RequestQueryNotValidError;
@@ -113,8 +113,22 @@ class RequestParamNotValidError extends base_error_1.BaseError {
113
113
  * @param expectedType the expected type of the param object
114
114
  */
115
115
  constructor(paramName, paramValue, expectedType, allParams) {
116
- super(`The param object ${paramName} with value ${paramValue} is not a valid ${expectedType}. All params: ${JSON.stringify(allParams)}`);
116
+ super(`The param object ${paramName} with value ${paramValue} is not a valid ${expectedType}. All params: ${JSON.stringify(allParams)}`, 400);
117
117
  }
118
118
  }
119
119
  exports.RequestParamNotValidError = RequestParamNotValidError;
120
120
  //#endregion Request Param Errors
121
+ //#region Request Authorization Errors
122
+ /**
123
+ * This is thrown when the request is not authorized.
124
+ */
125
+ class RequestNotAuthorizedError extends base_error_1.BaseError {
126
+ /**
127
+ * This is thrown when the request is not authorized.
128
+ */
129
+ constructor(errorMessage = 'Unauthorized') {
130
+ super(errorMessage, 403);
131
+ }
132
+ }
133
+ exports.RequestNotAuthorizedError = RequestNotAuthorizedError;
134
+ //#endregion Request Authorization Errors
@@ -34,5 +34,12 @@ declare const getParamRulesId: (req: any) => string;
34
34
  * @returns
35
35
  */
36
36
  declare const getParamEventId: (req: any) => string;
37
- export { getParamShareDataId, getParamFunctionId, getParamRulesId, getParamEventId };
37
+ /**
38
+ * The function gets the authority id from the restful parameter object
39
+ *
40
+ * @param req the incoming request
41
+ * @returns
42
+ */
43
+ declare const getAuthorityId: (req: any) => string;
44
+ export { getParamShareDataId, getParamFunctionId, getParamRulesId, getParamEventId, getAuthorityId, };
38
45
  //# sourceMappingURL=params-object-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"params-object-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/params-object-helpers.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAIH;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,QAAS,GAAG,KAAG,MAEvC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,QAAS,GAAG,KAAG,MAEtC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,QAAS,GAAG,KAAG,MAEnC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,QAAS,GAAG,KAAG,MAEnC,CAAA;AAID,OAAO,EACH,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,EAClB,CAAA"}
1
+ {"version":3,"file":"params-object-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/params-object-helpers.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAIH;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,QAAS,GAAG,KAAG,MAEvC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,QAAS,GAAG,KAAG,MAEtC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,QAAS,GAAG,KAAG,MAEnC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,QAAS,GAAG,KAAG,MAEnC,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,KAAG,MAElC,CAAA;AAID,OAAO,EACH,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,cAAc,GACjB,CAAA"}
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  // This file contains the functions to get the incoming params in the request object.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getParamEventId = exports.getParamRulesId = exports.getParamFunctionId = exports.getParamShareDataId = void 0;
5
+ exports.getAuthorityId = exports.getParamEventId = exports.getParamRulesId = exports.getParamFunctionId = exports.getParamShareDataId = void 0;
6
6
  /**
7
7
  * The pattern for this is:
8
8
  * Parameters are always in the request object and lowercase.
@@ -52,3 +52,13 @@ const getParamEventId = (req) => {
52
52
  return req.params.eventid;
53
53
  };
54
54
  exports.getParamEventId = getParamEventId;
55
+ /**
56
+ * The function gets the authority id from the restful parameter object
57
+ *
58
+ * @param req the incoming request
59
+ * @returns
60
+ */
61
+ const getAuthorityId = (req) => {
62
+ return req.params.authorityid;
63
+ };
64
+ exports.getAuthorityId = getAuthorityId;
@@ -2,6 +2,21 @@
2
2
  * This file contains the helper functions for the incoming request objects.
3
3
  * It is used to set and get the user object from the request object.
4
4
  */
5
+ import { AuthorizationAudience } from '../../models/authorization/authorization-models';
6
+ /**
7
+ * This function sets the Authorization Audience on the request object.
8
+ *
9
+ * @param req the incoming request object
10
+ * @param userObject the user object to set
11
+ * @returns
12
+ */
13
+ declare const setAuthorizationAudience: (req: any, authorizationAudience: AuthorizationAudience) => void;
14
+ /**
15
+ * This function gets the Authorization Audience from the request object.
16
+ * @param req the incoming request object
17
+ * @returns
18
+ */
19
+ declare const getAuthorizationAudience: (req: any) => AuthorizationAudience;
5
20
  /**
6
21
  * This function sets the IUserWithClaims object into the req.user object.
7
22
  * @param req the incoming request object
@@ -15,5 +30,5 @@ declare const setUserRequest: (req: any, userObject: any) => void;
15
30
  * @returns
16
31
  */
17
32
  declare const getUserRequest: (req: any) => any;
18
- export { setUserRequest, getUserRequest };
33
+ export { setAuthorizationAudience, getAuthorizationAudience, setUserRequest, getUserRequest, };
19
34
  //# sourceMappingURL=request-object-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-object-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/request-object-helpers.ts"],"names":[],"mappings":"AACA;;;GAGG;AAIH;;;;;GAKG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,cAAc,GAAG,KAAG,IAEnD,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,KAAG,GAElC,CAAC;AAGF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"request-object-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/request-object-helpers.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AASxF;;;;;;GAMG;AACH,QAAA,MAAM,wBAAwB,QAAS,GAAG,yBAAyB,qBAAqB,KAAG,IAM1F,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,wBAAwB,QAAS,GAAG,KAAG,qBAE5C,CAAA;AAID;;;;;GAKG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,cAAc,GAAG,KAAG,IAEnD,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,cAAc,QAAS,GAAG,KAAG,GAElC,CAAC;AAGF,OAAO,EACH,wBAAwB,EACxB,wBAAwB,EACxB,cAAc,EACd,cAAc,GACjB,CAAC"}
@@ -5,8 +5,35 @@
5
5
  * It is used to set and get the user object from the request object.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.getUserRequest = exports.setUserRequest = void 0;
8
+ exports.getUserRequest = exports.setUserRequest = exports.getAuthorizationAudience = exports.setAuthorizationAudience = void 0;
9
9
  const USER_REQUEST_KEY = 'user';
10
+ const AUTHORIZATION_AUDIENCE_KEY = 'authorizationaudience';
11
+ //#region Authorization
12
+ /**
13
+ * This function sets the Authorization Audience on the request object.
14
+ *
15
+ * @param req the incoming request object
16
+ * @param userObject the user object to set
17
+ * @returns
18
+ */
19
+ const setAuthorizationAudience = (req, authorizationAudience) => {
20
+ console.log('req', req);
21
+ console.log('authorizationAudience', authorizationAudience);
22
+ req[AUTHORIZATION_AUDIENCE_KEY] = authorizationAudience;
23
+ console.log('req', req);
24
+ return;
25
+ };
26
+ exports.setAuthorizationAudience = setAuthorizationAudience;
27
+ /**
28
+ * This function gets the Authorization Audience from the request object.
29
+ * @param req the incoming request object
30
+ * @returns
31
+ */
32
+ const getAuthorizationAudience = (req) => {
33
+ return req[AUTHORIZATION_AUDIENCE_KEY];
34
+ };
35
+ exports.getAuthorizationAudience = getAuthorizationAudience;
36
+ //#endregion Authorization
10
37
  /**
11
38
  * This function sets the IUserWithClaims object into the req.user object.
12
39
  * @param req the incoming request object
@@ -8,6 +8,6 @@ export * from './events/share-event-models';
8
8
  export * from './functions/share-data-function-models';
9
9
  export * from './generic/request-response-models';
10
10
  export * from './rules/share-rule-models';
11
- export * from './safe/safe-transactions';
11
+ export * from './safe/safe-transaction-models';
12
12
  export * from './share-data/share-data';
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAEA,cAAc,sDAAsD,CAAC;AACrE,cAAc,yCAAyC,CAAC;AACxD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC"}
@@ -25,5 +25,5 @@ __exportStar(require("./events/share-event-models"), exports);
25
25
  __exportStar(require("./functions/share-data-function-models"), exports);
26
26
  __exportStar(require("./generic/request-response-models"), exports);
27
27
  __exportStar(require("./rules/share-rule-models"), exports);
28
- __exportStar(require("./safe/safe-transactions"), exports);
28
+ __exportStar(require("./safe/safe-transaction-models"), exports);
29
29
  __exportStar(require("./share-data/share-data"), exports);
@@ -78,4 +78,4 @@ export interface ISAFETransactionAuthorityData {
78
78
  authorityValidationType: AuthorityValidationType;
79
79
  authorityOver: SAFETransactionType[];
80
80
  }
81
- //# sourceMappingURL=safe-transactions.d.ts.map
81
+ //# sourceMappingURL=safe-transaction-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-transaction-models.d.ts","sourceRoot":"","sources":["../../../src/models/safe/safe-transaction-models.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAItG;;GAEG;AACH,oBAAY,yBAAyB;IACjC,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,oBAAY,mBAAmB;IAC3B,SAAS,cAAc,CAAE,sCAAsC;IAC/D,SAAS,cAAc,CAAE,uCAAuC;IAChE,SAAS,cAAc,CAAE,sCAAsC;IAC/D,KAAK,UAAU,CAAE,kCAAkC;IACnD,MAAM,WAAW,CAAE,mCAAmC;IACtD,SAAS,cAAc;CAC1B;AAID;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,oBAAoB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE;QACT,IAAI,EAAE,mBAAmB,CAAC;QAC1B,MAAM,EAAE,yBAAyB,CAAC;KACrC,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACnE,WAAW,EAAE;QACT,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC;QACpC,MAAM,EAAE,yBAAyB,CAAC;QAClC,IAAI,EAAE,6BAA6B,CAAC;KACvC,CAAA;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,mBAAmB,EAAE,oBAAoB,CAAC;IAC1C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,aAAa,EAAE,mBAAmB,EAAE,CAAC;CACxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@degenerate/generic",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "This contains the generic information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -53,5 +53,5 @@
53
53
  "firebase-functions": "^6.1.0",
54
54
  "jsonwebtoken": "^9.0.2"
55
55
  },
56
- "gitHead": "914fe4dbb4c4a61963d137a4c583bd9084e2d802"
56
+ "gitHead": "94999f47ab811bb70d50974a2ca173cadeccf709"
57
57
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe-transactions.d.ts","sourceRoot":"","sources":["../../../src/models/safe/safe-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAItG;;GAEG;AACH,oBAAY,yBAAyB;IACjC,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED;;GAEG;AACH,oBAAY,mBAAmB;IAC3B,SAAS,cAAc,CAAE,sCAAsC;IAC/D,SAAS,cAAc,CAAE,uCAAuC;IAChE,SAAS,cAAc,CAAE,sCAAsC;IAC/D,KAAK,UAAU,CAAE,kCAAkC;IACnD,MAAM,WAAW,CAAE,mCAAmC;IACtD,SAAS,cAAc;CAC1B;AAID;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,oBAAoB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE;QACT,IAAI,EAAE,mBAAmB,CAAC;QAC1B,MAAM,EAAE,yBAAyB,CAAC;KACrC,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACnE,WAAW,EAAE;QACT,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC;QACpC,MAAM,EAAE,yBAAyB,CAAC;QAClC,IAAI,EAAE,6BAA6B,CAAC;KACvC,CAAA;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,mBAAmB,EAAE,oBAAoB,CAAC;IAC1C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,uBAAuB,EAAE,uBAAuB,CAAC;IACjD,aAAa,EAAE,mBAAmB,EAAE,CAAC;CACxC"}