vr-commons 1.0.70 → 1.0.72
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.
|
@@ -7,8 +7,7 @@ exports.formatTimeRemaining = exports.getTokenTimeRemaining = exports.shouldRefr
|
|
|
7
7
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
8
|
// Get token lifespan from env with fallback to 30 days (in seconds)
|
|
9
9
|
const getTokenLifespan = (type) => {
|
|
10
|
-
const
|
|
11
|
-
const value = process.env[envVar];
|
|
10
|
+
const value = process.env.TOKEN_LIFE_SPAN;
|
|
12
11
|
if (value) {
|
|
13
12
|
const parsed = parseInt(value, 10);
|
|
14
13
|
if (!isNaN(parsed) && parsed > 0) {
|
|
@@ -16,7 +15,7 @@ const getTokenLifespan = (type) => {
|
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
// Default to 30 days (2,592,000 seconds)
|
|
19
|
-
console.warn(`⚠️
|
|
18
|
+
console.warn(`⚠️ Token lie span not set or invalid, using default 30 days (2,592,000 seconds)`);
|
|
20
19
|
return 30 * 24 * 60 * 60;
|
|
21
20
|
};
|
|
22
21
|
// Helper to generate token with 30-day expiry
|
|
@@ -86,7 +85,7 @@ const shouldRefreshToken = (token) => {
|
|
|
86
85
|
return false;
|
|
87
86
|
const now = Math.floor(Date.now() / 1000);
|
|
88
87
|
const timeUntilExpiry = decoded.exp - now;
|
|
89
|
-
const refreshThreshold =
|
|
88
|
+
const refreshThreshold = parseInt(process.env.TOKEN_REFRESH_THRESHOLD || "604800");
|
|
90
89
|
return timeUntilExpiry < refreshThreshold && timeUntilExpiry > 0;
|
|
91
90
|
}
|
|
92
91
|
catch {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDeviceSession = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
// Session duration for device unlock sessions (
|
|
6
|
-
const SESSION_DURATION = parseInt(process.env.DEVICE_SESSION_DURATION || "
|
|
5
|
+
// Session duration for device unlock sessions (12 minutes)
|
|
6
|
+
const SESSION_DURATION = parseInt(process.env.DEVICE_SESSION_DURATION || "12") * 60 * 1000; // Convert minutes to milliseconds
|
|
7
7
|
/**
|
|
8
8
|
* Create a new device session (for BLE unlock)
|
|
9
9
|
* This is separate from the long-lasting auth token
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.sendVerificationCode = exports.sendEmail = exports.sendSMS = exports.getOTPExpiry = exports.generateOTP = exports.getVerificationMethod = void 0;
|
|
7
|
-
const twilio_1 = __importDefault(require("twilio"));
|
|
8
7
|
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
9
8
|
// Get verification method from env
|
|
10
9
|
const getVerificationMethod = () => {
|
|
@@ -34,19 +33,19 @@ exports.getOTPExpiry = getOTPExpiry;
|
|
|
34
33
|
// SMS Sender
|
|
35
34
|
const sendSMS = async (phoneNumber, message) => {
|
|
36
35
|
try {
|
|
37
|
-
const accountSid = process.env.TWILIO_ACCOUNT_SID;
|
|
38
|
-
const authToken = process.env.TWILIO_AUTH_TOKEN;
|
|
39
|
-
const fromNumber = process.env.TWILIO_PHONE_NUMBER;
|
|
40
|
-
if (!accountSid || !authToken || !fromNumber) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
const client = (
|
|
45
|
-
await client.messages.create({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
36
|
+
// const accountSid = process.env.TWILIO_ACCOUNT_SID;
|
|
37
|
+
// const authToken = process.env.TWILIO_AUTH_TOKEN;
|
|
38
|
+
// const fromNumber = process.env.TWILIO_PHONE_NUMBER;
|
|
39
|
+
// if (!accountSid || !authToken || !fromNumber) {
|
|
40
|
+
// console.error("Twilio credentials not configured");
|
|
41
|
+
// return false;
|
|
42
|
+
// }
|
|
43
|
+
// const client = twilio(accountSid, authToken);
|
|
44
|
+
// await client.messages.create({
|
|
45
|
+
// body: message,
|
|
46
|
+
// from: fromNumber,
|
|
47
|
+
// to: phoneNumber,
|
|
48
|
+
// });
|
|
50
49
|
console.log(`✅ SMS sent to ${phoneNumber}`);
|
|
51
50
|
return true;
|
|
52
51
|
}
|