forked from jsnbuchanan/crowd-funder-for-time-pwa
change accessToken to take a DID
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
Axios,
|
||||
AxiosRequestConfig,
|
||||
AxiosResponse,
|
||||
} from "axios";
|
||||
import { Axios, AxiosRequestConfig, AxiosResponse } from "axios";
|
||||
import * as didJwt from "did-jwt";
|
||||
import { LRUCache } from "lru-cache";
|
||||
import * as R from "ramda";
|
||||
@@ -458,7 +454,7 @@ export async function getHeaders(did?: string) {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
if (did) {
|
||||
const token = await accessToken(undefined, did);
|
||||
const token = await accessToken(did);
|
||||
headers["Authorization"] = "Bearer " + token;
|
||||
} else {
|
||||
// it's often OK to request without auth; we assume necessary checks are done earlier
|
||||
@@ -716,7 +712,7 @@ export async function createAndSubmitClaim(
|
||||
// Make the xhr request payload
|
||||
const payload = JSON.stringify({ jwtEncoded: vcJwt });
|
||||
const url = `${apiServer}/api/v2/claim`;
|
||||
const token = await accessToken(identity);
|
||||
const token = await accessToken(identity.did);
|
||||
|
||||
const response = await axios.post(url, payload, {
|
||||
headers: {
|
||||
@@ -948,7 +944,7 @@ export const bvcMeetingJoinClaim = (did: string, startTime: string) => {
|
||||
|
||||
export async function createEndorserJwt(did: string, payload: object) {
|
||||
const account = await getAccount(did);
|
||||
if (account.identity) {
|
||||
if (account?.identity) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const identity = JSON.parse(account.identity!);
|
||||
const privateKeyHex = identity.keys[0].privateKeyHex;
|
||||
@@ -957,7 +953,7 @@ export async function createEndorserJwt(did: string, payload: object) {
|
||||
issuer: did,
|
||||
signer: signer,
|
||||
});
|
||||
} else if (account.passkeyCredIdHex) {
|
||||
} else if (account?.passkeyCredIdHex) {
|
||||
return createDidPeerJwt(did, account.passkeyCredIdHex, payload);
|
||||
} else {
|
||||
throw new Error("No identity data found to sign for DID " + did);
|
||||
|
||||
Reference in New Issue
Block a user