Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps!: update libp2p, helia, sub-modules and aegir. #110

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30,851 changes: 18,795 additions & 12,056 deletions package-lock.json

Large diffs are not rendered by default.

100 changes: 54 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,69 +69,77 @@
},
"homepage": "https://github.com/hldb/welo#readme",
"devDependencies": {
"@chainsafe/libp2p-gossipsub": "^10.1.0",
"@chainsafe/libp2p-noise": "^13.0.3",
"@chainsafe/libp2p-yamux": "^5.0.3",
"@helia/interface": "^2.1.0",
"@libp2p/bootstrap": "^9.0.12",
"@libp2p/interface": "^0.1.6",
"@libp2p/kad-dht": "^10.0.15",
"@libp2p/mplex": "^9.0.12",
"@libp2p/tcp": "^8.0.13",
"@libp2p/webrtc": "^3.2.11",
"@libp2p/websockets": "^7.0.13",
"@multiformats/multiaddr": "^12.1.10",
"@types/mocha": "^10.0.0",
"aegir": "^38.1.5",
"blockstore-level": "^1.1.0",
"@chainsafe/libp2p-gossipsub": "^11.0.1",
"@chainsafe/libp2p-noise": "^14.1.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@helia/interface": "^3.0.0",
"@libp2p/bootstrap": "^10.0.10",
"@libp2p/circuit-relay-v2": "^1.0.10",
"@libp2p/identify": "^1.0.9",
"@libp2p/interface": "^1.1.1",
"@libp2p/kad-dht": "^12.0.2",
"@libp2p/keychain": "^4.0.5",
"@libp2p/mplex": "^10.0.10",
"@libp2p/tcp": "^9.0.10",
"@libp2p/webrtc": "^4.0.14",
"@libp2p/websockets": "^8.0.10",
"@multiformats/multiaddr": "^12.1.12",
"@types/mocha": "^10.0.6",
"aegir": "^42.1.0",
"blockstore-level": "^1.1.7",
"copy-deps": "^1.1.2",
"datastore-level": "^10.1.1",
"eslint": "^8.23.0",
"eslint-config-standard-with-typescript": "^23.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"datastore-level": "^10.1.6",
"eslint": "^8.56.0",
"eslint-config-standard-with-typescript": "^37.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-tsdoc": "^0.2.17",
"interface-datastore": "^8.2.0",
"ipns": "^6.0.0",
"interface-datastore": "^8.2.10",
"ipns": "^8.0.0",
"level": "^8.0.0",
"libp2p": "^0.46.21",
"make-dir": "^3.1.0",
"libp2p": "^1.1.1",
"make-dir": "^4.0.0",
"path-browserify": "^1.0.1",
"prettier": "^2.7.1",
"prettier-config-standard": "^5.0.0",
"protons": "^7.0.4",
"tsc-alias": "^1.8.7",
"typescript": "^5.1.6",
"prettier": "^3.1.1",
"prettier-config-standard": "^7.0.0",
"protons": "^7.3.4",
"tsc-alias": "^1.8.8",
"typescript": "^5.3.3",
"wherearewe": "^2.0.1"
},
"dependencies": {
"@alanshaw/pail": "^0.3.3",
"@ipld/car": "^5.2.4",
"@ipld/dag-cbor": "^9.0.6",
"@libp2p/crypto": "^2.0.8",
"@alanshaw/pail": "^0.3.4",
"@ipld/car": "^5.2.5",
"@ipld/dag-cbor": "^9.0.7",
"@libp2p/crypto": "^3.0.4",
"@libp2p/interfaces": "^3.3.2",
"@libp2p/peer-id": "^3.0.6",
"@libp2p/peer-id-factory": "^3.0.8",
"@open-draft/deferred-promise": "^2.1.0",
"@tabcat/zzzync": "^4.2.0",
"datastore-core": "^9.2.3",
"@libp2p/peer-id": "^4.0.4",
"@libp2p/peer-id-factory": "^4.0.3",
"@open-draft/deferred-promise": "^2.2.0",
"@tabcat/zzzync": "^5.0.0",
"datastore-core": "^9.2.7",
"fission-bloom-filters": "^1.7.1",
"helia": "^2.1.0",
"interface-blockstore": "^5.2.6",
"helia": "^3.0.0",
"interface-blockstore": "^5.2.9",
"it-all": "^3.0.4",
"it-concat": "^3.0.1",
"it-drain": "^3.0.5",
"it-length-prefixed": "^9.0.3",
"it-length-prefixed": "^9.0.4",
"it-pushable": "^3.2.3",
"multiformats": "^11.0.1",
"p-queue": "^7.3.0",
"protons-runtime": "^5.0.1",
"multiformats": "^13.0.0",
"p-queue": "^8.0.1",
"protons-runtime": "^5.2.2",
"remove": "^0.1.5",
"streaming-iterables": "^8.0.1",
"uint8arrays": "^4.0.6",
"uint8arrays": "^5.0.1",
"w3name": "^1.0.8",
"web3.storage": "^4.5.4"
"web3.storage": "^4.5.5"
},
"overrides": {
"@alanshaw/pail": {
"multiformats": "$multiformats"
}
},
"copyDependencies": {
"ipfs-core": [
Expand Down
11 changes: 5 additions & 6 deletions src/access/interface.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import type { Startable } from '@libp2p/interfaces/startable'

import type { EntryInstance } from '@/entry/interface.js'
import { HLDB_PREFIX } from '@/utils/constants.js'
import type { ComponentProtocol } from '@/interface.js'
import type { Manifest } from '@/manifest/index'
import type { Startable } from '@libp2p/interfaces/startable'
import { HLDB_PREFIX } from '@/utils/constants.js'

export interface AccessInstance extends Startable {
canAppend: (entry: EntryInstance<any>) => Promise<boolean>
close: () => Promise<void>
canAppend(entry: EntryInstance<any>): Promise<boolean>
close(): Promise<void>
}

export interface Open {
manifest: Manifest
}

export interface AccessComponent<T extends AccessInstance = AccessInstance, P extends string = string> extends ComponentProtocol<P> {
create: (config: Open) => T
create(config: Open): T
}

export const wildcard = '*'
Expand Down
8 changes: 3 additions & 5 deletions src/access/static/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { base32 } from 'multiformats/bases/base32'

import { Playable } from '@/utils/playable.js'
import { type Open, type AccessInstance, type AccessComponent, wildcard } from '../interface.js'
import protocol, { type Config } from './protocol.js'
import type { EntryInstance } from '@/entry/interface.js'
import type { Manifest } from '@/manifest/index.js'

import protocol, { Config } from './protocol.js'
import { wildcard, Open, AccessInstance, AccessComponent } from '../interface.js'
import { Playable } from '@/utils/playable.js'

// the Static in StaticAccess means the ACL is immutable and does not change
export class StaticAccess extends Playable implements AccessInstance {
Expand Down
3 changes: 1 addition & 2 deletions src/access/static/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Protocol } from '@/manifest/interface.js'

import { prefix } from '../interface.js'
import type { Protocol } from '@/manifest/interface.js'

const protocol = `${prefix}static` as const

Expand Down
22 changes: 10 additions & 12 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ import { EventEmitter, CustomEvent } from '@libp2p/interfaces/events'
import { start, stop } from '@libp2p/interfaces/startable'
import { NamespaceDatastore } from 'datastore-core'
import { Key } from 'interface-datastore'
import type { CID } from 'multiformats/cid'
import type { Datastore } from 'interface-datastore'

import { Playable } from '@/utils/playable.js'
import { Replica } from '@/replica/index.js'
import type { DbConfig, DbOpen, DbEvents, ClosedEmit, DbComponents } from './interface.js'
import type { AccessInstance } from '@/access/interface.js'
import type { IdentityInstance } from '@/identity/interface.js'
import type { Address } from '@/manifest/address.js'
import type { Manifest } from '@/manifest/index.js'
import type { AccessInstance } from '@/access/interface.js'
import type { Creator, Selector, StoreInstance } from '@/store/interface.js'
import type { Replicator } from '@/replicator/interface.js'
import type { Creator, Selector, StoreInstance } from '@/store/interface.js'
import type { Datastore } from 'interface-datastore'
import type { CID } from 'multiformats/cid'
import { Replica } from '@/replica/index.js'
import { STORE_NAMESPACE, REPLICA_NAMESPACE } from '@/utils/constants.js'

import type { DbConfig, DbOpen, DbEvents, ClosedEmit, DbComponents } from './interface.js'
import { Playable } from '@/utils/playable.js'

/**
* Database Class
Expand Down Expand Up @@ -72,7 +70,7 @@ export class Database extends Playable {
// todo: handle async action creators

interface CreatorProps {
value: (...args: any[]) => Promise<CID>
value(...args: any[]): Promise<CID>
}

const handleCreator = ([key, creator]: [string, Creator]): [
Expand All @@ -82,12 +80,12 @@ export class Database extends Playable {
key,
{
value: async (...args: any[]): Promise<CID> =>
await this.replica.write(creator(...args)).then((entry) => entry.cid)
this.replica.write(creator(...args)).then((entry) => entry.cid)
}
]

interface SelectorProps {
value: (...args: any[]) => Promise<any>
value(...args: any[]): Promise<any>
}

const handleSelector = ([key, selector]: [string, Selector]): [
Expand Down
10 changes: 4 additions & 6 deletions src/entry/basal/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import type { BlockView } from 'multiformats/interface'
import type { CID } from 'multiformats/cid'

import { encodeCbor, decodeCbor } from '@/utils/block.js'
import type { IdentityInstance } from '@/identity/interface.js'

import protocol from './protocol.js'
import type {
EntryData,
Expand All @@ -13,6 +7,10 @@ import type {
Fetch,
AsEntry
} from '../interface.js'
import type { IdentityInstance } from '@/identity/interface.js'
import type { CID } from 'multiformats/cid'
import type { BlockView } from 'multiformats/interface'
import { encodeCbor, decodeCbor } from '@/utils/block.js'

export interface SignedEntry {
auth: CID
Expand Down
2 changes: 1 addition & 1 deletion src/entry/basal/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Protocol } from '@/manifest/interface.js'
import { prefix } from '../interface.js'
import type { Protocol } from '@/manifest/interface.js'

const protocol = `${prefix}basal` as const

Expand Down
17 changes: 8 additions & 9 deletions src/entry/interface.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { BlockView } from 'multiformats/interface'
import type { CID } from 'multiformats/cid'

import { HLDB_PREFIX } from '@/utils/constants.js'
import type { ComponentProtocol } from '@/interface.js'
import type { IdentityInstance, IdentityComponent } from '@/identity/interface.js'
import type { ComponentProtocol } from '@/interface.js'
import type { Blockstore } from 'interface-blockstore'
import type { CID } from 'multiformats/cid'
import type { BlockView } from 'multiformats/interface'
import { HLDB_PREFIX } from '@/utils/constants.js'

export interface EntryData {
tag: Uint8Array
Expand Down Expand Up @@ -33,10 +32,10 @@ export interface Fetch {
export type AsEntry<Value> = Pick<EntryInstance<Value>, 'block' | 'identity'>

export interface EntryComponent<T extends EntryInstance<unknown> = EntryInstance<unknown>, P extends string = string> extends ComponentProtocol<P> {
create: (create: Create) => Promise<T>
fetch: (fetch: Fetch) => Promise<T>
asEntry: (entry: AsEntry<unknown>) => Promise<T | null>
verify: (entry: AsEntry<unknown>) => Promise<boolean>
create(create: Create): Promise<T>
fetch(fetch: Fetch): Promise<T>
asEntry(entry: AsEntry<unknown>): Promise<T | null>
verify(entry: AsEntry<unknown>): Promise<boolean>
}

export const prefix = `${HLDB_PREFIX}entry/` as const
19 changes: 9 additions & 10 deletions src/identity/basal/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import * as codec from '@ipld/dag-cbor'
import { keys } from '@libp2p/crypto'
import { Key } from 'interface-datastore'
import * as Block from 'multiformats/block'
import * as codec from '@ipld/dag-cbor'
import { sha256 as hasher } from 'multiformats/hashes/sha2'
import type { PrivateKey, PublicKey } from '@libp2p/interface/keys'
import { Key } from 'interface-datastore'
import type { BlockView } from 'multiformats/interface'
import type { CID } from 'multiformats/cid'

import protocol from './protocol.js'
import type {
IdentityInstance,
Expand All @@ -17,6 +13,9 @@ import type {
Get,
Import
} from '../interface.js'
import type { PrivateKey, PublicKey } from '@libp2p/interface/keys'
import type { CID } from 'multiformats/cid'
import type { BlockView } from 'multiformats/interface'
import { decodeCbor, encodeCbor } from '@/utils/block.js'

const secp256k1 = 'secp256k1'
Expand Down Expand Up @@ -83,18 +82,18 @@ export class Identity implements IdentityInstance<IdentityValue> {
}

async sign (data: Uint8Array): Promise<Uint8Array> {
return await sign(this, data)
return sign(this, data)
}

async verify (data: Uint8Array, sig: Uint8Array): Promise<boolean> {
return await verify(this, data, sig)
return verify(this, data, sig)
}
}

const gen = async (name: string): Promise<Identity> => {
const keypair = await keys.generateKeyPair(secp256k1, 256)
const value = await signIdentity(keypair, keypair.public)
const block = await Block.encode({ value, codec, hasher })
const block = await Block.encode<IdentityValue, number, number>({ value, codec, hasher })

return new Identity({ name, priv: keypair, pubkey: keypair.public, block })
}
Expand Down Expand Up @@ -264,7 +263,7 @@ const verify = async (
throw new Error('invalid identity used')
}

return await _identity.pubkey.verify(data, sig)
return _identity.pubkey.verify(data, sig)
}

export const basalIdentity: () => IdentityComponent<Identity, typeof protocol> = () => ({
Expand Down
3 changes: 1 addition & 2 deletions src/identity/basal/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Protocol } from '@/manifest/interface.js'

import { prefix } from '../interface.js'
import type { Protocol } from '@/manifest/interface.js'

const protocol = `${prefix}basal` as const

Expand Down
Loading
Loading