@estopia/shared 1.0.39 → 1.0.40
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.
- package/dist/helpers/scopeMatching.d.ts +11 -0
- package/dist/helpers/scopeMatching.d.ts.map +1 -0
- package/dist/helpers/scopeMatching.js +26 -0
- package/dist/helpers/scopeMatching.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a set of granted scopes satisfies a required scope.
|
|
3
|
+
* Supports hierarchical matching: a parent scope grants all its children.
|
|
4
|
+
* Example: 'profile' grants 'profile:read', 'profile:email', etc.
|
|
5
|
+
*
|
|
6
|
+
* @param grantedScopes - The list of scopes granted to the user or client.
|
|
7
|
+
* @param requiredScope - The specific scope being checked.
|
|
8
|
+
* @returns true if the required scope is granted, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hasScope(grantedScopes: string[], requiredScope: string): boolean;
|
|
11
|
+
//# sourceMappingURL=scopeMatching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeMatching.d.ts","sourceRoot":"","sources":["../../src/helpers/scopeMatching.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAYhF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasScope = hasScope;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a set of granted scopes satisfies a required scope.
|
|
6
|
+
* Supports hierarchical matching: a parent scope grants all its children.
|
|
7
|
+
* Example: 'profile' grants 'profile:read', 'profile:email', etc.
|
|
8
|
+
*
|
|
9
|
+
* @param grantedScopes - The list of scopes granted to the user or client.
|
|
10
|
+
* @param requiredScope - The specific scope being checked.
|
|
11
|
+
* @returns true if the required scope is granted, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
function hasScope(grantedScopes, requiredScope) {
|
|
14
|
+
if (!grantedScopes || !Array.isArray(grantedScopes))
|
|
15
|
+
return false;
|
|
16
|
+
return grantedScopes.some(granted => {
|
|
17
|
+
// Exact match
|
|
18
|
+
if (granted === requiredScope)
|
|
19
|
+
return true;
|
|
20
|
+
// Parent match (e.g., 'profile' matches 'profile:read')
|
|
21
|
+
if (requiredScope.startsWith(granted + ':'))
|
|
22
|
+
return true;
|
|
23
|
+
return false;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=scopeMatching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopeMatching.js","sourceRoot":"","sources":["../../src/helpers/scopeMatching.ts"],"names":[],"mappings":";;AASA,4BAYC;AArBD;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,aAAuB,EAAE,aAAqB;IACrE,IAAI,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC;QAAE,OAAO,KAAK,CAAC;IAElE,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QAClC,cAAc;QACd,IAAI,OAAO,KAAK,aAAa;YAAE,OAAO,IAAI,CAAC;QAE3C,wDAAwD;QACxD,IAAI,aAAa,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAEzD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export type { UserDto } from './types/user';
|
|
|
2
2
|
export type { DB } from './database/dataTypes';
|
|
3
3
|
export { OAUTH_SCOPES, SCOPE_IDS } from './types/oauth';
|
|
4
4
|
export type { OAuthScope } from './types/oauth';
|
|
5
|
+
export { hasScope } from './helpers/scopeMatching';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SCOPE_IDS = exports.OAUTH_SCOPES = void 0;
|
|
3
|
+
exports.hasScope = exports.SCOPE_IDS = exports.OAUTH_SCOPES = void 0;
|
|
4
4
|
var oauth_1 = require("./types/oauth");
|
|
5
5
|
Object.defineProperty(exports, "OAUTH_SCOPES", { enumerable: true, get: function () { return oauth_1.OAUTH_SCOPES; } });
|
|
6
6
|
Object.defineProperty(exports, "SCOPE_IDS", { enumerable: true, get: function () { return oauth_1.SCOPE_IDS; } });
|
|
7
|
+
var scopeMatching_1 = require("./helpers/scopeMatching");
|
|
8
|
+
Object.defineProperty(exports, "hasScope", { enumerable: true, get: function () { return scopeMatching_1.hasScope; } });
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,uCAAwD;AAA/C,qGAAA,YAAY,OAAA;AAAE,kGAAA,SAAS,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,uCAAwD;AAA/C,qGAAA,YAAY,OAAA;AAAE,kGAAA,SAAS,OAAA;AAEhC,yDAAmD;AAA1C,yGAAA,QAAQ,OAAA"}
|
package/dist/server.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { EventPublisher } from './broker/publisher';
|
|
|
9
9
|
export { EventSubscriber } from './broker/subscriber';
|
|
10
10
|
export type { EventPayloads } from './broker/eventTypes';
|
|
11
11
|
export { validateJWTToken, tryValidateJWTToken } from './helpers/validateJWTToken';
|
|
12
|
+
export { hasScope } from './helpers/scopeMatching';
|
|
12
13
|
export type { EstopiaRequest } from './types/request';
|
|
13
14
|
export { requireAuth } from './helpers/middlware/auth';
|
|
14
15
|
export { requireSecure } from './helpers/middlware/secure';
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,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AAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireAdmin = exports.requireSecure = exports.requireAuth = exports.tryValidateJWTToken = exports.validateJWTToken = exports.EventSubscriber = exports.EventPublisher = exports.DB = exports.ScyllaDBClient = exports.CockroachDBClient = exports.createCockroachDBConnection = exports.createLogger = void 0;
|
|
3
|
+
exports.requireAdmin = exports.requireSecure = exports.requireAuth = exports.hasScope = exports.tryValidateJWTToken = exports.validateJWTToken = exports.EventSubscriber = exports.EventPublisher = exports.DB = exports.ScyllaDBClient = exports.CockroachDBClient = exports.createCockroachDBConnection = exports.createLogger = void 0;
|
|
4
4
|
var logger_1 = require("./logging/logger");
|
|
5
5
|
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_1.createLogger; } });
|
|
6
6
|
var cockroach_1 = require("./database/cockroach");
|
|
@@ -19,6 +19,8 @@ Object.defineProperty(exports, "EventSubscriber", { enumerable: true, get: funct
|
|
|
19
19
|
var validateJWTToken_1 = require("./helpers/validateJWTToken");
|
|
20
20
|
Object.defineProperty(exports, "validateJWTToken", { enumerable: true, get: function () { return validateJWTToken_1.validateJWTToken; } });
|
|
21
21
|
Object.defineProperty(exports, "tryValidateJWTToken", { enumerable: true, get: function () { return validateJWTToken_1.tryValidateJWTToken; } });
|
|
22
|
+
var scopeMatching_1 = require("./helpers/scopeMatching");
|
|
23
|
+
Object.defineProperty(exports, "hasScope", { enumerable: true, get: function () { return scopeMatching_1.hasScope; } });
|
|
22
24
|
var auth_1 = require("./helpers/middlware/auth");
|
|
23
25
|
Object.defineProperty(exports, "requireAuth", { enumerable: true, get: function () { return auth_1.requireAuth; } });
|
|
24
26
|
var secure_1 = require("./helpers/middlware/secure");
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;AAAA,2CAAgD;AAAvC,sGAAA,YAAY,OAAA;AAGrB,kDAAmE;AAA1D,wHAAA,2BAA2B,OAAA;AAKpC,iEAAiE;AACjE,yBAA+C;AAAtC,uGAAA,IAAI,OAAqB;AAClC,qDAA4D;AAAnD,kHAAA,MAAM,OAAkB;AACjC,iCAAsC;AAA7B,4FAAA,MAAM,OAAM;AAErB,gDAAoD;AAA3C,2GAAA,cAAc,OAAA;AACvB,kDAAsD;AAA7C,6GAAA,eAAe,OAAA;AAGxB,+DAAmF;AAA1E,oHAAA,gBAAgB,OAAA;AAAE,uHAAA,mBAAmB,OAAA;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;AAAA,2CAAgD;AAAvC,sGAAA,YAAY,OAAA;AAGrB,kDAAmE;AAA1D,wHAAA,2BAA2B,OAAA;AAKpC,iEAAiE;AACjE,yBAA+C;AAAtC,uGAAA,IAAI,OAAqB;AAClC,qDAA4D;AAAnD,kHAAA,MAAM,OAAkB;AACjC,iCAAsC;AAA7B,4FAAA,MAAM,OAAM;AAErB,gDAAoD;AAA3C,2GAAA,cAAc,OAAA;AACvB,kDAAsD;AAA7C,6GAAA,eAAe,OAAA;AAGxB,+DAAmF;AAA1E,oHAAA,gBAAgB,OAAA;AAAE,uHAAA,mBAAmB,OAAA;AAC9C,yDAAmD;AAA1C,yGAAA,QAAQ,OAAA;AAGjB,iDAAuD;AAA9C,mGAAA,WAAW,OAAA;AACpB,qDAA2D;AAAlD,uGAAA,aAAa,OAAA;AACtB,mDAAyD;AAAhD,qGAAA,YAAY,OAAA"}
|