Browse Source

fix more logic for tests (cherry-picked from 83acb028c7)

master
Trent Larson 1 week ago
parent
commit
be27ca1855
  1. 2
      src/components/GiftedDialog.vue
  2. 14
      src/components/OfferDialog.vue
  3. 18
      src/libs/endorserServer.ts
  4. 2
      src/views/InviteOneView.vue
  5. 2
      src/views/OfferDetailsView.vue

2
src/components/GiftedDialog.vue

@ -320,7 +320,7 @@ export default class GiftedDialog extends Vue {
this.fromProjectId,
);
if (!result.success || result.error) {
if (!result.success) {
const errorMessage = this.getGiveCreationErrorMessage(result);
logger.error("Error with give creation result:", result);
this.$notify(

14
src/components/OfferDialog.vue

@ -249,10 +249,7 @@ export default class OfferDialog extends Vue {
this.projectId,
);
if (
result.type === "error" ||
this.isOfferCreationError(result.response)
) {
if (!result.success) {
const errorMessage = this.getOfferCreationErrorMessage(result);
logger.error("Error with offer creation result:", result);
this.$notify(
@ -296,15 +293,6 @@ export default class OfferDialog extends Vue {
// Helper functions for readability
/**
* @param result response "data" from the server
* @returns true if the result indicates an error
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
isOfferCreationError(result: any) {
return result.status !== 201 || result.data?.error;
}
/**
* @param result direct response eg. ErrorResult or SuccessResult (potentially with embedded "data")
* @returns best guess at an error message

18
src/libs/endorserServer.ts

@ -1315,17 +1315,29 @@ export async function createEndorserJwtVcFromClaim(
return createEndorserJwtForDid(issuerDid, vcPayload);
}
/**
* Create a JWT for a RegisterAction claim.
*
* @param activeDid - The DID of the user creating the invite
* @param contact - The contact to register, with a 'did' field (all optional for invites)
* @param identifier - The identifier for the invite, usually random
* @param expiresIn - The number of seconds until the invite expires
* @returns The JWT for the RegisterAction claim
*/
export async function createInviteJwt(
activeDid: string,
contact: Contact,
contact?: Contact,
identifier?: string,
expiresIn?: number, // in seconds
): Promise<string> {
const vcClaim: RegisterVerifiableCredential = {
"@context": SCHEMA_ORG_CONTEXT,
"@type": "RegisterAction",
agent: { identifier: activeDid },
object: SERVICE_ID,
identifier: identifier,
};
if (contact) {
if (contact?.did) {
vcClaim.participant = { identifier: contact.did };
}
@ -1340,7 +1352,7 @@ export async function createInviteJwt(
};
// Create a signature using private key of identity
const vcJwt = await createEndorserJwtForDid(activeDid, vcPayload);
const vcJwt = await createEndorserJwtForDid(activeDid, vcPayload, expiresIn);
return vcJwt;
}

2
src/views/InviteOneView.vue

@ -324,7 +324,7 @@ export default class InviteOneView extends Vue {
);
await axios.post(
this.apiServer + "/api/userUtil/invite",
{ inviteJwt: inviteJwt, notes: notes },
{ inviteIdentifier, inviteJwt, notes, expiresAt },
{ headers },
);
const newInvite = {

2
src/views/OfferDetailsView.vue

@ -703,7 +703,7 @@ export default class OfferDetailsView extends Vue {
);
}
if (result.type === "error" || this.isCreationError(result.response)) {
if (!result.success) {
const errorMessage = this.getCreationErrorMessage(result);
logger.error("Error with offer creation result:", result);
this.$notify(

Loading…
Cancel
Save