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.1 to 0.3.2

47

lib/Credentials.js

@@ -17,2 +17,6 @@ 'use strict';

var _nets = require('nets');
var _nets2 = _interopRequireDefault(_nets);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -77,6 +81,39 @@

profile = _ref.profile;
return _extends({}, profile, payload.own || {}, { address: payload.iss });
return _extends({}, profile, payload.own || {}, payload.capabilities && payload.capabilities.length === 1 ? { pushToken: payload.capabilities[0] } : {}, { address: payload.iss });
});
}
}, {
key: 'push',
value: function push(token, _ref2) {
var url = _ref2.url;
return new Promise(function (resolve, reject) {
if (!token) {
return reject(new Error('Missing push notification token'));
}
if (!url) {
return reject(new Error('Missing payload url for sending to users device'));
}
(0, _nets2.default)({
uri: 'https://chasqui.uport.me/api/v1/sns',
json: { url: url },
method: 'POST',
withCredentials: false,
headers: {
Authorization: 'Bearer ' + token
}
}, function (error, res, body) {
if (error) return reject(error);
if (res.statusCode === 200) {
resolve(body);
}
if (res.statusCode === 403) {
return reject(new Error('Error sending push notification to user: Invalid Token'));
}
reject(new Error('Error sending push notification to user: ' + res.statusCode + ' ' + body.toString()));
});
});
}
// Create attestation

@@ -86,6 +123,6 @@

key: 'attest',
value: function attest(_ref2) {
var sub = _ref2.sub,
claim = _ref2.claim,
exp = _ref2.exp;
value: function attest(_ref3) {
var sub = _ref3.sub,
claim = _ref3.claim,
exp = _ref3.exp;

@@ -92,0 +129,0 @@ return (0, _JWT.createJWT)(this.settings, { sub: sub, claim: claim, exp: exp });

11

package.json
{
"name": "uport",
"version": "0.3.1",
"version": "0.3.2",
"description": "Library for interacting with uport profiles and attestations",

@@ -22,7 +22,11 @@ "main": "lib/index.js",

"jsontokens": "^0.6.5",
"uport-lite": "^0.2.2"
"nets": "^3.2.0",
"uport-lite": "^0.2.4"
},
"jest": {
"coverageDirectory": "./coverage/",
"collectCoverage": true
"collectCoverage": true,
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/nock"
]
},

@@ -43,4 +47,5 @@ "devDependencies": {

"mockdate": "^2.0.1",
"nock": "^9.0.6",
"webpack": "^1.14.0"
}
}

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

// Coming soon, not yet implemented
credentials.pushTo(pushToken, attestation).then(response => {
credentials.push(pushToken, `me.uport:add?attestation=${attestationjwt}`, message).then(response => {

@@ -147,0 +147,0 @@ })

import { createJWT, verifyJWT } from './JWT'
import UportLite from 'uport-lite'
import nets from 'nets'

@@ -36,6 +37,37 @@ export default class Credentials {

return verifyJWT(this.settings, token, callbackUrl).then(({payload, profile}) => (
{...profile, ...(payload.own || {}), address: payload.iss}
{...profile, ...(payload.own || {}), ...(payload.capabilities && payload.capabilities.length === 1 ? {pushToken: payload.capabilities[0]} : {}), address: payload.iss}
))
}
push (token, {url}) {
return new Promise((resolve, reject) => {
if (!token) {
return reject(new Error('Missing push notification token'))
}
if (!url) {
return reject(new Error('Missing payload url for sending to users device'))
}
nets({
uri: 'https://chasqui.uport.me/api/v1/sns',
json: {url},
method: 'POST',
withCredentials: false,
headers: {
Authorization: `Bearer ${token}`
}
},
(error, res, body) => {
if (error) return reject(error)
if (res.statusCode === 200) {
resolve(body)
}
if (res.statusCode === 403) {
return reject(new Error('Error sending push notification to user: Invalid Token'))
}
reject(new Error(`Error sending push notification to user: ${res.statusCode} ${body.toString()}`))
})
})
}
// Create attestation

@@ -42,0 +74,0 @@ attest ({sub, claim, exp}) {

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