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

@peerbit/stream-interface

Package Overview
Dependencies
Maintainers
0
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerbit/stream-interface - npm Package Compare versions

Comparing version

to
5.0.3-171d517

dist/src/index.d.ts

132

package.json
{
"name": "@peerbit/stream-interface",
"version": "5.0.2",
"description": "Block store streaming",
"type": "module",
"sideEffects": false,
"private": false,
"publishConfig": {
"access": "public"
},
"module": "lib/esm/index.js",
"types": "lib/esm/index.d.ts",
"exports": {
"import": "./lib/esm/index.js"
},
"scripts": {
"clean": "shx rm -rf lib/*",
"build": "yarn clean && tsc -p tsconfig.json",
"test": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.ts --runInBand --forceExit",
"test:unit": "node ../../../node_modules/.bin/jest test -c ../../../jest.config.unit.ts --runInBand --forceExit",
"test:integration": "node ../node_modules/.bin/jest test -c ../../../jest.config.integration.ts --runInBand --forceExit"
},
"files": [
"lib",
"src",
"!src/**/__tests__",
"!lib/**/__tests__",
"!src/**/__benchmark__",
"!lib/**/__benchmark__",
"LICENSE"
],
"engines": {
"node": ">=16.15.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dao-xyz/peerbit.git"
},
"keywords": [
"peerbit"
],
"author": "dao.xyz",
"license": "MIT",
"bugs": {
"url": "https://github.com/dao-xyz/peerbit/issues"
},
"homepage": "https://github.com/dao-xyz/peerbit#readme",
"localMaintainers": [
"dao.xyz"
],
"dependencies": {
"@dao-xyz/borsh": "^5.2.1",
"@peerbit/crypto": "2.2.0"
},
"gitHead": "fcd486b9a5c3b7d94e2ae14f1b06ab2a0f7841ad"
"name": "@peerbit/stream-interface",
"version": "5.0.3-171d517",
"description": "Block store streaming",
"sideEffects": false,
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
}
},
"eslintConfig": {
"extends": "peerbit",
"parserOptions": {
"project": true,
"sourceType": "module"
},
"ignorePatterns": [
"!.aegir.js",
"test/ts-use",
"*.d.ts"
]
},
"publishConfig": {
"access": "public"
},
"scripts": {
"clean": "aegir clean",
"build": "aegir build --no-bundle",
"test": "",
"lint": "aegir lint"
},
"engines": {
"node": ">=16.15.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dao-xyz/peerbit.git"
},
"keywords": [
"peerbit"
],
"author": "dao.xyz",
"license": "MIT",
"bugs": {
"url": "https://github.com/dao-xyz/peerbit/issues"
},
"homepage": "https://github.com/dao-xyz/peerbit#readme",
"localMaintainers": [
"dao.xyz"
],
"dependencies": {
"@dao-xyz/borsh": "^5.2.3",
"@peerbit/crypto": "2.3.0-171d517"
}
}

@@ -1,3 +0,3 @@

# Direct block
# Stream interface
Block swap/share protocol built on top of [Direct Stream](./../direct-stream/README.md)
Message types for the Stream protocol

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

import { PublicSignKey } from "@peerbit/crypto";
import type { PeerId } from "@libp2p/interface";
import { DataMessage, Message } from "./messages.js";
import type { PublicSignKey } from "@peerbit/crypto";
import type { DataMessage, Message } from "./messages.js";

@@ -23,3 +23,3 @@ export interface PeerEvents {

peer: PeerId | PublicSignKey,
options?: { signal?: AbortSignal }
options?: { signal?: AbortSignal },
): Promise<void>;

@@ -34,6 +34,2 @@ }

export class DeliveryError extends Error {
constructor(message?: string) {
super(message);
}
}
export class DeliveryError extends Error {}
import {
deserialize,
field,
fixedArray,
option,
serialize,
variant,
vec,
field,
serialize,
deserialize,
fixedArray,
option
} from "@dao-xyz/borsh";
import { Uint8ArrayList } from "uint8arraylist";
import type { PeerId } from "@libp2p/interface";
import {
PublicSignKey,
SignatureWithKey,
verify,
getPublicKeyFromPeerId,
randomBytes,
sha256Base64,
getPublicKeyFromPeerId
verify,
} from "@peerbit/crypto";
import { Uint8ArrayList } from "uint8arraylist";
import type { PeerId } from "@libp2p/interface";
export const ID_LENGTH = 32;

@@ -35,28 +34,5 @@

// next 32 bytes should be an id
//return Buffer.from(msg.slice(0, 33)).toString('base64');
return sha256Base64(msg.subarray(0, 33)); // base64EncArr(msg, 0, ID_LENGTH + 1);
};
let concatBytes: (arr: Uint8Array[], totalLength: number) => Uint8Array;
if ((globalThis as any).Buffer) {
concatBytes = (globalThis as any).Buffer.concat;
} else {
concatBytes = (arrays, length) => {
if (length == null) {
let length = 0;
for (const element of arrays) {
length += element.length;
}
}
const output = new Uint8Array(length);
let offset = 0;
for (const arr of arrays) {
output.set(arr, offset);
offset += arr.length;
}
return output;
};
}
const coerceTo = (tos: (string | PublicSignKey | PeerId)[] | Set<string>) => {

@@ -80,3 +56,3 @@ const toHashes: string[] = [];

export const deliveryModeHasReceiver = (
mode: DeliveryMode
mode: DeliveryMode,
): mode is { to: string[] } => {

@@ -136,3 +112,3 @@ if (mode instanceof SilentDelivery && mode.to.length > 0) {

throw new Error(
"Invalud value of property 'to', expecting either undefined or an array with more than one element"
"Invalud value of property 'to', expecting either undefined or an array with more than one element",
);

@@ -164,3 +140,3 @@ }

throw new Error(
"Invalud value of property 'to', expecting either undefined or an array with more than one element"
"Invalud value of property 'to', expecting either undefined or an array with more than one element",
);

@@ -185,7 +161,3 @@ }

@variant(4)
export class AnyWhere extends DeliveryMode {
constructor() {
super();
}
}
export class AnyWhere extends DeliveryMode {}

@@ -331,3 +303,3 @@ @variant(0)

obj: T,
signer: (bytes: Uint8Array) => Promise<SignatureWithKey>
signer: (bytes: Uint8Array) => Promise<SignatureWithKey>,
): Promise<T> => {

@@ -345,3 +317,3 @@ const mode = obj.header.mode;

obj.header.signatures = new Signatures(
signatures ? [...signatures.signatures, signature] : [signature]
signatures ? [...signatures.signatures, signature] : [signature],
);

@@ -354,3 +326,3 @@ obj.header.mode = mode;

message: WithHeader,
expectSignatures: boolean
expectSignatures: boolean,
) => {

@@ -394,3 +366,3 @@ const signatures = message.header.signatures;

async sign(
signer: (bytes: Uint8Array) => Promise<SignatureWithKey>
signer: (bytes: Uint8Array) => Promise<SignatureWithKey>,
): Promise<this> {

@@ -421,3 +393,3 @@ return sign(this, signer);

| AcknowledgeDelivery
| AnyWhere
| AnyWhere,
> extends Message<T> {

@@ -424,0 +396,0 @@ @field({ type: MessageHeader })