@daffodil/auth 0.94.1 → 0.95.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 (34) hide show
  1. package/fesm2022/daffodil-auth-driver-in-memory.mjs +356 -249
  2. package/fesm2022/daffodil-auth-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-auth-driver-magento-2.4.7.mjs +459 -0
  4. package/fesm2022/daffodil-auth-driver-magento-2.4.7.mjs.map +1 -0
  5. package/fesm2022/daffodil-auth-driver-magento-auto.mjs +7 -0
  6. package/fesm2022/daffodil-auth-driver-magento-auto.mjs.map +1 -0
  7. package/fesm2022/daffodil-auth-driver-testing.mjs +220 -126
  8. package/fesm2022/daffodil-auth-driver-testing.mjs.map +1 -1
  9. package/fesm2022/daffodil-auth-driver.mjs +99 -126
  10. package/fesm2022/daffodil-auth-driver.mjs.map +1 -1
  11. package/fesm2022/daffodil-auth-routing.mjs +392 -257
  12. package/fesm2022/daffodil-auth-routing.mjs.map +1 -1
  13. package/fesm2022/daffodil-auth-state-testing.mjs +209 -106
  14. package/fesm2022/daffodil-auth-state-testing.mjs.map +1 -1
  15. package/fesm2022/daffodil-auth-state.mjs +867 -852
  16. package/fesm2022/daffodil-auth-state.mjs.map +1 -1
  17. package/fesm2022/daffodil-auth-testing.mjs +132 -76
  18. package/fesm2022/daffodil-auth-testing.mjs.map +1 -1
  19. package/fesm2022/daffodil-auth.mjs +65 -57
  20. package/fesm2022/daffodil-auth.mjs.map +1 -1
  21. package/package.json +1 -1
  22. package/types/daffodil-auth-driver-in-memory.d.ts +62 -62
  23. package/types/daffodil-auth-driver-magento-2.4.7.d.ts +119 -0
  24. package/types/daffodil-auth-driver-magento-auto.d.ts +1 -0
  25. package/types/daffodil-auth-driver-testing.d.ts +37 -36
  26. package/types/daffodil-auth-driver.d.ts +93 -112
  27. package/types/daffodil-auth-routing.d.ts +100 -104
  28. package/types/daffodil-auth-state-testing.d.ts +44 -43
  29. package/types/daffodil-auth-state.d.ts +265 -306
  30. package/types/daffodil-auth-testing.d.ts +28 -33
  31. package/types/daffodil-auth.d.ts +51 -62
  32. package/fesm2022/daffodil-auth-driver-magento.mjs +0 -385
  33. package/fesm2022/daffodil-auth-driver-magento.mjs.map +0 -1
  34. package/types/daffodil-auth-driver-magento.d.ts +0 -135
@@ -1 +1 @@
1
- {"version":3,"file":"daffodil-auth-driver.mjs","sources":["../../../libs/auth/driver/src/interfaces/auth-service.interface.ts","../../../libs/auth/driver/src/interfaces/login-service.interface.ts","../../../libs/auth/driver/src/interfaces/register-service.interface.ts","../../../libs/auth/driver/src/interfaces/reset-password-service.interface.ts","../../../libs/auth/driver/src/errors/codes.enum.ts","../../../libs/auth/driver/src/errors/unauthorized.ts","../../../libs/auth/driver/src/errors/authentication-failed.ts","../../../libs/auth/driver/src/errors/registration-failed.ts","../../../libs/auth/driver/src/errors/invalid-api-response.ts","../../../libs/auth/driver/src/errors/map.ts","../../../libs/auth/driver/src/services/auth-check.service.ts","../../../libs/auth/driver/src/constants/unauthenticated-error-codes.ts","../../../libs/auth/driver/src/daffodil-auth-driver.ts"],"sourcesContent":["import { Observable } from 'rxjs';\n\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffAuthServiceInterface {\n /**\n * Checks the validity of an auth token.\n */\n check(): Observable<void>;\n}\n\nexport const {\n token: DaffAuthDriver,\n /**\n * Provider function for {@link DaffAuthDriver}.\n */\n provider: provideDaffAuthDriver,\n} = createSingletonInjectionToken<DaffAuthServiceInterface>('DaffAuthDriver');\n","import { Observable } from 'rxjs';\n\nimport {\n DaffLoginInfo,\n DaffAuthToken,\n} from '@daffodil/auth';\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffLoginServiceInterface<\n TRequest extends DaffLoginInfo = DaffLoginInfo,\n TResponse extends DaffAuthToken = DaffAuthToken\n> {\n /**\n * Logs the user in.\n *\n * @returns An access token.\n */\n login(loginInfo: TRequest): Observable<TResponse>;\n\n /**\n * Logs the user out by revoking their access token.\n */\n logout(): Observable<void>;\n}\n\nexport const {\n token: DaffLoginDriver,\n /**\n * Provider function for {@link DaffLoginDriver}.\n */\n provider: provideDaffLoginDriver,\n} = createSingletonInjectionToken<DaffLoginServiceInterface>('DaffLoginDriver');\n","import { Observable } from 'rxjs';\n\nimport { DaffAccountRegistration } from '@daffodil/auth';\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffRegisterServiceInterface<\n TRequest extends DaffAccountRegistration = DaffAccountRegistration,\n> {\n\n /**\n * Registers an account for the specified customer and logs the customer in.\n *\n * @param registration The account registration info.\n * @return The authentication token.\n */\n register(registration: TRequest): Observable<string>;\n\n /**\n * Registers an account for the specified customer but does not log the customer in.\n *\n * @param registration The account registration info.\n */\n registerOnly(registration: TRequest): Observable<void>;\n}\n\nexport const {\n token: DaffRegisterDriver,\n /**\n * Provider function for {@link DaffRegisterDriver}.\n */\n provider: provideDaffRegisterDriver,\n} = createSingletonInjectionToken<DaffRegisterServiceInterface>('DaffRegisterDriver');\n","import { Observable } from 'rxjs';\n\nimport { DaffAuthResetPasswordInfo } from '@daffodil/auth';\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffResetPasswordServiceInterface<\n T extends DaffAuthResetPasswordInfo = DaffAuthResetPasswordInfo,\n> {\n\n /**\n * Resets password for the specified customer and logs in.\n */\n resetPassword(info: T): Observable<string>;\n\n /**\n * Resets password for the specified customer.\n */\n resetPasswordOnly(info: T): Observable<void>;\n\n /**\n * Send a password reset email to the specified email address.\n */\n sendResetEmail(email: string): Observable<void>;\n}\n\nexport const {\n token: DaffResetPasswordDriver,\n /**\n * Provider function for {@link DaffResetPasswordDriver}.\n */\n provider: provideDaffResetPasswordDriver,\n} = createSingletonInjectionToken<DaffResetPasswordServiceInterface>('DaffResetPasswordDriver');\n","export enum DaffAuthDriverErrorCodes {\n AUTHENTICATION_FAILED = 'DAFF_AUTH_AUTHENTICATION_FAILED',\n INVALID_API_RESPONSE = 'DAFF_AUTH_INVALID_API_RESPONSE',\n REGISTRATION_FAILED = 'DAFF_AUTH_REGISTRATION_FAILED',\n UNAUTHORIZED = 'DAFF_AUTH_UNAUTHORIZED',\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffUnauthorizedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.UNAUTHORIZED;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthenticationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\n/**\n * An error thrown when registration failed.\n */\nexport class DaffRegistrationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.REGISTRATION_FAILED;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthInvalidAPIResponseError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.INVALID_API_RESPONSE;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { DaffAuthenticationFailedError } from './authentication-failed';\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\nimport { DaffAuthInvalidAPIResponseError } from './invalid-api-response';\nimport { DaffRegistrationFailedError } from './registration-failed';\nimport { DaffUnauthorizedError } from './unauthorized';\n\n/**\n * A mapping from error codes to error class constructors.\n */\nexport const DaffAuthDriverErrorMap = {\n [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: DaffAuthenticationFailedError,\n [DaffAuthDriverErrorCodes.INVALID_API_RESPONSE]: DaffAuthInvalidAPIResponseError,\n [DaffAuthDriverErrorCodes.REGISTRATION_FAILED]: DaffRegistrationFailedError,\n [DaffAuthDriverErrorCodes.UNAUTHORIZED]: DaffUnauthorizedError,\n};\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n Observable,\n of,\n switchMap,\n throwError,\n} from 'rxjs';\n\nimport {\n DaffAuthStorageService,\n DaffAuthMissingTokenError,\n} from '@daffodil/auth';\n\nimport {\n DaffAuthDriver,\n DaffAuthServiceInterface,\n} from '../interfaces/public_api';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffAuthDriverTokenCheck {\n constructor(\n private storage: DaffAuthStorageService,\n @Inject(DaffAuthDriver) private driver: DaffAuthServiceInterface,\n ) {}\n\n /**\n * Checks if the auth token in storage is valid.\n * If there is not an auth token in storage, the driver is not called\n * and an error is immediately thrown.\n */\n check(): Observable<void> {\n return of(null).pipe(\n switchMap(() => {\n const token = this.storage.getAuthToken();\n\n if (!token) {\n return throwError(() => new DaffAuthMissingTokenError('There is not an auth token in storage'));\n }\n\n return this.driver.check();\n }),\n );\n }\n}\n","import { DaffAuthDriverErrorCodes } from '../errors/public_api';\n\n/**\n * The error codes that indicate that the user definitely should not be in an unauthenticated state\n * and if an auth token exists in storage, it is invalid.\n * These are contrasted to network failures and other sporadic and generic errors that aren't\n * a guarantee of the token's invalidity.\n */\nexport const DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES = {\n [DaffAuthDriverErrorCodes.UNAUTHORIZED]: true,\n [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: true,\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAWO,MAAM,EACX,KAAK,EAAE,cAAc;AACrB;;AAEG;AACH,QAAQ,EAAE,qBAAqB,GAChC,GAAG,6BAA6B,CAA2B,gBAAgB;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wBAAwB,wDAGzB,cAAc,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAHb,uBAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,wBAAwB,cAFvB,MAAM,EAAA,CAAA,CAAA;;2FAEP,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBAHpC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;0BAII,MAAM;2BAAC,cAAc;;;ACzB1B;;;;;AAKG;AACI,MAAM,qCAAqC,GAAG;AACnD,IAAA,CAAC,wBAAwB,CAAC,YAAY,GAAG,IAAI;AAC7C,IAAA,CAAC,wBAAwB,CAAC,qBAAqB,GAAG,IAAI;;;ACVxD;;AAEG;;;;"}
1
+ {"version":3,"file":"daffodil-auth-driver.mjs","names":[],"sources":["../../../libs/auth/driver/src/interfaces/auth-service.interface.ts","../../../libs/auth/driver/src/interfaces/login-service.interface.ts","../../../libs/auth/driver/src/interfaces/register-service.interface.ts","../../../libs/auth/driver/src/interfaces/reset-password-service.interface.ts","../../../libs/auth/driver/src/errors/codes.enum.ts","../../../libs/auth/driver/src/errors/unauthorized.ts","../../../libs/auth/driver/src/errors/authentication-failed.ts","../../../libs/auth/driver/src/errors/registration-failed.ts","../../../libs/auth/driver/src/errors/invalid-api-response.ts","../../../libs/auth/driver/src/errors/map.ts","../../../libs/auth/driver/src/services/auth-check.service.ts","../../../libs/auth/driver/src/constants/unauthenticated-error-codes.ts"],"sourcesContent":["import { Observable } from 'rxjs';\n\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffAuthServiceInterface {\n /**\n * Checks the validity of an auth token.\n */\n check(): Observable<void>;\n}\n\nexport const {\n token: DaffAuthDriver,\n /**\n * Provider function for {@link DaffAuthDriver}.\n */\n provider: provideDaffAuthDriver,\n} = createSingletonInjectionToken<DaffAuthServiceInterface>('DaffAuthDriver');\n","import { Observable } from 'rxjs';\n\nimport {\n DaffLoginInfo,\n DaffAuthToken,\n} from '@daffodil/auth';\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffLoginServiceInterface<\n TRequest extends DaffLoginInfo = DaffLoginInfo,\n TResponse extends DaffAuthToken = DaffAuthToken\n> {\n /**\n * Logs the user in.\n *\n * @returns An access token.\n */\n login(loginInfo: TRequest): Observable<TResponse>;\n\n /**\n * Logs the user out by revoking their access token.\n */\n logout(): Observable<void>;\n}\n\nexport const {\n token: DaffLoginDriver,\n /**\n * Provider function for {@link DaffLoginDriver}.\n */\n provider: provideDaffLoginDriver,\n} = createSingletonInjectionToken<DaffLoginServiceInterface>('DaffLoginDriver');\n","import { Observable } from 'rxjs';\n\nimport { DaffAccountRegistration } from '@daffodil/auth';\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffRegisterServiceInterface<\n TRequest extends DaffAccountRegistration = DaffAccountRegistration,\n> {\n\n /**\n * Registers an account for the specified customer and logs the customer in.\n *\n * @param registration The account registration info.\n * @return The authentication token.\n */\n register(registration: TRequest): Observable<string>;\n\n /**\n * Registers an account for the specified customer but does not log the customer in.\n *\n * @param registration The account registration info.\n */\n registerOnly(registration: TRequest): Observable<void>;\n}\n\nexport const {\n token: DaffRegisterDriver,\n /**\n * Provider function for {@link DaffRegisterDriver}.\n */\n provider: provideDaffRegisterDriver,\n} = createSingletonInjectionToken<DaffRegisterServiceInterface>('DaffRegisterDriver');\n","import { Observable } from 'rxjs';\n\nimport { DaffAuthResetPasswordInfo } from '@daffodil/auth';\nimport { createSingletonInjectionToken } from '@daffodil/core';\n\nexport interface DaffResetPasswordServiceInterface<\n T extends DaffAuthResetPasswordInfo = DaffAuthResetPasswordInfo,\n> {\n\n /**\n * Resets password for the specified customer and logs in.\n */\n resetPassword(info: T): Observable<string>;\n\n /**\n * Resets password for the specified customer.\n */\n resetPasswordOnly(info: T): Observable<void>;\n\n /**\n * Send a password reset email to the specified email address.\n */\n sendResetEmail(email: string): Observable<void>;\n}\n\nexport const {\n token: DaffResetPasswordDriver,\n /**\n * Provider function for {@link DaffResetPasswordDriver}.\n */\n provider: provideDaffResetPasswordDriver,\n} = createSingletonInjectionToken<DaffResetPasswordServiceInterface>('DaffResetPasswordDriver');\n","export enum DaffAuthDriverErrorCodes {\n AUTHENTICATION_FAILED = 'DAFF_AUTH_AUTHENTICATION_FAILED',\n INVALID_API_RESPONSE = 'DAFF_AUTH_INVALID_API_RESPONSE',\n REGISTRATION_FAILED = 'DAFF_AUTH_REGISTRATION_FAILED',\n UNAUTHORIZED = 'DAFF_AUTH_UNAUTHORIZED',\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffUnauthorizedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.UNAUTHORIZED;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthenticationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\n/**\n * An error thrown when registration failed.\n */\nexport class DaffRegistrationFailedError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.REGISTRATION_FAILED;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import {\n DaffError,\n DaffInheritableError,\n} from '@daffodil/core';\n\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\n\nexport class DaffAuthInvalidAPIResponseError extends DaffInheritableError implements DaffError {\n public readonly code: string = DaffAuthDriverErrorCodes.INVALID_API_RESPONSE;\n\n constructor(public message: string) {\n super(message);\n }\n}\n","import { DaffAuthenticationFailedError } from './authentication-failed';\nimport { DaffAuthDriverErrorCodes } from './codes.enum';\nimport { DaffAuthInvalidAPIResponseError } from './invalid-api-response';\nimport { DaffRegistrationFailedError } from './registration-failed';\nimport { DaffUnauthorizedError } from './unauthorized';\n\n/**\n * A mapping from error codes to error class constructors.\n */\nexport const DaffAuthDriverErrorMap = {\n [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: DaffAuthenticationFailedError,\n [DaffAuthDriverErrorCodes.INVALID_API_RESPONSE]: DaffAuthInvalidAPIResponseError,\n [DaffAuthDriverErrorCodes.REGISTRATION_FAILED]: DaffRegistrationFailedError,\n [DaffAuthDriverErrorCodes.UNAUTHORIZED]: DaffUnauthorizedError,\n};\n","import {\n Inject,\n Injectable,\n} from '@angular/core';\nimport {\n Observable,\n of,\n switchMap,\n throwError,\n} from 'rxjs';\n\nimport {\n DaffAuthStorageService,\n DaffAuthMissingTokenError,\n} from '@daffodil/auth';\n\nimport {\n DaffAuthDriver,\n DaffAuthServiceInterface,\n} from '../interfaces/public_api';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffAuthDriverTokenCheck {\n constructor(\n private storage: DaffAuthStorageService,\n @Inject(DaffAuthDriver) private driver: DaffAuthServiceInterface,\n ) {}\n\n /**\n * Checks if the auth token in storage is valid.\n * If there is not an auth token in storage, the driver is not called\n * and an error is immediately thrown.\n */\n check(): Observable<void> {\n return of(null).pipe(\n switchMap(() => {\n const token = this.storage.getAuthToken();\n\n if (!token) {\n return throwError(() => new DaffAuthMissingTokenError('There is not an auth token in storage'));\n }\n\n return this.driver.check();\n }),\n );\n }\n}\n","import { DaffAuthDriverErrorCodes } from '../errors/public_api';\n\n/**\n * The error codes that indicate that the user definitely should not be in an unauthenticated state\n * and if an auth token exists in storage, it is invalid.\n * These are contrasted to network failures and other sporadic and generic errors that aren't\n * a guarantee of the token's invalidity.\n */\nexport const DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES = {\n [DaffAuthDriverErrorCodes.UNAUTHORIZED]: true,\n [DaffAuthDriverErrorCodes.AUTHENTICATION_FAILED]: true,\n};\n"],"mappings":";;;;;;AAWA,MAAa,EACX,OAAO,gBAIP,UAAU,0BACR,8BAAwD,gBAAgB;ACQ5E,MAAa,EACX,OAAO,iBAIP,UAAU,2BACR,8BAAyD,iBAAiB;ACN9E,MAAa,EACX,OAAO,oBAIP,UAAU,8BACR,8BAA4D,oBAAoB;ACNpF,MAAa,EACX,OAAO,yBAIP,UAAU,mCACR,8BAAiE,yBAAyB;AC/B9F,IAAY;CAAZ,SAAY,0BAAwB;CAClC,yBAAA,2BAAA;CACA,yBAAA,0BAAA;CACA,yBAAA,yBAAA;CACA,yBAAA,kBAAA;AACF,EAAA,CALY,6BAAA,2BAAwB,CAAA,EAAA;ACOpC,IAAa,wBAAb,cAA2C,qBAAoB;CAG7D,YAAmB,SAAe;EAChC,MAAM,OAAO;EADI,KAAA,UAAA;EAFH,KAAA,OAAe,yBAAyB;CAIxD;AACD;ACND,IAAa,gCAAb,cAAmD,qBAAoB;CAGrE,YAAmB,SAAe;EAChC,MAAM,OAAO;EADI,KAAA,UAAA;EAFH,KAAA,OAAe,yBAAyB;CAIxD;AACD;ACHD,IAAa,8BAAb,cAAiD,qBAAoB;CAGnE,YAAmB,SAAe;EAChC,MAAM,OAAO;EADI,KAAA,UAAA;EAFH,KAAA,OAAe,yBAAyB;CAIxD;AACD;ACTD,IAAa,kCAAb,cAAqD,qBAAoB;CAGvE,YAAmB,SAAe;EAChC,MAAM,OAAO;EADI,KAAA,UAAA;EAFH,KAAA,OAAe,yBAAyB;CAIxD;AACD;ACJD,MAAa,yBAAyB;EACnC,yBAAyB,wBAAwB;EACjD,yBAAyB,uBAAuB;EAChD,yBAAyB,sBAAsB;EAC/C,yBAAyB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