From c5a9eef8525e9a5945e6934b872d17ca1804107a Mon Sep 17 00:00:00 2001 From: "IceHe.xyz" Date: Wed, 2 Mar 2022 12:24:07 +0800 Subject: [PATCH] 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 --- packages/core/src/connectors/index.ts | 6 +++--- packages/core/src/connectors/types.ts | 14 +++++++------- packages/core/src/connectors/utilities/aliyun.ts | 2 +- packages/core/src/database/update-where.test.ts | 6 +++--- packages/core/src/lib/passcode.ts | 4 ++-- .../core/src/middleware/koa-oidc-error-handler.ts | 2 +- packages/core/src/routes/session.ts | 2 +- packages/core/src/utils/password.ts | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/core/src/connectors/index.ts b/packages/core/src/connectors/index.ts index acf67cbab..282fcb406 100644 --- a/packages/core/src/connectors/index.ts +++ b/packages/core/src/connectors/index.ts @@ -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 { +): connector is SocialConnectorInstance => { return connector.metadata.type === ConnectorType.Social; }; export const getSocialConnectorInstanceById = async ( id: string -): Promise => { +): Promise => { const connector = await getConnectorInstanceById(id); if (!isSocialConnectorInstance(connector)) { diff --git a/packages/core/src/connectors/types.ts b/packages/core/src/connectors/types.ts index 83df65523..c74a74b63 100644 --- a/packages/core/src/connectors/types.ts +++ b/packages/core/src/connectors/types.ts @@ -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: { diff --git a/packages/core/src/connectors/utilities/aliyun.ts b/packages/core/src/connectors/utilities/aliyun.ts index f248b80f2..190cd2849 100644 --- a/packages/core/src/connectors/utilities/aliyun.ts +++ b/packages/core/src/connectors/utilities/aliyun.ts @@ -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_) diff --git a/packages/core/src/database/update-where.test.ts b/packages/core/src/database/update-where.test.ts index b75577f3d..810a3acdd 100644 --- a/packages/core/src/database/update-where.test.ts +++ b/packages/core/src/database/update-where.test.ts @@ -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 () => { diff --git a/packages/core/src/lib/passcode.ts b/packages/core/src/lib/passcode.ts index c42ab1f36..dbec48f1b 100644 --- a/packages/core/src/lib/passcode.ts +++ b/packages/core/src/lib/passcode.ts @@ -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(ConnectorType.Email) + ? await getConnectorInstanceByType(ConnectorType.Email) : await getConnectorInstanceByType(ConnectorType.SMS); return connector.sendMessage(emailOrPhone, passcode.type, { diff --git a/packages/core/src/middleware/koa-oidc-error-handler.ts b/packages/core/src/middleware/koa-oidc-error-handler.ts index 572d505ce..b7a216204 100644 --- a/packages/core/src/middleware/koa-oidc-error-handler.ts +++ b/packages/core/src/middleware/koa-oidc-error-handler.ts @@ -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(): Middleware { diff --git a/packages/core/src/routes/session.ts b/packages/core/src/routes/session.ts index 69627915b..72dbb6853 100644 --- a/packages/core/src/routes/session.ts +++ b/packages/core/src/routes/session.ts @@ -448,7 +448,7 @@ export default function sessionRoutes(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'); diff --git a/packages/core/src/utils/password.ts b/packages/core/src/utils/password.ts index 9d513174c..67ba16b19 100644 --- a/packages/core/src/utils/password.ts +++ b/packages/core/src/utils/password.ts @@ -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,