update to newer version
This commit is contained in:
parent
d6a32870bc
commit
29138de53e
37 changed files with 15795 additions and 12789 deletions
88
wallet/metadata.js
Normal file
88
wallet/metadata.js
Normal file
|
@ -0,0 +1,88 @@
|
|||
const ChainUtil = require('../chain-util');
|
||||
|
||||
class Metadata {
|
||||
constructor() {
|
||||
this.id = null;
|
||||
this.Signiture = null;
|
||||
this.Name = null;
|
||||
this.Geo = null;
|
||||
// this.GeospatialLocation = [];
|
||||
// this.Owenership = null;
|
||||
// this.Cost = null;
|
||||
// this.Identifications = null;
|
||||
// this.Integration = null;
|
||||
|
||||
this.IP_URL = null;
|
||||
this.Topic_Token = null;
|
||||
this.Permission = null;
|
||||
this.RequestDetail = null;
|
||||
this.OrgOwner = null;
|
||||
this.DepOwner = null;
|
||||
this.PrsnOwner = null;
|
||||
this.MetaHash = null;
|
||||
this.PaymentPerKbyte = null;
|
||||
this.PaymentPerMinute = null;
|
||||
this.Protocol = null;
|
||||
this.MessageAttributes= {};
|
||||
this.Interval = null;
|
||||
this.FurtherDetails = null;
|
||||
this.SSNmetadata = null;
|
||||
}
|
||||
|
||||
static MetadataOfIoTDevice(senderWallet, Name,Geo ,IP_URL , Topic_Token, Permission, RequestDetail, OrgOwner, DepOwner,PrsnOwner, PaymentPerKbyte, PaymentPerMinute, Protocol, MessageAttributes, Intrval, FurtherDetails, SSNmetadata) {
|
||||
const metadata = new this();
|
||||
metadata.id = ChainUtil.id();
|
||||
metadata.Name = Name;
|
||||
metadata.Geo = Geo;
|
||||
metadata.IP_URL = IP_URL;
|
||||
metadata.Topic_Token = Topic_Token;
|
||||
metadata.Permission = Permission;
|
||||
metadata.RequestDetail = RequestDetail
|
||||
metadata.OrgOwner = OrgOwner;
|
||||
metadata.DepOwner = DepOwner;
|
||||
metadata.PrsnOwner = PrsnOwner;
|
||||
metadata.PaymentPerKbyte = PaymentPerKbyte ;
|
||||
metadata.PaymentPerMinute = PaymentPerMinute;
|
||||
metadata.Protocol = Protocol;
|
||||
metadata.MessageAttributes = MessageAttributes;
|
||||
// metadata.MessageAttributes['DeviceID'] = metadata.id;
|
||||
// metadata.MessageAttributes['DeviceName'] = Name;
|
||||
// metadata.MessageAttributes['Sensors'] =[{"SensorName":"","Value":"" , "Unit":""}];
|
||||
// metadata.MessageAttributes['TimeStamp'] = "";
|
||||
metadata.Interval = Intrval;
|
||||
metadata.FurtherDetails = FurtherDetails;
|
||||
metadata.SSNmetadata = SSNmetadata;
|
||||
metadata.MetaHash = ChainUtil.hash(SSNmetadata);
|
||||
Metadata.signMetadata(metadata, senderWallet);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
static newMetadata(senderWallet,Name,Geo ,IP_URL , Topic_Token, Permission, RequestDetail,
|
||||
OrgOwner, DepOwner,PrsnOwner, PaymentPerKbyte, PaymentPerMinute, Protocol, MessageAttributes,
|
||||
Interval, FurtherDetails, SSNmetadata){
|
||||
return Metadata.MetadataOfIoTDevice(senderWallet, Name,Geo ,IP_URL , Topic_Token, Permission,
|
||||
RequestDetail, OrgOwner, DepOwner,PrsnOwner, PaymentPerKbyte, PaymentPerMinute, Protocol,
|
||||
MessageAttributes, Interval, FurtherDetails, SSNmetadata
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
static signMetadata (metadata, senderWallet) {
|
||||
metadata.Signiture = {
|
||||
timestamp: Date.now(),
|
||||
address: senderWallet.publicKey,
|
||||
signature: senderWallet.sign(ChainUtil.hash(metadata.SSNmetadata))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static verifyMetadata(metadata) {
|
||||
return ChainUtil.verifySignature(
|
||||
metadata.Signiture.address,
|
||||
metadata.Signiture.signature,
|
||||
ChainUtil.hash(metadata.SSNmetadata)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Metadata;
|
Loading…
Add table
Add a link
Reference in a new issue