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

uport-did-resolver

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uport-did-resolver - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4-alpha1

lib/register.d.ts

14

lib/__tests__/register-test.js

@@ -28,3 +28,3 @@ 'use strict';

'id': 'did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX#keys-1',
'type': 'Secp256k1VerificationKey2018',
'type': 'EcdsaPublicKeySecp256k1',
'owner': 'did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX',

@@ -37,6 +37,2 @@ 'publicKeyHex': '04613bb3a4874d27032618f020614c21cbe4c4e4781687525f6674089f9bd3d6c7f6eb13569053d31715a3ba32e0b791b97922af6387f087d6b5548c06944ab062'

'publicKeyBase64': 'QCFPBLm5pwmuTOu+haxv0+Vpmr6Rrz/DEEvbcjktQnQ='
}],
'authentication': [{
'type': 'Secp256k1SignatureAuthentication2018',
'publicKey': 'did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX#keys-1'
}]

@@ -57,3 +53,3 @@ };

'id': 'did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX#keys-1',
'type': 'Secp256k1VerificationKey2018',
'type': 'EcdsaPublicKeySecp256k1',
'owner': 'did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX',

@@ -68,7 +64,3 @@ 'publicKeyHex': '04613bb3a4874d27032618f020614c21cbe4c4e4781687525f6674089f9bd3d6c7f6eb13569053d31715a3ba32e0b791b97922af6387f087d6b5548c06944ab062'

'image': { '@type': 'ImageObject', 'name': 'avatar', 'contentUrl': '/ipfs/QmSCnmXC91Arz2gj934Ce4DeR7d9fULWRepjzGMX6SSazB' }
},
'authentication': [{
'type': 'Secp256k1SignatureAuthentication2018',
'publicKey': 'did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX#keys-1'
}]
}
};

@@ -75,0 +67,0 @@

@@ -1,88 +0,107 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
exports.convertToDid = convertToDid;
var _didResolver = require('did-resolver');
var _uportLite = require('uport-lite');
var _uportLite2 = _interopRequireDefault(_uportLite);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var did_resolver_1 = require("did-resolver");
var uport_lite_1 = __importDefault(require("uport-lite"));
function convertToDid(did, legacy) {
var publicKey = [{
id: did + '#keys-1',
type: 'Secp256k1VerificationKey2018',
owner: did,
publicKeyHex: legacy.publicKey.match(/^0x/) ? legacy.publicKey.slice(2) : legacy.publicKey
}];
var authentication = [{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: did + '#keys-1'
}];
if (legacy.publicEncKey) {
publicKey.push({
id: did + '#keys-2',
type: 'Curve25519EncryptionPublicKey',
owner: did,
publicKeyBase64: legacy.publicEncKey
});
}
var doc = {
'@context': 'https://w3id.org/did/v1',
id: did,
publicKey: publicKey,
authentication: authentication
};
if (legacy.name || legacy.description || legacy.image) {
var profile = (0, _assign2.default)({}, legacy);
delete profile['publicKey'];
delete profile['publicEncKey'];
doc.uportProfile = profile;
}
return doc;
var publicKey = [{
id: did + "#keys-1",
type: 'Secp256k1VerificationKey2018',
owner: did,
publicKeyHex: legacy.publicKey.match(/^0x/) ? legacy.publicKey.slice(2) : legacy.publicKey
}];
if (legacy.publicEncKey) {
publicKey.push({
id: did + "#keys-2",
type: 'Curve25519EncryptionPublicKey',
owner: did,
publicKeyBase64: legacy.publicEncKey
});
}
var doc = {
'@context': 'https://w3id.org/did/v1',
id: did,
publicKey: publicKey,
authentication: [{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: did + "#keys-1"
}]
};
if (legacy.name || legacy.description || legacy.image) {
var profile = Object.assign({}, legacy);
delete profile['publicKey'];
delete profile['publicEncKey'];
doc.uportProfile = profile;
}
return doc;
}
exports.convertToDid = convertToDid;
function register(configured) {
var cpsRegistry = configured || (0, _uportLite2.default)();
var registry = function registry(mnid) {
return new _promise2.default(function (resolve, reject) {
cpsRegistry(mnid, function (error, doc) {
return error ? reject(error) : resolve(doc);
});
});
};
function resolve(did, parsed) {
return new _promise2.default(function (resolve, reject) {
registry(parsed.id).then(function (doc) {
if (!doc) return resolve();
// Check if real DID document or legacy
if (doc['@context'] === 'https://w3id.org/did/v1') return resolve(doc);
if (typeof doc['publicKey'] === 'string') {
return resolve(convertToDid(did, doc));
}
}, reject);
});
}
(0, _didResolver.registerMethod)('uport', resolve);
var cpsRegistry = configured || uport_lite_1.default();
var registry = function (mnid) { return new Promise(function (resolve, reject) {
cpsRegistry(mnid, function (error, doc) { return error ? reject(error) : resolve(doc); });
}); };
function resolve(did, parsed) {
return __awaiter(this, void 0, void 0, function () {
var doc;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, registry(parsed.id)];
case 1:
doc = _a.sent();
if (!doc)
return [2 /*return*/, null
// Check if real DID document or legacy
];
// Check if real DID document or legacy
if (doc['@context'] === 'https://w3id.org/did/v1')
return [2 /*return*/, doc];
if (typeof doc['publicKey'] === 'string') {
return [2 /*return*/, convertToDid(did, doc)];
}
return [2 /*return*/, null];
}
});
});
}
did_resolver_1.registerMethod('uport', resolve);
}
module.exports = register;
exports.default = register;
//# sourceMappingURL=register.js.map
{
"name": "uport-did-resolver",
"version": "0.0.3",
"version": "0.0.4-alpha1",
"description": "Resolve uPort DID documents",
"main": "lib/register.js",
"types": "lib/register.d.ts",
"repository": {

@@ -18,43 +19,42 @@ "type": "git",

"scripts": {
"build": "tsc",
"test": "jest",
"build:es5": "./node_modules/.bin/babel src -d lib",
"build": "yarn build:es5 && yarn test",
"prepublish": "npm run build:es5"
"dev": "tsc --watch",
"format": "prettier"
},
"devDependencies": {
"@types/jest": "^23.3.10",
"@types/node": "^10.12.18",
"jest": "^23.6.0",
"prettier": "^1.15.3",
"regenerator-runtime": "^0.12.1",
"ts-jest": "^23.10.5",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^3.2.2"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"coverageDirectory": "./coverage/",
"collectCoverage": true
"collectCoverageFrom": [
"src/**/*.{ts,tsx}",
"!src/**/*.d.ts",
"!**/node_modules/**"
]
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^22.4.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"jest": "^22.4.0",
"regenerator-runtime": "^0.11.1",
"sinon": "^4.0.1",
"standard": "^11.0.0"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"did-resolver": "^0.0.4",
"uport-lite": "^1.0.2"
},
"standard": {
"ignore": [
"lib/**"
],
"globals": [
"it",
"describe",
"expect",
"jest",
"beforeAll",
"beforeEach",
"afterAll",
"afterEach"
]
"did-resolver": "0.0.6-alpha4",
"uport-lite": "^1.0.3"
}
}
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