@anthropic-ai/sdk 0.92.0 → 0.94.0

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 (97) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/client.d.mts +73 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +73 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +258 -9
  7. package/client.js.map +1 -1
  8. package/client.mjs +258 -9
  9. package/client.mjs.map +1 -1
  10. package/core/credentials.d.mts +131 -0
  11. package/core/credentials.d.mts.map +1 -0
  12. package/core/credentials.d.ts +131 -0
  13. package/core/credentials.d.ts.map +1 -0
  14. package/core/credentials.js +317 -0
  15. package/core/credentials.js.map +1 -0
  16. package/core/credentials.mjs +277 -0
  17. package/core/credentials.mjs.map +1 -0
  18. package/internal/utils/time.d.mts +3 -0
  19. package/internal/utils/time.d.mts.map +1 -0
  20. package/internal/utils/time.d.ts +3 -0
  21. package/internal/utils/time.d.ts.map +1 -0
  22. package/internal/utils/time.js +8 -0
  23. package/internal/utils/time.js.map +1 -0
  24. package/internal/utils/time.mjs +5 -0
  25. package/internal/utils/time.mjs.map +1 -0
  26. package/lib/credentials/credential-chain.d.mts +39 -0
  27. package/lib/credentials/credential-chain.d.mts.map +1 -0
  28. package/lib/credentials/credential-chain.d.ts +39 -0
  29. package/lib/credentials/credential-chain.d.ts.map +1 -0
  30. package/lib/credentials/credential-chain.js +245 -0
  31. package/lib/credentials/credential-chain.js.map +1 -0
  32. package/lib/credentials/credential-chain.mjs +208 -0
  33. package/lib/credentials/credential-chain.mjs.map +1 -0
  34. package/lib/credentials/identity-token.d.mts +11 -0
  35. package/lib/credentials/identity-token.d.mts.map +1 -0
  36. package/lib/credentials/identity-token.d.ts +11 -0
  37. package/lib/credentials/identity-token.d.ts.map +1 -0
  38. package/lib/credentials/identity-token.js +72 -0
  39. package/lib/credentials/identity-token.js.map +1 -0
  40. package/lib/credentials/identity-token.mjs +35 -0
  41. package/lib/credentials/identity-token.mjs.map +1 -0
  42. package/lib/credentials/oidc-federation.d.mts +40 -0
  43. package/lib/credentials/oidc-federation.d.mts.map +1 -0
  44. package/lib/credentials/oidc-federation.d.ts +40 -0
  45. package/lib/credentials/oidc-federation.d.ts.map +1 -0
  46. package/lib/credentials/oidc-federation.js +82 -0
  47. package/lib/credentials/oidc-federation.js.map +1 -0
  48. package/lib/credentials/oidc-federation.mjs +79 -0
  49. package/lib/credentials/oidc-federation.mjs.map +1 -0
  50. package/lib/credentials/token-cache.d.mts +54 -0
  51. package/lib/credentials/token-cache.d.mts.map +1 -0
  52. package/lib/credentials/token-cache.d.ts +54 -0
  53. package/lib/credentials/token-cache.d.ts.map +1 -0
  54. package/lib/credentials/token-cache.js +112 -0
  55. package/lib/credentials/token-cache.js.map +1 -0
  56. package/lib/credentials/token-cache.mjs +108 -0
  57. package/lib/credentials/token-cache.mjs.map +1 -0
  58. package/lib/credentials/types.d.mts +96 -0
  59. package/lib/credentials/types.d.mts.map +1 -0
  60. package/lib/credentials/types.d.ts +96 -0
  61. package/lib/credentials/types.d.ts.map +1 -0
  62. package/lib/credentials/types.js +266 -0
  63. package/lib/credentials/types.js.map +1 -0
  64. package/lib/credentials/types.mjs +224 -0
  65. package/lib/credentials/types.mjs.map +1 -0
  66. package/lib/credentials/user-oauth.d.mts +21 -0
  67. package/lib/credentials/user-oauth.d.mts.map +1 -0
  68. package/lib/credentials/user-oauth.d.ts +21 -0
  69. package/lib/credentials/user-oauth.d.ts.map +1 -0
  70. package/lib/credentials/user-oauth.js +130 -0
  71. package/lib/credentials/user-oauth.js.map +1 -0
  72. package/lib/credentials/user-oauth.mjs +94 -0
  73. package/lib/credentials/user-oauth.mjs.map +1 -0
  74. package/lib/credentials.d.mts +4 -0
  75. package/lib/credentials.d.mts.map +1 -0
  76. package/lib/credentials.d.ts +4 -0
  77. package/lib/credentials.d.ts.map +1 -0
  78. package/lib/credentials.js +8 -0
  79. package/lib/credentials.js.map +1 -0
  80. package/lib/credentials.mjs +3 -0
  81. package/lib/credentials.mjs.map +1 -0
  82. package/package.json +1 -1
  83. package/src/client.ts +342 -14
  84. package/src/core/credentials.ts +379 -0
  85. package/src/internal/utils/time.ts +4 -0
  86. package/src/lib/credentials/credential-chain.ts +292 -0
  87. package/src/lib/credentials/identity-token.ts +37 -0
  88. package/src/lib/credentials/oidc-federation.ts +140 -0
  89. package/src/lib/credentials/token-cache.ts +130 -0
  90. package/src/lib/credentials/types.ts +295 -0
  91. package/src/lib/credentials/user-oauth.ts +144 -0
  92. package/src/lib/credentials.ts +3 -0
  93. package/src/version.ts +1 -1
  94. package/version.d.mts +1 -1
  95. package/version.d.ts +1 -1
  96. package/version.js +1 -1
  97. package/version.mjs +1 -1
@@ -0,0 +1,131 @@
1
+ /** Current schema version written to `configs/<profile>.json`. Absent on read ⇒ "1.0". */
2
+ export declare const CONFIG_FILE_VERSION = "1.0";
3
+ /** Current schema version written to `credentials/<profile>.json`. Absent on read ⇒ "1.0". */
4
+ export declare const CREDENTIALS_FILE_VERSION = "1.0";
5
+ /**
6
+ * Authentication-mode-specific configuration. On the wire (configs/<profile>.json)
7
+ * this is a flat JSON object under the top-level `authentication` key — `type`,
8
+ * `credentials_path`, and the variant-specific fields all sit at the same level.
9
+ *
10
+ * Unknown fields are silently ignored for forward compatibility. Unknown
11
+ * authentication types are rejected because the SDK has no way to resolve
12
+ * credentials for them.
13
+ */
14
+ export type AuthenticationInfo = {
15
+ /**
16
+ * Filesystem path to the credentials JSON that stores access/refresh tokens.
17
+ * Defaults to `<config_dir>/credentials/<profile>.json` when omitted.
18
+ */
19
+ credentials_path?: string | undefined;
20
+ } & ({
21
+ type: 'oidc_federation';
22
+ /** Tagged ID (`fdrl_...`) of the federation rule. Required. */
23
+ federation_rule_id: string;
24
+ /** Optional `svac_...` expected-target check. */
25
+ service_account_id?: string | undefined;
26
+ identity_token?: {
27
+ source: 'file';
28
+ path: string;
29
+ } | undefined;
30
+ /** Display-only; the SDK does not send this on the jwt-bearer exchange. */
31
+ scope?: string | undefined;
32
+ } | {
33
+ type: 'user_oauth';
34
+ /** OAuth client ID for refresh. Empty → access token is treated as static. */
35
+ client_id?: string | undefined;
36
+ /** Display-only; the SDK does not send this on refresh. */
37
+ scope?: string | undefined;
38
+ /** Console URL the profile was created against. Display-only. */
39
+ console_url?: string | undefined;
40
+ });
41
+ export type AnthropicConfig = {
42
+ version?: string;
43
+ authentication: AuthenticationInfo;
44
+ base_url?: string | undefined;
45
+ organization_id?: string | undefined;
46
+ workspace_id?: string | undefined;
47
+ };
48
+ export type AnthropicCredentials = {
49
+ version?: string;
50
+ type: 'oauth_token';
51
+ access_token: string;
52
+ expires_at?: number;
53
+ refresh_token?: string;
54
+ scope?: string;
55
+ organization_uuid?: string;
56
+ organization_name?: string;
57
+ account_email?: string;
58
+ };
59
+ /**
60
+ * Loads the Anthropic configuration for the given (or active) profile.
61
+ *
62
+ * Returns `null` when running in a browser or no configuration can be resolved.
63
+ * Otherwise, returns the configuration based on the config file and environment variables.
64
+ *
65
+ * **Profile resolution** (first match wins):
66
+ * 1. Explicit `profile` argument
67
+ * 2. `ANTHROPIC_PROFILE` environment variable
68
+ * 3. Contents of `<config_dir>/active_config` file
69
+ * 4. `"default"`
70
+ *
71
+ * **Config resolution:**
72
+ * - If `<config_dir>/configs/<profile>.json` exists, it is loaded and
73
+ * missing fields are filled from environment variables. Values present
74
+ * in the file take precedence — env vars only fill gaps:
75
+ * - `ANTHROPIC_BASE_URL` → `base_url`
76
+ * - `ANTHROPIC_ORGANIZATION_ID` → `organization_id`
77
+ * - `ANTHROPIC_WORKSPACE_ID` → `workspace_id`
78
+ * - `ANTHROPIC_SCOPE` → `authentication.scope`
79
+ * - `ANTHROPIC_FEDERATION_RULE_ID` → `authentication.federation_rule_id` (oidc_federation)
80
+ * - `ANTHROPIC_IDENTITY_TOKEN_FILE` → `authentication.identity_token` (oidc_federation)
81
+ * - `ANTHROPIC_SERVICE_ACCOUNT_ID` → `authentication.service_account_id` (oidc_federation)
82
+ * - If no config file exists, an `oidc_federation` config is synthesized
83
+ * entirely from environment variables when both `ANTHROPIC_FEDERATION_RULE_ID`
84
+ * and `ANTHROPIC_ORGANIZATION_ID` are set.
85
+ */
86
+ export declare const loadConfig: (profile?: string) => Promise<AnthropicConfig | null>;
87
+ /**
88
+ * Source-tagged result of {@link loadConfigWithSource}. `fromFile` is `true`
89
+ * when `<config_dir>/configs/<profile>.json` exists on disk; `false` when the
90
+ * config was synthesized purely from environment variables.
91
+ *
92
+ * The credential chain uses this distinction to decide whether to back the
93
+ * federation exchange with a disk cache: file-backed profiles get a cache at
94
+ * `<config_dir>/credentials/<profile>.json`, env-only configs do not.
95
+ */
96
+ export type LoadedConfig = {
97
+ config: AnthropicConfig;
98
+ fromFile: boolean;
99
+ };
100
+ /**
101
+ * Same as {@link loadConfig}, but also reports whether the config was loaded
102
+ * from a profile file on disk (`fromFile: true`) or synthesized entirely from
103
+ * environment variables (`fromFile: false`).
104
+ */
105
+ export declare const loadConfigWithSource: (profile?: string) => Promise<LoadedConfig | null>;
106
+ /**
107
+ * Loads the credential material for the active profile.
108
+ *
109
+ * Returns the parsed credentials or `null` when running in a browser or
110
+ * no credentials file can be found.
111
+ *
112
+ * **Profile resolution** (first match wins):
113
+ * 1. `ANTHROPIC_PROFILE` environment variable
114
+ * 2. Contents of `<config_dir>/active_config` file
115
+ * 3. `"default"`
116
+ *
117
+ * **Credentials path resolution** (first match wins):
118
+ * 1. `authentication.credentials_path` from the active profile's config (via {@link loadConfig})
119
+ * 2. `<config_dir>/credentials/<profile>.json`
120
+ */
121
+ export declare const loadCredentials: () => Promise<AnthropicCredentials | null>;
122
+ /**
123
+ * Resolves the credentials file path for the given config.
124
+ *
125
+ * Uses `authentication.credentials_path` from the config if set, otherwise
126
+ * falls back to `<config_dir>/credentials/<profile>.json`.
127
+ *
128
+ * Returns `null` when running in a browser or the path cannot be resolved.
129
+ */
130
+ export declare const getCredentialsPath: (config: AnthropicConfig | null, profile?: string) => Promise<string | null>;
131
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/core/credentials.ts"],"names":[],"mappings":"AAGA,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AACzC,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,GAAG,CACA;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,+DAA+D;IAC/D,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,cAAc,CAAC,EACX;QACE,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,GACD,SAAS,CAAC;IACd,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CACJ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAqBF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAEjF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CA8FxF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,QAAa,OAAO,CAAC,oBAAoB,GAAG,IAAI,CA8B3E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,eAAe,GAAG,IAAI,EAC9B,UAAU,MAAM,KACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAkBvB,CAAC"}
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getCredentialsPath = exports.loadCredentials = exports.loadConfigWithSource = exports.loadConfig = exports.CREDENTIALS_FILE_VERSION = exports.CONFIG_FILE_VERSION = void 0;
37
+ const detect_platform_1 = require("../internal/detect-platform.js");
38
+ const utils_1 = require("../internal/utils.js");
39
+ /** Current schema version written to `configs/<profile>.json`. Absent on read ⇒ "1.0". */
40
+ exports.CONFIG_FILE_VERSION = '1.0';
41
+ /** Current schema version written to `credentials/<profile>.json`. Absent on read ⇒ "1.0". */
42
+ exports.CREDENTIALS_FILE_VERSION = '1.0';
43
+ const PROFILE_NAME_PATTERN = /^[A-Za-z0-9_.-]+$/;
44
+ function validateProfileName(name) {
45
+ if (!name) {
46
+ throw new Error('profile name is empty');
47
+ }
48
+ if (name === '.' || name === '..') {
49
+ throw new Error(`profile name "${name}" is not allowed`);
50
+ }
51
+ if (name.includes('/') || name.includes('\\')) {
52
+ throw new Error(`profile name "${name}" must not contain path separators`);
53
+ }
54
+ if (!PROFILE_NAME_PATTERN.test(name)) {
55
+ throw new Error(`profile name "${name}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`);
56
+ }
57
+ }
58
+ /**
59
+ * Loads the Anthropic configuration for the given (or active) profile.
60
+ *
61
+ * Returns `null` when running in a browser or no configuration can be resolved.
62
+ * Otherwise, returns the configuration based on the config file and environment variables.
63
+ *
64
+ * **Profile resolution** (first match wins):
65
+ * 1. Explicit `profile` argument
66
+ * 2. `ANTHROPIC_PROFILE` environment variable
67
+ * 3. Contents of `<config_dir>/active_config` file
68
+ * 4. `"default"`
69
+ *
70
+ * **Config resolution:**
71
+ * - If `<config_dir>/configs/<profile>.json` exists, it is loaded and
72
+ * missing fields are filled from environment variables. Values present
73
+ * in the file take precedence — env vars only fill gaps:
74
+ * - `ANTHROPIC_BASE_URL` → `base_url`
75
+ * - `ANTHROPIC_ORGANIZATION_ID` → `organization_id`
76
+ * - `ANTHROPIC_WORKSPACE_ID` → `workspace_id`
77
+ * - `ANTHROPIC_SCOPE` → `authentication.scope`
78
+ * - `ANTHROPIC_FEDERATION_RULE_ID` → `authentication.federation_rule_id` (oidc_federation)
79
+ * - `ANTHROPIC_IDENTITY_TOKEN_FILE` → `authentication.identity_token` (oidc_federation)
80
+ * - `ANTHROPIC_SERVICE_ACCOUNT_ID` → `authentication.service_account_id` (oidc_federation)
81
+ * - If no config file exists, an `oidc_federation` config is synthesized
82
+ * entirely from environment variables when both `ANTHROPIC_FEDERATION_RULE_ID`
83
+ * and `ANTHROPIC_ORGANIZATION_ID` are set.
84
+ */
85
+ const loadConfig = async (profile) => {
86
+ return (await (0, exports.loadConfigWithSource)(profile))?.config ?? null;
87
+ };
88
+ exports.loadConfig = loadConfig;
89
+ /**
90
+ * Same as {@link loadConfig}, but also reports whether the config was loaded
91
+ * from a profile file on disk (`fromFile: true`) or synthesized entirely from
92
+ * environment variables (`fromFile: false`).
93
+ */
94
+ const loadConfigWithSource = async (profile) => {
95
+ var _a, _b;
96
+ const rootConfigPath = await getRootConfigPath();
97
+ if (rootConfigPath === null) {
98
+ return null;
99
+ }
100
+ const profileName = profile ?? (await getActiveProfileName());
101
+ if (profileName === null) {
102
+ return null;
103
+ }
104
+ validateProfileName(profileName);
105
+ const fs = await Promise.resolve().then(() => __importStar(require('node:fs')));
106
+ const path = await Promise.resolve().then(() => __importStar(require('node:path')));
107
+ const configPath = path.join(rootConfigPath, 'configs', `${profileName}.json`);
108
+ let configRaw;
109
+ try {
110
+ configRaw = await fs.promises.readFile(configPath, 'utf-8');
111
+ }
112
+ catch (err) {
113
+ if (err?.code !== 'ENOENT') {
114
+ throw new Error(`failed to read config file ${configPath}: ${err}`);
115
+ }
116
+ configRaw = null;
117
+ }
118
+ if (configRaw === null) {
119
+ const organizationId = (0, utils_1.readEnv)('ANTHROPIC_ORGANIZATION_ID');
120
+ const identityTokenFile = (0, utils_1.readEnv)('ANTHROPIC_IDENTITY_TOKEN_FILE');
121
+ const federationRuleId = (0, utils_1.readEnv)('ANTHROPIC_FEDERATION_RULE_ID');
122
+ if (federationRuleId && organizationId) {
123
+ return {
124
+ fromFile: false,
125
+ config: {
126
+ organization_id: organizationId,
127
+ // A defaulted-but-empty CI variable (`ANTHROPIC_WORKSPACE_ID=""`) is
128
+ // treated as unset — readEnv coerces empty to undefined, and the body
129
+ // builder's truthy check skips it — so `"workspace_id": ""` never goes
130
+ // on the wire.
131
+ workspace_id: (0, utils_1.readEnv)('ANTHROPIC_WORKSPACE_ID'),
132
+ base_url: (0, utils_1.readEnv)('ANTHROPIC_BASE_URL'),
133
+ authentication: {
134
+ type: 'oidc_federation',
135
+ federation_rule_id: federationRuleId,
136
+ service_account_id: (0, utils_1.readEnv)('ANTHROPIC_SERVICE_ACCOUNT_ID'),
137
+ identity_token: identityTokenFile ? { source: 'file', path: identityTokenFile } : undefined,
138
+ scope: (0, utils_1.readEnv)('ANTHROPIC_SCOPE'),
139
+ },
140
+ },
141
+ };
142
+ }
143
+ return null;
144
+ }
145
+ let config;
146
+ try {
147
+ config = JSON.parse(configRaw);
148
+ }
149
+ catch (err) {
150
+ throw new Error(`failed to parse config file ${configPath}: ${err}`);
151
+ }
152
+ if (!config.authentication) {
153
+ throw new Error(`config file ${configPath} is missing "authentication"`);
154
+ }
155
+ const authType = config.authentication.type;
156
+ if (authType !== 'oidc_federation' && authType !== 'user_oauth') {
157
+ throw new Error(`authentication.type "${authType}" is not a known authentication type`);
158
+ }
159
+ // File values are authoritative; env vars only fill fields the file left unset.
160
+ config.organization_id ?? (config.organization_id = (0, utils_1.readEnv)('ANTHROPIC_ORGANIZATION_ID'));
161
+ config.workspace_id ?? (config.workspace_id = (0, utils_1.readEnv)('ANTHROPIC_WORKSPACE_ID'));
162
+ config.base_url ?? (config.base_url = (0, utils_1.readEnv)('ANTHROPIC_BASE_URL'));
163
+ (_a = config.authentication).scope ?? (_a.scope = (0, utils_1.readEnv)('ANTHROPIC_SCOPE'));
164
+ if (config.authentication.type === 'oidc_federation') {
165
+ if (!config.authentication.identity_token) {
166
+ const identityTokenFile = (0, utils_1.readEnv)('ANTHROPIC_IDENTITY_TOKEN_FILE');
167
+ if (identityTokenFile) {
168
+ config.authentication.identity_token = {
169
+ source: 'file',
170
+ path: identityTokenFile,
171
+ };
172
+ }
173
+ }
174
+ // Unlike siblings using `??= readEnv()` (which leaves `undefined`), coerce
175
+ // to '' so the type stays `string` (always set). The downstream required
176
+ // check in credential-chain rejects empty, so semantics match but types are
177
+ // cleaner.
178
+ if (!config.authentication.federation_rule_id) {
179
+ config.authentication.federation_rule_id = (0, utils_1.readEnv)('ANTHROPIC_FEDERATION_RULE_ID') ?? '';
180
+ }
181
+ (_b = config.authentication).service_account_id ?? (_b.service_account_id = (0, utils_1.readEnv)('ANTHROPIC_SERVICE_ACCOUNT_ID'));
182
+ }
183
+ return { config, fromFile: true };
184
+ };
185
+ exports.loadConfigWithSource = loadConfigWithSource;
186
+ /**
187
+ * Loads the credential material for the active profile.
188
+ *
189
+ * Returns the parsed credentials or `null` when running in a browser or
190
+ * no credentials file can be found.
191
+ *
192
+ * **Profile resolution** (first match wins):
193
+ * 1. `ANTHROPIC_PROFILE` environment variable
194
+ * 2. Contents of `<config_dir>/active_config` file
195
+ * 3. `"default"`
196
+ *
197
+ * **Credentials path resolution** (first match wins):
198
+ * 1. `authentication.credentials_path` from the active profile's config (via {@link loadConfig})
199
+ * 2. `<config_dir>/credentials/<profile>.json`
200
+ */
201
+ const loadCredentials = async () => {
202
+ const config = await (0, exports.loadConfig)();
203
+ const credentialsPath = await (0, exports.getCredentialsPath)(config);
204
+ if (!credentialsPath) {
205
+ return null;
206
+ }
207
+ const fs = await Promise.resolve().then(() => __importStar(require('node:fs')));
208
+ let raw;
209
+ try {
210
+ raw = await fs.promises.readFile(credentialsPath, 'utf-8');
211
+ }
212
+ catch (err) {
213
+ if (err?.code !== 'ENOENT') {
214
+ throw new Error(`failed to read credentials file ${credentialsPath}: ${err}`);
215
+ }
216
+ return null;
217
+ }
218
+ let creds;
219
+ try {
220
+ creds = JSON.parse(raw);
221
+ }
222
+ catch (err) {
223
+ throw new Error(`failed to parse credentials file ${credentialsPath}: ${err}`);
224
+ }
225
+ if (creds.type && creds.type !== 'oauth_token') {
226
+ throw new Error(`credentials file ${credentialsPath} has unsupported type "${creds.type}" (want "oauth_token")`);
227
+ }
228
+ return creds;
229
+ };
230
+ exports.loadCredentials = loadCredentials;
231
+ /**
232
+ * Resolves the credentials file path for the given config.
233
+ *
234
+ * Uses `authentication.credentials_path` from the config if set, otherwise
235
+ * falls back to `<config_dir>/credentials/<profile>.json`.
236
+ *
237
+ * Returns `null` when running in a browser or the path cannot be resolved.
238
+ */
239
+ const getCredentialsPath = async (config, profile) => {
240
+ if (config?.authentication.credentials_path) {
241
+ return config.authentication.credentials_path;
242
+ }
243
+ const rootConfigPath = await getRootConfigPath();
244
+ if (!rootConfigPath) {
245
+ return null;
246
+ }
247
+ const profileName = profile ?? (await getActiveProfileName());
248
+ if (!profileName) {
249
+ return null;
250
+ }
251
+ validateProfileName(profileName);
252
+ const path = await Promise.resolve().then(() => __importStar(require('node:path')));
253
+ return path.join(rootConfigPath, 'credentials', `${profileName}.json`);
254
+ };
255
+ exports.getCredentialsPath = getCredentialsPath;
256
+ const getRootConfigPath = async () => {
257
+ if (!supportsLocalConfigFiles()) {
258
+ return null;
259
+ }
260
+ const path = await Promise.resolve().then(() => __importStar(require('node:path')));
261
+ // ANTHROPIC_CONFIG_DIR is treated as a trusted path: it is set by the
262
+ // process operator, not by remote input, so it is not validated.
263
+ const configDir = (0, utils_1.readEnv)('ANTHROPIC_CONFIG_DIR');
264
+ if (configDir) {
265
+ return configDir;
266
+ }
267
+ const os = (0, detect_platform_1.getPlatformHeaders)()['X-Stainless-OS'];
268
+ if (os === 'Windows') {
269
+ const appData = (0, utils_1.readEnv)('APPDATA');
270
+ if (appData) {
271
+ return path.join(appData, 'Anthropic');
272
+ }
273
+ const userProfile = (0, utils_1.readEnv)('USERPROFILE');
274
+ if (userProfile) {
275
+ return path.join(userProfile, 'AppData', 'Roaming', 'Anthropic');
276
+ }
277
+ // No usable Windows config root — return null so callers fall through to
278
+ // "no config available" rather than silently writing under C:\.
279
+ return null;
280
+ }
281
+ const xdgConfigHome = (0, utils_1.readEnv)('XDG_CONFIG_HOME');
282
+ if (xdgConfigHome) {
283
+ return path.join(xdgConfigHome, 'anthropic');
284
+ }
285
+ const home = (0, utils_1.readEnv)('HOME');
286
+ if (home) {
287
+ return path.join(home, '.config', 'anthropic');
288
+ }
289
+ return null;
290
+ };
291
+ const supportsLocalConfigFiles = () => {
292
+ const runtime = (0, detect_platform_1.getPlatformHeaders)()['X-Stainless-Runtime'];
293
+ return runtime === 'node' || runtime === 'deno';
294
+ };
295
+ const getActiveProfileName = async () => {
296
+ const rootConfigPath = await getRootConfigPath();
297
+ if (!rootConfigPath) {
298
+ return null;
299
+ }
300
+ const profileName = (0, utils_1.readEnv)('ANTHROPIC_PROFILE');
301
+ if (profileName) {
302
+ return profileName;
303
+ }
304
+ const fs = await Promise.resolve().then(() => __importStar(require('node:fs')));
305
+ const path = await Promise.resolve().then(() => __importStar(require('node:path')));
306
+ const filePath = path.join(rootConfigPath, 'active_config');
307
+ try {
308
+ return (await fs.promises.readFile(filePath, 'utf-8')).trim() || 'default';
309
+ }
310
+ catch (err) {
311
+ if (err?.code !== 'ENOENT') {
312
+ throw new Error(`failed to read ${filePath}: ${err}`);
313
+ }
314
+ return 'default';
315
+ }
316
+ };
317
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/core/credentials.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAiE;AACjE,gDAA4C;AAE5C,0FAA0F;AAC7E,QAAA,mBAAmB,GAAG,KAAK,CAAC;AACzC,8FAA8F;AACjF,QAAA,wBAAwB,GAAG,KAAK,CAAC;AAgE9C,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,kBAAkB,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,oCAAoC,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,iBAAiB,IAAI,4EAA4E,CAClG,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;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