UNPKG

incubed

Version:

Typescript-version of the incubed client

31 lines 1.63 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const modules_1 = require("../../client/modules"); const ChainContext_1 = require("../../client/ChainContext"); const ipfs_1 = require("./ipfs"); modules_1.register({ name: 'ipfs', verifyProof, createChainContext: (client, chainId, spec) => new ChainContext_1.default(client, chainId, spec) }); /** general verification-function which handles it according to its given type. */ function verifyProof(request, response, allowWithoutProof, ctx) { return __awaiter(this, void 0, void 0, function* () { if (request.method !== 'ipfs_get' && request.method !== 'ipfs_put') return false; // handle verification with implicit proof (like ipfs) if (request.method === 'ipfs_get' && response.result) return ipfs_1.verifyIPFSHash(response.result, request.params[1] || 'base64', request.params[0]); return true; }); } exports.verifyProof = verifyProof; //# sourceMappingURL=index.js.map