From f0d746e35f4548cf751e09f261528d12efa6f41b Mon Sep 17 00:00:00 2001 From: Brad Clawsie Date: Thu, 30 Nov 2023 17:35:24 -0600 Subject: [PATCH] std to 0.208.0; refactor deprecated apis; github action deno version --- .github/workflows/ci.yml | 2 +- README.md | 8 ++++++++ mod.ts | 12 ++++++------ test.ts | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e677d27..61f456e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,6 @@ jobs: - uses: actions/checkout@v2 - uses: denolib/setup-deno@master with: - deno-version: 1.31.0 + deno-version: 1.38.2 - run: deno test --allow-all - run: deno lint diff --git a/README.md b/README.md index 1fce57b..3dc4cda 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,14 @@ Basic security API for Typescript that optimizes for easy use [![License:MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![ci](https://github.com/bradclawsie/easysecurity/workflows/ci/badge.svg) +## Important Compatibility Note + +Note that there will be breaking changes introduced after version 0.1.9. +These changes will start a 0.2.x version scheme. If you have a dependency +on this library as it is presently developed, I recommend fixing your +use at version 0.1.9 until you can undertake a migration forward. +Alternately, you may wish to simply fork version 0.1.9. + ## Motivation I find most security APIs hard to use. What I'm usually looking for is simple diff --git a/mod.ts b/mod.ts index d9e389f..a6fbe7f 100644 --- a/mod.ts +++ b/mod.ts @@ -1,15 +1,15 @@ -import { crypto } from "https://deno.land/std@0.200.0/crypto/crypto.ts"; -import { toHashString } from "https://deno.land/std@0.200.0/crypto/to_hash_string.ts"; +import { crypto } from "https://deno.land/std@0.208.0/crypto/crypto.ts"; +import { encodeHex } from "https://deno.land/std@0.208.0/encoding/hex.ts"; import { assertEquals, assertNotEquals, -} from "https://deno.land/std@0.200.0/assert/mod.ts"; +} from "https://deno.land/std@0.208.0/assert/mod.ts"; import { bytesToHex, bytesToString, hexToBytes, stringToBytes, -} from "https://deno.land/x/textras@0.1.7/mod.ts"; +} from "https://deno.land/x/textras@0.1.8/mod.ts"; /** * produce the hex-encoded string of the sha256 hash of string s @@ -17,14 +17,14 @@ import { * @returns {Promise} the hex-encoded sha256 of s */ const sha256Hex = async (s: string): Promise => - toHashString(await crypto.subtle.digest("SHA-256", stringToBytes(s))); + encodeHex(await crypto.subtle.digest("SHA-256", stringToBytes(s))); /** * test a string to see if it is a uuid (as generated by randomUUID) * @param {string} s - the string to test * @returns {boolean} if s is a uuid */ -const isUUID = (s: string) => { +const isUUID = (s: string): boolean => { const re = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; return re.test(s); }; diff --git a/test.ts b/test.ts index e37e696..748a930 100644 --- a/test.ts +++ b/test.ts @@ -1,7 +1,7 @@ import { assert, assertEquals, -} from "https://deno.land/std@0.200.0/assert/mod.ts"; +} from "https://deno.land/std@0.208.0/assert/mod.ts"; import { Crypter, isUUID, IV, Key, randomUUID, sha256Hex } from "./mod.ts"; /** -- 2.45.2