@@ -41,13 +41,13 @@ import { RegistrationRequest } from "./models/record-scanner/registrationRequest
41
41
class RecordScanner implements RecordProvider {
42
42
account ?: Account ;
43
43
readonly url : string ;
44
- private apiKey ?: string ;
44
+ private apiKey ?: { header : string , value : string } ;
45
45
private uuid ?: string ;
46
46
47
- constructor ( url : string , account ?: Account , apiKey ?: string ) {
47
+ constructor ( url : string , account ?: Account , apiKey ?: string | { header : string , value : string } ) {
48
48
this . account = account ;
49
49
this . url = url ;
50
- this . apiKey = apiKey ;
50
+ this . apiKey = typeof apiKey === "string" ? { header : "X-Provable-API-Key" , value : apiKey } : apiKey ;
51
51
}
52
52
53
53
/**
@@ -65,8 +65,8 @@ class RecordScanner implements RecordProvider {
65
65
*
66
66
* @param {string } apiKey The API key to use for the record scanner.
67
67
*/
68
- async setApiKey ( apiKey : string ) : Promise < void > {
69
- this . apiKey = apiKey ;
68
+ async setApiKey ( apiKey : string | { header : string , value : string } ) : Promise < void > {
69
+ this . apiKey = typeof apiKey === "string" ? { header : "X-Provable-API-Key" , value : apiKey } : apiKey ;
70
70
}
71
71
72
72
/**
@@ -299,7 +299,7 @@ class RecordScanner implements RecordProvider {
299
299
private async request ( req : Request ) : Promise < Response > {
300
300
try {
301
301
if ( this . apiKey ) {
302
- req . headers . set ( "X-Provable-API-Key" , this . apiKey ) ;
302
+ req . headers . set ( this . apiKey . header , this . apiKey . value ) ;
303
303
}
304
304
const response = await fetch ( req ) ;
305
305
@@ -313,21 +313,6 @@ class RecordScanner implements RecordProvider {
313
313
throw error ;
314
314
}
315
315
}
316
-
317
- /**
318
- * Helper function to build a query string from the records filter and response filter.
319
- *
320
- * @param {RecordSearchParams } recordsFilter The filter to use to find the records.
321
- * @param {RecordsResponseFilter } responseFilter The filter to use to filter the response.
322
- * @returns {string } The query string.
323
- */
324
- private buildQueryString ( recordsFilter : RecordsFilter , responseFilter : RecordsResponseFilter ) : string {
325
- return Object . entries ( { ...recordsFilter , ...responseFilter } )
326
- . map ( ( [ key , value ] ) => {
327
- return `${ key } =${ Array . isArray ( value ) ? value . join ( "," ) : value } `
328
- } )
329
- . join ( "&" ) ;
330
- }
331
316
}
332
317
333
318
export { RecordScanner } ;
0 commit comments