Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Fundb #51

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ Iris is a fully decentralized p2p database that you can use to build all kinds o
Used by [iris-messenger](https://iris.to) ([source](https://github.com/irislib/iris-messenger)), a decentralized social
networking application.


# TODO
put somewhere

config.module.rules.push({
test: /\.worker\.js$/,
loader: 'worker-loader',
options: {
worker: "Worker",
}
});
config.module.rules.push({
test: /\.sharedworker\.js$/,
loader: 'worker-loader',
options: {
worker: "SharedWorker",
}
});

## Installation

```sh
Expand Down
20 changes: 5 additions & 15 deletions dist/Channel.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'gun/sea';
/**
* Private communication channel between two or more participants ([Gun](https://github.com/amark/gun) public keys). Can be used independently of other Iris stuff.
*
Expand Down Expand Up @@ -39,12 +38,12 @@ import 'gun/sea';
*
* var gun1 = new Gun('https://gun-us.herokuapp.com/gun');
* var gun2 = new Gun('https://gun-us.herokuapp.com/gun');
* var myKey = await iris.Key.getDefault();
* var myKey = await Key.getDefault();
* var someoneElse = localStorage.getItem('someoneElsesKey');
* if (someoneElse) {
* someoneElse = JSON.parse(someoneElse);
* } else {
* someoneElse = await iris.Key.generate();
* someoneElse = await Key.generate();
* localStorage.setItem('someoneElsesKey', JSON.stringify(someoneElse));
* }
*
Expand Down Expand Up @@ -133,14 +132,14 @@ declare class Channel {
/**
*
*/
static getOurSecretChannelId(pub: any, pair: any): Promise<string | undefined>;
static getOurSecretChannelId(pub: any, pair: any): Promise<string | ArrayBuffer>;
/**
*
*/
static getTheirSecretChannelId(pub: any, pair: any): Promise<string | undefined>;
static getTheirSecretChannelId(pub: any, pair: any): Promise<string | ArrayBuffer>;
/**
* Calls back with Channels that you have initiated or written to.
* @param {Object} keypair Gun.SEA keypair that the gun instance is authenticated with
* @param {Object} keypair Key keypair that the gun instance is authenticated with
* @param callback callback function that is called for each public key you have a channel with
*/
static getChannels(callback: any, listenToChatLinks?: boolean): Promise<void>;
Expand Down Expand Up @@ -219,11 +218,6 @@ declare class Channel {
*/
getTyping(callback: any, timeout?: number): void;
/**
* Add a chat button to page
* @param options {label, channelOptions}
*/
static addChatButton(options?: {}): void;
/**
* Get a simple link that points to the channel.
*
* Direct channel: both users need to give their simple links. Use createChatLink() to get a two-way link that needs to be given by one user only.
Expand All @@ -237,10 +231,6 @@ declare class Channel {
getChatLinks(opts?: any): Promise<void>;
createChatLink(urlRoot?: string): Promise<string>;
/**
* Get a channel box element that you can add to your page
*/
getChatBox(): HTMLElement;
/**
* Set the user's online/active status
* @param {string} activity string: set the activity status every 3 seconds, null/false: stop updating
*/
Expand Down
39 changes: 25 additions & 14 deletions dist/Key.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import 'gun/sea';
declare class Key {
static getActiveKey(datadir?: string, keyfile?: string, fs?: any): Promise<any>;
static getDefault(datadir?: string, keyfile?: string): Promise<any>;
static getActivePub(datadir?: string, keyfile?: string): Promise<any>;
static setActiveKey(key: any, save: boolean | undefined, datadir: string | undefined, keyfile: string | undefined, fs: any): void;
static toString(key: any): string;
static getId(key: any): any;
static fromString(str: string): any;
static generate(): Promise<import("gun").ISEAPair>;
static sign(msg: any, pair: any): Promise<string>;
static verify(msg: any, pubKey: any): Promise<any>;
}
export default Key;
/// <reference types="node" />
declare const _default: {
getActiveKey(datadir?: string, keyfile?: string, fs?: any): Promise<any>;
getDefault(datadir?: string, keyfile?: string): Promise<any>;
getActivePub(datadir?: string, keyfile?: string): Promise<any>;
setActiveKey(key: any, save: boolean | undefined, datadir: string | undefined, keyfile: string | undefined, fs: any): void;
toString(key: any): string;
getId(key: any): any;
fromString(str: string): any;
generate(): Promise<{
pub: any;
priv: any;
epub: any;
epriv: any;
} | undefined>;
keyToJwk(key: any): JsonWebKey;
sign(data: any, pair: any, cb?: Function | undefined, opt?: any): Promise<any>;
verify(data: any, pair: any, cb?: Function | undefined, opt?: any): Promise<any>;
secret(key: any, pair: any): Promise<string | undefined>;
aeskey(key: any, salt?: Buffer | undefined): Promise<CryptoKey>;
random(len: number): Buffer;
encrypt(data: any, pair: any, cb?: Function | undefined, opt?: any): Promise<any>;
decrypt(data: any, pair: any, cb?: Function | undefined, opt?: any): Promise<string>;
};
export default _default;
54 changes: 0 additions & 54 deletions dist/Node.d.ts

This file was deleted.

38 changes: 1 addition & 37 deletions dist/SignedMessage.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Attribute from './Attribute';
/**
* Signed message object. Your friends can index and relay your messages, while others can still verify that they were signed by you.
*
Expand All @@ -15,48 +14,16 @@ import Attribute from './Attribute';
* Constructor: creates a message from the param obj.signedData that must contain at least the mandatory fields: author, type and time.
* @param obj
*
* @example
* https://github.com/irislib/iris-lib/blob/master/__tests__/SignedMessage.js
*
* Verification message:
* {
* signedData: {
* author: {name:'Alice', key:'ABCD1234'},
* recipient: {
* name: 'Bob',
* email: ['[email protected]', '[email protected]'],
* bitcoin: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
* },
* type: 'verification'
* },
* signer: 'ABCD1234',
* signature: '1234ABCD'
* }
*/
declare class SignedMessage {
signedData: any;
pubKey: any;
sig: any;
constructor(obj: any);
static _getArray(authorOrRecipient: any): Attribute[];
static _getIterable(authorOrRecipient: any): {
[Symbol.iterator](): Generator<Attribute, void, unknown>;
};
getAuthorIterable(): {
[Symbol.iterator](): Generator<Attribute, void, unknown>;
};
getRecipientIterable(): {
[Symbol.iterator](): Generator<Attribute, void, unknown>;
};
getAuthorArray(): Attribute[];
getRecipientArray(): Attribute[];
getSignerKeyID(): any;
_validate(): boolean;
isPositive(): boolean;
isNegative(): boolean;
isNeutral(): boolean;
/**
* @param {Object} key Gun.SEA keypair to sign the message with
* @param {Object} key keypair to sign the message with
*/
sign(key: any): Promise<boolean>;
/**
Expand All @@ -66,8 +33,6 @@ declare class SignedMessage {
* @returns {Promise<SignedMessage>} message
*/
static create(signedData: any, signingKey: any): Promise<SignedMessage>;
static createVerification(signedData: any, signingKey: any): Promise<SignedMessage>;
static createRating(signedData: any, signingKey: any): Promise<SignedMessage>;
getAuthor(index: any): any;
getRecipient(index: any): any;
/**
Expand All @@ -93,6 +58,5 @@ declare class SignedMessage {
*/
static deserialize(s: any): Promise<SignedMessage>;
static fromString(s: any): Promise<SignedMessage>;
static setReaction(gun: any, msg: any, reaction: any): Promise<void>;
}
export default SignedMessage;
8 changes: 8 additions & 0 deletions dist/db/Actor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Message } from './Message';
export declare function generateUuid(): string;
export declare class Actor {
id: string;
handle(_message: Message): void;
postMessage(message: Message): void;
constructor(id?: string);
}
50 changes: 50 additions & 0 deletions dist/db/Message.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Actor } from './Actor';
import { Children } from "./Node";
export declare class Message {
static fromObject(obj: any): Message;
static deserialize(str: string, from: Actor): Promise<Message>;
serialize(): string;
}
export declare class Get implements Message {
type: string;
id: string;
nodeId: string;
from: Actor;
recipients?: string[];
childKey?: string;
jsonStr?: string;
checksum?: string;
serialize(): string;
static deserialize(obj: any, jsonStr: string, from: Actor): Promise<Get>;
static fromObject(obj: any): Get;
static new(nodeId: string, from: Actor, recipients?: string[], childKey?: string, jsonStr?: string, checksum?: string): Get;
constructor(id: string, nodeId: string, from: Actor, recipients?: string[], childKey?: string, jsonStr?: string, checksum?: string);
}
export declare type UpdatedNodes = {
[key: string]: Children;
};
export declare class Put implements Message {
type: string;
id: string;
from: Actor;
updatedNodes: UpdatedNodes;
inResponseTo?: string;
recipients?: string[];
jsonStr?: string;
checksum?: string;
serialize(): string;
static deserialize(obj: any, jsonStr: string, from: Actor): Promise<Put>;
static fromObject(obj: any): Put;
static new(updatedNodes: UpdatedNodes, from: Actor, inResponseTo?: string, recipients?: string[], jsonStr?: string, checksum?: string): Put;
static newFromKv(key: string, children: Children, from: Actor): Put;
constructor(id: string, updatedNodes: UpdatedNodes, from: Actor, inResponseTo?: string, recipients?: string[], jsonStr?: string, checksum?: string);
}
export declare class Hi implements Message {
type: string;
peerId: string;
jsonStr?: string;
serialize(): string;
static deserialize(obj: any): Hi;
constructor(peerId: string, jsonStr?: string);
}
export declare function messageFromJsonString(jsonStr: string, from: Actor): Message;
47 changes: 47 additions & 0 deletions dist/db/Node.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Actor } from './Actor';
import { Message } from './Message';
import Router from './Router';
export declare type NodeData = {
value: any;
updatedAt: number;
};
export declare type Children = {
[key: string]: NodeData;
};
export declare type Config = {
peerId?: string;
allowPublicSpace: boolean;
myPublicKey?: string;
enableStats: boolean;
webSocketPeers?: string[];
localOnly: boolean;
};
export declare const DEFAULT_CONFIG: Config;
export default class Node extends Actor {
root: Node;
parent?: Node;
children: Map<string, Node>;
once_subscriptions: Map<number, Function>;
on_subscriptions: Map<number, Function>;
map_subscriptions: Map<number, Function>;
counter: number;
config: Config;
currentUser: any;
router: Router;
constructor(id?: string, config?: Config, parent?: Node);
getCurrentUser(): any;
setCurrentUser(key: any): void;
handle(message: Message): void;
get(key: string): Node;
user(pub: string | undefined): Node;
auth(key: any): void;
doCallbacks: (data: NodeData, key: string) => void;
put(value: any): Promise<void>;
private signIfNeeded;
private addParentNodes;
private request;
once(callback?: Function | null): Promise<any>;
on(callback: Function): void;
map(callback: Function): void;
opt(opts: any): void;
}
17 changes: 17 additions & 0 deletions dist/db/Router.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Actor } from "./Actor";
import { Put, Get, Message } from "./Message";
export default class Router extends Actor {
storageAdapters: Set<Actor>;
networkAdapters: Set<Actor>;
serverPeers: Set<Actor>;
seenMessages: Set<string>;
seenGetMessages: Map<string, Message>;
subscribersByTopic: Map<string, Set<Actor>>;
msgCounter: number;
peerId: string;
constructor(config?: any);
handle(message: Message): void;
handlePut(put: Put): void;
opt(opts: any): void;
handleGet(get: Get): void;
}
Loading