add page for one-on-one invites (incomplete)

This commit is contained in:
2024-10-05 18:35:59 -06:00
parent 9f4a19993e
commit 1bfdcab90b
9 changed files with 390 additions and 32 deletions

View File

@@ -239,8 +239,9 @@ export interface RegisterVerifiableCredential {
"@context": string;
"@type": string;
agent: { identifier: string };
identifier?: string;
object: string;
participant: { identifier: string };
participant?: { identifier: string };
}
// now for some of the error & other wrapper types
@@ -993,9 +994,10 @@ export async function generateEndorserJwtForAccount(
export async function createEndorserJwtForDid(
issuerDid: string,
payload: object,
expiresIn?: number,
) {
const account = await getAccount(issuerDid);
return createEndorserJwtForKey(account as KeyMeta, payload);
return createEndorserJwtForKey(account as KeyMeta, payload, expiresIn);
}
/**
@@ -1225,19 +1227,24 @@ export async function createEndorserJwtVcFromClaim(
return createEndorserJwtForDid(issuerDid, vcPayload);
}
export async function register(
export async function createInviteJwt(
activeDid: string,
apiServer: string,
axios: Axios,
contact: Contact,
) {
contact?: Contact,
inviteId?: string,
expiresIn?: number,
): Promise<string> {
const vcClaim: RegisterVerifiableCredential = {
"@context": SCHEMA_ORG_CONTEXT,
"@type": "RegisterAction",
agent: { identifier: activeDid },
object: SERVICE_ID,
participant: { identifier: contact.did },
};
if (contact) {
vcClaim.participant = { identifier: contact.did };
}
if (inviteId) {
vcClaim.identifier = inviteId;
}
// Make a payload for the claim
const vcPayload = {
vc: {
@@ -1247,7 +1254,17 @@ export async function register(
},
};
// Create a signature using private key of identity
const vcJwt = await createEndorserJwtForDid(activeDid, vcPayload);
const vcJwt = await createEndorserJwtForDid(activeDid, vcPayload, expiresIn);
return vcJwt;
}
export async function register(
activeDid: string,
apiServer: string,
axios: Axios,
contact: Contact,
): Promise<{ success?: boolean; error?: string }> {
const vcJwt = await createInviteJwt(activeDid, contact);
const url = apiServer + "/api/v2/claim";
const resp = await axios.post(url, { jwtEncoded: vcJwt });