Skip to content

Commit

Permalink
deps: export no-op for maxEventListener for react native (libp2p#2136)
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Nov 10, 2023
1 parent 1ab3709 commit 75b827e
Show file tree
Hide file tree
Showing 74 changed files with 12,567 additions and 0 deletions.
167 changes: 167 additions & 0 deletions packages/interface/src/keychain/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/**
* @packageDocumentation
*
* The libp2p keychain provides an API to store keys in a datastore in
* an encrypted format.
*
* @example
*
* ```typescript
* import { createLibp2p } from 'libp2p'
* import { FsDatastore } from 'datastore-fs'
*
* const node = await createLibp2p({
* datastore: new FsDatastore('/path/to/dir')
* })
*
* const info = await node.keychain.createKey('my-new-key', 'Ed25519')
*
* console.info(info) // { id: '...', name: 'my-new-key' }
* ```
*/

import type { KeyType } from '../keys/index.js'
import type { PeerId } from '../peer-id/index.js'
import type { Multibase } from 'multiformats/bases/interface'

export interface KeyInfo {
/**
* The universally unique key id
*/
id: string

/**
* The local key name
*/
name: string
}

export interface KeyChain {
/**
* Export an existing key as a PEM encrypted PKCS #8 string.
*
* @example
*
* ```js
* await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
* ```
*/
exportKey(name: string, password: string): Promise<Multibase<'m'>>

/**
* Import a new key from a PEM encoded PKCS #8 string.
*
* @example
*
* ```js
* await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
* const keyInfo = await libp2p.keychain.importKey('keyTestImport', pemKey, 'password123')
* ```
*/
importKey(name: string, pem: string, password: string): Promise<KeyInfo>

/**
* Import a new key from a PeerId with a private key component
*
* @example
*
* ```js
* const keyInfo = await libp2p.keychain.importPeer('keyTestImport', peerIdFromString('12D3Foo...'))
* ```
*/
importPeer(name: string, peerId: PeerId): Promise<KeyInfo>

/**
* Export an existing key as a PeerId
*
* @example
*
* ```js
* const peerId = await libp2p.keychain.exportPeerId('key-name')
* ```
*/
exportPeerId(name: string): Promise<PeerId>

/**
* Create a key in the keychain.
*
* @example
*
* ```js
* const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* ```
*/
createKey(name: string, type: KeyType, size?: number): Promise<KeyInfo>

/**
* List all the keys.
*
* @example
*
* ```js
* const keyInfos = await libp2p.keychain.listKeys()
* ```
*/
listKeys(): Promise<KeyInfo[]>

/**
* Removes a key from the keychain.
*
* @example
*
* ```js
* await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* const keyInfo = await libp2p.keychain.removeKey('keyTest')
* ```
*/
removeKey(name: string): Promise<KeyInfo>

/**
* Rename a key in the keychain.
*
* @example
*
* ```js
* await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* const keyInfo = await libp2p.keychain.renameKey('keyTest', 'keyNewNtest')
* ```
*/
renameKey(oldName: string, newName: string): Promise<KeyInfo>

/**
* Find a key by it's id.
*
* @example
*
* ```js
* const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* const keyInfo2 = await libp2p.keychain.findKeyById(keyInfo.id)
* ```
*/
findKeyById(id: string): Promise<KeyInfo>

/**
* Find a key by it's name.
*
* @example
*
* ```js
* const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* const keyInfo2 = await libp2p.keychain.findKeyByName('keyTest')
* ```
*/
findKeyByName(name: string): Promise<KeyInfo>

/**
* Rotate keychain password and re-encrypt all associated keys
*
* @example
*
* ```js
* await libp2p.keychain.rotateKeychainPass('oldPassword', 'newPassword')
* ```
*/
rotateKeychainPass(oldPass: string, newPass: string): Promise<void>
}
19 changes: 19 additions & 0 deletions packages/libp2p/src/autonat/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* The prefix to use in the protocol
*/
export const PROTOCOL_PREFIX = 'libp2p'

/**
* The name to use in the protocol
*/
export const PROTOCOL_NAME = 'autonat'

/**
* The version to use in the protocol
*/
export const PROTOCOL_VERSION = '1.0.0'
export const TIMEOUT = 30000
export const STARTUP_DELAY = 5000
export const REFRESH_INTERVAL = 60000
export const MAX_INBOUND_STREAMS = 1
export const MAX_OUTBOUND_STREAMS = 1
Loading

0 comments on commit 75b827e

Please sign in to comment.