diff --git a/package.json b/package.json index 37e1572..7db64bf 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@big-whale-labs/constants": "^0.2.25", - "@big-whale-labs/ketl-email": "^0.3.1", + "@big-whale-labs/ketl-email": "^0.4.1", "@big-whale-labs/seal-cred-email": "^1.1.2", "@hapi/boom": "^10.0.0", "@koa/cors": "^4.0.0", diff --git a/src/controllers/verify-ketl.ts b/src/controllers/verify-ketl.ts index 55a5e5f..21dc6e3 100644 --- a/src/controllers/verify-ketl.ts +++ b/src/controllers/verify-ketl.ts @@ -19,7 +19,6 @@ import checkInvite from '@/helpers/ketl/checkInvite' import fetchUserProfile from '@/helpers/twitter/fetchUserProfile' import getAttestationHash from '@/helpers/signatures/getAttestationHash' import getBalance from '@/helpers/getBalance' -import getEmailDomain from '@/helpers/getEmailDomain' import handleInvitationError from '@/helpers/handleInvitationError' import hexlifyString from '@/helpers/hexlifyString' import sendEmail from '@/helpers/sendEmail' @@ -56,8 +55,9 @@ export default class VerifyKetlController { async sendMultipleEmailAttestation( @Ctx() ctx: Context, @Body({ required: true }) - { email, types }: AttestationTypeList & Email + body: AttestationTypeList & Email ) { + const { email, types } = body const secret = [] for (const type of types) { @@ -81,12 +81,12 @@ export default class VerifyKetlController { if (!secret.length) return ctx.throw(notFound(handleInvitationError('email'))) - const domain = getEmailDomain(email) + const fullSecret = secret.join('') + void sendEmail({ - domain, forKetl: true, - secret: secret.join(''), - subject: "Here's your signup code!", + secret: fullSecret, + subject: "Here's your invite code!", to: email, }) } @@ -94,20 +94,19 @@ export default class VerifyKetlController { @Post('/email-unique') async sendUniqueEmail( @Body({ required: true }) - { email, type }: AttestationType & Email + body: AttestationType & Email ) { + const { email, type } = body const attestationHash = await getAttestationHash( VerificationType.email, hexlifyString(email) ) const { signature } = await signAttestationMessage(type, attestationHash) - const domain = getEmailDomain(email) void sendEmail({ - domain, forKetl: true, secret: `${type}${attestationHash}${signature}`, - subject: "Here's signup code!", + subject: "Here's your invite code!", to: email, }) } diff --git a/src/controllers/verify.ts b/src/controllers/verify.ts index f468fe7..acd7fbc 100644 --- a/src/controllers/verify.ts +++ b/src/controllers/verify.ts @@ -73,7 +73,6 @@ export default class VerifyController { const domainBytes = padZeroesOnRightUint8(utils.toUtf8Bytes(domain), 90) const signature = await eddsaSigFromString(domainBytes) void sendEmail({ - domain, secret: signature, subject: "Here's your token!", to: email, diff --git a/src/helpers/sendEmail.ts b/src/helpers/sendEmail.ts index 2b125ea..f36da85 100644 --- a/src/helpers/sendEmail.ts +++ b/src/helpers/sendEmail.ts @@ -3,6 +3,7 @@ import { createTransport } from 'nodemailer' import { inviteCode } from '@big-whale-labs/ketl-email' import { generateTokenHtml as scEmail } from '@big-whale-labs/seal-cred-email' import env from '@/helpers/env' +import getEmailDomain from '@/helpers/getEmailDomain' const user = env.SMTP_USER const pass = env.SMTP_PASS @@ -27,7 +28,6 @@ const emailerMailgun = createTransport( ) export default async function ({ - domain, forKetl, secret, subject, @@ -36,13 +36,15 @@ export default async function ({ to: string subject: string secret: string - domain: string forKetl?: boolean }) { try { const { html } = forKetl - ? inviteCode({ domain, secret }) - : scEmail({ domain, secret }) + ? inviteCode({ + inviteCode: secret, + value: to, + }) + : scEmail({ domain: getEmailDomain(to), secret }) const from = forKetl ? 'Ketl' : 'SealCred' const fromEmail = forKetl diff --git a/yarn.lock b/yarn.lock index 9f173fb..d3b4fad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -40,9 +40,9 @@ __metadata: languageName: node linkType: hard -"@big-whale-labs/ketl-email@npm:^0.3.1": - version: 0.3.1 - resolution: "@big-whale-labs/ketl-email@npm:0.3.1" +"@big-whale-labs/ketl-email@npm:^0.4.1": + version: 0.4.1 + resolution: "@big-whale-labs/ketl-email@npm:0.4.1" dependencies: dotenv: ^16.3.1 envalid: ^7.3.1 @@ -52,7 +52,7 @@ __metadata: react: ^18.2.0 react-dom: ^18.2.0 source-map-support: ^0.5.21 - checksum: 6b99f253a4c01c489497cf553b2a81e299a27c0dde9256d1c95e08cd8fb541847a06519ca048bb467cf5feed80b62ddf626eeea98d34dbf91da0c52d79c47240 + checksum: 2781cebcf07feac50de2d7890d14c159444f772e51be1832ca70ed6918dcdc8968189dfa74e3f043263ffd171da080b7c582a13d044df60f0e4a22572edfffb8 languageName: node linkType: hard @@ -1741,7 +1741,7 @@ __metadata: dependencies: "@big-whale-labs/bwl-eslint-backend": ^1.0.3 "@big-whale-labs/constants": ^0.2.25 - "@big-whale-labs/ketl-email": ^0.3.1 + "@big-whale-labs/ketl-email": ^0.4.1 "@big-whale-labs/prettier-config": ^1.1.3 "@big-whale-labs/seal-cred-email": ^1.1.2 "@hapi/boom": ^10.0.0