@abyss-project/main 42.7.0 → 43.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/constants/index.d.ts +1 -0
  2. package/dist/constants/index.js +1 -0
  3. package/dist/constants/index.js.map +1 -1
  4. package/dist/constants/oauth-app.constants.d.ts +3 -6
  5. package/dist/constants/oauth-app.constants.js +9 -42
  6. package/dist/constants/oauth-app.constants.js.map +1 -1
  7. package/dist/constants/oauth-scope-catalogue.d.ts +215 -0
  8. package/dist/constants/oauth-scope-catalogue.js +3164 -0
  9. package/dist/constants/oauth-scope-catalogue.js.map +1 -0
  10. package/dist/constants/tests/oauth-app.constants.spec.js +31 -54
  11. package/dist/constants/tests/oauth-app.constants.spec.js.map +1 -1
  12. package/dist/constants/tests/oauth-scope-catalogue.spec.js +198 -0
  13. package/dist/constants/tests/oauth-scope-catalogue.spec.js.map +1 -0
  14. package/dist/constants/tests/oauth-scope-positions.snapshot.d.ts +39 -0
  15. package/dist/constants/tests/oauth-scope-positions.snapshot.js +225 -0
  16. package/dist/constants/tests/oauth-scope-positions.snapshot.js.map +1 -0
  17. package/dist/server/index.d.ts +5 -2
  18. package/dist/server/index.js +5 -2
  19. package/dist/server/index.js.map +1 -1
  20. package/dist/server/oauth-access-token.util.d.ts +4 -1
  21. package/dist/server/oauth-access-token.util.js +22 -5
  22. package/dist/server/oauth-access-token.util.js.map +1 -1
  23. package/dist/server/oauth-claim-format.error.d.ts +4 -0
  24. package/dist/server/oauth-claim-format.error.js +19 -0
  25. package/dist/server/oauth-claim-format.error.js.map +1 -0
  26. package/dist/server/oauth-perimeter-claim.util.d.ts +14 -0
  27. package/dist/server/oauth-perimeter-claim.util.js +109 -0
  28. package/dist/server/oauth-perimeter-claim.util.js.map +1 -0
  29. package/dist/server/oauth-perimeter.util.d.ts +31 -0
  30. package/dist/server/oauth-perimeter.util.js +97 -0
  31. package/dist/server/oauth-perimeter.util.js.map +1 -0
  32. package/dist/server/oauth-route-access.util.d.ts +56 -0
  33. package/dist/server/oauth-route-access.util.js +65 -0
  34. package/dist/server/oauth-route-access.util.js.map +1 -0
  35. package/dist/server/oauth-scope-bits.util.d.ts +9 -0
  36. package/dist/server/oauth-scope-bits.util.js +82 -0
  37. package/dist/server/oauth-scope-bits.util.js.map +1 -0
  38. package/dist/server/tests/oauth-access-token.util.spec.js +29 -5
  39. package/dist/server/tests/oauth-access-token.util.spec.js.map +1 -1
  40. package/dist/server/tests/oauth-perimeter-claim.util.spec.js +148 -0
  41. package/dist/server/tests/oauth-perimeter-claim.util.spec.js.map +1 -0
  42. package/dist/server/tests/oauth-perimeter.util.spec.d.ts +1 -0
  43. package/dist/server/tests/oauth-perimeter.util.spec.js +215 -0
  44. package/dist/server/tests/oauth-perimeter.util.spec.js.map +1 -0
  45. package/dist/server/tests/oauth-route-access.util.spec.d.ts +1 -0
  46. package/dist/server/tests/oauth-route-access.util.spec.js +115 -0
  47. package/dist/server/tests/oauth-route-access.util.spec.js.map +1 -0
  48. package/dist/server/tests/oauth-scope-bits.util.spec.d.ts +1 -0
  49. package/dist/server/tests/oauth-scope-bits.util.spec.js +72 -0
  50. package/dist/server/tests/oauth-scope-bits.util.spec.js.map +1 -0
  51. package/dist/translate/en.translate.d.ts +8 -0
  52. package/dist/translate/en.translate.js +8 -0
  53. package/dist/translate/en.translate.js.map +1 -1
  54. package/dist/translate/fr.translate.d.ts +8 -0
  55. package/dist/translate/fr.translate.js +8 -0
  56. package/dist/translate/fr.translate.js.map +1 -1
  57. package/dist/types/enum/email-type.enum.d.ts +2 -0
  58. package/dist/types/enum/email-type.enum.js +2 -0
  59. package/dist/types/enum/email-type.enum.js.map +1 -1
  60. package/dist/types/enum/form-file-upload-refusal-reason.enum.d.ts +4 -0
  61. package/dist/types/enum/form-file-upload-refusal-reason.enum.js +9 -0
  62. package/dist/types/enum/form-file-upload-refusal-reason.enum.js.map +1 -0
  63. package/dist/types/enum/index.d.ts +2 -0
  64. package/dist/types/enum/index.js +2 -0
  65. package/dist/types/enum/index.js.map +1 -1
  66. package/dist/types/enum/oauth-app.enum.d.ts +0 -21
  67. package/dist/types/enum/oauth-app.enum.js +1 -24
  68. package/dist/types/enum/oauth-app.enum.js.map +1 -1
  69. package/dist/types/enum/oauth-scope.enum.d.ts +74 -0
  70. package/dist/types/enum/oauth-scope.enum.js +86 -0
  71. package/dist/types/enum/oauth-scope.enum.js.map +1 -0
  72. package/dist/types/enum/user-notification-category.enum.js +2 -0
  73. package/dist/types/enum/user-notification-category.enum.js.map +1 -1
  74. package/dist/types/enum/user-notification-content-type.enum.d.ts +24 -0
  75. package/dist/types/enum/user-notification-content-type.enum.js +3 -1
  76. package/dist/types/enum/user-notification-content-type.enum.js.map +1 -1
  77. package/dist/types/interface/api/requests/index.d.ts +1 -0
  78. package/dist/types/interface/api/requests/index.js +1 -0
  79. package/dist/types/interface/api/requests/index.js.map +1 -1
  80. package/dist/types/interface/api/requests/oauth-perimeter.request.d.ts +30 -0
  81. package/dist/types/interface/api/requests/oauth-perimeter.request.js +5 -0
  82. package/dist/types/interface/api/requests/oauth-perimeter.request.js.map +1 -0
  83. package/dist/types/interface/api/responses/index.d.ts +1 -0
  84. package/dist/types/interface/api/responses/index.js +1 -0
  85. package/dist/types/interface/api/responses/index.js.map +1 -1
  86. package/dist/types/interface/api/responses/oauth-perimeter.response.d.ts +23 -0
  87. package/dist/types/interface/api/responses/oauth-perimeter.response.js +3 -0
  88. package/dist/types/interface/api/responses/oauth-perimeter.response.js.map +1 -0
  89. package/package.json +15 -10
  90. package/dist/server/oauth-no-app-token.util.d.ts +0 -7
  91. package/dist/server/oauth-no-app-token.util.js +0 -14
  92. package/dist/server/oauth-no-app-token.util.js.map +0 -1
  93. package/dist/server/oauth-request-guard.util.d.ts +0 -27
  94. package/dist/server/oauth-request-guard.util.js +0 -34
  95. package/dist/server/oauth-request-guard.util.js.map +0 -1
  96. package/dist/server/tests/oauth-no-app-token.util.spec.js +0 -40
  97. package/dist/server/tests/oauth-no-app-token.util.spec.js.map +0 -1
  98. package/dist/server/tests/oauth-request-guard.util.spec.js +0 -80
  99. package/dist/server/tests/oauth-request-guard.util.spec.js.map +0 -1
  100. /package/dist/{server/tests/oauth-no-app-token.util.spec.d.ts → constants/tests/oauth-scope-catalogue.spec.d.ts} +0 -0
  101. /package/dist/server/tests/{oauth-request-guard.util.spec.d.ts → oauth-perimeter-claim.util.spec.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-perimeter.request.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/requests/oauth-perimeter.request.ts"],"names":[],"mappings":";;;AAGa,QAAA,2BAA2B,GAAG,aAAa,CAAC"}
@@ -57,6 +57,7 @@ export * from './mcp-connection.response';
57
57
  export * from './oauth-authorization-request.response';
58
58
  export * from './oauth-application.response';
59
59
  export * from './oauth-grant.response';
60
+ export * from './oauth-perimeter.response';
60
61
  export * from './oauth-userinfo.response';
61
62
  export * from './activity.admin.response';
62
63
  export * from './referred-traffic.admin.response';
@@ -73,6 +73,7 @@ __exportStar(require("./mcp-connection.response"), exports);
73
73
  __exportStar(require("./oauth-authorization-request.response"), exports);
74
74
  __exportStar(require("./oauth-application.response"), exports);
75
75
  __exportStar(require("./oauth-grant.response"), exports);
76
+ __exportStar(require("./oauth-perimeter.response"), exports);
76
77
  __exportStar(require("./oauth-userinfo.response"), exports);
77
78
  __exportStar(require("./activity.admin.response"), exports);
78
79
  __exportStar(require("./referred-traffic.admin.response"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,+DAA6C;AAC7C,yDAAuC;AACvC,qEAAmD;AACnD,iEAA+C;AAC/C,uEAAqD;AACrD,mDAAiC;AACjC,kDAAgC;AAChC,6DAA2C;AAC3C,mEAAiD;AACjD,6DAA2C;AAC3C,0DAAwC;AACxC,wEAAsD;AACtD,iEAA+C;AAC/C,2DAAyC;AACzC,qDAAmC;AACnC,2DAAyC;AACzC,iEAA+C;AAC/C,+DAA6C;AAC7C,6DAA2C;AAC3C,uDAAqC;AACrC,wDAAsC;AACtC,2DAAyC;AACzC,2DAAyC;AACzC,iDAA+B;AAC/B,qDAAmC;AACnC,8DAA4C;AAC5C,qDAAmC;AACnC,kEAAgD;AAChD,kFAAgE;AAChE,4EAA0D;AAC1D,iEAA+C;AAC/C,gEAA8C;AAC9C,0DAAwC;AACxC,kEAAgD;AAChD,mEAAiD;AACjD,sDAAoC;AACpC,kEAAgD;AAChD,4DAA0C;AAC1C,6DAA2C;AAC3C,8DAA4C;AAC5C,2DAAyC;AACzC,qDAAmC;AACnC,4DAA0C;AAC1C,kDAAgC;AAChC,iEAA+C;AAC/C,0DAAwC;AACxC,iEAA+C;AAC/C,qEAAmD;AACnD,+DAA6C;AAC7C,wDAAsC;AACtC,kDAAgC;AAChC,8DAA4C;AAC5C,qDAAmC;AACnC,4DAA0C;AAC1C,4DAA0C;AAC1C,yEAAuD;AACvD,+DAA6C;AAC7C,yDAAuC;AACvC,4DAA0C;AAC1C,4DAA0C;AAC1C,oEAAkD;AAClD,yEAAuD;AACvD,+DAA6C;AAC7C,2DAAyC;AACzC,iEAA+C;AAC/C,qDAAmC;AACnC,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,+DAA6C;AAC7C,yDAAuC;AACvC,qEAAmD;AACnD,iEAA+C;AAC/C,uEAAqD;AACrD,mDAAiC;AACjC,kDAAgC;AAChC,6DAA2C;AAC3C,mEAAiD;AACjD,6DAA2C;AAC3C,0DAAwC;AACxC,wEAAsD;AACtD,iEAA+C;AAC/C,2DAAyC;AACzC,qDAAmC;AACnC,2DAAyC;AACzC,iEAA+C;AAC/C,+DAA6C;AAC7C,6DAA2C;AAC3C,uDAAqC;AACrC,wDAAsC;AACtC,2DAAyC;AACzC,2DAAyC;AACzC,iDAA+B;AAC/B,qDAAmC;AACnC,8DAA4C;AAC5C,qDAAmC;AACnC,kEAAgD;AAChD,kFAAgE;AAChE,4EAA0D;AAC1D,iEAA+C;AAC/C,gEAA8C;AAC9C,0DAAwC;AACxC,kEAAgD;AAChD,mEAAiD;AACjD,sDAAoC;AACpC,kEAAgD;AAChD,4DAA0C;AAC1C,6DAA2C;AAC3C,8DAA4C;AAC5C,2DAAyC;AACzC,qDAAmC;AACnC,4DAA0C;AAC1C,kDAAgC;AAChC,iEAA+C;AAC/C,0DAAwC;AACxC,iEAA+C;AAC/C,qEAAmD;AACnD,+DAA6C;AAC7C,wDAAsC;AACtC,kDAAgC;AAChC,8DAA4C;AAC5C,qDAAmC;AACnC,4DAA0C;AAC1C,4DAA0C;AAC1C,yEAAuD;AACvD,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,4DAA0C;AAC1C,4DAA0C;AAC1C,oEAAkD;AAClD,yEAAuD;AACvD,+DAA6C;AAC7C,2DAAyC;AACzC,iEAA+C;AAC/C,qDAAmC;AACnC,2DAAyC"}
@@ -0,0 +1,23 @@
1
+ import type { IOAuthPerimeterResourceInput, OAuthPerimeterCandidateUnit } from '../requests/oauth-perimeter.request';
2
+ import type { IResponse } from '../type-message/response';
3
+ export interface IOAuthPerimeterCandidate {
4
+ id: string | null;
5
+ name: string;
6
+ unit: OAuthPerimeterCandidateUnit;
7
+ parentId: string | null;
8
+ kind?: string;
9
+ isProduction?: boolean;
10
+ }
11
+ export interface IListOAuthPerimeterCandidatesData {
12
+ candidates: IOAuthPerimeterCandidate[];
13
+ nextCursor: string | null;
14
+ }
15
+ export type IListPerimeterCandidatesOAuthAuthorizationRequestResponse = IResponse<IListOAuthPerimeterCandidatesData>;
16
+ export type IListOAuthPerimeterCandidatesAdminResponse = IResponse<IListOAuthPerimeterCandidatesData>;
17
+ export interface IOAuthPerimeterResolvedEntry extends IOAuthPerimeterResourceInput {
18
+ label: string;
19
+ }
20
+ export interface IResolveOAuthPerimeterAdminData {
21
+ entries: IOAuthPerimeterResolvedEntry[];
22
+ }
23
+ export type IResolveOAuthPerimeterAdminResponse = IResponse<IResolveOAuthPerimeterAdminData>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=oauth-perimeter.response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-perimeter.response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/oauth-perimeter.response.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/main",
3
- "version": "42.7.0",
3
+ "version": "43.1.0",
4
4
  "description": "Core package to interact with Abyss-Project",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,6 +42,19 @@
42
42
  ]
43
43
  }
44
44
  },
45
+ "publishConfig": {
46
+ "main": "dist/index.js",
47
+ "types": "dist/index.d.ts"
48
+ },
49
+ "scripts": {
50
+ "lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
51
+ "lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
52
+ "tsc": "tsc",
53
+ "build": "tsc -p tsconfig.build.json",
54
+ "dev": "tsc --watch",
55
+ "test": "jest",
56
+ "prepublishOnly": "tsc && node ../../scripts/check-sdk-surface.cjs"
57
+ },
45
58
  "repository": {
46
59
  "type": "git",
47
60
  "url": "https://gitlab.com/abyss-group"
@@ -92,13 +105,5 @@
92
105
  "sequelize-cli": "^6.2.0",
93
106
  "ts-jest": "^29.1.1",
94
107
  "typescript": "5.9.3"
95
- },
96
- "scripts": {
97
- "lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
98
- "lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
99
- "tsc": "tsc",
100
- "build": "tsc -p tsconfig.build.json",
101
- "dev": "tsc --watch",
102
- "test": "jest"
103
108
  }
104
- }
109
+ }
@@ -1,7 +0,0 @@
1
- export interface OAuthAppLocals {
2
- oauth?: unknown;
3
- }
4
- export declare const isOAuthAppRequest: (locals: OAuthAppLocals) => boolean;
5
- export declare const createNoAppTokenMiddleware: <Req, Res extends {
6
- locals: OAuthAppLocals;
7
- }>(refuse: (req: Req, res: Res) => void) => (req: Req, res: Res, next: () => void) => void;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNoAppTokenMiddleware = exports.isOAuthAppRequest = void 0;
4
- const isOAuthAppRequest = (locals) => locals.oauth !== undefined && locals.oauth !== null;
5
- exports.isOAuthAppRequest = isOAuthAppRequest;
6
- const createNoAppTokenMiddleware = (refuse) => (req, res, next) => {
7
- if ((0, exports.isOAuthAppRequest)(res.locals)) {
8
- refuse(req, res);
9
- return;
10
- }
11
- next();
12
- };
13
- exports.createNoAppTokenMiddleware = createNoAppTokenMiddleware;
14
- //# sourceMappingURL=oauth-no-app-token.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oauth-no-app-token.util.js","sourceRoot":"","sources":["../../src/server/oauth-no-app-token.util.ts"],"names":[],"mappings":";;;AAsBO,MAAM,iBAAiB,GAAG,CAAC,MAAsB,EAAW,EAAE,CACnE,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC;AADzC,QAAA,iBAAiB,qBACwB;AAM/C,MAAM,0BAA0B,GACrC,CAA8C,MAAoC,EAAE,EAAE,CACtF,CAAC,GAAQ,EAAE,GAAQ,EAAE,IAAgB,EAAQ,EAAE;IAC7C,IAAI,IAAA,yBAAiB,EAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjB,OAAO;IACT,CAAC;IACD,IAAI,EAAE,CAAC;AACT,CAAC,CAAC;AARS,QAAA,0BAA0B,8BAQnC"}
@@ -1,27 +0,0 @@
1
- import { OAuthAppAccess, OAuthAppProduct } from '../types/enum/oauth-app.enum';
2
- import type { OAuthAccessTokenClaims } from './oauth-access-token.util';
3
- export interface OAuthGuardRequest {
4
- method: string;
5
- }
6
- export declare enum OAuthGuardRefusalCode {
7
- INSUFFICIENT_SCOPE = "insufficient_scope",
8
- OAUTH_TOKEN_NOT_ALLOWED = "oauthTokenNotAllowed"
9
- }
10
- export type OAuthGuardOutcome = {
11
- allowed: true;
12
- } | {
13
- allowed: false;
14
- status: 403;
15
- code: OAuthGuardRefusalCode.INSUFFICIENT_SCOPE;
16
- requiredScope: string;
17
- } | {
18
- allowed: false;
19
- status: 403;
20
- code: OAuthGuardRefusalCode.OAUTH_TOKEN_NOT_ALLOWED;
21
- };
22
- export interface OAuthRequestGuardOptions {
23
- product: OAuthAppProduct;
24
- }
25
- export type OAuthRequestGuard = (req: OAuthGuardRequest, claims: Pick<OAuthAccessTokenClaims, 'scopes'>) => OAuthGuardOutcome;
26
- export declare const requiredOAuthAccessFor: (method: string) => OAuthAppAccess;
27
- export declare const createOAuthRequestGuard: (options: OAuthRequestGuardOptions) => OAuthRequestGuard;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createOAuthRequestGuard = exports.requiredOAuthAccessFor = exports.OAuthGuardRefusalCode = void 0;
4
- const oauth_app_constants_1 = require("../constants/oauth-app.constants");
5
- const oauth_app_enum_1 = require("../types/enum/oauth-app.enum");
6
- var OAuthGuardRefusalCode;
7
- (function (OAuthGuardRefusalCode) {
8
- OAuthGuardRefusalCode["INSUFFICIENT_SCOPE"] = "insufficient_scope";
9
- OAuthGuardRefusalCode["OAUTH_TOKEN_NOT_ALLOWED"] = "oauthTokenNotAllowed";
10
- })(OAuthGuardRefusalCode || (exports.OAuthGuardRefusalCode = OAuthGuardRefusalCode = {}));
11
- const READ_METHODS = new Set(['GET', 'HEAD']);
12
- const requiredOAuthAccessFor = (method) => READ_METHODS.has(method.toUpperCase()) ? oauth_app_enum_1.OAuthAppAccess.READ : oauth_app_enum_1.OAuthAppAccess.WRITE;
13
- exports.requiredOAuthAccessFor = requiredOAuthAccessFor;
14
- const createOAuthRequestGuard = (options) => {
15
- const readOnly = (0, oauth_app_constants_1.isOAuthAppProductReadOnly)(options.product);
16
- return (req, claims) => {
17
- const access = (0, exports.requiredOAuthAccessFor)(req.method);
18
- if (readOnly && access === oauth_app_enum_1.OAuthAppAccess.WRITE) {
19
- return { allowed: false, status: 403, code: OAuthGuardRefusalCode.OAUTH_TOKEN_NOT_ALLOWED };
20
- }
21
- const requiredScope = (0, oauth_app_constants_1.oauthAppScopeOf)(options.product, access);
22
- if (!claims.scopes.includes(requiredScope)) {
23
- return {
24
- allowed: false,
25
- status: 403,
26
- code: OAuthGuardRefusalCode.INSUFFICIENT_SCOPE,
27
- requiredScope,
28
- };
29
- }
30
- return { allowed: true };
31
- };
32
- };
33
- exports.createOAuthRequestGuard = createOAuthRequestGuard;
34
- //# sourceMappingURL=oauth-request-guard.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oauth-request-guard.util.js","sourceRoot":"","sources":["../../src/server/oauth-request-guard.util.ts"],"names":[],"mappings":";;;AAaA,0EAA8F;AAC9F,iEAA+E;AAQ/E,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAE/B,kEAAyC,CAAA;IAEzC,yEAAgD,CAAA;AAClD,CAAC,EALW,qBAAqB,qCAArB,qBAAqB,QAKhC;AAsBD,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAG5D,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAkB,EAAE,CACvE,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,+BAAc,CAAC,IAAI,CAAC,CAAC,CAAC,+BAAc,CAAC,KAAK,CAAC;AADzE,QAAA,sBAAsB,0BACmD;AAM/E,MAAM,uBAAuB,GAAG,CAAC,OAAiC,EAAqB,EAAE;IAC9F,MAAM,QAAQ,GAAG,IAAA,+CAAyB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,IAAA,8BAAsB,EAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,QAAQ,IAAI,MAAM,KAAK,+BAAc,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,qBAAqB,CAAC,uBAAuB,EAAE,CAAC;QAC9F,CAAC;QACD,MAAM,aAAa,GAAG,IAAA,qCAAe,EAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC3C,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,qBAAqB,CAAC,kBAAkB;gBAC9C,aAAa;aACd,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,uBAAuB,2BAkBlC"}
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const oauth_no_app_token_util_1 = require("../oauth-no-app-token.util");
4
- describe('oauth-no-app-token.util', () => {
5
- describe('isOAuthAppRequest', () => {
6
- it('is true when the authentication of an app token set res.locals.oauth', () => {
7
- expect((0, oauth_no_app_token_util_1.isOAuthAppRequest)({ oauth: { clientId: 'abys_app_x', scopes: ['cloud:read'] } })).toBe(true);
8
- });
9
- it('is true whatever the scopes: an empty scope list is still an app token', () => {
10
- expect((0, oauth_no_app_token_util_1.isOAuthAppRequest)({ oauth: { clientId: 'abys_app_x', scopes: [] } })).toBe(true);
11
- });
12
- it('is false for a session, which never sets res.locals.oauth', () => {
13
- expect((0, oauth_no_app_token_util_1.isOAuthAppRequest)({})).toBe(false);
14
- expect((0, oauth_no_app_token_util_1.isOAuthAppRequest)({ oauth: undefined })).toBe(false);
15
- expect((0, oauth_no_app_token_util_1.isOAuthAppRequest)({ oauth: null })).toBe(false);
16
- });
17
- });
18
- describe('createNoAppTokenMiddleware', () => {
19
- it('calls refuse and never next for a request carried by an app token', () => {
20
- const refuse = jest.fn();
21
- const next = jest.fn();
22
- const req = { method: 'GET' };
23
- const res = {
24
- locals: { oauth: { clientId: 'abys_app_x', scopes: ['console:read'] } },
25
- };
26
- (0, oauth_no_app_token_util_1.createNoAppTokenMiddleware)(refuse)(req, res, next);
27
- expect(refuse).toHaveBeenCalledTimes(1);
28
- expect(refuse).toHaveBeenCalledWith(req, res);
29
- expect(next).not.toHaveBeenCalled();
30
- });
31
- it('calls next and never refuse for a session', () => {
32
- const refuse = jest.fn();
33
- const next = jest.fn();
34
- (0, oauth_no_app_token_util_1.createNoAppTokenMiddleware)(refuse)({ method: 'GET' }, { locals: {} }, next);
35
- expect(next).toHaveBeenCalledTimes(1);
36
- expect(refuse).not.toHaveBeenCalled();
37
- });
38
- });
39
- });
40
- //# sourceMappingURL=oauth-no-app-token.util.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oauth-no-app-token.util.spec.js","sourceRoot":"","sources":["../../../src/server/tests/oauth-no-app-token.util.spec.ts"],"names":[],"mappings":";;AAAA,wEAA2F;AAM3F,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;YAC9E,MAAM,CAAC,IAAA,2CAAiB,EAAC,EAAE,KAAK,EA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B,EAAsB,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YAExE,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;YACnD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;YAEvB,IAAA,oDAA0B,EAA8B,MAAM,CAAC,CAC7D,EAAE,MAAM,EAAE,KAAK,EAAE,EACjB,EAAE,MAAM,EAAE,EAAE,EAAE,EACd,IAAI,CACL,CAAC;YAEF,MAAM,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const oauth_app_enum_1 = require("../../types/enum/oauth-app.enum");
4
- const oauth_request_guard_util_1 = require("../oauth-request-guard.util");
5
- const NOT_ALLOWED = {
6
- allowed: false,
7
- status: 403,
8
- code: oauth_request_guard_util_1.OAuthGuardRefusalCode.OAUTH_TOKEN_NOT_ALLOWED,
9
- };
10
- describe('oauth-request-guard.util', () => {
11
- describe('requiredOAuthAccessFor', () => {
12
- it.each([
13
- ['GET', oauth_app_enum_1.OAuthAppAccess.READ],
14
- ['HEAD', oauth_app_enum_1.OAuthAppAccess.READ],
15
- ['get', oauth_app_enum_1.OAuthAppAccess.READ],
16
- ['POST', oauth_app_enum_1.OAuthAppAccess.WRITE],
17
- ['PUT', oauth_app_enum_1.OAuthAppAccess.WRITE],
18
- ['PATCH', oauth_app_enum_1.OAuthAppAccess.WRITE],
19
- ['DELETE', oauth_app_enum_1.OAuthAppAccess.WRITE],
20
- ['OPTIONS', oauth_app_enum_1.OAuthAppAccess.WRITE],
21
- ])('%s needs %s', (method, access) => {
22
- expect((0, oauth_request_guard_util_1.requiredOAuthAccessFor)(method)).toBe(access);
23
- });
24
- });
25
- describe('createOAuthRequestGuard on a product with both accesses', () => {
26
- const guard = (0, oauth_request_guard_util_1.createOAuthRequestGuard)({ product: oauth_app_enum_1.OAuthAppProduct.CLOUD });
27
- it.each(['GET', 'HEAD'])('lets %s through with cloud:read', (method) => {
28
- expect(guard({ method }, { scopes: ['cloud:read'] })).toEqual({ allowed: true });
29
- });
30
- it.each(['GET', 'HEAD'])('refuses %s with cloud:write alone: write is not read', (method) => {
31
- expect(guard({ method }, { scopes: ['cloud:write'] })).toEqual({
32
- allowed: false,
33
- status: 403,
34
- code: oauth_request_guard_util_1.OAuthGuardRefusalCode.INSUFFICIENT_SCOPE,
35
- requiredScope: 'cloud:read',
36
- });
37
- });
38
- it.each(['POST', 'PUT', 'PATCH', 'DELETE'])('refuses %s with cloud:read, lets it through with cloud:write', (method) => {
39
- expect(guard({ method }, { scopes: ['cloud:read'] })).toEqual({
40
- allowed: false,
41
- status: 403,
42
- code: oauth_request_guard_util_1.OAuthGuardRefusalCode.INSUFFICIENT_SCOPE,
43
- requiredScope: 'cloud:write',
44
- });
45
- expect(guard({ method }, { scopes: ['cloud:write'] })).toEqual({ allowed: true });
46
- });
47
- it('refuses the scope of another product', () => {
48
- expect(guard({ method: 'GET' }, { scopes: ['form:read'] })).toMatchObject({
49
- allowed: false,
50
- code: oauth_request_guard_util_1.OAuthGuardRefusalCode.INSUFFICIENT_SCOPE,
51
- });
52
- });
53
- it('compares the method in any case', () => {
54
- expect(guard({ method: 'post' }, { scopes: ['cloud:read'] })).toMatchObject({
55
- allowed: false,
56
- requiredScope: 'cloud:write',
57
- });
58
- });
59
- });
60
- describe.each([oauth_app_enum_1.OAuthAppProduct.REFLEX, oauth_app_enum_1.OAuthAppProduct.CONSOLE])('createOAuthRequestGuard on %s, a read-only product', (product) => {
61
- const guard = (0, oauth_request_guard_util_1.createOAuthRequestGuard)({ product });
62
- it.each(['GET', 'HEAD'])('lets %s through with the read scope', (method) => {
63
- expect(guard({ method }, { scopes: [`${product}:read`] })).toEqual({ allowed: true });
64
- });
65
- it.each(['GET', 'HEAD'])('still asks for the read scope on %s', (method) => {
66
- expect(guard({ method }, { scopes: [] })).toEqual({
67
- allowed: false,
68
- status: 403,
69
- code: oauth_request_guard_util_1.OAuthGuardRefusalCode.INSUFFICIENT_SCOPE,
70
- requiredScope: `${product}:read`,
71
- });
72
- });
73
- it.each(['POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'])('refuses %s with oauthTokenNotAllowed, not insufficient_scope, whatever the scopes', (method) => {
74
- expect(guard({ method }, { scopes: [`${product}:read`] })).toEqual(NOT_ALLOWED);
75
- expect(guard({ method }, { scopes: [`${product}:read`, `${product}:write`] })).toEqual(NOT_ALLOWED);
76
- expect(guard({ method }, { scopes: [] })).toEqual(NOT_ALLOWED);
77
- });
78
- });
79
- });
80
- //# sourceMappingURL=oauth-request-guard.util.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"oauth-request-guard.util.spec.js","sourceRoot":"","sources":["../../../src/server/tests/oauth-request-guard.util.spec.ts"],"names":[],"mappings":";;AAAA,oEAAkF;AAClF,0EAIqC;AAErC,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,GAAG;IACX,IAAI,EAAE,gDAAqB,CAAC,uBAAuB;CACpD,CAAC;AAEF,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;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