Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"dependencies": {},
"devDependencies": {
"@cloudflare/workers-types": "^4.20221111.1",
"prettier": "^2.1.2",
"typescript": "^4.0.3"
"prettier": "^2.8.3",
"typescript": "^4.9.4"
},
"prettier": {
"semi": false,
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ const truncatedISO8061Date = (date: Date) => {
const computeHMACSHA256 = async (stringToSign: string, accountKey: string): Promise<string> => {
const enc = new TextEncoder()
const signatureUTF8 = enc.encode(stringToSign)
const keyData = enc.encode(btoa(accountKey))

const key = await crypto.subtle.importKey(
'raw',
//@ts-ignore
Buffer.from(accountKey, 'base64'),
keyData,
{
name: 'HMAC',
hash: {
Expand All @@ -38,11 +39,9 @@ const computeHMACSHA256 = async (stringToSign: string, accountKey: string): Prom
false,
['sign']
)

const digest = await crypto.subtle.sign('HMAC', key, signatureUTF8)

//@ts-ignore
return Buffer.from(digest).toString('base64')
return btoa(String.fromCharCode(...new Uint8Array(digest)))
}

const getCanonicalName = (accountName: string, containerName: string, blobName?: string) => {
Expand Down Expand Up @@ -90,6 +89,7 @@ const getSASqueryParams = async (input: SASinput) => {

return `${key}=${encodeURIComponent(queryParams[key])}`
})
.filter((el) => el)
.join('&')
}

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
resolved "https://registry.yarnpkg.com/@cloudflare/workers-types/-/workers-types-4.20221111.1.tgz#c3dbb5ef52cf5fab275803ece0424b205c78ad3e"
integrity sha512-BNV2wN8V6Zduvo7UzxcdjBbLQ906D2KhS804PDufLgx/sanGJCHVJMOIaLvS/b61JKtot1U7P/l1fjrjZ7/E3A==

prettier@^2.1.2:
version "2.8.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.2.tgz#c4ea1b5b454d7c4b59966db2e06ed7eec5dfd160"
integrity sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw==
prettier@^2.8.3:
version "2.8.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.3.tgz#ab697b1d3dd46fb4626fbe2f543afe0cc98d8632"
integrity sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==

typescript@^4.0.3:
typescript@^4.9.4:
version "4.9.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78"
integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==