Socket
Socket
Sign inDemoInstall

@celo/utils

Package Overview
Dependencies
Maintainers
6
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@celo/utils - npm Package Compare versions

Comparing version 0.0.5-dappkit2 to 0.0.5-dappkit3

8

lib/src/commentEncryption.d.ts
/// <reference types="node" />
/// <reference types="lodash" />
export interface encryptionStatus {
export interface EncryptionStatus {
encrypted: boolean;

@@ -35,3 +35,3 @@ comment: string;

*/
export declare function encryptComment(comment: string, pubKeyRecipient: Buffer, pubKeySelf: Buffer): encryptionStatus;
export declare function encryptComment(comment: string, pubKeyRecipient: Buffer, pubKeySelf: Buffer): EncryptionStatus;
/**

@@ -46,3 +46,3 @@ * Decrypts a comments encrypted by encryptComment. If it cannot decrypt the comment (i.e. comment was

*/
export declare const decryptComment: ((comment: string, key: Buffer, sender: boolean) => encryptionStatus) & import("lodash").MemoizedFunction;
export declare const decryptComment: ((comment: string, key: Buffer, sender: boolean) => EncryptionStatus) & import("lodash").MemoizedFunction;
/**

@@ -80,3 +80,3 @@ * Turns a private key to a compressed public key (hex string with hex leader).

encryptComment: typeof encryptComment;
decryptComment: ((comment: string, key: Buffer, sender: boolean) => encryptionStatus) & import("lodash").MemoizedFunction;
decryptComment: ((comment: string, key: Buffer, sender: boolean) => EncryptionStatus) & import("lodash").MemoizedFunction;
compressedPubKey: typeof compressedPubKey;

@@ -83,0 +83,0 @@ deriveCEK: typeof deriveCEK;

@@ -14,3 +14,2 @@ import countryData from 'country-data';

constructor(language?: string);
private assignCountries;
getCountry(countryName?: string | null): LocalizedCountry;

@@ -20,3 +19,4 @@ getCountryByPhoneCountryCode(countryCode: string): LocalizedCountry;

getFilteredCountries(query: string): string[];
private assignCountries;
}
export {};

@@ -40,18 +40,2 @@ "use strict";

}
Countries.prototype.assignCountries = function () {
var _this = this;
// add other languages to country data
this.localizedCountries = country_data_1.default.callingCountries.all.map(function (country) {
// this is assuming these two are the only cases, in i18n.ts seems like there
// are fallback languages 'es-US' and 'es-LA' that are not covered
var names = {
'en-us': country.name,
'es-ar': esData[country.alpha2],
};
var localizedCountry = __assign({ names: names, displayName: names[_this.language] }, country);
// use ISO 3166-1 alpha2 code as country id
_this.countryMap.set(country.alpha2.toUpperCase(), localizedCountry);
return localizedCountry;
});
};
Countries.prototype.getCountry = function (countryName) {

@@ -108,4 +92,20 @@ var _this = this;

};
Countries.prototype.assignCountries = function () {
var _this = this;
// add other languages to country data
this.localizedCountries = country_data_1.default.callingCountries.all.map(function (country) {
// this is assuming these two are the only cases, in i18n.ts seems like there
// are fallback languages 'es-US' and 'es-LA' that are not covered
var names = {
'en-us': country.name,
'es-ar': esData[country.alpha2],
};
var localizedCountry = __assign({ names: names, displayName: names[_this.language] }, country);
// use ISO 3166-1 alpha2 code as country id
_this.countryMap.set(country.alpha2.toUpperCase(), localizedCountry);
return localizedCountry;
});
};
return Countries;
}());
exports.Countries = Countries;

@@ -75,2 +75,4 @@ "use strict";

exports.serializeDappKitRequestDeeplink = serializeDappKitRequestDeeplink;
// TODO: parsing query params yields broad types
// once interface stabilizes, properly type the parsing
function parseDappkitResponseDepplink(url) {

@@ -123,32 +125,32 @@ var rawParams = url_1.parse(url, true);

}
if (!rawParams.query.dappName || !rawParams.query.callback || !rawParams.query.requestId) {
throw new Error("Invalid Deeplink: Does not contain meta parameters: " + url);
}
var requestMeta = {
// @ts-ignore
callback: rawParams.query.callback,
// @ts-ignore
requestId: rawParams.query.requestId,
// @ts-ignore
dappName: rawParams.query.dappName,
};
switch (rawParams.query.type) {
case DappKitRequestTypes.ACCOUNT_ADDRESS:
// @ts-ignore
return exports.AccountAuthRequest(
// @ts-ignore
rawParams.query.dappName, rawParams.query.callback, rawParams.query.requestId);
return exports.AccountAuthRequest(requestMeta);
break;
case DappKitRequestTypes.SIGN_TX:
// @ts-ignore
return {
type: DappKitRequestTypes.SIGN_TX,
return __assign({ type: DappKitRequestTypes.SIGN_TX,
// @ts-ignore
txData: rawParams.query.txData,
txData: rawParams.query.txData,
// @ts-ignore
estimatedGas: parseInt(rawParams.query.estimatedGas, 10),
estimatedGas: parseInt(rawParams.query.estimatedGas, 10),
// @ts-ignore
from: rawParams.query.from,
from: rawParams.query.from,
// @ts-ignore
to: rawParams.query.to,
to: rawParams.query.to,
// @ts-ignore
nonce: parseInt(rawParams.query.nonce, 10),
nonce: parseInt(rawParams.query.nonce, 10),
// @ts-ignore
gasCurrencyAddress: rawParams.query.gasCurrency,
// @ts-ignore
callback: rawParams.query.callback,
// @ts-ignore
requestId: rawParams.query.requestId,
// @ts-ignore
dappName: rawParams.query.dappName,
};
gasCurrencyAddress: rawParams.query.gasCurrency }, requestMeta);
default:

@@ -155,0 +157,0 @@ throw new Error('Invalid Deeplink: does not match defined requests');

@@ -16,3 +16,3 @@ "use strict";

}
throw 'Parsing error';
throw new Error('Parsing error');
};

@@ -19,0 +19,0 @@ exports.parseInputAmount = function (inputString) {

@@ -61,3 +61,3 @@ "use strict";

mockFunction = jest.fn(function () {
throw 'error';
throw new Error('error');
});

@@ -64,0 +64,0 @@ _a.label = 1;

@@ -79,6 +79,6 @@ "use strict";

describe('regression test', function () {
var recipPriv = Buffer.from('d2a515a64d37407f0e0e4a6a6a69a95eeb5ef8c2524ef01a6ffc6e3b39e0661b', 'hex');
var newRecipPriv = Buffer.from('d2a515a64d37407f0e0e4a6a6a69a95eeb5ef8c2524ef01a6ffc6e3b39e0661b', 'hex');
var senderPriv = Buffer.from('81cb7e2e21c10862dbb3c5782fff0fe315edbd51bd9b7ffc7f1dcf4212d70537', 'hex');
var encrypted = 'BGacSsVDzOXrVdXBkM2yBC4F1KD94rjfClQGi7r2TPkFu+hLQIRJ73H3z5wgWVgq8vcziPR5ugWPI/6pFduezNVMAJGB9pSLfA00wvb8twy5/uBIzaAQqkfKUJ4/n10N5+F313PDq0BU1LXsPN1Oq+5SWPQc4Z4MWKs+7zkcNz//BNNZkm8lgJ4frVHExBrED62rsth87vwxpsfyxxk36zdvAHN7xfYss3bqgYVA2+E45mRZOaJxnyRHfUYKU5tA5neTertXlzpZO93l4e9SrDTUVbI/dr8QuSc2Pot7C83cCQHjeIl9eB2W5DTfTwlThg/CeWW0afaElTjuEw1XXy9eC3H9nxTXOj44SM2WUB3uDH2K2wmPJsd+RW66CDI6fD2VHMst2CA2B01hX2h+6Ml84Ria53bI6iedOpb1ejsw98a1/z2QKAlh/KfMHmseY/dQMh9kBhIuOQwavf3t4PvyMJ2QbRGwi1cuItkkyg/8eiCa8Zdjn3OozoWSQnfR';
var comment = 'regression test on encryption method 👍';
var newComment = 'regression test on encryption method 👍';
// How comment was encrypted.

@@ -95,8 +95,8 @@ // Uses elliptic package

var _a = commentEncryption_1.decryptComment(encrypted, senderPriv, true), decrypted = _a.comment, didDecrypt = _a.encrypted;
assert.equal(decrypted, comment);
assert.equal(decrypted, newComment);
assert(didDecrypt);
});
it('should not regress for recipeient', function () {
var _a = commentEncryption_1.decryptComment(encrypted, recipPriv, false), decrypted = _a.comment, didDecrypt = _a.encrypted;
assert.equal(decrypted, comment);
var _a = commentEncryption_1.decryptComment(encrypted, newRecipPriv, false), decrypted = _a.comment, didDecrypt = _a.encrypted;
assert.equal(decrypted, newComment);
assert(didDecrypt);

@@ -110,3 +110,3 @@ });

var derived = commentEncryption_1.deriveCEK(input.toString('hex'));
assert(derived.length == 32);
assert(derived.length === 32);
});

@@ -128,3 +128,3 @@ it('should not regress', function () {

assert(Buffer.concat([Buffer.from('04', 'hex'), decompressed]).equals(publicKeyFull));
assert(decompressed.length == 64);
assert(decompressed.length === 64);
});

@@ -136,4 +136,4 @@ it('should work with long form input', function () {

assert(Buffer.concat([Buffer.from('04', 'hex'), decompressed]).equals(publicKeyFull));
assert(decompressed.length == 64);
assert(decompressed.length === 64);
});
});
{
"name": "@celo/utils",
"version": "0.0.5-dappkit2",
"version": "0.0.5-dappkit3",
"description": "Celo common utils",

@@ -11,7 +11,6 @@ "author": "Celo",

"scripts": {
"pretest": "tsc",
"prettify": "yarn run prettier --config ../../.prettierrc.js --write '{contracts,types,lib}/**/*.+(ts|tsx|js|jsx)'",
"build": "tsc",
"test": "npm run pretest && jest --ci --silent --coverage --runInBand",
"test:verbose": "npm run pretest && jest --ci --verbose --runInBand"
"lint": "tslint --project .",
"test": "yarn build && jest --ci --silent --coverage --runInBand",
"test:verbose": "yarn build && jest --ci --verbose --runInBand"
},

@@ -18,0 +17,0 @@ "dependencies": {

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