Skip to content

Commit

Permalink
Merge pull request #63 from blockchain-certificates/fix/cvjs-v1
Browse files Browse the repository at this point in the history
Fix V1 deps by forking from current CVJS state
  • Loading branch information
lemoustachiste committed Nov 28, 2023
2 parents b931776 + c09b65a commit f72314b
Show file tree
Hide file tree
Showing 180 changed files with 5,377 additions and 14,013 deletions.
2 changes: 1 addition & 1 deletion bundle-esm-stats.html

Large diffs are not rendered by default.

10,198 changes: 4,198 additions & 6,000 deletions package-lock.json

Large diffs are not rendered by default.

29 changes: 4 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"name": "@blockcerts/cert-verifier-js",
"name": "@blockcerts/cert-verifier-js-v1-legacy",
"version": "0.0.0-dev",
"description": "Javascript library for verifying Blockcerts",
"description": "Javascript library for verifying Blockcerts v1 (legacy)",
"repository": {
"type": "git",
"url": "https://github.com/blockchain-certificates/cert-verifier-js.git"
"url": "https://github.com/blockchain-certificates/cert-verifier-js-v1-legacy.git"
},
"main": "dist/verifier/index.js",
"module": "dist/verifier-es/index.js",
"node": "dist/verifier-node/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"postinstall": "rm -rf node_modules/@blockcerts/ecdsa-secp256k1-verification-key-2019/node_modules/base58-universal",
"dts:bundle": "dts-bundle-generator -o ./dist/index.d.ts --project tsconfig.json --no-banner src/index.ts",
"test": "jest --setupFilesAfterEnv=./test/setup.ts",
"test:build": "npm run test:manual:node:server& npm run test:build:esm && npm run test:build:cjs && npm run test:build:node && npm run test:build:iife && kill -9 $(lsof -t -i:4000)",
Expand Down Expand Up @@ -57,37 +56,17 @@
]
},
"dependencies": {
"@blockcerts/ecdsa-secp256k1-signature-2019": "^0.1.6",
"@blockcerts/ecdsa-secp256k1-verification-key-2019": "^0.1.5",
"@blockcerts/explorer-lookup": "^1.5.1",
"@blockcerts/hashlink-verifier": "^1.6.0",
"@blockcerts/schemas": "^3.4.1",
"@did-core/did-ld-json": "npm:@blockcerts/did-ld-json@^0.1.2",
"@digitalbazaar/ed25519-signature-2020": "github:lemoustachiste/ed25519-signature-2020#convert-to-module",
"@digitalbazaar/ed25519-verification-key-2020": "github:lemoustachiste/ed25519-verification-key-2020#convert-to-module",
"@digitalbazaar/vc-revocation-list": "github:blockchain-certificates/vc-revocation-list#fix/memory-leak",
"@transmute/did-key-ed25519": "^0.3.0-unstable.10",
"@transmute/did-key-secp256k1": "^0.3.0-unstable.10",
"@transmute/ed25519-key-pair": "^0.7.0-unstable.63",
"@trust/keyto": "^1.0.1",
"base58-universal": "github:lemoustachiste/base58-universal#fix/hoisting-error-alphabet",
"bigi": "^1.4.2",
"bitcoinjs-lib": "^6.1.3",
"bs58": "^5.0.0",
"buffer": "^6.0.3",
"core-js": "^3.23.5",
"ecurve": "^1.0.4",
"elliptic": "^6.5.4",
"js-sha3": "^0.9.2",
"jsonld": "^8.3.1",
"jsonld-checker": "npm:@blockcerts/jsonld-checker@^0.1.9",
"jsonld-signatures": "^11.2.1",
"jsonld-signatures-merkleproof2019": "^2.5.3",
"lodash.clonedeep": "^4.5.0",
"readable-stream": "npm:vite-compatible-readable-stream@^3.6.1",
"secp256k1": "^5.0.0",
"serialize-error": "github:blockchain-certificates/serialize-error",
"sha.js": "github:blockchain-certificates/sha.js#fix/jest-exports-esm",
"defa": "github:blockchain-certificates/sha.js#fix/jest-exports-esm",
"sha256": "^0.2.0"
},
"devDependencies": {
Expand Down
41 changes: 5 additions & 36 deletions src/certificate.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import domain from './domain';
import type { ParsedCertificate } from './parsers';
import parseJSON from './parsers/index';
import type { IFinalVerificationStatus, IVerificationStepCallbackFn } from './verifier';
import Verifier from './verifier';
import { DEFAULT_OPTIONS } from './constants';
import currentLocale from './constants/currentLocale';
import { deepCopy } from './helpers/object';
import convertHashlink, { getHashlinksFrom } from './parsers/helpers/convertHashlink';
import type { HashlinkVerifier } from '@blockcerts/hashlink-verifier';
import type { IFinalVerificationStatus, IVerificationStepCallbackFn } from './verifier';
import type { ParsedCertificate } from './parsers';
import type { ExplorerAPI, IBlockchainObject } from '@blockcerts/explorer-lookup';
import type { Blockcerts } from './models/Blockcerts';
import type { Issuer } from './models/Issuer';
import type { SignatureImage } from './models';
import type { BlockcertsV3, BlockcertsV3Display } from './models/BlockcertsV3';
import type { IVerificationMapItem } from './models/VerificationMap';

export interface ExplorerURLs {
Expand Down Expand Up @@ -47,7 +44,7 @@ export default class Certificate {
public certificateImage?: string;
public certificateJson: Blockcerts;
public description?: string; // v1
public display?: BlockcertsV3Display;
public display?: string;
public expires: string;
public explorerAPIs: ExplorerAPI[] = [];
public id: string;
Expand All @@ -66,8 +63,6 @@ export default class Certificate {
public signatureImage?: SignatureImage[]; // v1
public signers: Signers[] = [];
public subtitle?: string; // v1
public hashlinkVerifier: HashlinkVerifier;
public hasHashlinks: boolean = false;
public verificationSteps: IVerificationMapItem[];
public verifier: Verifier;

Expand All @@ -77,7 +72,7 @@ export default class Certificate {

if (typeof certificateDefinition !== 'object') {
try {
certificateDefinition = JSON.parse(certificateDefinition) as Blockcerts;
certificateDefinition = JSON.parse(certificateDefinition);
} catch (err) {
throw new Error(domain.i18n.getText('errors', 'certificateNotValid'));
}
Expand All @@ -89,22 +84,13 @@ export default class Certificate {

async init (): Promise<void> {
// Parse certificate
if ((this.certificateJson as BlockcertsV3).display?.content) {
const hashlinks = getHashlinksFrom((this.certificateJson as BlockcertsV3).display.content);
if (hashlinks.length) {
await import('@blockcerts/hashlink-verifier').then((hashlinkLib) => {
this.hashlinkVerifier = new hashlinkLib.HashlinkVerifier();
});
}
}
await this.parseJson(this.certificateJson);

this.verifier = new Verifier({
certificateJson: this.certificateJson,
expires: this.expires,
id: this.id,
issuer: this.issuer,
hashlinkVerifier: this.hashlinkVerifier,
revocationKey: this.revocationKey,
explorerAPIs: deepCopy<ExplorerAPI[]>(this.explorerAPIs)
});
Expand Down Expand Up @@ -139,10 +125,6 @@ export default class Certificate {
this.locale = domain.i18n.ensureIsSupported(this.options.locale === 'auto' ? domain.i18n.detectLocale() : this.options.locale);
this.explorerAPIs = this.options.explorerAPIs ?? [];

if (options.didResolverUrl) {
domain.did.didResolver.url = options.didResolverUrl;
}

currentLocale.locale = this.locale;
}

Expand Down Expand Up @@ -181,19 +163,6 @@ export default class Certificate {
this.signature = signature;
this.signatureImage = signatureImage;
this.subtitle = subtitle;
this.display = await this.parseHashlinksInDisplay(display);
}

async parseHashlinksInDisplay (display: BlockcertsV3Display): Promise<BlockcertsV3Display> {
const modifiedDisplay = deepCopy<BlockcertsV3Display>(display);
if (!modifiedDisplay) {
return;
}

if (modifiedDisplay.contentMediaType !== 'text/html') { // TODO: enum supported content media types
return modifiedDisplay;
}
modifiedDisplay.content = await convertHashlink(modifiedDisplay.content, this.hashlinkVerifier);
return modifiedDisplay;
this.display = display;
}
}
102 changes: 0 additions & 102 deletions src/constants/contexts/EcdsaSecp256k1Signature2019Context.json

This file was deleted.

Loading

0 comments on commit f72314b

Please sign in to comment.