0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

chore(core): fix typos (#303)

* chore(core): fix typos in routes/session.ts

* chore(core): fix typos in utils/password.ts

* chore(core): fix Connector typos

* chore(core): fix typos in connectors/utilities/aliyun.ts

* chore(core): fix 'custom' typos in database/update-where.test.ts

* chore(core): fix typos in middleware/koa-oidc-error-handler.ts
This commit is contained in:
IceHe.xyz 2022-03-02 12:24:07 +08:00 committed by GitHub
parent 572d5ad6a5
commit c5a9eef852
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 19 deletions

View file

@ -4,7 +4,7 @@ import { findConnectorById, hasConnector, insertConnector } from '@/queries/conn
import * as AliyunDM from './aliyun-dm';
import * as AliyunSMS from './aliyun-sms';
import * as GitHub from './github';
import { ConnectorInstance, ConnectorType, IConnector, SocialConectorInstance } from './types';
import { ConnectorInstance, ConnectorType, IConnector, SocialConnectorInstance } from './types';
const allConnectors: IConnector[] = [AliyunDM, AliyunSMS, GitHub];
@ -36,13 +36,13 @@ export const getConnectorInstanceById = async (id: string): Promise<ConnectorIns
const isSocialConnectorInstance = (
connector: ConnectorInstance
): connector is SocialConectorInstance => {
): connector is SocialConnectorInstance => {
return connector.metadata.type === ConnectorType.Social;
};
export const getSocialConnectorInstanceById = async (
id: string
): Promise<SocialConectorInstance> => {
): Promise<SocialConnectorInstance> => {
const connector = await getConnectorInstanceById(id);
if (!isSocialConnectorInstance(connector)) {

View file

@ -16,11 +16,11 @@ export interface ConnectorMetadata {
}
// The name `Connector` is used for database, use `ConnectorInstance` to avoid confusing.
export type IConnector = SmsConnector | EmailConector | SocialConector;
export type IConnector = SmsConnector | EmailConnector | SocialConnector;
export type ConnectorInstance =
| SmsConnectorInstance
| EmailConectorInstance
| SocialConectorInstance;
| EmailConnectorInstance
| SocialConnectorInstance;
export interface BaseConnector {
metadata: ConnectorMetadata;
@ -33,19 +33,19 @@ export interface SmsConnector extends BaseConnector {
export type SmsConnectorInstance = SmsConnector & { connector: Connector };
export interface EmailConector extends BaseConnector {
export interface EmailConnector extends BaseConnector {
sendMessage: EmailSendMessageFunction;
}
export type EmailConectorInstance = EmailConector & { connector: Connector };
export type EmailConnectorInstance = EmailConnector & { connector: Connector };
export interface SocialConector extends BaseConnector {
export interface SocialConnector extends BaseConnector {
getAuthorizationUri: GetAuthorizationUri;
getAccessToken: GetAccessToken;
getUserInfo: GetUserInfo;
}
export type SocialConectorInstance = SocialConector & { connector: Connector };
export type SocialConnectorInstance = SocialConnector & { connector: Connector };
type EmailMessageTypes = {
SignIn: {

View file

@ -3,7 +3,7 @@ import { createHmac } from 'crypto';
import { has } from '@silverhand/essentials';
import got from 'got';
// Aliyun has special excape rules.
// Aliyun has special escape rules.
// https://help.aliyun.com/document_detail/29442.html
const escaper = (string_: string) =>
encodeURIComponent(string_)

View file

@ -38,9 +38,9 @@ describe('buildUpdateWhere()', () => {
it('return query with jsonb partial update if input data type is jsonb', async () => {
const pool = createTestPool(
'update "applications"\nset\n"custom_client_metadata"=\ncoalesce("custom_client_metadata",\'{}\'::jsonb)|| $1\nwhere "id"=$2\nreturning *',
(_, [costumClientMetadata, id]) => ({
(_, [customClientMetadata, id]) => ({
id: String(id),
costumClientMetadata: String(costumClientMetadata),
customClientMetadata: String(customClientMetadata),
})
);
const updateWhere = buildUpdateWhere(pool, Applications, true);
@ -50,7 +50,7 @@ describe('buildUpdateWhere()', () => {
set: { customClientMetadata: { idTokenTtl: 3600 } },
where: { id: 'foo' },
})
).resolves.toStrictEqual({ id: 'foo', costumClientMetadata: '{"idTokenTtl":3600}' });
).resolves.toStrictEqual({ id: 'foo', customClientMetadata: '{"idTokenTtl":3600}' });
});
it('throws an error when `undefined` found in values', async () => {

View file

@ -2,7 +2,7 @@ import { Passcode, PasscodeType } from '@logto/schemas';
import { customAlphabet, nanoid } from 'nanoid';
import { getConnectorInstanceByType } from '@/connectors';
import { ConnectorType, EmailConectorInstance, SmsConnectorInstance } from '@/connectors/types';
import { ConnectorType, EmailConnectorInstance, SmsConnectorInstance } from '@/connectors/types';
import RequestError from '@/errors/RequestError';
import {
deletePasscodesByIds,
@ -44,7 +44,7 @@ export const sendPasscode = async (passcode: Passcode) => {
}
const connector = passcode.email
? await getConnectorInstanceByType<EmailConectorInstance>(ConnectorType.Email)
? await getConnectorInstanceByType<EmailConnectorInstance>(ConnectorType.Email)
: await getConnectorInstanceByType<SmsConnectorInstance>(ConnectorType.SMS);
return connector.sendMessage(emailOrPhone, passcode.type, {

View file

@ -6,7 +6,7 @@ import { errors } from 'oidc-provider';
import RequestError from '@/errors/RequestError';
/**
* OIDC Provider Error Definiation: https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/errors.js
* OIDC Provider Error Definition: https://github.com/panva/node-oidc-provider/blob/main/lib/helpers/errors.js
*/
export default function koaOIDCErrorHandler<StateT, ContextT>(): Middleware<StateT, ContextT> {

View file

@ -448,7 +448,7 @@ export default function sessionRoutes<T extends AnonymousRouter>(router: T, prov
const { connectorId } = ctx.guard.body;
const { result } = await provider.interactionDetails(ctx.req, ctx.res);
// User can not regsiter with social directly,
// User can not register with social directly,
// need to try to sign in with social first, then confirm to register and continue,
// so the result is expected to be exists.
assertThat(result, 'session.connector_session_not_found');

View file

@ -12,7 +12,7 @@ const peppers = string()
.parse(process.env.NODE_ENV === 'test' ? [nanoid()] : JSON.parse(assertEnv('PASSWORD_PEPPERS')));
const iterationCount = number()
.min(100)
.parse(process.env.NODE_ENV === 'test' ? 1000 : Number(assertEnv('PASSWORD_INTERATION_COUNT')));
.parse(process.env.NODE_ENV === 'test' ? 1000 : Number(assertEnv('PASSWORD_ITERATION_COUNT')));
export const encryptPassword = (
id: string,