@adonis-agora/agent 0.94.0 → 0.95.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 (144) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/assets/spa/assets/{index-DUq09Q_k.js → index-DBu17cDY.js} +1 -1
  3. package/dist/assets/spa/index.html +1 -1
  4. package/dist/providers/poppy_connections_provider.d.ts +1 -1
  5. package/dist/providers/poppy_connections_provider.js +1 -1
  6. package/dist/providers/poppy_provider.d.ts +1 -1
  7. package/dist/providers/poppy_provider.d.ts.map +1 -1
  8. package/dist/providers/poppy_provider.js +6 -6
  9. package/dist/providers/poppy_provider.js.map +1 -1
  10. package/dist/src/index.d.ts +1 -1
  11. package/dist/src/index.js +1 -1
  12. package/dist/src/mcp/auth.d.ts +3 -3
  13. package/dist/src/mcp/auth.d.ts.map +1 -1
  14. package/dist/src/mcp/auth.js +2 -29
  15. package/dist/src/mcp/auth.js.map +1 -1
  16. package/dist/src/mcp/discovery.d.ts +3 -3
  17. package/dist/src/mcp/discovery.d.ts.map +1 -1
  18. package/dist/src/mcp/discovery.js +2 -2
  19. package/dist/src/poppy/auth.d.ts +20 -16
  20. package/dist/src/poppy/auth.d.ts.map +1 -1
  21. package/dist/src/poppy/auth.js.map +1 -1
  22. package/dist/src/poppy/conversations.d.ts +25 -25
  23. package/dist/src/poppy/conversations.d.ts.map +1 -1
  24. package/dist/src/poppy/conversations.js +37 -37
  25. package/dist/src/poppy/conversations.js.map +1 -1
  26. package/dist/src/poppy/define_config.d.ts +7 -7
  27. package/dist/src/poppy/define_config.d.ts.map +1 -1
  28. package/dist/src/poppy/define_config.js +1 -1
  29. package/dist/src/poppy/endpoints.d.ts +2 -2
  30. package/dist/src/poppy/endpoints.js +1 -1
  31. package/dist/src/poppy/handler.d.ts +5 -5
  32. package/dist/src/poppy/handler.d.ts.map +1 -1
  33. package/dist/src/poppy/handler.js +23 -21
  34. package/dist/src/poppy/handler.js.map +1 -1
  35. package/dist/src/poppy/index.d.ts +2 -2
  36. package/dist/src/poppy/index.d.ts.map +1 -1
  37. package/dist/src/poppy/index.js +1 -1
  38. package/dist/src/poppy/index.js.map +1 -1
  39. package/dist/src/poppy/protocol.d.ts +30 -23
  40. package/dist/src/poppy/protocol.d.ts.map +1 -1
  41. package/dist/src/poppy/protocol.js +16 -17
  42. package/dist/src/poppy/protocol.js.map +1 -1
  43. package/dist/src/poppy/redis-store.d.ts +1 -1
  44. package/dist/src/poppy/redis-store.js +1 -1
  45. package/dist/src/poppy/store.d.ts +7 -7
  46. package/dist/src/poppy/store.js +1 -1
  47. package/dist/src/poppy-client/api.d.ts +5 -4
  48. package/dist/src/poppy-client/api.d.ts.map +1 -1
  49. package/dist/src/poppy-client/api.js +14 -9
  50. package/dist/src/poppy-client/api.js.map +1 -1
  51. package/dist/src/poppy-client/browser.d.ts +12 -18
  52. package/dist/src/poppy-client/browser.d.ts.map +1 -1
  53. package/dist/src/poppy-client/browser.js +33 -73
  54. package/dist/src/poppy-client/browser.js.map +1 -1
  55. package/dist/src/poppy-client/cli/main.d.ts.map +1 -1
  56. package/dist/src/poppy-client/cli/main.js +48 -56
  57. package/dist/src/poppy-client/cli/main.js.map +1 -1
  58. package/dist/src/poppy-client/company.d.ts +43 -28
  59. package/dist/src/poppy-client/company.d.ts.map +1 -1
  60. package/dist/src/poppy-client/company.js +216 -160
  61. package/dist/src/poppy-client/company.js.map +1 -1
  62. package/dist/src/poppy-client/conversations.d.ts +12 -13
  63. package/dist/src/poppy-client/conversations.d.ts.map +1 -1
  64. package/dist/src/poppy-client/conversations.js +24 -22
  65. package/dist/src/poppy-client/conversations.js.map +1 -1
  66. package/dist/src/poppy-client/discovery.d.ts +32 -10
  67. package/dist/src/poppy-client/discovery.d.ts.map +1 -1
  68. package/dist/src/poppy-client/discovery.js +134 -68
  69. package/dist/src/poppy-client/discovery.js.map +1 -1
  70. package/dist/src/poppy-client/dpop.d.ts +2 -1
  71. package/dist/src/poppy-client/dpop.d.ts.map +1 -1
  72. package/dist/src/poppy-client/dpop.js +2 -1
  73. package/dist/src/poppy-client/dpop.js.map +1 -1
  74. package/dist/src/poppy-client/errors.d.ts +5 -4
  75. package/dist/src/poppy-client/errors.d.ts.map +1 -1
  76. package/dist/src/poppy-client/errors.js +5 -4
  77. package/dist/src/poppy-client/errors.js.map +1 -1
  78. package/dist/src/poppy-client/http.d.ts +4 -2
  79. package/dist/src/poppy-client/http.d.ts.map +1 -1
  80. package/dist/src/poppy-client/http.js +9 -5
  81. package/dist/src/poppy-client/http.js.map +1 -1
  82. package/dist/src/poppy-client/identity.d.ts +15 -15
  83. package/dist/src/poppy-client/identity.d.ts.map +1 -1
  84. package/dist/src/poppy-client/identity.js +17 -33
  85. package/dist/src/poppy-client/identity.js.map +1 -1
  86. package/dist/src/poppy-client/index.d.ts +6 -3
  87. package/dist/src/poppy-client/index.d.ts.map +1 -1
  88. package/dist/src/poppy-client/index.js +6 -3
  89. package/dist/src/poppy-client/index.js.map +1 -1
  90. package/dist/src/poppy-client/llm.js +4 -4
  91. package/dist/src/poppy-client/llm.js.map +1 -1
  92. package/dist/src/poppy-client/mcp.d.ts +3 -4
  93. package/dist/src/poppy-client/mcp.d.ts.map +1 -1
  94. package/dist/src/poppy-client/mcp.js +26 -38
  95. package/dist/src/poppy-client/mcp.js.map +1 -1
  96. package/dist/src/poppy-client/safe_fetch.d.ts +30 -0
  97. package/dist/src/poppy-client/safe_fetch.d.ts.map +1 -0
  98. package/dist/src/poppy-client/safe_fetch.js +210 -0
  99. package/dist/src/poppy-client/safe_fetch.js.map +1 -0
  100. package/dist/src/poppy-client/session_jwt.d.ts +20 -0
  101. package/dist/src/poppy-client/session_jwt.d.ts.map +1 -0
  102. package/dist/src/poppy-client/session_jwt.js +37 -0
  103. package/dist/src/poppy-client/session_jwt.js.map +1 -0
  104. package/dist/src/poppy-client/signin.d.ts +34 -11
  105. package/dist/src/poppy-client/signin.d.ts.map +1 -1
  106. package/dist/src/poppy-client/signin.js +134 -80
  107. package/dist/src/poppy-client/signin.js.map +1 -1
  108. package/dist/src/poppy-client/store.d.ts +23 -11
  109. package/dist/src/poppy-client/store.d.ts.map +1 -1
  110. package/dist/src/poppy-client/store.js +1 -1
  111. package/dist/src/poppy-client/store.js.map +1 -1
  112. package/dist/src/poppy-client/task_coverage.d.ts +13 -0
  113. package/dist/src/poppy-client/task_coverage.d.ts.map +1 -0
  114. package/dist/src/poppy-client/task_coverage.js +66 -0
  115. package/dist/src/poppy-client/task_coverage.js.map +1 -0
  116. package/dist/src/poppy-client/token_client.d.ts +36 -33
  117. package/dist/src/poppy-client/token_client.d.ts.map +1 -1
  118. package/dist/src/poppy-client/token_client.js +47 -47
  119. package/dist/src/poppy-client/token_client.js.map +1 -1
  120. package/dist/src/poppy-client/types.d.ts +81 -42
  121. package/dist/src/poppy-client/types.d.ts.map +1 -1
  122. package/dist/src/poppy-client/types.js +1 -1
  123. package/dist/src/poppy-client/util.d.ts +12 -3
  124. package/dist/src/poppy-client/util.d.ts.map +1 -1
  125. package/dist/src/poppy-client/util.js +29 -9
  126. package/dist/src/poppy-client/util.js.map +1 -1
  127. package/dist/src/poppy-connections/config.d.ts +2 -2
  128. package/dist/src/poppy-connections/config.js +1 -1
  129. package/dist/src/poppy-connections/config.js.map +1 -1
  130. package/dist/src/poppy-connections/crypto.d.ts +2 -2
  131. package/dist/src/poppy-connections/crypto.js +2 -2
  132. package/dist/src/poppy-connections/index.d.ts +1 -1
  133. package/dist/src/poppy-connections/index.js +1 -1
  134. package/dist/src/poppy-connections/service.d.ts +11 -10
  135. package/dist/src/poppy-connections/service.d.ts.map +1 -1
  136. package/dist/src/poppy-connections/service.js +33 -21
  137. package/dist/src/poppy-connections/service.js.map +1 -1
  138. package/dist/src/poppy-connections/store.d.ts +2 -2
  139. package/dist/src/poppy-connections/tools.d.ts.map +1 -1
  140. package/dist/src/poppy-connections/tools.js +5 -4
  141. package/dist/src/poppy-connections/tools.js.map +1 -1
  142. package/package.json +6 -6
  143. package/skills/agent-governance/SKILL.md +3 -3
  144. package/skills/agent-tools/SKILL.md +3 -3
@@ -1,10 +1,14 @@
1
- import { discover, HttpJsonCache } from './discovery.js';
1
+ import { discover, HttpJsonCache, protectedResourceMetadataUrl, } from './discovery.js';
2
2
  import { DpopKey } from './dpop.js';
3
- import { ConversationError, OAuthError, PoppyError, ResourceAuthError } from './errors.js';
3
+ import { ConversationError, DiscoveryError, OAuthError, PoppyError, ResourceAuthError, } from './errors.js';
4
4
  import { PoppyHttp, readJson } from './http.js';
5
5
  import { generateEs256Key } from './keys.js';
6
+ import { companyFetch } from './safe_fetch.js';
7
+ import { signSessionJwt } from './session_jwt.js';
6
8
  import { TokenClient } from './token_client.js';
7
- import { randomId, scopeSet, wwwAuthError } from './util.js';
9
+ import { nowSeconds, randomId, requireSecureUrl, scopeSet, wwwAuthError, } from './util.js';
10
+ /** The protocol version `CompanyState` is written for. */
11
+ const STATE_PROTOCOL = '0.3';
8
12
  /** Entry point: one agent identity, one local state file, one local user. */
9
13
  export class PoppyAgent {
10
14
  opts;
@@ -15,7 +19,7 @@ export class PoppyAgent {
15
19
  this.opts = opts;
16
20
  this.profile = opts.profile ?? 'default';
17
21
  this.http = new PoppyHttp({
18
- fetch: opts.fetch,
22
+ fetch: opts.fetch ?? companyFetch(opts.insecureDev),
19
23
  log: opts.log,
20
24
  maxRetryAfterSeconds: opts.maxRetryAfterSeconds,
21
25
  });
@@ -29,32 +33,43 @@ export class PoppyAgent {
29
33
  log(line) {
30
34
  this.opts.log?.(line);
31
35
  }
32
- /** Discovers a Company and loads (or creates) this user's state there. */
36
+ /** Discovers a Company and loads (or creates) this user's state there, by its identifier. */
33
37
  async company(domain) {
34
38
  const discovered = await discover(domain, {
35
39
  fetch: this.http.fetch,
36
40
  insecureDev: this.opts.insecureDev,
37
41
  cache: this.cache,
38
42
  });
39
- if (!discovered.document.auth || !discovered.metadata) {
40
- throw new PoppyError('no_auth', `${discovered.domain} publishes no auth: it can only be browsed as an ordinary website (section 5)`);
41
- }
42
- const issuer = discovered.document.auth.issuer;
43
+ const { identifier } = discovered;
43
44
  const companies = this.store.profile(this.profile).companies;
44
- let state = companies[issuer];
45
+ const org = discovered.document.organization.domain.toLowerCase();
46
+ if (discovered.noIssuer === 'not_found') {
47
+ // 3.2: a 404 doesn't explicitly say that an issuer we know was removed.
48
+ const known = Object.values(companies).find((c) => c.hasIssuer && c.domains.includes(org));
49
+ if (known) {
50
+ throw new DiscoveryError('issuer_unavailable', `${org} no longer publishes the issuer ${known.issuer}; not falling back to its domain`);
51
+ }
52
+ }
53
+ let state = companies[identifier];
45
54
  if (!state) {
46
55
  state = {
47
- issuer,
56
+ issuer: identifier,
48
57
  domains: [],
49
- // 4.2: opaque, random, per Company. Never derived from personal information.
58
+ // 5.1: opaque, random, per Company. Never derived from personal information.
50
59
  userId: randomId('usr_'),
51
60
  dpopKey: await generateEs256Key(),
52
61
  tokens: {},
53
62
  conversations: {},
54
63
  };
55
- companies[issuer] = state;
64
+ companies[identifier] = state;
56
65
  }
57
- const org = discovered.document.organization.domain.toLowerCase();
66
+ // A state from before Draft 0.3: its tokens and Session belong to a protocol that's gone.
67
+ if (state.protocol !== STATE_PROTOCOL) {
68
+ state.protocol = STATE_PROTOCOL;
69
+ state.tokens = {};
70
+ state.sessionId = undefined;
71
+ }
72
+ state.hasIssuer = discovered.metadata !== undefined;
58
73
  if (!state.domains.includes(org))
59
74
  state.domains.push(org);
60
75
  await this.store.save();
@@ -62,35 +77,47 @@ export class PoppyAgent {
62
77
  }
63
78
  }
64
79
  const EXPIRY_SKEW_MS = 30_000;
80
+ /** Get a new delegation when this little of the last one is left. */
81
+ const DELEGATION_RENEW_SECONDS = 3600;
82
+ const DEFAULT_TOKEN_KEY = 'default';
65
83
  function tokenKey(opts) {
66
- if (opts.bearer)
67
- return `bearer|${opts.resource ?? ''}|${opts.scope ?? ''}`;
68
- if (!opts.scope && !opts.resource)
69
- return 'dpop';
70
- return `dpop|${opts.resource ?? ''}|${opts.scope ?? ''}`;
84
+ if (!opts.scope && !opts.resource && !opts.bearer)
85
+ return DEFAULT_TOKEN_KEY;
86
+ return `${opts.resource ?? ''}|${opts.scope ?? ''}|${opts.bearer ? 'bearer' : ''}`;
71
87
  }
72
- /** One User at one Company: Sessions, Account Token, and authenticated requests. */
88
+ /** One User at one Company: the Session, the refresh token, and requests to its endpoints. */
73
89
  export class CompanyClient {
74
90
  agent;
75
91
  discovered;
76
92
  state;
77
- tokens;
78
93
  dpop;
94
+ #tokens;
95
+ /** Each service's `resource`, or `null` when the default token works there (4.5). */
96
+ #resources = new Map();
97
+ #refreshing = Promise.resolve();
79
98
  constructor(agent, discovered, state) {
80
99
  this.agent = agent;
81
100
  this.discovered = discovered;
82
101
  this.state = state;
83
- this.tokens = new TokenClient(agent.identity, discovered.metadata, agent.http, agent.opts.tokenClient);
84
102
  this.dpop = new DpopKey(state.dpopKey);
85
103
  }
104
+ /** The Company's OAuth calls. A Company without an issuer offers no sign-in (3.2). */
105
+ get tokens() {
106
+ if (!this.discovered.metadata) {
107
+ throw new PoppyError('no_issuer', `${this.discovered.domain} has no OAuth issuer: it offers only signed-out Sessions`);
108
+ }
109
+ this.#tokens ??= new TokenClient(this.agent.identity, this.discovered.metadata, this.agent.http);
110
+ return this.#tokens;
111
+ }
86
112
  get document() {
87
113
  return this.discovered.document;
88
114
  }
89
115
  get metadata() {
90
- return this.discovered.metadata;
116
+ return this.tokens.metadata;
91
117
  }
118
+ /** The Company's identifier (3.2): its issuer, or its HTTPS domain without one. */
92
119
  get issuer() {
93
- return this.document.auth.issuer;
120
+ return this.discovered.identifier;
94
121
  }
95
122
  get userId() {
96
123
  return this.state.userId;
@@ -102,212 +129,237 @@ export class CompanyClient {
102
129
  return { insecureDev: this.agent.opts.insecureDev };
103
130
  }
104
131
  get accountToken() {
105
- const a = this.state.accountToken;
106
- if (a?.expiresAt && a.expiresAt <= Date.now())
107
- return undefined;
108
- return a;
132
+ return this.state.accountToken;
133
+ }
134
+ /** The current Session's `sid`, chosen here at random (5.2). */
135
+ get sessionId() {
136
+ this.state.sessionId ??= randomId('', 16);
137
+ return this.state.sessionId;
109
138
  }
110
139
  async save() {
111
140
  await this.agent.store.save();
112
141
  }
113
- /** Forget the current Session; the next request starts a new one. */
142
+ /** Stops using the current `sid`; the next request starts a new Session (5.5). */
114
143
  async newSession() {
115
144
  this.state.sessionId = undefined;
116
- this.state.tokens = {};
117
145
  await this.save();
118
146
  }
147
+ /** Sends a proof with token requests when the issuer's metadata lists ES256 (4.5). */
148
+ tokenDpop() {
149
+ const algs = this.metadata.dpop_signing_alg_values_supported;
150
+ return Array.isArray(algs) && algs.includes('ES256') ? this.dpop : undefined;
151
+ }
152
+ /** The delegated key of this User ID, with a live delegation (5.2). */
153
+ async #delegation() {
154
+ const current = this.state.delegation;
155
+ if (current && current.exp - nowSeconds() > DELEGATION_RENEW_SECONDS)
156
+ return current;
157
+ const key = await generateEs256Key();
158
+ const { jwt, exp } = await this.agent.identity.delegate(key.publicJwk);
159
+ this.state.delegation = { key, jwt, exp };
160
+ await this.save();
161
+ return this.state.delegation;
162
+ }
163
+ /** A `Poppy-Session` JWT good for this one request (5.2). */
164
+ async sessionJwt(method, url, accessToken) {
165
+ const { key, jwt } = await this.#delegation();
166
+ return signSessionJwt({
167
+ key,
168
+ delegation: jwt,
169
+ clientId: this.agent.identity.clientId,
170
+ audience: this.issuer,
171
+ sid: this.sessionId,
172
+ userId: this.userId,
173
+ method,
174
+ url,
175
+ accessToken,
176
+ });
177
+ }
119
178
  /**
120
- * A valid Session Token. Starts a Session if there is none (signed in if an Account Token
121
- * exists, 4.8), renews it when it is close to expiry, and handles `invalid_session`,
122
- * `account_mismatch` and a revoked Account Token (`invalid_grant`) as 4.2/4.8/4.9 describe.
179
+ * An access token, refreshed when close to expiry, or `null` when signed out. A refresh answered
180
+ * with `invalid_grant` means the sign-in is gone: the Session continues signed out (5.5).
123
181
  */
124
182
  async token(opts = {}) {
183
+ if (!this.accountToken)
184
+ return null;
125
185
  const key = tokenKey(opts);
126
186
  const rec = this.state.tokens[key];
127
- if (rec &&
128
- !opts.forceRenew &&
129
- rec.sessionId === this.state.sessionId &&
130
- rec.expiresAt - EXPIRY_SKEW_MS > Date.now()) {
187
+ if (rec && !opts.forceRenew && rec.expiresAt - EXPIRY_SKEW_MS > Date.now())
131
188
  return rec;
132
- }
133
- // Narrower and Bearer tokens are for an existing Session (4.3), so make sure there is one.
134
- if (key !== 'dpop' && !this.state.sessionId)
135
- await this.token();
136
- const resp = await this.issue(opts);
137
- return this.record(key, resp, opts.resource);
189
+ // One at a time: with rotation, a second refresh would present a token the first replaced.
190
+ const run = this.#refreshing.then(() => this.#refresh(key, opts));
191
+ this.#refreshing = run.catch(() => { });
192
+ return run;
138
193
  }
139
- async issue(opts) {
140
- const dpop = opts.bearer ? undefined : this.dpop;
141
- const narrowing = { scope: opts.scope, resource: opts.resource };
194
+ async #refresh(key, opts) {
142
195
  const acct = this.accountToken;
143
- if (acct) {
144
- try {
145
- return await this.tokens.refresh({
146
- refreshToken: acct.refreshToken,
147
- sessionId: this.state.sessionId,
148
- dpop,
149
- ...narrowing,
150
- });
151
- }
152
- catch (e) {
153
- if (!(e instanceof OAuthError))
154
- throw e;
155
- if (e.code === 'invalid_grant') {
156
- // 4.8/4.9: expired, revoked, or the User disconnected us. Continue signed out.
157
- this.agent.log('Account Token rejected (invalid_grant); continuing signed out');
158
- this.state.accountToken = undefined;
159
- await this.save();
160
- }
161
- else if ((e.code === 'invalid_session' || e.code === 'account_mismatch') &&
162
- this.state.sessionId) {
163
- this.agent.log(`${e.code}: starting a new Session`);
164
- await this.newSession();
165
- return this.tokens.refresh({ refreshToken: acct.refreshToken, dpop, ...narrowing });
166
- }
167
- else {
168
- throw e;
169
- }
170
- }
171
- }
196
+ if (!acct)
197
+ return null;
198
+ let resp;
172
199
  try {
173
- return await this.tokens.jwtBearer({
174
- userId: this.userId,
175
- sessionId: this.state.sessionId,
176
- dpop,
177
- ...narrowing,
200
+ resp = await this.tokens.refresh({
201
+ refreshToken: acct.refreshToken,
202
+ grantedScope: acct.scope,
203
+ dpop: opts.bearer ? undefined : this.tokenDpop(),
204
+ scope: opts.scope,
205
+ resource: opts.resource,
178
206
  });
179
207
  }
180
208
  catch (e) {
181
- if (e instanceof OAuthError && e.code === 'invalid_session' && this.state.sessionId) {
182
- this.agent.log('invalid_session: starting a new Session');
183
- await this.newSession();
184
- return this.tokens.jwtBearer({ userId: this.userId, dpop, ...narrowing });
185
- }
186
- throw e;
187
- }
188
- }
189
- async record(key, resp, resource) {
190
- if (resp.session_id !== this.state.sessionId) {
191
- // A different Session: tokens of the old one don't apply any more.
209
+ if (!(e instanceof OAuthError) || e.code !== 'invalid_grant')
210
+ throw e;
211
+ this.agent.log('refresh token rejected (invalid_grant); continuing signed out');
212
+ this.state.accountToken = undefined;
192
213
  this.state.tokens = {};
193
- this.state.sessionId = resp.session_id;
214
+ await this.save();
215
+ return null;
194
216
  }
195
- if (resp.refresh_token && this.state.accountToken) {
196
- // 4.8: the Company rotated the Account Token; MUST use the new one from now on.
197
- this.state.accountToken = {
198
- ...this.state.accountToken,
199
- refreshToken: resp.refresh_token,
200
- expiresAt: typeof resp.refresh_token_expires_in === 'number'
201
- ? Date.now() + resp.refresh_token_expires_in * 1000
202
- : this.state.accountToken.expiresAt,
203
- };
204
- }
205
- const rec = {
217
+ // 4.4: a new refresh token MUST replace the old one; none means keep using it.
218
+ if (resp.refresh_token)
219
+ acct.refreshToken = resp.refresh_token;
220
+ const fresh = {
206
221
  accessToken: resp.access_token,
207
222
  tokenType: resp.token_type,
208
- expiresAt: Date.now() + resp.expires_in * 1000,
223
+ expiresAt: Date.now() + (resp.expires_in ?? 0) * 1000,
209
224
  scope: resp.scope ?? '',
210
- sessionId: resp.session_id,
211
- signedIn: resp.signed_in,
212
- resource,
225
+ resource: opts.resource,
213
226
  };
214
- this.state.tokens[key] = rec;
227
+ this.state.tokens[key] = fresh;
215
228
  await this.save();
216
- return rec;
229
+ return fresh;
217
230
  }
218
- /** Stores the result of any sign-in type (4.4): Account Token + signed-in Session Token. */
231
+ /** Stores the result of any sign-in type (4.7): the refresh token and the access token. */
219
232
  async applySignIn(resp, via, requestedScope) {
220
233
  if (!resp.refresh_token) {
221
234
  throw new OAuthError('invalid_response', {
222
- description: 'sign-in returned no Account Token',
235
+ description: 'sign-in returned no refresh token',
223
236
  });
224
237
  }
225
238
  const old = this.state.accountToken;
239
+ const scope = resp.scope ?? requestedScope;
226
240
  this.state.accountToken = {
227
241
  refreshToken: resp.refresh_token,
228
- scope: resp.scope ?? '',
242
+ scope,
229
243
  obtainedAt: Date.now(),
230
- expiresAt: typeof resp.refresh_token_expires_in === 'number'
231
- ? Date.now() + resp.refresh_token_expires_in * 1000
232
- : undefined,
233
244
  via,
234
245
  };
235
- this.state.tokens = {};
236
- this.state.sessionId = resp.session_id;
237
- this.state.tokens.dpop = {
238
- accessToken: resp.access_token,
239
- tokenType: resp.token_type,
240
- expiresAt: Date.now() + resp.expires_in * 1000,
241
- scope: resp.scope ?? '',
242
- sessionId: resp.session_id,
243
- signedIn: resp.signed_in,
246
+ this.state.tokens = {
247
+ [DEFAULT_TOKEN_KEY]: {
248
+ accessToken: resp.access_token,
249
+ tokenType: resp.token_type,
250
+ expiresAt: Date.now() + (resp.expires_in ?? 0) * 1000,
251
+ scope,
252
+ },
244
253
  };
245
254
  await this.save();
246
255
  if (old && old.refreshToken !== resp.refresh_token) {
247
- // 4.4: the new Account Token replaces the old one, which we SHOULD revoke.
256
+ // 4.7: the new refresh token replaces the old one, which we SHOULD revoke. Not a sign-out.
248
257
  try {
249
258
  await this.tokens.revoke(old.refreshToken);
250
259
  }
251
260
  catch (e) {
252
- this.agent.log(`could not revoke the replaced Account Token: ${e.message}`);
261
+ this.agent.log(`could not revoke the replaced refresh token: ${e.message}`);
253
262
  }
254
263
  }
255
- const granted = scopeSet(resp.scope);
264
+ const granted = scopeSet(scope);
256
265
  return {
257
- grantedScope: resp.scope ?? '',
266
+ grantedScope: scope,
258
267
  missingScopes: [...scopeSet(requestedScope)].filter((s) => !granted.has(s)),
259
- sessionId: resp.session_id,
260
268
  };
261
269
  }
262
- /** Sign out (4.9): revoke the Account Token. Sessions carry on signed out. */
270
+ /** Sign out (5.5): revoke the refresh token. Sessions carry on signed out. */
263
271
  async signOut() {
264
272
  const acct = this.state.accountToken;
265
273
  if (!acct)
266
274
  return false;
267
275
  await this.tokens.revoke(acct.refreshToken, 'refresh_token');
268
276
  this.state.accountToken = undefined;
269
- // Signed-in Session Tokens may still be valid; drop them so the next request renews
270
- // with the agent's assertion and gets a signed-out token (4.9).
271
277
  this.state.tokens = {};
272
278
  await this.save();
273
279
  return true;
274
280
  }
275
- /** A Bearer Session Token for one MCP server (4.3 "Bearer tokens"). */
276
- async bearerFor(resource, forceRenew = false) {
277
- return (await this.token({ bearer: true, resource, forceRenew })).accessToken;
281
+ /**
282
+ * The `resource` a service asks tokens for (4.5): its protected resource metadata, when it names
283
+ * something other than the domain. Otherwise the default token works there.
284
+ */
285
+ async #resourceOf(service, refresh = false) {
286
+ const known = this.#resources.get(service);
287
+ if (known !== undefined && !refresh)
288
+ return known ?? undefined;
289
+ let resource = null;
290
+ const url = protectedResourceMetadataUrl(service);
291
+ requireSecureUrl(url.toString(), 'protected resource metadata', this.security);
292
+ const res = await this.http.request(url.toString(), {
293
+ headers: { accept: 'application/json' },
294
+ redirect: 'manual',
295
+ });
296
+ if (res.ok) {
297
+ const doc = await readJson(res);
298
+ const domain = new URL(this.discovered.wellKnownUrl).origin;
299
+ if (typeof doc?.resource === 'string' && doc.resource !== domain)
300
+ resource = doc.resource;
301
+ }
302
+ else {
303
+ await res.body?.cancel().catch(() => { });
304
+ }
305
+ this.#resources.set(service, resource);
306
+ return resource ?? undefined;
278
307
  }
279
308
  /**
280
- * An API or conversation request with `Authorization: DPoP` + a proof (4.3). Retries once
281
- * with a renewed token on `invalid_token`, and once with the Account Token on
282
- * `sign_in_required` when the current token is signed out but an Account Token exists.
309
+ * A request to one of the Company's APIs or endpoints: the Session header and, when signed in, an
310
+ * access token (5.2, 4.5). `invalid_session` starts a new Session once (section 7), and
311
+ * `invalid_token` refreshes once, falling back to signed out when the sign-in is gone (5.5).
283
312
  */
284
313
  async fetch(url, init = {}) {
285
- const { scope, resource, ...rest } = init;
286
- let rec = await this.token({ scope, resource });
287
- for (let attempt = 0;; attempt++) {
314
+ const { scope, service, bearer, signedOut, ...rest } = init;
315
+ const method = (rest.method ?? 'GET').toUpperCase();
316
+ const wantsAccount = !signedOut && this.accountToken !== undefined;
317
+ let resource = init.resource;
318
+ if (wantsAccount && resource === undefined && service) {
319
+ resource = await this.#resourceOf(service);
320
+ }
321
+ delete rest.resource;
322
+ let forceRenew = false;
323
+ let sessionRetried = false;
324
+ let tokenRetried = false;
325
+ for (;;) {
326
+ const rec = wantsAccount ? await this.token({ scope, resource, bearer, forceRenew }) : null;
327
+ forceRenew = false;
328
+ const scheme = rec?.tokenType.toLowerCase() === 'dpop' ? 'DPoP' : 'Bearer';
288
329
  const res = await this.http.request(url, {
289
330
  ...rest,
290
- dpop: this.dpop,
291
- accessToken: rec.accessToken,
292
- scheme: 'DPoP',
331
+ method,
332
+ session: () => this.sessionJwt(method, url, rec?.accessToken),
333
+ ...(rec ? { accessToken: rec.accessToken, scheme } : {}),
334
+ ...(scheme === 'DPoP' && rec ? { dpop: this.dpop } : {}),
293
335
  });
294
- if (attempt > 0)
295
- return res;
296
- const err = wwwAuthError(res.headers.get('www-authenticate'));
297
- if (res.status === 401 && (!err.error || err.error === 'invalid_token')) {
298
- rec = await this.token({ scope, resource, forceRenew: true });
299
- continue;
336
+ if (res.status === 400 && !sessionRetried) {
337
+ const body = await readJson(res.clone());
338
+ if (body?.error === 'invalid_session') {
339
+ sessionRetried = true;
340
+ this.agent.log('invalid_session: starting a new Session');
341
+ await res.body?.cancel().catch(() => { });
342
+ await this.newSession();
343
+ continue;
344
+ }
300
345
  }
301
- // A signed-out token, or a signed-in one whose Session was signed out meanwhile (4.4
302
- // "How sign-in is remembered"): the Account Token signs the Session (back) in.
303
- if (res.status === 403 && err.error === 'sign_in_required' && this.accountToken) {
304
- rec = await this.token({ scope, resource, forceRenew: true });
305
- continue;
346
+ if (res.status === 401 && rec && !tokenRetried) {
347
+ const err = wwwAuthError(res.headers.get('www-authenticate'));
348
+ if (err.error === 'invalid_token') {
349
+ tokenRetried = true;
350
+ await res.body?.cancel().catch(() => { });
351
+ // Stale metadata: the service says which `resource` it wants (4.5).
352
+ if (err.resourceMetadata && service && init.resource === undefined) {
353
+ resource = await this.#resourceOf(service, true);
354
+ }
355
+ forceRenew = true;
356
+ continue;
357
+ }
306
358
  }
307
359
  return res;
308
360
  }
309
361
  }
310
- /** `fetch` + JSON, mapping failures to typed errors (section 6, 7.13). */
362
+ /** `fetch` + JSON, mapping failures to typed errors (section 7, 8.13). */
311
363
  async json(url, init = {}) {
312
364
  const res = await this.fetch(url, init);
313
365
  if (!res.ok)
@@ -315,11 +367,15 @@ export class CompanyClient {
315
367
  return { status: res.status, body: (await readJson(res)) };
316
368
  }
317
369
  }
318
- /** Maps a failed resource response to a typed error. */
370
+ /**
371
+ * Maps a failed resource response to a typed error. A challenge without an error code means the
372
+ * request needs the account: it's handled as `insufficient_scope` (section 7).
373
+ */
319
374
  export async function throwForResponse(res) {
320
- const auth = wwwAuthError(res.headers.get('www-authenticate'));
321
- if (auth.error) {
322
- throw new ResourceAuthError(auth.error, {
375
+ const header = res.headers.get('www-authenticate');
376
+ const auth = wwwAuthError(header);
377
+ if (auth.error || (res.status === 401 && header)) {
378
+ throw new ResourceAuthError(auth.error ?? 'insufficient_scope', {
323
379
  status: res.status,
324
380
  scope: auth.scope,
325
381
  description: auth.description,
@@ -1 +1 @@
1
- {"version":3,"file":"company.js","sourceRoot":"","sources":["../../../src/poppy-client/company.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,E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