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

@dioxide-js/misc

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dioxide-js/misc - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

12

CHANGELOG.md

@@ -5,2 +5,14 @@ # Changelog

### [0.1.4](https://github.com/duiyuan/misc/compare/v0.1.3...v0.1.4) (2022-06-06)
### Features
* address add addressToShard fn ([2d6a6cb](https://github.com/duiyuan/misc/commit/2d6a6cb8689ee8e13d158e197860a5d178525262))
### Bug Fixes
* build support es6 iterator ([0fbb8b3](https://github.com/duiyuan/misc/commit/0fbb8b34685724a2504224cad9cd42ad641cc319))
### [0.1.3](https://github.com/duiyuan/misc/compare/v0.1.2...v0.1.3) (2022-06-03)

@@ -7,0 +19,0 @@

59

dist/lib/address.js
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,3 +31,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.isDioxideAddress = void 0;
exports.addressToShard = exports.isDioxideAddress = void 0;
var crc32c_1 = __importDefault(require("crc-32/crc32c"));

@@ -24,3 +49,3 @@ var base32_encode_1 = __importDefault(require("base32-encode"));

address = address.toLocaleLowerCase().replace(':ed25519', '');
var addr = new Uint8Array(base32_decode_1.default(address, 'Crockford'));
var addr = new Uint8Array((0, base32_decode_1.default)(address, 'Crockford'));
var publicKey = addr.slice(0, 32);

@@ -32,4 +57,4 @@ var errorCorrectingCode = crc32c_1.default.buf(publicKey, 3);

var errorCorrectingCodeBuffer = new Uint8Array(buffer);
var mergedBuffer = dataview_1.concat(publicKey, errorCorrectingCodeBuffer);
var encodedMergeBuffer = base32_encode_1.default(mergedBuffer, 'Crockford');
var mergedBuffer = (0, dataview_1.concat)(publicKey, errorCorrectingCodeBuffer);
var encodedMergeBuffer = (0, base32_encode_1.default)(mergedBuffer, 'Crockford');
return encodedMergeBuffer === address.toUpperCase();

@@ -42,2 +67,28 @@ }

exports.isDioxideAddress = isDioxideAddress;
/**
* address to shard
* @param address
* @param shardOrder
* @returns shard
*/
var addressToShard = function (address, shardOrder) {
var colonIdx = address.lastIndexOf(':');
if (colonIdx === -1)
throw 'invalid address format';
var unit8Array = new Uint8Array((0, base32_decode_1.default)(address.substring(0, colonIdx), 'Crockford'));
var decoded = String.fromCharCode.apply(null, __spreadArray([], __read(unit8Array), false));
if (!decoded || decoded.length != 36)
throw 'invalid address format';
var dwords = new Uint32Array(9);
for (var i = 0; i < 9; i++) {
dwords[i] = 0;
for (var j = 0; j < 4; j++) {
dwords[i] += decoded.charCodeAt(i * 4 + j) << (j * 8);
}
}
var shardDword = dwords[0] ^ dwords[7] ^ dwords[4];
var shardMask = ~(0xffffffff << shardOrder);
return shardDword & shardMask;
};
exports.addressToShard = addressToShard;
//# sourceMappingURL=address.js.map

2

dist/lib/dataview.js

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

function base64ToArraybuffer(content) {
return base64_arraybuffer_1.decode(content);
return (0, base64_arraybuffer_1.decode)(content);
}

@@ -109,0 +109,0 @@ exports.base64ToArraybuffer = base64ToArraybuffer;

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

if (ch === void 0) { ch = '0'; }
var output = "" + num;
var output = "".concat(num);
while (output.length < len) {
output = "" + ch + output;
output = "".concat(ch).concat(output);
}

@@ -46,3 +46,3 @@ return output;

var since = function (val) {
var time = moment_mini_1.default(val);
var time = (0, moment_mini_1.default)(val);
var now = Date.now();

@@ -49,0 +49,0 @@ if (!time.isValid()) {

"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]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

@@ -8,1 +8,8 @@ /**

export declare function isDioxideAddress(address: string, alg: 'ed25519'): boolean;
/**
* address to shard
* @param address
* @param shardOrder
* @returns shard
*/
export declare const addressToShard: (address: string, shardOrder: number) => number;
{
"name": "@dioxide-js/misc",
"version": "0.1.3",
"version": "0.1.4",
"description": "Simple misc",

@@ -78,7 +78,8 @@ "keywords": [],

"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.18.0",
"rollup-plugin-typescript2": "^0.32.0",
"shelljs": "^0.8.3",
"ts-jest": "^28.0.3",
"ts-node": "^7.0.1",
"typescript": "^4.3.2"
"tslib": "^2.4.0",
"typescript": "^4.7.3"
},

@@ -85,0 +86,0 @@ "dependencies": {

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 too big to display

Sorry, the diff of this file is not supported yet

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

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