New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uport-lite

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uport-lite - npm Package Compare versions

Comparing version 1.0.0-alpha-2 to 1.0.0-alpha-3

278

dist/uport-lite.js

@@ -14,10 +14,10 @@ (function webpackUniversalModuleDefinition(root, factory) {

/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -29,23 +29,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports

@@ -61,3 +61,3 @@ /******/ __webpack_require__.d = function(exports, name, getter) {

/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules

@@ -71,11 +71,11 @@ /******/ __webpack_require__.n = function(module) {

/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ })

@@ -179,3 +179,3 @@ /************************************************************************/

/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)))
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))

@@ -186,28 +186,4 @@ /***/ }),

module.exports = function(originalModule) {
if(!originalModule.webpackPolyfill) {
var module = Object.create(originalModule);
// module.parent = undefined by default
if(!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
Object.defineProperty(module, "exports", {
enumerable: true,
});
module.webpackPolyfill = 1;
}
return module;
};
/* (ignored) */
/***/ }),

@@ -217,8 +193,2 @@ /* 2 */

/* (ignored) */
/***/ }),
/* 3 */
/***/ (function(module, exports) {
var g;

@@ -248,71 +218,71 @@

/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(module) {Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony export (immutable) */ __webpack_exports__["eaeDecode"] = eaeDecode;
var BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
var base58 = __webpack_require__(0)(BASE58)
var hex = __webpack_require__(0)('0123456789abcdef')
const XMLHttpRequest = (typeof window !== 'undefined') ? window.XMLHttpRequest : __webpack_require__(2).XMLHttpRequest
const functionSignature = '0x447885f0'
var BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
var base58 = __webpack_require__(0)(BASE58);
var hex = __webpack_require__(0)('0123456789abcdef');
var XMLHttpRequest = typeof window !== 'undefined' ? window.XMLHttpRequest : __webpack_require__(1).XMLHttpRequest;
var functionSignature = '0x447885f0';
// Legacy
const getAttributesData = '0x446d5aa4000000000000000000000000'
var getAttributesData = '0x446d5aa4000000000000000000000000';
function http (opts, callback) {
const request = new XMLHttpRequest() // eslint-disable-line
const options = opts || {}
function http(opts, callback) {
var request = new XMLHttpRequest(); // eslint-disable-line
var options = opts || {};
request.onreadystatechange = () => {
request.onreadystatechange = function () {
if (request.readyState === 4 && request.timeout !== 1) {
if (request.status !== 200) {
callback(new Error(`[uport-lite] status ${request.status}: ${request.responseText}`))
callback(new Error('[uport-lite] status ' + request.status + ': ' + request.responseText));
} else {
try {
callback(null, JSON.parse(request.responseText))
callback(null, JSON.parse(request.responseText));
} catch (jsonError) {
callback(new Error(`[uport-lite] while parsing data: '${String(request.responseText)}', error: ${String(jsonError)}`))
callback(new Error('[uport-lite] while parsing data: \'' + String(request.responseText) + '\', error: ' + String(jsonError)));
}
}
}
}
};
if (options.data) {
request.open('POST', opts.uri)
request.open('POST', opts.uri);
} else {
request.open('GET', opts.uri)
request.open('GET', opts.uri);
}
if (options.accept) {
request.setRequestHeader('accept', options.accept)
request.setRequestHeader('accept', options.accept);
}
if (options.data) {
request.setRequestHeader('Content-Type', `application/json`)
request.send(JSON.stringify(options.data))
request.setRequestHeader('Content-Type', 'application/json');
request.send(JSON.stringify(options.data));
} else {
request.send()
request.send();
}
}
function registryEncodingToIPFS (hexStr) {
return base58.encode(hex.decode('1220' + hexStr.slice(2)))
function registryEncodingToIPFS(hexStr) {
return base58.encode(hex.decode('1220' + hexStr.slice(2)));
}
// to avoid adding further dependencies we are not verifying checksum
function eaeDecode (encoded) {
const data = base58.decode(encoded)
const netLength = data.length - 24
const network = data.slice(1, netLength)
const address = data.slice(netLength, 20 + netLength)
function eaeDecode(encoded) {
var data = base58.decode(encoded);
var netLength = data.length - 24;
var network = data.slice(1, netLength);
var address = data.slice(netLength, 20 + netLength);
return {
network: `0x${hex.encode(network)}`,
address: `0x${hex.encode(address)}`
}
network: '0x' + hex.encode(network),
address: '0x' + hex.encode(address)
};
}
const defaultNetworks = {
var defaultNetworks = {
'0x1': {

@@ -329,47 +299,49 @@ registry: '0xab5c8051b9a1df1aab0149f8b0630848b7ecabf6',

rpcUrl: 'https://kovan.infura.io'
// },
// '0x16B2': {
// registry: '',
// rpcUrl: 'https://infuranet.infura.io'
// },
// '0x16B2': {
// registry: '',
// rpcUrl: 'https://infuranet.infura.io'
}
}
};
function toBase58 (hexStr) {
return base58.encode(hex.decode(hexStr))
function toBase58(hexStr) {
return base58.encode(hex.decode(hexStr));
}
function UportLite (opts = {}) {
const infuraKey = opts.infuraKey || 'uport-lite-library'
const ipfsGw = opts.ipfsGw || 'https://ipfs.infura.io/ipfs/'
const networks = opts.networks ? Object.assign({}, defaultNetworks, opts.networks) : defaultNetworks
function asciiToHex (string, delim) {
function UportLite() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var infuraKey = opts.infuraKey || 'uport-lite-library';
var ipfsGw = opts.ipfsGw || 'https://ipfs.infura.io/ipfs/';
var networks = opts.networks ? Object.assign({}, defaultNetworks, opts.networks) : defaultNetworks;
function asciiToHex(string, delim) {
return string.split('').map(function (c) {
return ('0' + c.charCodeAt(0).toString(16)).slice(-2)
}).join(delim || '')
return ('0' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(delim || '');
}
function pad (pad, str, padLeft) {
function pad(pad, str, padLeft) {
if (typeof str === 'undefined') {
return pad
return pad;
}
if (padLeft) {
return (pad + str).slice(-pad.length)
return (pad + str).slice(-pad.length);
} else {
return (str + pad).substring(0, pad.length)
return (str + pad).substring(0, pad.length);
}
}
function encodeFunctionCall (functionSignature, registrationIdentifier, issuer, subject) {
var callString = functionSignature
callString += pad('0000000000000000000000000000000000000000000000000000000000000000', asciiToHex(registrationIdentifier))
callString += pad('0000000000000000000000000000000000000000000000000000000000000000', issuer.slice(2), true)
callString += pad('0000000000000000000000000000000000000000000000000000000000000000', subject.slice(2), true)
return callString
function encodeFunctionCall(functionSignature, registrationIdentifier, issuer, subject) {
var callString = functionSignature;
callString += pad('0000000000000000000000000000000000000000000000000000000000000000', asciiToHex(registrationIdentifier));
callString += pad('0000000000000000000000000000000000000000000000000000000000000000', issuer.slice(2), true);
callString += pad('0000000000000000000000000000000000000000000000000000000000000000', subject.slice(2), true);
return callString;
}
// TODO remove once feasible
function callLegacyRegistry (address, callback) {
const rpcUrl = `https://ropsten.infura.io/${infuraKey}`
if (!address) return callback(null)
function callLegacyRegistry(address, callback) {
var rpcUrl = 'https://ropsten.infura.io/' + infuraKey;
if (!address) return callback(null);
return http({

@@ -380,77 +352,71 @@ uri: rpcUrl,

method: 'eth_call',
params: [
{to: '0xb9C1598e24650437a3055F7f66AC1820c419a679', data: (getAttributesData + address.slice(2))},
'latest'
],
params: [{ to: '0xb9C1598e24650437a3055F7f66AC1820c419a679', data: getAttributesData + address.slice(2) }, 'latest'],
id: 1,
jsonrpc: '2.0'
}
}, (error, response) => {
if (error) return callback(error)
const hexHash = response.result.slice(130).slice(0, 68)
return callback(null, toBase58(hexHash))
})
}, function (error, response) {
if (error) return callback(error);
var hexHash = response.result.slice(130).slice(0, 68);
return callback(null, toBase58(hexHash));
});
}
function callRegistry (registrationIdentifier, issuerId, subjectId, callback) {
const issuer = eaeDecode(issuerId)
const subject = eaeDecode(subjectId)
function callRegistry(registrationIdentifier, issuerId, subjectId, callback) {
var issuer = eaeDecode(issuerId);
var subject = eaeDecode(subjectId);
if (issuer.network !== subject.network) {
throw new Error('Issuer and subject must be on the same network')
throw new Error('Issuer and subject must be on the same network');
}
if (!networks[issuer.network]) {
throw new Error(`Network id ${issuer.network} is not configured`)
throw new Error('Network id ' + issuer.network + ' is not configured');
}
const rpcUrl = networks[issuer.network].rpcUrl
const registryAddress = networks[issuer.network].registry
const callString = encodeFunctionCall(functionSignature, registrationIdentifier, issuer.address, subject.address)
var rpcUrl = networks[issuer.network].rpcUrl;
var registryAddress = networks[issuer.network].registry;
var callString = encodeFunctionCall(functionSignature, registrationIdentifier, issuer.address, subject.address);
return http({
uri: `${rpcUrl}/${infuraKey}`,
uri: rpcUrl + '/' + infuraKey,
accept: 'application/json',
data: {
method: 'eth_call',
params: [
{to: registryAddress, data: (callString)},
'latest'
],
params: [{ to: registryAddress, data: callString }, 'latest'],
id: 1,
jsonrpc: '2.0'
}
}, (error, response) => {
if (error) return callback(error)
if (response.result == 0) return callback(error)
return callback(null, registryEncodingToIPFS(response.result))
})
}, function (error, response) {
if (error) return callback(error);
if (response.result == 0) return callback(error);
return callback(null, registryEncodingToIPFS(response.result));
});
}
function fetchIpfs (ipfsHash, callback) {
if (!ipfsHash || ipfsHash === '0x') return callback()
return http({uri: `${ipfsGw}${ipfsHash}`}, callback)
function fetchIpfs(ipfsHash, callback) {
if (!ipfsHash || ipfsHash === '0x') return callback();
return http({ uri: '' + ipfsGw + ipfsHash }, callback);
}
function get (issuer, callback, subjectAddress, registrationIdentifier = 'uPortProfileIPFS1220') {
if (!issuer) return callback(null)
const subject = subjectAddress || issuer
function get(issuer, callback, subjectAddress) {
var registrationIdentifier = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'uPortProfileIPFS1220';
if (!issuer) return callback(null);
var subject = subjectAddress || issuer;
if (issuer.match(/0x[0-9a-fA-F]{40}/)) {
return callLegacyRegistry(issuer, (error, ipfsHash) => {
if (error) return callback(error)
fetchIpfs(ipfsHash, callback)
})
return callLegacyRegistry(issuer, function (error, ipfsHash) {
if (error) return callback(error);
fetchIpfs(ipfsHash, callback);
});
} else {
return callRegistry(registrationIdentifier, issuer, subject, (error, ipfsHash) => {
if (error) return callback(error)
fetchIpfs(ipfsHash, callback)
})
return callRegistry(registrationIdentifier, issuer, subject, function (error, ipfsHash) {
if (error) return callback(error);
fetchIpfs(ipfsHash, callback);
});
}
}
return get
return get;
}
module.exports = UportLite
module.exports = UportLite;
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(1)(module)))
/***/ })
/******/ ]);
});

@@ -1,13 +0,12 @@

var $jscomp={scope:{},owns:function(a,b){return Object.prototype.hasOwnProperty.call(a,b)}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var f=a[d];f in c||(c[f]={});c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Object.assign",function(a){return a?a:function(b,a){for(var d=1;d<arguments.length;d++){var f=arguments[d];if(f)for(var c in f)$jscomp.owns(f,c)&&(b[c]=f[c])}return b}},"es6-impl","es3");
(function(a,b){"object"===typeof exports&&"object"===typeof module?module.exports=b():"function"===typeof define&&define.amd?define("UportLite",[],b):"object"===typeof exports?exports.UportLite=b():a.UportLite=b()})(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var f=c[d]={i:d,l:!1,exports:{}};a[d].call(f.exports,f,f.exports,b);f.l=!0;return f.exports}var c={};b.m=a;b.c=c;b.i=function(b){return b};b.d=function(d,a,c){b.o(d,a)||Object.defineProperty(d,a,{configurable:!1,
enumerable:!0,get:c})};b.n=function(d){var a=d&&d.__esModule?function(){return d["default"]}:function(){return d};b.d(a,"a",a);return a};b.o=function(b,a){return Object.prototype.hasOwnProperty.call(b,a)};b.p="";return b(b.s=4)}([function(a,b,c){(function(b){var d=b&&b.Buffer?b.Buffer:Uint8Array;a.exports=function(b){function a(b){if(0===b.length)return new d(0);for(var a=[0],g=0;g<b.length;g++){var e=c[b[g]];if(void 0===e)return;for(var h=0;h<a.length;++h)e+=a[h]*f,a[h]=e&255,e>>=8;for(;0<e;)a.push(e&
255),e>>=8}for(g=0;b[g]===l&&g<b.length-1;++g)a.push(0);return d.from(a.reverse())}for(var c={},f=b.length,l=b.charAt(0),e=0;e<b.length;e++){var q=b.charAt(e);if(void 0!==c[q])throw new TypeError(q+" is ambiguous");c[q]=e}return{encode:function(a){if(0===a.length)return"";for(var d=[0],c=0;c<a.length;++c){for(var g=0,e=a[c];g<d.length;++g)e+=d[g]<<8,d[g]=e%f,e=e/f|0;for(;0<e;)d.push(e%f),e=e/f|0}c="";for(g=0;0===a[g]&&g<a.length-1;++g)c+=b[0];for(a=d.length-1;0<=a;--a)c+=b[d[a]];return c},decodeUnsafe:a,
decode:function(b){if(b=a(b))return b;throw Error("Non-base"+f+" character");}}}}).call(b,c(3))},function(a,b){a.exports=function(b){if(!b.webpackPolyfill){var a=Object.create(b);a.children||(a.children=[]);Object.defineProperty(a,"loaded",{enumerable:!0,get:function(){return a.l}});Object.defineProperty(a,"id",{enumerable:!0,get:function(){return a.i}});Object.defineProperty(a,"exports",{enumerable:!0});a.webpackPolyfill=1}return a}},function(a,b){},function(a,b){b=function(){return this}();try{b=
b||Function("return this")()||(0,eval)("this")}catch(c){"object"===typeof window&&(b=window)}a.exports=b},function(a,b,c){(function(a){function d(a,b){var c=new p,d=a||{};c.onreadystatechange=function(){if(4===c.readyState&&1!==c.timeout)if(200!==c.status)b(Error("[uport-lite] status "+c.status+": "+c.responseText));else try{b(null,JSON.parse(c.responseText))}catch(u){b(Error("[uport-lite] while parsing data: '"+String(c.responseText)+"', error: "+String(u)))}};d.data?c.open("POST",a.uri):c.open("GET",
a.uri);d.accept&&c.setRequestHeader("accept",d.accept);d.data?(c.setRequestHeader("Content-Type","application/json"),c.send(JSON.stringify(d.data))):c.send()}function m(a){var b=n.decode(a),c=b.length-24;a=b.slice(1,c);b=b.slice(c,20+c);return{network:"0x"+k.encode(a),address:"0x"+k.encode(b)}}Object.defineProperty(b,"__esModule",{value:!0});b.eaeDecode=m;var n=c(0)("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),k=c(0)("0123456789abcdef"),p="undefined"!==typeof window?window.XMLHttpRequest:
c(2).XMLHttpRequest,l={"0x1":{registry:"0xab5c8051b9a1df1aab0149f8b0630848b7ecabf6",rpcUrl:"https://mainnet.infura.io"},"0x3":{registry:"0x41566e3a081f5032bdcad470adb797635ddfe1f0",rpcUrl:"https://ropsten.infura.io"},"0x2a":{registry:"0x5f8e9351dc2d238fb878b6ae43aa740d62fc9758",rpcUrl:"https://kovan.infura.io"}};a.exports=function(a){function b(a,b){return a.split("").map(function(a){return("0"+a.charCodeAt(0).toString(16)).slice(-2)}).join(b||"")}function c(a,b,c){return"undefined"===typeof b?a:
c?(a+b).slice(-a.length):(b+a).substring(0,a.length)}function f(a,d,f,e){a+=c("0000000000000000000000000000000000000000000000000000000000000000",b(d));a+=c("0000000000000000000000000000000000000000000000000000000000000000",f.slice(2),!0);return a+=c("0000000000000000000000000000000000000000000000000000000000000000",e.slice(2),!0)}function e(a,b){var c="https://ropsten.infura.io/"+t;return a?d({uri:c,accept:"application/json",data:{method:"eth_call",params:[{to:"0xb9C1598e24650437a3055F7f66AC1820c419a679",
data:"0x446d5aa4000000000000000000000000"+a.slice(2)},"latest"],id:1,jsonrpc:"2.0"}},function(a,c){if(a)return b(a);a=c.result.slice(130).slice(0,68);return b(null,n.encode(k.decode(a)))}):b(null)}function p(a,b,c,e){b=m(b);var g=m(c);if(b.network!==g.network)throw Error("Issuer and subject must be on the same network");if(!r[b.network])throw Error("Network id "+b.network+" is not configured");c=r[b.network].rpcUrl;var v=r[b.network].registry;a=f("0x447885f0",a,b.address,g.address);return d({uri:c+
"/"+t,accept:"application/json",data:{method:"eth_call",params:[{to:v,data:a},"latest"],id:1,jsonrpc:"2.0"}},function(a,b){return a||0==b.result?e(a):e(null,n.encode(k.decode("1220"+b.result.slice(2))))})}function h(a,b){return a&&"0x"!==a?d({uri:""+w+a},b):b()}a=void 0===a?{}:a;var t=a.infuraKey||"uport-lite-library",w=a.ipfsGw||"https://ipfs.infura.io/ipfs/",r=a.networks?Object.assign({},l,a.networks):l;return function(a,b,c,d){d=void 0===d?"uPortProfileIPFS1220":d;if(!a)return b(null);c=c||a;return a.match(/0x[0-9a-fA-F]{40}/)?
e(a,function(a,c){if(a)return b(a);h(c,b)}):p(d,a,c,function(a,c){if(a)return b(a);h(c,b)})}}}).call(b,c(1)(a))}])});
var $jscomp={scope:{},owns:function(b,a){return Object.prototype.hasOwnProperty.call(b,a)}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(b,a,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");b!=Array.prototype&&b!=Object.prototype&&(b[a]=c.value)};$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(b,a,c,d){if(a){c=$jscomp.global;b=b.split(".");for(d=0;d<b.length-1;d++){var e=b[d];e in c||(c[e]={});c=c[e]}b=b[b.length-1];d=c[b];a=a(d);a!=d&&null!=a&&$jscomp.defineProperty(c,b,{configurable:!0,writable:!0,value:a})}};$jscomp.polyfill("Object.assign",function(b){return b?b:function(a,b){for(var d=1;d<arguments.length;d++){var e=arguments[d];if(e)for(var c in e)$jscomp.owns(e,c)&&(a[c]=e[c])}return a}},"es6-impl","es3");
(function(b,a){"object"===typeof exports&&"object"===typeof module?module.exports=a():"function"===typeof define&&define.amd?define("UportLite",[],a):"object"===typeof exports?exports.UportLite=a():b.UportLite=a()})(this,function(){return function(b){function a(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};b[d].call(e.exports,e,e.exports,a);e.l=!0;return e.exports}var c={};a.m=b;a.c=c;a.i=function(a){return a};a.d=function(b,e,c){a.o(b,e)||Object.defineProperty(b,e,{configurable:!1,
enumerable:!0,get:c})};a.n=function(b){var c=b&&b.__esModule?function(){return b["default"]}:function(){return b};a.d(c,"a",c);return c};a.o=function(b,a){return Object.prototype.hasOwnProperty.call(b,a)};a.p="";return a(a.s=3)}([function(b,a,c){(function(a){var c=a&&a.Buffer?a.Buffer:Uint8Array;b.exports=function(a){function b(a){if(0===a.length)return new c(0);for(var b=[0],f=0;f<a.length;f++){var h=d[a[f]];if(void 0===h)return;for(var g=0;g<b.length;++g)h+=b[g]*e,b[g]=h&255,h>>=8;for(;0<h;)b.push(h&
255),h>>=8}for(f=0;a[f]===v&&f<a.length-1;++f)b.push(0);return c.from(b.reverse())}for(var d={},e=a.length,v=a.charAt(0),g=0;g<a.length;g++){var f=a.charAt(g);if(void 0!==d[f])throw new TypeError(f+" is ambiguous");d[f]=g}return{encode:function(b){if(0===b.length)return"";for(var c=[0],f=0;f<b.length;++f){for(var d=0,g=b[f];d<c.length;++d)g+=c[d]<<8,c[d]=g%e,g=g/e|0;for(;0<g;)c.push(g%e),g=g/e|0}f="";for(d=0;0===b[d]&&d<b.length-1;++d)f+=a[0];for(b=c.length-1;0<=b;--b)f+=a[c[b]];return f},decodeUnsafe:b,
decode:function(a){if(a=b(a))return a;throw Error("Non-base"+e+" character");}}}}).call(a,c(2))},function(b,a){},function(b,a){a=function(){return this}();try{a=a||Function("return this")()||(0,eval)("this")}catch(c){"object"===typeof window&&(a=window)}b.exports=a},function(b,a,c){function d(a,b){var c=new p,d=a||{};c.onreadystatechange=function(){if(4===c.readyState&&1!==c.timeout)if(200!==c.status)b(Error("[uport-lite] status "+c.status+": "+c.responseText));else try{b(null,JSON.parse(c.responseText))}catch(n){b(Error("[uport-lite] while parsing data: '"+
String(c.responseText)+"', error: "+String(n)))}};d.data?c.open("POST",a.uri):c.open("GET",a.uri);d.accept&&c.setRequestHeader("accept",d.accept);d.data?(c.setRequestHeader("Content-Type","application/json"),c.send(JSON.stringify(d.data))):c.send()}function e(a){var b=m.decode(a),c=b.length-24;a=b.slice(1,c);b=b.slice(c,20+c);return{network:"0x"+k.encode(a),address:"0x"+k.encode(b)}}var m=c(0)("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),k=c(0)("0123456789abcdef"),p="undefined"!==
typeof window?window.XMLHttpRequest:c(1).XMLHttpRequest,u={"0x1":{registry:"0xab5c8051b9a1df1aab0149f8b0630848b7ecabf6",rpcUrl:"https://mainnet.infura.io"},"0x3":{registry:"0x41566e3a081f5032bdcad470adb797635ddfe1f0",rpcUrl:"https://ropsten.infura.io"},"0x2a":{registry:"0x5f8e9351dc2d238fb878b6ae43aa740d62fc9758",rpcUrl:"https://kovan.infura.io"}};b.exports=function(){function b(a,b){return a.split("").map(function(a){return("0"+a.charCodeAt(0).toString(16)).slice(-2)}).join(b||"")}function a(a,b,
c){return"undefined"===typeof b?a:c?(a+b).slice(-a.length):(b+a).substring(0,a.length)}function c(c,d,e,f){c+=a("0000000000000000000000000000000000000000000000000000000000000000",b(d));c+=a("0000000000000000000000000000000000000000000000000000000000000000",e.slice(2),!0);return c+=a("0000000000000000000000000000000000000000000000000000000000000000",f.slice(2),!0)}function h(a,b){var c="https://ropsten.infura.io/"+t;return a?d({uri:c,accept:"application/json",data:{method:"eth_call",params:[{to:"0xb9C1598e24650437a3055F7f66AC1820c419a679",
data:"0x446d5aa4000000000000000000000000"+a.slice(2)},"latest"],id:1,jsonrpc:"2.0"}},function(a,c){if(a)return b(a);a=c.result.slice(130).slice(0,68);return b(null,m.encode(k.decode(a)))}):b(null)}function n(a,b,f,g){b=e(b);var h=e(f);if(b.network!==h.network)throw Error("Issuer and subject must be on the same network");if(!q[b.network])throw Error("Network id "+b.network+" is not configured");f=q[b.network].rpcUrl;var w=q[b.network].registry;a=c("0x447885f0",a,b.address,h.address);return d({uri:f+
"/"+t,accept:"application/json",data:{method:"eth_call",params:[{to:w,data:a},"latest"],id:1,jsonrpc:"2.0"}},function(a,b){return a||0==b.result?g(a):g(null,m.encode(k.decode("1220"+b.result.slice(2))))})}function r(a,b){return a&&"0x"!==a?d({uri:""+p+a},b):b()}var l=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=l.infuraKey||"uport-lite-library",p=l.ipfsGw||"https://ipfs.infura.io/ipfs/",q=l.networks?Object.assign({},u,l.networks):u;return function(a,b,c){var d=3<arguments.length&&void 0!==
arguments[3]?arguments[3]:"uPortProfileIPFS1220";if(!a)return b(null);var e=c||a;return a.match(/0x[0-9a-fA-F]{40}/)?h(a,function(a,c){if(a)return b(a);r(c,b)}):n(d,a,e,function(a,c){if(a)return b(a);r(c,b)})}}}])});
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.eaeDecode = eaeDecode;
var BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';

@@ -8,0 +4,0 @@ var base58 = require('base-x-bytearray')(BASE58);

{
"name": "uport-lite",
"version": "1.0.0-alpha-2",
"version": "1.0.0-alpha-3",
"description": "Lightweight library for looking up public profiles on uport-registry",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -52,3 +52,3 @@ var BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

// to avoid adding further dependencies we are not verifying checksum
export function eaeDecode (encoded) {
function eaeDecode (encoded) {
const data = base58.decode(encoded)

@@ -55,0 +55,0 @@ const netLength = data.length - 24

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc