@superdurable/connector-dropbox 0.1.0 → 0.2.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/dex-connector.json +3 -4
- package/dist/{chunk-OVLMU3VN.js → chunk-HC4YIUZK.js} +36 -21
- package/dist/{connection-DDFkY9tu.d.ts → connection-DtKKxEuC.d.ts} +9 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +37 -18
- package/dist/mock.d.ts +1 -1
- package/dist/mock.js +1 -1
- package/package.json +1 -1
package/dex-connector.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"connectorId": "dropbox",
|
|
3
|
-
"releaseTag": "connectors/dropbox/go/v0.1
|
|
3
|
+
"releaseTag": "connectors/dropbox/go/v0.2.1",
|
|
4
4
|
"package": {
|
|
5
5
|
"ecosystem": "npm",
|
|
6
6
|
"name": "@superdurable/connector-dropbox",
|
|
7
|
-
"version": "0.1
|
|
7
|
+
"version": "0.2.1"
|
|
8
8
|
},
|
|
9
9
|
"factories": [
|
|
10
10
|
{
|
|
@@ -60,8 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"required": [
|
|
63
|
-
"limit"
|
|
64
|
-
"path"
|
|
63
|
+
"limit"
|
|
65
64
|
],
|
|
66
65
|
"type": "object"
|
|
67
66
|
}
|
|
@@ -9,46 +9,60 @@ var ConfigSchema = z.object({
|
|
|
9
9
|
"maxDownloadBytes": z.number().int().optional(),
|
|
10
10
|
"maxUploadBytes": z.number().int().optional()
|
|
11
11
|
});
|
|
12
|
+
var CredentialMaterialError = class extends TypeError {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "CredentialMaterialError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
19
|
+
"project credential decoding failed",
|
|
20
|
+
"shared project credential decoding failed",
|
|
21
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
22
|
+
]);
|
|
23
|
+
function isCredentialMaterialError(error) {
|
|
24
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
25
|
+
}
|
|
12
26
|
function decodeCredentials(value) {
|
|
13
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new
|
|
27
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
14
28
|
const fields = value;
|
|
15
29
|
const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
16
|
-
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new
|
|
17
|
-
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new
|
|
18
|
-
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new
|
|
19
|
-
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new
|
|
20
|
-
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new
|
|
30
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
31
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new CredentialMaterialError("credential access_token has an invalid type");
|
|
32
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new CredentialMaterialError("credential oauth_client_id has an invalid type");
|
|
33
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new CredentialMaterialError("credential oauth_client_secret has an invalid type");
|
|
34
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new CredentialMaterialError("credential refresh_token has an invalid type");
|
|
21
35
|
const credentials = {};
|
|
22
|
-
if (!fields["oauth_client_id"]) throw new
|
|
36
|
+
if (!fields["oauth_client_id"]) throw new CredentialMaterialError("credential oauth_client_id is required");
|
|
23
37
|
credentials.oauthClientId = fields["oauth_client_id"] ?? "";
|
|
24
|
-
if (!fields["oauth_client_secret"]) throw new
|
|
38
|
+
if (!fields["oauth_client_secret"]) throw new CredentialMaterialError("credential oauth_client_secret is required");
|
|
25
39
|
credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
|
|
26
|
-
if (!fields["access_token"]) throw new
|
|
40
|
+
if (!fields["access_token"]) throw new CredentialMaterialError("credential access_token is required");
|
|
27
41
|
credentials.accessToken = new SecretString(fields["access_token"] ?? "");
|
|
28
|
-
if (!fields["refresh_token"]) throw new
|
|
42
|
+
if (!fields["refresh_token"]) throw new CredentialMaterialError("credential refresh_token is required");
|
|
29
43
|
credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
|
|
30
44
|
return credentials;
|
|
31
45
|
}
|
|
32
46
|
function decodeSharedCredentials(value) {
|
|
33
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new
|
|
47
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
34
48
|
const fields = value;
|
|
35
49
|
const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
36
|
-
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new
|
|
37
|
-
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new
|
|
38
|
-
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new
|
|
39
|
-
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new
|
|
40
|
-
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new
|
|
50
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
51
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new CredentialMaterialError("credential access_token has an invalid type");
|
|
52
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new CredentialMaterialError("credential oauth_client_id has an invalid type");
|
|
53
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new CredentialMaterialError("credential oauth_client_secret has an invalid type");
|
|
54
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new CredentialMaterialError("credential refresh_token has an invalid type");
|
|
41
55
|
const credentials = {};
|
|
42
|
-
if (!fields["oauth_client_id"]) throw new
|
|
56
|
+
if (!fields["oauth_client_id"]) throw new CredentialMaterialError("credential oauth_client_id is required");
|
|
43
57
|
credentials.oauthClientId = fields["oauth_client_id"] ?? "";
|
|
44
58
|
credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
|
|
45
|
-
if (!fields["access_token"]) throw new
|
|
59
|
+
if (!fields["access_token"]) throw new CredentialMaterialError("credential access_token is required");
|
|
46
60
|
credentials.accessToken = new SecretString(fields["access_token"] ?? "");
|
|
47
61
|
credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
|
|
48
62
|
return credentials;
|
|
49
63
|
}
|
|
50
64
|
var ListFolderInputSchema = z.strictObject({
|
|
51
|
-
"path": z.string(),
|
|
65
|
+
"path": z.string().optional(),
|
|
52
66
|
"limit": z.number().int()
|
|
53
67
|
});
|
|
54
68
|
var EntryMetadataSchema = z.strictObject({
|
|
@@ -201,7 +215,7 @@ var UploadFileDefinition = {
|
|
|
201
215
|
branches: [
|
|
202
216
|
{ id: "uploaded", description: "Dropbox stored the replacement file content." },
|
|
203
217
|
{ id: "providerRejected", description: "Dropbox conclusively rejected the upload.", optional: true },
|
|
204
|
-
{ id: "invalidResponse", description: "
|
|
218
|
+
{ id: "invalidResponse", description: "Retained for compatibility and no longer selected: malformed or oversized upload metadata now retries the overwrite.", optional: true },
|
|
205
219
|
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
206
220
|
],
|
|
207
221
|
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
@@ -238,7 +252,6 @@ function newProjectCredentialProvider(project, connectionName, decode, encode, d
|
|
|
238
252
|
// src/generated/mock.ts
|
|
239
253
|
import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
|
240
254
|
var emptyListFolderInput = ListFolderInputSchema.parse({
|
|
241
|
-
"path": "",
|
|
242
255
|
"limit": 0
|
|
243
256
|
});
|
|
244
257
|
var emptyEntryMetadata = EntryMetadataSchema.parse({
|
|
@@ -442,6 +455,8 @@ var GeneratedMock = class {
|
|
|
442
455
|
|
|
443
456
|
export {
|
|
444
457
|
ConfigSchema,
|
|
458
|
+
CredentialMaterialError,
|
|
459
|
+
isCredentialMaterialError,
|
|
445
460
|
decodeCredentials,
|
|
446
461
|
decodeSharedCredentials,
|
|
447
462
|
ListFolderInputSchema,
|
|
@@ -36,6 +36,12 @@ interface Credentials {
|
|
|
36
36
|
/** Secret refresh token returned because offline access is requested. Dex stores it for automatic renewal; blank means reauthorization is required after access-token expiry. */
|
|
37
37
|
refreshToken: SecretString;
|
|
38
38
|
}
|
|
39
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
40
|
+
declare class CredentialMaterialError extends TypeError {
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
43
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
44
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
39
45
|
/** Decode private credential fields for the connector. */
|
|
40
46
|
declare function decodeCredentials(value: unknown): Credentials;
|
|
41
47
|
/** Decode shared credential fields for the connector. */
|
|
@@ -45,7 +51,7 @@ type CredentialSource = RefreshingCredentialProvider<Credentials>;
|
|
|
45
51
|
/** ListFolderInput selects one bounded page of a Dropbox folder. */
|
|
46
52
|
interface ListFolderInput {
|
|
47
53
|
/** Path is an empty string for the root or a Dropbox folder path or ID. */
|
|
48
|
-
"path"
|
|
54
|
+
"path"?: string | undefined;
|
|
49
55
|
/** Limit is the approximate number of entries per page, from 1 to 2000. */
|
|
50
56
|
"limit": number;
|
|
51
57
|
}
|
|
@@ -107,7 +113,7 @@ interface UploadedFile {
|
|
|
107
113
|
}
|
|
108
114
|
/** Runtime validator for ListFolderInput. */
|
|
109
115
|
declare const ListFolderInputSchema: z.ZodObject<{
|
|
110
|
-
path: z.ZodString
|
|
116
|
+
path: z.ZodOptional<z.ZodString>;
|
|
111
117
|
limit: z.ZodNumber;
|
|
112
118
|
}, z.core.$strict>;
|
|
113
119
|
/** Runtime validator for EntryMetadata. */
|
|
@@ -193,4 +199,4 @@ declare function newConnection(client: Operations, reference: ConnectionRef): Co
|
|
|
193
199
|
/** Bind scripted operations to a named connection. */
|
|
194
200
|
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
195
201
|
|
|
196
|
-
export { type ContinueFolderInput as C, type DownloadFileInput as D, type EntryMetadata as E, type FolderPage as F, type GetMetadataInput as G, type ListFolderInput as L, type Operations as O, type UploadFileInput as U, type DownloadedFile as a, type UploadedFile as b, type Config as c, type Credentials as d, Connection as e, ConfigSchema as f, ContinueFolderInputSchema as g, type CredentialSource as
|
|
202
|
+
export { type ContinueFolderInput as C, type DownloadFileInput as D, type EntryMetadata as E, type FolderPage as F, type GetMetadataInput as G, type ListFolderInput as L, type Operations as O, type UploadFileInput as U, type DownloadedFile as a, type UploadedFile as b, type Config as c, type Credentials as d, Connection as e, ConfigSchema as f, ContinueFolderInputSchema as g, CredentialMaterialError as h, type CredentialSource as i, DownloadFileInputSchema as j, DownloadedFileSchema as k, EntryMetadataSchema as l, FolderPageSchema as m, GetMetadataInputSchema as n, ListFolderInputSchema as o, UploadFileInputSchema as p, UploadedFileSchema as q, decodeCredentials as r, decodeSharedCredentials as s, isCredentialMaterialError as t, newConnection as u, newConnectionWithOperations as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ContinueFolderInput, F as FolderPage, L as ListFolderInput, G as GetMetadataInput, E as EntryMetadata, D as DownloadFileInput, a as DownloadedFile, U as UploadFileInput, b as UploadedFile, c as Config, d as Credentials, e as Connection, O as Operations } from './connection-
|
|
2
|
-
export { f as ConfigSchema, g as ContinueFolderInputSchema, h as
|
|
1
|
+
import { C as ContinueFolderInput, F as FolderPage, L as ListFolderInput, G as GetMetadataInput, E as EntryMetadata, D as DownloadFileInput, a as DownloadedFile, U as UploadFileInput, b as UploadedFile, c as Config, d as Credentials, e as Connection, O as Operations } from './connection-DtKKxEuC.js';
|
|
2
|
+
export { f as ConfigSchema, g as ContinueFolderInputSchema, h as CredentialMaterialError, i as CredentialSource, j as DownloadFileInputSchema, k as DownloadedFileSchema, l as EntryMetadataSchema, m as FolderPageSchema, n as GetMetadataInputSchema, o as ListFolderInputSchema, p as UploadFileInputSchema, q as UploadedFileSchema, r as decodeCredentials, s as decodeSharedCredentials, t as isCredentialMaterialError, u as newConnection, v as newConnectionWithOperations } from './connection-DtKKxEuC.js';
|
|
3
3
|
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
4
|
import { QueryDefinition, MutationDefinition, Query, Call, QueryAttempt, Mutation, MutationAttempt, CredentialProvider, CredentialRefreshDriver, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep } from '@superdurable/connectors-sdk';
|
|
5
5
|
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
@@ -129,7 +129,7 @@ declare const UploadFileBranch: {
|
|
|
129
129
|
declare const UploadFileBranchUploaded: "uploaded";
|
|
130
130
|
/** Dropbox conclusively rejected the upload. */
|
|
131
131
|
declare const UploadFileBranchProviderRejected: "providerRejected";
|
|
132
|
-
/**
|
|
132
|
+
/** Retained for compatibility and no longer selected: malformed or oversized upload metadata now retries the overwrite. */
|
|
133
133
|
declare const UploadFileBranchInvalidResponse: "invalidResponse";
|
|
134
134
|
/** Local input or connection credentials are invalid. */
|
|
135
135
|
declare const UploadFileBranchDefect: "defect";
|
|
@@ -329,7 +329,7 @@ interface UploadFileStepConfig<StepInput, OperationInput = UploadFileInput, Oper
|
|
|
329
329
|
uploaded: StepTarget<MutationResult<OperationOutput>>;
|
|
330
330
|
/** Dropbox conclusively rejected the upload. */
|
|
331
331
|
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
332
|
-
/**
|
|
332
|
+
/** Retained for compatibility and no longer selected: malformed or oversized upload metadata now retries the overwrite. */
|
|
333
333
|
invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
|
|
334
334
|
/** Local input or connection credentials are invalid. */
|
|
335
335
|
defect?: StepTarget<MutationResult<OperationOutput>>;
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ContinueFolderDefinition,
|
|
12
12
|
ContinueFolderInputSchema,
|
|
13
13
|
ContinueFolderMetadata,
|
|
14
|
+
CredentialMaterialError,
|
|
14
15
|
DownloadFileBranch,
|
|
15
16
|
DownloadFileBranchDefect,
|
|
16
17
|
DownloadFileBranchDownloaded,
|
|
@@ -58,10 +59,11 @@ import {
|
|
|
58
59
|
emptyEntryMetadata,
|
|
59
60
|
emptyFolderPage,
|
|
60
61
|
emptyUploadedFile,
|
|
62
|
+
isCredentialMaterialError,
|
|
61
63
|
newConnection,
|
|
62
64
|
newConnectionWithOperations,
|
|
63
65
|
newProjectCredentialProvider
|
|
64
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-HC4YIUZK.js";
|
|
65
67
|
|
|
66
68
|
// src/client.ts
|
|
67
69
|
import {
|
|
@@ -70,6 +72,7 @@ import {
|
|
|
70
72
|
resolveCredential
|
|
71
73
|
} from "@superdurable/connectors-sdk";
|
|
72
74
|
import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
|
|
75
|
+
import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
|
|
73
76
|
import {
|
|
74
77
|
BodyTooLargeError,
|
|
75
78
|
isHeaderSafeCredential,
|
|
@@ -245,9 +248,10 @@ var ListFolderOperation = class {
|
|
|
245
248
|
/** List one folder page. */
|
|
246
249
|
async invoke(call, input) {
|
|
247
250
|
input = ListFolderInputSchema.parse(input);
|
|
248
|
-
|
|
251
|
+
const path = input.path ?? "";
|
|
252
|
+
if (!validPath(path, true) || !Number.isInteger(input.limit) || input.limit < 1 || input.limit > 2e3)
|
|
249
253
|
return queryFailure("listFolder", "defect", "VALIDATION", "folder path or page limit is invalid", emptyFolderPage);
|
|
250
|
-
const exchange = await this.client.postJSON(call, "/2/files/list_folder", { path
|
|
254
|
+
const exchange = await this.client.postJSON(call, "/2/files/list_folder", { path, limit: input.limit });
|
|
251
255
|
const decision = queryDecision("listFolder", exchange, emptyFolderPage, "notFound");
|
|
252
256
|
if (decision) return decision;
|
|
253
257
|
try {
|
|
@@ -369,21 +373,40 @@ var UploadFileOperation = class {
|
|
|
369
373
|
if (content.toString("base64") !== input.contentBase64) return uploadFailure("defect", "VALIDATION", "upload content must be bounded Base64");
|
|
370
374
|
if (content.length > this.client.maxUploadBytes) return uploadFailure("defect", "VALIDATION", "upload content must be bounded Base64");
|
|
371
375
|
const exchange = await this.client.upload(call, input.path, content);
|
|
372
|
-
if (exchange.error === "credential"
|
|
376
|
+
if (exchange.error === "credential" && exchange.status === 0) {
|
|
377
|
+
if ((call.context?.attempt ?? 1) > 1) return uploadRetry("AUTHENTICATION", "connection credentials are unavailable or invalid after a possible earlier upload");
|
|
378
|
+
return uploadFailure("defect", "AUTHENTICATION", "connection credentials are unavailable or invalid");
|
|
379
|
+
}
|
|
380
|
+
if (exchange.error === "credential") return uploadRetry("PROTOCOL", "Dropbox echoed the access token, so the overwrite is repeated", exchange.retryAfterMs);
|
|
373
381
|
if (exchange.error === "refresh") return uploadRetry("AVAILABILITY", "Dropbox credentials could not be refreshed");
|
|
374
382
|
if (exchange.error === "request") return uploadRetry("TRANSPORT", "Dropbox upload request failed");
|
|
375
383
|
if (exchange.status === 429) return uploadRetry("RATE_LIMIT", "Dropbox rate limited the upload", exchange.retryAfterMs);
|
|
376
384
|
if (exchange.status === 408 || exchange.status >= 500) return uploadRetry("AVAILABILITY", "Dropbox upload is temporarily unavailable", exchange.retryAfterMs);
|
|
377
|
-
if (exchange.status !== 200) return uploadFailure("providerRejected", "PROVIDER_REJECTION", `Dropbox rejected HTTP ${exchange.status}`);
|
|
378
|
-
if (exchange.
|
|
385
|
+
if (exchange.status !== 200 && isDefiniteUploadRefusal(exchange)) return uploadFailure("providerRejected", "PROVIDER_REJECTION", `Dropbox rejected HTTP ${exchange.status}`);
|
|
386
|
+
if (exchange.status !== 200) return uploadRetry("PROTOCOL", `Dropbox answered the overwrite with unsettled HTTP ${exchange.status}`, exchange.retryAfterMs);
|
|
387
|
+
if (exchange.error === "tooLarge") return uploadRetry("RESPONSE_TOO_LARGE", "Dropbox upload metadata exceeded the configured limit");
|
|
379
388
|
if (exchange.error) return uploadRetry("TRANSPORT", "Dropbox upload response was interrupted");
|
|
380
389
|
try {
|
|
381
390
|
return newMutationBranch("uploaded", { file: decodeEntry(objectBody(exchange.body), true) });
|
|
382
391
|
} catch {
|
|
383
|
-
return
|
|
392
|
+
return uploadRetry("PROTOCOL", "Dropbox returned invalid upload metadata");
|
|
384
393
|
}
|
|
385
394
|
}
|
|
386
395
|
};
|
|
396
|
+
var definiteRefusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
|
|
397
|
+
function isDefiniteUploadRefusal(exchange) {
|
|
398
|
+
if (exchange.error) return false;
|
|
399
|
+
let wire;
|
|
400
|
+
try {
|
|
401
|
+
wire = JSON.parse(Buffer.from(exchange.body).toString("utf8"));
|
|
402
|
+
} catch {
|
|
403
|
+
wire = void 0;
|
|
404
|
+
}
|
|
405
|
+
const fields = wire && typeof wire === "object" && !Array.isArray(wire) ? wire : void 0;
|
|
406
|
+
if (fields && fields.id !== void 0 && fields.id !== null && fields.id !== "") return false;
|
|
407
|
+
if (definiteRefusalStatuses.has(exchange.status)) return true;
|
|
408
|
+
return exchange.status === 409 && typeof fields?.error_summary === "string" && fields.error_summary !== "";
|
|
409
|
+
}
|
|
387
410
|
|
|
388
411
|
// src/client.ts
|
|
389
412
|
var DropboxClient = class {
|
|
@@ -464,20 +487,14 @@ var DropboxClient = class {
|
|
|
464
487
|
}, this.maxResponseBytes);
|
|
465
488
|
}
|
|
466
489
|
async post(call, url, body, headers, successLimit, isDownload = false) {
|
|
467
|
-
let
|
|
490
|
+
let credentials;
|
|
468
491
|
try {
|
|
469
|
-
|
|
470
|
-
if (!(credentials.accessToken instanceof SecretString)) return { status: 0, body: new Uint8Array(), metadata: "", retryAfterMs: 0, error: "credential" };
|
|
471
|
-
token = credentials.accessToken.reveal();
|
|
492
|
+
credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
|
|
472
493
|
} catch (error) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
body: new Uint8Array(),
|
|
476
|
-
metadata: "",
|
|
477
|
-
retryAfterMs: 0,
|
|
478
|
-
error: error instanceof ReauthorizationRequiredError ? "credential" : "refresh"
|
|
479
|
-
};
|
|
494
|
+
const isTerminal = error instanceof ReauthorizationRequiredError || error instanceof ObjectNotFoundError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError || isCredentialMaterialError(error);
|
|
495
|
+
return { status: 0, body: new Uint8Array(), metadata: "", retryAfterMs: 0, error: isTerminal ? "credential" : "refresh" };
|
|
480
496
|
}
|
|
497
|
+
const token = credentials.accessToken instanceof SecretString ? credentials.accessToken.reveal() : "";
|
|
481
498
|
if (!token || !isHeaderSafeCredential(token)) return { status: 0, body: new Uint8Array(), metadata: "", retryAfterMs: 0, error: "credential" };
|
|
482
499
|
const endpoint = new URL(url);
|
|
483
500
|
const request = {
|
|
@@ -618,6 +635,7 @@ export {
|
|
|
618
635
|
ContinueFolderInputSchema,
|
|
619
636
|
ContinueFolderMetadata,
|
|
620
637
|
ContinueFolderOperation,
|
|
638
|
+
CredentialMaterialError,
|
|
621
639
|
DownloadFileBranch,
|
|
622
640
|
DownloadFileBranchDefect,
|
|
623
641
|
DownloadFileBranchDownloaded,
|
|
@@ -667,6 +685,7 @@ export {
|
|
|
667
685
|
decodeCredentials,
|
|
668
686
|
decodeSharedCredentials,
|
|
669
687
|
header,
|
|
688
|
+
isCredentialMaterialError,
|
|
670
689
|
newConnection,
|
|
671
690
|
newConnectionWithOperations,
|
|
672
691
|
newContinueFolderStep,
|
package/dist/mock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MockQuery, MockMutation, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
2
|
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
-
import { O as Operations, e as Connection, L as ListFolderInput, F as FolderPage, G as GetMetadataInput, E as EntryMetadata, C as ContinueFolderInput, D as DownloadFileInput, a as DownloadedFile, U as UploadFileInput, b as UploadedFile } from './connection-
|
|
3
|
+
import { O as Operations, e as Connection, L as ListFolderInput, F as FolderPage, G as GetMetadataInput, E as EntryMetadata, C as ContinueFolderInput, D as DownloadFileInput, a as DownloadedFile, U as UploadFileInput, b as UploadedFile } from './connection-DtKKxEuC.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/** Go zero value for ListFolderInput in scripted cases. */
|
package/dist/mock.js
CHANGED