From 3ef842d5f128ea59224ea71e45e97cda0d920b3b Mon Sep 17 00:00:00 2001 From: Jonathan Rayback Date: Fri, 29 Mar 2024 17:44:52 -0600 Subject: [PATCH 1/2] reorganize api folder; add type definition emitter to build --- index.ts | 6 +- jest.config.js | 2 +- package.json | 7 +- src/api/api.test.ts | 12 +- src/api/api.ts | 21 +- src/api/encode/asText.ts | 14 - .../encodeBinary.test.ts => binary.test.ts} | 4 +- src/api/encode/binary.ts | 24 + src/api/encode/encoders/encodeBinary.ts | 20 - src/api/encode/encoders/encodeRaw.ts | 11 - src/api/encode/encoders/encodeText.ts | 16 - src/api/encode/{ => lib}/asBinary.ts | 0 src/api/encode/lib/asText.ts | 14 + .../{encoders => }/lib/convertToBase64.ts | 0 .../encode/{encoders => }/lib/padUpFront.ts | 2 +- .../{encoders => }/lib/swapInTypeCode.ts | 2 +- .../encodeRaw.test.ts => raw.test.ts} | 12 +- src/api/encode/raw.ts | 10 + .../encodeText.test.ts => text.test.ts} | 10 +- src/api/encode/text.ts | 20 + src/api/transform/toBinary.test.ts | 18 +- src/api/transform/toBinary.ts | 4 +- src/api/transform/toRaw.test.ts | 36 +- src/api/transform/toText.test.ts | 18 +- src/api/transform/toText.ts | 4 +- src/lib/util/pipe.ts | 1 + src/main.ts | 4 +- test/standardsTest/README.md | 5 - test/standardsTest/standards.test.ts | 28 - test/standardsTest/standards.ts | 702 ------------------ tsconfig.json | 3 +- 31 files changed, 148 insertions(+), 882 deletions(-) delete mode 100644 src/api/encode/asText.ts rename src/api/encode/{encoders/encodeBinary.test.ts => binary.test.ts} (65%) create mode 100644 src/api/encode/binary.ts delete mode 100644 src/api/encode/encoders/encodeBinary.ts delete mode 100644 src/api/encode/encoders/encodeRaw.ts delete mode 100644 src/api/encode/encoders/encodeText.ts rename src/api/encode/{ => lib}/asBinary.ts (100%) create mode 100644 src/api/encode/lib/asText.ts rename src/api/encode/{encoders => }/lib/convertToBase64.ts (100%) rename src/api/encode/{encoders => }/lib/padUpFront.ts (91%) rename src/api/encode/{encoders => }/lib/swapInTypeCode.ts (90%) rename src/api/encode/{encoders/encodeRaw.test.ts => raw.test.ts} (79%) create mode 100644 src/api/encode/raw.ts rename src/api/encode/{encoders/encodeText.test.ts => text.test.ts} (54%) create mode 100644 src/api/encode/text.ts delete mode 100644 test/standardsTest/README.md delete mode 100644 test/standardsTest/standards.test.ts delete mode 100644 test/standardsTest/standards.ts diff --git a/index.ts b/index.ts index 134552c..cde6fe8 100644 --- a/index.ts +++ b/index.ts @@ -1,9 +1,9 @@ // Note: Main entry point for the library // This represents the public API of the library export { - encodeRaw, - encodeText, - encodeBinary, + raw, + text, + binary, toRaw, toText, toBinary diff --git a/jest.config.js b/jest.config.js index 99f2d00..d3baa66 100644 --- a/jest.config.js +++ b/jest.config.js @@ -11,7 +11,7 @@ export default { transform: { // allows jest to resolve module paths to a .ts source file using a .js extension // see dox for more information on this setting: https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/ - '^.+\\.[t|j]sx?$': [ + '^.+\\.[tj]sx?$': [ '@swc/jest' // use swc swap in for faster tests // { // useESM: true // don't seem to need this section when using @swc/jest diff --git a/package.json b/package.json index 0c31bce..fe141d8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@jrayback/simple-cesr", "type": "module", - "version": "0.1.2", + "version": "0.1.4", "description": "A simple, limited, true-to-spec implementation of the CESR protocol.", "main": "dist/index.js", "files": [ @@ -13,8 +13,9 @@ "test": "jest ./src/api ./src/implementation", "standards-test": "jest ./testing/standards", "all-tests": "jest", - "formatting": "npx ts-standard --fix", - "full-build": "npm run all-tests && npm run formatting && npm run build" + "formatter": "npx ts-standard --fix", + "emitter" : "tsc --emitDeclarationOnly --declaration --outDir dist", + "full-build": "npm run all-tests && npm run formatter && npm run build && npm run emitter" }, "repository": { "type": "git", diff --git a/src/api/api.test.ts b/src/api/api.test.ts index 130adf7..0c073fe 100644 --- a/src/api/api.test.ts +++ b/src/api/api.test.ts @@ -4,12 +4,12 @@ describe('API', () => { it('works...', () => { const code = 'M' const primitive = new Uint8Array([0, 1]) - expect(() => cesr.encodeRaw(code, primitive)).not.toThrow() - expect(() => cesr.encodeText(code, primitive)).not.toThrow() - expect(() => cesr.encodeBinary(code, primitive)).not.toThrow() - const raw = cesr.encodeRaw(code, primitive) - const text = cesr.encodeText(code, primitive) - const binary = cesr.encodeBinary(code, primitive) + expect(() => cesr.raw(code, primitive)).not.toThrow() + expect(() => cesr.text(code, primitive)).not.toThrow() + expect(() => cesr.binary(code, primitive)).not.toThrow() + const raw = cesr.raw(code, primitive) + const text = cesr.text(code, primitive) + const binary = cesr.binary(code, primitive) expect(() => cesr.toRaw(text)).not.toThrow() expect(() => cesr.toRaw(binary)).not.toThrow() expect(() => cesr.toText(binary)).not.toThrow() diff --git a/src/api/api.ts b/src/api/api.ts index 9d8f5bc..5a6a394 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,15 +1,6 @@ -import { encodeBinary } from './encode/encoders/encodeBinary.js' -import { encodeText } from './encode/encoders/encodeText.js' -import { encodeRaw } from './encode/encoders/encodeRaw.js' -import { toBinary } from './transform/toBinary.js' -import { toText } from './transform/toText.js' -import { toRaw } from './transform/toRaw.js' - -export { - encodeBinary, - encodeText, - encodeRaw, - toBinary, - toText, - toRaw -} +export { binary } from './encode/binary.js' +export { text } from './encode/text.js' +export { raw } from './encode/raw.js' +export { toBinary } from './transform/toBinary.js' +export { toText } from './transform/toText.js' +export { toRaw } from './transform/toRaw.js' diff --git a/src/api/encode/asText.ts b/src/api/encode/asText.ts deleted file mode 100644 index 3a2ea5f..0000000 --- a/src/api/encode/asText.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { pipe } from '../../lib/util/pipe.js' -import { swapInTypeCode } from './encoders/lib/swapInTypeCode.js' -import { padUpFront } from './encoders/lib/padUpFront.js' -import { convertToBase64 } from './encoders/lib/convertToBase64.js' -import { Code } from '../../core/code/code.js' - -// builds the proper text encoding for the given primitive -export const asText = (code: Code, primitive: Buffer): string => - pipe( - primitive, - padUpFront, - convertToBase64, - swapInTypeCode(code) - ) diff --git a/src/api/encode/encoders/encodeBinary.test.ts b/src/api/encode/binary.test.ts similarity index 65% rename from src/api/encode/encoders/encodeBinary.test.ts rename to src/api/encode/binary.test.ts index 8c7dc82..c545d30 100644 --- a/src/api/encode/encoders/encodeBinary.test.ts +++ b/src/api/encode/binary.test.ts @@ -1,9 +1,9 @@ import { Buffer } from 'buffer' -import { encodeBinary } from './encodeBinary.js' +import { binary } from './binary.js' describe('Binary encoder', () => { it('processes code "M" correctly', () => { - const result = encodeBinary('M', Buffer.from([0x00, 0x01])) + const result = binary('M', Buffer.from([0x00, 0x01])) expect(result).toStrictEqual(Buffer.from([48, 0, 1])) // 48 is the base64 encoding of 'M' }) }) diff --git a/src/api/encode/binary.ts b/src/api/encode/binary.ts new file mode 100644 index 0000000..776dc2c --- /dev/null +++ b/src/api/encode/binary.ts @@ -0,0 +1,24 @@ +import { pipe } from '../../lib/util/pipe.js' +import { Code } from '../../core/code/code.js' +import { Binary, Raw } from '../../core/domain/domains.js' +import { make } from '../../implementation/make.js' +import { asText } from './lib/asText.js' +import { asBinary } from './lib/asBinary.js' + +// encodes a primitive in the Binary domain. needs the type code and the primitive as a byte array +export const binary = (code: Code, primitive: Uint8Array): Binary => { + const doRaw = rawWith(code) // which code should be used to make the raw? + const doText = textWith(code) // which code should be used to encode the text? + const doBinary = asBinary + + // for Binary, go through all three steps... + return pipe( + primitive, + doRaw, // make the Raw + doText, // encode the raw primitive as Text + doBinary // return the encoded string as a Binary + ) +} + +const rawWith = (code: Code) => (primitive: Uint8Array) => make(code, primitive) +const textWith = (code: Code) => (tuple: Raw) => asText(code, tuple.raw) diff --git a/src/api/encode/encoders/encodeBinary.ts b/src/api/encode/encoders/encodeBinary.ts deleted file mode 100644 index c0c6698..0000000 --- a/src/api/encode/encoders/encodeBinary.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Code } from '../../../core/code/code.js' -import { Binary } from '../../../core/domain/domains.js' -import { make } from '../../../implementation/make.js' -import { asText } from '../asText.js' -import { asBinary } from '../asBinary.js' - -// encodes a primitive in the Binary domain. needs the type code and the primitive as a byte array -export const encodeBinary = (code: Code, primitive: Uint8Array): Binary => { - // for Binary, go through all three steps... - - // make the Raw - const tuplet = make(code, primitive) - - // encode the raw primitive as Text - const raw = tuplet.raw - const text = asText(code, raw) - - // return the encoded string as a Binary - return asBinary(text) -} diff --git a/src/api/encode/encoders/encodeRaw.ts b/src/api/encode/encoders/encodeRaw.ts deleted file mode 100644 index 43600a6..0000000 --- a/src/api/encode/encoders/encodeRaw.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Buffer } from 'buffer' -import { make } from '../../../implementation/make.js' -import { Code } from '../../../core/code/code.js' -import { Raw } from '../../../core/domain/domains.js' - -export const encodeRaw = (code: Code, primitive: Uint8Array): Raw => - // Make a Raw - make( // make ensures the primitive is valid - code, - Buffer.from(primitive) - ) diff --git a/src/api/encode/encoders/encodeText.ts b/src/api/encode/encoders/encodeText.ts deleted file mode 100644 index 7f1fc8a..0000000 --- a/src/api/encode/encoders/encodeText.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Code } from '../../../core/code/code.js' -import { Text } from '../../../core/domain/domains.js' - -import { make } from '../../../implementation/make.js' -import { asText } from '../asText.js' - -export const encodeText = (code: Code, primitive: Uint8Array): Text => { - // requires two steps... - - // make the Raw - const tuplet = make(code, primitive) - - // encode the raw primitive as Text - const raw = tuplet.raw - return asText(code, raw) -} diff --git a/src/api/encode/asBinary.ts b/src/api/encode/lib/asBinary.ts similarity index 100% rename from src/api/encode/asBinary.ts rename to src/api/encode/lib/asBinary.ts diff --git a/src/api/encode/lib/asText.ts b/src/api/encode/lib/asText.ts new file mode 100644 index 0000000..a8efa43 --- /dev/null +++ b/src/api/encode/lib/asText.ts @@ -0,0 +1,14 @@ +import { swapInTypeCode } from './swapInTypeCode.js' +import { padUpFront } from './padUpFront.js' +import { convertToBase64 } from './convertToBase64.js' +import { Code } from '../../..//core/code/code.js' +import { pipe } from '../../../lib/util/pipe.js' + +// builds the proper text encoding for the given primitive +export const asText = (code: Code, primitive: Buffer): string => + pipe( + primitive, + padUpFront, + convertToBase64, + swapInTypeCode(code) + ) diff --git a/src/api/encode/encoders/lib/convertToBase64.ts b/src/api/encode/lib/convertToBase64.ts similarity index 100% rename from src/api/encode/encoders/lib/convertToBase64.ts rename to src/api/encode/lib/convertToBase64.ts diff --git a/src/api/encode/encoders/lib/padUpFront.ts b/src/api/encode/lib/padUpFront.ts similarity index 91% rename from src/api/encode/encoders/lib/padUpFront.ts rename to src/api/encode/lib/padUpFront.ts index db4fa5a..dbf5a11 100644 --- a/src/api/encode/encoders/lib/padUpFront.ts +++ b/src/api/encode/lib/padUpFront.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer' import { match } from 'ts-pattern' -import { padSize } from '../../../../lib/keri/padSize.js' +import { padSize } from '../../../lib/keri/padSize.js' // only valid pad sizes in KERI are 0, 1, or 2 type PadSize = 0 | 1 | 2 diff --git a/src/api/encode/encoders/lib/swapInTypeCode.ts b/src/api/encode/lib/swapInTypeCode.ts similarity index 90% rename from src/api/encode/encoders/lib/swapInTypeCode.ts rename to src/api/encode/lib/swapInTypeCode.ts index bb5c125..65677be 100644 --- a/src/api/encode/encoders/lib/swapInTypeCode.ts +++ b/src/api/encode/lib/swapInTypeCode.ts @@ -1,5 +1,5 @@ import { match } from 'ts-pattern' -import { Code, CodeLength } from '../../../../core/code/code.js' +import { Code, CodeLength } from '../../../core/code/code.js' type Swapper = (text: string) => string diff --git a/src/api/encode/encoders/encodeRaw.test.ts b/src/api/encode/raw.test.ts similarity index 79% rename from src/api/encode/encoders/encodeRaw.test.ts rename to src/api/encode/raw.test.ts index fed51d3..f00e92f 100644 --- a/src/api/encode/encoders/encodeRaw.test.ts +++ b/src/api/encode/raw.test.ts @@ -1,31 +1,31 @@ import { Buffer } from 'buffer' -import { encodeRaw } from './encodeRaw.js' +import { raw } from './raw.js' describe('Raw encoder', () => { it("encodes a one-character primitive: 'A'", () => { // exmaple of 256 bit seed for ED25519 private key const binary = Buffer.from('4f3c811f1d6fa45a9d0b65e2c1e0ddf801d063e3f7e100c3500b6a229a5e9f2a', 'hex') // 32 bytes - const result = encodeRaw('A', binary) + const result = raw('A', binary) expect(result).toStrictEqual({ code: 'A', raw: binary }) }) it("encodes another one-character primitive: 'M'", () => { - const result = encodeRaw('M', Buffer.from([0x00, 0x01])) + const result = raw('M', Buffer.from([0x00, 0x01])) expect(result).toStrictEqual({ code: 'M', raw: Buffer.from([0, 1]) }) }) it("encodes yet another one-character primitive: 'N'", () => { - const result = encodeRaw('N', Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01])) + const result = raw('N', Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01])) expect(result).toStrictEqual({ code: 'N', raw: Buffer.from([0, 0, 0, 0, 0, 0, 0, 1]) }) }) it("encodes a two-character primitive: '0F'", () => { // randomly generated example of SHA-256 hash const binary = Buffer.from('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f', 'hex') - const result = encodeRaw('0F', binary) + const result = raw('0F', binary) expect(result).toStrictEqual({ code: '0F', raw: binary }) }) it("encodes a four-character primitive: '1AAB'", () => { // randomly generated example of ecsda secp256k1 public key const binary = Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex') - const result = encodeRaw('1AAB', binary) + const result = raw('1AAB', binary) expect(result).toStrictEqual({ code: '1AAB', raw: binary }) }) }) diff --git a/src/api/encode/raw.ts b/src/api/encode/raw.ts new file mode 100644 index 0000000..f664388 --- /dev/null +++ b/src/api/encode/raw.ts @@ -0,0 +1,10 @@ +import { Buffer } from 'buffer' +import { make } from '../../implementation/make.js' +import { Code } from '../../core/code/code.js' +import { Raw } from '../../core/domain/domains.js' + +export const raw = (code: Code, primitive: Uint8Array): Raw => + make( // make() ensures the primitive is valid + code, + Buffer.from(primitive) + ) diff --git a/src/api/encode/encoders/encodeText.test.ts b/src/api/encode/text.test.ts similarity index 54% rename from src/api/encode/encoders/encodeText.test.ts rename to src/api/encode/text.test.ts index 78126d1..b77e202 100644 --- a/src/api/encode/encoders/encodeText.test.ts +++ b/src/api/encode/text.test.ts @@ -1,22 +1,22 @@ import { Buffer } from 'buffer' -import { encodeText } from './encodeText.js' +import { text } from './text.js' describe('Text Encoder', () => { it('gets "MAAB" from ["M", 1]', () => { - const result = encodeText('M', Buffer.from([0x00, 0x01])) + const result = text('M', Buffer.from([0x00, 0x01])) expect(result).toBe('MAAB') }) it('gets "NAAAAAAAAAAB" from ["N", 1]', () => { - const result = encodeText('N', Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01])) + const result = text('N', Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01])) expect(result).toBe('NAAAAAAAAAAB') }) it('gets "0FDdrzWhk2F6..." from ["0F", "ddaf35a19..."]', () => { - const result = encodeText('0F', Buffer.from('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f', 'hex')) + const result = text('0F', Buffer.from('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f', 'hex')) expect(result).toBe('0FDdrzWhk2F6usxBc0muIEExEub6TompfqIKnu7mS1XTmiGSmSonT8GoNro8I6P-671FTUQjZDzoDiqayU-lTKSf') }) // 1AABArT5f26OkhTpogIbLHrW8iM0mfEU_tM-pr_D4rH-ryTB it('gets "1AABArT5f2..." from ["1AAB", "02b4f97f6e..."]', () => { - const result = encodeText('1AAB', Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex')) + const result = text('1AAB', Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex')) expect(result).toBe('1AABArT5f26OkhTpogIbLHrW8iM0mfEU_tM-pr_D4rH-ryTB') }) }) diff --git a/src/api/encode/text.ts b/src/api/encode/text.ts new file mode 100644 index 0000000..06ed796 --- /dev/null +++ b/src/api/encode/text.ts @@ -0,0 +1,20 @@ +import { pipe } from '../../lib/util/pipe.js' +import { Code } from '../../core/code/code.js' +import { Raw, Text } from '../../core/domain/domains.js' +import { make } from '../../implementation/make.js' +import { asText } from './lib/asText.js' + +export const text = (code: Code, primitive: Uint8Array): Text => { + const doRaw = rawWith(code) // which code should be used to make the raw? + const doText = textWith(code) // which code should be used to encode the text? + + // requires two steps... + return pipe( + primitive, + doRaw, // make the Raw + doText // encode the raw primitive as Text + ) +} + +const rawWith = (code: Code) => (primitive: Uint8Array) => make(code, primitive) +const textWith = (code: Code) => (tuple: Raw) => asText(code, tuple.raw) diff --git a/src/api/transform/toBinary.test.ts b/src/api/transform/toBinary.test.ts index fbc260b..db3118e 100644 --- a/src/api/transform/toBinary.test.ts +++ b/src/api/transform/toBinary.test.ts @@ -1,25 +1,25 @@ import { Raw } from '../../core/domain/domains.js' -import { encodeBinary } from '../encode/encoders/encodeBinary.js' -import { encodeText } from '../encode/encoders/encodeText.js' +import { binary } from '../encode/binary.js' +import { text } from '../encode/text.js' import { toBinary } from './toBinary.js' describe('Transform to Binary', () => { it('handles Text', () => { - const raw: Raw = { + const rah: Raw = { code: '1AAB', raw: Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex') } - const text = encodeText(raw.code, raw.raw) - const binary = encodeBinary(raw.code, raw.raw) - expect(toBinary(text)).toStrictEqual(binary) + const txt = text(rah.code, rah.raw) + const bin = binary(rah.code, rah.raw) + expect(toBinary(txt)).toStrictEqual(bin) }) it('handles Raw', () => { - const raw: Raw = { + const rah: Raw = { code: '1AAB', raw: Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex') } - const binary = encodeBinary(raw.code, raw.raw) - expect(toBinary(raw)).toStrictEqual(binary) + const bin = binary(rah.code, rah.raw) + expect(toBinary(rah)).toStrictEqual(bin) }) }) diff --git a/src/api/transform/toBinary.ts b/src/api/transform/toBinary.ts index b20d594..d8a6486 100644 --- a/src/api/transform/toBinary.ts +++ b/src/api/transform/toBinary.ts @@ -1,11 +1,11 @@ import { Buffer } from 'buffer' import { Binary, Text, Raw } from '../../core/domain/domains.js' -import { encodeBinary } from '../encode/encoders/encodeBinary.js' +import { binary } from '../encode/binary.js' export function toBinary (text: Text): Binary export function toBinary (Raw: Raw): Binary export function toBinary (textOrRaw: Text | Raw): Binary { if (typeof textOrRaw === 'string') return Buffer.from(textOrRaw, 'base64url') - else return encodeBinary(textOrRaw.code, textOrRaw.raw) + else return binary(textOrRaw.code, textOrRaw.raw) } diff --git a/src/api/transform/toRaw.test.ts b/src/api/transform/toRaw.test.ts index bd86e01..e16415e 100644 --- a/src/api/transform/toRaw.test.ts +++ b/src/api/transform/toRaw.test.ts @@ -1,44 +1,44 @@ import { Buffer } from 'buffer' import { Binary, Raw, Text } from '../../core/domain/domains.js' -import { encodeBinary } from '../encode/encoders/encodeBinary.js' -import { encodeText } from '../encode/encoders/encodeText.js' +import { binary } from '../encode/binary.js' +import { text } from '../encode/text.js' import { toRaw } from './toRaw.js' describe('Transform to Raw', () => { it('handles Text with one-character code', () => { - const raw: Raw = { + const rah: Raw = { code: 'M', raw: Buffer.from([0x00, 0x01]) } - const text: Text = encodeText(raw.code, raw.raw) - const actual = toRaw(text) - expect(actual).toStrictEqual(raw) + const txt: Text = text(rah.code, rah.raw) + const actual = toRaw(txt) + expect(actual).toStrictEqual(rah) }) it('handles Text with two-character code', () => { - const raw: Raw = { + const rah: Raw = { code: '0F', raw: Buffer.from('ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f', 'hex') } - const text: Text = encodeText(raw.code, raw.raw) - const actual = toRaw(text) - expect(actual).toStrictEqual(raw) + const txt: Text = text(rah.code, rah.raw) + const actual = toRaw(txt) + expect(actual).toStrictEqual(rah) }) it('handles Text with four-character code', () => { - const raw: Raw = { + const rah: Raw = { code: '1AAB', raw: Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex') } - const text: Text = encodeText(raw.code, raw.raw) - const actual = toRaw(text) - expect(actual).toStrictEqual(raw) + const txt: Text = text(rah.code, rah.raw) + const actual = toRaw(txt) + expect(actual).toStrictEqual(rah) }) it('handles Binary', () => { - const raw: Raw = { + const rah: Raw = { code: '1AAB', raw: Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex') } - const binary: Binary = encodeBinary(raw.code, raw.raw) - const actual = toRaw(binary) - expect(actual).toStrictEqual(raw) + const bin: Binary = binary(rah.code, rah.raw) + const actual = toRaw(bin) + expect(actual).toStrictEqual(rah) }) }) diff --git a/src/api/transform/toText.test.ts b/src/api/transform/toText.test.ts index f94d930..d08068c 100644 --- a/src/api/transform/toText.test.ts +++ b/src/api/transform/toText.test.ts @@ -1,25 +1,25 @@ import { Buffer } from 'buffer' import { Raw } from '../../core/domain/domains.js' -import { encodeBinary } from '../encode/encoders/encodeBinary.js' -import { encodeText } from '../encode/encoders/encodeText.js' +import { binary } from '../encode/binary.js' +import { text } from '../encode/text.js' import { toText } from './toText.js' describe('Transform to Text', () => { it('handles Binary', () => { - const raw: Raw = { + const rah: Raw = { code: '1AAB', raw: Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex') } - const binary = encodeBinary(raw.code, raw.raw) - const text = encodeText(raw.code, raw.raw) - expect(toText(binary)).toStrictEqual(text) + const bin = binary(rah.code, rah.raw) + const txt = text(rah.code, rah.raw) + expect(toText(bin)).toStrictEqual(txt) }) it('handles Raw', () => { - const raw: Raw = { + const rah: Raw = { code: '1AAB', raw: Buffer.from('02b4f97f6e8e9214e9a2021b2c7ad6f2233499f114fed33ea6bfc3e2b1feaf24c1', 'hex') } - const text = encodeText(raw.code, raw.raw) - expect(toText(raw)).toStrictEqual(text) + const txt = text(rah.code, rah.raw) + expect(toText(rah)).toStrictEqual(txt) }) }) diff --git a/src/api/transform/toText.ts b/src/api/transform/toText.ts index 335b1b2..b6238d4 100644 --- a/src/api/transform/toText.ts +++ b/src/api/transform/toText.ts @@ -1,12 +1,12 @@ import { Buffer } from 'buffer' import { Binary, Raw, Text } from '../../core/domain/domains.js' -import { encodeText } from '../encode/encoders/encodeText.js' +import { text } from '../encode/text.js' export function toText (binary: Binary): Text export function toText (raw: Raw): Text export function toText (binaryOrRaw: Binary | Raw): Text { if (binaryOrRaw instanceof Buffer) return binaryOrRaw.toString('base64url') - else return encodeText(binaryOrRaw.code, binaryOrRaw.raw) + else return text(binaryOrRaw.code, binaryOrRaw.raw) } diff --git a/src/lib/util/pipe.ts b/src/lib/util/pipe.ts index b191c25..426f567 100644 --- a/src/lib/util/pipe.ts +++ b/src/lib/util/pipe.ts @@ -1,3 +1,4 @@ +// a basic pipe implementation. don't use fancy libraries like Remeda for now. export const pipe = (value: any, ...fns: Function[]): any => fns .reduce( diff --git a/src/main.ts b/src/main.ts index 0a15704..d0b74ee 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,9 +1,9 @@ -import { encodeText } from './api/encode/encoders/encodeText.js' +import { text } from './api/encode/text.js' console.log('Welcome to simple-cesr!') console.log("We'll be doing amazing things like this:") const primitive = new Uint8Array([0x00, 0x01]) // two bytes console.log('Primitive:', primitive) -const encoded = encodeText('M', primitive) +const encoded = text('M', primitive) console.log('Encoded:', encoded) diff --git a/test/standardsTest/README.md b/test/standardsTest/README.md deleted file mode 100644 index 4ff4f50..0000000 --- a/test/standardsTest/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Standards Test - -The standards test confirms agreement of `simple-cesr`'s output with other implementations of CESR. - -The examples in `standards.js` are from the `Matter` class in [cesr-ts](https://github.com/weboftrust/cesr-ts) (derived from [signify-ts](https://github.com/weboftrust/signify-ts)) from [WebOfTrust](https://github.com/weboftrust). Given the same given inputs, `simple-cesr` should produce the same given outputs as `Matter`. diff --git a/test/standardsTest/standards.test.ts b/test/standardsTest/standards.test.ts deleted file mode 100644 index c5fabde..0000000 --- a/test/standardsTest/standards.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { Buffer } from 'buffer' -import { standards } from './standards.js' -import { encodeText } from '../../src/api/encode/encoders/encodeText.js' -import { Code } from '../../src/core/code/code.js' - -// Test is only against Matter output for now -const matter = standards.matter - -describe('Standards test => ', () => { - matter - .forEach((type) => { - const code = type.code - // test each sample from Matter grouped by type code - test(code, () => { - type.samples - .forEach((sample) => { - // convert the raw hex string to a Buffer, the form expected by the encoder - const primitive = Buffer.from(sample.raw, 'hex') - // encode the Buffer as Text - const text = encodeText(type.code as Code, primitive) - // the basic test is that the Text is the expected length - expect(text.length).toBe(type.length) - // the more specific test is that the Text matches the standard in the sample - expect(text).toBe(sample.text) - }) - }) - }) -}) diff --git a/test/standardsTest/standards.ts b/test/standardsTest/standards.ts deleted file mode 100644 index 7ba0443..0000000 --- a/test/standardsTest/standards.ts +++ /dev/null @@ -1,702 +0,0 @@ -// input for eneral standards test based on what is generated by the Matter class -// https://github.com/webOfTrust/signify-ts/ - -// code: the CESR type code -// length: the length of the encoded primitive, including code (from spec code tables) -// samples: specific examples from Matter where: -// raw: is the input primitive value as a hexstring (will be converted to byte array in test) and -// text: is the expected encoded value, as generated by Matter -export const standards = { - matter: [ - { - code: 'A', - length: 44, - samples: [ - { - raw: '858e916d31869a4cf1067052b346d7cb1345c91e15c10c5ddc4a73d4ceb03ea2', - text: 'AIWOkW0xhppM8QZwUrNG18sTRckeFcEMXdxKc9TOsD6i' - }, - { - raw: '39d9508ed1d58c8b7ad8412d76c33f8b0fb18db6e06d5ab9884ebd1712e443d3', - text: 'ADnZUI7R1YyLethBLXbDP4sPsY224G1auYhOvRcS5EPT' - }, - { - raw: '61ae197b0db9014f2b6f07b80e162b075a51dfdb5160300beef07387a2596419', - text: 'AGGuGXsNuQFPK28HuA4WKwdaUd_bUWAwC-7wc4eiWWQZ' - }, - { - raw: 'eea1f8eee09785feb9c0386fe2cc409866ba14b81dbb294c1774e6df8a0a85c9', - text: 'AO6h-O7gl4X-ucA4b-LMQJhmuhS4HbspTBd05t-KCoXJ' - }, - { - raw: '89596debaf3abab5c07cf116e2769f28115c2d2f5cc3453da1fb89b573ee0303', - text: 'AIlZbeuvOrq1wHzxFuJ2nygRXC0vXMNFPaH7ibVz7gMD' - } - ] - }, - { - code: 'B', - length: 44, - samples: [ - { - raw: '3cc6475abaafecaccc972c951ab9b2fa1b77c15f760a99a2ad512d22c631f627', - text: 'BDzGR1q6r-yszJcslRq5svobd8FfdgqZoq1RLSLGMfYn' - }, - { - raw: '665f49a3d1b5fed48140649b0c9b94d5e7ef5b6594b3e2f22ce8e8cffef740f0', - text: 'BGZfSaPRtf7UgUBkmwyblNXn71tllLPi8izo6M_-90Dw' - }, - { - raw: 'e01bf1473e2d4f329de6ad37512d048f1b687633c00bdc08f362292a8d3ebe97', - text: 'BOAb8Uc-LU8yneatN1EtBI8baHYzwAvcCPNiKSqNPr6X' - }, - { - raw: '92de313d61ac7d44ed5cf61e10b4a2c33c4bee38758d0873d7a1b4783893fa6a', - text: 'BJLeMT1hrH1E7Vz2HhC0osM8S-44dY0Ic9ehtHg4k_pq' - }, - { - raw: '5401fd73635d1eee3b351773974f1f6661d8b95309771da4baf9b954cc800295', - text: 'BFQB_XNjXR7uOzUXc5dPH2Zh2LlTCXcdpLr5uVTMgAKV' - } - ] - }, - { - code: 'C', - length: 44, - samples: [ - { - raw: '75c98c6b7f70ab949d76333c0ad68dc8deb4382aef476a2d57ac609006f85500', - text: 'CHXJjGt_cKuUnXYzPArWjcjetDgq70dqLVesYJAG-FUA' - }, - { - raw: '6b8da0610356225e43b144c955f76be6160e29ef48aa15d2cc98f7f379a2b806', - text: 'CGuNoGEDViJeQ7FEyVX3a-YWDinvSKoV0syY9_N5orgG' - }, - { - raw: 'cead777a1919cb435b47815a4404b2bfa0cae5c49a4a26b8cbd1238dc597e816', - text: 'CM6td3oZGctDW0eBWkQEsr-gyuXEmkomuMvRI43Fl-gW' - }, - { - raw: 'cb8a510c02b64faa40a83d7f955d78adbdd4af4829234a9abc90f724e02eb175', - text: 'CMuKUQwCtk-qQKg9f5VdeK291K9IKSNKmryQ9yTgLrF1' - }, - { - raw: 'f87a9ff617eec7a118eaaf44b5530092a0fe05d164dd3953ef927c265ddff03e', - text: 'CPh6n_YX7sehGOqvRLVTAJKg_gXRZN05U--SfCZd3_A-' - } - ] - }, - { - code: 'D', - length: 44, - samples: [ - { - raw: '3cc6475abaafecaccc972c951ab9b2fa1b77c15f760a99a2ad512d22c631f627', - text: 'DDzGR1q6r-yszJcslRq5svobd8FfdgqZoq1RLSLGMfYn' - }, - { - raw: '665f49a3d1b5fed48140649b0c9b94d5e7ef5b6594b3e2f22ce8e8cffef740f0', - text: 'DGZfSaPRtf7UgUBkmwyblNXn71tllLPi8izo6M_-90Dw' - }, - { - raw: 'e01bf1473e2d4f329de6ad37512d048f1b687633c00bdc08f362292a8d3ebe97', - text: 'DOAb8Uc-LU8yneatN1EtBI8baHYzwAvcCPNiKSqNPr6X' - }, - { - raw: '92de313d61ac7d44ed5cf61e10b4a2c33c4bee38758d0873d7a1b4783893fa6a', - text: 'DJLeMT1hrH1E7Vz2HhC0osM8S-44dY0Ic9ehtHg4k_pq' - }, - { - raw: '5401fd73635d1eee3b351773974f1f6661d8b95309771da4baf9b954cc800295', - text: 'DFQB_XNjXR7uOzUXc5dPH2Zh2LlTCXcdpLr5uVTMgAKV' - } - ] - }, - { - code: 'E', - length: 44, - samples: [ - { - raw: 'b517a498bf554ab419bbcaa61be07af412d33348eed4b44bd45384550df82d41', - text: 'ELUXpJi_VUq0GbvKphvgevQS0zNI7tS0S9RThFUN-C1B' - }, - { - raw: 'a18452e2ba2af0a8da60e34463636e303181c5768b4fdcb0f206b862a5c3f8b3', - text: 'EKGEUuK6KvCo2mDjRGNjbjAxgcV2i0_csPIGuGKlw_iz' - }, - { - raw: '37fb887452ffdb2988c92d993ce1af27427251ed3146826f04ed30582ce63d4c', - text: 'EDf7iHRS_9spiMktmTzhrydCclHtMUaCbwTtMFgs5j1M' - }, - { - raw: '3fd6aa5f6d376721bdea42120c137394a2ae297ea709821dde91d62a947ae9c4', - text: 'ED_Wql9tN2chvepCEgwTc5Siril-pwmCHd6R1iqUeunE' - }, - { - raw: '6d3035a2cd65f1904bf8be27a69b8b7115abe1dabcbd7a38265d2808f11cb717', - text: 'EG0wNaLNZfGQS_i-J6abi3EVq-HavL16OCZdKAjxHLcX' - } - ] - }, - { - code: 'F', - length: 44, - samples: [ - { - raw: 'c8e63d9e7d7d8f222e3162698466791370fc5926484a294d23c33849c177d6da', - text: 'FMjmPZ59fY8iLjFiaYRmeRNw_FkmSEopTSPDOEnBd9ba' - }, - { - raw: 'f0c48bda4e48e424ea0fb5797b43c07d39b1530afed484045f9df47fb0f3cc531', - text: 'FPDEi9pOSOQk6g-1eXtDwH05sVMK_tSEBF-d9H-w88xT' - }, - { - raw: '86f1e8f4d7854bb52d234c84ad48792e2d39df3e63d59aeb0713a75053ad7b1fd', - text: 'FIbx6PTXhUu1LSNMhK1IeS4tOd8-Y9Wa6wcTp1BTrXsf' - }, - { - raw: '4e7857cf55c509cf86d245fe68265705e1e91f0d07f8a64b33a616ba6d19ab701', - text: 'FE54V89VxQnPhtJF_mgmVwXh6R8NB_imSzOmFrptGatw' - }, - { - raw: '6bea02b3834beae4374977a67aaecfa3b0c9d3f4b0d6a1f10879e64d2f1d2a5bc', - text: 'FGvqArODS-rkN0l3pnquz6OwydP0sNah8Qh55k0vHSpb' - } - ] - }, - { - code: 'G', - length: 44, - samples: [ - { - raw: 'cb91d3ff78b2198f71d30f0cd8d58dcdd86f9f1f2cdd32074ff75f7e9c7e21cc', - text: 'GMuR0_94shmPcdMPDNjVjc3Yb58fLN0yB0_3X36cfiHM' - }, - { - raw: '14aae01c915e6d96f4a3c8b07f18ab7b54e564ea9edf74c5563d0bf0f1718dd3', - text: 'GBSq4ByRXm2W9KPIsH8Yq3tU5WTqnt90xVY9C_DxcY3T' - }, - { - raw: '2080982ef42d6be9c30716c33633f0b4e8f35f7e031e5822e4f6e994617aee2e', - text: 'GCCAmC70LWvpwwcWwzYz8LTo819-Ax5YIuT26ZRheu4u' - }, - { - raw: 'acbaae18d8f5c4bc7ff46f6edab63050d65d1bbaaed37225fda8eb2ec8f87257', - text: 'GKy6rhjY9cS8f_Rvbtq2MFDWXRu6rtNyJf2o6y7I-HJX' - }, - { - raw: '6ebc23dd5754bf5df268dd3e3b368a96d1e8db719b0e5e7971f7f4e9d5ee761f', - text: 'GG68I91XVL9d8mjdPjs2ipbR6Ntxmw5eeXH39OnV7nYf' - } - ] - }, - { - code: 'H', - length: 44, - samples: [ - { - raw: '0c52b16b0101ba42ee173a341b3c0e926ab77571db0b2e828a90c23331b18788', - text: 'HAxSsWsBAbpC7hc6NBs8DpJqt3Vx2wsugoqQwjMxsYeI' - }, - { - raw: '365e2121d72c3ad0ec0e1e39b7ed7481b5db8223d24be4b2e32c09cb301f5355', - text: 'HDZeISHXLDrQ7A4eObftdIG124Ij0kvksuMsCcswH1NV' - }, - { - raw: '062d2c49cb002b2e514aa1bf5ec334c60a78a25b012ea0081cc785b91ef5d933', - text: 'HAYtLEnLACsuUUqhv17DNMYKeKJbAS6gCBzHhbke9dkz' - }, - { - raw: '2cb8c57af1e07c9dc517ef650f44da9a3f25019ed6f00f15bf2609c929f8c488', - text: 'HCy4xXrx4HydxRfvZQ9E2po_JQGe1vAPFb8mCckp-MSI' - }, - { - raw: '22946046b0f72b188a1880c787e3eb758f7d99eef435a74e1835e108f80a0a6f', - text: 'HCKUYEaw9ysYihiAx4fj63WPfZnu9DWnThg14Qj4Cgpv' - } - ] - }, - { - code: 'I', - length: 44, - samples: [ - { - raw: 'fddeca56469d697c66ac2b32c43d9ac2405b2cc0241a2e8ed6d59dd7c70249c0', - text: 'IP3eylZGnWl8ZqwrMsQ9msJAWyzAJBoujtbVndfHAknA' - }, - { - raw: '3db80a61654755c8e5d9f44e8f2e4f6661be9475e1dd62a797ad8a34c91d055b', - text: 'ID24CmFlR1XI5dn0To8uT2ZhvpR14d1ip5etijTJHQVb' - }, - { - raw: '0e0e7b18eb42d66f5f16d91786b3e17382c9b78a212f0026090ab4cb4c6110d3', - text: 'IA4OexjrQtZvXxbZF4az4XOCybeKIS8AJgkKtMtMYRDT' - }, - { - raw: '8d52d7de37438e2289d8820e00cf9d62b60c87c08759399b8d95d9e9ed9dbf36', - text: 'II1S1943Q44iidiCDgDPnWK2DIfAh1k5m42V2entnb82' - }, - { - raw: '0633943b479376d7e79cfba50661521a7d61a0bb3448c3f2d98b992c893c0b9e', - text: 'IAYzlDtHk3bX55z7pQZhUhp9YaC7NEjD8tmLmSyJPAue' - } - ] - }, - { - code: 'J', - length: 44, - samples: [ - { - raw: '6f5291fd5e3a271bc9a5d77e77bfc38f70e889c1b4d1cf034a5e537045f3b5c8', - text: 'JG9Skf1eOicbyaXXfne_w49w6InBtNHPA0peU3BF87XI' - }, - { - raw: 'e9b4568f1e93c92a70a20c22a7e4c4bfc83e4e7a8b8325d3b43c7a31b937bdc5', - text: 'JOm0Vo8ek8kqcKIMIqfkxL_IPk56i4Ml07Q8ejG5N73F' - }, - { - raw: '3f53d2aafe2a2b3c7e6256a61f89644a4ebc1d92343150b1586c90ab81c43e2e', - text: 'JD9T0qr-Kis8fmJWph-JZEpOvB2SNDFQsVhskKuBxD4u' - }, - { - raw: '90f1ae94a87f5b31d621308e3f7fb39f87b85f3d3de245c3d57f75ee59056b8a', - text: 'JJDxrpSof1sx1iEwjj9_s5-HuF89PeJFw9V_de5ZBWuK' - }, - { - raw: 'a1c8062f7d91a7b52ac0e1875bc12f0f4e95d4d7d7252e16c68c3b2eb1e2b8d9', - text: 'JKHIBi99kae1KsDhh1vBLw9OldTX1yUuFsaMOy6x4rjZ' - } - ] - }, - { - code: 'M', - length: 4, - samples: [ - { - raw: '6ae3', - text: 'MGrj' - }, - { - raw: 'b7e2', - text: 'MLfi' - }, - { - raw: '3f3b', - text: 'MD87' - }, - { - raw: '8d90', - text: 'MI2Q' - }, - { - raw: 'e2ff', - text: 'MOL_' - } - ] - }, - { - code: 'N', - length: 12, - samples: [ - { - raw: 'c6e64b12b9fe842c', - text: 'NMbmSxK5_oQs' - }, - { - raw: 'a3f8d5704b9e6310', - text: 'NKP41XBLnmMQ' - }, - { - raw: '7cb569c376159d1a', - text: 'NHy1acN2FZ0a' - }, - { - raw: '9a5bf1c8ae63b027', - text: 'NJpb8ciuY7An' - }, - { - raw: '0d5f2816ca3098e7', - text: 'NA1fKBbKMJjn' - } - ] - }, - { - code: 'O', - length: 44, - samples: [ - { - raw: 'f7e5518d7ac1d9bf8c1244090a3b2a4481e0d4af3e4d25332187262d29925f77', - text: 'OPflUY16wdm_jBJECQo7KkSB4NSvPk0lMyGHJi0pkl93' - }, - { - raw: 'a72fc11b0710ae53cb7c4f3622359eb7a8d27512dd18942dd413417e02d7b84e', - text: 'OKcvwRsHEK5Ty3xPNiI1nreo0nUS3RiULdQTQX4C17hO' - }, - { - raw: 'b384d0e7e7bde2582fd12be6362e77b78eb01af81d0b2f9e04565079b9122e7c', - text: 'OLOE0OfnveJYL9Er5jYud7eOsBr4HQsvngRWUHm5Ei58' - }, - { - raw: '70e56c94eabfb7ff8a2fe73a126d9f1b1b7c82d2c9295f67b93bb6d379e46cc3', - text: 'OHDlbJTqv7f_ii_nOhJtnxsbfILSySlfZ7k7ttN55GzD' - }, - { - raw: 'b6d00770aa4a6b75f3d059eb6e4b7b0e4d93b8b5878d29f49f986f95dc0e4470', - text: 'OLbQB3CqSmt189BZ625Lew5Nk7i1h40p9J-Yb5XcDkRw' - } - ] - }, - { - code: '0A', - length: 24, - samples: [ - { - raw: '784d092dc4a2ec260d9728b9341e1a7c', - text: '0AB4TQktxKLsJg2XKLk0Hhp8' - }, - { - raw: 'e7dd8db8d223ec92accb322f13596568', - text: '0ADn3Y240iPskqzLMi8TWWVo' - }, - { - raw: '39aa391b5b820de57df633ac0025af16', - text: '0AA5qjkbW4IN5X32M6wAJa8W' - }, - { - raw: 'a528c1211d1116ad204f28e181ddbc7f', - text: '0AClKMEhHREWrSBPKOGB3bx_' - }, - { - raw: '82ffe6f6f680915386920e925ed23204', - text: '0ACC_-b29oCRU4aSDpJe0jIE' - } - ] - }, - { - code: '0B', - length: 88, - samples: [ - { - raw: '8cb872b8731604949611b8872026c3e4f7482973031773b3fa87b11f4c9c6112c4170f5ee2cd182ba5819c553a7bb9e323cd2f8aaf372ed57d47d9385761810a', - text: '0BCMuHK4cxYElJYRuIcgJsPk90gpcwMXc7P6h7EfTJxhEsQXD17izRgrpYGcVTp7ueMjzS-Krzcu1X1H2ThXYYEK' - }, - { - raw: 'e7479d9eb057be7126a45cd84cebdff7bb3881afabdec79836a248f0fd4fecc0cf1650cf99ede7556b32ecb415e3bcf0d6ce2d19a02e514e735ecd0df0b75a0e', - text: '0BDnR52esFe-cSakXNhM69_3uziBr6vex5g2okjw_U_swM8WUM-Z7edVazLstBXjvPDWzi0ZoC5RTnNezQ3wt1oO' - } - ] - }, - { - code: '0C', - length: 88, - samples: [ - { - raw: 'c5a0fa6553445a4fefb8b2ce35351788459271b55a548ea0674194afa8200c8e1186ab6aa231ffff58cff6bec2d96ea29cac5f4daf2972c3ac5f8c8db328f9dc', - text: '0CDFoPplU0RaT--4ss41NReIRZJxtVpUjqBnQZSvqCAMjhGGq2qiMf__WM_2vsLZbqKcrF9Nrylyw6xfjI2zKPnc' - }, - { - raw: '934cd3a7265d1a1af67694af84d200d97f3faaf478f1be4f488b2639b6c9560154fff40a39250cc31bb122d8f25862ac373cab3bf590328f7556fff4f5318094', - text: '0CCTTNOnJl0aGvZ2lK-E0gDZfz-q9Hjxvk9IiyY5tslWAVT_9Ao5JQzDG7Ei2PJYYqw3PKs79ZAyj3VW__T1MYCU' - }, - { - raw: 'fdbc3df8f44217a623e9e8aea7253719f4af8f59e7ee78a7783643342efed153278bd4f5e17d9e68909aee401d732584a6e9f958a5806fa82591c5f6ada916e1', - text: '0CD9vD349EIXpiPp6K6nJTcZ9K-PWefueKd4NkM0Lv7RUyeL1PXhfZ5okJruQB1zJYSm6flYpYBvqCWRxfatqRbh' - }, - { - raw: 'dea61652f4211fa70e9ee55e731a3013a64de265611f75b71921520bca91234e6bb1f3fed9e0e2db71cd92124706615ea40b37dd51ccf08cba0d04bf75b1e514', - text: '0CDephZS9CEfpw6e5V5zGjATpk3iZWEfdbcZIVILypEjTmux8_7Z4OLbcc2SEkcGYV6kCzfdUczwjLoNBL91seUU' - }, - { - raw: 'a6e78fb83dfd8992071fcbdff4e16af9ae7b2ed75cd7faf3120ddf075a0883cc035f538dee0090115d47db5ebbf20bda78e81bee11a4fd7298ae238ad06c0467', - text: '0CCm54-4Pf2Jkgcfy9_04Wr5rnsu11zX-vMSDd8HWgiDzANfU43uAJARXUfbXrvyC9p46BvuEaT9cpiuI4rQbARn' - } - ] - }, - { - code: '0D', - length: 88, - samples: [ - { - raw: 'adbe20f5337fe64da42575bfb20372e24d3ff67fb3c57c15e2a21b387d67c7e96373a3cf984e1548ac064cf9389cef6763ae1f828a963287f6ba7cbc79521e29', - text: '0DCtviD1M3_mTaQldb-yA3LiTT_2f7PFfBXiohs4fWfH6WNzo8-YThVIrAZM-Tic72djrh-CipYyh_a6fLx5Uh4p' - }, - { - raw: '347fa2163e71b2f3a2ceeb7cd31034540585e5d1933012aaf9319e7756b8076c5390223cfc4f2361317cd103eb7a7600f66ebacbe9d12469f3ae43882dad8976', - text: '0DA0f6IWPnGy86LO63zTEDRUBYXl0ZMwEqr5MZ53VrgHbFOQIjz8TyNhMXzRA-t6dgD2brrL6dEkafOuQ4gtrYl2' - }, - { - raw: '3a146daa178fa1ee2ec8aa5c73749d7423addcf1298856ec885606996959e45ff206ac6670a89fdae61f94045a05be90f9bd990a0213d3846b1edb6646747a73', - text: '0DA6FG2qF4-h7i7IqlxzdJ10I63c8SmIVuyIVgaZaVnkX_IGrGZwqJ_a5h-UBFoFvpD5vZkKAhPThGse22ZGdHpz' - }, - { - raw: '49f9d42a6f139c52c6fbf1776edf8721d0f815a3f39884931b716cfb415bcbdce034c3c5cdd8c60111f7ce5cf7dc0414a4b8d8c021b260fd8a955955b7f07e0c', - text: '0DBJ-dQqbxOcUsb78Xdu34ch0PgVo_OYhJMbcWz7QVvL3OA0w8XN2MYBEffOXPfcBBSkuNjAIbJg_YqVWVW38H4M' - }, - { - raw: '5b461d74083e9359929957bc6756378f7dafede7c1eef28091564604bfdcbcc4dc9d557af7eab2c43977a4a51d01f82d9b8632f5b54d7e024af707b05baf61b1', - text: '0DBbRh10CD6TWZKZV7xnVjePfa_t58Hu8oCRVkYEv9y8xNydVXr36rLEOXekpR0B-C2bhjL1tU1-Akr3B7Bbr2Gx' - } - ] - }, - { - code: '0E', - length: 88, - samples: [ - { - raw: '5bfe9207ddbcf530824fdfebf09390df804d7745b7337cdb146ace9fb0ab8b8edc42d799168d8f181cbf4ba8a7236f2e470202f9c40f81e8e419bcc8e5b933c8', - text: '0EBb_pIH3bz1MIJP3-vwk5DfgE13RbczfNsUas6fsKuLjtxC15kWjY8YHL9LqKcjby5HAgL5xA-B6OQZvMjluTPI' - }, - { - raw: 'f5be6a9a15c11609dab9eba53e6d66497306fa91835b193b9384c26802a34f5e075250c968fe20da529465bec9eeaac5e24362cf56f18d44cec5699fe76a2509', - text: '0ED1vmqaFcEWCdq566U-bWZJcwb6kYNbGTuThMJoAqNPXgdSUMlo_iDaUpRlvsnuqsXiQ2LPVvGNRM7FaZ_naiUJ' - }, - { - raw: '66aaccee9a5bce00c1eab49a18ce8a4d8f9b68e629c9b3edf0666f37452e2c6ebb0df5bbebb0ab21d0f0c57713c1871db6c3f03c6106ce3aa532591d3e32c40e', - text: '0EBmqszumlvOAMHqtJoYzopNj5to5inJs-3wZm83RS4sbrsN9bvrsKsh0PDFdxPBhx22w_A8YQbOOqUyWR0-MsQO' - }, - { - raw: '726f03fa74afce792320666a7f43b37a6b19188add0571aaa3ae5f46e0b4a2af64a5e88ddf5ecd2f8b9ca992e766e4a539c83983b85404c5fdac686aa153aed6', - text: '0EBybwP6dK_OeSMgZmp_Q7N6axkYit0Fcaqjrl9G4LSir2Sl6I3fXs0vi5ypkudm5KU5yDmDuFQExf2saGqhU67W' - }, - { - raw: 'f62f843fbddf045f731ff95331d0d3b3a00e02cddbec197dfc18099a9a6006d7b535f7ce7914ce458500f4926b99667ff639ffe4249ecae52fb2f05594272940', - text: '0ED2L4Q_vd8EX3Mf-VMx0NOzoA4CzdvsGX38GAmammAG17U19855FM5FhQD0kmuZZn_2Of_kJJ7K5S-y8FWUJylA' - } - ] - }, - { - code: '0F', - length: 88, - samples: [ - { - raw: '1af4f1196ba3ec4781a919983b206407e99234db0ba1f616e3258959693d60738be207b3b1c9a997955ed8de6ea08cbe115665b6fceef4374a544174605444b3', - text: '0FAa9PEZa6PsR4GpGZg7IGQH6ZI02wuh9hbjJYlZaT1gc4viB7OxyamXlV7Y3m6gjL4RVmW2_O70N0pUQXRgVESz' - }, - { - raw: 'b7b7c16b742f6cc61e28da2dd2a8c0b78f28c906d0fd144805d9161539f6a4c0f853a1f1eeef1c59a15f56b91be6a533124df5f946085f4c6229f79b0657b6e6', - text: '0FC3t8FrdC9sxh4o2i3SqMC3jyjJBtD9FEgF2RYVOfakwPhTofHu7xxZoV9WuRvmpTMSTfX5RghfTGIp95sGV7bm' - }, - { - raw: 'd31fad43cd02adaa95df6f6083e1a15cf4342150358a14ce648f953dc0cc0b80458544c24d490544b5f3e42854bc013fe9f57c924c4f185f49b4726f1fde15e7', - text: '0FDTH61DzQKtqpXfb2CD4aFc9DQhUDWKFM5kj5U9wMwLgEWFRMJNSQVEtfPkKFS8AT_p9XySTE8YX0m0cm8f3hXn' - }, - { - raw: '66796c34de3ed7fb610537e8df273abfa5946103972ca8ed777539de36e69b974372ea6c5f07a658f1ffd665c7940d016adce0d8bc3d94ce4459c667569da50c', - text: '0FBmeWw03j7X-2EFN-jfJzq_pZRhA5csqO13dTneNuabl0Ny6mxfB6ZY8f_WZceUDQFq3ODYvD2UzkRZxmdWnaUM' - }, - { - raw: '5bcfa86d938cd22d884561d245d139ffa2a37ae22cc7854b26d7faa47f78f6d49217f7d2421d922438d90f4a7bb91e1acb70dfcb33f0fd4cfce2a71b9c26eb61', - text: '0FBbz6htk4zSLYhFYdJF0Tn_oqN64izHhUsm1_qkf3j21JIX99JCHZIkONkPSnu5HhrLcN_LM_D9TPzipxucJuth' - } - ] - }, - { - code: '0G', - length: 88, - samples: [ - { - raw: '01e6d981d060da5305c0c4b798cfdca1f20bde68b4070e5a8b23cfa1016f4f249af48b265d7871f357279efdcba8678a35e0226fdd82edb775b72ebd56205528', - text: '0GAB5tmB0GDaUwXAxLeYz9yh8gveaLQHDlqLI8-hAW9PJJr0iyZdeHHzVyee_cuoZ4o14CJv3YLtt3W3Lr1WIFUo' - }, - { - raw: 'b5e8e05b5281b4df3b3e1518220e7d93661960cb1b7d9c08f86a66ee8386799696c461bb592ca559082fe7bb3a843cd27e32c973d677c0ae1e4d821b13bc56e5', - text: '0GC16OBbUoG03zs-FRgiDn2TZhlgyxt9nAj4ambug4Z5lpbEYbtZLKVZCC_nuzqEPNJ-Mslz1nfArh5NghsTvFbl' - }, - { - raw: 'e449839b82f6861fa9eb98ec6b089de8f7a8324a3151f275f2f0110ee1a4b888bf2738a20130858b816db80a4d8dce53f356b9e36dc2d17879a9ee50f17a2faf', - text: '0GDkSYObgvaGH6nrmOxrCJ3o96gySjFR8nXy8BEO4aS4iL8nOKIBMIWLgW24Ck2NzlPzVrnjbcLReHmp7lDxei-v' - }, - { - raw: '685f2659c1409f1d8217e4ce43833c2c2069e3ed82264c70f2016359bc3295b47aa7db1ddeb9513e74216be2c5d452c95fff601e377be938810cad7134b40122', - text: '0GBoXyZZwUCfHYIX5M5DgzwsIGnj7YImTHDyAWNZvDKVtHqn2x3euVE-dCFr4sXUUslf_2AeN3vpOIEMrXE0tAEi' - }, - { - raw: 'ce5d5131e29ba529371d5a73017a7a1a1272cda75deb19a0c9426045177b11d824a48611030d566b7acba94277ddfb0ab108252f5a76be0ec4daa8561846cb5e', - text: '0GDOXVEx4pulKTcdWnMBenoaEnLNp13rGaDJQmBFF3sR2CSkhhEDDVZresupQnfd-wqxCCUvWna-DsTaqFYYRste' - } - ] - }, - { - code: '0H', - length: 8, - samples: [ - { - raw: '48fd43fd', - text: '0HBI_UP9' - }, - { - raw: '822e72f5', - text: '0HCCLnL1' - }, - { - raw: '48f3c9eb', - text: '0HBI88nr' - }, - { - raw: '20e5ac52', - text: '0HAg5axS' - }, - { - raw: 'ce60aabc', - text: '0HDOYKq8' - } - ] - }, - { - code: '1AAA', - length: 48, - samples: [ - { - raw: '02b4e3429fccb0541c8018d172325c2671c6a248df84aefc3b146f616b5a394762', - text: '1AAAArTjQp_MsFQcgBjRcjJcJnHGokjfhK78OxRvYWtaOUdi' - }, - { - raw: '03a34d6f462f1b81a64c2a01cb7c8ad882a48ed215f954b4c4f5b6d687116bb03e', - text: '1AAAA6NNb0YvG4GmTCoBy3yK2IKkjtIV-VS0xPW21ocRa7A-' - }, - { - raw: '0291e19a245ddc8ba29acb4159f89e8e1c974d8ec3db57c471fe1a5c2d8e4bafdc', - text: '1AAAApHhmiRd3IuimstBWfiejhyXTY7D21fEcf4aXC2OS6_c' - }, - { - raw: '0369a092b6b5276b5f3ab509be3d74c6d8c7711a243a63ee1fabb0454df8ddf245', - text: '1AAAA2mgkra1J2tfOrUJvj10xtjHcRokOmPuH6uwRU343fJF' - }, - { - raw: '025fb3d5f4b8769cfb3f19749103b8b9a1b17c7cb5dfc006c167b5d5a7f3b8c634', - text: '1AAAAl-z1fS4dpz7Pxl0kQO4uaGxfHy138AGwWe11afzuMY0' - } - ] - }, - { - code: '1AAB', - length: 48, - samples: [ - { - raw: '029d8fb7ee8bee47d25a44fb3e83a4c1a1b5b5edf1d9ff7b2d3f3b5fe3b0ede8ac', - text: '1AABAp2Pt-6L7kfSWkT7PoOkwaG1te3x2f97LT87X-Ow7eis' - }, - { - raw: '03e8f9b8a16e9a64b8e8f058b48b6f56d3ff8d9ee4af2bc43b6ba6488d9d72a6f1', - text: '1AABA-j5uKFummS46PBYtItvVtP_jZ7kryvEO2umSI2dcqbx' - }, - { - raw: '027fbfecbce2d7b9c8d9a8b0a8e0be0b3d9a927d2a5b9e4e4a77af260e05dace28', - text: '1AABAn-_7Lzi17nI2aiwqOC-Cz2akn0qW55OSnevJg4F2s4o' - }, - { - raw: '0323a1f8339b4a2186cfeb1216691a2fb5285234b094307b2d8d8d8af3a391a5ff', - text: '1AABAyOh-DObSiGGz-sSFmkaL7UoUjSwlDB7LY2NivOjkaX_' - }, - { - raw: '02feab256e8b4f317bb5e85b4b4d7a2f2a7e362b4b5ee8af1c6aa907b30bfdc076', - text: '1AABAv6rJW6LTzF7tehbS016Lyp-NitLXuivHGqpB7ML_cB2' - } - ] - }, - { - code: '1AAC', - length: 80, - samples: [ - { - raw: '9a768bfe3045cd2189abcdef1234567890fedcba9876543210abcdef1234567890abcd1234ef567890abcd1234ef567890abcd1234ef567890', - text: '1AACmnaL_jBFzSGJq83vEjRWeJD-3LqYdlQyEKvN7xI0VniQq80SNO9WeJCrzRI071Z4kKvNEjTvVniQ' - }, - { - raw: '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12', - text: '1AACEjRWeJCrze8SNFZ4kKvN7xI0VniQq83vEjRWeJCrze8SNFZ4kKvN7xI0VniQq83vEjRWeJCrze8S' - }, - { - raw: 'fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fe', - text: '1AAC_ty6mHZUMhD-3LqYdlQyEP7cuph2VDIQ_ty6mHZUMhD-3LqYdlQyEP7cuph2VDIQ_ty6mHZUMhD-' - }, - { - raw: 'abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab', - text: '1AACq83vEjRWeJCrze8SNFZ4kKvN7xI0VniQq83vEjRWeJCrze8SNFZ4kKvN7xI0VniQq83vEjRWeJCr' - }, - { - raw: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01', - text: '1AACASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8B' - } - ] - }, - { - code: '1AAD', - length: 80, - samples: [ - { - raw: 'a1b2c3d4e5f67890123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef012', - text: '1AADobLD1OX2eJASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83vAS' - }, - { - raw: '123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef012', - text: '1AADEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83vAS' - }, - { - raw: 'fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fe', - text: '1AAD_ty6mHZUMhD-3LqYdlQyEP7cuph2VDIQ_ty6mHZUMhD-3LqYdlQyEP7cuph2VDIQ_ty6mHZUMhD-' - }, - { - raw: '9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba98', - text: '1AADmHZUMhD-3LqYdlQyEP7cuph2VDIQ_ty6mHZUMhD-3LqYdlQyEP7cuph2VDIQ_ty6mHZUMhD-3LqY' - }, - { - raw: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01', - text: '1AADASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8B' - } - ] - }, - { - code: '1AAE', - length: 56, - samples: [ - { - raw: 'f123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd', - text: '1AAE8SNFZ4mrze8BI0VniavN7wEjRWeJq83vASNFZ4mrze8BI0VniavN' - }, - { - raw: 'e9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fed', - text: '1AAE6YdlQyEP7cuph2VDIQ_ty6mHZUMhD-3LqYdlQyEP7cuph2VDIQ_t' - }, - { - raw: 'aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00', - text: '1AAEqrvM3e7_ABEiM0RVZneImaq7zN3u_wARIjNEVWZ3iJmqu8zd7v8A' - }, - { - raw: '00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566', - text: '1AAEABEiM0RVZneImaq7zN3u_wARIjNEVWZ3iJmqu8zd7v8AESIzRFVm' - }, - { - raw: 'ffeeddccbbaa99887766554433221100ffeeddccbbaa99887766554433221100ffeeddccbbaa99', - text: '1AAE_-7dzLuqmYh3ZlVEMyIRAP_u3cy7qpmId2ZVRDMiEQD_7t3Mu6qZ' - } - ] - }, - { - code: '1AAF', - length: 8, - samples: [ - { - raw: '464259', - text: '1AAFRkJZ' - }, - { - raw: 'e4feff', - text: '1AAF5P7_' - }, - { - raw: '493bcb', - text: '1AAFSTvL' - }, - { - raw: 'e4482d', - text: '1AAF5Egt' - }, - { - raw: 'e43537', - text: '1AAF5DU3' - } - ] - } - ] -} diff --git a/tsconfig.json b/tsconfig.json index 9b87cb9..6635a6a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,11 +6,12 @@ }, "compilerOptions": { /* Visit https://aka.ms/tsconfig to read more about this file */ - "noEmit": true, // don't emit any files -- we're using ts-node to run the code and swc to transpile it "module": "NodeNext", // the only valid options for a node project are "Node16" and "NodeNext", see inset text at https://www.typescriptlang.org/docs/handbook/modules/theory.html#the-module-output-format "moduleResolution": "NodeNext", "forceConsistentCasingInFileNames": true, "strict": true, // enforce all strict type-checking options "skipLibCheck": true, // don't type-check declarations from other libraries + // "declaration": true, // generate .d.ts files - even though we're using swc to compile, it doesn't generate the t.d.ts files we need + // "outDir": "./dist", // output directory for generated files } } From 9186979d99e3cb090339711831fa732cf82fa28c Mon Sep 17 00:00:00 2001 From: Jonathan Rayback Date: Fri, 29 Mar 2024 17:47:35 -0600 Subject: [PATCH 2/2] delete comments --- tsconfig.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 6635a6a..b0225ad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,5 @@ "forceConsistentCasingInFileNames": true, "strict": true, // enforce all strict type-checking options "skipLibCheck": true, // don't type-check declarations from other libraries - // "declaration": true, // generate .d.ts files - even though we're using swc to compile, it doesn't generate the t.d.ts files we need - // "outDir": "./dist", // output directory for generated files } }