@tstdl/base 0.82.13 → 0.82.14
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/authentication/server/authentication-subject.resolver.d.ts +7 -0
- package/authentication/server/authentication-subject.resolver.js +21 -0
- package/authentication/server/authentication-subject.resolver.js.map +1 -0
- package/authentication/server/authentication.service.d.ts +4 -1
- package/authentication/server/authentication.service.js +20 -9
- package/authentication/server/authentication.service.js.map +1 -1
- package/authentication/server/index.d.ts +1 -0
- package/authentication/server/index.js +1 -0
- package/authentication/server/index.js.map +1 -1
- package/authentication/server/module.d.ts +2 -0
- package/authentication/server/module.js +4 -0
- package/authentication/server/module.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a provided subject to the actual subject used for authentication.
|
|
3
|
+
* Useful for example if you want to be able to login via mail but actual subject is the user id.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class AuthenticationSubjectResolver {
|
|
6
|
+
abstract resolveSubject(providedSubject: string): string | Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuthenticationSubjectResolver = void 0;
|
|
10
|
+
const reflection_1 = require("../../reflection");
|
|
11
|
+
/**
|
|
12
|
+
* Resolve a provided subject to the actual subject used for authentication.
|
|
13
|
+
* Useful for example if you want to be able to login via mail but actual subject is the user id.
|
|
14
|
+
*/
|
|
15
|
+
let AuthenticationSubjectResolver = class AuthenticationSubjectResolver {
|
|
16
|
+
};
|
|
17
|
+
AuthenticationSubjectResolver = __decorate([
|
|
18
|
+
(0, reflection_1.Class)()
|
|
19
|
+
], AuthenticationSubjectResolver);
|
|
20
|
+
exports.AuthenticationSubjectResolver = AuthenticationSubjectResolver;
|
|
21
|
+
//# sourceMappingURL=authentication-subject.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication-subject.resolver.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication-subject.resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iDAAqC;AAErC;;;GAGG;AAEI,IAAe,6BAA6B,GAA5C,MAAe,6BAA6B;CAElD,CAAA;AAFqB,6BAA6B;IADlD,IAAA,kBAAK,GAAE;GACc,6BAA6B,CAElD;AAFqB,sEAA6B"}
|
|
@@ -4,6 +4,7 @@ import type { Record } from "../../types";
|
|
|
4
4
|
import type { RefreshToken, Token } from '../models';
|
|
5
5
|
import { AuthenticationCredentialsRepository } from './authentication-credentials.repository';
|
|
6
6
|
import { AuthenticationSessionRepository } from './authentication-session.repository';
|
|
7
|
+
import { AuthenticationSubjectResolver } from './authentication-subject.resolver';
|
|
7
8
|
import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider';
|
|
8
9
|
export declare class AuthenticationServiceOptions {
|
|
9
10
|
/** Secret used for signing tokens and refreshTokens */
|
|
@@ -31,13 +32,14 @@ export declare class AuthenticationService<AdditionalTokenPayload = Record<never
|
|
|
31
32
|
private readonly credentialsRepository;
|
|
32
33
|
private readonly sessionRepository;
|
|
33
34
|
private readonly tokenPayloadProvider;
|
|
35
|
+
private readonly subjectResolver;
|
|
34
36
|
private readonly secret;
|
|
35
37
|
private readonly tokenVersion;
|
|
36
38
|
private readonly tokenTimeToLive;
|
|
37
39
|
private readonly sessionTimeToLive;
|
|
38
40
|
private derivedTokenSigningSecret;
|
|
39
41
|
private derivedRefreshTokenSigningSecret;
|
|
40
|
-
constructor(credentialsRepository: AuthenticationCredentialsRepository, sessionRepository: AuthenticationSessionRepository, tokenPayloadProvider: AuthenticationTokenPayloadProvider<AdditionalTokenPayload, AuthenticationData> | undefined, options: AuthenticationServiceOptions);
|
|
42
|
+
constructor(credentialsRepository: AuthenticationCredentialsRepository, sessionRepository: AuthenticationSessionRepository, subjectResolver: AuthenticationSubjectResolver | undefined, tokenPayloadProvider: AuthenticationTokenPayloadProvider<AdditionalTokenPayload, AuthenticationData> | undefined, options: AuthenticationServiceOptions);
|
|
41
43
|
[afterResolve](): Promise<void>;
|
|
42
44
|
initialize(): Promise<void>;
|
|
43
45
|
setCredentials(subject: string, secret: string): Promise<void>;
|
|
@@ -47,6 +49,7 @@ export declare class AuthenticationService<AdditionalTokenPayload = Record<never
|
|
|
47
49
|
refresh(refreshToken: string, authenticationData: AuthenticationData): Promise<TokenResult<AdditionalTokenPayload>>;
|
|
48
50
|
validateToken(token: string): Promise<Token<AdditionalTokenPayload>>;
|
|
49
51
|
validateRefreshToken(token: string): Promise<RefreshToken>;
|
|
52
|
+
private getActualSubject;
|
|
50
53
|
private createToken;
|
|
51
54
|
private createRefreshToken;
|
|
52
55
|
private deriveSigningSecrets;
|
|
@@ -26,6 +26,7 @@ const type_guards_1 = require("../../utils/type-guards");
|
|
|
26
26
|
const units_1 = require("../../utils/units");
|
|
27
27
|
const authentication_credentials_repository_1 = require("./authentication-credentials.repository");
|
|
28
28
|
const authentication_session_repository_1 = require("./authentication-session.repository");
|
|
29
|
+
const authentication_subject_resolver_1 = require("./authentication-subject.resolver");
|
|
29
30
|
const authentication_token_payload_provider_1 = require("./authentication-token-payload.provider");
|
|
30
31
|
const helper_1 = require("./helper");
|
|
31
32
|
class AuthenticationServiceOptions {
|
|
@@ -60,15 +61,17 @@ let AuthenticationService = class AuthenticationService {
|
|
|
60
61
|
credentialsRepository;
|
|
61
62
|
sessionRepository;
|
|
62
63
|
tokenPayloadProvider;
|
|
64
|
+
subjectResolver;
|
|
63
65
|
secret;
|
|
64
66
|
tokenVersion;
|
|
65
67
|
tokenTimeToLive;
|
|
66
68
|
sessionTimeToLive;
|
|
67
69
|
derivedTokenSigningSecret;
|
|
68
70
|
derivedRefreshTokenSigningSecret;
|
|
69
|
-
constructor(credentialsRepository, sessionRepository, tokenPayloadProvider, options) {
|
|
71
|
+
constructor(credentialsRepository, sessionRepository, subjectResolver, tokenPayloadProvider, options) {
|
|
70
72
|
this.credentialsRepository = credentialsRepository;
|
|
71
73
|
this.sessionRepository = sessionRepository;
|
|
74
|
+
this.subjectResolver = subjectResolver;
|
|
72
75
|
this.tokenPayloadProvider = tokenPayloadProvider;
|
|
73
76
|
this.secret = options.secret;
|
|
74
77
|
this.tokenVersion = options.version ?? 1;
|
|
@@ -82,10 +85,11 @@ let AuthenticationService = class AuthenticationService {
|
|
|
82
85
|
await this.deriveSigningSecrets();
|
|
83
86
|
}
|
|
84
87
|
async setCredentials(subject, secret) {
|
|
88
|
+
const actualSubject = await this.getActualSubject(subject);
|
|
85
89
|
const salt = (0, random_1.getRandomBytes)(32);
|
|
86
90
|
const hash = await this.getHash(secret, salt);
|
|
87
91
|
const credentials = {
|
|
88
|
-
subject,
|
|
92
|
+
subject: actualSubject,
|
|
89
93
|
hashVersion: 1,
|
|
90
94
|
salt,
|
|
91
95
|
hash
|
|
@@ -93,7 +97,8 @@ let AuthenticationService = class AuthenticationService {
|
|
|
93
97
|
await this.credentialsRepository.save(credentials);
|
|
94
98
|
}
|
|
95
99
|
async authenticate(subject, secret) {
|
|
96
|
-
const
|
|
100
|
+
const actualSubject = await this.getActualSubject(subject);
|
|
101
|
+
const credentials = await this.credentialsRepository.tryLoadBySubject(actualSubject);
|
|
97
102
|
if ((0, type_guards_1.isUndefined)(credentials)) {
|
|
98
103
|
return { success: false };
|
|
99
104
|
}
|
|
@@ -105,19 +110,20 @@ let AuthenticationService = class AuthenticationService {
|
|
|
105
110
|
return { success: false };
|
|
106
111
|
}
|
|
107
112
|
async getToken(subject, authenticationData) {
|
|
113
|
+
const actualSubject = await this.getActualSubject(subject);
|
|
108
114
|
const now = (0, date_time_1.currentTimestamp)();
|
|
109
115
|
const end = now + this.sessionTimeToLive;
|
|
110
116
|
const session = await this.sessionRepository.insert({
|
|
111
|
-
subject,
|
|
117
|
+
subject: actualSubject,
|
|
112
118
|
begin: now,
|
|
113
119
|
end,
|
|
114
120
|
refreshTokenHashVersion: 0,
|
|
115
121
|
refreshTokenSalt: new Uint8Array(),
|
|
116
122
|
refreshTokenHash: new Uint8Array()
|
|
117
123
|
});
|
|
118
|
-
const tokenPayload = await this.tokenPayloadProvider?.getTokenPayload(
|
|
119
|
-
const { token, jsonToken } = await this.createToken(tokenPayload,
|
|
120
|
-
const refreshToken = await this.createRefreshToken(
|
|
124
|
+
const tokenPayload = await this.tokenPayloadProvider?.getTokenPayload(actualSubject, authenticationData);
|
|
125
|
+
const { token, jsonToken } = await this.createToken(tokenPayload, actualSubject, session.id, end, now);
|
|
126
|
+
const refreshToken = await this.createRefreshToken(actualSubject, session.id, end);
|
|
121
127
|
await this.sessionRepository.extend(session.id, {
|
|
122
128
|
end,
|
|
123
129
|
refreshTokenHashVersion: 1,
|
|
@@ -164,6 +170,9 @@ let AuthenticationService = class AuthenticationService {
|
|
|
164
170
|
}
|
|
165
171
|
return validatedToken;
|
|
166
172
|
}
|
|
173
|
+
async getActualSubject(subject) {
|
|
174
|
+
return this.subjectResolver?.resolveSubject(subject) ?? subject;
|
|
175
|
+
}
|
|
167
176
|
async createToken(additionalTokenPayload, subject, sessionId, refreshTokenExpiration, timestamp) {
|
|
168
177
|
const header = {
|
|
169
178
|
v: this.tokenVersion,
|
|
@@ -220,10 +229,12 @@ let AuthenticationService = class AuthenticationService {
|
|
|
220
229
|
};
|
|
221
230
|
AuthenticationService = __decorate([
|
|
222
231
|
(0, container_1.singleton)(),
|
|
223
|
-
__param(2, (0, container_1.inject)(
|
|
232
|
+
__param(2, (0, container_1.inject)(authentication_subject_resolver_1.AuthenticationSubjectResolver)),
|
|
224
233
|
__param(2, (0, container_1.optional)()),
|
|
234
|
+
__param(3, (0, container_1.inject)(authentication_token_payload_provider_1.AuthenticationTokenPayloadProvider)),
|
|
235
|
+
__param(3, (0, container_1.optional)()),
|
|
225
236
|
__metadata("design:paramtypes", [authentication_credentials_repository_1.AuthenticationCredentialsRepository,
|
|
226
|
-
authentication_session_repository_1.AuthenticationSessionRepository, Object, AuthenticationServiceOptions])
|
|
237
|
+
authentication_session_repository_1.AuthenticationSessionRepository, Object, Object, AuthenticationServiceOptions])
|
|
227
238
|
], AuthenticationService);
|
|
228
239
|
exports.AuthenticationService = AuthenticationService;
|
|
229
240
|
//# sourceMappingURL=authentication.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAAwE;AACxE,yEAAgE;AAChE,yCAAoD;AAEpD,mDAA4C;AAC5C,2DAAuD;AACvD,qDAA2G;AAC3G,+CAA8C;AAC9C,yCAAmF;AACnF,+CAAiE;AACjE,yDAAkD;AAClD,6CAA0E;AAE1E,mGAA8F;AAC9F,2FAAsF;AACtF,mGAA6F;AAC7F,qCAA8C;AAE9C,MAAa,4BAA4B;IACvC,uDAAuD;IAEvD,MAAM,CAAS;IAEf,4EAA4E;IAE5E,OAAO,CAAU;IAEjB,gCAAgC;IAEhC,eAAe,CAAU;IAEzB,gHAAgH;IAEhH,iBAAiB,CAAU;CAC5B;AAdC;IAAC,IAAA,iBAAQ,GAAE;;4DACI;AAGf;IAAC,IAAA,uBAAc,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6DAClB;AAGjB;IAAC,IAAA,uBAAc,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qEACV;AAGzB;IAAC,IAAA,uBAAc,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uEACR;AAf7B,oEAgBC;AAwBD,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAG5B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACf,qBAAqB,CAAsC;IAC3D,iBAAiB,CAAkC;IACnD,oBAAoB,CAA6F;
|
|
1
|
+
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAAwE;AACxE,yEAAgE;AAChE,yCAAoD;AAEpD,mDAA4C;AAC5C,2DAAuD;AACvD,qDAA2G;AAC3G,+CAA8C;AAC9C,yCAAmF;AACnF,+CAAiE;AACjE,yDAAkD;AAClD,6CAA0E;AAE1E,mGAA8F;AAC9F,2FAAsF;AACtF,uFAAkF;AAClF,mGAA6F;AAC7F,qCAA8C;AAE9C,MAAa,4BAA4B;IACvC,uDAAuD;IAEvD,MAAM,CAAS;IAEf,4EAA4E;IAE5E,OAAO,CAAU;IAEjB,gCAAgC;IAEhC,eAAe,CAAU;IAEzB,gHAAgH;IAEhH,iBAAiB,CAAU;CAC5B;AAdC;IAAC,IAAA,iBAAQ,GAAE;;4DACI;AAGf;IAAC,IAAA,uBAAc,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6DAClB;AAGjB;IAAC,IAAA,uBAAc,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qEACV;AAGzB;IAAC,IAAA,uBAAc,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uEACR;AAf7B,oEAgBC;AAwBD,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAG5B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACf,qBAAqB,CAAsC;IAC3D,iBAAiB,CAAkC;IACnD,oBAAoB,CAA6F;IACjH,eAAe,CAA4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,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QAC3E,IAAI,CAAC,gCAAgC,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACjF,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,MAA2B,EAAE,IAAgB;QACjE,MAAM,GAAG,GAAG,MAAM,IAAA,8BAAe,EAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAEhI,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF,CAAA;AA7NY,qBAAqB;IADjC,IAAA,qBAAS,GAAE;IAkBP,WAAA,IAAA,kBAAM,EAAC,+DAA6B,CAAC,CAAA;IAAE,WAAA,IAAA,oBAAQ,GAAE,CAAA;IACjD,WAAA,IAAA,kBAAM,EAAC,0EAAkC,CAAC,CAAA;IAAE,WAAA,IAAA,oBAAQ,GAAE,CAAA;qCAHhC,2EAAmC;QACvC,mEAA+B,kBAGzC,4BAA4B;GAnB5B,qBAAqB,CA6NjC;AA7NY,sDAAqB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './authentication-credentials.repository';
|
|
2
2
|
export * from './authentication-session.repository';
|
|
3
|
+
export * from './authentication-subject.resolver';
|
|
3
4
|
export * from './authentication-token-payload.provider';
|
|
4
5
|
export * from './authentication.api-controller';
|
|
5
6
|
export * from './authentication.service';
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./authentication-credentials.repository"), exports);
|
|
18
18
|
__exportStar(require("./authentication-session.repository"), exports);
|
|
19
|
+
__exportStar(require("./authentication-subject.resolver"), exports);
|
|
19
20
|
__exportStar(require("./authentication-token-payload.provider"), exports);
|
|
20
21
|
__exportStar(require("./authentication.api-controller"), exports);
|
|
21
22
|
__exportStar(require("./authentication.service"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/authentication/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0EAAwD;AACxD,sEAAoD;AACpD,0EAAwD;AACxD,kEAAgD;AAChD,2DAAyC;AACzC,2CAAyB;AACzB,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/authentication/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0EAAwD;AACxD,sEAAoD;AACpD,oEAAkD;AAClD,0EAAwD;AACxD,kEAAgD;AAChD,2DAAyC;AACzC,2CAAyB;AACzB,2CAAyB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Type } from "../../types";
|
|
2
2
|
import { AuthenticationCredentialsRepository } from './authentication-credentials.repository';
|
|
3
3
|
import { AuthenticationSessionRepository } from './authentication-session.repository';
|
|
4
|
+
import { AuthenticationSubjectResolver } from './authentication-subject.resolver';
|
|
4
5
|
import { AuthenticationTokenPayloadProvider } from './authentication-token-payload.provider';
|
|
5
6
|
import { AuthenticationService, AuthenticationServiceOptions } from './authentication.service';
|
|
6
7
|
export type AuthenticationModuleConfig = {
|
|
@@ -10,5 +11,6 @@ export type AuthenticationModuleConfig = {
|
|
|
10
11
|
/** override default AuthenticationService */
|
|
11
12
|
authenticationService?: Type<AuthenticationService<any, any>>;
|
|
12
13
|
tokenPayloadProvider?: Type<AuthenticationTokenPayloadProvider<any, any>>;
|
|
14
|
+
subjectResolver?: Type<AuthenticationSubjectResolver>;
|
|
13
15
|
};
|
|
14
16
|
export declare function configureAuthenticationServer(config: AuthenticationModuleConfig): void;
|
|
@@ -5,6 +5,7 @@ const container_1 = require("../../container");
|
|
|
5
5
|
const type_guards_1 = require("../../utils/type-guards");
|
|
6
6
|
const authentication_credentials_repository_1 = require("./authentication-credentials.repository");
|
|
7
7
|
const authentication_session_repository_1 = require("./authentication-session.repository");
|
|
8
|
+
const authentication_subject_resolver_1 = require("./authentication-subject.resolver");
|
|
8
9
|
const authentication_token_payload_provider_1 = require("./authentication-token-payload.provider");
|
|
9
10
|
const authentication_service_1 = require("./authentication.service");
|
|
10
11
|
function configureAuthenticationServer(config) {
|
|
@@ -17,6 +18,9 @@ function configureAuthenticationServer(config) {
|
|
|
17
18
|
if ((0, type_guards_1.isDefined)(config.tokenPayloadProvider)) {
|
|
18
19
|
container_1.container.registerSingleton(authentication_token_payload_provider_1.AuthenticationTokenPayloadProvider, { useToken: config.tokenPayloadProvider });
|
|
19
20
|
}
|
|
21
|
+
if ((0, type_guards_1.isDefined)(config.subjectResolver)) {
|
|
22
|
+
container_1.container.registerSingleton(authentication_subject_resolver_1.AuthenticationSubjectResolver, { useToken: config.subjectResolver });
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
exports.configureAuthenticationServer = configureAuthenticationServer;
|
|
22
26
|
//# sourceMappingURL=module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../source/authentication/server/module.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC,yDAAgD;AAChD,mGAA8F;AAC9F,2FAAsF;AACtF,mGAA6F;AAC7F,qEAA+F;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../source/authentication/server/module.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC,yDAAgD;AAChD,mGAA8F;AAC9F,2FAAsF;AACtF,uFAAkF;AAClF,mGAA6F;AAC7F,qEAA+F;AAa/F,SAAgB,6BAA6B,CAAC,MAAkC;IAC9E,qBAAS,CAAC,QAAQ,CAAC,qDAA4B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IACtF,qBAAS,CAAC,iBAAiB,CAAC,2EAAmC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC7G,qBAAS,CAAC,iBAAiB,CAAC,mEAA+B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAErG,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE;QAC3C,qBAAS,CAAC,iBAAiB,CAAC,8CAAqB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;KAChG;IAED,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE;QAC1C,qBAAS,CAAC,iBAAiB,CAAC,0EAAkC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,oBAAoB,EAAE,CAAC,CAAC;KAC5G;IAED,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,eAAe,CAAC,EAAE;QACrC,qBAAS,CAAC,iBAAiB,CAAC,+DAA6B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;KAClG;AACH,CAAC;AAhBD,sEAgBC"}
|