@tpzdsp/next-toolkit 1.9.4 → 1.9.5

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpzdsp/next-toolkit",
3
- "version": "1.9.4",
3
+ "version": "1.9.5",
4
4
  "description": "A reusable React component library for Next.js applications",
5
5
  "type": "module",
6
6
  "private": false,
@@ -7,8 +7,6 @@ type GlobalVarsProps = {
7
7
  };
8
8
 
9
9
  const GlobalVarsComponent = ({ analyticsId }: GlobalVarsProps) => {
10
- console.log(`Global Vars: ${analyticsId}`); // Debugging line to check the ID
11
-
12
10
  return (
13
11
  <>
14
12
  {/*
@@ -7,8 +7,6 @@ type GoogleAnalyticsProps = {
7
7
  };
8
8
 
9
9
  const GoogleAnalyticsComponent = ({ analyticsId }: GoogleAnalyticsProps) => {
10
- console.log(`Google Analytics ID: ${analyticsId}`); // Debugging line to check the ID
11
-
12
10
  return <Script src={`https://www.googletagmanager.com/gtag/js?id=${analyticsId}`} />;
13
11
  };
14
12
 
package/src/utils/auth.ts CHANGED
@@ -3,13 +3,22 @@
3
3
  import { cookies } from 'next/headers';
4
4
  import type { NextRequest } from 'next/server';
5
5
 
6
- import { COOKIE_NAME } from './constants';
6
+ import { getCookieName } from './constants';
7
7
  import { decodeAuthToken } from './utils';
8
8
  import type { Credentials } from '../types/auth';
9
9
 
10
- export const getCredentials = async (source?: NextRequest | null): Promise<Credentials | null> => {
11
- const cookieStore = source ? source?.cookies : await cookies();
12
- const token = cookieStore.get(COOKIE_NAME)?.value;
10
+ export const getCredentials = async (
11
+ source?: NextRequest | null,
12
+ env?: string,
13
+ ): Promise<Credentials | null> => {
14
+ if (!env) {
15
+ console.warn(
16
+ 'getCredentials: No environment specified e.g. "live", using default cookie name "auth0-jwt-test". Pass the env parameter to use a different environment.',
17
+ );
18
+ }
19
+
20
+ const cookieStore = source ? source.cookies : await cookies();
21
+ const token = cookieStore.get(getCookieName(env))?.value;
13
22
 
14
23
  if (!token) {
15
24
  return null;
@@ -1,4 +1,4 @@
1
- export const COOKIE_NAME = 'auth0-jwt-test';
1
+ export const getCookieName = (env?: string) => `auth0-jwt-${env ?? 'test'}`;
2
2
 
3
3
  export const SUPPORT_URL = '/support';
4
4