Deno 1.14 正式釋出,引入新的 Web Crypto API

2021-09-24 09:00:16

Deno 1.14 已釋出,包括以下新特性和變更:


此版本引入了許多新的 Web Crypto API:

  • crypto.subtle.exportKey()
    • HMAC 金鑰現在支援以 JWK 和"raw"格式匯出
    • RSA 金鑰現在支援以 pkcs#8 格式匯出
  • crypto.subtle.importKey()
    • HMAC 金鑰現在可以以 JWK 和"raw"格式匯入
    • 現在支援以 pkcs#8 格式匯入 RSA 金鑰
    • PBKDF2 金鑰現在支援以"raw"格式匯入
  • crypto.subtle.generateKey()
    • 現在支援生成 RSA-OAEP 金鑰
    • 現在支援生成 ECDH 金鑰
    • 現在支援生成 AES 金鑰
  • crypto.subtle.deriveBits()
    • 現在支援 PBKDF2 派生
    • 現在支援 HKDF 派生
  • crypto.subtle.verify()
    • 現在支援 ECDSA 簽名驗證
  • crypto.subtle.encrypt()
    • 現在支援 RSA-OAEP 加密
  • crypto.subtle.decrypt()
    • 現在支援 RSA-OAEP 解密

此版本引入了一個新的不穩定的 Web 平臺 API,用於根據模式匹配 URL。URLPattern是流行庫的內建替代品 。

const pattern = new URLPattern({ pathname: "/books/:id" });

console.log(pattern.test("https://example.com/books/123")); // true
console.log(pattern.test("https://example.com/books/123/456")); // false
console.log(pattern.test("https://example.com/books")); // false

console.log(pattern.exec("https://example.com/books/123").pathname); // { input: "/books/123", groups: { id: "123" } }

此版本引入了四個新的可用於檔案鎖定的不穩定 API:

  • Deno.flock
  • Deno.flockSync
  • Deno.funlock
  • Deno.funlockSync

這些 API 對於像提供適當的資料庫同步這種專案來說是必不可少的 。


 0.107.0 版本對進行了重大改進 。

在 v1.13 中原生 HTTP server API 到達穩定狀態後,團隊重寫了http/server.ts模組,並使用了新的穩定 API。最終實現了顯著的效能提升,以及建立了對使用者更友好的 API——主要用於處理 HTTP 伺服器的問題,例如錯誤處理和連線的多路複用。

展開閱讀全文