Skip to content

Commit

Permalink
feat(client): async headers callback (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
genaris authored Aug 1, 2024
1 parent 28f46e4 commit 46e8141
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions packages/client/src/anoncreds/IndyVdrProxyAnonCredsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export class IndyVdrProxyAnonCredsRegistry implements AnonCredsRegistry {

private _headers?: Headers

private get headers(): Record<string, string> | undefined {
private async getHeaders(): Promise<Record<string, string> | undefined> {
if (typeof this._headers === "function") {
return this._headers()
return await this._headers()
}

return this._headers
Expand Down Expand Up @@ -81,7 +81,7 @@ export class IndyVdrProxyAnonCredsRegistry implements AnonCredsRegistry {
`${this.proxyBaseUrl}/schema/${encodeURIComponent(schemaId)}`,
{
method: "GET",
headers: this.headers,
headers: await this.getHeaders(),
}
)
if (!response.ok) {
Expand Down Expand Up @@ -170,7 +170,7 @@ export class IndyVdrProxyAnonCredsRegistry implements AnonCredsRegistry {
`${this.proxyBaseUrl}/credential-definition/${encodeURIComponent(credentialDefinitionId)}`,
{
method: "GET",
headers: this.headers,
headers: await this.getHeaders(),
}
)

Expand Down Expand Up @@ -262,7 +262,7 @@ export class IndyVdrProxyAnonCredsRegistry implements AnonCredsRegistry {
`${this.proxyBaseUrl}/revocation-registry-definition/${encodeURIComponent(revocationRegistryDefinitionId)}`,
{
method: "GET",
headers: this.headers,
headers: await this.getHeaders(),
}
)
if (!response.ok) {
Expand Down Expand Up @@ -334,7 +334,7 @@ export class IndyVdrProxyAnonCredsRegistry implements AnonCredsRegistry {
`${this.proxyBaseUrl}/revocation-status-list/${encodeURIComponent(revocationRegistryId)}/${timestamp}`,
{
method: "GET",
headers: this.headers,
headers: await this.getHeaders(),
}
)
if (!response.ok) {
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/dids/IndyVdrProxyDidResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export class IndyVdrProxyDidResolver implements DidResolver {
private proxyBaseUrl: string
private _headers?: Headers

private get headers(): Record<string, string> | undefined {
private async getHeaders(): Promise<Record<string, string> | undefined> {
if (typeof this._headers === "function") {
return this._headers()
return await Promise.resolve(this._headers())
}

return this._headers
Expand All @@ -31,7 +31,7 @@ export class IndyVdrProxyDidResolver implements DidResolver {
`${this.proxyBaseUrl}/did/${encodeURIComponent(did)}`,
{
method: "GET",
headers: this.headers,
headers: await this.getHeaders(),
}
)
if (!response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Headers = Record<string, string> | (() => Record<string, string>)
export type Headers = Record<string, string> | (() => Record<string, string>) | (() => Promise<Record<string, string>>)

0 comments on commit 46e8141

Please sign in to comment.