@webamoki/web-svelte 0.7.3 → 0.7.4

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.
@@ -45,10 +45,7 @@ export async function signRequest(method, host, path, body, credentials, service
45
45
  const { accessKeyId, secretAccessKey, region } = credentials;
46
46
  // Create timestamp
47
47
  const now = new Date();
48
- const amzDate = now
49
- .toISOString()
50
- .replace(/[:-]|\.\d{3}/g, '')
51
- .slice(0, -1); // Format: YYYYMMDD'T'HHMMSS'Z'
48
+ const amzDate = now.toISOString().replace(/[:-]|\.\d{3}/g, ''); // Format: YYYYMMDDTHHMMSSZ
52
49
  const dateStamp = amzDate.slice(0, 8); // Format: YYYYMMDD
53
50
  // Hash the request body
54
51
  const payloadHash = bufferToHex(await sha256(body));
@@ -97,32 +97,29 @@ export async function sendEmail(options) {
97
97
  });
98
98
  const responseText = await response.text();
99
99
  if (!response.ok) {
100
- // Parse error response
100
+ // Parse error response using regex (works in Node.js and browsers)
101
101
  let errorMessage = 'Unknown error';
102
102
  let errorCode;
103
103
  try {
104
- const parser = new DOMParser();
105
- const xmlDoc = parser.parseFromString(responseText, 'text/xml');
106
- const errorNode = xmlDoc.querySelector('Error');
107
- if (errorNode) {
108
- errorCode = errorNode.querySelector('Code')?.textContent || undefined;
109
- errorMessage = errorNode.querySelector('Message')?.textContent || errorMessage;
110
- }
104
+ const codeMatch = responseText.match(/<Code>(.*?)<\/Code>/);
105
+ const messageMatch = responseText.match(/<Message>(.*?)<\/Message>/);
106
+ if (codeMatch)
107
+ errorCode = codeMatch[1];
108
+ if (messageMatch)
109
+ errorMessage = messageMatch[1];
111
110
  }
112
111
  catch {
113
112
  errorMessage = responseText || `HTTP ${response.status} ${response.statusText}`;
114
113
  }
115
114
  throw new Error(`sendEmail: failed to send email: ${JSON.stringify({ message: errorMessage, code: errorCode })}`);
116
115
  }
117
- // Parse success response for MessageId
116
+ // Parse success response for MessageId using regex (works in Node.js and browsers)
118
117
  try {
119
- const parser = new DOMParser();
120
- const xmlDoc = parser.parseFromString(responseText, 'text/xml');
121
- const messageId = xmlDoc.querySelector('MessageId')?.textContent;
122
- if (!messageId) {
118
+ const messageIdMatch = responseText.match(/<MessageId>(.*?)<\/MessageId>/);
119
+ if (!messageIdMatch || !messageIdMatch[1]) {
123
120
  throw new Error('sendEmail: SES response did not contain a MessageId');
124
121
  }
125
- return messageId;
122
+ return messageIdMatch[1];
126
123
  }
127
124
  catch (err) {
128
125
  if (err instanceof Error && err.message.includes('MessageId')) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.7.3",
6
+ "version": "0.7.4",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",