@point3/logto-module 1.0.8 → 1.0.10
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/client/__tests__/m2m-client.spec.js +16 -14
- package/dist/client/__tests__/m2m-client.spec.js.map +1 -1
- package/dist/client/__tests__/oauth-client.spec.js +17 -15
- package/dist/client/__tests__/oauth-client.spec.js.map +1 -1
- package/dist/client/config.js +7 -4
- package/dist/client/config.js.map +1 -1
- package/dist/client/index.js +21 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/logto-login-session.js +23 -17
- package/dist/client/logto-login-session.js.map +1 -1
- package/dist/client/m2m-client.js +33 -29
- package/dist/client/m2m-client.js.map +1 -1
- package/dist/client/oauth-client.js +32 -26
- package/dist/client/oauth-client.js.map +1 -1
- package/dist/client/types.js +17 -10
- package/dist/client/types.js.map +1 -1
- package/dist/errors.js +19 -8
- package/dist/errors.js.map +1 -1
- package/dist/index.js +40 -4
- package/dist/index.js.map +1 -1
- package/dist/module.js +23 -19
- package/dist/module.js.map +1 -1
- package/dist/stateless/decorator.js +7 -4
- package/dist/stateless/decorator.js.map +1 -1
- package/dist/stateless/guard.js +56 -20
- package/dist/stateless/guard.js.map +1 -1
- package/dist/stateless/guard.spec.js +24 -22
- package/dist/stateless/guard.spec.js.map +1 -1
- package/dist/stateless/index.js +18 -2
- package/dist/stateless/index.js.map +1 -1
- package/dist/token/access-token.js +5 -1
- package/dist/token/access-token.js.map +1 -1
- package/dist/token/index.js +18 -2
- package/dist/token/index.js.map +1 -1
- package/dist/token/verifier.js +18 -15
- package/dist/token/verifier.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/tsconfig.json +1 -2
package/dist/token/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./access-token"), exports);
|
|
18
|
+
__exportStar(require("./verifier"), exports);
|
|
3
19
|
//# sourceMappingURL=index.js.map
|
package/dist/token/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../token/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../token/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,6CAA2B"}
|
package/dist/token/verifier.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -10,20 +11,22 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LogtoTokenVerifier = exports.LogtoTokenVerifierToken = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const config_1 = require("@nestjs/config");
|
|
18
|
+
const jose_1 = require("jose");
|
|
19
|
+
exports.LogtoTokenVerifierToken = Symbol.for("LogtoTokenVerifier");
|
|
17
20
|
let LogtoTokenVerifier = class LogtoTokenVerifier {
|
|
18
21
|
constructor(configService) {
|
|
19
22
|
this.configService = configService;
|
|
20
23
|
}
|
|
21
24
|
async verifyToken(token, requiredScopes, requiredRoles) {
|
|
22
25
|
if (!token)
|
|
23
|
-
throw new UnauthorizedException('엑세스 토큰이 존재하지 않습니다.');
|
|
26
|
+
throw new common_1.UnauthorizedException('엑세스 토큰이 존재하지 않습니다.');
|
|
24
27
|
const jwksUri = this.configService.get("LOGTO_JWKS_URI") ?? 'http://localhost:3001/oidc/jwks';
|
|
25
28
|
const issuer = this.configService.get("LOGTO_AUTH_ISSUER");
|
|
26
|
-
const { payload } = await jwtVerify(token, createRemoteJWKSet(new URL(jwksUri)), { issuer });
|
|
29
|
+
const { payload } = await (0, jose_1.jwtVerify)(token, (0, jose_1.createRemoteJWKSet)(new URL(jwksUri)), { issuer });
|
|
27
30
|
const tokenPayload = payload;
|
|
28
31
|
if (requiredScopes || requiredRoles) {
|
|
29
32
|
this.shouldContainRequiredPrivileges(tokenPayload, requiredScopes, requiredRoles);
|
|
@@ -33,17 +36,17 @@ let LogtoTokenVerifier = class LogtoTokenVerifier {
|
|
|
33
36
|
async verifyIdToken(token) {
|
|
34
37
|
const jwksUri = process.env.LOGTO_JWKS_URI ?? 'http://localhost:3001/oidc/jwks';
|
|
35
38
|
const issuer = process.env.LOGTO_AUTH_ISSUER;
|
|
36
|
-
const { payload } = await jwtVerify(token, createRemoteJWKSet(new URL(jwksUri)), { issuer });
|
|
39
|
+
const { payload } = await (0, jose_1.jwtVerify)(token, (0, jose_1.createRemoteJWKSet)(new URL(jwksUri)), { issuer });
|
|
37
40
|
return payload;
|
|
38
41
|
}
|
|
39
42
|
shouldContainRequiredPrivileges(payload, requiredScopes, requiredRoles) {
|
|
40
43
|
const { userScopes, userRoles } = payload;
|
|
41
44
|
const scopes = userScopes?.flat() ?? [];
|
|
42
45
|
if (this.hasInsufficientScopes(requiredScopes, scopes)) {
|
|
43
|
-
throw new UnauthorizedException({ code: 'auth.insufficient_scope', status: 403 }, { cause: requiredScopes });
|
|
46
|
+
throw new common_1.UnauthorizedException({ code: 'auth.insufficient_scope', status: 403 }, { cause: requiredScopes });
|
|
44
47
|
}
|
|
45
48
|
if (this.hasInsufficientRoles(requiredRoles, userRoles)) {
|
|
46
|
-
throw new UnauthorizedException({ code: 'auth.role_mismatch', status: 403 }, { cause: requiredRoles });
|
|
49
|
+
throw new common_1.UnauthorizedException({ code: 'auth.role_mismatch', status: 403 }, { cause: requiredRoles });
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
hasInsufficientScopes(requiredScopes, userScopes) {
|
|
@@ -53,11 +56,11 @@ let LogtoTokenVerifier = class LogtoTokenVerifier {
|
|
|
53
56
|
return !!(requiredRoles && requiredRoles.length > 0 && !requiredRoles.some(role => userRoles.includes(role)));
|
|
54
57
|
}
|
|
55
58
|
};
|
|
56
|
-
LogtoTokenVerifier =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
exports.LogtoTokenVerifier = LogtoTokenVerifier;
|
|
60
|
+
exports.LogtoTokenVerifier = LogtoTokenVerifier = __decorate([
|
|
61
|
+
(0, common_1.Global)(),
|
|
62
|
+
(0, common_1.Injectable)(),
|
|
63
|
+
__param(0, (0, common_1.Inject)(config_1.ConfigService)),
|
|
64
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
61
65
|
], LogtoTokenVerifier);
|
|
62
|
-
export { LogtoTokenVerifier };
|
|
63
66
|
//# sourceMappingURL=verifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../token/verifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../token/verifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmF;AACnF,2CAA+C;AAC/C,+BAAqD;AAIxC,QAAA,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAIjE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC3B,YAEqB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAC7C,CAAC;IAYE,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,cAAyB,EAAE,aAAwB;QACvF,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,8BAAqB,CAAC,oBAAoB,CAAC,CAAC;QAElE,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,gBAAgB,CAAC,IAAI,iCAAiC,CAAC;QACtG,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC,CAAC;QAEnE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,gBAAS,EAC/B,KAAK,EAAE,IAAA,yBAAkB,EAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,EAC3C,EAAE,MAAM,EAAE,CACb,CAAC;QAEF,MAAM,YAAY,GAAG,OAAmC,CAAC;QAEzD,IAAI,cAAc,IAAI,aAAa,EAAE,CAAC;YAClC,IAAI,CAAC,+BAA+B,CAChC,YAAY,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,YAAY,CAAC;IACxB,CAAC;IAOM,KAAK,CAAC,aAAa,CAAC,KAAa;QACpC,MAAM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