workos 0.12.2 → 0.12.3

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.
Files changed (35) hide show
  1. package/README.md +15 -11
  2. package/dist/commands/auth-status.js +2 -1
  3. package/dist/commands/auth-status.js.map +1 -1
  4. package/dist/commands/claim.js +4 -3
  5. package/dist/commands/claim.js.map +1 -1
  6. package/dist/commands/login.js +3 -2
  7. package/dist/commands/login.js.map +1 -1
  8. package/dist/doctor/checks/ai-analysis.js +4 -3
  9. package/dist/doctor/checks/ai-analysis.js.map +1 -1
  10. package/dist/lib/adapters/cli-adapter.js +2 -1
  11. package/dist/lib/adapters/cli-adapter.js.map +1 -1
  12. package/dist/lib/agent-interface.js +38 -14
  13. package/dist/lib/agent-interface.js.map +1 -1
  14. package/dist/lib/credential-proxy.js +2 -1
  15. package/dist/lib/credential-proxy.js.map +1 -1
  16. package/dist/lib/device-auth.js +26 -10
  17. package/dist/lib/device-auth.js.map +1 -1
  18. package/dist/lib/ensure-auth.js +4 -3
  19. package/dist/lib/ensure-auth.js.map +1 -1
  20. package/dist/lib/installer-core.d.ts +3 -3
  21. package/dist/lib/resolve-install-credentials.js +4 -4
  22. package/dist/lib/resolve-install-credentials.js.map +1 -1
  23. package/dist/lib/run-with-core.js +3 -1
  24. package/dist/lib/run-with-core.js.map +1 -1
  25. package/dist/lib/token-refresh-client.js +2 -1
  26. package/dist/lib/token-refresh-client.js.map +1 -1
  27. package/dist/lib/token-refresh.d.ts +1 -1
  28. package/dist/lib/token-refresh.js +3 -2
  29. package/dist/lib/token-refresh.js.map +1 -1
  30. package/dist/utils/command-invocation.d.ts +8 -0
  31. package/dist/utils/command-invocation.js +17 -0
  32. package/dist/utils/command-invocation.js.map +1 -0
  33. package/dist/utils/exit-codes.js +3 -1
  34. package/dist/utils/exit-codes.js.map +1 -1
  35. package/package.json +1 -1
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Return the safest user-facing way to invoke this CLI.
3
+ *
4
+ * When the package is run through npm exec/npx, `workos ...` may resolve to an
5
+ * older global binary in the user's shell. Recovery hints should keep using npx.
6
+ */
7
+ export function getWorkOSCommand(env = process.env) {
8
+ const npmCommand = env.npm_command;
9
+ const npmExecPath = env.npm_execpath ?? '';
10
+ const npmUserAgent = env.npm_config_user_agent ?? '';
11
+ const launchedByNpmExec = npmCommand === 'exec' || npmExecPath.includes('npx-cli') || /\bnpx\//.test(npmUserAgent);
12
+ return launchedByNpmExec ? 'npx workos@latest' : 'workos';
13
+ }
14
+ export function formatWorkOSCommand(args, env = process.env) {
15
+ return `${getWorkOSCommand(env)} ${args}`;
16
+ }
17
+ //# sourceMappingURL=command-invocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-invocation.js","sourceRoot":"","sources":["../../src/utils/command-invocation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACnE,MAAM,UAAU,GAAG,GAAG,CAAC,WAAW,CAAC;IACnC,MAAM,WAAW,GAAG,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;IAC3C,MAAM,YAAY,GAAG,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC;IAErD,MAAM,iBAAiB,GAAG,UAAU,KAAK,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAEnH,OAAO,iBAAiB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,MAAyB,OAAO,CAAC,GAAG;IACpF,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * Return the safest user-facing way to invoke this CLI.\n *\n * When the package is run through npm exec/npx, `workos ...` may resolve to an\n * older global binary in the user's shell. Recovery hints should keep using npx.\n */\nexport function getWorkOSCommand(env: NodeJS.ProcessEnv = process.env): string {\n const npmCommand = env.npm_command;\n const npmExecPath = env.npm_execpath ?? '';\n const npmUserAgent = env.npm_config_user_agent ?? '';\n\n const launchedByNpmExec = npmCommand === 'exec' || npmExecPath.includes('npx-cli') || /\\bnpx\\//.test(npmUserAgent);\n\n return launchedByNpmExec ? 'npx workos@latest' : 'workos';\n}\n\nexport function formatWorkOSCommand(args: string, env: NodeJS.ProcessEnv = process.env): string {\n return `${getWorkOSCommand(env)} ${args}`;\n}\n"]}
@@ -7,6 +7,7 @@
7
7
  * 4 = Authentication required
8
8
  */
9
9
  import { outputError } from './output.js';
10
+ import { formatWorkOSCommand } from './command-invocation.js';
10
11
  export const ExitCode = {
11
12
  SUCCESS: 0,
12
13
  GENERAL_ERROR: 1,
@@ -24,7 +25,8 @@ export function exitWithCode(code, error) {
24
25
  export function exitWithAuthRequired(message) {
25
26
  exitWithCode(ExitCode.AUTH_REQUIRED, {
26
27
  code: 'auth_required',
27
- message: message ?? 'Not authenticated. Run `workos auth login` in an interactive terminal, or set WORKOS_API_KEY.',
28
+ message: message ??
29
+ `Not authenticated. Run \`${formatWorkOSCommand('auth login')}\` in an interactive terminal, or set WORKOS_API_KEY.`,
28
30
  });
29
31
  }
30
32
  //# sourceMappingURL=exit-codes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../../src/utils/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,CAAC;IACV,aAAa,EAAE,CAAC;IAChB,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,CAAC;CACR,CAAC;AAIX,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,IAAmB,EAAE,KAAyC;IACzF,IAAI,KAAK,EAAE,CAAC;QACV,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,YAAY,CAAC,QAAQ,CAAC,aAAa,EAAE;QACnC,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,OAAO,IAAI,+FAA+F;KACpH,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Standardized exit codes following gh CLI convention.\n *\n * 0 = Success\n * 1 = General error\n * 2 = Cancelled (e.g., Ctrl+C, user cancelled prompt)\n * 4 = Authentication required\n */\n\nimport { outputError } from './output.js';\n\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n CANCELLED: 2,\n AUTH_REQUIRED: 4,\n} as const;\n\nexport type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode];\n\n/** Exit with a specific code, optionally writing a structured error first. */\nexport function exitWithCode(code: ExitCodeValue, error?: { code: string; message: string }): never {\n if (error) {\n outputError(error);\n }\n process.exit(code);\n}\n\n/** Convenience: exit with code 4 and auth-required error. */\nexport function exitWithAuthRequired(message?: string): never {\n exitWithCode(ExitCode.AUTH_REQUIRED, {\n code: 'auth_required',\n message: message ?? 'Not authenticated. Run `workos auth login` in an interactive terminal, or set WORKOS_API_KEY.',\n });\n}\n"]}
1
+ {"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["../../src/utils/exit-codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,CAAC;IACV,aAAa,EAAE,CAAC;IAChB,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,CAAC;CACR,CAAC;AAIX,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,IAAmB,EAAE,KAAyC;IACzF,IAAI,KAAK,EAAE,CAAC;QACV,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,YAAY,CAAC,QAAQ,CAAC,aAAa,EAAE;QACnC,IAAI,EAAE,eAAe;QACrB,OAAO,EACL,OAAO;YACP,4BAA4B,mBAAmB,CAAC,YAAY,CAAC,uDAAuD;KACvH,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Standardized exit codes following gh CLI convention.\n *\n * 0 = Success\n * 1 = General error\n * 2 = Cancelled (e.g., Ctrl+C, user cancelled prompt)\n * 4 = Authentication required\n */\n\nimport { outputError } from './output.js';\nimport { formatWorkOSCommand } from './command-invocation.js';\n\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n CANCELLED: 2,\n AUTH_REQUIRED: 4,\n} as const;\n\nexport type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode];\n\n/** Exit with a specific code, optionally writing a structured error first. */\nexport function exitWithCode(code: ExitCodeValue, error?: { code: string; message: string }): never {\n if (error) {\n outputError(error);\n }\n process.exit(code);\n}\n\n/** Convenience: exit with code 4 and auth-required error. */\nexport function exitWithAuthRequired(message?: string): never {\n exitWithCode(ExitCode.AUTH_REQUIRED, {\n code: 'auth_required',\n message:\n message ??\n `Not authenticated. Run \\`${formatWorkOSCommand('auth login')}\\` in an interactive terminal, or set WORKOS_API_KEY.`,\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workos",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "type": "module",
5
5
  "description": "The Official Workos CLI",
6
6
  "repository": {