@@ -31,7 +31,9 @@ type LoggedAuthProvider = AuthProvider & {
31
31
requestLog : HttpRequest [ ] ;
32
32
} ;
33
33
34
- const containerTypes = [ 'tdf3' , 'nano' , 'dataset' ] as const ;
34
+ const bindingTypes = [ 'ecdsa' , 'gmac' ] ;
35
+
36
+ const containerTypes = [ 'tdf3' , 'nano' , 'dataset' , 'ztdf' ] ;
35
37
36
38
const parseJwt = ( jwt : string , field = 1 ) => {
37
39
return JSON . parse ( Buffer . from ( jwt . split ( '.' ) [ field ] , 'base64' ) . toString ( ) ) ;
@@ -219,48 +221,52 @@ export const handleArgs = (args: string[]) => {
219
221
} )
220
222
. implies ( 'exchangeToken' , 'clientId' )
221
223
222
- . option ( 'containerType' , {
223
- group : 'TDF Settings' ,
224
- alias : 't' ,
225
- choices : containerTypes ,
226
- description : 'Container format' ,
227
- default : 'nano' ,
228
- } )
229
-
230
- . option ( 'userId' , {
231
- group : 'TDF Settings' ,
232
- type : 'string' ,
233
- description : 'Owner email address' ,
234
- } )
235
-
236
224
// Examples
237
225
. example ( '$0 --auth ClientID123:Cli3nt$ecret' , '# OIDC client credentials' )
238
226
239
227
. example ( '$0 --clientId ClientID123 --clientSecret Cli3nt$ecret' , '# OIDC client credentials' )
240
228
241
- // POLICY
229
+ // Policy, encryption, and container options
242
230
. options ( {
243
- usersWithAccess : {
244
- alias : 'users-with-access' ,
245
- group : 'Encrypt Options' ,
246
- desc : 'Add users to the policy' ,
247
- type : 'string' ,
248
- default : '' ,
249
- validate : ( users : string ) => users . split ( ',' ) ,
250
- } ,
251
231
attributes : {
252
232
group : 'Encrypt Options' ,
253
233
desc : 'Data attributes for the policy' ,
254
234
type : 'string' ,
255
235
default : '' ,
256
236
validate : ( attributes : string ) => attributes . split ( ',' ) ,
257
237
} ,
238
+ containerType : {
239
+ group : 'Encrypt Options' ,
240
+ alias : 't' ,
241
+ choices : containerTypes ,
242
+ description : 'Container format' ,
243
+ default : 'nano' ,
244
+ } ,
245
+ policyBinding : {
246
+ group : 'Encrypt Options' ,
247
+ choices : bindingTypes ,
248
+ description : 'Policy Binding Type (nano only)' ,
249
+ default : 'gmac' ,
250
+ } ,
258
251
mimeType : {
259
252
group : 'Encrypt Options' ,
260
253
desc : 'Mime type for the plain text file (only supported for ztdf)' ,
261
254
type : 'string' ,
262
255
default : '' ,
263
256
} ,
257
+ userId : {
258
+ group : 'Encrypt Options' ,
259
+ type : 'string' ,
260
+ description : 'Owner email address' ,
261
+ } ,
262
+ usersWithAccess : {
263
+ alias : 'users-with-access' ,
264
+ group : 'Encrypt Options' ,
265
+ desc : 'Add users to the policy' ,
266
+ type : 'string' ,
267
+ default : '' ,
268
+ validate : ( users : string ) => users . split ( ',' ) ,
269
+ } ,
264
270
} )
265
271
266
272
// COMMANDS
@@ -299,7 +305,7 @@ export const handleArgs = (args: string[]) => {
299
305
log ( 'DEBUG' , `Initialized auth provider ${ JSON . stringify ( authProvider ) } ` ) ;
300
306
301
307
const kasEndpoint = argv . kasEndpoint ;
302
- if ( argv . containerType === 'tdf3' ) {
308
+ if ( argv . containerType === 'tdf3' || argv . containerType == 'ztdf' ) {
303
309
log ( 'DEBUG' , `TDF3 Client` ) ;
304
310
const client = new TDF3Client ( {
305
311
allowedKases,
@@ -389,7 +395,7 @@ export const handleArgs = (args: string[]) => {
389
395
const ignoreAllowList = ! ! argv . ignoreAllowList ;
390
396
const allowedKases = argv . allowList ?. split ( ',' ) ;
391
397
392
- if ( 'tdf3' === argv . containerType ) {
398
+ if ( 'tdf3' === argv . containerType || 'ztdf' === argv . containerType ) {
393
399
log ( 'DEBUG' , `TDF3 Client` ) ;
394
400
const client = new TDF3Client ( {
395
401
allowedKases,
@@ -411,6 +417,7 @@ export const handleArgs = (args: string[]) => {
411
417
}
412
418
} else {
413
419
const dpopEnabled = ! ! argv . dpop ;
420
+ const ecdsaBinding = argv . policyBinding . toLowerCase ( ) == 'ecdsa' ;
414
421
const client =
415
422
argv . containerType === 'nano'
416
423
? new NanoTDFClient ( { allowedKases, authProvider, dpopEnabled, kasEndpoint } )
@@ -425,7 +432,7 @@ export const handleArgs = (args: string[]) => {
425
432
addParams ( client , argv ) ;
426
433
427
434
const buffer = await processDataIn ( argv . file as string ) ;
428
- const cyphertext = await client . encrypt ( buffer ) ;
435
+ const cyphertext = await client . encrypt ( buffer , { ecdsaBinding } ) ;
429
436
430
437
log ( 'DEBUG' , `Handle cyphertext output ${ JSON . stringify ( cyphertext ) } ` ) ;
431
438
if ( argv . output ) {
0 commit comments