File tree Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -622,6 +622,7 @@ export const handleArgs = (args: string[]) => {
622
622
}
623
623
const authProvider = await processAuth ( argv ) ;
624
624
log ( 'DEBUG' , `Initialized auth provider ${ JSON . stringify ( authProvider ) } ` ) ;
625
+ const guessedPolicyEndpoint = guessPolicyUrl ( argv ) ;
625
626
const client = new OpenTDF ( {
626
627
authProvider,
627
628
defaultCreateOptions : {
@@ -633,7 +634,8 @@ export const handleArgs = (args: string[]) => {
633
634
noVerify : ! ! argv . noVerifyAssertions ,
634
635
} ,
635
636
disableDPoP : ! argv . dpop ,
636
- policyEndpoint : guessPolicyUrl ( argv ) ,
637
+ policyEndpoint : guessedPolicyEndpoint ,
638
+ platformUrl : guessedPolicyEndpoint ,
637
639
} ) ;
638
640
try {
639
641
log ( 'SILLY' , `Initialized client` ) ;
Original file line number Diff line number Diff line change @@ -190,17 +190,23 @@ export async function fetchKeyAccessServers(
190
190
} catch ( e ) {
191
191
throw new NetworkError ( `unable to fetch kas list from [${ req . url } ]` , e ) ;
192
192
}
193
- if ( response . ok ) {
194
- const { keyAccessServers = [ ] , pagination = { } } = await response . json ( ) ;
195
- allServers . push ( ...keyAccessServers ) ;
196
- nextOffset = pagination . nextOffset || 0 ;
193
+ // if we get an error from the kas registry, throw an error
194
+ if ( ! response . ok ) {
195
+ throw new ServiceError (
196
+ `unable to fetch kas list from [${ req . url } ], status: ${ response . status } `
197
+ ) ;
197
198
}
199
+ const { keyAccessServers = [ ] , pagination = { } } = await response . json ( ) ;
200
+ allServers . push ( ...keyAccessServers ) ;
201
+ nextOffset = pagination . nextOffset || 0 ;
198
202
} while ( nextOffset > 0 ) ;
199
203
200
- if ( ! allServers . length ) {
201
- throw new ConfigurationError ( 'There are no available KAS' ) ;
202
- }
203
204
const serverUrls = allServers . map ( ( server ) => server . uri ) ;
205
+ // add base platform kas
206
+ if ( ! serverUrls . includes ( `${ platformUrl } /kas` ) ) {
207
+ serverUrls . push ( `${ platformUrl } /kas` ) ;
208
+ }
209
+
204
210
return new OriginAllowList ( serverUrls , false ) ;
205
211
}
206
212
Original file line number Diff line number Diff line change @@ -497,7 +497,7 @@ class NanoTDFReader {
497
497
) {
498
498
if (
499
499
! this . opts . ignoreAllowlist &&
500
- ! this . outer . platformUrl &&
500
+ ! this . opts . platformUrl &&
501
501
! this . opts . allowedKASEndpoints ?. length
502
502
) {
503
503
throw new ConfigurationError ( 'platformUrl is required when allowedKasEndpoints is empty' ) ;
@@ -529,7 +529,7 @@ class NanoTDFReader {
529
529
dpopEnabled : this . outer . dpopEnabled ,
530
530
dpopKeys : this . outer . dpopKeys ,
531
531
kasEndpoint : this . opts . allowedKASEndpoints ?. [ 0 ] || 'https://disallow.all.invalid' ,
532
- platformUrl : this . outer . platformUrl ,
532
+ platformUrl : this . opts . platformUrl || this . outer . platformUrl ,
533
533
} ) ;
534
534
// TODO: The version number should be fetched from the API
535
535
const version = '0.0.1' ;
You can’t perform that action at this time.
0 commit comments