mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor(connector): connector constructor (#926)
This commit is contained in:
parent
a3a7c52a91
commit
27d81face1
11 changed files with 11 additions and 55 deletions
|
@ -45,13 +45,9 @@ export type { AlipayNativeConfig } from './types';
|
|||
export class AlipayNativeConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public getConfig: GetConnectorConfig<AlipayNativeConfig>;
|
||||
|
||||
private readonly signingPamameters: SigningPamameters = signingPamameters;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<AlipayNativeConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<AlipayNativeConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = alipayNativeConfigGuard.safeParse(config);
|
||||
|
|
|
@ -39,13 +39,9 @@ export type { AlipayConfig } from './types';
|
|||
export class AlipayConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public getConfig: GetConnectorConfig<AlipayConfig>;
|
||||
|
||||
private readonly signingPamameters: SigningPamameters = signingPamameters;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<AlipayConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<AlipayConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = alipayConfigGuard.safeParse(config);
|
||||
|
|
|
@ -17,11 +17,7 @@ import { SendEmailResponse, AliyunDmConfig, aliyunDmConfigGuard } from './types'
|
|||
export class AliyunDmConnector implements EmailConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public readonly getConfig: GetConnectorConfig<AliyunDmConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<AliyunDmConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<AliyunDmConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = aliyunDmConfigGuard.safeParse(config);
|
||||
|
|
|
@ -17,11 +17,7 @@ import { aliyunSmsConfigGuard, AliyunSmsConfig, SendSmsResponse } from './types'
|
|||
export class AliyunSmsConnector implements SmsConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public readonly getConfig: GetConnectorConfig<AliyunSmsConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<AliyunSmsConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<AliyunSmsConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = aliyunSmsConfigGuard.safeParse(config);
|
||||
|
|
|
@ -35,11 +35,7 @@ import {
|
|||
export class FacebookConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public readonly getConfig: GetConnectorConfig<FacebookConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<FacebookConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<FacebookConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = facebookConfigGuard.safeParse(config);
|
||||
|
|
|
@ -25,11 +25,7 @@ import { githubConfigGuard, AccessTokenResponse, GithubConfig, UserInfoResponse
|
|||
export class GithubConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public readonly getConfig: GetConnectorConfig<GithubConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<GithubConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<GithubConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = githubConfigGuard.safeParse(config);
|
||||
|
|
|
@ -29,11 +29,7 @@ import { googleConfigGuard, AccessTokenResponse, GoogleConfig, UserInfoResponse
|
|||
export class GoogleConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public readonly getConfig: GetConnectorConfig<GoogleConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<GoogleConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<GoogleConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = googleConfigGuard.safeParse(config);
|
||||
|
|
|
@ -24,11 +24,7 @@ import {
|
|||
export class SendGridMailConnector implements EmailConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public readonly getConfig: GetConnectorConfig<SendGridMailConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<SendGridMailConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<SendGridMailConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = sendGridMailConfigGuard.safeParse(config);
|
||||
|
|
|
@ -16,11 +16,7 @@ import { twilioSmsConfigGuard, SendSmsResponse, TwilioSmsConfig, PublicParameter
|
|||
export class TwilioSmsConnector implements SmsConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public readonly getConfig: GetConnectorConfig<TwilioSmsConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<TwilioSmsConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<TwilioSmsConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = twilioSmsConfigGuard.safeParse(config);
|
||||
|
|
|
@ -37,11 +37,7 @@ import {
|
|||
export class WeChatNativeConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public getConfig: GetConnectorConfig<WeChatNativeConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<WeChatNativeConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<WeChatNativeConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = weChatNativeConfigGuard.safeParse(config);
|
||||
|
|
|
@ -33,11 +33,7 @@ import { weChatConfigGuard, AccessTokenResponse, UserInfoResponse, WeChatConfig
|
|||
export class WeChatConnector implements SocialConnector {
|
||||
public metadata: ConnectorMetadata = defaultMetadata;
|
||||
|
||||
public getConfig: GetConnectorConfig<WeChatConfig>;
|
||||
|
||||
constructor(getConnectorConfig: GetConnectorConfig<WeChatConfig>) {
|
||||
this.getConfig = getConnectorConfig;
|
||||
}
|
||||
constructor(public readonly getConfig: GetConnectorConfig<WeChatConfig>) {}
|
||||
|
||||
public validateConfig: ValidateConfig = async (config: unknown) => {
|
||||
const result = weChatConfigGuard.safeParse(config);
|
||||
|
|
Loading…
Reference in a new issue