diff --git a/lib/src/index.ts b/lib/src/index.ts index ac127f63..f1eb7980 100644 --- a/lib/src/index.ts +++ b/lib/src/index.ts @@ -9,7 +9,9 @@ import { DefaultParams, } from './nanotdf/index.js'; import { keyAgreement } from './nanotdf-crypto/index.js'; -import { TypedArray, createAttribute, Policy } from './tdf/index.js'; +import { Policy } from './tdf/Policy.js'; +import { type TypedArray } from './tdf/TypedArray.js'; +import { createAttribute } from './tdf/AttributeObject.js'; import { fetchECKasPubKey } from './access.js'; import { ClientConfig } from './nanotdf/Client.js'; import { ConfigurationError } from './errors.js'; diff --git a/lib/src/nanotdf-crypto/digest.ts b/lib/src/nanotdf-crypto/digest.ts index c40ed6c3..fa687281 100644 --- a/lib/src/nanotdf-crypto/digest.ts +++ b/lib/src/nanotdf-crypto/digest.ts @@ -1,4 +1,4 @@ -import { TypedArray } from '../tdf/index.js'; +import { TypedArray } from '../tdf/TypedArray.js'; export default function digest( hashType: AlgorithmIdentifier, diff --git a/lib/src/nanotdf/Client.ts b/lib/src/nanotdf/Client.ts index a42696b8..bb7e9510 100644 --- a/lib/src/nanotdf/Client.ts +++ b/lib/src/nanotdf/Client.ts @@ -1,4 +1,4 @@ -import { type TypedArray } from '../tdf/index.js'; +import { type TypedArray } from '../tdf/TypedArray.js'; import * as base64 from '../encodings/base64.js'; import { generateKeyPair, keyAgreement } from '../nanotdf-crypto/index.js'; import getHkdfSalt from './helpers/getHkdfSalt.js'; diff --git a/lib/src/nanotdf/NanoTDF.ts b/lib/src/nanotdf/NanoTDF.ts index 4a926c7e..5b4f77b4 100644 --- a/lib/src/nanotdf/NanoTDF.ts +++ b/lib/src/nanotdf/NanoTDF.ts @@ -1,4 +1,4 @@ -import { TypedArray } from '../tdf/index.js'; +import { TypedArray } from '../tdf/TypedArray.js'; import { base64 } from '../encodings/index.js'; import Header from './models/Header.js'; import Payload from './models/Payload.js'; diff --git a/lib/src/nanotdf/encrypt-dataset.ts b/lib/src/nanotdf/encrypt-dataset.ts index 31ab5a7b..160a74e9 100644 --- a/lib/src/nanotdf/encrypt-dataset.ts +++ b/lib/src/nanotdf/encrypt-dataset.ts @@ -3,7 +3,7 @@ import Header from './models/Header.js'; import DefaultParams from './models/DefaultParams.js'; import Payload from './models/Payload.js'; import { getBitLength as authTagLengthForCipher } from './models/Ciphers.js'; -import TypedArray from '../tdf/TypedArray.js'; +import { TypedArray } from '../tdf/TypedArray.js'; import encrypt from '../nanotdf-crypto/encrypt.js'; /** diff --git a/lib/src/nanotdf/encrypt.ts b/lib/src/nanotdf/encrypt.ts index 6ad7901f..055606ab 100644 --- a/lib/src/nanotdf/encrypt.ts +++ b/lib/src/nanotdf/encrypt.ts @@ -6,7 +6,7 @@ import EmbeddedPolicy from './models/Policy/EmbeddedPolicy.js'; import Payload from './models/Payload.js'; import getHkdfSalt from './helpers/getHkdfSalt.js'; import { getBitLength as authTagLengthForCipher } from './models/Ciphers.js'; -import { TypedArray } from '../tdf/index.js'; +import { TypedArray } from '../tdf/TypedArray.js'; import { GMAC_BINDING_LEN } from './constants.js'; import { AlgorithmName, KeyFormat, KeyUsageType } from './../nanotdf-crypto/enums.js'; diff --git a/lib/src/nanotdf/helpers/getHkdfSalt.ts b/lib/src/nanotdf/helpers/getHkdfSalt.ts index cd8dbc32..3c4d1cc6 100644 --- a/lib/src/nanotdf/helpers/getHkdfSalt.ts +++ b/lib/src/nanotdf/helpers/getHkdfSalt.ts @@ -1,4 +1,4 @@ -import { TypedArray } from '../../tdf/index.js'; +import { TypedArray } from '../../tdf/TypedArray.js'; import { digest, enums } from '../../nanotdf-crypto/index.js'; diff --git a/lib/src/tdf/Crypto.ts b/lib/src/tdf/Crypto.ts deleted file mode 100644 index fa546a8f..00000000 --- a/lib/src/tdf/Crypto.ts +++ /dev/null @@ -1,42 +0,0 @@ -export enum AlgorithmName { - ECDH = 'ECDH', - ECDSA = 'ECDSA', - ES256 = 'ES256', - HKDF = 'HKDF', - RSA_OAEP = 'RSA-OAEP', - RSA_PSS = 'RSA-PSS', -} - -export enum NamedCurve { - P256 = 'P-256', - P384 = 'P-384', - P512 = 'P-512', -} - -export enum CipherType { - AesGcm = 'AES-GCM', -} - -export enum HashType { - Sha256 = 'SHA-256', -} - -export enum KeyFormat { - Raw = 'raw', - Pkcs8 = 'pkcs8', - Spki = 'spki', -} - -export enum KeyType { - Private = 'private', - Public = 'public', -} - -export enum KeyUsageType { - Encrypt = 'encrypt', - Decrypt = 'decrypt', - Verify = 'verify', - Sign = 'sign', - UnwrapKey = 'unwrapKey', - WrapKey = 'wrapKey', -} diff --git a/lib/src/tdf/Policy.ts b/lib/src/tdf/Policy.ts index 4ff775ea..da0dfd98 100644 --- a/lib/src/tdf/Policy.ts +++ b/lib/src/tdf/Policy.ts @@ -1,7 +1,7 @@ import { type AttributeObject } from './AttributeObject.js'; import { v4 as uuid } from 'uuid'; -export default class Policy { +export class Policy { static CURRENT_VERSION = '1.1.0'; private uuidStr = uuid(); diff --git a/lib/src/tdf/PolicyObject.ts b/lib/src/tdf/PolicyObject.ts index a09abb19..0002c016 100644 --- a/lib/src/tdf/PolicyObject.ts +++ b/lib/src/tdf/PolicyObject.ts @@ -5,7 +5,7 @@ export interface PolicyObjectBody { readonly dissem: string[]; } -export default interface PolicyObject { +export interface PolicyObject { readonly uuid: string; readonly body: PolicyObjectBody; readonly schemaVersion?: string; diff --git a/lib/src/tdf/TypedArray.ts b/lib/src/tdf/TypedArray.ts index eec2ab41..28e78765 100644 --- a/lib/src/tdf/TypedArray.ts +++ b/lib/src/tdf/TypedArray.ts @@ -1,4 +1,4 @@ -type TypedArray = +export type TypedArray = | Int8Array | Uint8Array | Int16Array @@ -8,5 +8,3 @@ type TypedArray = | Uint8ClampedArray | Float32Array | Float64Array; - -export default TypedArray; diff --git a/lib/src/tdf/index.ts b/lib/src/tdf/index.ts deleted file mode 100644 index 02b4f25f..00000000 --- a/lib/src/tdf/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { type AttributeObject, createAttribute } from './AttributeObject.js'; -export { type default as PolicyObject } from './PolicyObject.js'; -export { type default as TypedArray } from './TypedArray.js'; -export { default as Policy } from './Policy.js'; -export * as Crypto from './Crypto.js'; diff --git a/lib/tdf3/src/tdf.ts b/lib/tdf3/src/tdf.ts index 986cafbd..9ad211e0 100644 --- a/lib/tdf3/src/tdf.ts +++ b/lib/tdf3/src/tdf.ts @@ -45,7 +45,7 @@ import { htmlWrapperTemplate } from './templates/index.js'; // TODO: remove dependencies from ciphers so that we can open-source instead of relying on other Virtru libs import { AesGcmCipher } from './ciphers/index.js'; import { type AuthProvider, reqSignature } from '../../src/auth/auth.js'; -import PolicyObject from '../../src/tdf/PolicyObject.js'; +import { PolicyObject } from '../../src/tdf/PolicyObject.js'; import { type CryptoService, type DecryptResult } from './crypto/declarations.js'; import { CentralDirectory } from './utils/zip-reader.js'; import { SymmetricCipher } from './ciphers/symmetric-cipher-base.js'; diff --git a/lib/tests/mocha/unit/builders.spec.ts b/lib/tests/mocha/unit/builders.spec.ts index b74833e1..8c932a0f 100644 --- a/lib/tests/mocha/unit/builders.spec.ts +++ b/lib/tests/mocha/unit/builders.spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { type AttributeObject } from '../../../src/tdf/index.js'; +import { type AttributeObject } from '../../../src/tdf/AttributeObject.js'; import { EncryptParamsBuilder } from '../../../tdf3/src/client/builders.js'; const aex = {