forked from trent_larson/crowd-funder-for-time-pwa
fix more logic for tests (cherry-picked from 83acb028c756fc38bbc1e8e604247e704b3974a2)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user