@superdurable/connector-amazon-sqs 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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `@superdurable/connector-amazon-sqs` implements `receiveMessages`, `deleteMessage`, and `changeMessageVisibility` as Dex Mutations. The package includes generated operation models, Step factories, mock cases, and `dex-connector.json`; hand-written code signs the SQS JSON protocol with AWS Signature Version 4 and classifies provider outcomes. It has no Trigger.
4
4
 
5
- Install the published package with `npm install @superdurable/connector-amazon-sqs@0.1.0`. Node.js 22 or 24 is required by the Connector SDK. For this checkout, run `npm ci` from this directory.
5
+ Install the published package with `npm install @superdurable/connector-amazon-sqs@0.1.2`. Node.js 22 or 24 is required by the Connector SDK. For this checkout, run `npm ci` from this directory.
6
6
 
7
7
  ## Connection
8
8
 
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "connectorId": "amazon-sqs",
3
- "releaseTag": "connectors/amazon/sqs/go/v0.3.0",
3
+ "releaseTag": "connectors/amazon/sqs/go/v0.3.1",
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-amazon-sqs",
7
- "version": "0.1.1"
7
+ "version": "0.1.2"
8
8
  },
9
9
  "factories": [
10
10
  {
11
11
  "name": "newReceiveMessagesStep",
12
12
  "kind": "mutation",
13
13
  "operationId": "receiveMessages",
14
+ "inputType": "ReceiveMessagesInput",
15
+ "description": "Long-poll one queue for up to ten messages with their bodies, receipt handles, receive counts, and message attributes, hiding each received message from other consumers for its visibility timeout.",
14
16
  "fields": {
15
17
  "stepType": "stepType",
16
18
  "annotations": "annotations",
@@ -43,12 +45,37 @@
43
45
  "field": "defect",
44
46
  "optional": true
45
47
  }
46
- ]
48
+ ],
49
+ "inputSchema": {
50
+ "additionalProperties": false,
51
+ "description": "ReceiveMessagesInput selects one queue and how long and how many messages to wait for.",
52
+ "properties": {
53
+ "maxMessages": {
54
+ "description": "MaxMessages is the most messages to receive, from 1 to 10; zero uses the connection's maxMessagesPerReceive.",
55
+ "type": "integer"
56
+ },
57
+ "queueUrl": {
58
+ "description": "QueueURL is the queue URL, such as https://sqs.eu-west-1.amazonaws.com/123456789012/orders; blank uses the connection's defaultQueueUrl.",
59
+ "type": "string"
60
+ },
61
+ "visibilityTimeoutSeconds": {
62
+ "description": "VisibilityTimeoutSeconds hides each received message from other consumers for this many seconds, from 0 to 43200; nil uses the queue's own visibility timeout.",
63
+ "type": "integer"
64
+ },
65
+ "waitTimeSeconds": {
66
+ "description": "WaitTimeSeconds is how long to wait for a message to arrive, from 0 to 20 seconds; nil uses the connection's receiveWaitSeconds, and 0 returns at once.",
67
+ "type": "integer"
68
+ }
69
+ },
70
+ "type": "object"
71
+ }
47
72
  },
48
73
  {
49
74
  "name": "newDeleteMessageStep",
50
75
  "kind": "mutation",
51
76
  "operationId": "deleteMessage",
77
+ "inputType": "DeleteMessageInput",
78
+ "description": "Acknowledge one received message by deleting it from its queue with the receipt handle of its latest delivery, so SQS does not deliver it again; repeating an attempt is safe.",
52
79
  "fields": {
53
80
  "stepType": "stepType",
54
81
  "annotations": "annotations",
@@ -76,12 +103,36 @@
76
103
  "field": "defect",
77
104
  "optional": true
78
105
  }
79
- ]
106
+ ],
107
+ "inputSchema": {
108
+ "additionalProperties": false,
109
+ "description": "DeleteMessageInput acknowledges one received message.",
110
+ "properties": {
111
+ "messageId": {
112
+ "description": "MessageID optionally names the message in the Result and receipt; it is not sent to SQS.",
113
+ "type": "string"
114
+ },
115
+ "queueUrl": {
116
+ "description": "QueueURL is the queue the message came from; blank uses the connection's defaultQueueUrl.",
117
+ "type": "string"
118
+ },
119
+ "receiptHandle": {
120
+ "description": "ReceiptHandle is the handle of the message's latest delivery, from receiveMessages.",
121
+ "type": "string"
122
+ }
123
+ },
124
+ "required": [
125
+ "receiptHandle"
126
+ ],
127
+ "type": "object"
128
+ }
80
129
  },
81
130
  {
82
131
  "name": "newChangeMessageVisibilityStep",
83
132
  "kind": "mutation",
84
133
  "operationId": "changeMessageVisibility",
134
+ "inputType": "ChangeMessageVisibilityInput",
135
+ "description": "Release one received message back to the queue at once with a zero timeout, or hide it for longer while the Flow keeps processing it, by setting its visibility timeout from now.",
85
136
  "fields": {
86
137
  "stepType": "stepType",
87
138
  "annotations": "annotations",
@@ -109,7 +160,34 @@
109
160
  "field": "defect",
110
161
  "optional": true
111
162
  }
112
- ]
163
+ ],
164
+ "inputSchema": {
165
+ "additionalProperties": false,
166
+ "description": "ChangeMessageVisibilityInput releases one received message or hides it for longer.",
167
+ "properties": {
168
+ "messageId": {
169
+ "description": "MessageID optionally names the message in the Result and receipt; it is not sent to SQS.",
170
+ "type": "string"
171
+ },
172
+ "queueUrl": {
173
+ "description": "QueueURL is the queue the message came from; blank uses the connection's defaultQueueUrl.",
174
+ "type": "string"
175
+ },
176
+ "receiptHandle": {
177
+ "description": "ReceiptHandle is the handle of the message's latest delivery, from receiveMessages.",
178
+ "type": "string"
179
+ },
180
+ "visibilityTimeoutSeconds": {
181
+ "description": "VisibilityTimeoutSeconds hides the message for this many seconds from now, from 0 to 43200. Zero releases it to other consumers at once. SQS caps a message's total in-flight time at 12 hours from its first receive.",
182
+ "type": "integer"
183
+ }
184
+ },
185
+ "required": [
186
+ "receiptHandle",
187
+ "visibilityTimeoutSeconds"
188
+ ],
189
+ "type": "object"
190
+ }
113
191
  }
114
192
  ]
115
193
  }
@@ -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(),
@@ -8,6 +32,36 @@ var ConfigSchema = z.object({
8
32
  "receiveWaitSeconds": z.number().int().optional(),
9
33
  "maxResponseBytes": z.number().int().optional()
10
34
  });
35
+ var CredentialMaterialError = class extends TypeError {
36
+ constructor(message) {
37
+ super(message);
38
+ this.name = "CredentialMaterialError";
39
+ }
40
+ };
41
+ var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
42
+ "project credential decoding failed",
43
+ "shared project credential decoding failed",
44
+ "project credential decoding failed: this connector version does not support shared credentials"
45
+ ]);
46
+ function isCredentialMaterialError(error) {
47
+ return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
48
+ }
49
+ function decodeCredentials(value) {
50
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
51
+ const fields = value;
52
+ const allowed = /* @__PURE__ */ new Set(["access_key_id", "secret_access_key", "session_token"]);
53
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
54
+ if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new CredentialMaterialError("credential access_key_id has an invalid type");
55
+ if (fields["secret_access_key"] != null && !(typeof fields["secret_access_key"] === "string")) throw new CredentialMaterialError("credential secret_access_key has an invalid type");
56
+ if (fields["session_token"] != null && !(typeof fields["session_token"] === "string")) throw new CredentialMaterialError("credential session_token has an invalid type");
57
+ const credentials = {};
58
+ if (!fields["access_key_id"]) throw new CredentialMaterialError("credential access_key_id is required");
59
+ credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
60
+ if (!fields["secret_access_key"]) throw new CredentialMaterialError("credential secret_access_key is required");
61
+ credentials.secretAccessKey = new SecretString(fields["secret_access_key"] ?? "");
62
+ credentials.sessionToken = new SecretString(fields["session_token"] ?? "");
63
+ return credentials;
64
+ }
11
65
  var ReceiveMessagesInputSchema = z.strictObject({
12
66
  "queueUrl": z.string().optional(),
13
67
  "maxMessages": z.number().int().optional(),
@@ -24,8 +78,8 @@ var MessageSchema = z.strictObject({
24
78
  "receiptHandle": z.string(),
25
79
  "body": z.string(),
26
80
  "md5OfBody": z.string(),
27
- "sentAt": z.iso.datetime({ offset: true }).optional(),
28
- "firstReceivedAt": z.iso.datetime({ offset: true }).optional(),
81
+ "sentAt": GoTimeJSONSchema.optional(),
82
+ "firstReceivedAt": GoTimeJSONSchema.optional(),
29
83
  "receiveCount": z.number().int(),
30
84
  "messageGroupId": z.string().optional(),
31
85
  "messageDeduplicationId": z.string().optional(),
@@ -56,7 +110,7 @@ var ChangedMessageVisibilitySchema = z.strictObject({
56
110
  "queueUrl": z.string(),
57
111
  "messageId": z.string().optional(),
58
112
  "visibilityTimeoutSeconds": z.number().int(),
59
- "visibleAfter": z.iso.datetime({ offset: true })
113
+ "visibleAfter": GoTimeJSONSchema
60
114
  });
61
115
 
62
116
  // src/generated/definitions.ts
@@ -154,6 +208,9 @@ function newConnectionWithOperations(operations, reference) {
154
208
 
155
209
  export {
156
210
  ConfigSchema,
211
+ CredentialMaterialError,
212
+ isCredentialMaterialError,
213
+ decodeCredentials,
157
214
  ReceiveMessagesInputSchema,
158
215
  MessageAttributeValueSchema,
159
216
  MessageSchema,
@@ -34,6 +34,14 @@ interface Credentials {
34
34
  /** 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 IAM user keys use. */
35
35
  sessionToken?: SecretString;
36
36
  }
37
+ /** Stored credential material that fails the connector credential checks, so no retry can succeed. */
38
+ declare class CredentialMaterialError extends TypeError {
39
+ constructor(message: string);
40
+ }
41
+ /** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
42
+ declare function isCredentialMaterialError(error: unknown): boolean;
43
+ /** Decode private credential fields for the connector. */
44
+ declare function decodeCredentials(value: unknown): Credentials;
37
45
  /** Host-owned source of private connector credentials. */
38
46
  type CredentialSource = CredentialProvider<Credentials>;
39
47
  /** ReceiveMessagesInput selects one queue and how long and how many messages to wait for. */
@@ -156,8 +164,8 @@ declare const MessageSchema: z.ZodObject<{
156
164
  receiptHandle: z.ZodString;
157
165
  body: z.ZodString;
158
166
  md5OfBody: z.ZodString;
159
- sentAt: z.ZodOptional<z.ZodISODateTime>;
160
- firstReceivedAt: z.ZodOptional<z.ZodISODateTime>;
167
+ sentAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
168
+ firstReceivedAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
161
169
  receiveCount: z.ZodNumber;
162
170
  messageGroupId: z.ZodOptional<z.ZodString>;
163
171
  messageDeduplicationId: z.ZodOptional<z.ZodString>;
@@ -177,8 +185,8 @@ declare const ReceivedMessagesSchema: z.ZodObject<{
177
185
  receiptHandle: z.ZodString;
178
186
  body: z.ZodString;
179
187
  md5OfBody: z.ZodString;
180
- sentAt: z.ZodOptional<z.ZodISODateTime>;
181
- firstReceivedAt: z.ZodOptional<z.ZodISODateTime>;
188
+ sentAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
189
+ firstReceivedAt: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
182
190
  receiveCount: z.ZodNumber;
183
191
  messageGroupId: z.ZodOptional<z.ZodString>;
184
192
  messageDeduplicationId: z.ZodOptional<z.ZodString>;
@@ -213,7 +221,7 @@ declare const ChangedMessageVisibilitySchema: z.ZodObject<{
213
221
  queueUrl: z.ZodString;
214
222
  messageId: z.ZodOptional<z.ZodString>;
215
223
  visibilityTimeoutSeconds: z.ZodNumber;
216
- visibleAfter: z.ZodISODateTime;
224
+ visibleAfter: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
217
225
  }, z.core.$strict>;
218
226
 
219
227
  /** Typed operations supplied by a client or mock. */
@@ -239,4 +247,4 @@ declare function newConnection(client: Operations, reference: ConnectionRef): Co
239
247
  /** Bind scripted operations to a named connection. */
240
248
  declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
241
249
 
242
- export { type ChangeMessageVisibilityInput as C, type DeleteMessageInput as D, type Message as M, type Operations as O, type ReceiveMessagesInput as R, type ChangedMessageVisibility as a, Connection as b, type DeletedMessage as c, type ReceivedMessages as d, type Config as e, type Credentials as f, ChangeMessageVisibilityInputSchema as g, ChangedMessageVisibilitySchema as h, ConfigSchema as i, type CredentialSource as j, DeleteMessageInputSchema as k, DeletedMessageSchema as l, type MessageAttributeValue as m, MessageAttributeValueSchema as n, MessageSchema as o, ReceiveMessagesInputSchema as p, ReceivedMessagesSchema as q, newConnection as r, newConnectionWithOperations as s };
250
+ export { type ChangeMessageVisibilityInput as C, type DeleteMessageInput as D, type Message as M, type Operations as O, type ReceiveMessagesInput as R, type ChangedMessageVisibility as a, Connection as b, type DeletedMessage as c, type ReceivedMessages as d, type Config as e, type Credentials as f, ChangeMessageVisibilityInputSchema as g, ChangedMessageVisibilitySchema as h, ConfigSchema as i, CredentialMaterialError as j, type CredentialSource as k, DeleteMessageInputSchema as l, DeletedMessageSchema as m, type MessageAttributeValue as n, MessageAttributeValueSchema as o, MessageSchema as p, ReceiveMessagesInputSchema as q, ReceivedMessagesSchema as r, decodeCredentials 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 ChangeMessageVisibilityInput, a as ChangedMessageVisibility, b as Connection, D as DeleteMessageInput, c as DeletedMessage, R as ReceiveMessagesInput, d as ReceivedMessages, e as Config, f as Credentials, O as Operations } from './connection-DqOJtCt2.js';
2
- export { g as ChangeMessageVisibilityInputSchema, h as ChangedMessageVisibilitySchema, i as ConfigSchema, j as CredentialSource, k as DeleteMessageInputSchema, l as DeletedMessageSchema, M as Message, m as MessageAttributeValue, n as MessageAttributeValueSchema, o as MessageSchema, p as ReceiveMessagesInputSchema, q as ReceivedMessagesSchema, r as newConnection, s as newConnectionWithOperations } from './connection-DqOJtCt2.js';
1
+ import { C as ChangeMessageVisibilityInput, a as ChangedMessageVisibility, b as Connection, D as DeleteMessageInput, c as DeletedMessage, R as ReceiveMessagesInput, d as ReceivedMessages, e as Config, f as Credentials, O as Operations } from './connection-BC2kNwv9.js';
2
+ export { g as ChangeMessageVisibilityInputSchema, h as ChangedMessageVisibilitySchema, i as ConfigSchema, j as CredentialMaterialError, k as CredentialSource, l as DeleteMessageInputSchema, m as DeletedMessageSchema, M as Message, n as MessageAttributeValue, o as MessageAttributeValueSchema, p as MessageSchema, q as ReceiveMessagesInputSchema, r as ReceivedMessagesSchema, s as decodeCredentials, t as isCredentialMaterialError, u as newConnection, v as newConnectionWithOperations } from './connection-BC2kNwv9.js';
3
3
  import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
4
4
  import { MutationDefinition, MutationStepConfig, Mutation, MutationResult, MutationStep, Call, MutationAttempt, CredentialProvider, Receipt, Failure } from '@superdurable/connectors-sdk';
5
5
  import { StepTarget } from '@superdurable/dex';
@@ -212,6 +212,8 @@ declare class SQSClient {
212
212
  resolveQueue(inputQueueUrl: string | undefined): QueueAddress;
213
213
  /** Resolve one current access key without retaining it in a result. */
214
214
  resolveCredentials(call: Call): Promise<Credentials | undefined>;
215
+ /** Return null for a transient credential failure and undefined for a terminal or invalid one. */
216
+ private resolveCredentialsOrTransient;
215
217
  /** Sign and send one JSON-protocol action with AWS Signature Version 4. */
216
218
  exchange(call: Call, credentials: Credentials, action: string, requestBody: object): Promise<SQSResponse>;
217
219
  /** Build one secret-safe receipt. */
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  ConfigSchema,
12
12
  Connection,
13
13
  ConnectorID,
14
+ CredentialMaterialError,
14
15
  DeleteMessageBranch,
15
16
  DeleteMessageBranchDefect,
16
17
  DeleteMessageBranchDeleted,
@@ -33,9 +34,11 @@ import {
33
34
  ReceiveMessagesInputSchema,
34
35
  ReceiveMessagesMetadata,
35
36
  ReceivedMessagesSchema,
37
+ decodeCredentials,
38
+ isCredentialMaterialError,
36
39
  newConnection,
37
40
  newConnectionWithOperations
38
- } from "./chunk-JUNMI7YJ.js";
41
+ } from "./chunk-GUYXQWWQ.js";
39
42
 
40
43
  // src/generated/steps.ts
41
44
  import { goToBranch, newMutationStep } from "@superdurable/connectors-sdk";
@@ -73,6 +76,8 @@ function newChangeMessageVisibilityStep(configuration) {
73
76
 
74
77
  // src/client.ts
75
78
  import { createHash as createHash2, createHmac } from "crypto";
79
+ import { ReauthorizationRequiredError } from "@superdurable/connectors-sdk";
80
+ import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
76
81
  import { BodyTooLargeError, parseRetryAfter, sendProviderRequest } from "@superdurable/connectors-sdk/providerhttp";
77
82
 
78
83
  // src/operations.ts
@@ -90,6 +95,9 @@ function failure(operation, kind, message) {
90
95
  function defect(operation, output, message) {
91
96
  return newMutationBranch("defect", output, zeroReceipt(), failure(operation, "VALIDATION", message));
92
97
  }
98
+ function credentialsRetry(operation) {
99
+ return newMutationRetry(failure(operation, "AVAILABILITY", "SQS connection credentials are temporarily unavailable; nothing was sent"));
100
+ }
93
101
  function credentialsDefect(operation, output) {
94
102
  return newMutationBranch("defect", output, zeroReceipt(), failure(operation, "AUTHENTICATION", "SQS connection credentials are unavailable; save an access key ID and secret access key for the connection"));
95
103
  }
@@ -146,7 +154,8 @@ var ReceiveMessagesOperation = class {
146
154
  if (visibility !== void 0 && (!Number.isSafeInteger(visibility) || visibility < 0 || visibility > 43200)) return defect(operation, zeroReceived, "visibilityTimeoutSeconds must be from 0 to 43200");
147
155
  const attemptId = call.idempotencyKey ?? "";
148
156
  if (queue.isFIFO && (!attemptId || Buffer.byteLength(attemptId) > 128 || !printable.test(attemptId))) return defect(operation, zeroReceived, "idempotency key is missing or not a valid ReceiveRequestAttemptId");
149
- const credentials = await this.client.resolveCredentials(call);
157
+ const credentials = await this.client["resolveCredentialsOrTransient"](call);
158
+ if (credentials === null) return credentialsRetry(operation);
150
159
  if (!credentials) return credentialsDefect(operation, zeroReceived);
151
160
  const batch = { queueUrl: queue.url, ...queue.isFIFO ? { isFifo: true } : {} };
152
161
  const attributes = receiveSystemAttributes();
@@ -208,7 +217,8 @@ var DeleteMessageOperation = class {
208
217
  } catch (error2) {
209
218
  return defect(operation, zeroDeleted, error2.message);
210
219
  }
211
- const credentials = await this.client.resolveCredentials(call);
220
+ const credentials = await this.client["resolveCredentialsOrTransient"](call);
221
+ if (credentials === null) return credentialsRetry(operation);
212
222
  if (!credentials) return credentialsDefect(operation, zeroDeleted);
213
223
  const deleted = { queueUrl: queue.url, ...input.messageId ? { messageId: input.messageId } : {} };
214
224
  const objectId = input.messageId ? `${queue.url}#${input.messageId}` : queue.url;
@@ -247,7 +257,8 @@ var ChangeMessageVisibilityOperation = class {
247
257
  return defect(operation, zeroChanged, error.message);
248
258
  }
249
259
  if (!Number.isSafeInteger(input.visibilityTimeoutSeconds) || input.visibilityTimeoutSeconds < 0 || input.visibilityTimeoutSeconds > 43200) return defect(operation, zeroChanged, "visibilityTimeoutSeconds must be from 0 to 43200");
250
- const credentials = await this.client.resolveCredentials(call);
260
+ const credentials = await this.client["resolveCredentialsOrTransient"](call);
261
+ if (credentials === null) return credentialsRetry(operation);
251
262
  if (!credentials) return credentialsDefect(operation, zeroChanged);
252
263
  const changed = { queueUrl: queue.url, ...input.messageId ? { messageId: input.messageId } : {}, visibilityTimeoutSeconds: input.visibilityTimeoutSeconds, visibleAfter: "0001-01-01T00:00:00Z" };
253
264
  const objectId = input.messageId ? `${queue.url}#${input.messageId}` : queue.url;
@@ -258,7 +269,8 @@ var ChangeMessageVisibilityOperation = class {
258
269
  return transportRetry(operation, "visibility change");
259
270
  }
260
271
  const classified = classifyAcknowledgement(call, this.client, response, credentials, operation, "visibility change", changed, objectId);
261
- if (classified) return classified;
272
+ const isRepeatedRelease = input.visibilityTimeoutSeconds === 0 && call.context.attempt > 1 && classified?.kind === "branch" && classified.branch === "receiptHandleInvalid";
273
+ if (classified && !isRepeatedRelease) return classified;
262
274
  const receipt = this.client.receipt(call, response, objectId);
263
275
  changed.visibleAfter = new Date(Date.parse(receipt.observedAt) + input.visibilityTimeoutSeconds * 1e3).toISOString().replace(/\.000Z$/, "Z");
264
276
  return newMutationBranch("changed", changed, receipt);
@@ -330,6 +342,9 @@ function decodeMessage(value) {
330
342
 
331
343
  // src/client.ts
332
344
  var provider2 = "amazon-sqs";
345
+ function isTerminalCredentialError(error) {
346
+ return isCredentialMaterialError(error) || error instanceof ReauthorizationRequiredError || error instanceof ObjectNotFoundError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError;
347
+ }
333
348
  var regionPattern = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
334
349
  var queueNamePattern = /^[A-Za-z0-9_-]{1,80}$/;
335
350
  var ownerPattern = /^[A-Za-z0-9_-]{1,64}$/;
@@ -414,8 +429,17 @@ var SQSClient = class {
414
429
  }
415
430
  /** Resolve one current access key without retaining it in a result. */
416
431
  async resolveCredentials(call) {
432
+ return await this.resolveCredentialsOrTransient(call) ?? void 0;
433
+ }
434
+ /** Return null for a transient credential failure and undefined for a terminal or invalid one. */
435
+ async resolveCredentialsOrTransient(call) {
436
+ let credentials;
437
+ try {
438
+ credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
439
+ } catch (error) {
440
+ return isTerminalCredentialError(error) ? void 0 : null;
441
+ }
417
442
  try {
418
- const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
419
443
  const key = credentials.accessKeyId?.reveal();
420
444
  const secret = credentials.secretAccessKey?.reveal();
421
445
  const token = credentials.sessionToken?.reveal() ?? "";
@@ -555,6 +579,10 @@ function classifyResponse(operation, subject, response, credentials, now) {
555
579
  } else if (["AccessDenied", "AccessDeniedException", "KmsAccessDenied", "KmsDisabled", "KmsInvalidState", "KmsNotFound", "KmsOptInRequired", "KmsInvalidKeyUsage"].includes(code) || status === 403) {
556
580
  kind = "AUTHORIZATION";
557
581
  description = withStatus(`SQS denied the ${subject}`);
582
+ } else if (![400, 401, 403, 404, 411, 413, 414, 415, 422, 501].includes(status)) {
583
+ branch = "retry";
584
+ kind = "AVAILABILITY";
585
+ description = withStatus(`SQS answered the ${subject} ambiguously`);
558
586
  }
559
587
  const failure2 = { provider: provider2, operation, kind, message: description };
560
588
  return { branch, failure: failure2, retryAfterMs: branch === "retry" ? parseRetryAfter(header(response.headers, "retry-after"), now) : 0 };
@@ -603,6 +631,7 @@ export {
603
631
  ConfigSchema,
604
632
  Connection,
605
633
  ConnectorID,
634
+ CredentialMaterialError,
606
635
  DeleteMessageBranch,
607
636
  DeleteMessageBranchDefect,
608
637
  DeleteMessageBranchDeleted,
@@ -629,7 +658,9 @@ export {
629
658
  ReceivedMessagesSchema,
630
659
  SQSClient,
631
660
  classifyResponse,
661
+ decodeCredentials,
632
662
  header,
663
+ isCredentialMaterialError,
633
664
  newChangeMessageVisibilityStep,
634
665
  newConnection,
635
666
  newConnectionWithOperations,
package/dist/sqsmock.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MockMutation, Case } from '@superdurable/connectors-sdk/connectormock';
2
2
  import { Failure } from '@superdurable/connectors-sdk';
3
- import { O as Operations, b as Connection, R as ReceiveMessagesInput, d as ReceivedMessages, D as DeleteMessageInput, c as DeletedMessage, C as ChangeMessageVisibilityInput, a as ChangedMessageVisibility, M as Message, m as MessageAttributeValue } from './connection-DqOJtCt2.js';
3
+ import { O as Operations, b as Connection, R as ReceiveMessagesInput, d as ReceivedMessages, D as DeleteMessageInput, c as DeletedMessage, C as ChangeMessageVisibilityInput, a as ChangedMessageVisibility, M as Message, n as MessageAttributeValue } from './connection-BC2kNwv9.js';
4
4
  import 'zod';
5
5
 
6
6
  /** Go zero value for ReceiveMessagesInput in scripted cases. */
package/dist/sqsmock.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  ReceiveMessagesInputSchema,
14
14
  ReceivedMessagesSchema,
15
15
  newConnectionWithOperations
16
- } from "./chunk-JUNMI7YJ.js";
16
+ } from "./chunk-GUYXQWWQ.js";
17
17
 
18
18
  // src/generated/mock.ts
19
19
  import { branchCase, retryCase, newMutation } from "@superdurable/connectors-sdk/connectormock";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-amazon-sqs",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "description": "Amazon SQS connector for Dex TypeScript applications",
6
6
  "repository": {
@@ -22,7 +22,8 @@
22
22
  "./sqsmock": {
23
23
  "types": "./dist/sqsmock.d.ts",
24
24
  "import": "./dist/sqsmock.js"
25
- }
25
+ },
26
+ "./dex-connector.json": "./dex-connector.json"
26
27
  },
27
28
  "files": [
28
29
  "dist",