Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const QRCode = require('qrcode-svg');

const fs = require('fs');

var pako = require('pako');

const WORKDIR = '.cli';

const IDENTITYFILE = `${WORKDIR}/identity.json`;
Expand Down Expand Up @@ -97,9 +99,13 @@ getIdentity().then((identity) => {
console.info('using identity', identity);
createCredential(identity, schemaName as SchemaNames, JSON.parse(fs.readFileSync(dataPath, 'utf8'))).then((credential) => {
console.info('credential created');

const strigifiedCredential = JSON.stringify(credential);
const qrData = strigifiedCredential;
console.info(qrData);
const compressedCredential = pako.deflate(strigifiedCredential, { to: 'string' });
const qrData = JSON.stringify({ cp: compressedCredential });

console.log(qrData);

const qrcode = new QRCode({
content: qrData,
padding: 40,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"capacitor-secure-storage-plugin": "0.3.1",
"hammerjs": "^2.0.8",
"iota-identity-wasm-test": "0.0.13",
"pako": "^1.0.11",
"qr-scanner": "^1.2.0",
"qrcode-svg": "^1.1.0",
"randomstring": "^1.1.5",
Expand Down
12 changes: 6 additions & 6 deletions ui/components/modal/Presentation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import QRCode from 'qrcode-svg';
import { onMount } from 'svelte';

import pako from 'pako';

import { detectSwipeGesture } from '~/lib/helpers';

import { qrCode, modalStatus, storedCredentials } from '~/lib/store';
Expand All @@ -12,29 +14,27 @@
detectSwipeGesture('wrapper', 'swipedown', () => goBack());
});

console.log($modalStatus.props);

const credential = $storedCredentials.find((credential) => credential.id === $modalStatus.props.id);
const schema = credential.credentialDocument.type[1];
const challenge = Date.now();

console.log(credential, schema, challenge);

retrieveIdentity('did').then((identity) => {
createVerifiablePresentation(identity, [credential.credentialDocument], challenge, true).then(
createVerifiablePresentation(identity, [ credential.credentialDocument ], challenge, true).then(
(verifiablePresentations) => {
const strigifiedPresentation = JSON.stringify(verifiablePresentations);
const qrData = strigifiedPresentation;
const compressedPresentation = pako.deflate(strigifiedPresentation, { to: 'string' });
const qrData = JSON.stringify({ cp: compressedPresentation });
const deviceHeight = document.documentElement.clientHeight;
console.log(qrData);
qrCode.set(
new QRCode({
content: qrData,
color: '#000000',
//join: true,
height: deviceHeight * 0.3,
width: deviceHeight * 0.3,
ecl: 'L',
ecl: 'L'
}).svg()
);
}
Expand Down
5 changes: 5 additions & 0 deletions ui/views/Scan.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
import pako from 'pako';

import Scanner from '~/components/Scanner.svelte';

import { goto, parse, isChannelInfo, isVerifiablePresentation, isVerifiableCredential } from '~/lib/helpers';
Expand All @@ -10,6 +12,9 @@

if (!parsedData) return goBack();

if (parsedData.cp) {
parsedData = parse(pako.inflate(parsedData.cp, { to: 'string' }));
}
//window.alert("Found something");
if (isChannelInfo(parsedData)) {
socketConnectionState.set({ state: 'registerMobileClient', payload: parsedData });
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5710,7 +5710,7 @@ p-try@^2.0.0:
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==

pako@~1.0.5:
pako@^1.0.11, pako@~1.0.5:
version "1.0.11"
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==
Expand Down