Skip to content

Commit

Permalink
fix(app, database-client): remove headers and add did to cacheClient
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schultz committed Feb 3, 2023
1 parent 6ef25db commit 49fafb8
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions database-client/src/ceramicCacheClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from "axios";
import { Logger } from "./ceramicClient";
import { DataStorageBase } from "./types";
import type { DID as CeramicDID } from "dids";
import {
PROVIDER_ID,
Stamp,
Expand All @@ -14,13 +15,15 @@ export class CeramicCacheDatabase implements DataStorageBase {
ceramicCacheUrl: string;
ceramicCacheApiKey: string;
address: string;
did: string;
logger: Logger;

constructor(ceramicCacheUrl: string, ceramicCacheApiKey: string, address: string, logger?: Logger) {
constructor(ceramicCacheUrl: string, ceramicCacheApiKey: string, address: string, logger?: Logger, did?: CeramicDID) {
this.ceramicCacheUrl = ceramicCacheUrl;
this.ceramicCacheApiKey = ceramicCacheApiKey;
this.address = address;
this.logger = logger;
this.did = (did.hasParent ? did.parent : did.id).toLowerCase();
}

async createPassport(): Promise<string> {
Expand All @@ -34,11 +37,6 @@ export class CeramicCacheDatabase implements DataStorageBase {
try {
const response = await axios.get(
`${this.ceramicCacheUrl}/ceramic-cache/stamp?address=${this.address}`,
{
headers: {
"X-API-Key": this.ceramicCacheApiKey,
},
}
)
const { data } = response;
if (data && data.success === 200) {
Expand Down Expand Up @@ -70,13 +68,6 @@ export class CeramicCacheDatabase implements DataStorageBase {
provider: stamp.provider,
stamp: stamp.credential,
},
{
headers: {
"X-API-Key": this.ceramicCacheApiKey,
accept: "application/json",
'Content-Type': 'application/json',
},
}
)
} catch (e) {
this.logger.error(`Error saving stamp to ceramicCache address: ${this.address}:` + e.toString());
Expand All @@ -86,9 +77,6 @@ export class CeramicCacheDatabase implements DataStorageBase {
this.logger.info(`deleting stamp from ceramicCache for ${provider} on ${this.address}`);
try {
await axios.delete(`${this.ceramicCacheUrl}/ceramic-cache/stamp`, {
headers: {
'Content-Type': 'application/json',
},
data: {
address: this.address,
provider: provider,
Expand Down

0 comments on commit 49fafb8

Please sign in to comment.