Skip to content

Commit

Permalink
Change to 2.0 protocols
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas ONeil <[email protected]>
  • Loading branch information
loneil committed Jul 26, 2024
1 parent 982815a commit a722426
Show file tree
Hide file tree
Showing 18 changed files with 673 additions and 371 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
&.accepted,
&.approved,
&.credential-acked,
&.done,
&.issued,
&.verified,
&.checked-in {
Expand Down
28 changes: 15 additions & 13 deletions services/tenant-ui/frontend/src/components/holder/Credentials.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<script setup lang="ts">
// Types
import { V10CredentialExchange } from '@/types/acapyApi/acapyInterface';
import { V20CredExRecordDetail } from '@/types/acapyApi/acapyInterface';
// Vue
import { ref } from 'vue';
Expand All @@ -68,30 +68,32 @@ const holderStore = useHolderStore();
const cardView = ref(false);
// Actions for a cred row/card
const acceptOffer = (event: any, data: V10CredentialExchange) => {
if (data.credential_exchange_id) {
holderStore.acceptCredentialOffer(data.credential_exchange_id).then(() => {
toast.success(`Credential successfully added to your wallet`);
});
const acceptOffer = (event: any, data: V20CredExRecordDetail) => {
if (data.cred_ex_record?.cred_ex_id) {
holderStore
.acceptCredentialOffer(data.cred_ex_record?.cred_ex_id)
.then(() => {
toast.success(`Credential successfully added to your wallet`);
});
}
};
const rejectOffer = (event: any, data: V10CredentialExchange) => {
const rejectOffer = (event: any, data: V20CredExRecordDetail) => {
confirm.require({
target: event.currentTarget,
message: 'Are you sure you want to reject this credential offer?',
header: 'Confirmation',
icon: 'pi pi-exclamation-triangle',
accept: async () => {
if (data.credential_exchange_id) {
if (data.cred_ex_record?.cred_ex_id) {
// Send a problem report then delete the cred exchange record
await holderStore
.sendProblemReport(data.credential_exchange_id)
.sendProblemReport(data.cred_ex_record?.cred_ex_id)
.catch((err: any) => {
console.error(`Problem report failed: ${err}`);
toast.error('Failure sending Problem Report');
});
holderStore
.deleteCredentialExchange(data.credential_exchange_id)
.deleteCredentialExchange(data.cred_ex_record?.cred_ex_id)
.then(() => {
loadCredentials();
toast.success(`Credential offer rejected`);
Expand All @@ -100,16 +102,16 @@ const rejectOffer = (event: any, data: V10CredentialExchange) => {
},
});
};
const deleteCredential = (event: any, data: V10CredentialExchange) => {
const deleteCredential = (event: any, data: V20CredExRecordDetail) => {
confirm.require({
target: event.currentTarget,
message: 'Are you sure you want to delete this credential exchange record?',
header: 'Confirmation',
icon: 'pi pi-exclamation-triangle',
accept: () => {
if (data.credential_exchange_id) {
if (data.cred_ex_record?.cred_ex_id) {
holderStore
.deleteCredentialExchange(data.credential_exchange_id)
.deleteCredentialExchange(data.cred_ex_record?.cred_ex_id)
.then(() => {
loadCredentials();
toast.info(`Credential exchange deleted`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<hr class="expand-divider" />
<RowExpandData
:id="data.credential_exchange_id"
:url="API_PATH.ISSUE_CREDENTIAL_RECORDS"
:url="API_PATH.ISSUE_CREDENTIAL_20_RECORDS"
/>
</template>
<Column :expander="true" header-style="width: 3rem" />
Expand Down Expand Up @@ -147,9 +147,10 @@

<script setup lang="ts">
// Types
import { ExtendedV20CredExRecordByFormat } from '@/types';
import {
CredAttrSpec,
V10CredentialExchange,
V20CredExRecordDetail,
} from '@/types/acapyApi/acapyInterface';
// Vue
Expand Down Expand Up @@ -188,21 +189,23 @@ const holderStore = useHolderStore();
// The data table row format
const formattedcredentialExchanges = computed(() =>
credentialExchanges.value.map((ce) => ({
credential_exchange_id: ce.credential_exchange_id,
credential_exchange_id: ce.cred_ex_record?.cred_ex_id,
credential_attributes: getAttributes(ce),
connection: findConnectionName(ce.connection_id ?? ''),
credential_definition_id: ce.credential_definition_id,
state: ce.state,
updated: formatDateLong(ce.updated_at ?? ''),
updated_at: ce.updated_at,
created: formatDateLong(ce.created_at ?? ''),
created_at: ce.created_at,
connection: findConnectionName(ce.cred_ex_record?.connection_id ?? ''),
credential_definition_id: (
ce.cred_ex_record?.by_format as ExtendedV20CredExRecordByFormat
)?.cred_offer?.indy?.cred_def_id,
state: ce.cred_ex_record?.state,
updated: formatDateLong(ce.cred_ex_record?.updated_at ?? ''),
updated_at: ce.cred_ex_record?.updated_at,
created: formatDateLong(ce.cred_ex_record?.created_at ?? ''),
created_at: ce.cred_ex_record?.created_at,
}))
);
// Cred attributes
const getAttributes = (data: V10CredentialExchange): CredAttrSpec[] => {
return data.credential_offer_dict?.credential_preview?.attributes ?? [];
const getAttributes = (data: V20CredExRecordDetail): CredAttrSpec[] => {
return data.cred_ex_record?.cred_offer?.credential_preview?.attributes ?? [];
};
const expandedRows = ref([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
v-model:filters="filter"
v-model:expandedRows="expandedRows"
:loading="loading"
:value="formattedCredentials"
:value="formattedCredentials20"
:paginator="true"
:rows="TABLE_OPT.ROWS_DEFAULT"
:rows-per-page-options="TABLE_OPT.ROWS_OPTIONS"
Expand Down Expand Up @@ -135,7 +135,7 @@
<template #expansion="{ data }">
<RowExpandData
:id="data.credential_exchange_id"
:url="API_PATH.ISSUE_CREDENTIAL_RECORDS"
:url="API_PATH.ISSUE_CREDENTIAL_20_RECORDS"
/>
</template>
</DataTable>
Expand Down Expand Up @@ -179,17 +179,17 @@ const issuerStore = useIssuerStore();
const { loading, credentials, selectedCredential } =
storeToRefs(useIssuerStore());
const formattedCredentials: Ref<any[]> = computed(() =>
const formattedCredentials20: Ref<any[]> = computed(() =>
credentials.value.map((cred: any) => ({
connection_id: cred.connection_id,
state: cred.state,
revocation_id: cred.revocation_id,
revoc_reg_id: cred.revoc_reg_id,
connection: findConnectionName(cred.connection_id),
credential_definition_id: cred.credential_definition_id,
credential_exchange_id: cred.credential_exchange_id,
sent_time: cred.sent_time,
created: formatDateLong(cred.created_at),
connection_id: cred.cred_ex_record.connection_id,
state: cred.cred_ex_record.state,
cred_rev_id: cred.indy.cred_rev_id,
rev_reg_id: cred.indy.rev_reg_id,
connection: findConnectionName(cred.cred_ex_record.connection_id),
credential_definition_id:
cred.cred_ex_record.by_format?.cred_offer?.indy?.cred_def_id,
credential_exchange_id: cred.cred_ex_record.cred_ex_id,
created: formatDateLong(cred.cred_ex_record.created_at),
created_at: cred.created_at,
}))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,15 @@ const handleSubmit = async (isFormValid: boolean) => {
auto_issue: true,
auto_remove: false,
connection_id: formFields.selectedConnection.value,
cred_def_id: formFields.selectedCred.value,
credential_preview: {
'@type': 'issue-credential/1.0/credential-preview',
'@type': 'issue-credential/2.0/credential-preview',
attributes: credentialValuesRaw.value,
},
filter: {
indy: {
cred_def_id: formFields.selectedCred.value,
},
},
trace: false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<script setup lang="ts">
// Types
import { V10CredentialExchange } from '@/types/acapyApi/acapyInterface';
import { V20CredExRecordDetail } from '@/types/acapyApi/acapyInterface';
// Vue/State
import { computed, ref } from 'vue';
Expand All @@ -38,16 +38,15 @@ defineEmits(['success']);
// Props
const props = defineProps<{
credExchRecord: V10CredentialExchange;
credExchRecord: V20CredExRecordDetail;
connectionDisplay: string;
}>();
// Check revocation allowed
const canRevoke = computed(() => {
return (
props.credExchRecord.state === 'credential_acked' &&
props.credExchRecord.revocation_id &&
props.credExchRecord.revoc_reg_id
props.credExchRecord.cred_ex_record?.state === 'done' &&
props.credExchRecord.indy?.rev_reg_id
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
<small>
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
{{ t('issue.revocationId') }}:
{{ props.credExchRecord.revocation_id }}
{{ props.credExchRecord?.indy?.cred_rev_id }}
</small>
</p>
<p>
<small>
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
{{ t('issue.revocationRegistry') }}:
{{ props.credExchRecord.revoc_reg_id }}
{{ props.credExchRecord?.indy?.rev_reg_id }}
</small>
</p>
</div>
Expand All @@ -62,7 +62,7 @@
// Types
import {
RevokeRequest,
V10CredentialExchange,
V20CredExRecordDetail,
} from '@/types/acapyApi/acapyInterface';
// Vue/State
Expand All @@ -86,7 +86,7 @@ const emit = defineEmits(['closed', 'success']);
// Props
const props = defineProps<{
credExchRecord: V10CredentialExchange;
credExchRecord: V20CredExRecordDetail;
connectionDisplay: string;
}>();
Expand All @@ -110,9 +110,9 @@ const handleSubmit = async (isFormValid: boolean) => {
try {
const payload: RevokeRequest = {
comment: formFields.comment,
connection_id: props.credExchRecord.connection_id,
rev_reg_id: props.credExchRecord.revoc_reg_id,
cred_rev_id: props.credExchRecord.revocation_id,
connection_id: props.credExchRecord.cred_ex_record?.connection_id,
rev_reg_id: props.credExchRecord.indy?.rev_reg_id,
cred_rev_id: props.credExchRecord.indy?.cred_rev_id,
publish: true,
notify: true,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
// Types
import {
IndyProofRequest,
V10PresentationSendRequestRequest,
V20PresSendRequestRequest,
} from '@/types/acapyApi/acapyInterface';
// Vue
Expand Down Expand Up @@ -195,12 +195,12 @@ const handleSubmit = async (isFormValid: boolean) => {
? JSON.parse(proofRequestJson.value)
: proofRequestJson.value;
// Set up the body with the fields from the form
const payload: V10PresentationSendRequestRequest = {
const payload: V20PresSendRequestRequest = {
connection_id: formFields.selectedConnection.value,
auto_verify: false,
comment: formFields.comment,
trace: false,
proof_request: proofRequest,
presentation_request: { indy: proofRequest },
};
await verifierStore.sendPresentationRequest(payload);
toast.info('Request Sent');
Expand Down
11 changes: 10 additions & 1 deletion services/tenant-ui/frontend/src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,17 @@ export const API_PATH = {
ISSUE_CREDENTIAL_RECORD: (id: string) => `/issue-credential/records/${id}`,
ISSUE_CREDENTIAL_RECORDS_SEND_OFFER: (id: string) =>
`/issue-credential/records/${id}/send-offer`,
ISSUE_CREDENTIALS_SEND_OFFER: '/issue-credential/send-offer',
ISSUE_CREDENTIALS_SEND_OFFER: '/issue-credential-2.0/send-offer',
ISSUE_CREDENTIAL_RECORDS_SEND_REQUEST: (id: string) =>
`/issue-credential/records/${id}/send-request`,
ISSUE_CREDENTIAL_RECORDS_PROBLEM_REPORT: (id: string) =>
`/issue-credential/records/${id}/problem-report`,

ISSUE_CREDENTIAL_20_RECORDS: '/issue-credential-2.0/records',
ISSUE_CREDENTIAL_20_RECORD: (id: string) =>
`/issue-credential-2.0/records/${id}`,
ISSUE_CREDENTIALS_20_SEND_OFFER: '/issue-credential-2.0/send-offer',

LEDGER_TAA: '/ledger/taa',
LEDGER_TAA_ACCEPT: '/ledger/taa/accept',

Expand Down Expand Up @@ -118,6 +123,10 @@ export const API_PATH = {
PRESENT_PROOF_SEND_PROPOSAL: '/present-proof/send-proposal',
PRESENT_PROOF_SEND_REQUEST: '/present-proof/send-request',

PRESENT_PROOF_20_RECORDS: '/present-proof-2.0/records',
PRESENT_PROOF_20_RECORD: (id: string) => `/present-proof-2.0/records/${id}`,
PRESENT_PROOF_20_SEND_REQUEST: '/present-proof-2.0/send-request',

REVOCATION_REVOKE: '/revocation/revoke',

SCHEMAS: '/schemas',
Expand Down
5 changes: 3 additions & 2 deletions services/tenant-ui/frontend/src/store/holderStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
IndyCredInfo,
OcaRecord,
V10CredentialExchange,
V20CredExRecordDetail,
} from '@/types/acapyApi/acapyInterface';

import { defineStore } from 'pinia';
Expand All @@ -16,7 +17,7 @@ export const useHolderStore = defineStore('holder', () => {

// state
const credentials: Ref<IndyCredInfo[]> = ref([]);
const credentialExchanges: Ref<V10CredentialExchange[]> = ref([]);
const credentialExchanges: Ref<V20CredExRecordDetail[]> = ref([]);
const selectedCredential: any = ref(null);

const ocas: Ref<OcaRecord[]> = ref([]);
Expand Down Expand Up @@ -44,7 +45,7 @@ export const useHolderStore = defineStore('holder', () => {

async function listHolderCredentialExchanges() {
return fetchList(
API_PATH.ISSUE_CREDENTIAL_RECORDS,
API_PATH.ISSUE_CREDENTIAL_20_RECORDS,
credentialExchanges,
error,
loading,
Expand Down
Loading

0 comments on commit a722426

Please sign in to comment.