arweave-id
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -10,2 +10,4 @@ "use strict"; | ||
const toUint8Array = require('base64-to-uint8array'); | ||
const xss_1 = require("xss"); | ||
const v1claimed_1 = __importDefault(require("./v1claimed")); | ||
/** | ||
@@ -43,9 +45,9 @@ * Function to get an ArweaveId object for the supplied arweave address. | ||
case 'Name': | ||
id.name = tag['value']; | ||
id.name = xss_1.filterXSS(tag['value']); | ||
break; | ||
case 'Url': | ||
id.url = tag['value']; | ||
id.url = xss_1.filterXSS(tag['value']); | ||
break; | ||
case 'Text': | ||
id.text = tag['value']; | ||
id.text = xss_1.filterXSS(tag['value']); | ||
break; | ||
@@ -124,8 +126,8 @@ case 'Content-Type': | ||
transaction.addTag('App-Version', '0.0.2'); | ||
transaction.addTag('Name', arweaveIdData.name.trim()); | ||
transaction.addTag('Name', xss_1.filterXSS(arweaveIdData.name.trim())); | ||
if ((arweaveIdData.text !== undefined) && (arweaveIdData.text !== '')) { | ||
transaction.addTag('Text', arweaveIdData.text); | ||
transaction.addTag('Text', xss_1.filterXSS(arweaveIdData.text)); | ||
} | ||
if ((arweaveIdData.url !== undefined) && (arweaveIdData.url !== '')) { | ||
transaction.addTag('Url', arweaveIdData.url); | ||
transaction.addTag('Url', xss_1.filterXSS(arweaveIdData.url)); | ||
} | ||
@@ -148,3 +150,7 @@ mediaType.length === 0 ? mediaType = 'none' : transaction.addTag('Content-Type', mediaType); | ||
async function check(name, arweaveInstance) { | ||
const query = `query { transactions(tags: [{name:"App-Name", value:"arweave-id"}, {name:"Name", value:"${name}"}]) {id tags{name value}}}`; | ||
let _name = xss_1.filterXSS(name); | ||
if (v1claimed_1.default[_name] !== undefined) { | ||
return v1claimed_1.default[_name]; | ||
} | ||
const query = `query { transactions(tags: [{name:"App-Name", value:"arweave-id"}, {name:"Name", value:"${_name}"}]) {id tags{name value}}}`; | ||
let res = await arweaveInstance.api.post('arql', { query: query }); | ||
@@ -151,0 +157,0 @@ let arweaveIDTxns = res.data.data.transactions; // Gets all transactions that claim 'arweaveID' |
{ | ||
"name": "arweave-id", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "", | ||
@@ -36,4 +36,5 @@ "main": "build/src/index.js", | ||
"identicon.js": "^2.3.3", | ||
"jshashes": "^1.0.8" | ||
"jshashes": "^1.0.8", | ||
"xss": "^1.0.7" | ||
} | ||
} |
@@ -11,2 +11,5 @@ # arweave-id Version 2 | ||
## Basic Usage | ||
Install using `npm install arweave-id` then do | ||
```javascript | ||
@@ -36,2 +39,3 @@ import Arweave from 'arweave/web' | ||
`get(address: string, arweaveInstance: Arweave): Promise<ArweaveId>` | ||
Looks up the ArweaveID associated with a given Arweave address and returns all available data elements | ||
@@ -48,2 +52,3 @@ | ||
`set(arweaveIdData: ArweaveId, jwk: JWKInterface, arweaveInstance: Arweave ): Promise<ISetReturn>` | ||
Creates, signs, and submits an arweave-id transaction claiming ownership of the ArweaveId provided. | ||
@@ -64,2 +69,3 @@ | ||
`check(name: string, arweaveInstance: IArweave): Promise<string>` | ||
Look up an arweave-id name to see if it's available, returns an empty string `''` or the owners address. | ||
@@ -76,2 +82,3 @@ | ||
`getIdenticon(name: string): string` | ||
This function is provided as a method of generating an avatar for the user. Example usage, when the optional avatar has not been set. | ||
@@ -78,0 +85,0 @@ |
Sorry, the diff of this file is not supported yet
68095
18
993
86
5
+ Addedxss@^1.0.7
+ Addedcommander@2.20.3(transitive)
+ Addedcssfilter@0.0.10(transitive)
+ Addedxss@1.0.15(transitive)