Skip to content

Commit

Permalink
fix(database-client): add token headers to passport client
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schultz committed Feb 3, 2023
1 parent 6f231b4 commit 96f88ec
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions database-client/src/passportScorerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@ import {

export class PassportDatabase implements DataStorageBase {
passportScorerUrl: string;
passportScorerApiKey: string;
address: string;
token: string;
did: string;
logger: Logger;
allowEmpty: boolean;


constructor(
passportScorerUrl: string,
passportScorerApiKey: string,
address: string,
token: string,
logger?: Logger,
did?: CeramicDID
did?: CeramicDID,
) {
this.passportScorerUrl = passportScorerUrl;
this.passportScorerApiKey = passportScorerApiKey;
this.address = address;
this.logger = logger;
this.did = (did.hasParent ? did.parent : did.id).toLowerCase();
this.allowEmpty = false;
this.token = token;
}

async createPassport(initialStamps?: Stamp[]): Promise<string> {
Expand Down Expand Up @@ -85,7 +86,10 @@ export class PassportDatabase implements DataStorageBase {
address: this.address,
provider: stamp.provider,
stamp: stamp.credential,
});
}, {
headers:
{ Authorization: `Bearer ${this.token}`},
});
} catch (e) {
this.logger.error(`Error saving stamp to passportScorer address: ${this.address}:` + e.toString());
}
Expand All @@ -99,6 +103,7 @@ export class PassportDatabase implements DataStorageBase {
address: this.address,
provider: provider,
},
headers: { Authorization: `Bearer ${this.token}` },
});
} catch (e) {
this.logger.error(`Error deleting stamp from passportScorer for ${provider} on ${this.address}: ` + e.toString());
Expand Down

0 comments on commit 96f88ec

Please sign in to comment.