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/components/UserNameDialog.vue b/src/components/UserNameDialog.vue index af504930..160ae402 100644 --- a/src/components/UserNameDialog.vue +++ b/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, diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index ff56017d..c65983b7 100644 --- a/src/libs/endorserServer.ts +++ b/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 { 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; } diff --git a/src/services/AbsurdSqlDatabaseService.ts b/src/services/AbsurdSqlDatabaseService.ts index 878dbea5..004e6c0b 100644 --- a/src/services/AbsurdSqlDatabaseService.ts +++ b/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(); 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(