@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
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The Gmail account-source connector: the original selected-id `list`, `read` and `changesSince`
|
|
3
|
+
* methods, bounded and never enumerating a mailbox for an empty selection, and the additive resumable `sync` provider
|
|
4
|
+
* that the account-source coordinator drives. Every operation checks the exact current sync handle before and after
|
|
5
|
+
* its work, verifies the privately bound mailbox before its first content request, and holds at most one sanitized
|
|
6
|
+
* label snapshot per cycle under that response's own expiry. It commits nothing: storage, quota and grant services
|
|
7
|
+
* own durability.
|
|
8
|
+
* @module agentos-ext-gmail-source/GmailSourceConnector
|
|
9
|
+
*/
|
|
10
|
+
import { randomUUID } from 'node:crypto';
|
|
11
|
+
import { SourceSyncFault, assertSourceSyncPolicy, } from '@framers/agentos-ext-account-sources';
|
|
12
|
+
import { GmailApi } from './gmail.js';
|
|
13
|
+
/**
|
|
14
|
+
* A connector's fixed refusal; its message is `gmail_connector_<reason>`. `configuration` for an invalid option or
|
|
15
|
+
* clock, `selection` for a malformed or oversized selection or cursor, `history_bound` when selected history did not
|
|
16
|
+
* finish within its page budget, `busy` for an operation that overlaps another on the same connector, and `skipped`
|
|
17
|
+
* for a selected read that was deliberately not retained, with the skip reason in `skip`.
|
|
18
|
+
*/
|
|
19
|
+
export class GmailConnectorFault extends Error {
|
|
20
|
+
reason;
|
|
21
|
+
skip;
|
|
22
|
+
/**
|
|
23
|
+
* @param reason Why the connector refused.
|
|
24
|
+
* @param skip The skip reason of a `skipped` refusal, otherwise null.
|
|
25
|
+
*/
|
|
26
|
+
constructor(reason, skip = null) {
|
|
27
|
+
super(`gmail_connector_${reason}`);
|
|
28
|
+
this.reason = reason;
|
|
29
|
+
this.skip = skip;
|
|
30
|
+
this.name = 'GmailConnectorFault';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const id = (value) => typeof value === 'string' && /^[a-fA-F0-9]{1,64}$/.test(value);
|
|
34
|
+
const cursor = (value) => /^[0-9]{1,128}$/.test(value);
|
|
35
|
+
const opaqueKey = (value) => typeof value === 'string' && /^[A-Za-z0-9:_-]{1,512}$/.test(value);
|
|
36
|
+
const scopeKey = (scope) => JSON.stringify([scope.tenantId, scope.ownerId, scope.connectionId]);
|
|
37
|
+
// The lease a verification belongs to: the connection, its generation and the lease token, which a renewal keeps.
|
|
38
|
+
const identityKey = (handle) => JSON.stringify([
|
|
39
|
+
scopeKey(handle.lease.scope), handle.lease.generation, handle.lease.token,
|
|
40
|
+
]);
|
|
41
|
+
// The lease and the owner fence ticket, which a document application advances.
|
|
42
|
+
const handleKey = (handle) => JSON.stringify([
|
|
43
|
+
identityKey(handle), handle.ticket.tenantId, handle.ticket.ownerId, handle.ticket.epoch,
|
|
44
|
+
]);
|
|
45
|
+
const time = (value) => Number.isSafeInteger(value) && value >= 0 && value <= 8_639_999_913_600_000;
|
|
46
|
+
/**
|
|
47
|
+
* One serial connector per active lease. Store, quota and grant services own durability.
|
|
48
|
+
*
|
|
49
|
+
* Every operation, original or `sync`, runs alone on the connector within at most 90 seconds and one second before
|
|
50
|
+
* the lease expires. It checks the exact current handle, the connection's generation, barrier, pause flag and policy
|
|
51
|
+
* before its work, and the handle again after it, so a late result of a superseded lease is refused. The first content
|
|
52
|
+
* operation of each lease, and every `begin`, reads the profile and passes its address only to the host's binding.
|
|
53
|
+
* The clients the connector builds for one lease share one access token, so a cycle refreshes the grant once. Call
|
|
54
|
+
* `dispose()` when the run ends.
|
|
55
|
+
*
|
|
56
|
+
* @typeParam Prepared - The host's prepared-document type of its sync store and revocation service.
|
|
57
|
+
*/
|
|
58
|
+
export class GmailSourceConnector {
|
|
59
|
+
options;
|
|
60
|
+
/** The account-source kind. */
|
|
61
|
+
kind = 'gmail';
|
|
62
|
+
/** The resumable provider the account-source coordinator drives; it commits nothing. */
|
|
63
|
+
sync;
|
|
64
|
+
disposed = false;
|
|
65
|
+
controller = null;
|
|
66
|
+
verified = null;
|
|
67
|
+
api = null;
|
|
68
|
+
labelContext = null;
|
|
69
|
+
labelPermission = null;
|
|
70
|
+
labelAttempted = false;
|
|
71
|
+
labels = null;
|
|
72
|
+
labelTimer = null;
|
|
73
|
+
// The lease's access token, shared by every client this connector builds; memory only, cleared on disposal.
|
|
74
|
+
tokens = { current: null };
|
|
75
|
+
clock;
|
|
76
|
+
/**
|
|
77
|
+
* @param options The API configuration, the host's store, revocation service, current-handle getter, mailbox
|
|
78
|
+
* binding, owner probe key, permission callback, detail-path builder and optional clock. Construction sends nothing.
|
|
79
|
+
* @throws {GmailConnectorFault} `configuration` for a malformed owner probe key.
|
|
80
|
+
*/
|
|
81
|
+
constructor(options) {
|
|
82
|
+
this.options = options;
|
|
83
|
+
if (!opaqueKey(options.bootstrapQuotaKey))
|
|
84
|
+
throw new GmailConnectorFault('configuration');
|
|
85
|
+
this.clock = options.clock ?? Date.now;
|
|
86
|
+
this.sync = Object.freeze({
|
|
87
|
+
kind: 'gmail',
|
|
88
|
+
begin: (request) => this.operation(request, (signal) => this.verifyIdentity(request, signal, true)),
|
|
89
|
+
scanPage: (request, pageToken) => this.operation(request, async (signal) => {
|
|
90
|
+
await this.verifyIdentity(request, signal);
|
|
91
|
+
return this.needApi().list(request.cutoff, request.policy.windowMs, request.policy.scanPageSize, pageToken, signal);
|
|
92
|
+
}),
|
|
93
|
+
historyPage: (request, fromCursor, pageToken) => this.operation(request, async (signal) => {
|
|
94
|
+
await this.verifyIdentity(request, signal);
|
|
95
|
+
return this.needApi().history(fromCursor, request.policy.scanPageSize, pageToken, signal);
|
|
96
|
+
}),
|
|
97
|
+
readSource: (request, sourceId) => this.operation(request, (signal) => this.readDocument(request, sourceId, signal)),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
now() {
|
|
101
|
+
const value = this.clock();
|
|
102
|
+
if (!time(value))
|
|
103
|
+
throw new GmailConnectorFault('configuration');
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
clearLabels() {
|
|
107
|
+
if (this.labelTimer !== null)
|
|
108
|
+
clearTimeout(this.labelTimer);
|
|
109
|
+
this.labelTimer = null;
|
|
110
|
+
this.labels = null;
|
|
111
|
+
this.labelContext = null;
|
|
112
|
+
this.labelPermission = null;
|
|
113
|
+
this.labelAttempted = false;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Ends the connector: aborts the operation in flight and drops the label snapshot, the verified identity, the API
|
|
117
|
+
* clients and the held access token. Every later call throws `cancelled`. Call it in a `finally` block.
|
|
118
|
+
*/
|
|
119
|
+
dispose() {
|
|
120
|
+
if (this.disposed)
|
|
121
|
+
return;
|
|
122
|
+
this.disposed = true;
|
|
123
|
+
this.controller?.abort();
|
|
124
|
+
this.clearLabels();
|
|
125
|
+
this.api = null;
|
|
126
|
+
this.verified = null;
|
|
127
|
+
this.tokens.current = null;
|
|
128
|
+
}
|
|
129
|
+
async stored(work) {
|
|
130
|
+
try {
|
|
131
|
+
return await work();
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (error instanceof SourceSyncFault)
|
|
135
|
+
throw error;
|
|
136
|
+
throw new SourceSyncFault('storage_unavailable');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
current(request) {
|
|
140
|
+
if (this.disposed)
|
|
141
|
+
throw new SourceSyncFault('cancelled');
|
|
142
|
+
const handle = this.options.currentHandle();
|
|
143
|
+
if (handle.lease.expiresAt <= this.now() || handle.ticket.tenantId !== handle.lease.scope.tenantId
|
|
144
|
+
|| handle.ticket.ownerId !== handle.lease.scope.ownerId
|
|
145
|
+
|| (request !== undefined && (scopeKey(request.scope) !== scopeKey(handle.lease.scope)
|
|
146
|
+
|| request.generation !== handle.lease.generation)))
|
|
147
|
+
throw new SourceSyncFault('grant_rejected');
|
|
148
|
+
return handle;
|
|
149
|
+
}
|
|
150
|
+
async fenced(request, expected) {
|
|
151
|
+
const handle = this.current(request);
|
|
152
|
+
if (handleKey(handle) !== expected || await this.stored(() => this.options.store.withCurrentHandle(handle, async () => true)) !== true) {
|
|
153
|
+
throw new SourceSyncFault('grant_rejected');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async context(signal) {
|
|
157
|
+
const handle = this.current();
|
|
158
|
+
const snapshot = await this.stored(() => this.options.store.snapshot(handle.lease.scope));
|
|
159
|
+
if (!snapshot || snapshot.state.generation !== handle.lease.generation)
|
|
160
|
+
throw new SourceSyncFault('grant_rejected');
|
|
161
|
+
return { scope: handle.lease.scope, generation: handle.lease.generation,
|
|
162
|
+
cycleId: randomUUID(), cutoff: this.now(), policy: snapshot.policy, signal };
|
|
163
|
+
}
|
|
164
|
+
// One operation at a time, bounded and fenced on both sides; any failure clears the label snapshot.
|
|
165
|
+
async operation(request, work) {
|
|
166
|
+
if (this.disposed || request.signal?.aborted)
|
|
167
|
+
throw new SourceSyncFault('cancelled');
|
|
168
|
+
if (this.controller !== null)
|
|
169
|
+
throw new GmailConnectorFault('busy');
|
|
170
|
+
const controller = new AbortController();
|
|
171
|
+
this.controller = controller;
|
|
172
|
+
let timedOut = false;
|
|
173
|
+
let timer = null;
|
|
174
|
+
const abort = () => { controller.abort(); this.clearLabels(); };
|
|
175
|
+
request.signal?.addEventListener('abort', abort, { once: true });
|
|
176
|
+
if (request.signal?.aborted)
|
|
177
|
+
abort();
|
|
178
|
+
try {
|
|
179
|
+
assertSourceSyncPolicy(request.policy);
|
|
180
|
+
if (!time(request.cutoff) || request.cutoff > this.now() || !request.cycleId || request.cycleId.length > 512) {
|
|
181
|
+
throw new SourceSyncFault('invalid_response');
|
|
182
|
+
}
|
|
183
|
+
const handle = this.current(request);
|
|
184
|
+
const expected = handleKey(handle);
|
|
185
|
+
const duration = Math.min(90_000, handle.lease.expiresAt - this.now() - 1000);
|
|
186
|
+
if (duration <= 0)
|
|
187
|
+
throw new SourceSyncFault('network');
|
|
188
|
+
timer = setTimeout(() => { timedOut = true; abort(); }, duration);
|
|
189
|
+
await this.fenced(request, expected);
|
|
190
|
+
const snapshot = await this.stored(() => this.options.store.snapshot(request.scope));
|
|
191
|
+
if (!snapshot || snapshot.state.generation !== request.generation || snapshot.barrier || snapshot.state.paused
|
|
192
|
+
|| Object.keys(snapshot.policy).some((key) => snapshot.policy[key]
|
|
193
|
+
!== request.policy[key]))
|
|
194
|
+
throw new SourceSyncFault('grant_rejected');
|
|
195
|
+
const context = JSON.stringify([identityKey(handle), request.cycleId]);
|
|
196
|
+
if (this.labelContext !== context) {
|
|
197
|
+
this.clearLabels();
|
|
198
|
+
this.labelContext = context;
|
|
199
|
+
}
|
|
200
|
+
if (this.verified !== identityKey(handle)) {
|
|
201
|
+
this.verified = null;
|
|
202
|
+
this.api = null;
|
|
203
|
+
this.tokens.current = null;
|
|
204
|
+
}
|
|
205
|
+
if (controller.signal.aborted)
|
|
206
|
+
throw new SourceSyncFault('cancelled');
|
|
207
|
+
const value = await work(controller.signal);
|
|
208
|
+
if (controller.signal.aborted)
|
|
209
|
+
throw new SourceSyncFault('cancelled');
|
|
210
|
+
await this.fenced(request, expected);
|
|
211
|
+
if (controller.signal.aborted)
|
|
212
|
+
throw new SourceSyncFault('cancelled');
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
this.clearLabels();
|
|
217
|
+
if (this.disposed || request.signal?.aborted)
|
|
218
|
+
throw new SourceSyncFault('cancelled');
|
|
219
|
+
if (timedOut)
|
|
220
|
+
throw new SourceSyncFault('network');
|
|
221
|
+
if (error instanceof SourceSyncFault || error instanceof GmailConnectorFault)
|
|
222
|
+
throw error;
|
|
223
|
+
throw new SourceSyncFault('invalid_response');
|
|
224
|
+
}
|
|
225
|
+
finally {
|
|
226
|
+
if (timer !== null)
|
|
227
|
+
clearTimeout(timer);
|
|
228
|
+
request.signal?.removeEventListener('abort', abort);
|
|
229
|
+
this.controller = null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
makeApi(mailboxKey) {
|
|
233
|
+
if (!opaqueKey(mailboxKey))
|
|
234
|
+
throw new SourceSyncFault('invalid_response');
|
|
235
|
+
return new GmailApi({ ...this.options.api, revocations: this.options.revocations,
|
|
236
|
+
currentHandle: this.options.currentHandle, mailboxKey, clock: this.clock, tokenHolder: this.tokens });
|
|
237
|
+
}
|
|
238
|
+
needApi() {
|
|
239
|
+
if (!this.api)
|
|
240
|
+
throw new SourceSyncFault('grant_rejected');
|
|
241
|
+
return this.api;
|
|
242
|
+
}
|
|
243
|
+
// Reads the profile under the bound mailbox's quota key, or the owner probe key before one is bound, hands its
|
|
244
|
+
// address to the host's binding alone and answers the profile's history id. An identity this lease has already
|
|
245
|
+
// verified answers an empty string, which only `begin` (fresh) never returns.
|
|
246
|
+
async verifyIdentity(request, signal, fresh = false) {
|
|
247
|
+
const handle = this.current(request);
|
|
248
|
+
const identity = identityKey(handle);
|
|
249
|
+
if (!fresh && this.verified === identity && this.api)
|
|
250
|
+
return '';
|
|
251
|
+
const existing = await this.stored(() => this.options.mailbox.key(handle));
|
|
252
|
+
if (existing !== null && !opaqueKey(existing))
|
|
253
|
+
throw new SourceSyncFault('invalid_response');
|
|
254
|
+
const api = this.makeApi(existing ?? this.options.bootstrapQuotaKey);
|
|
255
|
+
const profile = await api.profile(signal);
|
|
256
|
+
if (signal.aborted)
|
|
257
|
+
throw new SourceSyncFault('cancelled');
|
|
258
|
+
if (handleKey(this.current(request)) !== handleKey(handle))
|
|
259
|
+
throw new SourceSyncFault('grant_rejected');
|
|
260
|
+
const accepted = await this.stored(() => this.options.mailbox.accept(handle, profile.emailAddress));
|
|
261
|
+
if (accepted === null || (existing !== null && accepted !== existing))
|
|
262
|
+
throw new SourceSyncFault('grant_rejected');
|
|
263
|
+
if (!opaqueKey(accepted))
|
|
264
|
+
throw new SourceSyncFault('invalid_response');
|
|
265
|
+
if (signal.aborted)
|
|
266
|
+
throw new SourceSyncFault('cancelled');
|
|
267
|
+
this.api = this.makeApi(accepted);
|
|
268
|
+
this.verified = identity;
|
|
269
|
+
return profile.historyId;
|
|
270
|
+
}
|
|
271
|
+
// One label request per cycle and permission; a refused or expired snapshot holds no names and is not requested again.
|
|
272
|
+
async cycleLabels(permission, signal) {
|
|
273
|
+
const policyKey = JSON.stringify([permission.evidenceId, permission.retentionMs]);
|
|
274
|
+
if (this.labelPermission !== policyKey) {
|
|
275
|
+
const context = this.labelContext;
|
|
276
|
+
this.clearLabels();
|
|
277
|
+
this.labelContext = context;
|
|
278
|
+
this.labelPermission = policyKey;
|
|
279
|
+
}
|
|
280
|
+
if (!this.labelAttempted) {
|
|
281
|
+
const labels = await this.needApi().labels(permission, signal);
|
|
282
|
+
if (signal.aborted)
|
|
283
|
+
throw new SourceSyncFault('cancelled');
|
|
284
|
+
this.labelAttempted = true;
|
|
285
|
+
if (labels.cache.kind === 'cache' && labels.cache.expiresAt > this.now()) {
|
|
286
|
+
this.labels = labels;
|
|
287
|
+
const delay = Math.min(86_400_000, labels.cache.expiresAt - this.now());
|
|
288
|
+
this.labelTimer = setTimeout(() => {
|
|
289
|
+
this.labels = null;
|
|
290
|
+
this.labelTimer = null;
|
|
291
|
+
}, Math.max(0, delay));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (this.labels?.cache.kind === 'cache' && this.labels.cache.expiresAt <= this.now()) {
|
|
295
|
+
if (this.labelTimer !== null)
|
|
296
|
+
clearTimeout(this.labelTimer);
|
|
297
|
+
this.labelTimer = null;
|
|
298
|
+
this.labels = null;
|
|
299
|
+
}
|
|
300
|
+
return this.labels;
|
|
301
|
+
}
|
|
302
|
+
// The permission is asked for every read, so a withdrawn permission skips without a label or thread request.
|
|
303
|
+
async readDocument(request, sourceId, signal) {
|
|
304
|
+
if (!id(sourceId))
|
|
305
|
+
throw new GmailConnectorFault('selection');
|
|
306
|
+
await this.verifyIdentity(request, signal);
|
|
307
|
+
const permission = await this.stored(() => this.options.permission({ ...request, signal }));
|
|
308
|
+
if (signal.aborted)
|
|
309
|
+
throw new SourceSyncFault('cancelled');
|
|
310
|
+
if (permission === null) {
|
|
311
|
+
this.clearLabels();
|
|
312
|
+
return { kind: 'skipped', id: sourceId, reason: 'not_permitted' };
|
|
313
|
+
}
|
|
314
|
+
const labels = await this.cycleLabels(permission, signal);
|
|
315
|
+
return this.needApi().readThread(sourceId, { cutoff: request.cutoff, windowMs: request.policy.windowMs,
|
|
316
|
+
sourceDetailUrl: this.options.sourceDetailUrl(request.scope, sourceId), permission, labels, signal });
|
|
317
|
+
}
|
|
318
|
+
// At most the smaller of 100, the retained-document limit and the changed-per-lease limit, deduplicated.
|
|
319
|
+
selection(selection, request) {
|
|
320
|
+
if (!Array.isArray(selection.ids)
|
|
321
|
+
|| selection.ids.length > Math.min(100, request.policy.maxRetainedDocuments, request.policy.maxChangedPerLease)
|
|
322
|
+
|| selection.ids.some((value) => !id(value)))
|
|
323
|
+
throw new GmailConnectorFault('selection');
|
|
324
|
+
return [...new Set(selection.ids)];
|
|
325
|
+
}
|
|
326
|
+
// Only a canonical missing thread becomes `removed`; a retry or a skip throws instead of answering a partial result.
|
|
327
|
+
selected(result) {
|
|
328
|
+
if (result.kind === 'document')
|
|
329
|
+
return result.document.read;
|
|
330
|
+
if (result.kind === 'gone')
|
|
331
|
+
return { id: result.id, reason: 'removed' };
|
|
332
|
+
if (result.kind === 'retry')
|
|
333
|
+
throw new SourceSyncFault(result.reason, result.retryAt);
|
|
334
|
+
throw new GmailConnectorFault('skipped', result.reason);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Reads the selected threads, freshly mapped; an empty selection enumerates nothing.
|
|
338
|
+
*
|
|
339
|
+
* @param selection Thread ids, at most the smaller of 100, the retained-document limit and the changed-per-lease
|
|
340
|
+
* limit.
|
|
341
|
+
* @param signal Cancels the call.
|
|
342
|
+
* @returns The read items and the threads Gmail no longer holds.
|
|
343
|
+
* @throws {GmailConnectorFault} `selection` before any request for a malformed or oversized selection, `skipped`
|
|
344
|
+
* for a thread that was not retained.
|
|
345
|
+
* @throws {SourceSyncFault} A fixed failure, including a retry with its time.
|
|
346
|
+
*/
|
|
347
|
+
async list(selection, signal) {
|
|
348
|
+
const request = await this.context(signal);
|
|
349
|
+
return this.operation(request, async (child) => {
|
|
350
|
+
const ids = this.selection(selection, request);
|
|
351
|
+
const items = [];
|
|
352
|
+
const gone = [];
|
|
353
|
+
for (const sourceId of ids) {
|
|
354
|
+
const result = this.selected(await this.readDocument(request, sourceId, child));
|
|
355
|
+
if ('content' in result)
|
|
356
|
+
items.push(result.item);
|
|
357
|
+
else
|
|
358
|
+
gone.push(result);
|
|
359
|
+
}
|
|
360
|
+
return { items, gone };
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Reads one thread by its id; the caller's title, size and version are not trusted.
|
|
365
|
+
*
|
|
366
|
+
* @param item The thread to read.
|
|
367
|
+
* @param signal Cancels the call.
|
|
368
|
+
* @returns The freshly mapped read, or `removed` when Gmail no longer holds the thread.
|
|
369
|
+
* @throws {GmailConnectorFault} `selection` for a malformed id, `skipped` for a thread that was not retained.
|
|
370
|
+
* @throws {SourceSyncFault} A fixed failure, including a retry with its time.
|
|
371
|
+
*/
|
|
372
|
+
async read(item, signal) {
|
|
373
|
+
const request = await this.context(signal);
|
|
374
|
+
return this.operation(request, async (child) => {
|
|
375
|
+
this.selection({ ids: [item.id] }, request);
|
|
376
|
+
return this.selected(await this.readDocument(request, item.id, child));
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* The selected threads changed since a cursor. With a null cursor it reads the profile's history id first and then
|
|
381
|
+
* the whole selection, answering that id; with a cursor it drains history within the page budget and rereads only
|
|
382
|
+
* the selected threads it names. An empty selection answers the given cursor, or the empty-string sentinel for a
|
|
383
|
+
* null one, without a request; never persist that sentinel or pass it with a nonempty selection.
|
|
384
|
+
*
|
|
385
|
+
* @param fromCursor A history id from an earlier call, or null.
|
|
386
|
+
* @param selection The thread ids, bounded as for `list`.
|
|
387
|
+
* @param signal Cancels the call.
|
|
388
|
+
* @returns The changed and removed selected threads and the cursor reached; only a fully successful call answers one.
|
|
389
|
+
* @throws {GmailConnectorFault} `selection` for a malformed cursor or selection, `history_bound` when history did not
|
|
390
|
+
* finish within the page budget, `skipped` for a thread that was not retained.
|
|
391
|
+
* @throws {SourceSyncFault} `history_expired` for an expired cursor, or another fixed failure.
|
|
392
|
+
*/
|
|
393
|
+
async changesSince(fromCursor, selection, signal) {
|
|
394
|
+
const request = await this.context(signal);
|
|
395
|
+
return this.operation(request, async (child) => {
|
|
396
|
+
const ids = this.selection(selection, request);
|
|
397
|
+
if (ids.length === 0)
|
|
398
|
+
return { changed: [], gone: [], cursor: fromCursor ?? '' };
|
|
399
|
+
if (fromCursor !== null && !cursor(fromCursor))
|
|
400
|
+
throw new GmailConnectorFault('selection');
|
|
401
|
+
const selected = new Set(ids);
|
|
402
|
+
const changedIds = new Set();
|
|
403
|
+
let terminal;
|
|
404
|
+
if (fromCursor === null) {
|
|
405
|
+
terminal = await this.verifyIdentity(request, child, true);
|
|
406
|
+
for (const sourceId of ids)
|
|
407
|
+
changedIds.add(sourceId);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
await this.verifyIdentity(request, child);
|
|
411
|
+
let pageToken = null;
|
|
412
|
+
const tokens = new Set();
|
|
413
|
+
terminal = fromCursor;
|
|
414
|
+
let complete = false;
|
|
415
|
+
for (let n = 0; n < Math.min(20, request.policy.maxHistoryPagesPerLease); n++) {
|
|
416
|
+
const page = await this.needApi().history(fromCursor, request.policy.scanPageSize, pageToken, child);
|
|
417
|
+
for (const sourceId of page.ids)
|
|
418
|
+
if (selected.has(sourceId))
|
|
419
|
+
changedIds.add(sourceId);
|
|
420
|
+
terminal = page.cursor;
|
|
421
|
+
if (page.nextPageToken === null) {
|
|
422
|
+
complete = true;
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
if (tokens.has(page.nextPageToken))
|
|
426
|
+
throw new SourceSyncFault('invalid_response');
|
|
427
|
+
tokens.add(page.nextPageToken);
|
|
428
|
+
pageToken = page.nextPageToken;
|
|
429
|
+
}
|
|
430
|
+
if (!complete)
|
|
431
|
+
throw new GmailConnectorFault('history_bound');
|
|
432
|
+
}
|
|
433
|
+
const changed = [];
|
|
434
|
+
const gone = [];
|
|
435
|
+
for (const sourceId of ids) {
|
|
436
|
+
if (!changedIds.has(sourceId))
|
|
437
|
+
continue;
|
|
438
|
+
const result = this.selected(await this.readDocument(request, sourceId, child));
|
|
439
|
+
if ('content' in result)
|
|
440
|
+
changed.push(result.item);
|
|
441
|
+
else
|
|
442
|
+
gone.push(result);
|
|
443
|
+
}
|
|
444
|
+
return { changed, gone, cursor: terminal };
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Disposes the connector and runs the released fenced disconnect for the current generation: the local purge and
|
|
449
|
+
* the queueing of the grant for the revocation worker. Resolving does not mean Google has confirmed the
|
|
450
|
+
* revocation; the revocation service's `status` reports that.
|
|
451
|
+
*
|
|
452
|
+
* @throws {SourceSyncFault} `grant_rejected` when the generation has moved on, `storage_unavailable` while the
|
|
453
|
+
* local purge is still pending.
|
|
454
|
+
*/
|
|
455
|
+
async revoke() {
|
|
456
|
+
const handle = this.current();
|
|
457
|
+
this.dispose();
|
|
458
|
+
const notice = await this.stored(() => this.options.revocations.disconnect(handle.lease.scope, handle.lease.generation));
|
|
459
|
+
if (notice === null)
|
|
460
|
+
throw new SourceSyncFault('grant_rejected');
|
|
461
|
+
if (notice.localPending)
|
|
462
|
+
throw new SourceSyncFault('storage_unavailable');
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
//# sourceMappingURL=GmailSourceConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GmailSourceConnector.js","sourceRoot":"","sources":["../src/GmailSourceConnector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EAAE,sBAAsB,GAMxC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAiE,MAAM,YAAY,CAAC;AAyCrG;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAKvB;IACV;IALX;;;OAGG;IACH,YAAqB,MAA4E,EACtF,OAAoC,IAAI;QACjD,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;QAFhB,WAAM,GAAN,MAAM,CAAsE;QACtF,SAAI,GAAJ,IAAI,CAAoC;QACb,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACxE,CAAC;CACF;AACD,MAAM,EAAE,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/G,MAAM,MAAM,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,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AC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;QACzH,IAAI,MAAM,KAAK,IAAI;YAAE,MAAM,IAAI,eAAe,CAAC,gBAAgB,CAAC,CAAC;QACjE,IAAI,MAAM,CAAC,YAAY;YAAE,MAAM,IAAI,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAC5E,CAAC;CACF"}
|
package/dist/gmail.d.ts
CHANGED
|
@@ -49,6 +49,25 @@ export interface GmailApiOptions<Prepared = unknown> {
|
|
|
49
49
|
readonly apiOrigin?: string;
|
|
50
50
|
/** CI-only OAuth stand-in endpoints, checked as `GmailOAuthFlow` checks them. */
|
|
51
51
|
readonly oauthEndpoints?: GmailOAuthEndpoints;
|
|
52
|
+
/**
|
|
53
|
+
* Reuse of one access token for one sync lease, shared by every client given the same holder. A held token is used
|
|
54
|
+
* only while `currentHandle` answers the lease it was obtained under (the same connection, generation and lease
|
|
55
|
+
* token) and that lease has not expired by `clock`; a 401 drops it, and the repeat refreshes as before. Without a
|
|
56
|
+
* holder every operation refreshes the grant.
|
|
57
|
+
*/
|
|
58
|
+
readonly tokenHolder?: GmailTokenHolder;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A memory-only slot for one access token and the sync lease it was obtained under, given to the clients built for
|
|
62
|
+
* one lease so that a cycle refreshes the grant once. Create it as `{ current: null }` for each lease and drop it when
|
|
63
|
+
* the lease ends; never persist, log or serialize it.
|
|
64
|
+
*/
|
|
65
|
+
export interface GmailTokenHolder {
|
|
66
|
+
/** The held token and the key of its lease, written and cleared by the clients; null when none is held. */
|
|
67
|
+
current: {
|
|
68
|
+
readonly lease: string;
|
|
69
|
+
readonly value: string;
|
|
70
|
+
} | null;
|
|
52
71
|
}
|
|
53
72
|
/** Server-memory identity result. Never serialize it into a source or telemetry. */
|
|
54
73
|
export interface GmailProfile {
|
|
@@ -90,10 +109,11 @@ export declare class GmailApiFault extends Error {
|
|
|
90
109
|
}
|
|
91
110
|
/**
|
|
92
111
|
* The capped, read-only Gmail API client. Each provider operation makes one attempt: one OAuth refresh inside the
|
|
93
|
-
* host's grant operation,
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
112
|
+
* host's grant operation, or the access token a `tokenHolder` holds for the current lease, then one HTTP dispatch, each
|
|
113
|
+
* admitted by the shared quota with a new attempt id; a 401 drops a held token and earns one fresh token and one
|
|
114
|
+
* repeat of the same call. Provider waits are recorded through the quota's `defer` and thrown as `rate_limited` or
|
|
115
|
+
* `provider_unavailable` with their time; the durable coordinator owns retry episodes, backoff and exhaustion. Every
|
|
116
|
+
* failure is a fixed `SourceSyncFault`.
|
|
97
117
|
*
|
|
98
118
|
* @typeParam Prepared - The host's prepared-document type of its `SourceRevocations`.
|
|
99
119
|
*/
|
|
@@ -120,6 +140,7 @@ export declare class GmailApi<Prepared = unknown> {
|
|
|
120
140
|
private reserve;
|
|
121
141
|
private defer;
|
|
122
142
|
private accessToken;
|
|
143
|
+
private dropToken;
|
|
123
144
|
/** Consume/cancel the whole body within the quota callback, before releasing its slot. */
|
|
124
145
|
private wire;
|
|
125
146
|
private request;
|
package/dist/gmail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gmail.d.ts","sourceRoot":"","sources":["../src/gmail.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,WAAW,EAAkD,KAAK,iBAAiB,EACxF,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAC5E,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAC9E,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAA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