Feat(auth): Rename authentication to auth (#6229)

**What**
- rename `authenticationModule` -> `authModule`
This commit is contained in:
Philip Korsholm
2024-01-29 10:19:30 +00:00
committed by GitHub
parent a41aad4bea
commit 512b041929
70 changed files with 245 additions and 147 deletions
@@ -0,0 +1,43 @@
import { AuthProviderScope, AuthenticationResponse } from "@medusajs/types"
import { MedusaError } from "../common"
export abstract class AbstractAuthModuleProvider {
public static PROVIDER: string
public static DISPLAY_NAME: string
protected readonly scopes_: Record<string, AuthProviderScope>
public get provider() {
return (this.constructor as Function & { PROVIDER: string }).PROVIDER
}
public get displayName() {
return (this.constructor as Function & { DISPLAY_NAME: string })
.DISPLAY_NAME
}
protected constructor({ scopes }) {
this.scopes_ = scopes
}
public validateScope(scope) {
if (!this.scopes_[scope]) {
throw new MedusaError(
MedusaError.Types.INVALID_ARGUMENT,
`Scope "${scope}" is not valid for provider ${this.provider}`
)
}
}
abstract authenticate(
data: Record<string, unknown>
): Promise<AuthenticationResponse>
public validateCallback(
data: Record<string, unknown>
): Promise<AuthenticationResponse> {
throw new Error(
`Callback authentication not implemented for provider ${this.provider}`
)
}
}
+1
View File
@@ -0,0 +1 @@
export * from "./abstract-auth-provider"