1
1
import { type AuthProvider } from './auth/providers.js' ;
2
2
import { ConfigurationError , InvalidFileError } from './errors.js' ;
3
- import { NanoTDFDatasetClient } from './nanoclients.js' ;
3
+ import { type EncryptOptions as NanoEncryptOptions , NanoTDFDatasetClient } from './nanoclients.js' ;
4
4
export { Client as TDF3Client } from '../tdf3/src/client/index.js' ;
5
5
import NanoTDF from './nanotdf/NanoTDF.js' ;
6
6
import decryptNanoTDF from './nanotdf/decrypt.js' ;
7
7
import Client from './nanotdf/Client.js' ;
8
8
import Header from './nanotdf/models/Header.js' ;
9
9
import { fromSource , sourceToStream , type Source } from './seekable.js' ;
10
10
import { Client as TDF3Client } from '../tdf3/src/client/index.js' ;
11
- import { AssertionConfig , AssertionVerificationKeys } from '../tdf3/src/assertions.js' ;
11
+ import {
12
+ type Assertion ,
13
+ AssertionConfig ,
14
+ AssertionVerificationKeys ,
15
+ } from '../tdf3/src/assertions.js' ;
12
16
import { type KasPublicKeyAlgorithm , OriginAllowList , isPublicKeyAlgorithm } from './access.js' ;
13
17
import { type Manifest } from '../tdf3/src/models/manifest.js' ;
14
-
15
- export { type KasPublicKeyAlgorithm , isPublicKeyAlgorithm } ;
18
+ import { type Payload } from '../tdf3/src/models/payload.js' ;
19
+ import {
20
+ type Segment ,
21
+ type SplitType ,
22
+ type EncryptionInformation ,
23
+ } from '../tdf3/src/models/encryption-information.js' ;
24
+ import { type KeyAccessObject } from '../tdf3/src/models/key-access.js' ;
25
+ import { type IntegrityAlgorithm } from '../tdf3/src/tdf.js' ;
26
+
27
+ export {
28
+ type Assertion ,
29
+ type EncryptionInformation ,
30
+ type IntegrityAlgorithm ,
31
+ type KasPublicKeyAlgorithm ,
32
+ type KeyAccessObject ,
33
+ type Manifest ,
34
+ type Payload ,
35
+ type Segment ,
36
+ type SplitType ,
37
+ isPublicKeyAlgorithm ,
38
+ } ;
16
39
17
40
export type Keys = {
18
41
[ keyID : string ] : CryptoKey | CryptoKeyPair ;
@@ -399,6 +422,7 @@ export type NanoTDFCollection = {
399
422
400
423
class Collection {
401
424
client ?: NanoTDFDatasetClient ;
425
+ encryptOptions ?: NanoEncryptOptions ;
402
426
403
427
constructor ( authProvider : AuthProvider , opts : CreateNanoTDFCollectionOptions ) {
404
428
if ( opts . signers || opts . signingKeyID ) {
@@ -410,6 +434,14 @@ class Collection {
410
434
if ( opts . ecdsaBindingKeyID ) {
411
435
throw new ConfigurationError ( 'custom binding key not implemented' ) ;
412
436
}
437
+ switch ( opts . bindingType ) {
438
+ case 'ecdsa' :
439
+ this . encryptOptions = { ecdsaBinding : true } ;
440
+ break ;
441
+ case 'gmac' :
442
+ this . encryptOptions = { ecdsaBinding : false } ;
443
+ break ;
444
+ }
413
445
414
446
this . client = new NanoTDFDatasetClient ( {
415
447
authProvider,
@@ -423,7 +455,7 @@ class Collection {
423
455
throw new ConfigurationError ( 'Collection is closed' ) ;
424
456
}
425
457
const chunker = await fromSource ( source ) ;
426
- const cipherChunk = await this . client . encrypt ( await chunker ( ) ) ;
458
+ const cipherChunk = await this . client . encrypt ( await chunker ( ) , this . encryptOptions ) ;
427
459
const stream : DecoratedStream = new ReadableStream < Uint8Array > ( {
428
460
start ( controller ) {
429
461
controller . enqueue ( new Uint8Array ( cipherChunk ) ) ;
0 commit comments