| 63 | } |
| 64 | |
| 65 | function getTimestampParts(date: Date): { amzDate: string; dateStamp: string; } { |
| 66 | const year = date.getUTCFullYear(); |
| 67 | const month = String(date.getUTCMonth() + 1).padStart(2, "0"); |
| 68 | const day = String(date.getUTCDate()).padStart(2, "0"); |
| 69 | const hour = String(date.getUTCHours()).padStart(2, "0"); |
| 70 | const minute = String(date.getUTCMinutes()).padStart(2, "0"); |
| 71 | const second = String(date.getUTCSeconds()).padStart(2, "0"); |
| 72 | |
| 73 | return { |
| 74 | amzDate: `${year}${month}${day}T${hour}${minute}${second}Z`, |
| 75 | dateStamp: `${year}${month}${day}` |
| 76 | }; |
| 77 | } |
| 78 | |
| 79 | async function sha256Hex(data: ArrayBuffer | Uint8Array | string): Promise<string> { |
| 80 | return toHex(await crypto.subtle.digest("SHA-256", toArrayBuffer(data))); |