diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 04856244..754c9bf6 100644 --- a/src/components/GiftedDialog.vue +++ b/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( diff --git a/src/components/OfferDialog.vue b/src/components/OfferDialog.vue index a66dd0f1..659488f1 100644 --- a/src/components/OfferDialog.vue +++ b/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 diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index a6c3c9cd..40d38c6d 100644 --- a/src/libs/endorserServer.ts +++ b/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 { 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; } diff --git a/src/views/InviteOneView.vue b/src/views/InviteOneView.vue index 18d66a3d..0ae150c1 100644 --- a/src/views/InviteOneView.vue +++ b/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 = { diff --git a/src/views/OfferDetailsView.vue b/src/views/OfferDetailsView.vue index f5ef82cc..cfd7cc73 100644 --- a/src/views/OfferDetailsView.vue +++ b/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(