@peerbit/stream-interface
Advanced tools
Comparing version
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-5901172", | ||
"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-5901172" | ||
} | ||
} |
@@ -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 }) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
12
9.09%0
-100%54649
-13.06%1180
-4.76%2
Infinity%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated