Is a javascript library for Schema related operation (generate, sign, register etc). It also provides APIs to store/update/retrive Schema to/from the Hypersign Schema Registry on the Hypersign Blockchain network easily.
NOTES
A DID registred on Hypersign blockchain in order to register a schema on Hypersign blockchain network.
consthypersignSchema=newHypersignSchema();// OR initialize by passing a namepace. Default ''// More complex way to initialize this class can be found in this documentation laterconstnamespace='testnet';consthypersignSchema=newHypersignSchema({ namespace });
constschemaBody= { name:'testSchema', description:'This is a test schema generation', author:'did:hid:testnet:zAtZ8oBrVPvaKKou21KRnmzRtZaJpWxsgWuB9GNRLTQ6R', fields: [{ name:'name', type:'integer', isRequired:false }], additionalProperties:false,}constschema=awaithypersignSchema.generate(schemaBody);
Output
{"type":"https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json","modelVersion":"1.0","id":"sch:hid:testnet:z57BBNTNqkFXpsFfSMLvfvBhhiSEicGK3nVvJMXRKcE3S:1.0","name":"testSchema","author":"did:hid:testnet:zAtZ8oBrVPvaKKou21KRnmzRtZaJpWxsgWuB9GNRLTQ6R","authored":"2023-01-07T07:24:06Z","schema": {"schema":"http://json-schema.org/draft-07/schema","description":"This is a test schema generation","type":"object","properties":"{\"name\":{\"type\":\"integer\"}}","required": [],"additionalProperties":false }}
{"type":"https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json","modelVersion":"1.0","id":"sch:hid:testnet:z57BBNTNqkFXpsFfSMLvfvBhhiSEicGK3nVvJMXRKcE3S:1.0","name":"testSchema","author":"did:hid:testnet:zAtZ8oBrVPvaKKou21KRnmzRtZaJpWxsgWuB9GNRLTQ6R","authored":"2023-01-07T07:24:06Z","schema": {"schema":"http://json-schema.org/draft-07/schema","description":"This is a test schema generation","type":"object","properties":"{\"name\":{\"type\":\"integer\"}}","required": [],"additionalProperties":false },"proof": {"type":"Ed25519Signature2020","created":"2023-01-07T07:24:07Z","verificationMethod":"did:hid:testnet:zAtZ8oBrVPvaKKou21KRnmzRtZaJpWxsgWuB9GNRLTQ6R#key-1","proofPurpose":"assertion","proofValue":"aozlK3ZSAHuP2x7is60jYXdhS8zc68bO2y9CVShgLNaXxTHdeLIIgqY5Ci6ji0nrC5Q4e+YiGtV/SNIFkvO4CQ==" }}
OnChain APIs
Initialize with offlineSigner
Create Instance of the class
consthypersignSchema=newHypersignSchema({ offlineSigner,// OPTIONAL signer of type OfflineSigner nodeRestEndpoint:'https://api.jagrat.hypersign.id',// OPTIONAL RPC endpoint of the Hypersign blockchain, Default 'TEST' nodeRpcEndpoint:'https://rpc.jagrat.hypersign.id',// OPTIONAL REST endpoint of the Hypersign blockchain namespace:'testnet',// OPTIONAL namespace of did, Default '' });// OR Just initalize with offlineSignerconsthypersignSchema=newHypersignSchema({ offlineSigner})
{"type":"https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json","modelVersion":"1.0","id":"sch:hid:testnet:z57BBNTNqkFXpsFfSMLvfvBhhiSEicGK3nVvJMXRKcE3S:1.0","name":"testSchema","author":"did:hid:testnet:zAtZ8oBrVPvaKKou21KRnmzRtZaJpWxsgWuB9GNRLTQ6R","authored":"2023-01-07T07:24:06Z","schema": {"schema":"http://json-schema.org/draft-07/schema","description":"This is a test schema generation","type":"object","properties":"{\"name\":{\"type\":\"integer\"}}","required": [],"additionalProperties":false },"proof": {"type":"Ed25519Signature2020","created":"2023-01-07T07:24:07Z","verificationMethod":"did:hid:testnet:zAtZ8oBrVPvaKKou21KRnmzRtZaJpWxsgWuB9GNRLTQ6R#key-1","proofPurpose":"assertion","proofValue":"aozlK3ZSAHuP2x7is60jYXdhS8zc68bO2y9CVShgLNaXxTHdeLIIgqY5Ci6ji0nrC5Q4e+YiGtV/SNIFkvO4CQ==" }}