@xenterprises/fastify-xconfig 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xenterprises/fastify-xconfig",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "description": "Fastify configuration plugin for setting up middleware, services, and route handling.",
6
6
  "main": "src/xConfig.js",
7
7
  "scripts": {
package/src/auth/admin.js CHANGED
@@ -130,7 +130,7 @@ export async function setupAdminAuth(fastify, options) {
130
130
  const accessToken = await reply.adminJwtSign({ id: admin.id });
131
131
 
132
132
  // Generate refresh token
133
- const refreshToken = randomUUID();
133
+ const refreshToken = await fastify.randomUUID();
134
134
  const hashedRefreshToken = await bcrypt.hash(refreshToken, 10);
135
135
 
136
136
  // Store hashed refresh token in the database
@@ -175,7 +175,7 @@ export async function setupAdminAuth(fastify, options) {
175
175
  const accessToken = await reply.adminJwtSign({ id: admin.id });
176
176
 
177
177
  // Generate new refresh token
178
- const newRefreshToken = randomUUID();
178
+ const newRefreshToken = await fastify.randomUUID();
179
179
  const hashedNewRefreshToken = await bcrypt.hash(newRefreshToken, 10);
180
180
 
181
181
  // Update refresh token in the database
@@ -1,5 +1,6 @@
1
1
  import jwt from "@fastify/jwt";
2
2
  import bcrypt from "bcrypt";
3
+ import { config } from "process";
3
4
  const isProduction = process.env.NODE_ENV === 'production';
4
5
  export async function setupAuth(fastify, options) {
5
6
  if (options.user?.active !== false) {
@@ -114,14 +115,17 @@ export async function setupAuth(fastify, options) {
114
115
  },
115
116
  });
116
117
 
117
- // Send welcome email
118
- await fastify.sendGrid.sendEmail(email, auth?.user?.registerEmail?.subject, auth?.user?.registerEmail?.templateId, { name: firstName, email });
118
+ // // Send welcome email
119
+ // if (options.user?.sendWelcomeEmail) {
120
+ // await fastify.sendGrid.sendEmail(email, auth?.user?.registerEmail?.subject, auth?.user?.registerEmail?.templateId, { name: firstName, email });
121
+ // }
122
+
119
123
 
120
124
  // Issue access token
121
125
  const accessToken = await reply.userJwtSign({ id: user.id });
122
126
 
123
127
  // Generate refresh token
124
- const refreshToken = randomUUID();
128
+ const refreshToken = await fastify.randomUUID();
125
129
  const hashedRefreshToken = await bcrypt.hash(refreshToken, 10);
126
130
 
127
131
  // Store hashed refresh token in the database
@@ -168,7 +172,7 @@ export async function setupAuth(fastify, options) {
168
172
  const accessToken = await reply.userJwtSign({ id: user.id });
169
173
 
170
174
  // Generate refresh token
171
- const refreshToken = randomUUID();
175
+ const refreshToken = await fastify.randomUUID();
172
176
  const hashedRefreshToken = await bcrypt.hash(refreshToken, 10);
173
177
 
174
178
  // Store hashed refresh token in the database
@@ -4,7 +4,7 @@ import { randomUUID } from "uncrypto";
4
4
  async function xUUID(fastify, options) {
5
5
  fastify.decorate("generateUUID", randomUUID);
6
6
 
7
- fastify.decorate('UUID', () => {
7
+ fastify.decorate('randomUUID', () => {
8
8
  return randomUUID(); // Generate a UUID using uncrypto's randomUUID
9
9
  });
10
10
  }