@framers/agentos-ext-gmail-source 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -4
- package/dist/GmailOAuthFlow.d.ts +21 -6
- package/dist/GmailOAuthFlow.d.ts.map +1 -1
- package/dist/GmailOAuthFlow.js +66 -19
- package/dist/GmailOAuthFlow.js.map +1 -1
- package/dist/GmailSourceConnector.d.ts +161 -0
- package/dist/GmailSourceConnector.d.ts.map +1 -0
- package/dist/GmailSourceConnector.js +465 -0
- package/dist/GmailSourceConnector.js.map +1 -0
- package/dist/gmail.d.ts +25 -4
- package/dist/gmail.d.ts.map +1 -1
- package/dist/gmail.js +38 -15
- package/dist/gmail.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/sync.d.ts +66 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +145 -0
- package/dist/sync.js.map +1 -0
- package/manifest.json +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Gmail source
|
|
2
2
|
|
|
3
|
-
This library provides read-only Gmail authorization on the AgentOS redirect grant and sealed-token contracts, text helpers that sanitize and trim mail before it is stored (see Text ingestion below), a bounded mapper that turns one thread response into a sanitized source document (see Thread documents below),
|
|
3
|
+
This library provides read-only Gmail authorization on the AgentOS redirect grant and sealed-token contracts, text helpers that sanitize and trim mail before it is stored (see Text ingestion below), a bounded mapper that turns one thread response into a sanitized source document (see Thread documents below), a capped read-only API client that sends every call through the host's quota and grant services (see Read-only API below), and a connector that binds them to durable account-source synchronization (see Connector and durable synchronization below). It requests the sole Gmail read-only scope, offline access and incremental consent. It exports no send, reply, label-modification or attachment-download tool.
|
|
4
4
|
|
|
5
|
-
Install it next to `@framers/agentos` 0.13.
|
|
5
|
+
Install it next to `@framers/agentos` 0.13.146 or later, whose HTML loader strips tags in linear time, and `@framers/agentos-ext-account-sources` 0.7.0 or later. Both are peer dependencies with a floor and no upper bound. Node.js 20.19 or later is required.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import { GmailOAuthFlow } from '@framers/agentos-ext-gmail-source';
|
|
@@ -30,9 +30,9 @@ Construct `GmailOAuthFlow(client, store, options)` on the server. `client` conta
|
|
|
30
30
|
|
|
31
31
|
`begin({ redirectUri })` returns the authorization URL, state and PKCE verifier. Keep state and verifier under a short-lived, single-use record tied to the signed-in account. `complete(input)` checks state, exchanges the code and verifies the granted scope and refresh material. It returns credentials in memory and does not persist them. The host must atomically consume the start and recheck account liveness and generation before installing the sealed grant. Do not log callback URLs, credentials or errors from arbitrary provider middleware.
|
|
32
32
|
|
|
33
|
-
Construct a flow for each scheduled token operation, with that operation's sealed store and abort signal, call `accessToken`, and discard the flow at the end of the operation. A store scoped to one operation must never be retained for another worker. The host's durable lifecycle owns disconnect, purge, refresh exclusion across workers and revocation. `forget` on an independently held flow is not a cross-worker lifecycle operation.
|
|
33
|
+
Construct a flow for each scheduled token operation, with that operation's sealed store and abort signal, call `accessToken`, and discard the flow at the end of the operation. A store scoped to one operation must never be retained for another worker. The host's durable lifecycle owns disconnect, purge, refresh exclusion across workers and revocation. `forget` on an independently held flow is not a cross-worker lifecycle operation. `accessToken` checks the read-only scope, before Google is asked, on the grant its own call read in the key's turn, the one a refresh renews, so neither another writer between two reads nor calls for other keys can change its outcome; a token held in memory is used only while the store holds the grant it came with, refresh token and scope alike.
|
|
34
34
|
|
|
35
|
-
OAuth responses are capped at 65,536 bytes and must finish within 15 seconds. Parent cancellation stops dispatch and body consumption. Fixed `GmailOAuthFault` reasons contain no provider message or credential. When an exchange succeeds and `complete` does not return the grant, because the grant fails the checks or because the parent cancelled before `complete` returned, the flow asks Google to revoke the grant before it throws. That revocation has the same byte cap and a 15-second deadline of its own, and the parent's cancellation does not stop it. The fault's `cleanup` field then reads `confirmed` or `unconfirmed`. An unconfirmed outcome needs a provider-permission removal instruction. It does not authorize retaining the grant.
|
|
35
|
+
OAuth responses are capped at 65,536 bytes and must finish within 15 seconds. An answer past the cap is refused at once: the rest of Google's stream is cancelled without waiting for the cancellation to settle, and the Gmail API's answers are read the same way. Parent cancellation stops dispatch and body consumption. `revoke(token)` resolves when Google revokes the token, and when Google answers that the token is already expired or revoked: Google answers such a token with 400 and `invalid_token`, where RFC 7009 section 2.2 answers 200, and either way the token no longer works. So the revoke-only queue confirms the revocation of a grant the person already removed at Google rather than retrying it to its deadline and then asking for a permission removal. Revoke a grant's refresh token to end the grant: Google answers an expired access token the same way while its refresh token stays valid. Every other answer that is not a success throws `OAuthGrantRefused` with reason `revoke`. Fixed `GmailOAuthFault` reasons contain no provider message or credential. When an exchange succeeds and `complete` does not return the grant, because the grant fails the checks or because the parent cancelled before `complete` returned, the flow asks Google to revoke the grant before it throws. That revocation has the same byte cap and a 15-second deadline of its own, and the parent's cancellation does not stop it. The fault's `cleanup` field then reads `confirmed` or `unconfirmed`; Google's answer that the grant is already expired or revoked reads `confirmed`. An unconfirmed outcome needs a provider-permission removal instruction. It does not authorize retaining the grant.
|
|
36
36
|
|
|
37
37
|
The host supplies informed consent, cache permission, retention policy, account isolation and a truthful availability state. Authorization alone does not establish permission to store or send mailbox content to a model. Do not infer those permissions from this package's successful tests.
|
|
38
38
|
|
|
@@ -129,6 +129,46 @@ const changes = await api.history(profile.historyId, 100, null, signal); // { ki
|
|
|
129
129
|
|
|
130
130
|
One provider operation makes one attempt, with one fresh-token retry permitted after 401. Every HTTP dispatch is separately metered. Token refreshes also use the one-unit profile reservation as conservative local accounting; this does not assert a Gmail quota cost for the OAuth endpoint. The durable account-source coordinator owns retry episodes, exponential backoff and exhaustion. The client persists provider waits through the quota service and never sleeps or buys capacity. A quota deferral, or a start that missed the quota's send window, sends nothing and throws `rate_limited` with the time to try again; only a reused attempt id is `invalid_response`. A retry time the client hands back is always after its own clock, even when the quota's database clock lags it; give the client the clock the host's sync store reads (`Date.now` for both unless given). Unknown errors become fixed failures without retaining their messages or causes.
|
|
131
131
|
|
|
132
|
+
Each operation refreshes the grant unless the client has a `tokenHolder`: a memory-only `{ current: null }` slot that the clients of one sync lease share. A held access token is reused only while `currentHandle` answers the lease it was obtained under (the same connection, generation and lease token) and that lease has not expired by the client's clock; a 401 drops it, and the repeat refreshes as before. A reused token skips the grant operation, so check the sync handle before and after each call, as the connector does. Give each lease a new holder and never persist or log it. `GmailSourceConnector` makes one for each connector, so a sync cycle refreshes the grant once.
|
|
133
|
+
|
|
132
134
|
A canonical thread 404 means gone. History 404 means the history anchor expired and bounded recovery is required. Domain policy is a fixed failure. Missing or explicitly invalid grants and insufficient scope are passed to the coordinator's fenced grant-loss lifecycle. Client configuration errors and transient network/provider failures are not reported as revoked mailboxes. Oversized successful thread responses are counted skips; oversized control pages fail without a cursor advance. Response streams are capped before decoding and are cancelled on size, deadline or caller cancellation.
|
|
133
135
|
|
|
134
136
|
The client performs no storage write, purge, logging, model request or attachment fetch. Its successful result is still untrusted source material and needs the host's fresh owner/generation/expiry checks before storage, preparation or delivery. Limits are defensive library policy, not provider maxima; hosts must record any live compatibility failure before changing them.
|
|
137
|
+
|
|
138
|
+
## Connector and durable synchronization
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { runGmailSourceSync, verifyGmailSource } from '@framers/agentos-ext-gmail-source';
|
|
142
|
+
|
|
143
|
+
const options = {
|
|
144
|
+
scope, // the connection's tenant, owner and connection ids
|
|
145
|
+
coordinator: { store, prepare, clock }, // the released AccountSourceSync options without provider and lifecycle
|
|
146
|
+
revocations, // the host's SourceRevocations on the same tables
|
|
147
|
+
connector: {
|
|
148
|
+
api: { client, quota, projectKey: 'project-1', bounds, limits }, // as for GmailApi, without the handle and keys
|
|
149
|
+
mailbox, // the host's private identity binding: key(handle) and accept(handle, address)
|
|
150
|
+
bootstrapQuotaKey, // a stable keyed hash for the owner, never an address
|
|
151
|
+
permission: async (request) => cachePermission, // the evidenced permission for a read, or null
|
|
152
|
+
sourceDetailUrl: (scope, sourceId) => detailPath(sourceId), // an authenticated relative path, never a Gmail link
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// Once, after the host installed the grant and recorded its generation as grant-ready.
|
|
157
|
+
const verification = await verifyGmailSource(options, generation, signal); // { kind: 'verified' }, or why not
|
|
158
|
+
// Each scheduled or requested sync. The run's connector is disposed when the run ends.
|
|
159
|
+
const result = await runGmailSourceSync(options, 'scheduled', signal);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
`GmailSourceConnector(options)` implements the original selected-id account-source interface and exposes the additive `sync` provider. It performs no document commit. Supply the released SQL sync store, revocation service, API configuration, dynamic current-handle getter, private mailbox binding, cache-permission callback, trusted relative detail-path builder and a stable opaque owner probe key. Every network operation uses the existing grant and quota services. The API clients it builds for one lease share one access token in memory, so a sync cycle refreshes the grant once; a 401 or a new lease refreshes it again, and disposal drops it. Never capture the first handle in a getter: source application can refresh the owner ticket.
|
|
163
|
+
|
|
164
|
+
The mailbox binding is server-only. Both callbacks run under the exact handle's transaction through the released store. `key(handle)` reads the existing stable mailbox key or returns null before initial acceptance. `accept(handle, address)` compares or atomically creates the host's private identity binding and returns its stable key; null refuses the identity. It cannot replace an existing identity on reconnect. Store any display address sealed, never in a source, telemetry field or URL. The initial profile is charged to a stable owner probe key; all content uses the accepted mailbox key. The shared project budget applies to both.
|
|
165
|
+
|
|
166
|
+
The connector verifies the mailbox before its first content operation even when a resumed coordinator skips `begin`. A fresh `begin` reads a new profile anchor before enumeration. Raw profile identity is passed only to the private binding. The connector retains no profile address. Each cycle can hold one sanitized label snapshot under its independent response expiry. Expired or refused names are omitted without repeated label requests. Cancellation, failure, cycle/generation changes and disposal clear the snapshot. Call `dispose()` in a finally block for direct use.
|
|
167
|
+
|
|
168
|
+
The original `list`, `read` and `changesSince` methods operate only on selected ids, bounded by the smaller retained and per-lease changed-item allowance and a hard ceiling of 100. Empty ids never enumerate a mailbox. Initial selected changes capture an anchor before reading the selection. Incremental selected changes drain bounded history and then reread only selected changed ids. A partial history, expired anchor, retry, skipped read or stale fence returns no successful cursor. Only a canonical missing thread is reported as removed. An empty selection with a null cursor returns an empty-string sentinel which must never be used with a nonempty selection or persisted as a provider history id.
|
|
169
|
+
|
|
170
|
+
Use `runGmailSourceSync(options, trigger, signal?)` for durable ingestion. Its options supply scope, coordinator configuration without a provider/lifecycle, the revocation service and connector configuration without a store/current-handle/clock/revocation service. The function constructs the released account-source coordinator, supplies this connector's sync provider and disposes the connector when the run ends. The coordinator alone owns candidate bounds, work persistence, retry episodes, history completion, reconciliation and generation-fenced application. A returned document is always passed through the released store's current policy and expiry checks. Do not persist a facade SourceRead directly and lose the full sync document's cache/provenance envelope.
|
|
171
|
+
|
|
172
|
+
After a host atomically installs a candidate sealed grant under an authenticated one-use start, transitions that same generation to grant-ready and records pending identity verification, it may call `verifyGmailSource(options, expectedGeneration, signal?)`. This claims a real lease, verifies the profile, binds identity and releases the lease without fetching content or advancing any cursor. Busy means another lease exists, not identity approval. A scheduled worker also verifies identity before content. Failed or cancelled authorization cannot install a grant after its generation was fenced. Hosts must clean up exchanged grants that could not be installed. Never create a synthetic handle to bypass the grant service.
|
|
173
|
+
|
|
174
|
+
`revoke()` invokes the released immediate fence/purge lifecycle and disposes the connector. Provider confirmation is a separate status from the revocation service; the account-independent queue worker performs that request. Run maintenance and expiry even while polling is paused. All source-derived results retain private ownership and deletion/expiry restrictions. This package exposes no send, reply, attachment download or general URL fetch.
|
package/dist/GmailOAuthFlow.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @fileoverview Google's read-only Gmail grant on the AgentOS redirect OAuth flow: the read-only scope alone, asked for
|
|
3
3
|
* offline and incrementally with consent, for registered callbacks only; granted scopes and refresh material checked
|
|
4
4
|
* before a grant is accepted; every token and revocation call capped at 65,536 bytes, bounded by one 15-second
|
|
5
|
-
* deadline and stopped by the caller's cancellation, except the revocation of a grant the flow will not hand back.
|
|
5
|
+
* deadline and stopped by the caller's cancellation, except the revocation of a grant the flow will not hand back. A
|
|
6
|
+
* token Google answers as already expired or revoked counts as revoked.
|
|
6
7
|
* @module agentos-ext-gmail-source/GmailOAuthFlow
|
|
7
8
|
*/
|
|
8
9
|
import { RedirectOAuthFlow, type IOAuthTokenStore, type OAuthTokenSet, type RedirectOAuthConfig, type RedirectBegin, type RedirectCompleteInput } from '@framers/agentos/auth';
|
|
@@ -22,6 +23,8 @@ export declare class GmailOAuthFlow extends RedirectOAuthFlow {
|
|
|
22
23
|
private readonly signal?;
|
|
23
24
|
/** The fetch and stand-in endpoints of a withheld grant's revocation, without the caller's signal. */
|
|
24
25
|
private readonly withheld;
|
|
26
|
+
/** Each `accessToken` call's own record of what its read of the store found. */
|
|
27
|
+
private readonly reads;
|
|
25
28
|
/**
|
|
26
29
|
* @param client The dedicated client and its registered callback addresses (one to sixteen).
|
|
27
30
|
* @param store Where the grant is kept, a namespaced `SealedTokenStore` on a server; null for a flow that only
|
|
@@ -60,19 +63,31 @@ export declare class GmailOAuthFlow extends RedirectOAuthFlow {
|
|
|
60
63
|
*/
|
|
61
64
|
private revokeWithheld;
|
|
62
65
|
/**
|
|
63
|
-
* Refreshes
|
|
64
|
-
*
|
|
66
|
+
* Refreshes the grant the core flow has just read in the key's turn for this `accessToken` call, once that read is
|
|
67
|
+
* found to hold the read-only scope alone (any other grant, or a refresh outside such a call, throws `scope` before
|
|
68
|
+
* Google is asked), then checks the answer: a scope it returns must be the read-only scope alone, and a refresh token
|
|
69
|
+
* it returns must be usable. An omitted scope keeps the kept grant's checked scope.
|
|
65
70
|
*/
|
|
66
71
|
protected refreshTokens(refreshToken: string): Promise<OAuthTokenSet>;
|
|
67
72
|
/** Keeps an accepted grant under `key` after the exchange's checks; the store receives its refresh token and scope. */
|
|
68
73
|
keep(key: string, tokens: OAuthTokenSet): Promise<void>;
|
|
69
74
|
/**
|
|
70
75
|
* An access token for the grant kept under `key`, refreshed when needed, only while the kept scope is the read-only
|
|
71
|
-
* scope alone.
|
|
72
|
-
*
|
|
76
|
+
* scope alone. Each call checks the scope of the grant its own read answered in the key's turn, the one a refresh
|
|
77
|
+
* renews, so neither another writer between two reads nor calls for other keys can change its outcome. A token held
|
|
78
|
+
* in memory is used only while the store holds the grant it came with, refresh token and scope alike, and a held grant
|
|
79
|
+
* always holds the read-only scope alone. Throws `OAuthGrantRefused` with reason `missing` when nothing is kept or the
|
|
80
|
+
* grant changes during the refresh, and with reason `refresh` when Google refuses it; `GmailOAuthFault` `scope` when
|
|
81
|
+
* the kept grant holds another scope.
|
|
73
82
|
*/
|
|
74
83
|
accessToken(key: string): Promise<string>;
|
|
75
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Revokes a token at Google. It resolves when Google revokes the token, and when Google answers that the token is
|
|
86
|
+
* already expired or revoked (400 with `invalid_token`), as RFC 7009 section 2.2 answers 200 for an invalid token:
|
|
87
|
+
* either way the token no longer works. Revoke a grant's refresh token to end the grant; Google answers an expired
|
|
88
|
+
* access token the same way while its refresh token stays valid. Any other answer that is not a success throws
|
|
89
|
+
* `OAuthGrantRefused` with reason `revoke`, the status and Google's error when it is an allowlisted OAuth error code.
|
|
90
|
+
*/
|
|
76
91
|
revoke(token: string): Promise<void>;
|
|
77
92
|
}
|
|
78
93
|
//# sourceMappingURL=GmailOAuthFlow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GmailOAuthFlow.d.ts","sourceRoot":"","sources":["../src/GmailOAuthFlow.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"GmailOAuthFlow.d.ts","sourceRoot":"","sources":["../src/GmailOAuthFlow.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,iBAAiB,EAAqB,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAC/E,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,qBAAqB,EACzE,MAAM,uBAAuB,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,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKxD;;;;;;OAMG;IACY,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUpD"}
|
package/dist/GmailOAuthFlow.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* @fileoverview Google's read-only Gmail grant on the AgentOS redirect OAuth flow: the read-only scope alone, asked for
|
|
3
3
|
* offline and incrementally with consent, for registered callbacks only; granted scopes and refresh material checked
|
|
4
4
|
* before a grant is accepted; every token and revocation call capped at 65,536 bytes, bounded by one 15-second
|
|
5
|
-
* deadline and stopped by the caller's cancellation, except the revocation of a grant the flow will not hand back.
|
|
5
|
+
* deadline and stopped by the caller's cancellation, except the revocation of a grant the flow will not hand back. A
|
|
6
|
+
* token Google answers as already expired or revoked counts as revoked.
|
|
6
7
|
* @module agentos-ext-gmail-source/GmailOAuthFlow
|
|
7
8
|
*/
|
|
9
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
8
10
|
import { RedirectOAuthFlow, OAuthGrantRefused, } from '@framers/agentos/auth';
|
|
9
11
|
import { readCapped, ReadCapExceeded } from '@framers/agentos-ext-account-sources';
|
|
10
12
|
import { GMAIL_READONLY_SCOPE, GmailOAuthFault, } from './types.js';
|
|
@@ -92,7 +94,8 @@ function abortable(work, signal, stopped, discard) {
|
|
|
92
94
|
function cancel(response) { void response.body?.cancel().catch(() => { }); }
|
|
93
95
|
/**
|
|
94
96
|
* Reads a body through the released byte cap. The bridge stream turns the signal's abort into a fixed fault, even
|
|
95
|
-
* while no bytes arrive, and passes a cancellation
|
|
97
|
+
* while no bytes arrive, and passes a cancellation on to the provider's stream without waiting for it to settle, so the
|
|
98
|
+
* cap's refusal and the deadline never wait on a stream whose cancellation does not end.
|
|
96
99
|
*/
|
|
97
100
|
async function boundedBody(response, signal, stopped) {
|
|
98
101
|
if (signal.aborted) {
|
|
@@ -136,10 +139,8 @@ async function boundedBody(response, signal, stopped) {
|
|
|
136
139
|
}
|
|
137
140
|
}
|
|
138
141
|
},
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
catch { /* No provider text escapes. */ } },
|
|
142
|
+
// Asked for, not awaited: `readCapped` awaits this cancellation before it throws past the cap.
|
|
143
|
+
cancel() { closed = true; void reader.cancel().catch(() => { }); },
|
|
143
144
|
});
|
|
144
145
|
try {
|
|
145
146
|
return await readCapped(new Response(bridge, { headers: response.headers }), maxBytes);
|
|
@@ -226,6 +227,33 @@ function normalize(tokens, refreshRequired, scopeRequired) {
|
|
|
226
227
|
return { accessToken: tokens.accessToken, refreshToken: tokens.refreshToken, expiresAt: tokens.expiresAt,
|
|
227
228
|
metadata: scope === undefined ? undefined : { scope: GMAIL_READONLY_SCOPE } };
|
|
228
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* The caller's store as the core flow reads it. A read made for an `accessToken` call notes on that call's own record
|
|
232
|
+
* whether the grant it answered holds the read-only scope alone. The core reads the grant and refreshes it in the key's
|
|
233
|
+
* turn, within the call, so the refresh checks the very grant it renews, whatever other calls read meanwhile. The
|
|
234
|
+
* record ends with its call; a read made for `forget` notes nothing.
|
|
235
|
+
*/
|
|
236
|
+
function notingStore(store, reads) {
|
|
237
|
+
return {
|
|
238
|
+
async load(key) {
|
|
239
|
+
const kept = await store.load(key);
|
|
240
|
+
const read = reads.getStore();
|
|
241
|
+
if (read !== undefined)
|
|
242
|
+
read.scopeOnly = kept !== null && scopeOnly(kept.metadata?.scope);
|
|
243
|
+
return kept;
|
|
244
|
+
},
|
|
245
|
+
save: (key, tokens) => store.save(key, tokens),
|
|
246
|
+
clear: (key) => store.clear(key),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/** The `error` code an answer's JSON object names, and undefined for any other body. */
|
|
250
|
+
async function answeredError(response) {
|
|
251
|
+
const parsed = await response.json().catch(() => undefined);
|
|
252
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
253
|
+
return undefined;
|
|
254
|
+
const { error } = parsed;
|
|
255
|
+
return typeof error === 'string' ? error : undefined;
|
|
256
|
+
}
|
|
229
257
|
/**
|
|
230
258
|
* Google's read-only Gmail grant on the core redirect flow. `begin` asks for the read-only scope alone, offline, with
|
|
231
259
|
* incremental authorization and consent, for a registered callback; `complete` accepts only that scope with refresh
|
|
@@ -241,6 +269,8 @@ export class GmailOAuthFlow extends RedirectOAuthFlow {
|
|
|
241
269
|
signal;
|
|
242
270
|
/** The fetch and stand-in endpoints of a withheld grant's revocation, without the caller's signal. */
|
|
243
271
|
withheld;
|
|
272
|
+
/** Each `accessToken` call's own record of what its read of the store found. */
|
|
273
|
+
reads;
|
|
244
274
|
/**
|
|
245
275
|
* @param client The dedicated client and its registered callback addresses (one to sixteen).
|
|
246
276
|
* @param store Where the grant is kept, a namespaced `SealedTokenStore` on a server; null for a flow that only
|
|
@@ -250,7 +280,9 @@ export class GmailOAuthFlow extends RedirectOAuthFlow {
|
|
|
250
280
|
*/
|
|
251
281
|
constructor(client, store, options = {}) {
|
|
252
282
|
const chosen = selectedEndpoints(options);
|
|
253
|
-
|
|
283
|
+
const reads = new AsyncLocalStorage();
|
|
284
|
+
super(store === null ? null : notingStore(store, reads), oauthFetch(options, chosen));
|
|
285
|
+
this.reads = reads;
|
|
254
286
|
if (!tokenString(client.clientId) || !tokenString(client.clientSecret)
|
|
255
287
|
|| !Array.isArray(client.redirectUris) || client.redirectUris.length === 0 || client.redirectUris.length > 16) {
|
|
256
288
|
throw new GmailOAuthFault('configuration');
|
|
@@ -337,11 +369,15 @@ export class GmailOAuthFlow extends RedirectOAuthFlow {
|
|
|
337
369
|
}
|
|
338
370
|
}
|
|
339
371
|
/**
|
|
340
|
-
* Refreshes
|
|
341
|
-
*
|
|
372
|
+
* Refreshes the grant the core flow has just read in the key's turn for this `accessToken` call, once that read is
|
|
373
|
+
* found to hold the read-only scope alone (any other grant, or a refresh outside such a call, throws `scope` before
|
|
374
|
+
* Google is asked), then checks the answer: a scope it returns must be the read-only scope alone, and a refresh token
|
|
375
|
+
* it returns must be usable. An omitted scope keeps the kept grant's checked scope.
|
|
342
376
|
*/
|
|
343
377
|
async refreshTokens(refreshToken) {
|
|
344
378
|
this.active();
|
|
379
|
+
if (this.reads.getStore()?.scopeOnly !== true)
|
|
380
|
+
throw new GmailOAuthFault('scope');
|
|
345
381
|
const tokens = normalize(await super.refreshTokens(refreshToken), false, false);
|
|
346
382
|
this.active();
|
|
347
383
|
return tokens;
|
|
@@ -354,28 +390,39 @@ export class GmailOAuthFlow extends RedirectOAuthFlow {
|
|
|
354
390
|
}
|
|
355
391
|
/**
|
|
356
392
|
* An access token for the grant kept under `key`, refreshed when needed, only while the kept scope is the read-only
|
|
357
|
-
* scope alone.
|
|
358
|
-
*
|
|
393
|
+
* scope alone. Each call checks the scope of the grant its own read answered in the key's turn, the one a refresh
|
|
394
|
+
* renews, so neither another writer between two reads nor calls for other keys can change its outcome. A token held
|
|
395
|
+
* in memory is used only while the store holds the grant it came with, refresh token and scope alike, and a held grant
|
|
396
|
+
* always holds the read-only scope alone. Throws `OAuthGrantRefused` with reason `missing` when nothing is kept or the
|
|
397
|
+
* grant changes during the refresh, and with reason `refresh` when Google refuses it; `GmailOAuthFault` `scope` when
|
|
398
|
+
* the kept grant holds another scope.
|
|
359
399
|
*/
|
|
360
400
|
async accessToken(key) {
|
|
361
401
|
this.active();
|
|
362
402
|
if (this.store === null)
|
|
363
403
|
throw new GmailOAuthFault('configuration');
|
|
364
|
-
const
|
|
365
|
-
if (saved === null)
|
|
366
|
-
throw new OAuthGrantRefused('missing');
|
|
367
|
-
if (!scopeOnly(saved.metadata?.scope))
|
|
368
|
-
throw new GmailOAuthFault('scope');
|
|
369
|
-
const token = await super.accessToken(key);
|
|
404
|
+
const token = await this.reads.run({}, () => super.accessToken(key));
|
|
370
405
|
this.active();
|
|
371
406
|
return token;
|
|
372
407
|
}
|
|
373
|
-
/**
|
|
408
|
+
/**
|
|
409
|
+
* Revokes a token at Google. It resolves when Google revokes the token, and when Google answers that the token is
|
|
410
|
+
* already expired or revoked (400 with `invalid_token`), as RFC 7009 section 2.2 answers 200 for an invalid token:
|
|
411
|
+
* either way the token no longer works. Revoke a grant's refresh token to end the grant; Google answers an expired
|
|
412
|
+
* access token the same way while its refresh token stays valid. Any other answer that is not a success throws
|
|
413
|
+
* `OAuthGrantRefused` with reason `revoke`, the status and Google's error when it is an allowlisted OAuth error code.
|
|
414
|
+
*/
|
|
374
415
|
async revoke(token) {
|
|
375
416
|
this.active();
|
|
376
417
|
if (!tokenString(token))
|
|
377
418
|
throw new GmailOAuthFault('configuration');
|
|
378
|
-
await
|
|
419
|
+
const response = await this.fetchImpl(this.endpoints.revoke, { method: 'POST',
|
|
420
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ token }).toString() });
|
|
421
|
+
if (!response.ok) {
|
|
422
|
+
const error = await answeredError(response);
|
|
423
|
+
if (response.status !== 400 || error !== 'invalid_token')
|
|
424
|
+
throw new OAuthGrantRefused('revoke', response.status, error);
|
|
425
|
+
}
|
|
379
426
|
this.active();
|
|
380
427
|
}
|
|
381
428
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GmailOAuthFlow.js","sourceRoot":"","sources":["../src/GmailOAuthFlow.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,iBAAiB,EAAE,iBAAiB,GAErC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EACL,oBAAoB,EAAE,eAAe,GAEtC,MAAM,YAAY,CAAC;AAEpB,yEAAyE;AACzE,MAAM,SAAS,GAAwB,MAAM,CAAC,MAAM,CAAC;IACnD,aAAa,EAAE,8CAA8C;IAC7D,KAAK,EAAE,qCAAqC;IAC5C,MAAM,EAAE,sCAAsC;CAC/C,CAAC,CAAC;AACH,+CAA+C;AA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,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QAAC,OAAO,KAAK,CAAC;IACpG,CAAC;IACD;;;;;;OAMG;IACM,KAAK,CAAC,MAAM,CAAC,KAAa;QACjC,IAAI,CAAC,MAAM,EAAE,CAAC;QAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,eAAe,CAAC,eAAe,CAAC,CAAC;QACnF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM;YAC3E,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,EAAE,EAAE,IAAI,EAAE,IAAI,eAAe,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACvH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,KAAK,KAAK,eAAe;gBAAE,MAAM,IAAI,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC1H,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { type ResumableAccountSourceConnector, type AccountSourceSyncProvider, type SourceSelection, type SourceItem, type SourceRead, type SourceGone, type SourceChanges, type SourceSyncRequest, type SourceSyncScope, type SourceSyncHandle, type SourceSyncSkipReason, type SourceCachePermission, type SqlAccountSourceSyncStore, type SourceRevocations } from '@framers/agentos-ext-account-sources';
|
|
2
|
+
import { type GmailApiOptions } from './gmail.js';
|
|
3
|
+
/** All callbacks are server-only and use the exact current handle's owner transaction. */
|
|
4
|
+
export interface GmailMailboxBinding {
|
|
5
|
+
/** Return the stable opaque mailbox key, or null before first profile acceptance. */
|
|
6
|
+
key(handle: SourceSyncHandle): Promise<string | null>;
|
|
7
|
+
/** Compare or create the private identity binding; null refuses any content access. */
|
|
8
|
+
accept(handle: SourceSyncHandle, emailAddress: string): Promise<string | null>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* What a `GmailSourceConnector` is built from: trusted server configuration and the host's released account-source
|
|
12
|
+
* services, never values from a browser request.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam Prepared - The host's prepared-document type of its sync store and revocation service.
|
|
15
|
+
*/
|
|
16
|
+
export interface GmailSourceConnectorOptions<Prepared = unknown> {
|
|
17
|
+
/**
|
|
18
|
+
* The API client's configuration without the values the connector supplies itself: the current handle, the quota
|
|
19
|
+
* key of the mailbox, the revocation service, the clock and the lease's access-token holder.
|
|
20
|
+
*/
|
|
21
|
+
readonly api: Omit<GmailApiOptions<Prepared>, 'currentHandle' | 'mailboxKey' | 'revocations' | 'clock' | 'tokenHolder'>;
|
|
22
|
+
/** The released SQL sync store: its snapshot and its exact-handle transaction. */
|
|
23
|
+
readonly store: Pick<SqlAccountSourceSyncStore<Prepared>, 'snapshot' | 'withCurrentHandle'>;
|
|
24
|
+
/** The released revocation service: its grant operation and the fenced disconnect `revoke` uses. */
|
|
25
|
+
readonly revocations: Pick<SourceRevocations<Prepared>, 'withGrant' | 'disconnect'>;
|
|
26
|
+
/** Answers the handle that holds this connection's lease now; never a getter of the first handle. */
|
|
27
|
+
readonly currentHandle: () => SourceSyncHandle;
|
|
28
|
+
/** The host's private mailbox identity binding. */
|
|
29
|
+
readonly mailbox: GmailMailboxBinding;
|
|
30
|
+
/**
|
|
31
|
+
* A stable opaque quota key for the identity probe before a mailbox is bound: 1 to 512 letters, digits, `:`, `_` or
|
|
32
|
+
* `-`, derived by the host with a server secret, never an address or a key that rotates with a connection.
|
|
33
|
+
*/
|
|
34
|
+
readonly bootstrapQuotaKey: string;
|
|
35
|
+
/** The host's evidenced cache permission for one read; null records a `not_permitted` skip without a request. */
|
|
36
|
+
readonly permission: (request: SourceSyncRequest) => Promise<SourceCachePermission | null>;
|
|
37
|
+
/** The host's trusted, authenticated relative source-detail path for one thread; never a Gmail link. */
|
|
38
|
+
readonly sourceDetailUrl: (scope: SourceSyncScope, sourceId: string) => string;
|
|
39
|
+
/** Current time as integer UTC epoch milliseconds, the clock the sync store reads; `Date.now` unless given. */
|
|
40
|
+
readonly clock?: () => number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A connector's fixed refusal; its message is `gmail_connector_<reason>`. `configuration` for an invalid option or
|
|
44
|
+
* clock, `selection` for a malformed or oversized selection or cursor, `history_bound` when selected history did not
|
|
45
|
+
* finish within its page budget, `busy` for an operation that overlaps another on the same connector, and `skipped`
|
|
46
|
+
* for a selected read that was deliberately not retained, with the skip reason in `skip`.
|
|
47
|
+
*/
|
|
48
|
+
export declare class GmailConnectorFault extends Error {
|
|
49
|
+
readonly reason: 'configuration' | 'selection' | 'history_bound' | 'busy' | 'skipped';
|
|
50
|
+
readonly skip: SourceSyncSkipReason | null;
|
|
51
|
+
/**
|
|
52
|
+
* @param reason Why the connector refused.
|
|
53
|
+
* @param skip The skip reason of a `skipped` refusal, otherwise null.
|
|
54
|
+
*/
|
|
55
|
+
constructor(reason: 'configuration' | 'selection' | 'history_bound' | 'busy' | 'skipped', skip?: SourceSyncSkipReason | null);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One serial connector per active lease. Store, quota and grant services own durability.
|
|
59
|
+
*
|
|
60
|
+
* Every operation, original or `sync`, runs alone on the connector within at most 90 seconds and one second before
|
|
61
|
+
* the lease expires. It checks the exact current handle, the connection's generation, barrier, pause flag and policy
|
|
62
|
+
* before its work, and the handle again after it, so a late result of a superseded lease is refused. The first content
|
|
63
|
+
* operation of each lease, and every `begin`, reads the profile and passes its address only to the host's binding.
|
|
64
|
+
* The clients the connector builds for one lease share one access token, so a cycle refreshes the grant once. Call
|
|
65
|
+
* `dispose()` when the run ends.
|
|
66
|
+
*
|
|
67
|
+
* @typeParam Prepared - The host's prepared-document type of its sync store and revocation service.
|
|
68
|
+
*/
|
|
69
|
+
export declare class GmailSourceConnector<Prepared = unknown> implements ResumableAccountSourceConnector {
|
|
70
|
+
private readonly options;
|
|
71
|
+
/** The account-source kind. */
|
|
72
|
+
readonly kind = "gmail";
|
|
73
|
+
/** The resumable provider the account-source coordinator drives; it commits nothing. */
|
|
74
|
+
readonly sync: AccountSourceSyncProvider;
|
|
75
|
+
private disposed;
|
|
76
|
+
private controller;
|
|
77
|
+
private verified;
|
|
78
|
+
private api;
|
|
79
|
+
private labelContext;
|
|
80
|
+
private labelPermission;
|
|
81
|
+
private labelAttempted;
|
|
82
|
+
private labels;
|
|
83
|
+
private labelTimer;
|
|
84
|
+
private readonly tokens;
|
|
85
|
+
private readonly clock;
|
|
86
|
+
/**
|
|
87
|
+
* @param options The API configuration, the host's store, revocation service, current-handle getter, mailbox
|
|
88
|
+
* binding, owner probe key, permission callback, detail-path builder and optional clock. Construction sends nothing.
|
|
89
|
+
* @throws {GmailConnectorFault} `configuration` for a malformed owner probe key.
|
|
90
|
+
*/
|
|
91
|
+
constructor(options: GmailSourceConnectorOptions<Prepared>);
|
|
92
|
+
private now;
|
|
93
|
+
private clearLabels;
|
|
94
|
+
/**
|
|
95
|
+
* Ends the connector: aborts the operation in flight and drops the label snapshot, the verified identity, the API
|
|
96
|
+
* clients and the held access token. Every later call throws `cancelled`. Call it in a `finally` block.
|
|
97
|
+
*/
|
|
98
|
+
dispose(): void;
|
|
99
|
+
private stored;
|
|
100
|
+
private current;
|
|
101
|
+
private fenced;
|
|
102
|
+
private context;
|
|
103
|
+
private operation;
|
|
104
|
+
private makeApi;
|
|
105
|
+
private needApi;
|
|
106
|
+
private verifyIdentity;
|
|
107
|
+
private cycleLabels;
|
|
108
|
+
private readDocument;
|
|
109
|
+
private selection;
|
|
110
|
+
private selected;
|
|
111
|
+
/**
|
|
112
|
+
* Reads the selected threads, freshly mapped; an empty selection enumerates nothing.
|
|
113
|
+
*
|
|
114
|
+
* @param selection Thread ids, at most the smaller of 100, the retained-document limit and the changed-per-lease
|
|
115
|
+
* limit.
|
|
116
|
+
* @param signal Cancels the call.
|
|
117
|
+
* @returns The read items and the threads Gmail no longer holds.
|
|
118
|
+
* @throws {GmailConnectorFault} `selection` before any request for a malformed or oversized selection, `skipped`
|
|
119
|
+
* for a thread that was not retained.
|
|
120
|
+
* @throws {SourceSyncFault} A fixed failure, including a retry with its time.
|
|
121
|
+
*/
|
|
122
|
+
list(selection: SourceSelection, signal?: AbortSignal): Promise<{
|
|
123
|
+
items: SourceItem[];
|
|
124
|
+
gone: SourceGone[];
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Reads one thread by its id; the caller's title, size and version are not trusted.
|
|
128
|
+
*
|
|
129
|
+
* @param item The thread to read.
|
|
130
|
+
* @param signal Cancels the call.
|
|
131
|
+
* @returns The freshly mapped read, or `removed` when Gmail no longer holds the thread.
|
|
132
|
+
* @throws {GmailConnectorFault} `selection` for a malformed id, `skipped` for a thread that was not retained.
|
|
133
|
+
* @throws {SourceSyncFault} A fixed failure, including a retry with its time.
|
|
134
|
+
*/
|
|
135
|
+
read(item: SourceItem, signal?: AbortSignal): Promise<SourceRead | SourceGone>;
|
|
136
|
+
/**
|
|
137
|
+
* The selected threads changed since a cursor. With a null cursor it reads the profile's history id first and then
|
|
138
|
+
* the whole selection, answering that id; with a cursor it drains history within the page budget and rereads only
|
|
139
|
+
* the selected threads it names. An empty selection answers the given cursor, or the empty-string sentinel for a
|
|
140
|
+
* null one, without a request; never persist that sentinel or pass it with a nonempty selection.
|
|
141
|
+
*
|
|
142
|
+
* @param fromCursor A history id from an earlier call, or null.
|
|
143
|
+
* @param selection The thread ids, bounded as for `list`.
|
|
144
|
+
* @param signal Cancels the call.
|
|
145
|
+
* @returns The changed and removed selected threads and the cursor reached; only a fully successful call answers one.
|
|
146
|
+
* @throws {GmailConnectorFault} `selection` for a malformed cursor or selection, `history_bound` when history did not
|
|
147
|
+
* finish within the page budget, `skipped` for a thread that was not retained.
|
|
148
|
+
* @throws {SourceSyncFault} `history_expired` for an expired cursor, or another fixed failure.
|
|
149
|
+
*/
|
|
150
|
+
changesSince(fromCursor: string | null, selection: SourceSelection, signal?: AbortSignal): Promise<SourceChanges>;
|
|
151
|
+
/**
|
|
152
|
+
* Disposes the connector and runs the released fenced disconnect for the current generation: the local purge and
|
|
153
|
+
* the queueing of the grant for the revocation worker. Resolving does not mean Google has confirmed the
|
|
154
|
+
* revocation; the revocation service's `status` reports that.
|
|
155
|
+
*
|
|
156
|
+
* @throws {SourceSyncFault} `grant_rejected` when the generation has moved on, `storage_unavailable` while the
|
|
157
|
+
* local purge is still pending.
|
|
158
|
+
*/
|
|
159
|
+
revoke(): Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=GmailSourceConnector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GmailSourceConnector.d.ts","sourceRoot":"","sources":["../src/GmailSourceConnector.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,+BAA+B,EAAE,KAAK,yBAAyB,EACpE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAC3F,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EACnE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,KAAK,yBAAyB,EACrF,KAAK,iBAAiB,EACvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAY,KAAK,eAAe,EAA2C,MAAM,YAAY,CAAC;AAErG,0FAA0F;AAC1F,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,I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