chore: Update modules providers configuration with 'identifier' and 'PROVIDER' (#9636)
* chore: Update modules providers configuration with 'identifier' and 'PROVIDER' * update check * fix tests * type * normalize auth provider * emailpass * providers --------- Co-authored-by: Carlos R. L. Rodrigues <rodrigolr@gmail.com> Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
902ac12f73
commit
876d8072e7
@@ -69,22 +69,32 @@ export abstract class AbstractAuthModuleProvider implements IAuthProvider {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
private static PROVIDER: string
|
||||
static identifier: string
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
private static DISPLAY_NAME: string
|
||||
static DISPLAY_NAME: string
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected readonly container_: any
|
||||
|
||||
/**
|
||||
* @deprecated Use `identifier` instead.
|
||||
* @ignore
|
||||
*/
|
||||
public get provider() {
|
||||
return (this.constructor as typeof AbstractAuthModuleProvider).PROVIDER
|
||||
return (this.constructor as typeof AbstractAuthModuleProvider).identifier
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public get identifier() {
|
||||
return (this.constructor as typeof AbstractAuthModuleProvider).identifier
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -98,21 +108,6 @@ export abstract class AbstractAuthModuleProvider implements IAuthProvider {
|
||||
*/
|
||||
static validateOptions(options: Record<any, any>): void | never {}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* @privateRemarks
|
||||
* Documenting the constructor in the class's TSDocs as it's difficult to relay
|
||||
* the necessary information with this constructor's signature.
|
||||
*/
|
||||
protected constructor({}, config: { provider: string; displayName: string }) {
|
||||
this.container_ = arguments[0]
|
||||
;(this.constructor as typeof AbstractAuthModuleProvider).PROVIDER ??=
|
||||
config.provider
|
||||
;(this.constructor as typeof AbstractAuthModuleProvider).DISPLAY_NAME ??=
|
||||
config.displayName
|
||||
}
|
||||
|
||||
/**
|
||||
* This method authenticates the user.
|
||||
*
|
||||
|
||||
@@ -19,3 +19,4 @@ export * from "./module-provider"
|
||||
export * from "./query-context"
|
||||
export * from "./types/links-config"
|
||||
export * from "./types/medusa-service"
|
||||
export * from "./module-provider-registration-key"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
export const moduleProviderRegistrationKeyPrefix = "__providers__"
|
||||
|
||||
/**
|
||||
* Return the key used to register a module provider in the container
|
||||
* @param {string} moduleKey
|
||||
* @return {string}
|
||||
*/
|
||||
export function getProviderRegistrationKey({
|
||||
providerId,
|
||||
providerIdentifier,
|
||||
}: {
|
||||
providerId?: string
|
||||
providerIdentifier?: string
|
||||
}): string {
|
||||
const registrationIdentifier = `${
|
||||
providerIdentifier ? providerIdentifier : ""
|
||||
}${providerId ? `${providerIdentifier ? "_" : ""}${providerId}` : ""}`
|
||||
return moduleProviderRegistrationKeyPrefix + registrationIdentifier
|
||||
}
|
||||
Reference in New Issue
Block a user