mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
better default parameter parsing
This commit is contained in:
parent
cb7b8d51f1
commit
783f653119
16
package-lock.json
generated
16
package-lock.json
generated
@ -157,7 +157,7 @@
|
||||
},
|
||||
"@types/events": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "http://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz",
|
||||
"integrity": "sha512-KEIlhXnIutzKwRbQkGWb/I4HFqBuUykAdHgDED6xqwXJfONCjF5VoE0cXEiurh3XauygxzeDzgtXUqvLkxFzzA==",
|
||||
"dev": true
|
||||
},
|
||||
@ -1435,7 +1435,7 @@
|
||||
"dependencies": {
|
||||
"pify": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
||||
}
|
||||
}
|
||||
@ -1500,7 +1500,7 @@
|
||||
"dependencies": {
|
||||
"file-type": {
|
||||
"version": "3.9.0",
|
||||
"resolved": "http://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
|
||||
"integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek="
|
||||
},
|
||||
"get-stream": {
|
||||
@ -1514,7 +1514,7 @@
|
||||
},
|
||||
"pify": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
||||
}
|
||||
}
|
||||
@ -3764,7 +3764,7 @@
|
||||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
|
||||
},
|
||||
"mem": {
|
||||
@ -5519,7 +5519,7 @@
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"path-key": {
|
||||
@ -6523,7 +6523,7 @@
|
||||
},
|
||||
"tar": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
|
||||
"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
|
||||
"requires": {
|
||||
"block-stream": "0.0.9",
|
||||
@ -7101,7 +7101,7 @@
|
||||
},
|
||||
"utf8": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "http://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz",
|
||||
"integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g="
|
||||
},
|
||||
"util": {
|
||||
|
@ -96,7 +96,6 @@ export default class DDO {
|
||||
if (typeof did === "object") {
|
||||
this.readFromData(did)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -195,10 +194,8 @@ export default class DDO {
|
||||
*
|
||||
*/
|
||||
public addSignature(encoding?: string, isEmbedded?: boolean): string {
|
||||
if ( encoding == null ) {
|
||||
encoding = DDO.ENCODING_TYPES.PEM
|
||||
}
|
||||
isEmbedded = isEmbedded == null ? false : isEmbedded
|
||||
encoding = encoding ? encoding : DDO.ENCODING_TYPES.PEM
|
||||
isEmbedded = isEmbedded ? isEmbedded : false
|
||||
|
||||
encoding = encoding.toLowerCase()
|
||||
// generate the key pairs
|
||||
@ -262,10 +259,8 @@ export default class DDO {
|
||||
* hash text
|
||||
*
|
||||
*/
|
||||
public addProof(authIndex, privateKey, signatureText?) {
|
||||
if ( authIndex == null ) {
|
||||
authIndex = 0
|
||||
}
|
||||
public addProof(privateKey: string, authIndex?: number, signatureText?: string) {
|
||||
authIndex = authIndex ? authIndex : 0
|
||||
const authentication = this.authentications[authIndex]
|
||||
|
||||
let publicKey = null
|
||||
@ -531,9 +526,8 @@ export default class DDO {
|
||||
*
|
||||
*/
|
||||
public validateProof(signatureText?: string): boolean {
|
||||
if ( signatureText == null ) {
|
||||
signatureText = this.hashTextList().join()
|
||||
}
|
||||
signatureText = signatureText ? signatureText : this.hashTextList().join()
|
||||
|
||||
if ( !this.isProofDefined() ) {
|
||||
return false
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ describe("libDDO", () => {
|
||||
assert(ddo)
|
||||
const privateKey = ddo.addSignature()
|
||||
assert(privateKey.match("-----BEGIN RSA PRIVATE KEY-----"))
|
||||
ddo.addProof(0, privateKey)
|
||||
ddo.addProof(privateKey)
|
||||
// console.log(ddo.toJSON())
|
||||
assert(ddo.validateProof())
|
||||
})
|
||||
@ -152,7 +152,7 @@ describe("libDDO", () => {
|
||||
assert(ddo)
|
||||
const privateKey = ddo.addSignature("pem", true)
|
||||
assert(privateKey.match("-----BEGIN RSA PRIVATE KEY-----"))
|
||||
ddo.addProof(0, privateKey)
|
||||
ddo.addProof(privateKey)
|
||||
// console.log(ddo.toJSON())
|
||||
assert(ddo.validateProof())
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user