Open-Attestation / open-attestation

Meta framework for providing digital provenance and integrity to documents.
https://openattestation.com
Apache License 2.0
54 stars 18 forks source link

Generics for signDocument #136

Closed yehjxraymond closed 3 years ago

yehjxraymond commented 3 years ago

image

Current signDocument changes the type to a generic Promise<SignedWrappedDocument<v2.OpenAttestationDocument>>, add in generic to automatically update the type of output.

Nebulis commented 3 years ago

wrong repo ? https://github.com/Open-Attestation/oa-did-sign/blob/master/src/signDocument/signDocument.ts

This could work:

export const signDocument = async (
  document: SignedWrappedDocument<T extends v2.OpenAttestationDocument> | WrappedDocument<T extends v2.OpenAttestationDocument>,
  algorithm: string,
  publicKey: string,
  privateKey: string
): Promise<SignedWrappedDocument<T>>
yehjxraymond commented 3 years ago

Added in https://github.com/Open-Attestation/oa-did-sign/pull/1/files

Thanks!