From edbe708b65e342033c2e66bce21ac3d1622088c3 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 2 Oct 2024 14:47:32 +0200 Subject: [PATCH] feat(opentimestamps): updates data model and useSigitMeta hook --- src/hooks/useSigitMeta.tsx | 7 +++++-- src/types/core.ts | 8 ++++++++ src/types/opentimestamps.d.ts | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/hooks/useSigitMeta.tsx b/src/hooks/useSigitMeta.tsx index 22a6a6d..dc05559 100644 --- a/src/hooks/useSigitMeta.tsx +++ b/src/hooks/useSigitMeta.tsx @@ -3,7 +3,8 @@ import { CreateSignatureEventContent, DocSignatureEvent, Meta, - SignedEventContent + SignedEventContent, + Timestamp } from '../types' import { Mark } from '../types/mark' import { @@ -59,6 +60,8 @@ export interface FlatMeta signersStatus: { [signer: `npub1${string}`]: SignStatus } + + timestamps?: Timestamp[] } /** @@ -163,7 +166,6 @@ export const useSigitMeta = (meta: Meta): FlatMeta => { setEncryptionKey(decrypted) } } - // Temp. map to hold events and signers const parsedSignatureEventsMap = new Map< `npub1${string}`, @@ -277,6 +279,7 @@ export const useSigitMeta = (meta: Meta): FlatMeta => { createSignature: meta?.createSignature, docSignatures: meta?.docSignatures, keys: meta?.keys, + timestamps: meta?.timestamps, isValid, kind, tags, diff --git a/src/types/core.ts b/src/types/core.ts index 5d4e4ac..ea12271 100644 --- a/src/types/core.ts +++ b/src/types/core.ts @@ -43,6 +43,14 @@ export interface Sigit { export interface Timestamp { nostrId: string timestamp: string + isComplete?: boolean +} + +export interface TimestampUpgradeResponse { + upgraded: boolean + nostrId: string + timestamp: string + isComplete: boolean } export interface UserAppData { diff --git a/src/types/opentimestamps.d.ts b/src/types/opentimestamps.d.ts index 5c45488..f3398d2 100644 --- a/src/types/opentimestamps.d.ts +++ b/src/types/opentimestamps.d.ts @@ -3,13 +3,14 @@ interface OpenTimestamps { DetachedTimestampFile: { fromHash(op: any, hash: Uint8Array): any fromBytes(op: any, buffer: Uint8Array): any + deserialize(buffer: any): any } // Stamp the provided timestamp file and return a Promise stamp(file: any): Promise // Verify the provided timestamp proof file - verify(file: any): Promise + verify(ots: string, file: string): Promise // Other utilities or operations (like OpSHA256, serialization) Ops: { @@ -25,5 +26,5 @@ interface OpenTimestamps { deserialize(bytes: Uint8Array): any // Other potential methods based on repo functions - upgrade(file: any): Promise + upgrade(file: any): Promise }