UNPKG

@minespider/core-bundles

Version:

A high-level SDK for Minespider Core. It abstract the low-level features from the core SDK for a more high-level usage such as DAPPs. Some of the features are 1:1 with the SDK some others abstract some low-level interactions or multiple actions

86 lines 3.92 kB
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; define(["require", "exports", "eth-crypto", "axios", "hasha"], function (require, exports, EthCrypto, axios_1, hasha_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CertificateCacheServiceAdapter = void 0; EthCrypto = __importStar(EthCrypto); axios_1 = __importDefault(axios_1); hasha_1 = __importDefault(hasha_1); class CertificateCacheServiceAdapter { constructor(certificateCacheServiceEndpoint) { this.certificateCacheServiceEndpoint = certificateCacheServiceEndpoint; } async getCertificate(uuid, privateKey) { const signature = EthCrypto.sign(privateKey, hasha_1.default(uuid.toLowerCase(), { algorithm: "sha256", })); const response = await axios_1.default.get(`${this.certificateCacheServiceEndpoint}/certificate/${uuid}?signature=${signature}`); return response.data; } async getCertificates(ownerUuid, privateKey) { const signature = EthCrypto.sign(privateKey, hasha_1.default(ownerUuid.toLowerCase(), { algorithm: "sha256", })); const response = await axios_1.default.get(`${this.certificateCacheServiceEndpoint}/certificates/findByOwner/${ownerUuid}?signature=${signature}`); return response.data.items; } async registerClient(clientDTO) { await axios_1.default.post(`${this.certificateCacheServiceEndpoint}/client`, clientDTO); } async getCertificateHistoryByOwner(entityId) { return new Promise(async (resolve, reject) => { try { let response = await axios_1.default.get(this.certificateCacheServiceEndpoint + "/certificates/history/by-owner", { params: { entityId } }); resolve(response.data.content); } catch (error) { reject(error); } }); } async getCertificateHistoryByCertificate(uuid, parentsDepth = 10, childrenDepth = 10) { return new Promise(async (resolve, reject) => { try { let response = await axios_1.default.get(this.certificateCacheServiceEndpoint + "/certificates/history", { params: { uuid, parentsDepth, childrenDepth } }); resolve(response.data.content); } catch (error) { reject(error); } }); } } exports.CertificateCacheServiceAdapter = CertificateCacheServiceAdapter; }); //# sourceMappingURL=CertificateCacheServiceAdapter.js.map