payload-zitadel-plugin 0.5.2 → 0.5.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/README.md CHANGED
@@ -10,7 +10,7 @@ Thus, the user collection in PayloadCMS becomes just a shadow of the information
10
10
  ## Install
11
11
 
12
12
  ```shell
13
- pnpm add payload-zitadel-plugin@0.5.2
13
+ pnpm add payload-zitadel-plugin@0.5.4
14
14
  ```
15
15
 
16
16
  ## Configuration
@@ -150,10 +150,10 @@ export default withPayload({
150
150
  })
151
151
  ```
152
152
 
153
- Also, every environment variable has a `<ENV_NAME>__FILE` variant if you want to load the data via Docker secrets.
153
+ Also, every environment variable has a `<ENV_NAME>_FILE` variant if you want to load the data via Docker secrets.
154
154
  For instance, you could set the `ZITADEL_API_JWT_FILE=/run/secrets/zitadel_api_jwt` environment variable
155
155
  and provide a Docker secret `zitadel_api_jwt` via Docker Compose.
156
- Please keep in mind that for the `<ENV_NAME>__FILE` variant to be used,
156
+ Please keep in mind that for the `<ENV_NAME>_FILE` variant to be used,
157
157
  the `<ENV_NAME>` variable needs to be unset (as the base variable takes precedence).
158
158
 
159
159
  ### further configuration
@@ -1 +1 @@
1
- {"version":3,"file":"envs.d.ts","sourceRoot":"","sources":["../../src/utils/envs.ts"],"names":[],"mappings":"AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,MAAM,EACpC,MAAM,CAAC,EAAE,EACT,sBAAmB,KACwE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"envs.d.ts","sourceRoot":"","sources":["../../src/utils/envs.ts"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,MAAM,EACpC,MAAM,CAAC,EAAE,EACT,sBAAmB,KACwE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA"}
@@ -30,7 +30,23 @@ import { readFileSync } from 'fs';
30
30
  * // Direct value takes precedence
31
31
  * // If PASSWORD=mysecret and PASSWORD_FILE also exists
32
32
  * getEnvContent('PASSWORD', true) // Returns "mysecret" (not the file contents)
33
- */ const getEnvContent = (key, useFileCheck = false)=>useFileCheck ? key.toUpperCase().endsWith('_FILE') ? process.env[key] ? readFileSync(process.env[key], 'utf8') : undefined : process.env[key] ? process.env[key] : getEnvContent(`${key}_FILE`, useFileCheck) : process.env[key];
33
+ */ const getEnvContent = (key, useFileCheck = false)=>{
34
+ const value = process.env[key];
35
+ if (useFileCheck) {
36
+ const hasFileEnding = key.toUpperCase().endsWith('_FILE');
37
+ if (value && hasFileEnding) {
38
+ try {
39
+ return readFileSync(value, 'utf8');
40
+ } catch (e) {
41
+ console.log(`An error occurred while trying to read the file at ${value} [${key}]:`, e);
42
+ }
43
+ }
44
+ if (!value && !hasFileEnding) {
45
+ return getEnvContent(`${key}_FILE`, useFileCheck);
46
+ }
47
+ }
48
+ return value;
49
+ };
34
50
  /**
35
51
  * Loads multiple environment variables into a typed object.
36
52
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/envs.ts"],"sourcesContent":["import {readFileSync} from 'fs'\n\n/**\n * Retrieves the content of an environment variable with support for file-based secrets (Docker secrets pattern).\n *\n * This function provides three modes of operation:\n * 1. Direct read: Returns the environment variable value as-is\n * 2. File read: Reads the content from a file path specified in the environment variable\n * 3. Fallback: Automatically tries the _FILE variant if the direct variable doesn't exist\n *\n * @param key - Name of environment variable name to retrieve content from\n * @param useFileCheck - Whether to enable file checking and _FILE fallback behavior (default: false)\n *\n * @returns The environment variable value, file contents, or undefined if not found\n *\n * @example\n * // Direct read (fileCheck = false)\n * getEnvContent('API_KEY') // Returns process.env.API_KEY\n *\n * @example\n * // Read from file (when name ends with _FILE)\n * // If PASSWORD_FILE=/run/secrets/password\n * getEnvContent('PASSWORD_FILE', true) // Returns contents of /run/secrets/password\n *\n * @example\n * // Automatic fallback (when name doesn't end with _FILE)\n * // If PASSWORD is not set but PASSWORD_FILE=/run/secrets/password exists\n * getEnvContent('PASSWORD', true) // Returns contents of /run/secrets/password\n *\n * @example\n * // Direct value takes precedence\n * // If PASSWORD=mysecret and PASSWORD_FILE also exists\n * getEnvContent('PASSWORD', true) // Returns \"mysecret\" (not the file contents)\n */\nconst getEnvContent = (key: string, useFileCheck = false): string | undefined => useFileCheck ?\n (key.toUpperCase().endsWith('_FILE') ?\n (process.env[key] ? readFileSync(process.env[key], 'utf8') : undefined) :\n (process.env[key] ? process.env[key] : getEnvContent(`${key}_FILE`, useFileCheck))\n ) : process.env[key]\n\n/**\n * Loads multiple environment variables into a typed object.\n *\n * This is a convenience function that reads multiple environment variables at once\n * and returns them as a typed object. It supports the same file-based secrets pattern\n * as getEnvContent() when fileCheck is enabled.\n *\n * @template T - String literal union type representing the environment variable names\n * @param keys - Array of environment variable names to load\n * @param useFileCheck - Whether to enable file checking and _FILE fallback behavior (default: true)\n *\n * @returns A partial record mapping variable names to their values (undefined if not found)\n *\n * @example\n * // Basic usage with string array\n * const config = loadEnv(['API_KEY', 'DATABASE_URL'])\n * // Returns: { API_KEY?: string, DATABASE_URL?: string }\n *\n * @example\n * // Disable file checking for direct env var access only\n * const config = loadEnv(['NODE_ENV', 'PORT'], false)\n *\n * @example\n * // With Docker secrets (fileCheck = true)\n * // If DATABASE_PASSWORD_FILE=/run/secrets/db_password exists\n * const config = loadEnv(['DATABASE_PASSWORD'])\n * // Automatically reads from DATABASE_PASSWORD or DATABASE_PASSWORD_FILE\n *\n * @see getEnvContent for details on file checking behavior\n */\nexport const loadEnv = <T extends string>(\n keys: T[],\n useFileCheck = true\n) => Object.fromEntries(keys.map(key => [key, getEnvContent(key as string, useFileCheck)])) as Partial<Record<T, string>>"],"names":["readFileSync","getEnvContent","key","useFileCheck","toUpperCase","endsWith","process","env","undefined","loadEnv","keys","Object","fromEntries","map"],"mappings":"AAAA,SAAQA,YAAY,QAAO,KAAI;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,MAAMC,gBAAgB,CAACC,KAAaC,eAAe,KAAK,GAAyBA,eAC5ED,IAAIE,WAAW,GAAGC,QAAQ,CAAC,WACnBC,QAAQC,GAAG,CAACL,IAAI,GAAGF,aAAaM,QAAQC,GAAG,CAACL,IAAI,EAAE,UAAUM,YAC5DF,QAAQC,GAAG,CAACL,IAAI,GAAGI,QAAQC,GAAG,CAACL,IAAI,GAAGD,cAAc,GAAGC,IAAI,KAAK,CAAC,EAAEC,gBACxEG,QAAQC,GAAG,CAACL,IAAI;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,MAAMO,UAAU,CACnBC,MACAP,eAAe,IAAI,GAClBQ,OAAOC,WAAW,CAACF,KAAKG,GAAG,CAACX,CAAAA,MAAO;YAACA;YAAKD,cAAcC,KAAeC;SAAc,GAAgC"}
1
+ {"version":3,"sources":["../../src/utils/envs.ts"],"sourcesContent":["import {readFileSync} from 'fs'\n\n/**\n * Retrieves the content of an environment variable with support for file-based secrets (Docker secrets pattern).\n *\n * This function provides three modes of operation:\n * 1. Direct read: Returns the environment variable value as-is\n * 2. File read: Reads the content from a file path specified in the environment variable\n * 3. Fallback: Automatically tries the _FILE variant if the direct variable doesn't exist\n *\n * @param key - Name of environment variable name to retrieve content from\n * @param useFileCheck - Whether to enable file checking and _FILE fallback behavior (default: false)\n *\n * @returns The environment variable value, file contents, or undefined if not found\n *\n * @example\n * // Direct read (fileCheck = false)\n * getEnvContent('API_KEY') // Returns process.env.API_KEY\n *\n * @example\n * // Read from file (when name ends with _FILE)\n * // If PASSWORD_FILE=/run/secrets/password\n * getEnvContent('PASSWORD_FILE', true) // Returns contents of /run/secrets/password\n *\n * @example\n * // Automatic fallback (when name doesn't end with _FILE)\n * // If PASSWORD is not set but PASSWORD_FILE=/run/secrets/password exists\n * getEnvContent('PASSWORD', true) // Returns contents of /run/secrets/password\n *\n * @example\n * // Direct value takes precedence\n * // If PASSWORD=mysecret and PASSWORD_FILE also exists\n * getEnvContent('PASSWORD', true) // Returns \"mysecret\" (not the file contents)\n */\nconst getEnvContent = (key: string, useFileCheck = false) => {\n const value = process.env[key]\n if (useFileCheck) {\n const hasFileEnding = key.toUpperCase().endsWith('_FILE')\n if (value && hasFileEnding) {\n try {\n return readFileSync(value, 'utf8')\n } catch (e) {\n console.log(`An error occurred while trying to read the file at ${value} [${key}]:`, e)\n }\n }\n if (!value && !hasFileEnding) {\n return getEnvContent(`${key}_FILE`, useFileCheck)\n }\n }\n return value\n}\n\n/**\n * Loads multiple environment variables into a typed object.\n *\n * This is a convenience function that reads multiple environment variables at once\n * and returns them as a typed object. It supports the same file-based secrets pattern\n * as getEnvContent() when fileCheck is enabled.\n *\n * @template T - String literal union type representing the environment variable names\n * @param keys - Array of environment variable names to load\n * @param useFileCheck - Whether to enable file checking and _FILE fallback behavior (default: true)\n *\n * @returns A partial record mapping variable names to their values (undefined if not found)\n *\n * @example\n * // Basic usage with string array\n * const config = loadEnv(['API_KEY', 'DATABASE_URL'])\n * // Returns: { API_KEY?: string, DATABASE_URL?: string }\n *\n * @example\n * // Disable file checking for direct env var access only\n * const config = loadEnv(['NODE_ENV', 'PORT'], false)\n *\n * @example\n * // With Docker secrets (fileCheck = true)\n * // If DATABASE_PASSWORD_FILE=/run/secrets/db_password exists\n * const config = loadEnv(['DATABASE_PASSWORD'])\n * // Automatically reads from DATABASE_PASSWORD or DATABASE_PASSWORD_FILE\n *\n * @see getEnvContent for details on file checking behavior\n */\nexport const loadEnv = <T extends string>(\n keys: T[],\n useFileCheck = true\n) => Object.fromEntries(keys.map(key => [key, getEnvContent(key as string, useFileCheck)])) as Partial<Record<T, string>>"],"names":["readFileSync","getEnvContent","key","useFileCheck","value","process","env","hasFileEnding","toUpperCase","endsWith","e","console","log","loadEnv","keys","Object","fromEntries","map"],"mappings":"AAAA,SAAQA,YAAY,QAAO,KAAI;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GACD,MAAMC,gBAAgB,CAACC,KAAaC,eAAe,KAAK;IACpD,MAAMC,QAAQC,QAAQC,GAAG,CAACJ,IAAI;IAC9B,IAAIC,cAAc;QACd,MAAMI,gBAAgBL,IAAIM,WAAW,GAAGC,QAAQ,CAAC;QACjD,IAAIL,SAASG,eAAe;YACxB,IAAI;gBACA,OAAOP,aAAaI,OAAO;YAC/B,EAAE,OAAOM,GAAG;gBACRC,QAAQC,GAAG,CAAC,CAAC,mDAAmD,EAAER,MAAM,EAAE,EAAEF,IAAI,EAAE,CAAC,EAAEQ;YACzF;QACJ;QACA,IAAI,CAACN,SAAS,CAACG,eAAe;YAC1B,OAAON,cAAc,GAAGC,IAAI,KAAK,CAAC,EAAEC;QACxC;IACJ;IACA,OAAOC;AACX;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BC,GACD,OAAO,MAAMS,UAAU,CACnBC,MACAX,eAAe,IAAI,GAClBY,OAAOC,WAAW,CAACF,KAAKG,GAAG,CAACf,CAAAA,MAAO;YAACA;YAAKD,cAAcC,KAAeC;SAAc,GAAgC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload-zitadel-plugin",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "plugin for Payload CMS, which enables authentication via Zitadel IdP",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -36,26 +36,26 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@payloadcms/next": "^3.60.0",
40
- "@payloadcms/translations": "^3.60.0",
41
- "@payloadcms/ui": "^3.60.0",
39
+ "@payloadcms/next": "^3.61.0",
40
+ "@payloadcms/translations": "^3.61.0",
41
+ "@payloadcms/ui": "^3.61.0",
42
42
  "jose": "^6.1.0",
43
- "next": "^15.5.6",
44
- "payload": "^3.60.0",
43
+ "next": "^16.0.0",
44
+ "payload": "^3.61.0",
45
45
  "react": "^19.2.0",
46
46
  "react-dom": "^19.2.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@swc/cli": "^0.7.8",
50
50
  "@swc/core": "^1.13.20",
51
- "@types/node": "^24.8.1",
51
+ "@types/node": "^24.9.1",
52
52
  "@types/react": "^19.2.2",
53
53
  "@types/react-dom": "^19.2.2",
54
54
  "rimraf": "^6.0.1",
55
55
  "typescript": "^5.9.3"
56
56
  },
57
57
  "engines": {
58
- "node": "^24.10.0"
58
+ "node": "^25.0.0"
59
59
  },
60
60
  "exports": {
61
61
  ".": {