mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
cleanup
This commit is contained in:
parent
cd7cd1e337
commit
99f215300e
@ -4,10 +4,9 @@ import Proof from "./Proof"
|
||||
import PublicKey from "./PublicKey"
|
||||
import Service from "./Service"
|
||||
|
||||
import * as ursa from "ursa"
|
||||
import * as Web3 from "web3"
|
||||
|
||||
const ursa = require('ursa');
|
||||
|
||||
interface IDDO {
|
||||
id: string
|
||||
created?: string
|
||||
@ -20,6 +19,8 @@ interface IDDO {
|
||||
|
||||
export default class DDO {
|
||||
|
||||
public static CONTEXT: string = "https://w3id.org/future-method/v1"
|
||||
|
||||
public static validateSignature(text: string, keyValue: string, signature: string, authenticationType: string) {
|
||||
if ( authenticationType === Authentication.TYPE_RSA ) {
|
||||
// var key = ursa.createPublicKey(keyValue, "utf8")
|
||||
@ -44,7 +45,6 @@ export default class DDO {
|
||||
return false
|
||||
}
|
||||
|
||||
public static CONTEXT: string = "https://w3id.org/future-method/v1"
|
||||
public context: string = DDO.CONTEXT
|
||||
public did: string
|
||||
public created: string
|
||||
@ -151,21 +151,19 @@ export default class DDO {
|
||||
keyType = PublicKey.PEM
|
||||
}
|
||||
if (keyType === PublicKey.PEM ) {
|
||||
var keys = ursa.generatePrivateKey(1024, 65537)
|
||||
const keys = ursa.generatePrivateKey(1024, 65537)
|
||||
const nextIndex = this.publicKeys.length + 1
|
||||
const keyId = (this.did ? this.did : '' ) + "#keys=" + nextIndex
|
||||
var publicKey = new PublicKey({id: keyId, owner: keyId, type: keyType})
|
||||
const keyId = (this.did ? this.did : "" ) + "#keys=" + nextIndex
|
||||
const publicKey = new PublicKey({id: keyId, owner: keyId, type: keyType})
|
||||
publicKey.value = keys.toPublicPem("utf8")
|
||||
this.publicKeys.push(publicKey)
|
||||
|
||||
|
||||
return keys.toPrivatePem("utf8")
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
public addService(data): Service {
|
||||
var service = new Service(data)
|
||||
const service = new Service(data)
|
||||
if (service.id == null ) {
|
||||
service.id = this.did
|
||||
}
|
||||
|
@ -45,26 +45,26 @@ export default class PublicKey {
|
||||
}
|
||||
|
||||
public decodeValue(): string {
|
||||
var value = this.value
|
||||
var buffer
|
||||
let value = this.value
|
||||
let buffer = null
|
||||
switch (this.type) {
|
||||
case PublicKey.PEM:
|
||||
value = this.value
|
||||
break;
|
||||
break
|
||||
case PublicKey.JWK:
|
||||
// TODO: implement
|
||||
break;
|
||||
break
|
||||
case PublicKey.HEX:
|
||||
value = Web3.utils.hexToAscii(this.value)
|
||||
break;
|
||||
break
|
||||
case PublicKey.BASE64:
|
||||
buffer = new Buffer(this.value, 'base64')
|
||||
value = buffer.toString('ascii')
|
||||
break;
|
||||
buffer = new Buffer(this.value, "base64")
|
||||
value = buffer.toString("ascii")
|
||||
break
|
||||
case PublicKey.BASE85:
|
||||
buffer = new Buffer(this.value, 'base85')
|
||||
value = buffer.toString('ascii')
|
||||
break;
|
||||
buffer = new Buffer(this.value, "base85")
|
||||
value = buffer.toString("ascii")
|
||||
break
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user