@terreno/api 0.20.0 → 0.20.2
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/dist/auth.js +2 -2
- package/dist/secretProviders.js +2 -1
- package/package.json +1 -1
- package/src/auth.ts +2 -2
- package/src/secretProviders.ts +3 -1
package/dist/auth.js
CHANGED
|
@@ -90,6 +90,7 @@ exports.addMeRoutes = exports.addAuthRoutes = exports.setupAuth = exports.genera
|
|
|
90
90
|
var node_crypto_1 = require("node:crypto");
|
|
91
91
|
var express_1 = __importDefault(require("express"));
|
|
92
92
|
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
93
|
+
var luxon_1 = require("luxon");
|
|
93
94
|
var ms_1 = __importDefault(require("ms"));
|
|
94
95
|
var passport_1 = __importDefault(require("passport"));
|
|
95
96
|
var passport_anonymous_1 = require("passport-anonymous");
|
|
@@ -247,7 +248,6 @@ var generateTokens = function (user_1, authOptions_1) {
|
|
|
247
248
|
});
|
|
248
249
|
};
|
|
249
250
|
exports.generateTokens = generateTokens;
|
|
250
|
-
// TODO allow customization
|
|
251
251
|
var setupAuth = function (app, userModel) {
|
|
252
252
|
passport_1.default.use(new passport_anonymous_1.Strategy());
|
|
253
253
|
passport_1.default.use(userModel.createStrategy());
|
|
@@ -371,7 +371,7 @@ var setupAuth = function (app, userModel) {
|
|
|
371
371
|
? error.expiredAt
|
|
372
372
|
: undefined;
|
|
373
373
|
message = (0, errors_1.errorMessage)(error);
|
|
374
|
-
details = "[jwt] Error decoding token".concat(userText, ": ").concat(error, ", expired at ").concat(expiredAt, ", current time: ").concat(
|
|
374
|
+
details = "[jwt] Error decoding token".concat(userText, ": ").concat(error, ", expired at ").concat(expiredAt, ", current time: ").concat(luxon_1.DateTime.now().toMillis());
|
|
375
375
|
logger_1.logger.debug(details);
|
|
376
376
|
return [2 /*return*/, res.status(401).json({ details: details, message: message })];
|
|
377
377
|
}
|
package/dist/secretProviders.js
CHANGED
|
@@ -97,6 +97,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
97
97
|
};
|
|
98
98
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
99
99
|
exports.CachingSecretProvider = exports.CompositeSecretProvider = exports.GcpSecretProvider = exports.EnvSecretProvider = void 0;
|
|
100
|
+
var luxon_1 = require("luxon");
|
|
100
101
|
var errors_1 = require("./errors");
|
|
101
102
|
var logger_1 = require("./logger");
|
|
102
103
|
/**
|
|
@@ -368,7 +369,7 @@ var CachingSecretProvider = /** @class */ (function () {
|
|
|
368
369
|
switch (_a.label) {
|
|
369
370
|
case 0:
|
|
370
371
|
key = this.cacheKey(secretName, version);
|
|
371
|
-
now =
|
|
372
|
+
now = luxon_1.DateTime.now().toMillis();
|
|
372
373
|
cached = this.cache.get(key);
|
|
373
374
|
if (cached && cached.expiresAt > now) {
|
|
374
375
|
return [2 /*return*/, cached.value];
|
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {randomUUID} from "node:crypto";
|
|
2
2
|
import express from "express";
|
|
3
3
|
import jwt, {type JwtPayload} from "jsonwebtoken";
|
|
4
|
+
import {DateTime} from "luxon";
|
|
4
5
|
import type {Model, ObjectId} from "mongoose";
|
|
5
6
|
import ms, {type StringValue} from "ms";
|
|
6
7
|
import passport from "passport";
|
|
@@ -185,7 +186,6 @@ export const generateTokens = async (
|
|
|
185
186
|
return {refreshToken, sessionId, token};
|
|
186
187
|
};
|
|
187
188
|
|
|
188
|
-
// TODO allow customization
|
|
189
189
|
export const setupAuth = (app: express.Application, userModel: UserModel): void => {
|
|
190
190
|
passport.use(new AnonymousStrategy());
|
|
191
191
|
passport.use(userModel.createStrategy());
|
|
@@ -300,7 +300,7 @@ export const setupAuth = (app: express.Application, userModel: UserModel): void
|
|
|
300
300
|
? (error as {expiredAt?: unknown}).expiredAt
|
|
301
301
|
: undefined;
|
|
302
302
|
const message = errorMessage(error);
|
|
303
|
-
const details = `[jwt] Error decoding token${userText}: ${error}, expired at ${expiredAt}, current time: ${
|
|
303
|
+
const details = `[jwt] Error decoding token${userText}: ${error}, expired at ${expiredAt}, current time: ${DateTime.now().toMillis()}`;
|
|
304
304
|
logger.debug(details);
|
|
305
305
|
return res.status(401).json({details, message});
|
|
306
306
|
}
|
package/src/secretProviders.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {DateTime} from "luxon";
|
|
2
|
+
|
|
1
3
|
import type {SecretProvider} from "./configurationPlugin";
|
|
2
4
|
import {APIError} from "./errors";
|
|
3
5
|
import {logger} from "./logger";
|
|
@@ -245,7 +247,7 @@ export class CachingSecretProvider implements SecretProvider {
|
|
|
245
247
|
|
|
246
248
|
async getSecret(secretName: string, version?: string): Promise<string | null> {
|
|
247
249
|
const key = this.cacheKey(secretName, version);
|
|
248
|
-
const now =
|
|
250
|
+
const now = DateTime.now().toMillis();
|
|
249
251
|
const cached = this.cache.get(key);
|
|
250
252
|
if (cached && cached.expiresAt > now) {
|
|
251
253
|
return cached.value;
|