This commit is contained in:
Daniel Lugo 2021-10-08 14:57:47 -04:00
parent 62c833862b
commit 3f89ec57ba
5 changed files with 61 additions and 61 deletions

View file

@ -5,7 +5,6 @@ const uuidv1 = require('uuid/v1')
const logger = require('../../../config/log')
const Common = require('shock-common')
const { Constants, Schema } = Common
const Gun = require('gun')
const { ErrorCode } = Constants

View file

@ -15,7 +15,6 @@ const SchemaManager = require('../../../schema')
const LightningServices = require('../../../../utils/lightningServices')
const Key = require('../key')
const Utils = require('../utils')
const Gun = require('gun')
const { selfContentToken, enrollContentTokens } = require('../../../seed')
/// <reference path="../../../utils/GunSmith/Smith.ts" />
const TipForwarder = require('../../../tipsCallback')

View file

@ -6,7 +6,6 @@
const { makePromise, Constants, Schema } = require('shock-common')
const mapValues = require('lodash/mapValues')
const Bluebird = require('bluebird')
const Gun = require('gun')
const { pubToEpub } = require('../contact-api/utils')
const {

View file

@ -58,38 +58,6 @@ namespace GunT {
export type LoadListener = (data: LoadListenerData, key: string) => void
export interface GUNNode {
_: Soul
/**
* Used only inside the subprocess.
*/
back(
path: 'opt'
): {
peers: Record<
string,
{
url: string
id: string
wire?: {
readyState: number
}
}
>
}
get(key: string): GUNNode
load(this: GUNNode, cb?: LoadListener): void
map(): GUNNode
off(): void
on(this: GUNNode, cb: Listener): void
once(this: GUNNode, cb?: Listener, opts?: { wait?: number }): void
user(): UserGUNNode
user(pub: string): GUNNode
put(data: ValidDataValue, cb?: Callback): void
set(data: ValidDataValue, cb?: Callback): GUNNode
then(): Promise<ListenerData>
}
export interface CreateAck {
pub: string | undefined
err: string | undefined
@ -114,15 +82,4 @@ namespace GunT {
export interface UserSoul extends Soul {
sea: UserPair
}
export interface UserGUNNode extends GUNNode {
_: UserSoul
auth(alias: string, pass: string, cb: AuthCB): void
is?: {
alias: string
pub: string
}
create(user: string, pass: string, cb: CreateCB): void
leave(): void
}
}

View file

@ -3,17 +3,61 @@
*/
/// <reference path="GunT.ts" />
namespace Smith {
export interface GunSmithNode extends GunT.GUNNode {
export interface GunSmithNode {
_: GunT.Soul
/**
* @override
* Used only inside the subprocess.
*/
back(
path: 'opt'
): {
peers: Record<
string,
{
url: string
id: string
wire?: {
readyState: number
}
}
>
}
/**
*
*/
get(key: string): GunSmithNode
/**
* @override
*
*/
map(): GunSmithNode
/**
* @override
*
*/
off(): void
/**
*
*/
on(cb: GunT.Listener): void
/**
*
*/
once(cb?: GunT.Listener, opts?: { wait?: number }): void
/**
* A promise version of put().
* @throws
*/
pPut(data: GunT.ValidDataValue): Promise<void>
/**
* A promise version of set().
* @throws
*/
pSet(data: GunT.ValidDataValue): Promise<void>
/**
*
*/
put(data: GunT.ValidDataValue, cb?: GunT.Callback): void
/**
*
*/
set(data: GunT.ValidDataValue, cb?: GunT.Callback): GunSmithNode
/**
@ -34,19 +78,21 @@ namespace Smith {
* if needed.
*/
specialThen(): Promise<GunT.ListenerData>
/**
* A promise version of put().
* @throws
*/
pPut(data: GunT.ValidDataValue): Promise<void>
/**
* A promise version of set().
* @throws
*/
pSet(data: GunT.ValidDataValue): Promise<void>
then(): Promise<GunT.ListenerData>
user(): UserSmithNode
user(pub: string): GunSmithNode
}
export type UserSmithNode = GunSmithNode & GunT.UserGUNNode
export interface UserSmithNode extends GunSmithNode {
_: GunT.UserSoul
auth(alias: string, pass: string, cb: GunT.AuthCB): void
is?: {
alias: string
pub: string
}
create(user: string, pass: string, cb: GunT.CreateCB): void
leave(): void
}
export interface PendingPut {
cb: GunT.Callback