Socket
Socket
Sign inDemoInstall

@celo/base

Package Overview
Dependencies
Maintainers
18
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@celo/base - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

1

lib/address.d.ts

@@ -0,1 +1,2 @@

/// <reference types="node" />
export declare type Address = string;

@@ -2,0 +3,0 @@ export declare const eqAddress: (a: Address, b: Address) => boolean;

2

lib/address.test.js

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

return __generator(this, function (_a) {
expect((0, address_1.getAddressChunks)('0xce10ce10ce10ce10ce10ce10ce10ce10ce10ce10')).toEqual([
expect(address_1.getAddressChunks('0xce10ce10ce10ce10ce10ce10ce10ce10ce10ce10')).toEqual([
'ce10',

@@ -46,0 +46,0 @@ 'ce10',

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

mockFunction = jest.fn();
return [4 /*yield*/, (0, async_1.retryAsync)(mockFunction, 3, [], 1)];
return [4 /*yield*/, async_1.retryAsync(mockFunction, 3, [], 1)];
case 1:

@@ -67,3 +67,3 @@ _a.sent();

_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, (0, async_1.retryAsync)(mockFunction, 3, [], 1)];
return [4 /*yield*/, async_1.retryAsync(mockFunction, 3, [], 1)];
case 2:

@@ -97,3 +97,3 @@ _a.sent();

_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, (0, async_1.selectiveRetryAsyncWithBackOff)(mockFunction, 3, ['test error'], [])];
return [4 /*yield*/, async_1.selectiveRetryAsyncWithBackOff(mockFunction, 3, ['test error'], [])];
case 2:

@@ -123,3 +123,3 @@ _b.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, (0, async_1.sleep)(10)];
case 0: return [4 /*yield*/, async_1.sleep(10)];
case 1:

@@ -131,3 +131,3 @@ _a.sent();

}); });
return [4 /*yield*/, (0, async_1.retryAsyncWithBackOffAndTimeout)(mockFunction, 3, [], 1)];
return [4 /*yield*/, async_1.retryAsyncWithBackOffAndTimeout(mockFunction, 3, [], 1)];
case 1:

@@ -152,3 +152,3 @@ result = _a.sent();

_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, (0, async_1.retryAsyncWithBackOffAndTimeout)(mockFunction, 3, [], 1, 1, 100)];
return [4 /*yield*/, async_1.retryAsyncWithBackOffAndTimeout(mockFunction, 3, [], 1, 1, 100)];
case 2:

@@ -176,3 +176,3 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, (0, async_1.sleep)(1000)];
case 0: return [4 /*yield*/, async_1.sleep(1000)];
case 1:

@@ -187,3 +187,3 @@ _a.sent();

_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, (0, async_1.retryAsyncWithBackOffAndTimeout)(mockFunction, 3, [], 1, 1, 100)];
return [4 /*yield*/, async_1.retryAsyncWithBackOffAndTimeout(mockFunction, 3, [], 1, 1, 100)];
case 2:

@@ -214,3 +214,3 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, (0, async_1.sleep)(5)];
case 0: return [4 /*yield*/, async_1.sleep(5)];
case 1:

@@ -239,3 +239,3 @@ _a.sent();

expected = _a.sent();
return [4 /*yield*/, (0, async_1.concurrentMap)(3, xs, fn)];
return [4 /*yield*/, async_1.concurrentMap(3, xs, fn)];
case 2:

@@ -258,5 +258,5 @@ result = _a.sent();

p1 = Promise.all(xs.map(c1.inc));
p2 = (0, async_1.concurrentMap)(2, xs, c2.inc);
p2 = async_1.concurrentMap(2, xs, c2.inc);
// sleep enough for Promise.all to finish
return [4 /*yield*/, (0, async_1.sleep)(7)];
return [4 /*yield*/, async_1.sleep(7)];
case 1:

@@ -267,3 +267,3 @@ // sleep enough for Promise.all to finish

expect(c1.val()).not.toEqual(c2.val());
return [4 /*yield*/, (0, async_1.sleep)(20)];
return [4 /*yield*/, async_1.sleep(20)];
case 2:

@@ -289,4 +289,4 @@ _a.sent();

xs = [1, 3, 4];
p = (0, async_1.concurrentMap)(5, xs, c.inc);
return [4 /*yield*/, (0, async_1.sleep)(7)];
p = async_1.concurrentMap(5, xs, c.inc);
return [4 /*yield*/, async_1.sleep(7)];
case 1:

@@ -312,3 +312,3 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, (0, async_1.sleep)(1000)];
case 0: return [4 /*yield*/, async_1.sleep(1000)];
case 1:

@@ -324,3 +324,3 @@ _a.sent();

_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, (0, async_1.timeout)(mockFunction, [], 900, timeoutError)];
return [4 /*yield*/, async_1.timeout(mockFunction, [], 900, timeoutError)];
case 2:

@@ -327,0 +327,0 @@ _a.sent();

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

it('should check if a message contains a attestation code', function () {
expect((0, attestations_1.messageContainsAttestationCode)(MESSAGE_1)).toBeTruthy();
expect((0, attestations_1.messageContainsAttestationCode)(MESSAGE_2)).toBeTruthy();
expect((0, attestations_1.messageContainsAttestationCode)(MESSAGE_3)).toBeTruthy();
expect((0, attestations_1.messageContainsAttestationCode)(MESSAGE_3_WITH_LINK)).toBeTruthy();
expect(attestations_1.messageContainsAttestationCode(MESSAGE_1)).toBeTruthy();
expect(attestations_1.messageContainsAttestationCode(MESSAGE_2)).toBeTruthy();
expect(attestations_1.messageContainsAttestationCode(MESSAGE_3)).toBeTruthy();
expect(attestations_1.messageContainsAttestationCode(MESSAGE_3_WITH_LINK)).toBeTruthy();
});
it('should fail if a message does not contain a attestation code', function () {
expect((0, attestations_1.messageContainsAttestationCode)('asdfasdaf')).toBeFalsy();
expect((0, attestations_1.messageContainsAttestationCode)('')).toBeFalsy();
expect((0, attestations_1.messageContainsAttestationCode)('Howdy there')).toBeFalsy();
expect(attestations_1.messageContainsAttestationCode('asdfasdaf')).toBeFalsy();
expect(attestations_1.messageContainsAttestationCode('')).toBeFalsy();
expect(attestations_1.messageContainsAttestationCode('Howdy there')).toBeFalsy();
});

@@ -30,7 +30,7 @@ });

it('should extract the code from a message', function () {
expect((0, attestations_1.extractAttestationCodeFromMessage)(MESSAGE_1)).toBe(MESSAGE_1_DECODED);
expect((0, attestations_1.extractAttestationCodeFromMessage)(MESSAGE_2)).toBe(MESSAGE_2_DECODED);
expect((0, attestations_1.extractAttestationCodeFromMessage)(MESSAGE_3)).toBe(MESSAGE_3_DECODED);
expect((0, attestations_1.extractAttestationCodeFromMessage)(MESSAGE_3_WITH_LINK)).toBe(MESSAGE_3_DECODED);
expect((0, attestations_1.extractAttestationCodeFromMessage)(MESSAGE_4_UNSANITIZED)).toBe(MESSAGE_4_DECODED);
expect(attestations_1.extractAttestationCodeFromMessage(MESSAGE_1)).toBe(MESSAGE_1_DECODED);
expect(attestations_1.extractAttestationCodeFromMessage(MESSAGE_2)).toBe(MESSAGE_2_DECODED);
expect(attestations_1.extractAttestationCodeFromMessage(MESSAGE_3)).toBe(MESSAGE_3_DECODED);
expect(attestations_1.extractAttestationCodeFromMessage(MESSAGE_3_WITH_LINK)).toBe(MESSAGE_3_DECODED);
expect(attestations_1.extractAttestationCodeFromMessage(MESSAGE_4_UNSANITIZED)).toBe(MESSAGE_4_DECODED);
});

@@ -46,5 +46,5 @@ });

it('sanitizes correctly', function () {
expect((0, attestations_1.sanitizeMessageBase64)(CODE_1)).toBe(SANITIZED_CODE_1);
expect((0, attestations_1.sanitizeMessageBase64)(CODE_2)).toBe(SANITIZED_CODE_2);
expect((0, attestations_1.sanitizeMessageBase64)(NORMAL_CODE)).toBe(NORMAL_CODE);
expect(attestations_1.sanitizeMessageBase64(CODE_1)).toBe(SANITIZED_CODE_1);
expect(attestations_1.sanitizeMessageBase64(CODE_2)).toBe(SANITIZED_CODE_2);
expect(attestations_1.sanitizeMessageBase64(NORMAL_CODE)).toBe(NORMAL_CODE);
});

@@ -51,0 +51,0 @@ });

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

};
expect((0, collections_1.linkedListChange)(lst, change, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChange(lst, change, bnc)).toMatchObject(expected);
});

@@ -35,3 +35,3 @@ it('becoming greatest', function () {

};
expect((0, collections_1.linkedListChange)(lst, change, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChange(lst, change, bnc)).toMatchObject(expected);
});

@@ -51,3 +51,3 @@ it('becoming smallest', function () {

};
expect((0, collections_1.linkedListChange)(lst, change, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChange(lst, change, bnc)).toMatchObject(expected);
});

@@ -69,3 +69,3 @@ it('change order', function () {

};
expect((0, collections_1.linkedListChange)(lst, change, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChange(lst, change, bnc)).toMatchObject(expected);
});

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

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -96,3 +96,3 @@ it('becoming greatest', function () {

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -112,3 +112,3 @@ it('becoming smallest', function () {

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -130,3 +130,3 @@ it('change order', function () {

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -151,3 +151,3 @@ it('change order, become smallest', function () {

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -172,3 +172,3 @@ it('change order, become largest', function () {

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -193,3 +193,3 @@ it('change order, then replace with another', function () {

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -215,3 +215,3 @@ it('change order, then replace with another again', function () {

};
expect((0, collections_1.linkedListChanges)(lst, changes, bnc)).toMatchObject(expected);
expect(collections_1.linkedListChanges(lst, changes, bnc)).toMatchObject(expected);
});

@@ -218,0 +218,0 @@ });

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

switch (_a.label) {
case 0: return [4 /*yield*/, (0, async_1.sleep)(Math.floor(Math.random() * 10))];
case 0: return [4 /*yield*/, async_1.sleep(Math.floor(Math.random() * 10))];
case 1:

@@ -48,0 +48,0 @@ _a.sent();

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

var fs_1 = require("fs");
var pdef = JSON.parse((0, fs_1.readFileSync)('./package.json', 'utf-8'));
var pdef = JSON.parse(fs_1.readFileSync('./package.json', 'utf-8'));
describe('Base package', function () {

@@ -8,0 +8,0 @@ // @celo/base is built on the premise of having absolutely no dependencies, no exceptions made

@@ -5,10 +5,10 @@ "use strict";

test('stringToBoolean()', function () {
expect((0, parsing_1.stringToBoolean)('true')).toBe(true);
expect((0, parsing_1.stringToBoolean)(' true ')).toBe(true);
expect((0, parsing_1.stringToBoolean)('false')).toBe(false);
expect((0, parsing_1.stringToBoolean)(' false ')).toBe(false);
expect((0, parsing_1.stringToBoolean)('FaLse')).toBe(false);
expect((0, parsing_1.stringToBoolean)('TruE')).toBe(true);
expect(function () { return (0, parsing_1.stringToBoolean)('fals'); }).toThrow("Unable to parse 'fals' as boolean");
expect(parsing_1.stringToBoolean('true')).toBe(true);
expect(parsing_1.stringToBoolean(' true ')).toBe(true);
expect(parsing_1.stringToBoolean('false')).toBe(false);
expect(parsing_1.stringToBoolean(' false ')).toBe(false);
expect(parsing_1.stringToBoolean('FaLse')).toBe(false);
expect(parsing_1.stringToBoolean('TruE')).toBe(true);
expect(function () { return parsing_1.stringToBoolean('fals'); }).toThrow("Unable to parse 'fals' as boolean");
});
//# sourceMappingURL=parsing.test.js.map

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

var phoneNumbers_1 = require("./phoneNumbers");
var sha3 = function (v) { return (0, web3_utils_1.soliditySha3)({ type: 'string', value: v }); };
var sha3 = function (v) { return web3_utils_1.soliditySha3({ type: 'string', value: v }); };
var TEST_PHONE_NUMBERS = {

@@ -36,10 +36,10 @@ VALID_US_1: '6282287826',

it('Hashes an valid number without a salt', function () {
expect((0, phoneNumbers_1.getPhoneHash)(sha3, TEST_PHONE_NUMBERS.VALID_E164, '')).toBe('0x483128504c69591aed5751690805ba9aad6c390644421dc189f6dbb6e085aadf');
expect(phoneNumbers_1.getPhoneHash(sha3, TEST_PHONE_NUMBERS.VALID_E164, '')).toBe('0x483128504c69591aed5751690805ba9aad6c390644421dc189f6dbb6e085aadf');
});
it('Hashes an valid number with a salt', function () {
expect((0, phoneNumbers_1.getPhoneHash)(sha3, TEST_PHONE_NUMBERS.VALID_E164, 'abcdefg')).toBe('0xf08257f6b126597dbd090fecf4f5106cfb59c98ef997644cef16f9349464810c');
expect(phoneNumbers_1.getPhoneHash(sha3, TEST_PHONE_NUMBERS.VALID_E164, 'abcdefg')).toBe('0xf08257f6b126597dbd090fecf4f5106cfb59c98ef997644cef16f9349464810c');
});
it('Throws for an invalid number', function () {
try {
(0, phoneNumbers_1.getPhoneHash)(sha3, TEST_PHONE_NUMBERS.VALID_US_1, '');
phoneNumbers_1.getPhoneHash(sha3, TEST_PHONE_NUMBERS.VALID_US_1, '');
fail('expected an error');

@@ -55,8 +55,8 @@ }

// @ts-ignore
expect((0, phoneNumbers_1.isE164Number)(null)).toBe(false);
expect((0, phoneNumbers_1.isE164Number)('')).toBe(false);
expect((0, phoneNumbers_1.isE164Number)(TEST_PHONE_NUMBERS.VALID_US_1)).toBe(false);
expect((0, phoneNumbers_1.isE164Number)(TEST_PHONE_NUMBERS.VALID_US_2)).toBe(false);
expect((0, phoneNumbers_1.isE164Number)(TEST_PHONE_NUMBERS.VALID_US_3)).toBe(true);
expect((0, phoneNumbers_1.isE164Number)(TEST_PHONE_NUMBERS.VALID_US_4)).toBe(false);
expect(phoneNumbers_1.isE164Number(null)).toBe(false);
expect(phoneNumbers_1.isE164Number('')).toBe(false);
expect(phoneNumbers_1.isE164Number(TEST_PHONE_NUMBERS.VALID_US_1)).toBe(false);
expect(phoneNumbers_1.isE164Number(TEST_PHONE_NUMBERS.VALID_US_2)).toBe(false);
expect(phoneNumbers_1.isE164Number(TEST_PHONE_NUMBERS.VALID_US_3)).toBe(true);
expect(phoneNumbers_1.isE164Number(TEST_PHONE_NUMBERS.VALID_US_4)).toBe(false);
});

@@ -63,0 +63,0 @@ });

@@ -48,7 +48,7 @@ "use strict";

fn = jest.fn().mockResolvedValue(null);
task = (0, task_1.repeatTask)({
task = task_1.repeatTask({
name: 'testTask',
timeInBetweenMS: 10,
}, fn);
return [4 /*yield*/, (0, async_1.sleep)(15)];
return [4 /*yield*/, async_1.sleep(15)];
case 1:

@@ -58,3 +58,3 @@ _a.sent();

task.stop();
return [4 /*yield*/, (0, async_1.sleep)(10)];
return [4 /*yield*/, async_1.sleep(10)];
case 2:

@@ -74,7 +74,7 @@ _a.sent();

fn = jest.fn().mockRejectedValue(new Error('Failed'));
task = (0, task_1.repeatTask)({
task = task_1.repeatTask({
name: 'testTask',
timeInBetweenMS: 10,
}, fn);
return [4 /*yield*/, (0, async_1.sleep)(35)];
return [4 /*yield*/, async_1.sleep(35)];
case 1:

@@ -100,7 +100,7 @@ _a.sent();

}); });
task = (0, task_1.repeatTask)({
task = task_1.repeatTask({
name: 'testTask',
timeInBetweenMS: 10,
}, fn);
return [4 /*yield*/, (0, async_1.sleep)(35)];
return [4 /*yield*/, async_1.sleep(35)];
case 1:

@@ -128,3 +128,3 @@ _a.sent();

logger = jest.fn();
(0, task_1.repeatTask)({
task_1.repeatTask({
name: 'testTask',

@@ -134,3 +134,3 @@ timeInBetweenMS: 10,

}, fn);
return [4 /*yield*/, (0, async_1.sleep)(5)];
return [4 /*yield*/, async_1.sleep(5)];
case 1:

@@ -160,7 +160,7 @@ _b.sent();

}); });
task = (0, task_1.repeatTask)({
task = task_1.repeatTask({
name: 'testTask',
timeInBetweenMS: 10,
}, fn);
return [4 /*yield*/, (0, async_1.sleep)(25)];
return [4 /*yield*/, async_1.sleep(25)];
case 1:

@@ -180,3 +180,3 @@ _a.sent();

fn = jest.fn().mockResolvedValue(null);
task = (0, task_1.repeatTask)({
task = task_1.repeatTask({
name: 'testTask',

@@ -186,7 +186,7 @@ initialDelayMS: 10,

}, fn);
return [4 /*yield*/, (0, async_1.sleep)(2)];
return [4 /*yield*/, async_1.sleep(2)];
case 1:
_a.sent();
expect(fn).toHaveBeenCalledTimes(0);
return [4 /*yield*/, (0, async_1.sleep)(10)];
return [4 /*yield*/, async_1.sleep(10)];
case 2:

@@ -209,3 +209,3 @@ _a.sent();

onSuccess = jest.fn();
task = (0, task_1.conditionWatcher)({
task = task_1.conditionWatcher({
name: 'testCondition',

@@ -216,3 +216,3 @@ onSuccess: onSuccess,

});
return [4 /*yield*/, (0, async_1.sleep)(25)];
return [4 /*yield*/, async_1.sleep(25)];
case 1:

@@ -237,3 +237,3 @@ _a.sent();

onSuccess = jest.fn();
task = (0, task_1.conditionWatcher)({
task = task_1.conditionWatcher({
name: 'testCondition',

@@ -244,3 +244,3 @@ onSuccess: onSuccess,

});
return [4 /*yield*/, (0, async_1.sleep)(25)];
return [4 /*yield*/, async_1.sleep(25)];
case 1:

@@ -262,3 +262,3 @@ _a.sent();

onSuccess = jest.fn().mockRejectedValue(new Error('fail'));
task = (0, task_1.conditionWatcher)({
task = task_1.conditionWatcher({
name: 'testCondition',

@@ -269,3 +269,3 @@ onSuccess: onSuccess,

});
return [4 /*yield*/, (0, async_1.sleep)(25)];
return [4 /*yield*/, async_1.sleep(25)];
case 1:

@@ -286,3 +286,3 @@ _a.sent();

case 0:
task = (0, task_1.tryObtainValueWithRetries)({
task = task_1.tryObtainValueWithRetries({
name: 'testGet',

@@ -305,3 +305,3 @@ maxAttemps: 2,

case 0:
task = (0, task_1.tryObtainValueWithRetries)({
task = task_1.tryObtainValueWithRetries({
name: 'testGet',

@@ -328,3 +328,3 @@ maxAttemps: 2,

case 0:
task = (0, task_1.tryObtainValueWithRetries)({
task = task_1.tryObtainValueWithRetries({
name: 'testGet',

@@ -351,3 +351,3 @@ maxAttemps: 2,

tryGetValue = jest.fn().mockResolvedValue(null);
task = (0, task_1.tryObtainValueWithRetries)({
task = task_1.tryObtainValueWithRetries({
name: 'testGet',

@@ -358,3 +358,3 @@ maxAttemps: 15,

});
return [4 /*yield*/, (0, async_1.sleep)(15)];
return [4 /*yield*/, async_1.sleep(15)];
case 1:

@@ -367,3 +367,3 @@ _a.sent();

currentCalls = tryGetValue.mock.calls.length;
return [4 /*yield*/, (0, async_1.sleep)(10)];
return [4 /*yield*/, async_1.sleep(10)];
case 3:

@@ -370,0 +370,0 @@ _a.sent();

{
"name": "@celo/base",
"version": "1.5.1",
"version": "1.5.2",
"description": "Celo base common utils, no dependencies",

@@ -5,0 +5,0 @@ "author": "Celo",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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