mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor(connector): update connector-schemas
This commit is contained in:
parent
44a9dcc9ad
commit
56bf856289
2 changed files with 13 additions and 24 deletions
|
@ -15,10 +15,10 @@ export class ConnectorError extends Error {
|
||||||
public code: ConnectorErrorCodes;
|
public code: ConnectorErrorCodes;
|
||||||
public data: unknown;
|
public data: unknown;
|
||||||
|
|
||||||
constructor(code: ConnectorErrorCodes, data?: unknown) {
|
constructor(code: ConnectorErrorCodes, payload?: { message?: string; data?: unknown }) {
|
||||||
const message = typeof data === 'string' ? data : 'Connector error occurred.';
|
const { message, data } = payload ?? {};
|
||||||
super(message);
|
super(message ?? 'Connector error occurred.');
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.data = typeof data === 'string' ? { message: data } : data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ export enum ConnectorPlatform {
|
||||||
Web = 'Web',
|
Web = 'Web',
|
||||||
}
|
}
|
||||||
|
|
||||||
type i18nPhrases = { [Language.English]: string } & {
|
type I18nPhrases = { [Language.English]: string } & {
|
||||||
[key in Exclude<Language, Language.English>]?: string;
|
[key in Exclude<Language, Language.English>]?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,15 +24,20 @@ export type ConnectorMetadata = {
|
||||||
target: string;
|
target: string;
|
||||||
type: ConnectorType;
|
type: ConnectorType;
|
||||||
platform: Nullable<ConnectorPlatform>;
|
platform: Nullable<ConnectorPlatform>;
|
||||||
name: i18nPhrases;
|
name: I18nPhrases;
|
||||||
logo: string;
|
logo: string;
|
||||||
logoDark: Nullable<string>;
|
logoDark: Nullable<string>;
|
||||||
description: i18nPhrases;
|
description: I18nPhrases;
|
||||||
readme: string;
|
readme: string;
|
||||||
configTemplate: string;
|
configTemplate: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type MessageTypes = 'SignIn' | 'Register' | 'ForgotPassword' | 'Test';
|
export enum MessageTypes {
|
||||||
|
SignIn = 'SignIn',
|
||||||
|
Register = 'Register',
|
||||||
|
ForgotPassword = 'ForgotPassword',
|
||||||
|
Test = 'Test',
|
||||||
|
}
|
||||||
|
|
||||||
export type SendMessageFunction = (
|
export type SendMessageFunction = (
|
||||||
data: { to: string; type: MessageTypes; payload: { code: string } },
|
data: { to: string; type: MessageTypes; payload: { code: string } },
|
||||||
|
@ -65,20 +70,4 @@ export class LogtoConnector<T> {
|
||||||
public validateConfig: ValidateConfig<T> = () => {
|
public validateConfig: ValidateConfig<T> = () => {
|
||||||
throw new ConnectorError(ConnectorErrorCodes.NotImplemented);
|
throw new ConnectorError(ConnectorErrorCodes.NotImplemented);
|
||||||
};
|
};
|
||||||
|
|
||||||
public getAuthorizationUri: GetAuthorizationUri = async () => {
|
|
||||||
throw new ConnectorError(ConnectorErrorCodes.NotImplemented);
|
|
||||||
};
|
|
||||||
|
|
||||||
public getUserInfo: GetUserInfo = async () => {
|
|
||||||
throw new ConnectorError(ConnectorErrorCodes.NotImplemented);
|
|
||||||
};
|
|
||||||
|
|
||||||
public sendMessage: SendMessageFunction = async () => {
|
|
||||||
throw new ConnectorError(ConnectorErrorCodes.NotImplemented);
|
|
||||||
};
|
|
||||||
|
|
||||||
protected authResponseParser: AuthResponseParser = async () => {
|
|
||||||
throw new ConnectorError(ConnectorErrorCodes.NotImplemented);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue