Browse Source

add more type casts

playwright-pwa-install-test
Trent Larson 4 months ago
parent
commit
c0df24fe01
  1. 4
      src/libs/endorserServer.ts
  2. 2
      src/views/AccountViewView.vue
  3. 3
      src/views/ClaimAddRawView.vue
  4. 3
      src/views/ConfirmGiftView.vue
  5. 3
      src/views/ContactAmountsView.vue
  6. 5
      src/views/DIDView.vue
  7. 3
      src/views/DiscoverView.vue
  8. 44
      src/views/GiftedDetails.vue
  9. 3
      src/views/IdentitySwitcherView.vue
  10. 5
      src/views/ImportAccountView.vue
  11. 12
      src/views/ImportDerivedAccountView.vue
  12. 6
      src/views/NewEditAccountView.vue
  13. 5
      src/views/NewEditProjectView.vue
  14. 4
      src/views/NewIdentifierView.vue
  15. 17
      src/views/ProjectViewView.vue
  16. 7
      src/views/ProjectsView.vue
  17. 8
      src/views/QuickActionBvcEndView.vue
  18. 3
      src/views/SearchAreaView.vue
  19. 15
      src/views/SharedPhotoView.vue
  20. 9
      src/views/StartView.vue
  21. 3
      src/views/TestView.vue

4
src/libs/endorserServer.ts

@ -56,12 +56,12 @@ export interface GenericVerifiableCredential {
export interface GenericCredWrapper<T extends GenericVerifiableCredential> {
"@context": string;
"@type": string;
claim: T;
claimType?: string;
handleId: string;
id: string;
issuedAt: string;
issuer: string;
claim: T;
claimType?: string;
}
export const BLANK_GENERIC_SERVER_RECORD: GenericCredWrapper<GenericVerifiableCredential> =
{

2
src/views/AccountViewView.vue

@ -1092,7 +1092,7 @@ export default class AccountViewView extends Vue {
}
async uploadImportFile(event: Event) {
inputImportFileNameRef.value = event.target.files[0];
inputImportFileNameRef.value = (event.target as EventTarget).files[0];
}
showContactImport() {

3
src/views/ClaimAddRawView.vue

@ -30,6 +30,7 @@
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import GiftedDialog from "@/components/GiftedDialog.vue";
import { NotificationIface } from "@/constants/app";
@ -55,7 +56,7 @@ export default class ClaimAddRawView extends Vue {
this.activeDid = settings?.activeDid || "";
this.apiServer = settings?.apiServer || "";
this.claimStr = this.$route.query.claim;
this.claimStr = (this.$route as Router).query["claim"];
try {
this.veriClaim = JSON.parse(this.claimStr);
this.claimStr = JSON.stringify(this.veriClaim, null, 2);

3
src/views/ConfirmGiftView.vue

@ -398,6 +398,7 @@ import * as yaml from "js-yaml";
import * as R from "ramda";
import { Component, Vue } from "vue-facing-decorator";
import { useClipboard } from "@vueuse/core";
import { Router } from "vue-router";
import GiftedDialog from "@/components/GiftedDialog.vue";
import QuickNav from "@/components/QuickNav.vue";
@ -764,7 +765,7 @@ export default class ClaimView extends Vue {
const route = {
path: "/claim/" + encodeURIComponent(claimId),
};
this.$router.push(route).then(async () => {
(this.$router as Router).push(route).then(async () => {
this.resetThisValues();
await this.loadClaim(claimId, this.activeDid);
});

3
src/views/ContactAmountsView.vue

@ -108,6 +108,7 @@
import { AxiosError, AxiosRequestHeaders } from "axios";
import * as R from "ramda";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import QuickNav from "@/components/QuickNav.vue";
import { NotificationIface } from "@/constants/app";
@ -144,7 +145,7 @@ export default class ContactAmountssView extends Vue {
async created() {
try {
await db.open();
const contactDid = this.$route.query.contactDid as string;
const contactDid = (this.$route as Router).query["contactDid"] as string;
this.contact = (await db.contacts.get(contactDid)) || null;
const settings = await db.settings.get(MASTER_SETTINGS_KEY);

5
src/views/DIDView.vue

@ -128,6 +128,7 @@
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import QuickNav from "@/components/QuickNav.vue";
import InfiniteScroll from "@/components/InfiniteScroll.vue";
@ -162,7 +163,7 @@ export default class DIDView extends Vue {
activeDid = "";
allMyDids: Array<string> = [];
apiServer = "";
claims: Array<GenericCredWrapper> = [];
claims: Array<GenericCredWrapper<GenericVerifiableCredential>> = [];
contact?: Contact;
hitEnd = false;
isLoading = false;
@ -275,7 +276,7 @@ export default class DIDView extends Vue {
const route = {
path: "/claim/" + encodeURIComponent(jwtId),
};
this.$router.push(route);
(this.$router as Router).push(route);
}
public claimAmount(claim: GenericVerifiableCredential) {

3
src/views/DiscoverView.vue

@ -129,6 +129,7 @@
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import QuickNav from "@/components/QuickNav.vue";
import InfiniteScroll from "@/components/InfiniteScroll.vue";
@ -394,7 +395,7 @@ export default class DiscoverView extends Vue {
const route = {
path: "/project/" + encodeURIComponent(id),
};
this.$router.push(route);
(this.$router as Router).push(route);
}
public computedLocalTabStyleClassNames() {

44
src/views/GiftedDetails.vue

@ -250,20 +250,24 @@ export default class GiftedDetails extends Vue {
}
this.amountInput =
this.$route.query.amountInput ||
(this.$route as Router).query["amountInput"] ||
String(this.prevCredToEdit?.claim?.object?.amountOfThisGood) ||
this.amountInput;
this.description =
this.$route.query.description ||
(this.$route as Router).query["description"] ||
this.prevCredToEdit?.claim?.description ||
this.description;
this.destinationPathAfter = this.$route.query.destinationPathAfter;
this.giverDid = (this.$route.query.giverDid ||
this.destinationPathAfter = (this.$route as Router).query[
"destinationPathAfter"
];
this.giverDid = ((this.$route as Router).query["giverDid"] ||
this.prevCredToEdit?.claim?.agent?.identifier ||
this.giverDid) as string;
this.giverName = (this.$route.query.giverName as string) || "";
this.hideBackButton = this.$route.query.hideBackButton === "true";
this.message = (this.$route.query.message as string) || "";
this.giverName =
((this.$route as Router).query["giverName"] as string) || "";
this.hideBackButton =
(this.$route as Router).query["hideBackButton"] === "true";
this.message = ((this.$route as Router).query["message"] as string) || "";
// find any offer ID
const fulfills = this.prevCredToEdit?.claim?.fulfills;
const fulfillsArray = Array.isArray(fulfills)
@ -272,43 +276,44 @@ export default class GiftedDetails extends Vue {
? [fulfills]
: [];
const offer = fulfillsArray.find((rec) => rec.claimType === "Offer");
this.offerId = (this.$route.query.offerId ||
this.offerId = ((this.$route as Router).query["offerId"] ||
offer?.identifier ||
this.offerId) as string;
// find any project ID
const project = fulfillsArray.find((rec) => rec.claimType === "PlanAction");
this.projectId = (this.$route.query.projectId ||
this.projectId = ((this.$route as Router).query["projectId"] ||
project?.identifier ||
this.projectId) as string;
this.recipientDid = (this.$route.query.recipientDid ||
this.recipientDid = ((this.$route as Router).query["recipientDid"] ||
this.prevCredToEdit?.claim?.recipient?.identifier) as string;
this.recipientName = (this.$route.query.recipientName as string) || "";
this.unitCode = (this.$route.query.unitCode ||
this.recipientName =
((this.$route as Router).query["recipientName"] as string) || "";
this.unitCode = ((this.$route as Router).query["unitCode"] ||
this.prevCredToEdit?.claim?.object?.unitCode ||
this.unitCode) as string;
this.imageUrl =
(this.$route.query.imageUrl as string) ||
((this.$route as Router).query["imageUrl"] as string) ||
this.prevCredToEdit?.claim?.image ||
localStorage.getItem("imageUrl") ||
this.imageUrl;
// this is an endpoint for sharing project info to highlight something given
// https://developer.mozilla.org/en-US/docs/Web/Manifest/share_target
if (this.$route.query.shareTitle) {
if ((this.$route as Router).query["shareTitle"]) {
this.description =
(this.$route.query.shareTitle as string) +
((this.$route as Router).query["shareTitle"] as string) +
(this.description ? "\n" + this.description : "");
}
if (this.$route.query.shareText) {
if ((this.$route as Router).query["shareText"]) {
this.description =
(this.description ? this.description + "\n" : "") +
(this.$route.query.shareText as string);
((this.$route as Router).query["shareText"] as string);
}
if (this.$route.query.shareUrl) {
this.imageUrl = this.$route.query.shareUrl as string;
if ((this.$route as Router).query["shareUrl"]) {
this.imageUrl = (this.$route as Router).query["shareUrl"] as string;
}
try {
@ -688,6 +693,7 @@ export default class GiftedDetails extends Vue {
constructGiveParam() {
const recipientDid = this.givenToRecipient ? this.recipientDid : undefined;
const projectId = this.givenToProject ? this.projectId : undefined;
// const giveClaim = constructGive(
const giveClaim = hydrateGive(
this.prevCredToEdit?.claim as GiveVerifiableCredential,
this.giverDid,

3
src/views/IdentitySwitcherView.vue

@ -99,6 +99,7 @@
</template>
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import { NotificationIface } from "@/constants/app";
import { db, accountsDB } from "@/db/index";
@ -155,7 +156,7 @@ export default class IdentitySwitcherView extends Vue {
await db.settings.update(MASTER_SETTINGS_KEY, {
activeDid: did,
});
this.$router.push({ name: "account" });
(this.$router as Router).push({ name: "account" });
}
async deleteAccount(id: string) {

5
src/views/ImportAccountView.vue

@ -77,6 +77,7 @@
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import { NotificationIface } from "@/constants/app";
import { accountsDB, db } from "@/db/index";
@ -110,7 +111,7 @@ export default class ImportAccountView extends Vue {
}
public onCancelClick() {
this.$router.back();
(this.$router as Router).back();
}
public async fromMnemonic() {
@ -146,7 +147,7 @@ export default class ImportAccountView extends Vue {
await db.settings.update(MASTER_SETTINGS_KEY, {
activeDid: newId.did,
});
this.$router.push({ name: "account" });
(this.$router as Router).push({ name: "account" });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.error("Error saving mnemonic & updating settings:", err);

12
src/views/ImportDerivedAccountView.vue

@ -70,6 +70,8 @@
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import {
DEFAULT_ROOT_DERIVATION_PATH,
deriveAddress,
@ -100,7 +102,7 @@ export default class ImportAccountView extends Vue {
}
public onCancelClick() {
this.$router.back();
(this.$router as Router).back();
}
public switchAccount(did: string) {
@ -124,9 +126,11 @@ export default class ImportAccountView extends Vue {
}
});
// increment the last number in that max derivation path
const newDerivPath = nextDerivationPath(accountWithMaxDeriv.derivationPath);
const newDerivPath = nextDerivationPath(
accountWithMaxDeriv.derivationPath as string,
);
const mne: string = accountWithMaxDeriv.mnemonic;
const mne: string = accountWithMaxDeriv.mnemonic as string;
const [address, privateHex, publicHex] = deriveAddress(mne, newDerivPath);
@ -147,7 +151,7 @@ export default class ImportAccountView extends Vue {
await db.settings.update(MASTER_SETTINGS_KEY, {
activeDid: newId.did,
});
this.$router.push({ name: "account" });
(this.$router as Router).push({ name: "account" });
} catch (err) {
console.error("Error saving mnemonic & updating settings:", err);
}

6
src/views/NewEditAccountView.vue

@ -45,6 +45,8 @@
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import { db } from "@/db/index";
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings";
@ -68,11 +70,11 @@ export default class NewEditAccountView extends Vue {
firstName: this.givenName,
lastName: "", // deprecated, pre v 0.1.3
});
this.$router.back();
(this.$router as Router).back();
}
onClickCancel() {
this.$router.back();
(this.$router as Router).back();
}
}
</script>

5
src/views/NewEditProjectView.vue

@ -180,6 +180,7 @@ import { AxiosError, AxiosRequestHeaders } from "axios";
import { DateTime } from "luxon";
import { Component, Vue } from "vue-facing-decorator";
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet";
import { Router } from "vue-router";
import ImageMethodDialog from "@/components/ImageMethodDialog.vue";
import QuickNav from "@/components/QuickNav.vue";
@ -423,7 +424,7 @@ export default class NewEditProjectView extends Vue {
useAppStore()
.setProjectId(resp.data.success.handleId)
.then(() => {
this.$router.push({ name: "project" });
(this.$router as Router).push({ name: "project" });
});
} else {
console.error(
@ -521,7 +522,7 @@ export default class NewEditProjectView extends Vue {
}
public onCancelClick() {
this.$router.back();
(this.$router as Router).back();
}
}
</script>

4
src/views/NewIdentifierView.vue

@ -54,6 +54,8 @@
<script lang="ts">
import "dexie-export-import";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import { generateSaveAndActivateIdentity } from "@/libs/util";
import QuickNav from "@/components/QuickNav.vue";
@ -65,7 +67,7 @@ export default class NewIdentifierView extends Vue {
await generateSaveAndActivateIdentity();
this.loading = false;
setTimeout(() => {
this.$router.push({ name: "home" });
(this.$router as Router).push({ name: "home" });
}, 1000);
}
}

17
src/views/ProjectViewView.vue

@ -404,6 +404,7 @@
<script lang="ts">
import { AxiosError } from "axios";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import GiftedDialog from "@/components/GiftedDialog.vue";
import OfferDialog from "@/components/OfferDialog.vue";
@ -423,7 +424,9 @@ import {
getHeaders,
GiverReceiverInputInfo,
GiveSummaryRecord,
GiveVerifiableCredential,
OfferSummaryRecord,
OfferVerifiableCredential,
PlanSummaryRecord,
} from "@/libs/endorserServer";
import * as serverUtil from "@/libs/endorserServer";
@ -496,7 +499,7 @@ export default class ProjectViewView extends Vue {
const route = {
name: "new-edit-project",
};
this.$router.push(route);
(this.$router as Router).push(route);
}
// Isn't there a better way to make this available to the template?
@ -820,7 +823,7 @@ export default class ProjectViewView extends Vue {
const route = {
path: "/project/" + encodeURIComponent(projectId),
};
this.$router.push(route);
(this.$router as Router).push(route);
this.loadProject(projectId, this.activeDid);
}
@ -856,18 +859,18 @@ export default class ProjectViewView extends Vue {
const route = {
name: "contact-gift",
};
this.$router.push(route);
(this.$router as Router).push(route);
}
onClickLoadClaim(jwtId: string) {
const route = {
path: "/claim/" + encodeURIComponent(jwtId),
};
this.$router.push(route);
(this.$router as Router).push(route);
}
checkIsFulfillable(offer: OfferSummaryRecord) {
const offerRecord: GenericCredWrapper = {
const offerRecord: GenericCredWrapper<OfferVerifiableCredential> = {
...BLANK_GENERIC_SERVER_RECORD,
claim: offer.fullClaim,
claimType: "Offer",
@ -877,7 +880,7 @@ export default class ProjectViewView extends Vue {
}
onClickFulfillGiveToOffer(offer: OfferSummaryRecord) {
const offerRecord: GenericCredWrapper = {
const offerRecord: GenericCredWrapper<OfferVerifiableCredential> = {
...BLANK_GENERIC_SERVER_RECORD,
claim: offer.fullClaim,
issuer: offer.offeredByDid,
@ -922,7 +925,7 @@ export default class ProjectViewView extends Vue {
}
checkIsConfirmable(give: GiveSummaryRecord) {
const giveDetails: GenericCredWrapper = {
const giveDetails: GenericCredWrapper<GiveVerifiableCredential> = {
...BLANK_GENERIC_SERVER_RECORD,
claim: give.fullClaim,
claimType: "GiveAction",

7
src/views/ProjectsView.vue

@ -229,6 +229,7 @@
<script lang="ts">
import { AxiosRequestConfig } from "axios";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import { NotificationIface } from "@/constants/app";
import { accountsDB, db } from "@/db/index";
@ -364,7 +365,7 @@ export default class ProjectsView extends Vue {
const route = {
path: "/project/" + encodeURIComponent(id),
};
this.$router.push(route);
(this.$router as Router).push(route);
}
/**
@ -375,14 +376,14 @@ export default class ProjectsView extends Vue {
const route = {
name: "new-edit-project",
};
this.$router.push(route);
(this.$router as Router).push(route);
}
onClickLoadClaim(jwtId: string) {
const route = {
path: "/claim/" + encodeURIComponent(jwtId),
};
this.$router.push(route);
(this.$router as Router).push(route);
}
/**

8
src/views/QuickActionBvcEndView.vue

@ -139,6 +139,7 @@ import axios from "axios";
import { DateTime } from "luxon";
import * as R from "ramda";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import QuickNav from "@/components/QuickNav.vue";
import TopMessage from "@/components/TopMessage.vue";
@ -174,7 +175,7 @@ export default class QuickActionBvcBeginView extends Vue {
apiServer = "";
claimCountByUser = 0;
claimCountWithHidden = 0;
claimsToConfirm: GenericCredWrapper[] = [];
claimsToConfirm: GenericCredWrapper<GenericVerifiableCredential>[] = [];
claimsToConfirmSelected: string[] = [];
description = "breakfast";
loadingConfirms = true;
@ -227,7 +228,8 @@ export default class QuickActionBvcBeginView extends Vue {
}
await response.json().then((data) => {
const dataByOthers = R.reject(
(claim: GenericCredWrapper) => claim.issuer === this.activeDid,
(claim: GenericCredWrapper<GenericVerifiableCredential>) =>
claim.issuer === this.activeDid,
data,
);
const dataByOthersWithoutHidden = R.reject(
@ -258,7 +260,7 @@ export default class QuickActionBvcBeginView extends Vue {
const route = {
path: "/claim/" + encodeURIComponent(jwtId),
};
this.$router.push(route);
(this.$router as Router).push(route);
}
async record() {

3
src/views/SearchAreaView.vue

@ -105,6 +105,7 @@ import {
LRectangle,
LTileLayer,
} from "@vue-leaflet/vue-leaflet";
import { Router } from "vue-router";
import QuickNav from "@/components/QuickNav.vue";
import { NotificationIface } from "@/constants/app";
@ -213,7 +214,7 @@ export default class DiscoverView extends Vue {
},
7000,
);
this.$router.back();
(this.$router as Router).back();
} catch (err) {
this.$notify(
{

15
src/views/SharedPhotoView.vue

@ -55,6 +55,7 @@
<script lang="ts">
import axios from "axios";
import { Component, Vue } from "vue-facing-decorator";
import { RouteLocationRaw, Router } from "vue-router";
import PhotoDialog from "@/components/PhotoDialog.vue";
import QuickNav from "@/components/QuickNav.vue";
@ -92,7 +93,9 @@ export default class SharedPhotoView extends Vue {
// clear the temp image
db.temp.delete("shared-photo");
this.imageFileName = this.$route.query.fileName as string;
this.imageFileName = (this.$route as Router).query[
"fileName"
] as string;
}
} catch (err: unknown) {
console.error("Got an error loading an identifier:", err);
@ -111,15 +114,17 @@ export default class SharedPhotoView extends Vue {
async recordGift() {
await this.sendToImageServer("GiveAction").then((url) => {
if (url) {
this.$router.push({
const route = {
name: "gifted-details",
// this might be wrong since "name" goes with params, but it works so test well when you change it
query: {
destinationPathAfter: "/home",
hideBackButton: true,
imageUrl: url,
recipientDid: this.activeDid,
},
});
} as RouteLocationRaw;
(this.$router as Router).push(route);
}
});
}
@ -130,7 +135,7 @@ export default class SharedPhotoView extends Vue {
await db.settings.update(MASTER_SETTINGS_KEY, {
profileImageUrl: imgUrl,
});
this.$router.push({ name: "account" });
(this.$router as Router).push({ name: "account" });
},
IMAGE_TYPE_PROFILE,
true,
@ -142,7 +147,7 @@ export default class SharedPhotoView extends Vue {
async cancel() {
this.imageBlob = undefined;
this.imageFileName = undefined;
this.$router.push({ name: "home" });
(this.$router as Router).push({ name: "home" });
}
async sendToImageServer(imageType: string) {

9
src/views/StartView.vue

@ -88,6 +88,7 @@
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import { AppString, PASSKEYS_ENABLED } from "@/constants/app";
import { accountsDB, db } from "@/db/index";
@ -113,22 +114,22 @@ export default class StartView extends Vue {
}
public onClickNewSeed() {
this.$router.push({ name: "new-identifier" });
(this.$router as Router).push({ name: "new-identifier" });
}
public async onClickNewPasskey() {
const keyName =
AppString.APP_NAME + (this.givenName ? " - " + this.givenName : "");
await registerSaveAndActivatePasskey(keyName);
this.$router.push({ name: "account" });
(this.$router as Router).push({ name: "account" });
}
public onClickNo() {
this.$router.push({ name: "import-account" });
(this.$router as Router).push({ name: "import-account" });
}
public onClickDerive() {
this.$router.push({ name: "import-derive" });
(this.$router as Router).push({ name: "import-derive" });
}
}
</script>

3
src/views/TestView.vue

@ -242,6 +242,7 @@ import { Buffer } from "buffer/";
import { Base64URLString } from "@simplewebauthn/types";
import { ref } from "vue";
import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import QuickNav from "@/components/QuickNav.vue";
import { AppString, NotificationIface } from "@/constants/app";
@ -349,7 +350,7 @@ export default class Help extends Vue {
this.userName = DEFAULT_USERNAME;
},
onYes: async () => {
this.$router.push({ name: "new-edit-account" });
(this.$router as Router).push({ name: "new-edit-account" });
},
noText: "try again and use " + DEFAULT_USERNAME,
},

Loading…
Cancel
Save