@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));
|
package/dist/utils/email/ses.js
CHANGED
|
@@ -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
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
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
|
|
120
|
-
|
|
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
|
|
122
|
+
return messageIdMatch[1];
|
|
126
123
|
}
|
|
127
124
|
catch (err) {
|
|
128
125
|
if (err instanceof Error && err.message.includes('MessageId')) {
|