@logto/connector-aws-ses 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -220,8 +220,8 @@ var createAwsSesConnector = async ({ getConfig }) => {
220
220
  sendMessage: sendMessage(getConfig)
221
221
  };
222
222
  };
223
- var src_default = createAwsSesConnector;
223
+ var index_default = createAwsSesConnector;
224
224
  export {
225
- src_default as default
225
+ index_default as default
226
226
  };
227
227
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/constant.ts","../src/types.ts","../src/utils.ts"],"sourcesContent":["import { assert } from '@silverhand/essentials';\n\nimport type { SESv2Client, SendEmailCommand, SendEmailCommandOutput } from '@aws-sdk/client-sesv2';\nimport { SESv2ServiceException } from '@aws-sdk/client-sesv2';\nimport type {\n CreateConnector,\n EmailConnector,\n GetConnectorConfig,\n SendMessageFunction,\n} from '@logto/connector-kit';\nimport {\n ConnectorError,\n ConnectorErrorCodes,\n ConnectorType,\n validateConfig,\n} from '@logto/connector-kit';\n\nimport { defaultMetadata } from './constant.js';\nimport { awsSesConfigGuard } from './types.js';\nimport { makeClient, makeCommand, makeEmailContent } from './utils.js';\n\nconst sendMessage =\n (getConfig: GetConnectorConfig): SendMessageFunction =>\n async (data, inputConfig) => {\n const { to, type, payload } = data;\n const config = inputConfig ?? (await getConfig(defaultMetadata.id));\n validateConfig(config, awsSesConfigGuard);\n const { accessKeyId, accessKeySecret, region, templates } = config;\n const template = templates.find((template) => template.usageType === type);\n\n assert(\n template,\n new ConnectorError(\n ConnectorErrorCodes.TemplateNotFound,\n `Cannot find template for type: ${type}`\n )\n );\n\n const client: SESv2Client = makeClient(accessKeyId, accessKeySecret, region);\n const emailContent = makeEmailContent(template, payload);\n const command: SendEmailCommand = makeCommand(config, emailContent, to);\n\n try {\n const response: SendEmailCommandOutput = await client.send(command);\n\n assert(\n response.$metadata.httpStatusCode === 200,\n new ConnectorError(ConnectorErrorCodes.InvalidResponse, response)\n );\n\n return response.MessageId;\n } catch (error: unknown) {\n if (error instanceof SESv2ServiceException) {\n throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, error.message);\n }\n\n throw error;\n }\n };\n\nconst createAwsSesConnector: CreateConnector<EmailConnector> = async ({ getConfig }) => {\n return {\n metadata: defaultMetadata,\n type: ConnectorType.Email,\n configGuard: awsSesConfigGuard,\n sendMessage: sendMessage(getConfig),\n };\n};\n\nexport default createAwsSesConnector;\n","import type { ConnectorMetadata } from '@logto/connector-kit';\nimport { ConnectorConfigFormItemType } from '@logto/connector-kit';\n\nexport const defaultMetadata: ConnectorMetadata = {\n id: 'aws-ses-mail',\n target: 'aws-ses',\n platform: null,\n name: {\n en: 'AWS Direct Mail',\n 'zh-CN': 'AWS邮件推送',\n 'tr-TR': 'AWS Direct Mail',\n ko: 'AWS 다이렉트 메일',\n },\n logo: './logo.svg',\n logoDark: './logo-dark.svg',\n description: {\n en: 'Amazon SES is a cloud email service provider that can integrate into any application for bulk email sending.',\n 'zh-CN':\n 'Amazon SES 是云电子邮件发送服务提供商,它可以集成到任何应用程序中,用于批量发送电子邮件。',\n 'tr-TR':\n 'Amazon SES, toplu e-posta dağıtımı için herhangi bir uygulamaya entegre edilebilen bir bulut e-posta dağıtım hizmeti sağlayıcısıdır.',\n ko: 'Amazon SES는 모든 애플리케이션에 통합하여 대량으로 이메일을 전송할 수 있는 클라우드 이메일 서비스 공급자입니다.',\n },\n readme: './README.md',\n formItems: [\n {\n key: 'accessKeyId',\n label: 'Access Key ID',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<access-key-id>',\n },\n {\n key: 'accessKeySecret',\n label: 'Access Key Secret',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<access-key-secret>',\n },\n {\n key: 'region',\n label: 'Region',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<region>',\n },\n {\n key: 'emailAddress',\n label: 'Email Address',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<email-address>',\n },\n {\n key: 'emailAddressIdentityArn',\n label: 'Email Address Identity ARN',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<email-address-identity-arn>',\n },\n {\n key: 'feedbackForwardingEmailAddress',\n label: 'Feedback Forwarding Email Address',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<feedback-forwarding-email-address>',\n },\n {\n key: 'feedbackForwardingEmailAddressIdentityArn',\n label: 'Feedback Forwarding Email Address Identity ARN',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<feedback-forwarding-email-address-identity-arn>',\n },\n {\n key: 'configurationSetName',\n label: 'Configuration Set Name',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<configuration-set-name>',\n },\n {\n key: 'templates',\n label: 'Templates',\n type: ConnectorConfigFormItemType.Json,\n required: true,\n defaultValue: [\n {\n usageType: 'SignIn',\n subject: '<sign-in-template-subject>',\n content:\n 'Your Logto sign-in verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n {\n usageType: 'Register',\n subject: '<register-template-subject>',\n content:\n 'Your Logto sign-up verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n {\n usageType: 'ForgotPassword',\n subject: '<forgot-password-template-subject>',\n content:\n 'Your Logto password change verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n {\n usageType: 'Generic',\n subject: '<generic-template-subject>',\n content:\n 'Your Logto verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n ],\n },\n ],\n};\n","import { z } from 'zod';\n\n/**\n * UsageType here is used to specify the use case of the template, can be either\n * 'Register', 'SignIn', 'ForgotPassword', 'Generic'.\n */\nconst requiredTemplateUsageTypes = ['Register', 'SignIn', 'ForgotPassword', 'Generic'];\nconst templateGuard = z.object({\n usageType: z.string(),\n subject: z.string(),\n content: z.string(), // With variable {{code}}, support HTML\n});\n\nexport type Template = z.infer<typeof templateGuard>;\n\nexport const awsSesConfigGuard = z.object({\n accessKeyId: z.string(),\n accessKeySecret: z.string(),\n region: z.string(),\n emailAddress: z.string().optional(),\n emailAddressIdentityArn: z.string().optional(),\n templates: z.array(templateGuard).refine(\n (templates) =>\n requiredTemplateUsageTypes.every((requiredType) =>\n templates.map((template) => template.usageType).includes(requiredType)\n ),\n (templates) => ({\n message: `Template with UsageType (${requiredTemplateUsageTypes\n .filter(\n (requiredType) => !templates.map((template) => template.usageType).includes(requiredType)\n )\n .join(', ')}) should be provided!`,\n })\n ),\n feedbackForwardingEmailAddress: z.string().optional(),\n feedbackForwardingEmailAddressIdentityArn: z.string().optional(),\n configurationSetName: z.string().optional(),\n});\n\nexport type AwsSesConfig = z.infer<typeof awsSesConfigGuard>;\n","import type { EmailContent } from '@aws-sdk/client-sesv2';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\nimport type { AwsCredentialIdentity } from '@aws-sdk/types';\nimport { replaceSendMessageHandlebars, type SendMessagePayload } from '@logto/connector-kit';\n\nimport type { AwsSesConfig, Template } from './types.js';\n\nexport const makeClient = (\n accessKeyId: string,\n secretAccessKey: string,\n region: string\n): SESv2Client => {\n const credentials: AwsCredentialIdentity = {\n accessKeyId,\n secretAccessKey,\n };\n\n return new SESv2Client({ credentials, region });\n};\n\nexport const makeEmailContent = (template: Template, payload: SendMessagePayload): EmailContent => {\n return {\n Simple: {\n Subject: { Data: replaceSendMessageHandlebars(template.subject, payload), Charset: 'utf8' },\n Body: {\n Html: {\n Data: replaceSendMessageHandlebars(template.content, payload),\n },\n },\n },\n };\n};\n\nexport const makeCommand = (\n config: AwsSesConfig,\n emailContent: EmailContent,\n to: string\n): SendEmailCommand => {\n return new SendEmailCommand({\n Destination: { ToAddresses: [to] },\n Content: emailContent,\n FromEmailAddress: config.emailAddress,\n FromEmailAddressIdentityArn: config.emailAddressIdentityArn,\n FeedbackForwardingEmailAddress: config.feedbackForwardingEmailAddress,\n FeedbackForwardingEmailAddressIdentityArn: config.feedbackForwardingEmailAddressIdentityArn,\n ConfigurationSetName: config.configurationSetName,\n });\n};\n"],"mappings":";AAAA,SAAS,cAAc;AAGvB,SAAS,6BAA6B;AAOtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACdP,SAAS,mCAAmC;AAErC,IAAM,kBAAqC;AAAA,EAChD,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,IACX,IAAI;AAAA,IACJ,SACE;AAAA,IACF,SACE;AAAA,IACF,IAAI;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,IACT;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;AAAA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QAAQ,IAAI;AAC9B,QAAM,SAAS,eAAgB,MAAM,UAAU,gBAAgB,EAAE;AACjE,iBAAe,QAAQ,iBAAiB;AACxC,QAAM,EAAE,aAAa,iBAAiB,QAAQ,UAAU,IAAI;AAC5D,QAAM,WAAW,UAAU,KAAK,CAACA,cAAaA,UAAS,cAAc,IAAI;AAEzE;AAAA,IACE;AAAA,IACA,IAAI;AAAA,MACF,oBAAoB;AAAA,MACpB,kCAAkC,IAAI;AAAA,IACxC;AAAA,EACF;AAEA,QAAM,SAAsB,WAAW,aAAa,iBAAiB,MAAM;AAC3E,QAAM,eAAe,iBAAiB,UAAU,OAAO;AACvD,QAAM,UAA4B,YAAY,QAAQ,cAAc,EAAE;AAEtE,MAAI;AACF,UAAM,WAAmC,MAAM,OAAO,KAAK,OAAO;AAElE;AAAA,MACE,SAAS,UAAU,mBAAmB;AAAA,MACtC,IAAI,eAAe,oBAAoB,iBAAiB,QAAQ;AAAA,IAClE;AAEA,WAAO,SAAS;AAAA,EAClB,SAAS,OAAgB;AACvB,QAAI,iBAAiB,uBAAuB;AAC1C,YAAM,IAAI,eAAe,oBAAoB,iBAAiB,MAAM,OAAO;AAAA,IAC7E;AAEA,UAAM;AAAA,EACR;AACF;AAEF,IAAM,wBAAyD,OAAO,EAAE,UAAU,MAAM;AACtF,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM,cAAc;AAAA,IACpB,aAAa;AAAA,IACb,aAAa,YAAY,SAAS;AAAA,EACpC;AACF;AAEA,IAAO,cAAQ;","names":["template"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/constant.ts","../src/types.ts","../src/utils.ts"],"sourcesContent":["import { assert } from '@silverhand/essentials';\n\nimport type { SESv2Client, SendEmailCommand, SendEmailCommandOutput } from '@aws-sdk/client-sesv2';\nimport { SESv2ServiceException } from '@aws-sdk/client-sesv2';\nimport type {\n CreateConnector,\n EmailConnector,\n GetConnectorConfig,\n SendMessageFunction,\n} from '@logto/connector-kit';\nimport {\n ConnectorError,\n ConnectorErrorCodes,\n ConnectorType,\n validateConfig,\n} from '@logto/connector-kit';\n\nimport { defaultMetadata } from './constant.js';\nimport { awsSesConfigGuard } from './types.js';\nimport { makeClient, makeCommand, makeEmailContent } from './utils.js';\n\nconst sendMessage =\n (getConfig: GetConnectorConfig): SendMessageFunction =>\n async (data, inputConfig) => {\n const { to, type, payload } = data;\n const config = inputConfig ?? (await getConfig(defaultMetadata.id));\n validateConfig(config, awsSesConfigGuard);\n const { accessKeyId, accessKeySecret, region, templates } = config;\n const template = templates.find((template) => template.usageType === type);\n\n assert(\n template,\n new ConnectorError(\n ConnectorErrorCodes.TemplateNotFound,\n `Cannot find template for type: ${type}`\n )\n );\n\n const client: SESv2Client = makeClient(accessKeyId, accessKeySecret, region);\n const emailContent = makeEmailContent(template, payload);\n const command: SendEmailCommand = makeCommand(config, emailContent, to);\n\n try {\n const response: SendEmailCommandOutput = await client.send(command);\n\n assert(\n response.$metadata.httpStatusCode === 200,\n new ConnectorError(ConnectorErrorCodes.InvalidResponse, response)\n );\n\n return response.MessageId;\n } catch (error: unknown) {\n if (error instanceof SESv2ServiceException) {\n throw new ConnectorError(ConnectorErrorCodes.InvalidResponse, error.message);\n }\n\n throw error;\n }\n };\n\nconst createAwsSesConnector: CreateConnector<EmailConnector> = async ({ getConfig }) => {\n return {\n metadata: defaultMetadata,\n type: ConnectorType.Email,\n configGuard: awsSesConfigGuard,\n sendMessage: sendMessage(getConfig),\n };\n};\n\nexport default createAwsSesConnector;\n","import type { ConnectorMetadata } from '@logto/connector-kit';\nimport { ConnectorConfigFormItemType } from '@logto/connector-kit';\n\nexport const defaultMetadata: ConnectorMetadata = {\n id: 'aws-ses-mail',\n target: 'aws-ses',\n platform: null,\n name: {\n en: 'AWS Direct Mail',\n 'zh-CN': 'AWS邮件推送',\n 'tr-TR': 'AWS Direct Mail',\n ko: 'AWS 다이렉트 메일',\n },\n logo: './logo.svg',\n logoDark: './logo-dark.svg',\n description: {\n en: 'Amazon SES is a cloud email service provider that can integrate into any application for bulk email sending.',\n 'zh-CN':\n 'Amazon SES 是云电子邮件发送服务提供商,它可以集成到任何应用程序中,用于批量发送电子邮件。',\n 'tr-TR':\n 'Amazon SES, toplu e-posta dağıtımı için herhangi bir uygulamaya entegre edilebilen bir bulut e-posta dağıtım hizmeti sağlayıcısıdır.',\n ko: 'Amazon SES는 모든 애플리케이션에 통합하여 대량으로 이메일을 전송할 수 있는 클라우드 이메일 서비스 공급자입니다.',\n },\n readme: './README.md',\n formItems: [\n {\n key: 'accessKeyId',\n label: 'Access Key ID',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<access-key-id>',\n },\n {\n key: 'accessKeySecret',\n label: 'Access Key Secret',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<access-key-secret>',\n },\n {\n key: 'region',\n label: 'Region',\n type: ConnectorConfigFormItemType.Text,\n required: true,\n placeholder: '<region>',\n },\n {\n key: 'emailAddress',\n label: 'Email Address',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<email-address>',\n },\n {\n key: 'emailAddressIdentityArn',\n label: 'Email Address Identity ARN',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<email-address-identity-arn>',\n },\n {\n key: 'feedbackForwardingEmailAddress',\n label: 'Feedback Forwarding Email Address',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<feedback-forwarding-email-address>',\n },\n {\n key: 'feedbackForwardingEmailAddressIdentityArn',\n label: 'Feedback Forwarding Email Address Identity ARN',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<feedback-forwarding-email-address-identity-arn>',\n },\n {\n key: 'configurationSetName',\n label: 'Configuration Set Name',\n type: ConnectorConfigFormItemType.Text,\n required: false,\n placeholder: '<configuration-set-name>',\n },\n {\n key: 'templates',\n label: 'Templates',\n type: ConnectorConfigFormItemType.Json,\n required: true,\n defaultValue: [\n {\n usageType: 'SignIn',\n subject: '<sign-in-template-subject>',\n content:\n 'Your Logto sign-in verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n {\n usageType: 'Register',\n subject: '<register-template-subject>',\n content:\n 'Your Logto sign-up verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n {\n usageType: 'ForgotPassword',\n subject: '<forgot-password-template-subject>',\n content:\n 'Your Logto password change verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n {\n usageType: 'Generic',\n subject: '<generic-template-subject>',\n content:\n 'Your Logto verification code is {{code}}. The code will remain active for 10 minutes.',\n },\n ],\n },\n ],\n};\n","import { z } from 'zod';\n\n/**\n * UsageType here is used to specify the use case of the template, can be either\n * 'Register', 'SignIn', 'ForgotPassword', 'Generic'.\n */\nconst requiredTemplateUsageTypes = ['Register', 'SignIn', 'ForgotPassword', 'Generic'];\nconst templateGuard = z.object({\n usageType: z.string(),\n subject: z.string(),\n content: z.string(), // With variable {{code}}, support HTML\n});\n\nexport type Template = z.infer<typeof templateGuard>;\n\nexport const awsSesConfigGuard = z.object({\n accessKeyId: z.string(),\n accessKeySecret: z.string(),\n region: z.string(),\n emailAddress: z.string().optional(),\n emailAddressIdentityArn: z.string().optional(),\n templates: z.array(templateGuard).refine(\n (templates) =>\n requiredTemplateUsageTypes.every((requiredType) =>\n templates.map((template) => template.usageType).includes(requiredType)\n ),\n (templates) => ({\n message: `Template with UsageType (${requiredTemplateUsageTypes\n .filter(\n (requiredType) => !templates.map((template) => template.usageType).includes(requiredType)\n )\n .join(', ')}) should be provided!`,\n })\n ),\n feedbackForwardingEmailAddress: z.string().optional(),\n feedbackForwardingEmailAddressIdentityArn: z.string().optional(),\n configurationSetName: z.string().optional(),\n});\n\nexport type AwsSesConfig = z.infer<typeof awsSesConfigGuard>;\n","import type { EmailContent } from '@aws-sdk/client-sesv2';\nimport { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';\nimport type { AwsCredentialIdentity } from '@aws-sdk/types';\nimport { replaceSendMessageHandlebars, type SendMessagePayload } from '@logto/connector-kit';\n\nimport type { AwsSesConfig, Template } from './types.js';\n\nexport const makeClient = (\n accessKeyId: string,\n secretAccessKey: string,\n region: string\n): SESv2Client => {\n const credentials: AwsCredentialIdentity = {\n accessKeyId,\n secretAccessKey,\n };\n\n return new SESv2Client({ credentials, region });\n};\n\nexport const makeEmailContent = (template: Template, payload: SendMessagePayload): EmailContent => {\n return {\n Simple: {\n Subject: { Data: replaceSendMessageHandlebars(template.subject, payload), Charset: 'utf8' },\n Body: {\n Html: {\n Data: replaceSendMessageHandlebars(template.content, payload),\n },\n },\n },\n };\n};\n\nexport const makeCommand = (\n config: AwsSesConfig,\n emailContent: EmailContent,\n to: string\n): SendEmailCommand => {\n return new SendEmailCommand({\n Destination: { ToAddresses: [to] },\n Content: emailContent,\n FromEmailAddress: config.emailAddress,\n FromEmailAddressIdentityArn: config.emailAddressIdentityArn,\n FeedbackForwardingEmailAddress: config.feedbackForwardingEmailAddress,\n FeedbackForwardingEmailAddressIdentityArn: config.feedbackForwardingEmailAddressIdentityArn,\n ConfigurationSetName: config.configurationSetName,\n });\n};\n"],"mappings":";AAAA,SAAS,cAAc;AAGvB,SAAS,6BAA6B;AAOtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACdP,SAAS,mCAAmC;AAErC,IAAM,kBAAqC;AAAA,EAChD,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,SAAS;AAAA,IACT,IAAI;AAAA,EACN;AAAA,EACA,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AAAA,IACX,IAAI;AAAA,IACJ,SACE;AAAA,IACF,SACE;AAAA,IACF,IAAI;AAAA,EACN;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,IACT;AAAA,MACE,KAAK;AAAA,MACL,OAAO;AAAA,MACP,MAAM,4BAA4B;AAAA,MAClC,UAAU;AAAA,MACV,aAAa;A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iBAAiB,uBAAuB;AAC1C,YAAM,IAAI,eAAe,oBAAoB,iBAAiB,MAAM,OAAO;AAAA,IAC7E;AAEA,UAAM;AAAA,EACR;AACF;AAEF,IAAM,wBAAyD,OAAO,EAAE,UAAU,MAAM;AACtF,SAAO;AAAA,IACL,UAAU;AAAA,IACV,MAAM,cAAc;AAAA,IACpB,aAAa;AAAA,IACb,aAAa,YAAY,SAAS;AAAA,EACpC;AACF;AAEA,IAAO,gBAAQ;","names":["template"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@logto/connector-aws-ses",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Logto Connector for Amazon SES",
5
5
  "author": "Jeff <admin@breadth.app>",
6
6
  "dependencies": {
7
7
  "@aws-sdk/client-sesv2": "^3.556.0",
8
8
  "@aws-sdk/types": "^3.535.0",
9
- "@logto/connector-kit": "^4.0.0",
9
+ "@logto/connector-kit": "^4.1.1",
10
10
  "@silverhand/essentials": "^2.9.1",
11
11
  "got": "^14.0.0",
12
12
  "snakecase-keys": "^8.0.1",
@@ -47,15 +47,15 @@
47
47
  "@silverhand/ts-config": "6.0.0",
48
48
  "@types/node": "^20.11.20",
49
49
  "@types/supertest": "^6.0.2",
50
- "@vitest/coverage-v8": "^2.0.0",
50
+ "@vitest/coverage-v8": "^2.1.9",
51
51
  "eslint": "^8.56.0",
52
52
  "lint-staged": "^15.0.2",
53
53
  "nock": "^13.3.1",
54
54
  "prettier": "^3.0.0",
55
55
  "supertest": "^7.0.0",
56
- "tsup": "^8.1.0",
56
+ "tsup": "^8.3.0",
57
57
  "typescript": "^5.5.3",
58
- "vitest": "^2.0.0"
58
+ "vitest": "^2.1.9"
59
59
  },
60
60
  "scripts": {
61
61
  "precommit": "lint-staged",