~bradclawsie/easysecurity

f0d746e35f4548cf751e09f261528d12efa6f41b — Brad Clawsie 9 months ago 1cf3193 0.1.9
std to 0.208.0; refactor deprecated apis; github action deno version
4 files changed, 16 insertions(+), 8 deletions(-)

M .github/workflows/ci.yml
M README.md
M mod.ts
M test.ts
M .github/workflows/ci.yml => .github/workflows/ci.yml +1 -1
@@ 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

M README.md => README.md +8 -0
@@ 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

M mod.ts => mod.ts +6 -6
@@ 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<string>} the hex-encoded sha256 of s
 */
const sha256Hex = async (s: string): Promise<string> =>
  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);
};

M test.ts => test.ts +1 -1
@@ 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";

/**