Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@toruslabs/metadata-helpers

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toruslabs/metadata-helpers - npm Package Compare versions

Comparing version 1.2.3 to 2.0.0

67

dist/metadataHelpers.cjs.js

@@ -428,3 +428,3 @@ module.exports =

function setTorusShare(_x4, _x5, _x6, _x7) {
function setTorusShare(_x4, _x5, _x6, _x7, _x8) {
return _setTorusShare.apply(this, arguments);

@@ -434,4 +434,4 @@ }

function _setTorusShare() {
_setTorusShare = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2(m, webAuthnKeyHex, subspace, subspaceData) {
var keyPair, privKey, data, d, serializedDec, serializedBuf, encParams, encParamsHex, sData, metadataParams;
_setTorusShare = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2(m, webAuthnPubKey, webAuthnRefHex, subspace, subspaceData) {
var refKeyPair, privKey, pubKey, data, d, serializedSubspaceData, serializedSubspaceDataBuf, encSubspaceData, encSubspaceDataHex, serializedDec, serializedBuf, encParams, encParamsHex, sData, metadataParams;
return regenerator_default.a.wrap(function _callee2$(_context2) {

@@ -441,18 +441,30 @@ while (1) {

case 0:
keyPair = ec.keyFromPrivate(webAuthnKeyHex);
privKey = keyPair.getPrivate();
_context2.next = 4;
return getData(m, webAuthnKeyHex, WEBAUTHN_TORUS_SHARE);
refKeyPair = ec.keyFromPrivate(webAuthnRefHex);
privKey = refKeyPair.getPrivate();
pubKey = ec.keyFromPublic({
x: webAuthnPubKey.pub_key_X,
y: webAuthnPubKey.pub_key_Y
});
_context2.next = 5;
return getData(m, webAuthnRefHex, WEBAUTHN_TORUS_SHARE);
case 4:
case 5:
data = _context2.sent;
d = {};
if (data) d = data;
d[subspace] = subspaceData;
serializedSubspaceData = JSON.stringify(subspaceData);
serializedSubspaceDataBuf = Buffer.from(serializedSubspaceData, "utf-8");
_context2.next = 12;
return Object(eccrypto_["encrypt"])(Buffer.from(pubKey.getPublic("hex"), "hex"), serializedSubspaceDataBuf);
case 12:
encSubspaceData = _context2.sent;
encSubspaceDataHex = encParamsBufToHex(encSubspaceData);
d[subspace] = encSubspaceDataHex;
serializedDec = JSON.stringify(d);
serializedBuf = Buffer.from(serializedDec, "utf-8");
_context2.next = 12;
_context2.next = 19;
return Object(eccrypto_["encrypt"])(Object(eccrypto_["getPublic"])(Buffer.from(privKey.toString("hex", 64), "hex")), serializedBuf);
case 12:
case 19:
encParams = _context2.sent;

@@ -462,6 +474,6 @@ encParamsHex = encParamsBufToHex(encParams);

metadataParams = m.generateMetadataParams(sData, privKey.toString(16));
_context2.next = 18;
_context2.next = 25;
return m.setMetadata(metadataParams, WEBAUTHN_TORUS_SHARE);
case 18:
case 25:
case "end":

@@ -476,3 +488,3 @@ return _context2.stop();

function setDeviceShare(_x8, _x9, _x10, _x11) {
function setDeviceShare(_x9, _x10, _x11, _x12) {
return _setDeviceShare.apply(this, arguments);

@@ -521,3 +533,3 @@ }

function getTorusShare(_x12, _x13, _x14) {
function getTorusShare(_x13, _x14, _x15, _x16) {
return _getTorusShare.apply(this, arguments);

@@ -527,4 +539,4 @@ }

function _getTorusShare() {
_getTorusShare = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee4(m, webAuthnKeyHex, subspace) {
var data;
_getTorusShare = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee4(m, webAuthnKeyHex, webAuthnRefHex, subspace) {
var data, encParamsHex, encParams, serializedSubspaceDataBuf, serializedSubspaceData, subspaceData;
return regenerator_default.a.wrap(function _callee4$(_context4) {

@@ -535,3 +547,3 @@ while (1) {

_context4.next = 2;
return getData(m, webAuthnKeyHex, WEBAUTHN_TORUS_SHARE);
return getData(m, webAuthnRefHex, WEBAUTHN_TORUS_SHARE);

@@ -541,3 +553,3 @@ case 2:

if (!data) {
if (data) {
_context4.next = 5;

@@ -547,8 +559,17 @@ break;

return _context4.abrupt("return", data[subspace]);
return _context4.abrupt("return", null);
case 5:
return _context4.abrupt("return", null);
encParamsHex = data[subspace];
encParams = encParamsHexToBuf(encParamsHex);
_context4.next = 9;
return Object(eccrypto_["decrypt"])(Buffer.from(webAuthnKeyHex, "hex"), encParams);
case 6:
case 9:
serializedSubspaceDataBuf = _context4.sent;
serializedSubspaceData = serializedSubspaceDataBuf.toString("utf-8");
subspaceData = JSON.parse(serializedSubspaceData);
return _context4.abrupt("return", subspaceData);
case 13:
case "end":

@@ -563,3 +584,3 @@ return _context4.stop();

function getDeviceShare(_x15, _x16, _x17) {
function getDeviceShare(_x17, _x18, _x19) {
return _getDeviceShare.apply(this, arguments);

@@ -566,0 +587,0 @@ }

{
"name": "@toruslabs/metadata-helpers",
"version": "1.2.3",
"version": "2.0.0",
"description": "Helper methods for metadata",

@@ -5,0 +5,0 @@ "main": "dist/metadataHelpers.cjs.js",

import { Ecies } from "@toruslabs/eccrypto";
import MetadataStorageLayer from "./MetadataStorageLayer";
import MetadataStorageLayer, { PubKeyParams } from "./MetadataStorageLayer";
declare type EciesHex = {

@@ -11,6 +11,6 @@ iv: string;

export declare function encParamsBufToHex(encParams: Ecies): EciesHex;
export declare function setTorusShare(m: MetadataStorageLayer, webAuthnKeyHex: string, subspace: string, subspaceData: unknown): Promise<void>;
export declare function setTorusShare(m: MetadataStorageLayer, webAuthnPubKey: PubKeyParams, webAuthnRefHex: string, subspace: string, subspaceData: unknown): Promise<void>;
export declare function setDeviceShare(m: MetadataStorageLayer, webAuthnRefHex: string, subspace: string, subspaceData: unknown): Promise<void>;
export declare function getTorusShare<T>(m: MetadataStorageLayer, webAuthnKeyHex: string, subspace: string): Promise<T | null>;
export declare function getTorusShare<T>(m: MetadataStorageLayer, webAuthnKeyHex: string, webAuthnRefHex: string, subspace: string): Promise<T | null>;
export declare function getDeviceShare<T>(m: MetadataStorageLayer, webAuthnRefHex: string, subspace: string): Promise<T | null>;
export {};

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

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

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