UNPKG

did-relayer-quick

Version:

Veramo plugin that can enable creation and control of did:quick identifiers.

41 lines 1.5 kB
import Debug from 'debug'; import { saveDIDQuickUpdate } from './saveDIDQuickUpdate.js'; import { postPendingDIDQuickUpdates } from './postPendingDIDQuickUpdates.js'; const debug = Debug('veramo:did-relayer-quick'); /** * {@link @veramo/did-manager#DIDManager} identifier provider for `did:quick` identifiers * @public */ export class QuickDIDRelayer { methods; saveToArweaveStore; constructor(options) { this.saveToArweaveStore = options.saveToArweaveStore; this.methods = { saveCredential: this.saveCredential.bind(this), postPendingUpdates: this.postPendingUpdates.bind(this), }; } async saveCredential(credential, context) { const { success, credentialHash } = await saveDIDQuickUpdate(credential, context.agent); if (success) { console.log("saveCredential credentialHash: ", credentialHash); await this.saveToArweaveStore.set(credentialHash, true); return true; } return false; } async postPendingUpdates(batchSize, context) { const updates = this.saveToArweaveStore.getIterator(); const batch = []; for (let i = 0; i < 10; i++) { const result = await updates.next(); if (result.done) break; batch.push(result.value[0]); } await postPendingDIDQuickUpdates(batch, context.agent); return true; } } //# sourceMappingURL=quick-did-relayer.js.map