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

uport

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uport - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0-alpha-1

22

lib/Credentials.js

@@ -7,2 +7,4 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -35,5 +37,6 @@

this.settings = settings;
this.settings.networks = settings.networks ? configNetworks(settings.networks) : {};
if (!this.settings.registry) {
(function () {
var registry = (0, _uportLite2.default)();
var registry = (0, _uportLite2.default)({ networks: _this.settings.networks });
_this.settings.registry = function (address) {

@@ -160,2 +163,17 @@ return new Promise(function (resolve, reject) {

exports.default = Credentials;
exports.default = Credentials;
var configNetworks = function configNetworks(nets) {
Object.keys(nets).forEach(function (key) {
var net = nets[key];
if ((typeof net === 'undefined' ? 'undefined' : _typeof(net)) === 'object') {
['registry', 'rpcUrl'].forEach(function (key) {
if (!net.hasOwnProperty(key)) throw new Error('Malformed network config object, object must have \'' + key + '\' key specified.');
});
} else {
throw new Error('Network configuration object required');
}
});
return nets;
};

9

lib/JWT.js

@@ -14,2 +14,4 @@ 'use strict';

var _mnid = require('mnid');
var JOSE_HEADER = { typ: 'JWT', alg: 'ES256K' };

@@ -50,7 +52,10 @@

if (payload.aud) {
if (payload.aud.match(/^0x[0-9a-fA-F]+$/)) {
if (payload.aud.match(/^0x[0-9a-fA-F]+$/) || (0, _mnid.isMNID)(payload.aud)) {
if (!address) {
return reject(new Error('JWT audience is required but your app address has not been configured'));
}
if (payload.aud !== address) {
var addressHex = (0, _mnid.isMNID)(address) ? (0, _mnid.decode)(address).address : address;
var audHex = (0, _mnid.isMNID)(payload.aud) ? (0, _mnid.decode)(payload.aud).address : payload.aud;
if (audHex !== addressHex) {
return reject(new Error('JWT audience does not match your address'));

@@ -57,0 +62,0 @@ }

{
"name": "uport",
"version": "0.3.3",
"version": "0.4.0-alpha-1",
"description": "Library for interacting with uport profiles and attestations",

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

"jsontokens": "^0.6.5",
"mnid": "^0.1.1",
"nets": "^3.2.0",
"uport-lite": "^0.2.4"
"uport-lite": "next"
},

@@ -26,0 +27,0 @@ "jest": {

@@ -9,3 +9,3 @@ # uport-js

Uport.js provides a simple way for you to integrate uport.js into your javscript application. You can also interact with your uport users directly in the browser.
Uport.js provides a simple way for you to integrate uport.js into your javscript application. You can also interact with your uport users directly in the browser.

@@ -42,7 +42,22 @@ We have an easy to use browser library [uport-connect](https://github.com/uport-project/uport-connect) which can help you do so.

appName: 'App Name',
address: 'UPORT ADDRESS FOR YOUR APP',
signer: signer
address: 'MNID Encoded uPort Address For Your App'
signer: signer,
networks: networks
})
```
Going forward all uPort application ID addresses must be [MNID encoded](https://github.com/uport-project/mnid). MNID will encode the network with the address. Use of hex encoded addresses is deprecated. Using a hex encoded address will indicated you are on ropsten using our deprecated registry, if you require this use case then continue to pass a hex encoded address. If you are on ropsten but using our latest registry, pass a MNID encoded address with ropsten.
The networks object includes a set of networks for which JWTs will be verified over. JWT verification includes an on-chain lookup for the public key mapped to the issuers identity, the MIND encoding of the issuer's address defines the network and registry to use for lookup. If you are interested in verifying JWTs over additional networks, pass in a network configs object, defined as follows:
```javascript
const networks = { id: '0x2a' :
{ registry: '0x5f8e9351dc2d238fb878b6ae43aa740d62fc9758',
rpcUrl: 'https://kovan.infura.io' },
id: .... : { ... }
}
```
Look in [uport-lite](https://github.com/uport-project/uport-lite) for the default networks and registries which will be queried for JWT verification.
## Requesting information from your users

@@ -65,3 +80,3 @@

requested: ['name','phone','identity_no'],
callbackUrl: 'https://....' // URL to send the response of the request to
callbackUrl: 'https://....' // URL to send the response of the request to
}.then(requestToken => {

@@ -68,0 +83,0 @@ // send requestToken to browser

@@ -8,4 +8,5 @@ import { createJWT, verifyJWT } from './JWT'

this.settings = settings
this.settings.networks = settings.networks ? configNetworks(settings.networks) : {}
if (!this.settings.registry) {
const registry = UportLite()
const registry = UportLite({networks: this.settings.networks})
this.settings.registry = (address) => new Promise((resolve, reject) => {

@@ -85,3 +86,3 @@ registry(address, (error, profile) => {

attest ({sub, claim, exp}) {
return createJWT(this.settings, {sub, claim, exp})
return createJWT(this.settings, {sub: sub, claim, exp})
}

@@ -94,1 +95,15 @@

}
const configNetworks = (nets) => {
Object.keys(nets).forEach((key) => {
const net = nets[key]
if (typeof net === 'object') {
['registry', 'rpcUrl'].forEach((key) => {
if (!net.hasOwnProperty(key)) throw new Error(`Malformed network config object, object must have '${key}' key specified.`)
})
} else {
throw new Error(`Network configuration object required`)
}
})
return nets
}

@@ -1,6 +0,6 @@

import { createUnsignedToken, TokenVerifier, decodeToken } from 'jsontokens'
import { createUnsignedToken, TokenVerifier, decodeToken } from 'jsontokens'
import { isMNID, decode} from 'mnid'
const JOSE_HEADER = {typ: 'JWT', alg: 'ES256K'}
export function createJWT ({address, signer}, payload) {

@@ -33,7 +33,10 @@ const signingInput = createUnsignedToken(

if (payload.aud) {
if (payload.aud.match(/^0x[0-9a-fA-F]+$/)) {
if (payload.aud.match(/^0x[0-9a-fA-F]+$/) || isMNID(payload.aud)) {
if (!address) {
return reject(new Error('JWT audience is required but your app address has not been configured'))
}
if (payload.aud !== address) {
const addressHex = isMNID(address) ? decode(address).address : address
const audHex = isMNID(payload.aud) ? decode(payload.aud).address : payload.aud
if (audHex !== addressHex) {
return reject(new Error('JWT audience does not match your address'))

@@ -40,0 +43,0 @@ }

Sorry, the diff of this file is too big to display

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