@nauth-toolkit/core 0.1.29 → 0.1.31
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/dto/index.d.ts +1 -0
- package/dist/dto/index.d.ts.map +1 -1
- package/dist/dto/index.js +1 -0
- package/dist/dto/index.js.map +1 -1
- package/dist/dto/social-auth.dto.d.ts +0 -83
- package/dist/dto/social-auth.dto.d.ts.map +1 -1
- package/dist/dto/social-auth.dto.js +1 -143
- package/dist/dto/social-auth.dto.js.map +1 -1
- package/dist/dto/social-redirect.dto.d.ts +302 -0
- package/dist/dto/social-redirect.dto.d.ts.map +1 -0
- package/dist/dto/social-redirect.dto.js +464 -0
- package/dist/dto/social-redirect.dto.js.map +1 -0
- package/dist/dto/verify-mfa-code.dto.d.ts.map +1 -1
- package/dist/dto/verify-mfa-code.dto.js.map +1 -1
- package/dist/handlers/social-redirect.handler.d.ts +3 -3
- package/dist/handlers/social-redirect.handler.d.ts.map +1 -1
- package/dist/handlers/social-redirect.handler.js +9 -12
- package/dist/handlers/social-redirect.handler.js.map +1 -1
- package/dist/schemas/auth-config.schema.d.ts +12 -12
- package/dist/services/index.d.ts +0 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/social-auth.service.d.ts +8 -47
- package/dist/services/social-auth.service.d.ts.map +1 -1
- package/dist/services/social-auth.service.js +7 -56
- package/dist/services/social-auth.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -2930,6 +2930,9 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2930
2930
|
disallowMultipleSessions?: boolean | undefined;
|
|
2931
2931
|
maxLifetime?: string | number | undefined;
|
|
2932
2932
|
} | undefined;
|
|
2933
|
+
login?: {
|
|
2934
|
+
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
2935
|
+
} | undefined;
|
|
2933
2936
|
social?: {
|
|
2934
2937
|
google?: {
|
|
2935
2938
|
clientSecret?: string | undefined;
|
|
@@ -2966,9 +2969,6 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2966
2969
|
allowedReturnToOrigins?: string[] | undefined;
|
|
2967
2970
|
} | undefined;
|
|
2968
2971
|
} | undefined;
|
|
2969
|
-
login?: {
|
|
2970
|
-
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
2971
|
-
} | undefined;
|
|
2972
2972
|
tablePrefix?: string | undefined;
|
|
2973
2973
|
signup?: {
|
|
2974
2974
|
enabled?: boolean | undefined;
|
|
@@ -3198,6 +3198,9 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3198
3198
|
disallowMultipleSessions?: boolean | undefined;
|
|
3199
3199
|
maxLifetime?: string | number | undefined;
|
|
3200
3200
|
} | undefined;
|
|
3201
|
+
login?: {
|
|
3202
|
+
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
3203
|
+
} | undefined;
|
|
3201
3204
|
social?: {
|
|
3202
3205
|
google?: {
|
|
3203
3206
|
clientSecret?: string | undefined;
|
|
@@ -3234,9 +3237,6 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3234
3237
|
allowedReturnToOrigins?: string[] | undefined;
|
|
3235
3238
|
} | undefined;
|
|
3236
3239
|
} | undefined;
|
|
3237
|
-
login?: {
|
|
3238
|
-
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
3239
|
-
} | undefined;
|
|
3240
3240
|
tablePrefix?: string | undefined;
|
|
3241
3241
|
signup?: {
|
|
3242
3242
|
enabled?: boolean | undefined;
|
|
@@ -3466,6 +3466,9 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3466
3466
|
disallowMultipleSessions?: boolean | undefined;
|
|
3467
3467
|
maxLifetime?: string | number | undefined;
|
|
3468
3468
|
} | undefined;
|
|
3469
|
+
login?: {
|
|
3470
|
+
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
3471
|
+
} | undefined;
|
|
3469
3472
|
social?: {
|
|
3470
3473
|
google?: {
|
|
3471
3474
|
clientSecret?: string | undefined;
|
|
@@ -3502,9 +3505,6 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3502
3505
|
allowedReturnToOrigins?: string[] | undefined;
|
|
3503
3506
|
} | undefined;
|
|
3504
3507
|
} | undefined;
|
|
3505
|
-
login?: {
|
|
3506
|
-
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
3507
|
-
} | undefined;
|
|
3508
3508
|
tablePrefix?: string | undefined;
|
|
3509
3509
|
signup?: {
|
|
3510
3510
|
enabled?: boolean | undefined;
|
|
@@ -3734,6 +3734,9 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3734
3734
|
disallowMultipleSessions?: boolean | undefined;
|
|
3735
3735
|
maxLifetime?: string | number | undefined;
|
|
3736
3736
|
} | undefined;
|
|
3737
|
+
login?: {
|
|
3738
|
+
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
3739
|
+
} | undefined;
|
|
3737
3740
|
social?: {
|
|
3738
3741
|
google?: {
|
|
3739
3742
|
clientSecret?: string | undefined;
|
|
@@ -3770,9 +3773,6 @@ export declare const authConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
3770
3773
|
allowedReturnToOrigins?: string[] | undefined;
|
|
3771
3774
|
} | undefined;
|
|
3772
3775
|
} | undefined;
|
|
3773
|
-
login?: {
|
|
3774
|
-
identifierType?: "email" | "phone" | "username" | "email_or_username" | undefined;
|
|
3775
|
-
} | undefined;
|
|
3776
3776
|
tablePrefix?: string | undefined;
|
|
3777
3777
|
signup?: {
|
|
3778
3778
|
enabled?: boolean | undefined;
|
package/dist/services/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export * from './session.service';
|
|
|
4
4
|
export * from './auth.service';
|
|
5
5
|
export * from './email-verification.service';
|
|
6
6
|
export * from './client-info.service';
|
|
7
|
-
export * from './challenge.service';
|
|
8
7
|
export * from './auth-challenge-helper.service';
|
|
9
8
|
export * from './mfa-base.service';
|
|
10
9
|
export * from './mfa.service';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AAEtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC"}
|
package/dist/services/index.js
CHANGED
|
@@ -20,7 +20,7 @@ __exportStar(require("./session.service"), exports);
|
|
|
20
20
|
__exportStar(require("./auth.service"), exports);
|
|
21
21
|
__exportStar(require("./email-verification.service"), exports);
|
|
22
22
|
__exportStar(require("./client-info.service"), exports);
|
|
23
|
-
|
|
23
|
+
// ChallengeService is internal - exported from /internal only
|
|
24
24
|
__exportStar(require("./auth-challenge-helper.service"), exports);
|
|
25
25
|
__exportStar(require("./mfa-base.service"), exports);
|
|
26
26
|
__exportStar(require("./mfa.service"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,gDAA8B;AAC9B,oDAAkC;AAClC,iDAA+B;AAC/B,+DAA6C;AAC7C,wDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,gDAA8B;AAC9B,oDAAkC;AAClC,iDAA+B;AAC/B,+DAA6C;AAC7C,wDAAsC;AACtC,8DAA8D;AAC9D,kEAAgD;AAChD,qDAAmC;AACnC,gDAA8B;AAC9B,2DAAyC;AACzC,yDAAuC;AACvC,kEAAgD"}
|
|
@@ -5,17 +5,19 @@ import { AuthService } from './auth.service';
|
|
|
5
5
|
import { InternalAuthAuditService as AuthAuditService } from './auth-audit.service';
|
|
6
6
|
import { NAuthLogger } from '../utils/nauth-logger';
|
|
7
7
|
import { SocialProviderRegistry } from './social-provider-registry.service';
|
|
8
|
-
import {
|
|
9
|
-
import { GetSocialAuthUrlDTO, GetSocialAuthUrlResponseDTO, HandleSocialCallbackDTO, LinkSocialAccountDTO, LinkSocialAccountResponseDTO, GetLinkedAccountsDTO, GetLinkedAccountsResponseDTO, UnlinkSocialAccountDTO, UnlinkSocialAccountResponseDTO, CanSetPasswordDTO, CanSetPasswordResponseDTO, SetPasswordForSocialUserDTO, SetPasswordForSocialUserResponseDTO } from '../dto/social-auth.dto';
|
|
8
|
+
import { LinkSocialAccountDTO, LinkSocialAccountResponseDTO, GetLinkedAccountsDTO, GetLinkedAccountsResponseDTO, UnlinkSocialAccountDTO, UnlinkSocialAccountResponseDTO, CanSetPasswordDTO, CanSetPasswordResponseDTO, SetPasswordForSocialUserDTO, SetPasswordForSocialUserResponseDTO } from '../dto/social-auth.dto';
|
|
10
9
|
/**
|
|
11
10
|
* Social Auth Service
|
|
12
11
|
*
|
|
13
|
-
*
|
|
12
|
+
* Service for managing social authentication accounts and their relationships.
|
|
14
13
|
* This service provides:
|
|
15
|
-
* - OAuth authentication flows (login/signup via social providers)
|
|
16
14
|
* - Social account linking/unlinking
|
|
17
15
|
* - Account management for social users
|
|
18
16
|
* - Password management for social-only users
|
|
17
|
+
* - Querying linked accounts
|
|
18
|
+
*
|
|
19
|
+
* **Note:** For OAuth authentication flows (login/signup), use `SocialRedirectHandler`
|
|
20
|
+
* or the frontend SDK's `loginWithSocial()` method.
|
|
19
21
|
*
|
|
20
22
|
* **Optional Feature:** Only available when social auth provider modules are imported.
|
|
21
23
|
*
|
|
@@ -31,8 +33,8 @@ import { GetSocialAuthUrlDTO, GetSocialAuthUrlResponseDTO, HandleSocialCallbackD
|
|
|
31
33
|
* // Then inject and use
|
|
32
34
|
* constructor(private socialAuthService: SocialAuthService) {}
|
|
33
35
|
*
|
|
34
|
-
* const
|
|
35
|
-
* const
|
|
36
|
+
* const result = await this.socialAuthService.linkSocialAccount({ userId, provider, code, state });
|
|
37
|
+
* const accounts = await this.socialAuthService.getLinkedAccounts({ userId });
|
|
36
38
|
* ```
|
|
37
39
|
*/
|
|
38
40
|
export declare class SocialAuthService {
|
|
@@ -43,47 +45,6 @@ export declare class SocialAuthService {
|
|
|
43
45
|
private readonly logger;
|
|
44
46
|
private readonly auditService?;
|
|
45
47
|
constructor(providerRegistry: SocialProviderRegistry, userRepository: Repository<BaseUser>, socialAccountRepository: Repository<BaseSocialAccount>, authService: AuthService, logger: NAuthLogger, auditService?: AuthAuditService | undefined);
|
|
46
|
-
/**
|
|
47
|
-
* Get social authentication URL
|
|
48
|
-
*
|
|
49
|
-
* Generates OAuth authorization URL for the specified provider.
|
|
50
|
-
* This is the first step in the OAuth flow - redirect user to this URL.
|
|
51
|
-
*
|
|
52
|
-
* @param dto - Request DTO containing provider and optional state
|
|
53
|
-
* @returns Response DTO with OAuth authorization URL
|
|
54
|
-
* @throws {NAuthException} SOCIAL_CONFIG_MISSING if provider not registered or configured
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* const dto = { provider: 'google', state: 'csrf-token-123' };
|
|
59
|
-
* const { url } = await socialAuthService.getSocialAuthUrl(dto);
|
|
60
|
-
* // Redirect user to url
|
|
61
|
-
* res.redirect(url);
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
getSocialAuthUrl(dto: GetSocialAuthUrlDTO): Promise<GetSocialAuthUrlResponseDTO>;
|
|
65
|
-
/**
|
|
66
|
-
* Handle social authentication callback
|
|
67
|
-
*
|
|
68
|
-
* Processes OAuth callback and authenticates user (login or signup).
|
|
69
|
-
* This is called after the user is redirected back from the OAuth provider.
|
|
70
|
-
*
|
|
71
|
-
* @param dto - Request DTO containing provider, code, and state
|
|
72
|
-
* @returns Auth response (tokens or challenge if MFA/verification required)
|
|
73
|
-
* @throws {NAuthException} Various auth errors (SOCIAL_AUTH_FAILED, etc.)
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* const dto = {
|
|
78
|
-
* provider: 'google',
|
|
79
|
-
* code: req.query.code,
|
|
80
|
-
* state: req.query.state
|
|
81
|
-
* };
|
|
82
|
-
* const result = await socialAuthService.handleSocialCallback(dto);
|
|
83
|
-
* // Returns tokens or challenge
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
handleSocialCallback(dto: HandleSocialCallbackDTO): Promise<AuthResponseDTO>;
|
|
87
48
|
/**
|
|
88
49
|
* Link social account to existing authenticated user
|
|
89
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social-auth.service.d.ts","sourceRoot":"","sources":["../../src/services/social-auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAS,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,wB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,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB3D"}
|
|
@@ -10,12 +10,15 @@ const dto_validator_1 = require("../utils/dto-validator");
|
|
|
10
10
|
/**
|
|
11
11
|
* Social Auth Service
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Service for managing social authentication accounts and their relationships.
|
|
14
14
|
* This service provides:
|
|
15
|
-
* - OAuth authentication flows (login/signup via social providers)
|
|
16
15
|
* - Social account linking/unlinking
|
|
17
16
|
* - Account management for social users
|
|
18
17
|
* - Password management for social-only users
|
|
18
|
+
* - Querying linked accounts
|
|
19
|
+
*
|
|
20
|
+
* **Note:** For OAuth authentication flows (login/signup), use `SocialRedirectHandler`
|
|
21
|
+
* or the frontend SDK's `loginWithSocial()` method.
|
|
19
22
|
*
|
|
20
23
|
* **Optional Feature:** Only available when social auth provider modules are imported.
|
|
21
24
|
*
|
|
@@ -31,8 +34,8 @@ const dto_validator_1 = require("../utils/dto-validator");
|
|
|
31
34
|
* // Then inject and use
|
|
32
35
|
* constructor(private socialAuthService: SocialAuthService) {}
|
|
33
36
|
*
|
|
34
|
-
* const
|
|
35
|
-
* const
|
|
37
|
+
* const result = await this.socialAuthService.linkSocialAccount({ userId, provider, code, state });
|
|
38
|
+
* const accounts = await this.socialAuthService.getLinkedAccounts({ userId });
|
|
36
39
|
* ```
|
|
37
40
|
*/
|
|
38
41
|
class SocialAuthService {
|
|
@@ -53,58 +56,6 @@ class SocialAuthService {
|
|
|
53
56
|
// ============================================================================
|
|
54
57
|
// Social Authentication Methods
|
|
55
58
|
// ============================================================================
|
|
56
|
-
/**
|
|
57
|
-
* Get social authentication URL
|
|
58
|
-
*
|
|
59
|
-
* Generates OAuth authorization URL for the specified provider.
|
|
60
|
-
* This is the first step in the OAuth flow - redirect user to this URL.
|
|
61
|
-
*
|
|
62
|
-
* @param dto - Request DTO containing provider and optional state
|
|
63
|
-
* @returns Response DTO with OAuth authorization URL
|
|
64
|
-
* @throws {NAuthException} SOCIAL_CONFIG_MISSING if provider not registered or configured
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* const dto = { provider: 'google', state: 'csrf-token-123' };
|
|
69
|
-
* const { url } = await socialAuthService.getSocialAuthUrl(dto);
|
|
70
|
-
* // Redirect user to url
|
|
71
|
-
* res.redirect(url);
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
async getSocialAuthUrl(dto) {
|
|
75
|
-
dto = await (0, dto_validator_1.ensureValidatedDto)(social_auth_dto_1.GetSocialAuthUrlDTO, dto);
|
|
76
|
-
const { provider, state } = dto;
|
|
77
|
-
const providerInstance = this.providerRegistry.getProvider(provider);
|
|
78
|
-
const url = await providerInstance.getAuthUrl(state);
|
|
79
|
-
return { url };
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Handle social authentication callback
|
|
83
|
-
*
|
|
84
|
-
* Processes OAuth callback and authenticates user (login or signup).
|
|
85
|
-
* This is called after the user is redirected back from the OAuth provider.
|
|
86
|
-
*
|
|
87
|
-
* @param dto - Request DTO containing provider, code, and state
|
|
88
|
-
* @returns Auth response (tokens or challenge if MFA/verification required)
|
|
89
|
-
* @throws {NAuthException} Various auth errors (SOCIAL_AUTH_FAILED, etc.)
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```typescript
|
|
93
|
-
* const dto = {
|
|
94
|
-
* provider: 'google',
|
|
95
|
-
* code: req.query.code,
|
|
96
|
-
* state: req.query.state
|
|
97
|
-
* };
|
|
98
|
-
* const result = await socialAuthService.handleSocialCallback(dto);
|
|
99
|
-
* // Returns tokens or challenge
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
async handleSocialCallback(dto) {
|
|
103
|
-
dto = await (0, dto_validator_1.ensureValidatedDto)(social_auth_dto_1.HandleSocialCallbackDTO, dto);
|
|
104
|
-
const { provider, code, state } = dto;
|
|
105
|
-
const providerInstance = this.providerRegistry.getProvider(provider);
|
|
106
|
-
return await providerInstance.handleCallback(code, state);
|
|
107
|
-
}
|
|
108
59
|
/**
|
|
109
60
|
* Link social account to existing authenticated user
|
|
110
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social-auth.service.js","sourceRoot":"","sources":["../../src/services/social-auth.service.ts"],"names":[],"mappings":";;;AAKA,oFAAyE;AACzE,mEAA+D;AAC/D,gEAA0D;AAE1D,oFAA8E;
|
|
1
|
+
{"version":3,"file":"social-auth.service.js","sourceRoot":"","sources":["../../src/services/social-auth.service.ts"],"names":[],"mappings":";;;AAKA,oFAAyE;AACzE,mEAA+D;AAC/D,gEAA0D;AAE1D,oFAA8E;AAE9E,4DAWgC;AAChC,0DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,iBAAiB;IAET;IACA;IACA;IACA;IACA;IACA;IANnB,YACmB,gBAAwC,EACxC,cAAoC,EACpC,uBAAsD,EACtD,WAAwB,EACxB,MAAmB,EACnB,YAA+B;QAL/B,qBAAgB,GAAhB,gBAAgB,CAAwB;QACxC,mBAAc,GAAd,cAAc,CAAsB;QACpC,4BAAuB,GAAvB,uBAAuB,CAA+B;QACtD,gBAAW,GAAX,WAAW,CAAa;QACxB,WAAM,GAAN,MAAM,CAAa;QACnB,iBAAY,GAAZ,YAAY,CAAmB;IAC/C,CAAC;IAEJ,+EAA+E;IAC/E,gCAAgC;IAChC,+EAA+E;IAE/E;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,iBAAiB,CAAC,GAAyB;QAC/C,GAAG,GAAG,MAAM,IAAA,kCAAkB,EAAC,sCAAoB,EAAE,GAAG,CAAC,CAAC;QAC1D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;QAC9C,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACrE,MAAM,MAAM,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