@punks/backend-entity-manager 0.0.505 → 0.0.508

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.
@@ -5,7 +5,12 @@ export declare enum UserCreationError {
5
5
  export type UserCreationInput<TUserRegistrationInfo, TUserContext extends IAuthUserContext> = {
6
6
  email: string;
7
7
  userName: string;
8
- password: string;
8
+ /**
9
+ * Password for the user account.
10
+ * - Required for standard email/password authentication
11
+ * - Should be omitted (undefined) when using passwordless OAuth login
12
+ */
13
+ password?: string;
9
14
  registrationInfo: TUserRegistrationInfo;
10
15
  context?: TUserContext;
11
16
  verified?: boolean;
@@ -5,4 +5,5 @@ export declare class AwsSesEmailProvider implements IEmailProvider<AwsSesEmailTe
5
5
  constructor();
6
6
  sendTemplatedEmail<TPayload, TAugmentedPayload>(input: TemplatedEmailInput<TPayload>, template: IEmailTemplate<AwsSesEmailTemplateData, TPayload, TAugmentedPayload>, options?: EmailSendOptions): Promise<void>;
7
7
  sendHtmlEmail<TPayload>(input: HtmlEmailInput<TPayload>, options?: EmailSendOptions): Promise<void>;
8
+ private invokeEmailSend;
8
9
  }
@@ -6,5 +6,7 @@ export type AwsSesSettings = {
6
6
  defaultSender: string;
7
7
  defaultCc?: string[];
8
8
  defaultBcc?: string[];
9
+ sandboxMode?: boolean;
10
+ sandboxAddresses?: string[];
9
11
  };
10
12
  export declare const awsSesSettings: AppInMemorySettings<AwsSesSettings>;
package/dist/esm/index.js CHANGED
@@ -23798,7 +23798,7 @@ let UserCreationHandler = class UserCreationHandler {
23798
23798
  error: UserCreationError.UserAlreadyExists,
23799
23799
  };
23800
23800
  }
23801
- if (user && !user.verified) {
23801
+ if (user && !user.verified && input.password) {
23802
23802
  const passwordHash = await this.createPasswordHash(input.password, user.id);
23803
23803
  await this.services.getUsersService().update(user.id, {
23804
23804
  passwordHash,
@@ -23812,10 +23812,11 @@ let UserCreationHandler = class UserCreationHandler {
23812
23812
  };
23813
23813
  }
23814
23814
  const newUser = await this.createUser(input.email, input.userName, input.registrationInfo, input.context);
23815
- const passwordHash = await this.createPasswordHash(input.password, newUser.id);
23816
23815
  await this.services.getUsersService().update(newUser.id, {
23817
- passwordHash,
23818
- passwordUpdateTimestamp: new Date(),
23816
+ ...(input.password && {
23817
+ passwordHash: await this.createPasswordHash(input.password, newUser.id),
23818
+ passwordUpdateTimestamp: new Date(),
23819
+ }),
23819
23820
  verified: input.verified ?? true,
23820
23821
  });
23821
23822
  this.logger.debug(`New user created: ${input.email} - ${input.userName}`, {
@@ -41300,28 +41301,55 @@ let AwsSesEmailProvider = class AwsSesEmailProvider {
41300
41301
  cc: input.cc ?? templateData.cc,
41301
41302
  from: input.from ?? templateData.from,
41302
41303
  attachments: input.attachments,
41303
- });
41304
+ }, options);
41304
41305
  }
41305
41306
  async sendHtmlEmail(input, options) {
41307
+ const from = input.from || awsSesSettings.value.defaultSender;
41308
+ if (!from) {
41309
+ throw new Error("No sender address provided");
41310
+ }
41311
+ if (awsSesSettings.value.sandboxMode || options?.sandboxMode) {
41312
+ if (awsSesSettings.value.sandboxAddresses?.length) {
41313
+ await this.invokeEmailSend({
41314
+ from,
41315
+ to: awsSesSettings.value.sandboxAddresses,
41316
+ subjectTemplate: input.subjectTemplate,
41317
+ bodyTemplate: input.bodyTemplate,
41318
+ payload: input.payload,
41319
+ });
41320
+ }
41321
+ return;
41322
+ }
41323
+ await this.invokeEmailSend({
41324
+ from,
41325
+ to: input.to ?? [],
41326
+ cc: input.cc ?? awsSesSettings.value.defaultCc ?? [],
41327
+ bcc: input.bcc ?? awsSesSettings.value.defaultBcc ?? [],
41328
+ subjectTemplate: input.subjectTemplate,
41329
+ bodyTemplate: input.bodyTemplate,
41330
+ payload: input.payload,
41331
+ });
41332
+ }
41333
+ async invokeEmailSend({ from, to, cc, bcc, subjectTemplate, bodyTemplate, payload, }) {
41306
41334
  await this.client.send(new SendEmailCommand({
41307
- Source: input.from ?? input.from ?? awsSesSettings.value.defaultSender,
41335
+ Source: from,
41308
41336
  Destination: {
41309
- ToAddresses: input.to ?? input.to ?? [],
41310
- CcAddresses: input.cc ?? awsSesSettings.value.defaultCc ?? [],
41311
- BccAddresses: input.bcc ?? awsSesSettings.value.defaultBcc ?? [],
41337
+ ToAddresses: to ?? [],
41338
+ CcAddresses: cc ?? [],
41339
+ BccAddresses: bcc ?? [],
41312
41340
  },
41313
41341
  Message: {
41314
41342
  Subject: {
41315
41343
  Data: renderHandlebarsTemplate({
41316
- template: input.subjectTemplate,
41317
- context: input.payload,
41344
+ template: subjectTemplate,
41345
+ context: payload,
41318
41346
  }),
41319
41347
  },
41320
41348
  Body: {
41321
41349
  Html: {
41322
41350
  Data: renderHandlebarsTemplate({
41323
- template: input.bodyTemplate,
41324
- context: input.payload,
41351
+ template: bodyTemplate,
41352
+ context: payload,
41325
41353
  }),
41326
41354
  },
41327
41355
  },