1
1
import axios from "axios" ;
2
2
import { Logger } from "./ceramicClient" ;
3
3
import { DataStorageBase } from "./types" ;
4
+ import type { DID as CeramicDID } from "dids" ;
4
5
import {
5
6
PROVIDER_ID ,
6
7
Stamp ,
@@ -14,13 +15,15 @@ export class CeramicCacheDatabase implements DataStorageBase {
14
15
ceramicCacheUrl : string ;
15
16
ceramicCacheApiKey : string ;
16
17
address : string ;
18
+ did : string ;
17
19
logger : Logger ;
18
20
19
- constructor ( ceramicCacheUrl : string , ceramicCacheApiKey : string , address : string , logger ?: Logger ) {
21
+ constructor ( ceramicCacheUrl : string , ceramicCacheApiKey : string , address : string , logger ?: Logger , did ?: CeramicDID ) {
20
22
this . ceramicCacheUrl = ceramicCacheUrl ;
21
23
this . ceramicCacheApiKey = ceramicCacheApiKey ;
22
24
this . address = address ;
23
25
this . logger = logger ;
26
+ this . did = ( did . hasParent ? did . parent : did . id ) . toLowerCase ( ) ;
24
27
}
25
28
26
29
async createPassport ( ) : Promise < string > {
@@ -34,11 +37,6 @@ export class CeramicCacheDatabase implements DataStorageBase {
34
37
try {
35
38
const response = await axios . get (
36
39
`${ this . ceramicCacheUrl } /ceramic-cache/stamp?address=${ this . address } ` ,
37
- {
38
- headers : {
39
- "X-API-Key" : this . ceramicCacheApiKey ,
40
- } ,
41
- }
42
40
)
43
41
const { data } = response ;
44
42
if ( data && data . success === 200 ) {
@@ -70,13 +68,6 @@ export class CeramicCacheDatabase implements DataStorageBase {
70
68
provider : stamp . provider ,
71
69
stamp : stamp . credential ,
72
70
} ,
73
- {
74
- headers : {
75
- "X-API-Key" : this . ceramicCacheApiKey ,
76
- accept : "application/json" ,
77
- 'Content-Type' : 'application/json' ,
78
- } ,
79
- }
80
71
)
81
72
} catch ( e ) {
82
73
this . logger . error ( `Error saving stamp to ceramicCache address: ${ this . address } :` + e . toString ( ) ) ;
@@ -86,9 +77,6 @@ export class CeramicCacheDatabase implements DataStorageBase {
86
77
this . logger . info ( `deleting stamp from ceramicCache for ${ provider } on ${ this . address } ` ) ;
87
78
try {
88
79
await axios . delete ( `${ this . ceramicCacheUrl } /ceramic-cache/stamp` , {
89
- headers : {
90
- 'Content-Type' : 'application/json' ,
91
- } ,
92
80
data : {
93
81
address : this . address ,
94
82
provider : provider ,
0 commit comments