= {
JWT: 'jwt',
@@ -139,7 +140,9 @@ const CreateCredentialDisplay = () => {
proofFormat: proofFormats[format],
options: {
save,
- store: selectedItems, // TODO: fix this doesn't create new credential
+ store: selectedItems.map((store) =>
+ store.toLowerCase()
+ ) as AvailableCredentialStores[],
},
});
@@ -259,8 +262,14 @@ const CreateCredentialDisplay = () => {
+ capitalizeString(store)
+ )}
+ selectedItems={
+ selectedItems.map((store) =>
+ capitalizeString(store)
+ ) as AvailableCredentialStores[]
+ }
setSelectedItems={setSelectedItems}
placeholder={t('save.select-storage-placeholder')}
name="storage"
diff --git a/packages/dapp/src/components/DashboardDisplay/utils.tsx b/packages/dapp/src/components/DashboardDisplay/utils.tsx
index f69624a5f..04018bf25 100644
--- a/packages/dapp/src/components/DashboardDisplay/utils.tsx
+++ b/packages/dapp/src/components/DashboardDisplay/utils.tsx
@@ -129,15 +129,13 @@ export const filterColumnsType = (
const availableTypes = types
.filter((type) => type.selected)
.map((type) => type.type);
+
const filteredList = credentialList.filter((credential) => {
const { type } = credential.data;
if (!type) return false;
for (const typ of availableTypes) {
- if (
- (typeof type === 'string' && type === typ) ||
- (Array.isArray(type) && type.indexOf(typ) >= 0)
- ) {
+ if ((typeof type === 'string' && type === typ) || Array.isArray(type)) {
return true;
}
}
diff --git a/packages/dapp/src/components/ShareCredentialModal/index.tsx b/packages/dapp/src/components/ShareCredentialModal/index.tsx
index 89eab51bf..071ba5649 100644
--- a/packages/dapp/src/components/ShareCredentialModal/index.tsx
+++ b/packages/dapp/src/components/ShareCredentialModal/index.tsx
@@ -155,8 +155,13 @@ export const ShareCredentialModal = () => {
try {
const result = await shareResponse.json();
- if (!result.presentationId)
- throw new Error('Failed to share presentation');
+ if (!result.presentationId) {
+ throw new Error(
+ result.message === 'Invalid presentation'
+ ? 'Invalid presentation'
+ : 'Failed to share presentation'
+ );
+ }
setShareLink(
`${window.location.origin}/app/share-presentation/${result.presentationId}`
@@ -165,7 +170,10 @@ export const ShareCredentialModal = () => {
setTimeout(() => {
useToastStore.setState({
open: true,
- title: t('share-presentation-error'),
+ title:
+ (e as Error).message === 'Invalid presentation'
+ ? t('share-error-invalid')
+ : t('share-presentation-error'),
type: 'error',
loading: false,
link: null,
@@ -183,6 +191,7 @@ export const ShareCredentialModal = () => {
backdrop="blur"
size="4xl"
isOpen={isOpen}
+ isDismissable={false}
onClose={() => setIsOpen(false)}
hideCloseButton={true}
placement="center"
diff --git a/packages/dapp/src/hooks/useCampaignClaims.ts b/packages/dapp/src/hooks/useCampaignClaims.ts
index b6c1bf183..a01d09741 100644
--- a/packages/dapp/src/hooks/useCampaignClaims.ts
+++ b/packages/dapp/src/hooks/useCampaignClaims.ts
@@ -18,11 +18,12 @@ export type Campaigns = Campaign[];
export const useCampaignClaims = (token: string | null) => {
return useQuery({
queryKey: ['claims'],
+ enabled: !!token,
queryFn: async () => {
const res = await fetch('/api/campaigns/claims', {
headers: {
'Content-Type': 'application/json',
- Authorization: `Bearer ${token}`,
+ ...(token && { Authorization: `Bearer ${token}` }),
},
cache: 'no-store',
});
diff --git a/packages/dapp/src/messages/en.json b/packages/dapp/src/messages/en.json
index b4711b647..d1181c6f6 100644
--- a/packages/dapp/src/messages/en.json
+++ b/packages/dapp/src/messages/en.json
@@ -203,7 +203,8 @@
"rewards": "Rewards"
},
"RequirementDisplay": {
- "verify": "Verify"
+ "verify": "Verify",
+ "requirements-not-met": "You do not meet the requirements"
},
"RewardDisplay": {},
"CredentialCard": {
@@ -365,7 +366,7 @@
"title": "Delete Shared Presentation"
},
"FilterPopover": {
- "clear": "clear",
+ "clear": "Clear",
"datastore": "Data Store",
"ecosystem": "Ecosystem",
"filter": "Filter",
@@ -603,6 +604,7 @@
"placeholder": "Enter a title for the presentation. This can't be changed later.",
"please-sign-in": "Please sign in to share your credentials",
"selected": "Selected Credentials",
+ "share-error-invalid": "One or more credentials in the presentation are invalid.",
"share-presentation-error": "Failed to share presentation",
"share-presentation-success": "Successfully shared presentation",
"share-link-description": "Share your credential:",
diff --git a/packages/snap/CHANGELOG.md b/packages/snap/CHANGELOG.md
index b317fd9db..2b28d9526 100644
--- a/packages/snap/CHANGELOG.md
+++ b/packages/snap/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## 1.2.3-beta.0
+
+### Patch Changes
+
+- [#625](https://github.com/blockchain-lab-um/masca/pull/625) [`f29e494`](https://github.com/blockchain-lab-um/masca/commit/f29e494a8cb6a9de30682a59feb6adee7e15b1e7) Thanks [@martines3000](https://github.com/martines3000)! - Adjust nbf and iat for idtoken signing
+
## 1.2.2
### Patch Changes
diff --git a/packages/snap/package.json b/packages/snap/package.json
index bb8ee4f21..8be066704 100644
--- a/packages/snap/package.json
+++ b/packages/snap/package.json
@@ -1,6 +1,6 @@
{
"name": "@blockchain-lab-um/masca",
- "version": "1.2.2",
+ "version": "1.2.3-beta.0",
"description": "Snap for managing VCs and VPs in MetaMask",
"keywords": [
"MetaMask",
@@ -56,6 +56,7 @@
"dependencies": {
"@0xpolygonid/js-sdk": "1.9.4",
"@blockchain-lab-um/did-provider-key": "1.0.8",
+ "@blockchain-lab-um/extended-verification": "0.1.2",
"@blockchain-lab-um/masca-types": "1.3.2",
"@blockchain-lab-um/oidc-client-plugin": "0.3.1",
"@blockchain-lab-um/oidc-types": "0.0.8",
diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json
index 0c53677f7..17602e4c8 100644
--- a/packages/snap/snap.manifest.json
+++ b/packages/snap/snap.manifest.json
@@ -1,5 +1,5 @@
{
- "version": "1.2.2",
+ "version": "1.2.3-beta.0",
"description": "Snap for managing VCs and VPs in MetaMask",
"proposedName": "Masca",
"repository": {
@@ -26,7 +26,7 @@
"./files/circuits/credentialAtomicQuerySigV2/circuit_final.zkey",
"./files/circuits/credentialAtomicQuerySigV2/verification_key.json"
],
- "shasum": "PH2tAavJ5wTcCLXx2DKWvCORcuv2baPUsVwQulOjm3E="
+ "shasum": "kqzTcg3I/aUg/O0tRt8kBvQHnP6f/GeTJNCJK6q2fDk="
},
"initialPermissions": {
"endowment:ethereum-provider": {},
diff --git a/packages/snap/src/Snap.service.ts b/packages/snap/src/Snap.service.ts
index d313f98dd..59ad4fe48 100644
--- a/packages/snap/src/Snap.service.ts
+++ b/packages/snap/src/Snap.service.ts
@@ -330,7 +330,6 @@ class SnapService {
const res = await VeramoService.verifyData(params);
- if (res.error) throw new Error(res.error.message);
return verbose ? res : res.verified;
}
diff --git a/packages/snap/src/utils/sign.ts b/packages/snap/src/utils/sign.ts
index ca060aec1..5f4f6b37e 100644
--- a/packages/snap/src/utils/sign.ts
+++ b/packages/snap/src/utils/sign.ts
@@ -26,9 +26,9 @@ export const sign = async (signArgs: SignArgs, signOptions: SignOptions) => {
const jwtPayload = {
...signArgs.payload,
- exp: Math.floor(Date.now() / 1000) + 60 * 60,
- iat: Math.floor(Date.now() / 1000),
- nbf: Math.floor(Date.now() / 1000),
+ exp: Math.floor(new Date().getTime() / 1000) + 60 * 60, // 1 hour in the future
+ iat: Math.floor(new Date().getTime() / 1000) - 60, // 1 minute in the past
+ nbf: Math.floor(new Date().getTime() / 1000) - 60, // 1 minute in the past
iss: did,
sub: did,
};
diff --git a/packages/snap/src/veramo/Veramo.service.ts b/packages/snap/src/veramo/Veramo.service.ts
index a72bc3ff9..8b728bff4 100644
--- a/packages/snap/src/veramo/Veramo.service.ts
+++ b/packages/snap/src/veramo/Veramo.service.ts
@@ -1,3 +1,7 @@
+import {
+ type VerificationResult,
+ VerificationService,
+} from '@blockchain-lab-um/extended-verification';
import {
KeyDIDProvider,
getDidKeyResolver as keyDidResolver,
@@ -111,6 +115,7 @@ class VeramoService {
static async init(): Promise {
VeramoService.instance = await VeramoService.createAgent();
+ await VerificationService.init();
}
/**
@@ -516,28 +521,22 @@ class VeramoService {
static async verifyData(
params: VerifyDataRequestParams
): Promise {
- try {
- const { credential, presentation } = params;
+ const { credential, presentation } = params;
- if (credential) {
- const vcResult = await VeramoService.instance.verifyCredential({
- credential,
- });
- return JSON.parse(JSON.stringify(vcResult)) as IVerifyResult;
- }
- if (presentation) {
- const vpResult = await VeramoService.instance.verifyPresentation({
- presentation,
- });
- return JSON.parse(JSON.stringify(vpResult)) as IVerifyResult;
- }
- return {
- verified: false,
- error: new Error('No valid credential or presentation.'),
- } as IVerifyResult;
- } catch (error: unknown) {
- return { verified: false, error: error as Error } as IVerifyResult;
+ let result: Result | undefined = undefined;
+ if (credential) {
+ result = await VerificationService.verify(credential);
+ } else if (presentation) {
+ result = await VerificationService.verify(presentation);
}
+
+ if (!result) throw new Error('No valid credential or presentation.');
+
+ if (isError(result)) {
+ throw new Error(result.error);
+ }
+
+ return result.data as IVerifyResult;
}
static async handleOIDCCredentialOffer(params: {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7e587de60..78786786b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -459,6 +459,9 @@ importers:
'@blockchain-lab-um/did-provider-key':
specifier: 1.0.8
version: link:../../libs/did-provider-key
+ '@blockchain-lab-um/extended-verification':
+ specifier: 0.1.2
+ version: link:../../libs/extended-verification
'@blockchain-lab-um/masca-connector':
specifier: 1.3.2
version: link:../connector
@@ -771,6 +774,9 @@ importers:
'@blockchain-lab-um/did-provider-key':
specifier: 1.0.8
version: link:../../libs/did-provider-key
+ '@blockchain-lab-um/extended-verification':
+ specifier: 0.1.2
+ version: link:../../libs/extended-verification
'@blockchain-lab-um/masca-types':
specifier: 1.3.2
version: link:../types