offrouter-core 0.2.0 → 0.2.2

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 (139) hide show
  1. package/dist/audit.d.ts +137 -0
  2. package/dist/audit.d.ts.map +1 -0
  3. package/dist/audit.js +320 -0
  4. package/dist/audit.js.map +1 -0
  5. package/dist/auth/credential-chain.d.ts +84 -0
  6. package/dist/auth/credential-chain.d.ts.map +1 -0
  7. package/dist/auth/credential-chain.js +150 -0
  8. package/dist/auth/credential-chain.js.map +1 -0
  9. package/dist/auth/index.d.ts +10 -0
  10. package/dist/auth/index.d.ts.map +1 -0
  11. package/dist/auth/index.js +7 -0
  12. package/dist/auth/index.js.map +1 -0
  13. package/dist/auth/keychain.d.ts +60 -0
  14. package/dist/auth/keychain.d.ts.map +1 -0
  15. package/dist/auth/keychain.js +104 -0
  16. package/dist/auth/keychain.js.map +1 -0
  17. package/dist/auth/oauth-pkce.d.ts +138 -0
  18. package/dist/auth/oauth-pkce.d.ts.map +1 -0
  19. package/dist/auth/oauth-pkce.js +375 -0
  20. package/dist/auth/oauth-pkce.js.map +1 -0
  21. package/dist/auth/oauth-server.d.ts +36 -0
  22. package/dist/auth/oauth-server.d.ts.map +1 -0
  23. package/dist/auth/oauth-server.js +210 -0
  24. package/dist/auth/oauth-server.js.map +1 -0
  25. package/dist/config.d.ts +76 -0
  26. package/dist/config.d.ts.map +1 -0
  27. package/dist/config.js +355 -0
  28. package/dist/config.js.map +1 -0
  29. package/dist/delegation.d.ts +123 -0
  30. package/dist/delegation.d.ts.map +1 -0
  31. package/dist/delegation.js +455 -0
  32. package/dist/delegation.js.map +1 -0
  33. package/dist/index.d.ts +41 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +26 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/policy.d.ts +45 -0
  38. package/dist/policy.d.ts.map +1 -0
  39. package/dist/policy.js +318 -0
  40. package/dist/policy.js.map +1 -0
  41. package/{src/protocol.ts → dist/protocol.d.ts} +2 -2
  42. package/dist/protocol.d.ts.map +1 -0
  43. package/dist/protocol.js +6 -0
  44. package/dist/protocol.js.map +1 -0
  45. package/dist/providers/adapter.d.ts +137 -0
  46. package/dist/providers/adapter.d.ts.map +1 -0
  47. package/dist/providers/adapter.js +163 -0
  48. package/dist/providers/adapter.js.map +1 -0
  49. package/dist/providers/catalog-data.d.ts +128 -0
  50. package/dist/providers/catalog-data.d.ts.map +1 -0
  51. package/dist/providers/catalog-data.js +397 -0
  52. package/dist/providers/catalog-data.js.map +1 -0
  53. package/dist/providers/catalog.d.ts +63 -0
  54. package/dist/providers/catalog.d.ts.map +1 -0
  55. package/dist/providers/catalog.js +394 -0
  56. package/dist/providers/catalog.js.map +1 -0
  57. package/dist/providers/fake.d.ts +46 -0
  58. package/dist/providers/fake.d.ts.map +1 -0
  59. package/dist/providers/fake.js +234 -0
  60. package/dist/providers/fake.js.map +1 -0
  61. package/dist/providers/openai-compatible.d.ts +65 -0
  62. package/dist/providers/openai-compatible.d.ts.map +1 -0
  63. package/dist/providers/openai-compatible.js +434 -0
  64. package/dist/providers/openai-compatible.js.map +1 -0
  65. package/dist/proxy/responses-mapper.d.ts +366 -0
  66. package/dist/proxy/responses-mapper.d.ts.map +1 -0
  67. package/dist/proxy/responses-mapper.js +517 -0
  68. package/dist/proxy/responses-mapper.js.map +1 -0
  69. package/dist/proxy/responses-server.d.ts +29 -0
  70. package/dist/proxy/responses-server.d.ts.map +1 -0
  71. package/dist/proxy/responses-server.js +360 -0
  72. package/dist/proxy/responses-server.js.map +1 -0
  73. package/dist/router.d.ts +18 -0
  74. package/dist/router.d.ts.map +1 -0
  75. package/dist/router.js +296 -0
  76. package/dist/router.js.map +1 -0
  77. package/dist/schemas.d.ts +560 -0
  78. package/dist/schemas.d.ts.map +1 -0
  79. package/{src/schemas.ts → dist/schemas.js} +83 -103
  80. package/dist/schemas.js.map +1 -0
  81. package/dist/secrets.d.ts +112 -0
  82. package/dist/secrets.d.ts.map +1 -0
  83. package/dist/secrets.js +326 -0
  84. package/dist/secrets.js.map +1 -0
  85. package/dist/types.d.ts +117 -0
  86. package/dist/types.d.ts.map +1 -0
  87. package/dist/types.js +6 -0
  88. package/dist/types.js.map +1 -0
  89. package/dist/usage-file.d.ts +59 -0
  90. package/dist/usage-file.d.ts.map +1 -0
  91. package/dist/usage-file.js +316 -0
  92. package/dist/usage-file.js.map +1 -0
  93. package/dist/usage.d.ts +235 -0
  94. package/dist/usage.d.ts.map +1 -0
  95. package/dist/usage.js +517 -0
  96. package/dist/usage.js.map +1 -0
  97. package/package.json +9 -4
  98. package/src/audit.test.ts +0 -302
  99. package/src/audit.ts +0 -553
  100. package/src/auth/credential-chain.test.ts +0 -326
  101. package/src/auth/credential-chain.ts +0 -235
  102. package/src/auth/index.ts +0 -45
  103. package/src/auth/keychain.test.ts +0 -265
  104. package/src/auth/keychain.ts +0 -168
  105. package/src/auth/oauth-pkce.test.ts +0 -329
  106. package/src/auth/oauth-pkce.ts +0 -571
  107. package/src/auth/oauth-server.test.ts +0 -83
  108. package/src/auth/oauth-server.ts +0 -296
  109. package/src/config.test.ts +0 -479
  110. package/src/config.ts +0 -505
  111. package/src/delegation.test.ts +0 -368
  112. package/src/delegation.ts +0 -605
  113. package/src/index.ts +0 -280
  114. package/src/policy.test.ts +0 -634
  115. package/src/policy.ts +0 -420
  116. package/src/providers/adapter.test.ts +0 -293
  117. package/src/providers/adapter.ts +0 -328
  118. package/src/providers/catalog-data.test.ts +0 -258
  119. package/src/providers/catalog-data.ts +0 -498
  120. package/src/providers/catalog.test.ts +0 -84
  121. package/src/providers/catalog.ts +0 -483
  122. package/src/providers/fake.ts +0 -312
  123. package/src/providers/openai-compatible.test.ts +0 -366
  124. package/src/providers/openai-compatible.ts +0 -554
  125. package/src/proxy/responses-mapper.test.ts +0 -290
  126. package/src/proxy/responses-mapper.ts +0 -736
  127. package/src/proxy/responses-server.test.ts +0 -322
  128. package/src/proxy/responses-server.ts +0 -469
  129. package/src/router.test.ts +0 -699
  130. package/src/router.ts +0 -352
  131. package/src/schemas.test.ts +0 -291
  132. package/src/secrets.test.ts +0 -271
  133. package/src/secrets.ts +0 -461
  134. package/src/types.ts +0 -173
  135. package/src/usage-file.test.ts +0 -243
  136. package/src/usage-file.ts +0 -435
  137. package/src/usage.test.ts +0 -335
  138. package/src/usage.ts +0 -859
  139. package/tsconfig.json +0 -9
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Credential-chain resolution for OffRouter.
3
+ *
4
+ * Tries each source in order: env -> config -> keychain -> (oauth, opt-in).
5
+ * Never logs secret values. Uses Redacted<T> wrapper for safe output.
6
+ * Never scrapes other CLI credential stores.
7
+ */
8
+ import { accountStorageKey, getOAuthTokens, isOAuthTokenExpired, } from "./keychain.js";
9
+ // ---------------------------------------------------------------------------
10
+ // Redacted wrapper
11
+ // ---------------------------------------------------------------------------
12
+ /**
13
+ * Wrapper that hides secret material from JSON serialization and string
14
+ * conversion. The raw value is accessible via `.rawValue` for use in
15
+ * Authorization headers, never for logging.
16
+ */
17
+ export class Redacted {
18
+ #value;
19
+ constructor(value) {
20
+ this.#value = value;
21
+ }
22
+ /** Access the raw secret value. Use only for provider API calls. */
23
+ get rawValue() {
24
+ return this.#value;
25
+ }
26
+ /** Returns a constant redacted string for JSON serialization. */
27
+ toJSON() {
28
+ return "[REDACTED]";
29
+ }
30
+ /** Returns a constant redacted string for debugging. */
31
+ toString() {
32
+ return "[REDACTED]";
33
+ }
34
+ }
35
+ /**
36
+ * Resolve a credential by trying each source in order.
37
+ * Returns the first non-empty value, or null if all sources are empty.
38
+ */
39
+ export async function resolveCredential(sources, opts) {
40
+ for (const source of sources) {
41
+ const value = await trySource(source, opts);
42
+ if (value !== null) {
43
+ return { value: new Redacted(value), source: source.type };
44
+ }
45
+ }
46
+ return null;
47
+ }
48
+ /**
49
+ * Try a single credential source.
50
+ * Returns the raw secret string or null if not found.
51
+ */
52
+ async function trySource(source, opts) {
53
+ switch (source.type) {
54
+ case "env": {
55
+ return tryEnv(source.name);
56
+ }
57
+ case "config": {
58
+ return tryConfig(source.key, opts.config);
59
+ }
60
+ case "keychain": {
61
+ return tryKeychain(source.providerId, opts.store, source.accountId);
62
+ }
63
+ case "oauth": {
64
+ // Resolve stored OAuth tokens. This does NOT trigger a login flow;
65
+ // it resolves tokens already obtained via the `login` command.
66
+ // If the token is expired and a refresher is wired, try refreshing.
67
+ return tryOAuth(source.provider, opts.store, opts.refreshOAuthToken);
68
+ }
69
+ }
70
+ }
71
+ /**
72
+ * Read a value from environment variables.
73
+ */
74
+ function tryEnv(name) {
75
+ const value = process.env[name];
76
+ if (typeof value === "string" && value.trim().length > 0) {
77
+ return value.trim();
78
+ }
79
+ return null;
80
+ }
81
+ /**
82
+ * Read a value from trusted config using dot-notation path.
83
+ * Only reads from config if provided (trusted source).
84
+ * Path format: "providers.{providerId}.apiKey"
85
+ */
86
+ function tryConfig(key, config) {
87
+ if (!config) {
88
+ return null;
89
+ }
90
+ const parts = key.split(".");
91
+ let current = config;
92
+ for (const part of parts) {
93
+ if (typeof current !== "object" || current === null) {
94
+ return null;
95
+ }
96
+ const obj = current;
97
+ if (!(part in obj)) {
98
+ return null;
99
+ }
100
+ current = obj[part];
101
+ }
102
+ if (typeof current === "string" && current.trim().length > 0) {
103
+ return current.trim();
104
+ }
105
+ return null;
106
+ }
107
+ /**
108
+ * Read a value from the secret store (keychain-backed).
109
+ */
110
+ async function tryKeychain(providerId, store, accountId) {
111
+ try {
112
+ const key = accountStorageKey(providerId, accountId);
113
+ const value = await store.get(key);
114
+ if (typeof value === "string" && value.trim().length > 0) {
115
+ return value.trim();
116
+ }
117
+ }
118
+ catch {
119
+ // KeychainUnavailableError or other errors: treat as missing.
120
+ }
121
+ return null;
122
+ }
123
+ /**
124
+ * Resolve a credential from stored OAuth tokens (no new login flow).
125
+ * Returns the access token if valid, triggers refresh if expired + wired,
126
+ * or returns null if no tokens exist or refresh fails.
127
+ */
128
+ async function tryOAuth(providerId, store, refresh) {
129
+ try {
130
+ const tokens = await getOAuthTokens(providerId, store);
131
+ if (!tokens)
132
+ return null;
133
+ if (!isOAuthTokenExpired(tokens)) {
134
+ return tokens.accessToken;
135
+ }
136
+ // Expired: try refresh if a refresher is wired.
137
+ if (!refresh)
138
+ return null;
139
+ try {
140
+ return await refresh(providerId);
141
+ }
142
+ catch {
143
+ return null;
144
+ }
145
+ }
146
+ catch {
147
+ return null;
148
+ }
149
+ }
150
+ //# sourceMappingURL=credential-chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-chain.js","sourceRoot":"","sources":["../../src/auth/credential-chain.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACV,MAAM,CAAI;IAEnB,YAAY,KAAQ;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,oEAAoE;IACpE,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,iEAAiE;IACjE,MAAM;QACJ,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,wDAAwD;IACxD,QAAQ;QACN,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAuDD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAA2B,EAC3B,IAA8B;IAE9B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,EAAE,KAAK,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,E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AE,KAAK,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAEzB,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC,WAAW,CAAC;QAC5B,CAAC;QAED,gDAAgD;QAChD,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAC1B,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Auth module barrel export for OffRouter.
3
+ */
4
+ export { Redacted, resolveCredential, } from "./credential-chain.js";
5
+ export type { CredentialResult, CredentialSource, ResolveCredentialOptions, } from "./credential-chain.js";
6
+ export { deleteOAuthTokens, getOAuthTokens, getProviderToken, isOAuthTokenExpired, setOAuthTokens, setProviderToken, } from "./keychain.js";
7
+ export type { OAuthStoredTokens } from "./keychain.js";
8
+ export { defaultCallbackPort, exchangeCodeForTokens, generateCodeChallenge, generateCodeVerifier, isOAuthProvider, PKCE_CONFIGS, refreshTokens, resolveClientId, runOAuthLogin, startOAuthFlow, } from "./oauth-pkce.js";
9
+ export type { OAuthFlowResult, OAuthFlowState, OAuthProviderConfig, OAuthStartOptions, OAuthTokenOptions, OAuthTokenResponse, RunOAuthLoginOptions, RunOAuthLoginResult, } from "./oauth-pkce.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,QAAQ,EACR,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Auth module barrel export for OffRouter.
3
+ */
4
+ export { Redacted, resolveCredential, } from "./credential-chain.js";
5
+ export { deleteOAuthTokens, getOAuthTokens, getProviderToken, isOAuthTokenExpired, setOAuthTokens, setProviderToken, } from "./keychain.js";
6
+ export { defaultCallbackPort, exchangeCodeForTokens, generateCodeChallenge, generateCodeVerifier, isOAuthProvider, PKCE_CONFIGS, refreshTokens, resolveClientId, runOAuthLogin, startOAuthFlow, } from "./oauth-pkce.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,QAAQ,EACR,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Keychain-backed token helpers for OffRouter.
3
+ *
4
+ * Provides getProviderToken/setProviderToken that use the SecretStore
5
+ * abstraction (file or OS keychain). Never scrapes other CLI credential stores.
6
+ *
7
+ * Per-account token storage: when accountId is provided and differs from
8
+ * providerId, the storage key is "${providerId}:${accountId}". Otherwise the
9
+ * plain providerId is used for backward compatibility with existing tokens.
10
+ */
11
+ import type { SecretStore } from "../secrets.js";
12
+ import { Redacted } from "./credential-chain.js";
13
+ /**
14
+ * Compute the storage key for a provider+account combination.
15
+ * Backward compatible: when accountId is absent or equals providerId, returns
16
+ * the plain providerId so existing tokens resolve.
17
+ */
18
+ export declare function accountStorageKey(providerId: string, accountId?: string): string;
19
+ /**
20
+ * Retrieve a provider token from the secret store.
21
+ * Returns undefined if no token is stored or the store is unavailable.
22
+ */
23
+ export declare function getProviderToken(providerId: string, store: SecretStore, accountId?: string): Promise<Redacted<string> | undefined>;
24
+ /**
25
+ * Store a provider token in the secret store.
26
+ * Throws if the store is unavailable (e.g., KeychainUnavailableError).
27
+ */
28
+ export declare function setProviderToken(providerId: string, token: string, store: SecretStore, accountId?: string): Promise<void>;
29
+ /**
30
+ * Structured OAuth token material stored under "${providerId}[:account]:oauth".
31
+ * accessToken is the bearer used for provider calls; refreshToken drives
32
+ * silent refresh; expiresAt/obtainedAt are epoch milliseconds. Stored as JSON
33
+ * so the whole token set moves atomically and stays separate from API keys.
34
+ */
35
+ export interface OAuthStoredTokens {
36
+ accessToken: string;
37
+ refreshToken?: string;
38
+ expiresAt?: number;
39
+ scope?: string;
40
+ obtainedAt: number;
41
+ }
42
+ /** Compute the secret-store key for a provider+account OAuth token set. */
43
+ export declare function oauthStorageKey(providerId: string, accountId?: string): string;
44
+ /**
45
+ * Store structured OAuth tokens (access, optional refresh, expiry, scope).
46
+ */
47
+ export declare function setOAuthTokens(providerId: string, tokens: OAuthStoredTokens, store: SecretStore, accountId?: string): Promise<void>;
48
+ /**
49
+ * Retrieve structured OAuth tokens. Returns undefined if nothing is stored,
50
+ * the store is unavailable, or the stored payload is corrupt.
51
+ */
52
+ export declare function getOAuthTokens(providerId: string, store: SecretStore, accountId?: string): Promise<OAuthStoredTokens | undefined>;
53
+ /** Remove stored OAuth tokens for a provider+account. */
54
+ export declare function deleteOAuthTokens(providerId: string, store: SecretStore, accountId?: string): Promise<void>;
55
+ /**
56
+ * Returns true when the access token is expired or within the skew window.
57
+ * Tokens without an expiresAt are treated as not expired (no expiry known).
58
+ */
59
+ export declare function isOAuthTokenExpired(tokens: OAuthStoredTokens, now?: number, skewMs?: number): boolean;
60
+ //# sourceMappingURL=keychain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/auth/keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhF;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAWvC;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAGf;AASD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA8BxC;AAED,yDAAyD;AACzD,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,EACzB,GAAG,GAAE,MAAmB,EACxB,MAAM,SAAS,GACd,OAAO,CAKT"}
@@ -0,0 +1,104 @@
1
+ import { Redacted } from "./credential-chain.js";
2
+ /**
3
+ * Compute the storage key for a provider+account combination.
4
+ * Backward compatible: when accountId is absent or equals providerId, returns
5
+ * the plain providerId so existing tokens resolve.
6
+ */
7
+ export function accountStorageKey(providerId, accountId) {
8
+ if (!accountId || accountId === providerId)
9
+ return providerId;
10
+ return `${providerId}:${accountId}`;
11
+ }
12
+ /**
13
+ * Retrieve a provider token from the secret store.
14
+ * Returns undefined if no token is stored or the store is unavailable.
15
+ */
16
+ export async function getProviderToken(providerId, store, accountId) {
17
+ try {
18
+ const key = accountStorageKey(providerId, accountId);
19
+ const value = await store.get(key);
20
+ if (typeof value === "string" && value.length > 0) {
21
+ return new Redacted(value);
22
+ }
23
+ }
24
+ catch {
25
+ // KeychainUnavailableError or other errors: treat as missing.
26
+ }
27
+ return undefined;
28
+ }
29
+ /**
30
+ * Store a provider token in the secret store.
31
+ * Throws if the store is unavailable (e.g., KeychainUnavailableError).
32
+ */
33
+ export async function setProviderToken(providerId, token, store, accountId) {
34
+ const key = accountStorageKey(providerId, accountId);
35
+ await store.set(key, token);
36
+ }
37
+ // ---------------------------------------------------------------------------
38
+ // OAuth token storage (structured, separate from API-key tokens)
39
+ // ---------------------------------------------------------------------------
40
+ /** Suffix that namespaces structured OAuth token blobs in the secret store. */
41
+ const OAUTH_SUFFIX = ":oauth";
42
+ /** Compute the secret-store key for a provider+account OAuth token set. */
43
+ export function oauthStorageKey(providerId, accountId) {
44
+ return `${accountStorageKey(providerId, accountId)}${OAUTH_SUFFIX}`;
45
+ }
46
+ /**
47
+ * Store structured OAuth tokens (access, optional refresh, expiry, scope).
48
+ */
49
+ export async function setOAuthTokens(providerId, tokens, store, accountId) {
50
+ const key = oauthStorageKey(providerId, accountId);
51
+ await store.set(key, JSON.stringify(tokens));
52
+ }
53
+ /**
54
+ * Retrieve structured OAuth tokens. Returns undefined if nothing is stored,
55
+ * the store is unavailable, or the stored payload is corrupt.
56
+ */
57
+ export async function getOAuthTokens(providerId, store, accountId) {
58
+ try {
59
+ const key = oauthStorageKey(providerId, accountId);
60
+ const raw = await store.get(key);
61
+ if (typeof raw !== "string" || raw.length === 0) {
62
+ return undefined;
63
+ }
64
+ const parsed = JSON.parse(raw);
65
+ if (typeof parsed.accessToken !== "string" ||
66
+ parsed.accessToken.length === 0) {
67
+ return undefined;
68
+ }
69
+ return {
70
+ accessToken: parsed.accessToken,
71
+ refreshToken: typeof parsed.refreshToken === "string" && parsed.refreshToken.length > 0
72
+ ? parsed.refreshToken
73
+ : undefined,
74
+ expiresAt: typeof parsed.expiresAt === "number" ? parsed.expiresAt : undefined,
75
+ scope: typeof parsed.scope === "string" ? parsed.scope : undefined,
76
+ obtainedAt: typeof parsed.obtainedAt === "number" ? parsed.obtainedAt : Date.now(),
77
+ };
78
+ }
79
+ catch {
80
+ // Corrupt payload or unavailable store: treat as missing.
81
+ return undefined;
82
+ }
83
+ }
84
+ /** Remove stored OAuth tokens for a provider+account. */
85
+ export async function deleteOAuthTokens(providerId, store, accountId) {
86
+ try {
87
+ const key = oauthStorageKey(providerId, accountId);
88
+ await store.delete(key);
89
+ }
90
+ catch {
91
+ // Unavailable store: nothing to delete.
92
+ }
93
+ }
94
+ /**
95
+ * Returns true when the access token is expired or within the skew window.
96
+ * Tokens without an expiresAt are treated as not expired (no expiry known).
97
+ */
98
+ export function isOAuthTokenExpired(tokens, now = Date.now(), skewMs = 60_000) {
99
+ if (typeof tokens.expiresAt !== "number") {
100
+ return false;
101
+ }
102
+ return now + skewMs >= tokens.expiresAt;
103
+ }
104
+ //# sourceMappingURL=keychain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keychain.js","sourceRoot":"","sources":["../../src/auth/keychain.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB,EAAE,SAAkB;IACtE,IAAI,CAAC,SAAS,IAAI,SAAS,KAAK,UAAU;QAAE,OAAO,UAAU,CAAC;IAC9D,OAAO,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAAkB,EAClB,KAAkB,EAClB,SAAkB;IAElB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,iBAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACrD,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,OAAO,KAAK,KA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CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,wCAAwC;IAC1C,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAyB,EACzB,MAAc,IAAI,CAAC,GAAG,EAAE,EACxB,MAAM,GAAG,MAAM;IAEf,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,GAAG,GAAG,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,138 @@
1
+ import type { SecretStore } from "../secrets.js";
2
+ import { Redacted } from "./credential-chain.js";
3
+ /**
4
+ * Generate a random code verifier for PKCE (RFC 7636).
5
+ * Length is between 43 and 128 characters.
6
+ */
7
+ export declare function generateCodeVerifier(): string;
8
+ /**
9
+ * Generate a S256 code challenge from a verifier (RFC 7636).
10
+ * Uses Web Crypto API (available in Node >= 22, Workers, browsers).
11
+ */
12
+ export declare function generateCodeChallenge(verifier: string): Promise<string>;
13
+ export interface OAuthProviderConfig {
14
+ authorizeUrl: string;
15
+ tokenUrl: string;
16
+ scopes: string[];
17
+ defaultClientId?: string;
18
+ clientIdEnvVar?: string;
19
+ }
20
+ /**
21
+ * OAuth PKCE configurations for supported providers.
22
+ * Only Anthropic and OpenAI/Codex are supported.
23
+ * Gemini/xAI/Z.ai are API-key only.
24
+ */
25
+ export declare const PKCE_CONFIGS: Record<string, OAuthProviderConfig>;
26
+ /**
27
+ * Returns true if the provider supports OAuth (opt-in).
28
+ */
29
+ export declare function isOAuthProvider(providerId: string): boolean;
30
+ /**
31
+ * In-memory session data associated with a PKCE nonce.
32
+ * Never serialised into the caller-visible state string.
33
+ */
34
+ export interface OAuthSession {
35
+ codeVerifier: string;
36
+ redirectUri: string;
37
+ createdAt: number;
38
+ }
39
+ /**
40
+ * Retrieve and delete a session by nonce (one-shot consume).
41
+ * Returns null if the nonce is unknown, already consumed, or expired.
42
+ */
43
+ export declare function consumeOAuthSession(nonce: string): OAuthSession | null;
44
+ /**
45
+ * Cancel / discard a session without consuming it.
46
+ */
47
+ export declare function cancelOAuthSession(nonce: string): void;
48
+ export interface OAuthFlowState {
49
+ provider: string;
50
+ nonce: string;
51
+ }
52
+ export interface OAuthFlowResult {
53
+ authorizeUrl: string;
54
+ state: string;
55
+ }
56
+ export interface OAuthTokenResponse {
57
+ accessToken: Redacted<string>;
58
+ refreshToken?: Redacted<string>;
59
+ expiresIn?: number;
60
+ scope?: string;
61
+ }
62
+ export interface OAuthStartOptions {
63
+ redirectUri: string;
64
+ /** Override client ID (default from env or PKCE_CONFIGS). */
65
+ clientId?: string;
66
+ }
67
+ export interface OAuthTokenOptions {
68
+ store: SecretStore;
69
+ fetch?: typeof globalThis.fetch;
70
+ }
71
+ /**
72
+ * Create an OAuth state string that encodes provider metadata.
73
+ * Used to validate the callback matches the initiated flow.
74
+ */
75
+ export declare function createOAuthState(provider: string): string;
76
+ /**
77
+ * Start an OAuth PKCE flow for the given provider.
78
+ * Returns the authorization URL and state for redirect.
79
+ * Never auto-triggers; requires explicit user configuration.
80
+ */
81
+ export declare function startOAuthFlow(provider: string, options: OAuthStartOptions): Promise<OAuthFlowResult>;
82
+ /**
83
+ * Exchange an authorization code for tokens.
84
+ * Called after the user completes the OAuth flow in their browser.
85
+ */
86
+ export declare function exchangeCodeForTokens(provider: string, code: string, statePayload: string, options: OAuthTokenOptions): Promise<OAuthTokenResponse>;
87
+ /**
88
+ * Return the default callback port for a provider, or 0 (OS-assigned).
89
+ */
90
+ export declare function defaultCallbackPort(provider: string): number;
91
+ /**
92
+ * Resolve the client id for a provider from process env (or a provided env
93
+ * override). Returns undefined if the env var is not set.
94
+ */
95
+ export declare function resolveClientId(provider: string, env?: NodeJS.ProcessEnv): string | undefined;
96
+ export interface RunOAuthLoginOptions {
97
+ provider: string;
98
+ store: SecretStore;
99
+ /** Override client id (else resolved from env / PKCE_CONFIGS). */
100
+ clientId?: string;
101
+ /** Loopback port (defaults to provider default or 0). */
102
+ port?: number;
103
+ /** Wait timeout in ms (default 5 min). */
104
+ timeoutMs?: number;
105
+ /** Called with the authorize URL once built (test/display). */
106
+ onAuthorizeUrl?: (url: string) => void;
107
+ /** Best-effort browser open (non-throwing). */
108
+ openBrowser?: (url: string) => Promise<boolean> | boolean;
109
+ /** Injectable fetch (tests). */
110
+ fetch?: typeof globalThis.fetch;
111
+ /** Optional abort signal. */
112
+ signal?: AbortSignal;
113
+ }
114
+ export interface RunOAuthLoginResult {
115
+ provider: string;
116
+ redirectUri: string;
117
+ expiresAt?: number;
118
+ scope?: string;
119
+ }
120
+ /**
121
+ * Run the full OAuth PKCE login flow:
122
+ * 1. Start a local callback server on 127.0.0.1
123
+ * 2. Build the authorize URL with PKCE challenge + state
124
+ * 3. Notify caller (onAuthorizeUrl) and attempt browser open
125
+ * 4. Wait for the provider callback (code + state)
126
+ * 5. Exchange code for tokens
127
+ * 6. Store structured tokens in the secret store
128
+ * 7. Clean up the server
129
+ */
130
+ export declare function runOAuthLogin(opts: RunOAuthLoginOptions): Promise<RunOAuthLoginResult>;
131
+ /**
132
+ * Refresh an OAuth token using a refresh token.
133
+ * Updates the stored tokens on success.
134
+ */
135
+ export declare function refreshTokens(provider: string, refreshToken: string, store: SecretStore, options?: {
136
+ fetch?: typeof globalThis.fetch;
137
+ }): Promise<OAuthTokenResponse>;
138
+ //# sourceMappingURL=oauth-pkce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-pkce.d.ts","sourceRoot":"","sources":["../../src/auth/oauth-pkce.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAWjD;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAA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