Socket
Socket
Sign inDemoInstall

@celo/utils

Package Overview
Dependencies
Maintainers
19
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 1.5.2 to 2.0.0-alpha.2

2

lib/address.d.ts

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

export { Address, bufferToHex, ensureLeading0x, eqAddress, findAddressIndex, getAddressChunks, hexToBuffer, isHexString, mapAddressListDataOnto, mapAddressListOnto, normalizeAddress, normalizeAddressWith0x, NULL_ADDRESS, trimLeading0x, } from '@celo/base/lib/address';
export { Address, bufferToHex, ensureLeading0x, eqAddress, findAddressIndex, getAddressChunks, hexToBuffer, isHexString, mapAddressListDataOnto, mapAddressListOnto, normalizeAddress, normalizeAddressWith0x, NULL_ADDRESS, trimLeading0x } from '@celo/base/lib/address';
export { isValidChecksumAddress, toChecksumAddress } from 'ethereumjs-util';

@@ -3,0 +3,0 @@ export declare const privateKeyToAddress: (privateKey: string) => string;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -25,3 +6,2 @@ exports.isValidAddress = exports.isValidPrivateKey = exports.publicKeyToAddress = exports.privateKeyToPublicKey = exports.privateKeyToAddress = exports.toChecksumAddress = exports.isValidChecksumAddress = exports.trimLeading0x = exports.NULL_ADDRESS = exports.normalizeAddressWith0x = exports.normalizeAddress = exports.mapAddressListOnto = exports.mapAddressListDataOnto = exports.isHexString = exports.hexToBuffer = exports.getAddressChunks = exports.findAddressIndex = exports.eqAddress = exports.ensureLeading0x = exports.bufferToHex = void 0;

var ethereumjs_util_1 = require("ethereumjs-util");
var Web3Utils = __importStar(require("web3-utils"));
// Exports moved to @celo/base, forwarding them

@@ -62,4 +42,18 @@ // here for backwards compatibility

exports.isValidPrivateKey = isValidPrivateKey;
var isValidAddress = function (input) { return Web3Utils.isAddress(input); };
var isValidAddress = function (input) {
if ("string" !== typeof input) {
return false;
}
if ((!/^(0x)?[0-9a-f]{40}$/i.test(input))) {
return false;
}
if (/^(0x|0X)?[0-9A-F]{40}$/.test(input.toUpperCase())) {
return true;
}
if ((0, ethereumjs_util_1.toChecksumAddress)(input) === input) {
return true;
}
return false;
};
exports.isValidAddress = isValidAddress;
//# sourceMappingURL=address.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBlsPoP = exports.getBlsPublicKey = exports.blsPrivateKeyToProcessedPrivateKey = exports.BLS_POP_SIZE = exports.BLS_PUBLIC_KEY_SIZE = void 0;
// this is an implementation of a subset of BLS12-377
var keccak256 = require('keccak256');
var bls12377js_1 = require("bls12377js");
var ethereumjs_util_1 = require("ethereumjs-util");
var address_1 = require("./address");
var BigInteger = require('bigi');
var reverse = require('buffer-reverse');
var bls12377js = __importStar(require("bls12377js"));
var address_1 = require("./address");
var n = BigInteger.fromHex('12ab655e9a2ca55660b44d1e5c37b00159aa76fed00000010a11800000000001', 16);

@@ -43,3 +24,3 @@ var MODULUSMASK = 31;

]);
var privateKeyBLSBytes = keccak256(keyBytes);
var privateKeyBLSBytes = (0, ethereumjs_util_1.keccak256)(keyBytes);
// tslint:disable-next-line:no-bitwise

@@ -63,3 +44,3 @@ privateKeyBLSBytes[0] &= MODULUSMASK;

var blsPrivateKeyBytes = getBlsPrivateKey(privateKeyHex);
return '0x' + bls12377js.BLS.privateToPublicBytes(blsPrivateKeyBytes).toString('hex');
return '0x' + bls12377js_1.BLS.privateToPublicBytes(blsPrivateKeyBytes).toString('hex');
};

@@ -72,6 +53,5 @@ exports.getBlsPublicKey = getBlsPublicKey;

var blsPrivateKeyBytes = getBlsPrivateKey(privateKeyHex);
return ('0x' +
bls12377js.BLS.signPoP(blsPrivateKeyBytes, Buffer.from(address.slice(2), 'hex')).toString('hex'));
return ('0x' + bls12377js_1.BLS.signPoP(blsPrivateKeyBytes, Buffer.from(address.slice(2), 'hex')).toString('hex'));
};
exports.getBlsPoP = getBlsPoP;
//# sourceMappingURL=bls.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var crypto_1 = require("crypto");
var elliptic_1 = require("elliptic");
var commentEncryption_1 = require("./commentEncryption");
var ec = new elliptic_1.ec('secp256k1');
describe('Comment Encryption', function () {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var self = ec.keyFromPrivate((0, crypto_1.randomBytes)(32));

@@ -83,3 +86,3 @@ var selfPublic = Buffer.from(self.getPublic('hex'), 'hex');

// How comment was encrypted.
// Uses elliptic package
// Uses elliptic package (see note above)
// console.info(

@@ -86,0 +89,0 @@ // encryptComment(

import { MinimalContact } from '@celo/base/lib/contacts';
export { ContactPhoneNumber, getContactPhoneNumber, isContact, MinimalContact, } from '@celo/base/lib/contacts';
export { ContactPhoneNumber, getContactPhoneNumber, isContact, MinimalContact } from '@celo/base/lib/contacts';
/**
* @deprecated May be removed in future
*/
export declare const getContactNameHash: (contact: MinimalContact) => string;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getContactNameHash = exports.isContact = exports.getContactPhoneNumber = void 0;
var Web3Utils = __importStar(require("web3-utils"));
var web3_utils_1 = require("web3-utils");
// Exports moved to @celo/base, forwarding them

@@ -29,2 +10,5 @@ // here for backwards compatibility

Object.defineProperty(exports, "isContact", { enumerable: true, get: function () { return contacts_1.isContact; } });
/**
* @deprecated May be removed in future
*/
var getContactNameHash = function (contact) {

@@ -34,5 +18,5 @@ if (!contact) {

}
return Web3Utils.keccak256(contact.displayName || '');
return (0, web3_utils_1.keccak256)(contact.displayName || '');
};
exports.getContactNameHash = getContactNameHash;
//# sourceMappingURL=contacts.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataEncryptionKeyUtils = exports.deriveDek = exports.decompressPublicKey = exports.compressedPubKey = void 0;
var elliptic_1 = require("elliptic");
var account_1 = require("./account");
var address_1 = require("./address");
var ec = new elliptic_1.ec('secp256k1');
/**

@@ -15,2 +13,7 @@ * Turns a private key to a compressed public key (hex string with hex leader).

function compressedPubKey(privateKey) {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var key = ec.keyFromPrivate(privateKey);

@@ -28,2 +31,7 @@ return (0, address_1.ensureLeading0x)(key.getPublic(true, 'hex'));

function decompressPublicKey(publicKey) {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
return Buffer.from(ec.keyFromPublic(publicKey).getPublic(false, 'hex'), 'hex').slice(1);

@@ -30,0 +38,0 @@ }

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

var crypto_1 = require("crypto");
var elliptic_1 = require("elliptic");
var dataEncryptionKey_1 = require("./dataEncryptionKey");
var ec = new elliptic_1.ec('secp256k1');
describe('deriveDek', function () {

@@ -63,2 +61,7 @@ it('should produce a the expected keys', function () { return __awaiter(void 0, void 0, void 0, function () {

it('should work with compressed input', function () {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var privateKey = ec.keyFromPrivate((0, crypto_1.randomBytes)(32));

@@ -72,2 +75,7 @@ var publicKeyFull = Buffer.from(privateKey.getPublic(false, 'hex'), 'hex');

it('should work with long form input', function () {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var privateKey = ec.keyFromPrivate((0, crypto_1.randomBytes)(32));

@@ -74,0 +82,0 @@ var publicKeyFull = Buffer.from(privateKey.getPublic(false, 'hex'), 'hex');

@@ -5,3 +5,3 @@ /// <reference types="node" />

export declare function ensureCompressed(publicKey: string): string;
export declare function ensureUncompressed(publicKey: string): string;
export declare function ensureUncompressed(publicKey: string): any;
export declare function trimUncompressedPrefix(publicKey: string): string;

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

var crypto_1 = require("crypto");
var elliptic_1 = require("elliptic");
var secp256k1 = new elliptic_1.ec('secp256k1');
function computeSharedSecret(privateKey, publicKey) {

@@ -24,3 +22,8 @@ var ecdh = (0, crypto_1.createECDH)('secp256k1');

function ensureCompressed(publicKey) {
return secp256k1.keyFromPublic(ensureUncompressedPrefix(publicKey), 'hex').getPublic(true, 'hex');
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
return ec.keyFromPublic(ensureUncompressedPrefix(publicKey), 'hex').getPublic(true, 'hex');
}

@@ -30,3 +33,8 @@ exports.ensureCompressed = ensureCompressed;

var noLeading0x = (0, address_1.trimLeading0x)(publicKey);
var uncompressed = secp256k1
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var uncompressed = ec
.keyFromPublic(ensureUncompressedPrefix(noLeading0x), 'hex')

@@ -33,0 +41,0 @@ .getPublic(false, 'hex');

@@ -11,4 +11,2 @@ /**

var crypto_1 = require("crypto");
var elliptic_1 = require("elliptic");
var ec = new elliptic_1.ec('secp256k1');
exports.IV_LENGTH = 16;

@@ -124,2 +122,7 @@ /**

function Encrypt(pubKeyTo, plaintext) {
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var ephemPrivKey = ec.keyFromPrivate((0, crypto_1.randomBytes)(32));

@@ -150,2 +153,7 @@ var ephemPubKey = ephemPrivKey.getPublic(false, 'hex');

var symmetricEncrypted = encrypted.slice(65);
// NOTE: elliptic is disabled elsewhere in this library to prevent
// accidental signing of truncated messages.
// tslint:disable-next-line:import-blacklist
var EC = require('elliptic').ec;
var ec = new EC('secp256k1');
var ephemPubKey = ec.keyFromPublic(ephemPubKeyEncoded).getPublic();

@@ -152,0 +160,0 @@ var px = ec.keyFromPrivate(privKey).derive(ephemPubKey);

@@ -6,3 +6,2 @@ import * as AddressUtils from './address';

export * from './contacts';
export * from './countries';
export * from './currencies';

@@ -13,5 +12,4 @@ export * from './dappkit';

export { IstanbulUtils } from './istanbul';
export { PhoneNumberUtils } from './phoneNumbers';
export { SignatureUtils } from './signatureUtils';
export { StringUtils } from './string';
export { AddressUtils };

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.AddressUtils = exports.StringUtils = exports.SignatureUtils = exports.PhoneNumberUtils = exports.IstanbulUtils = exports.ECIES = exports.DataEncryptionKeyUtils = exports.CommentEncryptionUtils = exports.AttestationUtils = exports.AccountUtils = void 0;
exports.AddressUtils = exports.StringUtils = exports.SignatureUtils = exports.IstanbulUtils = exports.ECIES = exports.DataEncryptionKeyUtils = exports.CommentEncryptionUtils = exports.AttestationUtils = exports.AccountUtils = void 0;
var AddressUtils = __importStar(require("./address"));

@@ -36,3 +36,2 @@ exports.AddressUtils = AddressUtils;

__exportStar(require("./contacts"), exports);
__exportStar(require("./countries"), exports);
__exportStar(require("./currencies"), exports);

@@ -46,4 +45,2 @@ __exportStar(require("./dappkit"), exports);

Object.defineProperty(exports, "IstanbulUtils", { enumerable: true, get: function () { return istanbul_1.IstanbulUtils; } });
var phoneNumbers_1 = require("./phoneNumbers");
Object.defineProperty(exports, "PhoneNumberUtils", { enumerable: true, get: function () { return phoneNumbers_1.PhoneNumberUtils; } });
var signatureUtils_1 = require("./signatureUtils");

@@ -50,0 +47,0 @@ Object.defineProperty(exports, "SignatureUtils", { enumerable: true, get: function () { return signatureUtils_1.SignatureUtils; } });

@@ -1,4 +0,1 @@

import { BaseProps } from '@celo/base/lib/inputValidation';
export { BaseProps, validateDecimal, validateInteger, ValidatorKind, } from '@celo/base/lib/inputValidation';
export declare function validatePhone(input: string, countryCallingCode?: string): string;
export declare function validateInput(input: string, props: BaseProps): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateInput = exports.validatePhone = exports.ValidatorKind = exports.validateInteger = exports.validateDecimal = void 0;
var inputValidation_1 = require("@celo/base/lib/inputValidation");
var phoneNumbers_1 = require("./phoneNumbers");
exports.ValidatorKind = exports.validateInteger = exports.validateDecimal = void 0;
// Exports moved to @celo/base, forwarding them
// here for backwards compatibility
var inputValidation_2 = require("@celo/base/lib/inputValidation");
Object.defineProperty(exports, "validateDecimal", { enumerable: true, get: function () { return inputValidation_2.validateDecimal; } });
Object.defineProperty(exports, "validateInteger", { enumerable: true, get: function () { return inputValidation_2.validateInteger; } });
Object.defineProperty(exports, "ValidatorKind", { enumerable: true, get: function () { return inputValidation_2.ValidatorKind; } });
function validatePhone(input, countryCallingCode) {
input = input.replace(/[^0-9()\- ]/g, '');
if (!countryCallingCode) {
return input;
}
var displayNumber = (0, phoneNumbers_1.getDisplayPhoneNumber)(input, countryCallingCode);
if (!displayNumber) {
return input;
}
return displayNumber;
}
exports.validatePhone = validatePhone;
function validateInput(input, props) {
if (!props.validator && !props.customValidator) {
return input;
}
switch (props.validator) {
case 'decimal':
return (0, inputValidation_1.validateDecimal)(input, props.decimalSeparator);
case 'integer':
return (0, inputValidation_1.validateInteger)(input);
case 'phone':
return validatePhone(input, props.countryCallingCode);
case 'custom': {
if (props.customValidator) {
return props.customValidator(input);
}
}
}
throw new Error('Unhandled input validator');
}
exports.validateInput = validateInput;
var inputValidation_1 = require("@celo/base/lib/inputValidation");
Object.defineProperty(exports, "validateDecimal", { enumerable: true, get: function () { return inputValidation_1.validateDecimal; } });
Object.defineProperty(exports, "validateInteger", { enumerable: true, get: function () { return inputValidation_1.validateInteger; } });
Object.defineProperty(exports, "ValidatorKind", { enumerable: true, get: function () { return inputValidation_1.ValidatorKind; } });
//# sourceMappingURL=inputValidation.js.map

@@ -5,6 +5,2 @@ import * as t from 'io-ts';

export declare const JSONStringType: t.Type<string, string, unknown>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare const E164PhoneNumberType: t.Type<string, string, unknown>;
export declare const AddressType: t.Type<string, string, unknown>;

@@ -14,85 +10,3 @@ export declare const PublicKeyType: t.Type<string, string, unknown>;

export declare const SaltType: t.StringC;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare const AttestationServiceStatusResponseType: t.TypeC<{
status: t.LiteralC<"ok">;
smsProviders: t.ArrayC<t.StringC>;
blacklistedRegionCodes: t.UnionC<[t.ArrayC<t.StringC>, t.UndefinedC]>;
accountAddress: t.Type<string, string, unknown>;
signature: t.UnionC<[t.StringC, t.UndefinedC]>;
version: t.StringC;
latestBlock: t.NumberC;
ageOfLatestBlock: t.NumberC;
isNodeSyncing: t.BooleanC;
appSignature: t.StringC;
smsProvidersRandomized: t.BooleanC;
maxDeliveryAttempts: t.NumberC;
maxRerequestMins: t.NumberC;
twilioVerifySidProvided: t.BooleanC;
}>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare const AttestationServiceTestRequestType: t.TypeC<{
phoneNumber: t.Type<string, string, unknown>;
message: t.StringC;
signature: t.StringC;
provider: t.UnionC<[t.StringC, t.UndefinedC]>;
}>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare type AttestationServiceTestRequest = t.TypeOf<typeof AttestationServiceTestRequestType>;
export declare type Signature = t.TypeOf<typeof SignatureType>;
export declare type Address = t.TypeOf<typeof AddressType>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare type E164Number = t.TypeOf<typeof E164PhoneNumberType>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare const AttestationRequestType: t.TypeC<{
phoneNumber: t.Type<string, string, unknown>;
account: t.Type<string, string, unknown>;
issuer: t.Type<string, string, unknown>;
salt: t.UnionC<[t.UndefinedC, t.StringC]>;
smsRetrieverAppSig: t.UnionC<[t.UndefinedC, t.StringC]>;
securityCodePrefix: t.UnionC<[t.UndefinedC, t.StringC]>;
language: t.UnionC<[t.UndefinedC, t.StringC]>;
}>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare type AttestationRequest = t.TypeOf<typeof AttestationRequestType>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare const GetAttestationRequestType: t.TypeC<{
phoneNumber: t.Type<string, string, unknown>;
account: t.Type<string, string, unknown>;
issuer: t.Type<string, string, unknown>;
salt: t.UnionC<[t.UndefinedC, t.StringC]>;
securityCode: t.UnionC<[t.UndefinedC, t.StringC]>;
}>;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
export declare type GetAttestationRequest = t.TypeOf<typeof GetAttestationRequestType>;
export declare const AttestationResponseType: t.TypeC<{
success: t.BooleanC;
error: t.UnionC<[t.UndefinedC, t.StringC]>;
errors: t.UnionC<[t.UndefinedC, t.StringC]>;
provider: t.UnionC<[t.UndefinedC, t.StringC]>;
identifier: t.UnionC<[t.UndefinedC, t.StringC]>;
account: t.UnionC<[t.UndefinedC, t.Type<string, string, unknown>]>;
issuer: t.UnionC<[t.UndefinedC, t.Type<string, string, unknown>]>;
status: t.UnionC<[t.UndefinedC, t.StringC]>;
attempt: t.UnionC<[t.UndefinedC, t.NumberC]>;
countryCode: t.UnionC<[t.UndefinedC, t.StringC]>;
duration: t.UnionC<[t.UndefinedC, t.NumberC]>;
salt: t.UnionC<[t.UndefinedC, t.StringC]>;
attestationCode: t.UnionC<[t.UndefinedC, t.StringC]>;
}>;
export declare type AttestationResponse = t.TypeOf<typeof AttestationResponseType>;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.AttestationResponseType = exports.GetAttestationRequestType = exports.AttestationRequestType = exports.AttestationServiceTestRequestType = exports.AttestationServiceStatusResponseType = exports.SaltType = exports.SignatureType = exports.PublicKeyType = exports.AddressType = exports.E164PhoneNumberType = exports.JSONStringType = exports.UrlType = exports.URL_REGEX = exports.isValidUrl = void 0;
exports.SaltType = exports.SignatureType = exports.PublicKeyType = exports.AddressType = exports.JSONStringType = exports.UrlType = exports.URL_REGEX = exports.isValidUrl = void 0;
var io_1 = require("@celo/base/lib/io");

@@ -29,3 +29,2 @@ var ethereumjs_util_1 = require("ethereumjs-util");

var address_1 = require("./address");
var phoneNumbers_1 = require("./phoneNumbers");
// Exports moved to @celo/base, forwarding them

@@ -54,12 +53,2 @@ // here for backwards compatibility

}, String);
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
exports.E164PhoneNumberType = new t.Type('E164Number', t.string.is, function (input, context) {
return Either_1.either.chain(t.string.validate(input, context), function (stringValue) {
return (0, phoneNumbers_1.isE164NumberStrict)(stringValue)
? t.success(stringValue)
: t.failure(stringValue, context, 'is not a valid e164 number');
});
}, String);
exports.AddressType = new t.Type('Address', t.string.is, function (input, context) {

@@ -81,80 +70,2 @@ return Either_1.either.chain(t.string.validate(input, context), function (stringValue) {

exports.SaltType = t.string;
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
exports.AttestationServiceStatusResponseType = t.type({
status: t.literal('ok'),
smsProviders: t.array(t.string),
blacklistedRegionCodes: t.union([t.array(t.string), t.undefined]),
accountAddress: exports.AddressType,
signature: t.union([exports.SignatureType, t.undefined]),
version: t.string,
latestBlock: t.number,
ageOfLatestBlock: t.number,
isNodeSyncing: t.boolean,
appSignature: t.string,
smsProvidersRandomized: t.boolean,
maxDeliveryAttempts: t.number,
maxRerequestMins: t.number,
twilioVerifySidProvided: t.boolean,
});
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
exports.AttestationServiceTestRequestType = t.type({
phoneNumber: exports.E164PhoneNumberType,
message: t.string,
signature: exports.SignatureType,
provider: t.union([t.string, t.undefined]),
});
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
exports.AttestationRequestType = t.type({
phoneNumber: exports.E164PhoneNumberType,
account: exports.AddressType,
issuer: exports.AddressType,
// io-ts way of defining optional key-value pair
salt: t.union([t.undefined, exports.SaltType]),
smsRetrieverAppSig: t.union([t.undefined, t.string]),
// if specified, the message sent will be short random number prefixed by this string
securityCodePrefix: t.union([t.undefined, t.string]),
language: t.union([t.undefined, t.string]),
});
/**
* @deprecated moved to @celo/phone-utils will be removed in next major version
*/
exports.GetAttestationRequestType = t.type({
phoneNumber: exports.E164PhoneNumberType,
account: exports.AddressType,
issuer: exports.AddressType,
// io-ts way of defining optional key-value pair
salt: t.union([t.undefined, exports.SaltType]),
// if the value supplied matches the stored security code, the response will include the complete message
securityCode: t.union([t.undefined, t.string]),
});
exports.AttestationResponseType = t.type({
// Always returned in 1.0.x
success: t.boolean,
// Returned for errors in 1.0.x
error: t.union([t.undefined, t.string]),
// Stringifyed JSON dict of dicts, mapping attempt to error info.
errors: t.union([t.undefined, t.string]),
// Returned for successful send in 1.0.x
provider: t.union([t.undefined, t.string]),
// New fields
identifier: t.union([t.undefined, t.string]),
account: t.union([t.undefined, exports.AddressType]),
issuer: t.union([t.undefined, exports.AddressType]),
status: t.union([t.undefined, t.string]),
attempt: t.union([t.undefined, t.number]),
countryCode: t.union([t.undefined, t.string]),
// Time to receive eventual delivery/failure (inc retries)
duration: t.union([t.undefined, t.number]),
// Only used by test endpoint to return randomly generated salt.
// Never return a user-supplied salt.
salt: t.union([t.undefined, t.string]),
// only returned if the request supplied the correct security code
attestationCode: t.union([t.undefined, t.string]),
});
//# sourceMappingURL=io.js.map
import { NativeSigner, serializeSignature, Signer } from '@celo/base/lib/signatureUtils';
import { EIP712TypedData } from './sign-typed-data-utils';
export { NativeSigner, POP_SIZE, serializeSignature, Signature, Signer, } from '@celo/base/lib/signatureUtils';
export { NativeSigner, POP_SIZE, serializeSignature, Signature, Signer } from '@celo/base/lib/signatureUtils';
export declare function hashMessageWithPrefix(message: string): string;

@@ -5,0 +5,0 @@ export declare function hashMessage(message: string): string;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -71,3 +52,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var signatureUtils_1 = require("@celo/base/lib/signatureUtils");
var Web3Utils = __importStar(require("web3-utils"));
var web3_utils_1 = require("web3-utils");
var address_1 = require("./address");

@@ -84,3 +65,3 @@ var sign_typed_data_utils_1 = require("./sign-typed-data-utils");

function messageLength(message) {
if (Web3Utils.isHexStrict(message)) {
if ((0, web3_utils_1.isHexStrict)(message)) {
return (message.length - 2) / 2;

@@ -94,7 +75,7 @@ }

var prefix = '\x19Ethereum Signed Message:\n' + messageLength(message);
return Web3Utils.soliditySha3(prefix, message);
return (0, web3_utils_1.soliditySha3)(prefix, message);
}
exports.hashMessageWithPrefix = hashMessageWithPrefix;
function hashMessage(message) {
return Web3Utils.soliditySha3({ type: 'string', value: message });
return (0, web3_utils_1.soliditySha3)({ type: 'string', value: message });
}

@@ -101,0 +82,0 @@ exports.hashMessage = hashMessage;

{
"name": "@celo/utils",
"version": "1.5.2",
"version": "2.0.0-alpha.2",
"description": "Celo common utils",

@@ -9,2 +9,3 @@ "author": "Celo",

"types": "./lib/index.d.ts",
"sideEffects": false,
"scripts": {

@@ -23,8 +24,7 @@ "prepublishOnly": "yarn build",

"dependencies": {
"@celo/base": "1.5.2",
"@celo/base": "2.0.0-alpha.2",
"@types/bn.js": "^5.1.0",
"@types/country-data": "^0.0.0",
"@types/elliptic": "^6.4.9",
"@types/ethereumjs-util": "^5.2.0",
"@types/google-libphonenumber": "^7.4.17",
"@types/lodash": "^4.14.170",
"@types/node": "^10.12.18",

@@ -37,14 +37,6 @@ "@types/randombytes": "^2.0.0",

"bls12377js": "https://github.com/celo-org/bls12377js#cb38a4cfb643c778619d79b20ca3e5283a2122a6",
"bn.js": "4.11.8",
"buffer-reverse": "^1.0.1",
"country-data": "^0.0.31",
"crypto-js": "^3.1.9-1",
"elliptic": "^6.5.4",
"ethereumjs-util": "^5.2.0",
"fp-ts": "2.1.1",
"google-libphonenumber": "^3.2.15",
"io-ts": "2.0.1",
"keccak256": "^1.0.0",
"lodash": "^4.17.21",
"numeral": "^2.0.6",
"web3-eth-abi": "1.3.6",

@@ -58,5 +50,7 @@ "web3-utils": "1.3.6"

"resolutions": {
"elliptic/bn.js": "4.11.8",
"web3-utils/bn.js": "4.11.8"
"bn.js": "4.11.9",
"elliptic/bn.js": "bn.js@4.11.9",
"web3-utils/bn.js": "bn.js@4.11.9",
"@ethereumjs/bn.js": "bn.js@4.11.9"
}
}

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

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