Skip to content

Commit

Permalink
Merge pull request #16 from jrayback/rayback_231121_update-package-de…
Browse files Browse the repository at this point in the history
…pendencies

update package dependencies
  • Loading branch information
jrayback authored Dec 8, 2023
2 parents 4e84ba9 + 586cb33 commit 763dc0e
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 138 deletions.
4 changes: 2 additions & 2 deletions maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This page lists all active maintainers of this repository.

## Author (from [signify-ts](https://github.com/WebOfTrust/signify-ts))

- pfeairheller
- pfeairheller

## Maintainers (in alphabetical order)

- jrayback
- jrayback
162 changes: 88 additions & 74 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
"@types/jest": "^29.5.8",
"@types/libsodium-wrappers-sumo": "^0.7.8",
"@types/node": "^20.9.0",
"@types/text-encoding": "^0.0.39",
"@types/urlsafe-base64": "^1.0.31",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"depcheck": "^1.4.7",
Expand All @@ -41,14 +39,9 @@
"typescript": "^5.2.2"
},
"dependencies": {
"blake3": "^2.1.7",
"ecdsa-secp256r1": "^1.3.3",
"libsodium-wrappers-sumo": "^0.7.13",
"text-encoding": "^0.7.0",
"urlsafe-base64": "^1.0.0"
},
"overrides": {
"blake3-wasm": "^2.1.7",
"@c4312/blake3-internal": "^2.1.7"
"@noble/curves": "^1.2.0",
"@noble/hashes": "^1.3.2",
"buffer": "^6.0.3",
"libsodium-wrappers-sumo": "^0.7.13"
}
}
6 changes: 3 additions & 3 deletions src/bexter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BexDex, Matter, MatterArgs, MtrDex } from './matter';
import { EmptyMaterialError } from './kering';
import Base64 from 'urlsafe-base64';
import { Buffer } from 'buffer';

const B64REX = '^[A-Za-z0-9\\-_]*$';
export const Reb64 = new RegExp(B64REX);
Expand Down Expand Up @@ -114,15 +114,15 @@ export class Bexter extends Matter {
const wad = new Array(ws);
wad.fill('A');
const base = wad.join('') + bext; // pre pad with wad of zeros in Base64 == 'A'
const raw = Base64.decode(base); // [ls:] // convert and remove leader
const raw = Buffer.from(base, 'base64url'); // [ls:] // convert and remove leader

return Uint8Array.from(raw).subarray(ls); // raw binary equivalent of text
}

get bext(): string {
const sizage = Matter.Sizes.get(this.code);
const wad = Uint8Array.from(new Array(sizage?.ls).fill(0));
const bext = Base64.encode(Buffer.from([...wad, ...this.raw]));
const bext = Buffer.from([...wad, ...this.raw]).toString('base64url');

let ws = 0;
if (sizage?.ls === 0 && bext !== undefined) {
Expand Down
2 changes: 0 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// import {TextEncoder, TextDecoder} from 'util'
import { TextEncoder, TextDecoder } from 'text-encoding';
export enum Serials {
JSON = 'JSON',
}
Expand Down
8 changes: 3 additions & 5 deletions src/diger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createHash } from 'blake3';
import { blake3 } from '@noble/hashes/blake3';

import { Matter, MatterArgs, MtrDex } from './matter';

Expand All @@ -25,8 +25,7 @@ export class Diger extends Matter {
}

if (code === MtrDex.Blake3_256) {
const hasher = createHash();
const dig = hasher.update(ser).digest('');
const dig = blake3.create({}).update(ser).digest();
super({ raw: dig, code: code });
} else {
throw new Error(`Unsupported code = ${code} for digester.`);
Expand Down Expand Up @@ -74,8 +73,7 @@ export class Diger extends Matter {
}

blake3_256(ser: Uint8Array, dig: any) {
const hasher = createHash();
const digest = hasher.update(ser).digest('');
const digest = blake3.create({}).update(ser).digest();
return digest.toString() === dig.toString();
}
}
10 changes: 6 additions & 4 deletions src/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { EmptyMaterialError } from './kering';
import { b, b64ToInt, d, intToB64, readInt } from './core';
import Base64 from 'urlsafe-base64';
import { Buffer } from 'buffer';

export class IndexerCodex {
Expand Down Expand Up @@ -399,7 +398,10 @@ export class Indexer {
}

const full =
both + Base64.encode(Buffer.from(bytes)).slice(ps - xizage.ls);
both +
Buffer.from(bytes)
.toString('base64url')
.slice(ps - xizage.ls);
if (full.length != xizage.fs) {
throw new Error(`Invalid code=${both} for raw size=${raw.length}.`);
}
Expand Down Expand Up @@ -474,7 +476,7 @@ export class Indexer {
let raw;
if (ps != 0) {
const base = new Array(ps + 1).join('A') + qb64.slice(cs);
const paw = Base64.decode(base); // decode base to leave prepadded raw
const paw = Buffer.from(base, 'base64url'); // decode base to leave prepadded raw
const pi = readInt(paw.slice(0, ps)); // prepad as int
if (pi & (2 ** pbs - 1)) {
// masked pad bits non-zero
Expand All @@ -485,7 +487,7 @@ export class Indexer {
raw = paw.slice(ps); // strip off ps prepad paw bytes
} else {
const base = qb64.slice(cs);
const paw = Base64.decode(base);
const paw = Buffer.from(base, 'base64url');
const li = readInt(paw.slice(0, xizage!.ls));
if (li != 0) {
if (li == 1) {
Expand Down
Loading

0 comments on commit 763dc0e

Please sign in to comment.