Skip to content

Commit 8c01cb7

Browse files
authored
Merge pull request #64 from neurocode-io/remove-buffer-api
Remove none working buffer api
2 parents e36e1c7 + f5a27b1 commit 8c01cb7

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"dependencies": {},
3232
"devDependencies": {
3333
"@cloudflare/workers-types": "^4.20221111.1",
34-
"prettier": "^2.1.2",
35-
"typescript": "^4.0.3"
34+
"prettier": "^2.8.3",
35+
"typescript": "^4.9.4"
3636
},
3737
"prettier": {
3838
"semi": false,

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ const truncatedISO8061Date = (date: Date) => {
2525
const computeHMACSHA256 = async (stringToSign: string, accountKey: string): Promise<string> => {
2626
const enc = new TextEncoder()
2727
const signatureUTF8 = enc.encode(stringToSign)
28+
const keyData = enc.encode(btoa(accountKey))
29+
2830
const key = await crypto.subtle.importKey(
2931
'raw',
30-
//@ts-ignore
31-
Buffer.from(accountKey, 'base64'),
32+
keyData,
3233
{
3334
name: 'HMAC',
3435
hash: {
@@ -38,11 +39,9 @@ const computeHMACSHA256 = async (stringToSign: string, accountKey: string): Prom
3839
false,
3940
['sign']
4041
)
41-
4242
const digest = await crypto.subtle.sign('HMAC', key, signatureUTF8)
4343

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

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

9190
return `${key}=${encodeURIComponent(queryParams[key])}`
9291
})
92+
.filter((el) => el)
9393
.join('&')
9494
}
9595

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
resolved "https://registry.yarnpkg.com/@cloudflare/workers-types/-/workers-types-4.20221111.1.tgz#c3dbb5ef52cf5fab275803ece0424b205c78ad3e"
88
integrity sha512-BNV2wN8V6Zduvo7UzxcdjBbLQ906D2KhS804PDufLgx/sanGJCHVJMOIaLvS/b61JKtot1U7P/l1fjrjZ7/E3A==
99

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

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

0 commit comments

Comments
 (0)