File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -41,11 +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
45
private uuid ?: string ;
45
46
46
- constructor ( url : string , account ?: Account ) {
47
+ constructor ( url : string , account ?: Account , apiKey ?: string ) {
47
48
this . account = account ;
48
49
this . url = url ;
50
+ this . apiKey = apiKey ;
49
51
}
50
52
51
53
/**
@@ -58,6 +60,15 @@ class RecordScanner implements RecordProvider {
58
60
this . account = account ;
59
61
}
60
62
63
+ /**
64
+ * Set the API key to use for the record scanner.
65
+ *
66
+ * @param {string } apiKey The API key to use for the record scanner.
67
+ */
68
+ async setApiKey ( apiKey : string ) : Promise < void > {
69
+ this . apiKey = apiKey ;
70
+ }
71
+
61
72
/**
62
73
* Register the account with the record scanner service.
63
74
*
@@ -287,6 +298,9 @@ class RecordScanner implements RecordProvider {
287
298
*/
288
299
private async request ( req : Request ) : Promise < Response > {
289
300
try {
301
+ if ( this . apiKey ) {
302
+ req . headers . set ( "X-Provable-API-Key" , this . apiKey ) ;
303
+ }
290
304
const response = await fetch ( req ) ;
291
305
292
306
if ( ! response . ok ) {
You can’t perform that action at this time.
0 commit comments