fastify-txstate 3.6.0 → 3.6.1

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.
@@ -4,7 +4,6 @@ export interface IssuerConfigRaw extends Omit<IssuerConfig, 'validateUrl' | 'log
4
4
  validateUrl?: string;
5
5
  logoutUrl?: string;
6
6
  }
7
- export declare const uaCookieName: string;
8
7
  export declare function unifiedAuthenticate(req: FastifyRequest, options?: {
9
8
  authenticateAll?: boolean;
10
9
  exceptRoutes?: Set<string>;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uaCookieName = void 0;
4
3
  exports.unifiedAuthenticate = unifiedAuthenticate;
5
4
  exports.unifiedAuthenticateAll = unifiedAuthenticateAll;
6
5
  exports.requireCookieAuth = requireCookieAuth;
@@ -12,7 +11,7 @@ let hasInit = false;
12
11
  const issuerKeys = new Map();
13
12
  const issuerConfig = new Map();
14
13
  const trustedClients = new Set();
15
- exports.uaCookieName = process.env.UA_COOKIE_NAME ?? (0, crypto_1.randomBytes)(16).toString('hex');
14
+ const uaCookieName = process.env.UA_COOKIE_NAME ?? (0, crypto_1.randomBytes)(16).toString('hex');
16
15
  const tokenCache = new txstate_utils_1.Cache(async (token, req) => {
17
16
  const claims = (0, jose_1.decodeJwt)(token);
18
17
  let verifyKey;
@@ -114,7 +113,7 @@ function tokenFromReq(req) {
114
113
  const m = req?.headers.authorization?.match(/^bearer (.*)$/i);
115
114
  if (m != null)
116
115
  return m[1];
117
- const m2 = req?.headers.cookie?.match(new RegExp(`${exports.uaCookieName}=([^;]+)`));
116
+ const m2 = req?.headers.cookie?.match(new RegExp(`${uaCookieName}=([^;]+)`));
118
117
  if (m2 != null)
119
118
  return m2[1];
120
119
  }
@@ -184,7 +183,7 @@ function registerUaCookieRoutes(app) {
184
183
  headers: {
185
184
  type: 'object',
186
185
  properties: {
187
- cookie: { type: 'string', pattern: `${exports.uaCookieName}=[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+` }
186
+ cookie: { type: 'string', pattern: `${uaCookieName}=[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+` }
188
187
  },
189
188
  required: ['cookie']
190
189
  }
@@ -194,7 +193,7 @@ function registerUaCookieRoutes(app) {
194
193
  ? `${req.auth.issuerConfig.logoutUrl.toString()}?unifiedJwt=${encodeURIComponent(req.auth.token)}`
195
194
  : (process.env.PUBLIC_URL || new URL('..', req.url).toString());
196
195
  return res
197
- .header('Set-Cookie', `${exports.uaCookieName}=; Path=/; Secure; HttpOnly; SameSite=Lax; Expires=Thu, 01 Jan 1970 00:00:00 GMT`)
196
+ .header('Set-Cookie', `${uaCookieName}=; Path=/; Secure; HttpOnly; SameSite=Lax; Expires=Thu, 01 Jan 1970 00:00:00 GMT`)
198
197
  .redirect(redirectUrl);
199
198
  });
200
199
  app.get('/.uaService', {
@@ -211,7 +210,7 @@ function registerUaCookieRoutes(app) {
211
210
  }
212
211
  }, async (req, res) => {
213
212
  return res
214
- .header('Set-Cookie', `${exports.uaCookieName}=${req.query.unifiedJwt}; Path=/; Secure; HttpOnly; SameSite=Lax`)
213
+ .header('Set-Cookie', `${uaCookieName}=${req.query.unifiedJwt}; Path=/; Secure; HttpOnly; SameSite=Lax`)
215
214
  .redirect(req.query.requestedUrl ?? (process.env.PUBLIC_URL || new URL('..', req.url).toString()));
216
215
  });
217
216
  /**
package/lib-esm/index.js CHANGED
@@ -8,6 +8,7 @@ export const ValidationError = ftxst.ValidationError
8
8
  export const ValidationErrors = ftxst.ValidationErrors
9
9
  export const unifiedAuthenticate = ftxst.unifiedAuthenticate
10
10
  export const unifiedAuthenticateAll = ftxst.unifiedAuthenticateAll
11
+ export const registerUaCookieRoutes = ftxst.registerUaCookieRoutes
11
12
  export const analyticsPlugin = ftxst.analyticsPlugin
12
13
  export const AnalyticsClient = ftxst.AnalyticsClient
13
14
  export const LoggingAnalyticsClient = ftxst.LoggingAnalyticsClient
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify-txstate",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "description": "A small wrapper for fastify providing a set of common conventions & utility functions we use.",
5
5
  "exports": {
6
6
  ".": {