@superdurable/connector-amazon-s3 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dex-connector.json +124 -6
- package/dist/{chunk-OCSVX3FX.js → chunk-IGAKQPN2.js} +61 -4
- package/dist/{connection-DmewJaUl.d.ts → connection-BXFHjy1h.d.ts} +14 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +36 -6
- package/dist/mock.d.ts +1 -1
- package/dist/mock.js +1 -1
- package/package.json +3 -2
package/dex-connector.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"connectorId": "amazon-s3",
|
|
3
|
-
"releaseTag": "connectors/amazon/s3/go/v0.23.
|
|
3
|
+
"releaseTag": "connectors/amazon/s3/go/v0.23.1",
|
|
4
4
|
"package": {
|
|
5
5
|
"ecosystem": "npm",
|
|
6
6
|
"name": "@superdurable/connector-amazon-s3",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.2"
|
|
8
8
|
},
|
|
9
9
|
"factories": [
|
|
10
10
|
{
|
|
11
11
|
"name": "newListObjectsStep",
|
|
12
12
|
"kind": "query",
|
|
13
13
|
"operationId": "listObjects",
|
|
14
|
+
"inputType": "ListObjectsInput",
|
|
15
|
+
"description": "List one bounded page of a bucket's object keys and common prefixes under an optional prefix and delimiter, in key order, continuing with an opaque continuation token.",
|
|
14
16
|
"fields": {
|
|
15
17
|
"stepType": "stepType",
|
|
16
18
|
"annotations": "annotations",
|
|
@@ -43,12 +45,45 @@
|
|
|
43
45
|
"field": "defect",
|
|
44
46
|
"optional": true
|
|
45
47
|
}
|
|
46
|
-
]
|
|
48
|
+
],
|
|
49
|
+
"inputSchema": {
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"description": "ListObjectsInput selects one page of a bucket listing. Keys are listed in UTF-8 binary order.",
|
|
52
|
+
"properties": {
|
|
53
|
+
"bucket": {
|
|
54
|
+
"description": "Bucket is the bucket name; blank uses the connection's defaultBucket.",
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"continuationToken": {
|
|
58
|
+
"description": "ContinuationToken is the NextContinuationToken of the previous page; blank reads the first page.",
|
|
59
|
+
"type": "string"
|
|
60
|
+
},
|
|
61
|
+
"delimiter": {
|
|
62
|
+
"description": "Delimiter groups keys that contain it after Prefix into CommonPrefixes, usually \"/\" to list one folder level; blank lists every key under Prefix.",
|
|
63
|
+
"type": "string"
|
|
64
|
+
},
|
|
65
|
+
"maxKeys": {
|
|
66
|
+
"description": "MaxKeys bounds the objects plus common prefixes on the page, from 1 to 1000; zero uses the connection's listPageSize.",
|
|
67
|
+
"type": "integer"
|
|
68
|
+
},
|
|
69
|
+
"prefix": {
|
|
70
|
+
"description": "Prefix limits the page to keys that begin with it, such as reports/2026/; blank lists every key.",
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"startAfter": {
|
|
74
|
+
"description": "StartAfter lists only keys after this key; blank starts at the first key.",
|
|
75
|
+
"type": "string"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"type": "object"
|
|
79
|
+
}
|
|
47
80
|
},
|
|
48
81
|
{
|
|
49
82
|
"name": "newHeadObjectStep",
|
|
50
83
|
"kind": "query",
|
|
51
84
|
"operationId": "headObject",
|
|
85
|
+
"inputType": "HeadObjectInput",
|
|
86
|
+
"description": "Read one object's size, ETag, content type, modification time, version, storage class, and user-defined metadata without reading its content.",
|
|
52
87
|
"fields": {
|
|
53
88
|
"stepType": "stepType",
|
|
54
89
|
"annotations": "annotations",
|
|
@@ -81,12 +116,32 @@
|
|
|
81
116
|
"field": "defect",
|
|
82
117
|
"optional": true
|
|
83
118
|
}
|
|
84
|
-
]
|
|
119
|
+
],
|
|
120
|
+
"inputSchema": {
|
|
121
|
+
"additionalProperties": false,
|
|
122
|
+
"description": "HeadObjectInput identifies the object whose metadata is read.",
|
|
123
|
+
"properties": {
|
|
124
|
+
"bucket": {
|
|
125
|
+
"description": "Bucket is the bucket name; blank uses the connection's defaultBucket.",
|
|
126
|
+
"type": "string"
|
|
127
|
+
},
|
|
128
|
+
"key": {
|
|
129
|
+
"description": "Key is the object key, such as reports/2026-09.md.",
|
|
130
|
+
"type": "string"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"required": [
|
|
134
|
+
"key"
|
|
135
|
+
],
|
|
136
|
+
"type": "object"
|
|
137
|
+
}
|
|
85
138
|
},
|
|
86
139
|
{
|
|
87
140
|
"name": "newGetObjectTextStep",
|
|
88
141
|
"kind": "query",
|
|
89
142
|
"operationId": "getObjectText",
|
|
143
|
+
"inputType": "GetObjectTextInput",
|
|
144
|
+
"description": "Read one small text object as bounded UTF-8 text, refusing binary, compressed, and oversized objects without returning their content.",
|
|
90
145
|
"fields": {
|
|
91
146
|
"stepType": "stepType",
|
|
92
147
|
"annotations": "annotations",
|
|
@@ -129,12 +184,32 @@
|
|
|
129
184
|
"field": "defect",
|
|
130
185
|
"optional": true
|
|
131
186
|
}
|
|
132
|
-
]
|
|
187
|
+
],
|
|
188
|
+
"inputSchema": {
|
|
189
|
+
"additionalProperties": false,
|
|
190
|
+
"description": "GetObjectTextInput identifies the object whose text is read.",
|
|
191
|
+
"properties": {
|
|
192
|
+
"bucket": {
|
|
193
|
+
"description": "Bucket is the bucket name; blank uses the connection's defaultBucket.",
|
|
194
|
+
"type": "string"
|
|
195
|
+
},
|
|
196
|
+
"key": {
|
|
197
|
+
"description": "Key is the object key, such as reports/2026-09.md.",
|
|
198
|
+
"type": "string"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"required": [
|
|
202
|
+
"key"
|
|
203
|
+
],
|
|
204
|
+
"type": "object"
|
|
205
|
+
}
|
|
133
206
|
},
|
|
134
207
|
{
|
|
135
208
|
"name": "newPutObjectStep",
|
|
136
209
|
"kind": "mutation",
|
|
137
210
|
"operationId": "putObject",
|
|
211
|
+
"inputType": "PutObjectInput",
|
|
212
|
+
"description": "Store one object from bounded text or bytes with its content type and user-defined metadata, either replacing any object at the key or, in create-only mode, only when the key is free; a repeated attempt of the same Step converges on the same object.",
|
|
138
213
|
"fields": {
|
|
139
214
|
"stepType": "stepType",
|
|
140
215
|
"annotations": "annotations",
|
|
@@ -162,7 +237,50 @@
|
|
|
162
237
|
"field": "defect",
|
|
163
238
|
"optional": true
|
|
164
239
|
}
|
|
165
|
-
]
|
|
240
|
+
],
|
|
241
|
+
"inputSchema": {
|
|
242
|
+
"additionalProperties": false,
|
|
243
|
+
"description": "PutObjectInput describes one object to store. Set at most one of TextContent and ByteContent; leaving both empty stores an empty object.",
|
|
244
|
+
"properties": {
|
|
245
|
+
"bucket": {
|
|
246
|
+
"description": "Bucket is the bucket name; blank uses the connection's defaultBucket.",
|
|
247
|
+
"type": "string"
|
|
248
|
+
},
|
|
249
|
+
"byteContent": {
|
|
250
|
+
"contentEncoding": "base64",
|
|
251
|
+
"description": "ByteContent is binary content, encoded as base64 in JSON.",
|
|
252
|
+
"type": "string"
|
|
253
|
+
},
|
|
254
|
+
"contentType": {
|
|
255
|
+
"description": "ContentType is the media type S3 stores and returns, such as text/markdown; charset=utf-8.",
|
|
256
|
+
"type": "string"
|
|
257
|
+
},
|
|
258
|
+
"isCreateOnly": {
|
|
259
|
+
"description": "IsCreateOnly stores the object only when no current object exists at the key, by sending If-None-Match: *; an object that this Step execution did not write selects alreadyExists.",
|
|
260
|
+
"type": "boolean"
|
|
261
|
+
},
|
|
262
|
+
"key": {
|
|
263
|
+
"description": "Key is the object key, such as reports/2026-09.md.",
|
|
264
|
+
"type": "string"
|
|
265
|
+
},
|
|
266
|
+
"metadata": {
|
|
267
|
+
"additionalProperties": {
|
|
268
|
+
"type": "string"
|
|
269
|
+
},
|
|
270
|
+
"description": "Metadata is user-defined metadata, keyed by lowercase name without the x-amz-meta- prefix, such as report-id. Values are printable ASCII. The dex-idempotency-key name is reserved.",
|
|
271
|
+
"type": "object"
|
|
272
|
+
},
|
|
273
|
+
"textContent": {
|
|
274
|
+
"description": "TextContent is UTF-8 text content.",
|
|
275
|
+
"type": "string"
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"required": [
|
|
279
|
+
"contentType",
|
|
280
|
+
"key"
|
|
281
|
+
],
|
|
282
|
+
"type": "object"
|
|
283
|
+
}
|
|
166
284
|
}
|
|
167
285
|
]
|
|
168
286
|
}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
// src/generated/models.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
5
|
+
function isGoTimeJSON(value) {
|
|
6
|
+
const match = goTimeJSONPattern.exec(value);
|
|
7
|
+
if (!match) return false;
|
|
8
|
+
const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
|
|
9
|
+
const year = Number(yearText);
|
|
10
|
+
const month = Number(monthText);
|
|
11
|
+
const day = Number(dayText);
|
|
12
|
+
const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
13
|
+
const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
14
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
|
|
15
|
+
}
|
|
16
|
+
function canonicalGoTimeJSON(value) {
|
|
17
|
+
const match = goTimeJSONPattern.exec(value);
|
|
18
|
+
const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
|
|
19
|
+
const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
|
|
20
|
+
const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
|
|
21
|
+
const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
|
|
22
|
+
if (Math.abs(offsetMinutes) >= 1440) return value;
|
|
23
|
+
const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
|
|
24
|
+
return clock + (digits ? "." + digits : "") + offset;
|
|
25
|
+
}
|
|
26
|
+
var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
|
|
3
27
|
var ConfigSchema = z.object({
|
|
4
28
|
"region": z.string().optional(),
|
|
5
29
|
"endpoint": z.string().optional(),
|
|
@@ -10,6 +34,36 @@ var ConfigSchema = z.object({
|
|
|
10
34
|
"maxTextBytes": z.number().int().optional(),
|
|
11
35
|
"maxUploadBytes": z.number().int().optional()
|
|
12
36
|
});
|
|
37
|
+
var CredentialMaterialError = class extends TypeError {
|
|
38
|
+
constructor(message) {
|
|
39
|
+
super(message);
|
|
40
|
+
this.name = "CredentialMaterialError";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
44
|
+
"project credential decoding failed",
|
|
45
|
+
"shared project credential decoding failed",
|
|
46
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
47
|
+
]);
|
|
48
|
+
function isCredentialMaterialError(error) {
|
|
49
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
50
|
+
}
|
|
51
|
+
function decodeCredentials(value) {
|
|
52
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
53
|
+
const fields = value;
|
|
54
|
+
const allowed = /* @__PURE__ */ new Set(["access_key_id", "secret_access_key", "session_token"]);
|
|
55
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
56
|
+
if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new CredentialMaterialError("credential access_key_id has an invalid type");
|
|
57
|
+
if (fields["secret_access_key"] != null && !(typeof fields["secret_access_key"] === "string")) throw new CredentialMaterialError("credential secret_access_key has an invalid type");
|
|
58
|
+
if (fields["session_token"] != null && !(typeof fields["session_token"] === "string")) throw new CredentialMaterialError("credential session_token has an invalid type");
|
|
59
|
+
const credentials = {};
|
|
60
|
+
if (!fields["access_key_id"]) throw new CredentialMaterialError("credential access_key_id is required");
|
|
61
|
+
credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
|
|
62
|
+
if (!fields["secret_access_key"]) throw new CredentialMaterialError("credential secret_access_key is required");
|
|
63
|
+
credentials.secretAccessKey = new SecretString(fields["secret_access_key"] ?? "");
|
|
64
|
+
credentials.sessionToken = new SecretString(fields["session_token"] ?? "");
|
|
65
|
+
return credentials;
|
|
66
|
+
}
|
|
13
67
|
var ListObjectsInputSchema = z.strictObject({
|
|
14
68
|
"bucket": z.string().optional(),
|
|
15
69
|
"prefix": z.string().optional(),
|
|
@@ -22,7 +76,7 @@ var ObjectSummarySchema = z.strictObject({
|
|
|
22
76
|
"key": z.string(),
|
|
23
77
|
"sizeBytes": z.number().int(),
|
|
24
78
|
"eTag": z.string().optional(),
|
|
25
|
-
"lastModified":
|
|
79
|
+
"lastModified": GoTimeJSONSchema.optional(),
|
|
26
80
|
"storageClass": z.string().optional()
|
|
27
81
|
});
|
|
28
82
|
var ListObjectsOutputSchema = z.strictObject({
|
|
@@ -48,7 +102,7 @@ var ObjectMetadataSchema = z.strictObject({
|
|
|
48
102
|
"contentLanguage": z.string().optional(),
|
|
49
103
|
"contentDisposition": z.string().optional(),
|
|
50
104
|
"cacheControl": z.string().optional(),
|
|
51
|
-
"lastModified":
|
|
105
|
+
"lastModified": GoTimeJSONSchema.optional(),
|
|
52
106
|
"versionId": z.string().optional(),
|
|
53
107
|
"storageClass": z.string().optional(),
|
|
54
108
|
"serverSideEncryption": z.string().optional(),
|
|
@@ -65,7 +119,7 @@ var ObjectTextSchema = z.strictObject({
|
|
|
65
119
|
"contentType": z.string().optional(),
|
|
66
120
|
"eTag": z.string().optional(),
|
|
67
121
|
"versionId": z.string().optional(),
|
|
68
|
-
"lastModified":
|
|
122
|
+
"lastModified": GoTimeJSONSchema.optional(),
|
|
69
123
|
"sizeBytes": z.number().int(),
|
|
70
124
|
"text": z.string().optional()
|
|
71
125
|
});
|
|
@@ -85,7 +139,7 @@ var StoredObjectSchema = z.strictObject({
|
|
|
85
139
|
"versionId": z.string().optional(),
|
|
86
140
|
"sizeBytes": z.number().int(),
|
|
87
141
|
"contentType": z.string().optional(),
|
|
88
|
-
"lastModified":
|
|
142
|
+
"lastModified": GoTimeJSONSchema.optional(),
|
|
89
143
|
"isFromEarlierAttempt": z.boolean().optional()
|
|
90
144
|
});
|
|
91
145
|
|
|
@@ -218,6 +272,9 @@ var ConnectionNameProvider = "amazon-s3";
|
|
|
218
272
|
|
|
219
273
|
export {
|
|
220
274
|
ConfigSchema,
|
|
275
|
+
CredentialMaterialError,
|
|
276
|
+
isCredentialMaterialError,
|
|
277
|
+
decodeCredentials,
|
|
221
278
|
ListObjectsInputSchema,
|
|
222
279
|
ObjectSummarySchema,
|
|
223
280
|
ListObjectsOutputSchema,
|
|
@@ -40,6 +40,14 @@ interface Credentials {
|
|
|
40
40
|
/** Secret session token, only for temporary AWS credentials whose access key ID starts with ASIA, such as the output of aws sts get-session-token or aws sts assume-role (https://docs.aws.amazon.com/STS/latest/APIReference/API_GetSessionToken.html). Temporary credentials expire, usually within hours, and this connector cannot renew them: replace all three values before they expire, or an expired token selects providerRejected. Blank means long-term credentials, which Amazon S3 IAM user keys, Cloudflare R2, and MinIO use. */
|
|
41
41
|
sessionToken?: SecretString;
|
|
42
42
|
}
|
|
43
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
44
|
+
declare class CredentialMaterialError extends TypeError {
|
|
45
|
+
constructor(message: string);
|
|
46
|
+
}
|
|
47
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
48
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
49
|
+
/** Decode private credential fields for the connector. */
|
|
50
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
43
51
|
/** Host-owned source of private connector credentials. */
|
|
44
52
|
type CredentialSource = CredentialProvider<Credentials>;
|
|
45
53
|
/** ListObjectsInput selects one page of a bucket listing. Keys are listed in UTF-8 binary order. */
|
|
@@ -217,7 +225,7 @@ declare const ObjectSummarySchema: z.ZodObject<{
|
|
|
217
225
|
key: z.ZodString;
|
|
218
226
|
sizeBytes: z.ZodNumber;
|
|
219
227
|
eTag: z.ZodOptional<z.ZodString>;
|
|
220
|
-
lastModified: z.ZodOptional<z.
|
|
228
|
+
lastModified: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
221
229
|
storageClass: z.ZodOptional<z.ZodString>;
|
|
222
230
|
}, z.core.$strict>;
|
|
223
231
|
/** Runtime validator for ListObjectsOutput. */
|
|
@@ -229,7 +237,7 @@ declare const ListObjectsOutputSchema: z.ZodObject<{
|
|
|
229
237
|
key: z.ZodString;
|
|
230
238
|
sizeBytes: z.ZodNumber;
|
|
231
239
|
eTag: z.ZodOptional<z.ZodString>;
|
|
232
|
-
lastModified: z.ZodOptional<z.
|
|
240
|
+
lastModified: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
233
241
|
storageClass: z.ZodOptional<z.ZodString>;
|
|
234
242
|
}, z.core.$strict>>>;
|
|
235
243
|
commonPrefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -252,7 +260,7 @@ declare const ObjectMetadataSchema: z.ZodObject<{
|
|
|
252
260
|
contentLanguage: z.ZodOptional<z.ZodString>;
|
|
253
261
|
contentDisposition: z.ZodOptional<z.ZodString>;
|
|
254
262
|
cacheControl: z.ZodOptional<z.ZodString>;
|
|
255
|
-
lastModified: z.ZodOptional<z.
|
|
263
|
+
lastModified: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
256
264
|
versionId: z.ZodOptional<z.ZodString>;
|
|
257
265
|
storageClass: z.ZodOptional<z.ZodString>;
|
|
258
266
|
serverSideEncryption: z.ZodOptional<z.ZodString>;
|
|
@@ -271,7 +279,7 @@ declare const ObjectTextSchema: z.ZodObject<{
|
|
|
271
279
|
contentType: z.ZodOptional<z.ZodString>;
|
|
272
280
|
eTag: z.ZodOptional<z.ZodString>;
|
|
273
281
|
versionId: z.ZodOptional<z.ZodString>;
|
|
274
|
-
lastModified: z.ZodOptional<z.
|
|
282
|
+
lastModified: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
275
283
|
sizeBytes: z.ZodNumber;
|
|
276
284
|
text: z.ZodOptional<z.ZodString>;
|
|
277
285
|
}, z.core.$strict>;
|
|
@@ -293,7 +301,7 @@ declare const StoredObjectSchema: z.ZodObject<{
|
|
|
293
301
|
versionId: z.ZodOptional<z.ZodString>;
|
|
294
302
|
sizeBytes: z.ZodNumber;
|
|
295
303
|
contentType: z.ZodOptional<z.ZodString>;
|
|
296
|
-
lastModified: z.ZodOptional<z.
|
|
304
|
+
lastModified: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
297
305
|
isFromEarlierAttempt: z.ZodOptional<z.ZodBoolean>;
|
|
298
306
|
}, z.core.$strict>;
|
|
299
307
|
|
|
@@ -324,4 +332,4 @@ declare function newConnectionWithOperations(operations: Operations, reference:
|
|
|
324
332
|
/** Provider expected by named connections. */
|
|
325
333
|
declare const ConnectionNameProvider = "amazon-s3";
|
|
326
334
|
|
|
327
|
-
export { type Config as C, type GetObjectTextInput as G, type HeadObjectInput as H, type ListObjectsInput as L, type ObjectText as O, type PutObjectInput as P, type StoredObject as S, type ListObjectsOutput as a, type ObjectMetadata as b, type Credentials as c, Connection as d, type Operations as e, ConfigSchema as f, ConnectionNameProvider as g, type CredentialSource as
|
|
335
|
+
export { type Config as C, type GetObjectTextInput as G, type HeadObjectInput as H, type ListObjectsInput as L, type ObjectText as O, type PutObjectInput as P, type StoredObject as S, type ListObjectsOutput as a, type ObjectMetadata as b, type Credentials as c, Connection as d, type Operations as e, ConfigSchema as f, ConnectionNameProvider as g, CredentialMaterialError as h, type CredentialSource as i, GetObjectTextInputSchema as j, HeadObjectInputSchema as k, ListObjectsInputSchema as l, ListObjectsOutputSchema as m, ObjectMetadataSchema as n, type ObjectSummary as o, ObjectSummarySchema as p, ObjectTextSchema as q, PutObjectInputSchema as r, StoredObjectSchema as s, decodeCredentials as t, isCredentialMaterialError as u, newConnection as v, newConnectionWithOperations as w };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GetObjectTextInput, O as ObjectText, L as ListObjectsInput, a as ListObjectsOutput, H as HeadObjectInput, b as ObjectMetadata, P as PutObjectInput, S as StoredObject, C as Config, c as Credentials, d as Connection, e as Operations } from './connection-
|
|
2
|
-
export { f as ConfigSchema, g as ConnectionNameProvider, h as
|
|
1
|
+
import { G as GetObjectTextInput, O as ObjectText, L as ListObjectsInput, a as ListObjectsOutput, H as HeadObjectInput, b as ObjectMetadata, P as PutObjectInput, S as StoredObject, C as Config, c as Credentials, d as Connection, e as Operations } from './connection-BXFHjy1h.js';
|
|
2
|
+
export { f as ConfigSchema, g as ConnectionNameProvider, h as CredentialMaterialError, i as CredentialSource, j as GetObjectTextInputSchema, k as HeadObjectInputSchema, l as ListObjectsInputSchema, m as ListObjectsOutputSchema, n as ObjectMetadataSchema, o as ObjectSummary, p as ObjectSummarySchema, q as ObjectTextSchema, r as PutObjectInputSchema, s as StoredObjectSchema, t as decodeCredentials, u as isCredentialMaterialError, v as newConnection, w as newConnectionWithOperations } from './connection-BXFHjy1h.js';
|
|
3
3
|
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
4
|
import { QueryDefinition, MutationDefinition, Query, Call, QueryAttempt, Mutation, MutationAttempt, CredentialProvider, ReceiptDraft, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep } from '@superdurable/connectors-sdk';
|
|
5
5
|
import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
|
|
@@ -206,6 +206,8 @@ declare class S3Client {
|
|
|
206
206
|
/** Bind the object write mutation. */ putObject(): PutObjectOperation;
|
|
207
207
|
/** Resolve current credentials once per Invoke without exposing secret-bearing errors. */
|
|
208
208
|
startSession(call: Call): Promise<S3Session | undefined>;
|
|
209
|
+
/** Return null for a transient credential failure and undefined for a terminal or invalid one. */
|
|
210
|
+
private resolveSession;
|
|
209
211
|
/** Resolve and validate an input bucket. */
|
|
210
212
|
bucket(inputBucket?: string): string;
|
|
211
213
|
/** Send a SigV4 request once; Dex owns operation retries. */
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Connection,
|
|
4
4
|
ConnectionNameProvider,
|
|
5
5
|
ConnectorID,
|
|
6
|
+
CredentialMaterialError,
|
|
6
7
|
GetObjectTextBranch,
|
|
7
8
|
GetObjectTextBranchDefect,
|
|
8
9
|
GetObjectTextBranchInvalidResponse,
|
|
@@ -46,13 +47,17 @@ import {
|
|
|
46
47
|
PutObjectInputSchema,
|
|
47
48
|
PutObjectMetadata,
|
|
48
49
|
StoredObjectSchema,
|
|
50
|
+
decodeCredentials,
|
|
51
|
+
isCredentialMaterialError,
|
|
49
52
|
newConnection,
|
|
50
53
|
newConnectionWithOperations
|
|
51
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-IGAKQPN2.js";
|
|
52
55
|
|
|
53
56
|
// src/client.ts
|
|
54
57
|
import { createHash as createHash2, createHmac } from "crypto";
|
|
55
58
|
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
59
|
+
import { ReauthorizationRequiredError } from "@superdurable/connectors-sdk";
|
|
60
|
+
import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
|
|
56
61
|
|
|
57
62
|
// src/operations.ts
|
|
58
63
|
import { createHash } from "crypto";
|
|
@@ -87,7 +92,8 @@ var ListObjectsOperation = class {
|
|
|
87
92
|
}
|
|
88
93
|
const maxKeys = input.maxKeys || this.client.listPageSize;
|
|
89
94
|
if (!Number.isSafeInteger(maxKeys) || maxKeys < 1 || maxKeys > 1e3) return defectQuery(operation, zeroList, "maxKeys must be from 1 to 1000");
|
|
90
|
-
const session = await this.client
|
|
95
|
+
const session = await this.client["resolveSession"](call);
|
|
96
|
+
if (session === null) return newQueryRetry(credentialRetryFailure(operation));
|
|
91
97
|
if (!session) return credentialDefectQuery(operation, zeroList);
|
|
92
98
|
const query = { "list-type": "2", "encoding-type": "url", "max-keys": String(maxKeys) };
|
|
93
99
|
if (input.prefix) query.prefix = input.prefix;
|
|
@@ -136,7 +142,8 @@ var HeadObjectOperation = class {
|
|
|
136
142
|
} catch (error) {
|
|
137
143
|
return defectQuery(operation, zeroMetadata, errorMessage(error));
|
|
138
144
|
}
|
|
139
|
-
const session = await this.client
|
|
145
|
+
const session = await this.client["resolveSession"](call);
|
|
146
|
+
if (session === null) return newQueryRetry(credentialRetryFailure(operation));
|
|
140
147
|
if (!session) return credentialDefectQuery(operation, zeroMetadata);
|
|
141
148
|
const identity = { bucket, key: input.key, sizeBytes: 0 };
|
|
142
149
|
let response;
|
|
@@ -173,7 +180,8 @@ var GetObjectTextOperation = class {
|
|
|
173
180
|
} catch (error) {
|
|
174
181
|
return defectQuery(operation, zeroText, errorMessage(error));
|
|
175
182
|
}
|
|
176
|
-
const session = await this.client
|
|
183
|
+
const session = await this.client["resolveSession"](call);
|
|
184
|
+
if (session === null) return newQueryRetry(credentialRetryFailure(operation));
|
|
177
185
|
if (!session) return credentialDefectQuery(operation, zeroText);
|
|
178
186
|
const identity = { bucket, key: input.key, sizeBytes: 0 };
|
|
179
187
|
let response;
|
|
@@ -243,7 +251,8 @@ var PutObjectOperation = class {
|
|
|
243
251
|
} catch (error) {
|
|
244
252
|
return defectMutation(zeroStored, errorMessage(error));
|
|
245
253
|
}
|
|
246
|
-
const session = await this.client
|
|
254
|
+
const session = await this.client["resolveSession"](call);
|
|
255
|
+
if (session === null) return newMutationRetry(credentialRetryFailure(operation));
|
|
247
256
|
if (!session) return newMutationBranch("defect", zeroStored, {}, failure(operation, "AUTHENTICATION", "S3 connection credentials are unavailable"));
|
|
248
257
|
const requested = { bucket, key: input.key, sizeBytes: content.length, contentType: input.contentType };
|
|
249
258
|
const headers = { "content-type": input.contentType, "content-md5": createHash("md5").update(content).digest("base64"), "x-amz-meta-dex-idempotency-key": call.id };
|
|
@@ -264,6 +273,8 @@ var PutObjectOperation = class {
|
|
|
264
273
|
if (input.isCreateOnly && response.status === 412) return this.readExisting(call, session, requested);
|
|
265
274
|
const classified = classify(operation, "object write", response, session, false, this.client.currentTime());
|
|
266
275
|
if (classified.retry) return newMutationRetry(classified.failure, classified.retryAfterMs);
|
|
276
|
+
if (!definiteWriteRefusalStatuses.has(response.status))
|
|
277
|
+
return newMutationRetry(failure(operation, "AVAILABILITY", "S3 answered the object write ambiguously"));
|
|
267
278
|
return newMutationBranch("providerRejected", requested, receipt, classified.failure);
|
|
268
279
|
}
|
|
269
280
|
async readExisting(call, session, requested) {
|
|
@@ -291,6 +302,7 @@ var PutObjectOperation = class {
|
|
|
291
302
|
return newMutationBranch("alreadyExists", stored, receipt, failure("putObject", "CONFLICT", "another object already exists"));
|
|
292
303
|
}
|
|
293
304
|
};
|
|
305
|
+
var definiteWriteRefusalStatuses = /* @__PURE__ */ new Set([301, 400, 401, 403, 404, 411, 413, 414, 415, 422, 501]);
|
|
294
306
|
function failure(operation, kind, message) {
|
|
295
307
|
return { provider: "amazon-s3", operation, kind, message };
|
|
296
308
|
}
|
|
@@ -300,6 +312,9 @@ function errorMessage(error) {
|
|
|
300
312
|
function defectQuery(operation, value, message) {
|
|
301
313
|
return newQueryBranch("defect", value, {}, failure(operation, "VALIDATION", message));
|
|
302
314
|
}
|
|
315
|
+
function credentialRetryFailure(operation) {
|
|
316
|
+
return failure(operation, "AVAILABILITY", "S3 connection credentials are temporarily unavailable; nothing was sent");
|
|
317
|
+
}
|
|
303
318
|
function credentialDefectQuery(operation, value) {
|
|
304
319
|
return newQueryBranch("defect", value, {}, failure(operation, "AUTHENTICATION", "S3 connection credentials are unavailable"));
|
|
305
320
|
}
|
|
@@ -424,6 +439,9 @@ function validatePutHeaders(input) {
|
|
|
424
439
|
}
|
|
425
440
|
|
|
426
441
|
// src/client.ts
|
|
442
|
+
function isTerminalCredentialError(error) {
|
|
443
|
+
return isCredentialMaterialError(error) || error instanceof ReauthorizationRequiredError || error instanceof ObjectNotFoundError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError;
|
|
444
|
+
}
|
|
427
445
|
var emptyHash = createHash2("sha256").update("").digest("hex");
|
|
428
446
|
var encoder = new TextEncoder();
|
|
429
447
|
var S3Client = class {
|
|
@@ -482,8 +500,17 @@ var S3Client = class {
|
|
|
482
500
|
}
|
|
483
501
|
/** Resolve current credentials once per Invoke without exposing secret-bearing errors. */
|
|
484
502
|
async startSession(call) {
|
|
503
|
+
return await this.resolveSession(call) ?? void 0;
|
|
504
|
+
}
|
|
505
|
+
/** Return null for a transient credential failure and undefined for a terminal or invalid one. */
|
|
506
|
+
async resolveSession(call) {
|
|
507
|
+
let credentials;
|
|
508
|
+
try {
|
|
509
|
+
credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
510
|
+
} catch (error) {
|
|
511
|
+
return isTerminalCredentialError(error) ? void 0 : null;
|
|
512
|
+
}
|
|
485
513
|
try {
|
|
486
|
-
const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
487
514
|
const accessKeyId = credentials.accessKeyId.reveal();
|
|
488
515
|
const secretAccessKey = credentials.secretAccessKey.reveal();
|
|
489
516
|
const sessionToken = credentials.sessionToken?.reveal() ?? "";
|
|
@@ -662,6 +689,7 @@ export {
|
|
|
662
689
|
Connection,
|
|
663
690
|
ConnectionNameProvider,
|
|
664
691
|
ConnectorID,
|
|
692
|
+
CredentialMaterialError,
|
|
665
693
|
GetObjectTextBranch,
|
|
666
694
|
GetObjectTextBranchDefect,
|
|
667
695
|
GetObjectTextBranchInvalidResponse,
|
|
@@ -711,7 +739,9 @@ export {
|
|
|
711
739
|
S3Client,
|
|
712
740
|
StoredObjectSchema,
|
|
713
741
|
containsCredential,
|
|
742
|
+
decodeCredentials,
|
|
714
743
|
header,
|
|
744
|
+
isCredentialMaterialError,
|
|
715
745
|
newConnection,
|
|
716
746
|
newConnectionWithOperations,
|
|
717
747
|
newGetObjectTextStep,
|
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 { e as Operations, d as Connection, L as ListObjectsInput, a as ListObjectsOutput, H as HeadObjectInput, b as ObjectMetadata, G as GetObjectTextInput, O as ObjectText, P as PutObjectInput, S as StoredObject,
|
|
3
|
+
import { e as Operations, d as Connection, L as ListObjectsInput, a as ListObjectsOutput, H as HeadObjectInput, b as ObjectMetadata, G as GetObjectTextInput, O as ObjectText, P as PutObjectInput, S as StoredObject, o as ObjectSummary } from './connection-BXFHjy1h.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/** Go zero value for ListObjectsInput in scripted cases. */
|
package/dist/mock.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
PutObjectInputSchema,
|
|
16
16
|
StoredObjectSchema,
|
|
17
17
|
newConnectionWithOperations
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-IGAKQPN2.js";
|
|
19
19
|
|
|
20
20
|
// src/generated/mock.ts
|
|
21
21
|
import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-amazon-s3",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Amazon S3 object operations for Dex",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"./mock": {
|
|
26
26
|
"types": "./dist/mock.d.ts",
|
|
27
27
|
"import": "./dist/mock.js"
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
32
|
"dist",
|