Browse Source

fix more logic for tests

pull/134/head
Trent Larson 7 days ago
parent
commit
83acb028c7
  1. 2
      src/components/GiftedDialog.vue
  2. 14
      src/components/OfferDialog.vue
  3. 9
      src/components/UserNameDialog.vue
  4. 18
      src/libs/endorserServer.ts
  5. 2
      src/services/AbsurdSqlDatabaseService.ts
  6. 2
      src/views/InviteOneView.vue
  7. 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

9
src/components/UserNameDialog.vue

@ -41,7 +41,6 @@ import { NotificationIface, USE_DEXIE_DB } from "../constants/app";
import { db, retrieveSettingsForActiveAccount } from "../db/index";
import * as databaseUtil from "../db/databaseUtil";
import { MASTER_SETTINGS_KEY } from "../db/tables/settings";
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
@Component
export default class UserNameDialog extends Vue {
@ -72,11 +71,9 @@ export default class UserNameDialog extends Vue {
}
async onClickSaveChanges() {
const platformService = PlatformServiceFactory.getInstance();
await platformService.dbExec(
"UPDATE settings SET firstName = ? WHERE key = ?",
[this.givenName, MASTER_SETTINGS_KEY],
);
await databaseUtil.updateDefaultSettings({
firstName: this.givenName,
});
if (USE_DEXIE_DB) {
await db.settings.update(MASTER_SETTINGS_KEY, {
firstName: this.givenName,

18
src/libs/endorserServer.ts

@ -1316,17 +1316,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 };
}
@ -1341,7 +1353,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/services/AbsurdSqlDatabaseService.ts

@ -84,7 +84,7 @@ class AbsurdSqlDatabaseService implements DatabaseService {
SQL.FS.mkdir("/sql");
SQL.FS.mount(sqlFS, {}, "/sql");
const path = "/sql/timesafari.sqlite";
const path = "/sql/timesafari.absurd-sql";
if (typeof SharedArrayBuffer === "undefined") {
const stream = SQL.FS.open(path, "a+");
await stream.node.contents.readIfFallback();

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