Skip to content

Commit 1dbf8e3

Browse files
added optional apiKey field to RecordScanner
1 parent 7c61c28 commit 1dbf8e3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

sdk/src/record-scanner.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ import { RegistrationRequest } from "./models/record-scanner/registrationRequest
4141
class RecordScanner implements RecordProvider {
4242
account?: Account;
4343
readonly url: string;
44+
private apiKey?: string;
4445
private uuid?: string;
4546

46-
constructor(url: string, account?: Account) {
47+
constructor(url: string, account?: Account, apiKey?: string) {
4748
this.account = account;
4849
this.url = url;
50+
this.apiKey = apiKey;
4951
}
5052

5153
/**
@@ -58,6 +60,15 @@ class RecordScanner implements RecordProvider {
5860
this.account = account;
5961
}
6062

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+
6172
/**
6273
* Register the account with the record scanner service.
6374
*
@@ -287,6 +298,9 @@ class RecordScanner implements RecordProvider {
287298
*/
288299
private async request(req: Request): Promise<Response> {
289300
try {
301+
if (this.apiKey) {
302+
req.headers.set("X-Provable-API-Key", this.apiKey);
303+
}
290304
const response = await fetch(req);
291305

292306
if (!response.ok) {

0 commit comments

Comments
 (0)