mirror of
https://github.com/fluencelabs/fluent-pad
synced 2025-04-25 00:42:14 +00:00
Update JS SDK and Aqua compiler to the latest version
This commit is contained in:
parent
fab57b598a
commit
5b7761bac7
23840
client/package-lock.json
generated
23840
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@fluencelabs/fluence": "0.11.0",
|
||||
"@fluencelabs/fluence": "0.12.0",
|
||||
"@fluencelabs/fluence-network-environment": "^1.0.10",
|
||||
"@testing-library/jest-dom": "^5.11.9",
|
||||
"@testing-library/react": "^11.2.5",
|
||||
@ -54,7 +54,7 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/aqua": "^0.3.0-224",
|
||||
"@fluencelabs/aqua": "^0.3.0-226",
|
||||
"@fluencelabs/aqua-lib": "^0.1.14",
|
||||
"@types/lodash": "^4.14.168",
|
||||
"chokidar-cli": "^3.0.0"
|
||||
|
@ -3,10 +3,10 @@
|
||||
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||||
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||||
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
|
||||
* Aqua version: 0.3.0-224
|
||||
* Aqua version: 0.3.0-226
|
||||
*
|
||||
*/
|
||||
import { FluencePeer } from '@fluencelabs/fluence';
|
||||
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
||||
import {
|
||||
ResultCodes,
|
||||
RequestFlow,
|
||||
@ -14,41 +14,44 @@ import {
|
||||
CallParams,
|
||||
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v1';
|
||||
|
||||
|
||||
// Services
|
||||
|
||||
export interface UserStatusDef {
|
||||
export interface UserStatusDef {
|
||||
notifyOnline: (userPeerId: string, isOnline: boolean, callParams: CallParams<'userPeerId' | 'isOnline'>) => void;
|
||||
notifyUserAdded: (
|
||||
currentUser: { name: string; peer_id: string; relay_id: string },
|
||||
isOnline: boolean,
|
||||
callParams: CallParams<'currentUser' | 'isOnline'>,
|
||||
) => void;
|
||||
notifyUserRemoved: (userPeerId: string, callParams: CallParams<'userPeerId'>) => void;
|
||||
}
|
||||
notifyUserAdded: (currentUser: {name:string;peer_id:string;relay_id:string}, isOnline: boolean, callParams: CallParams<'currentUser' | 'isOnline'>) => void;
|
||||
notifyUserRemoved: (userPeerId: string, callParams: CallParams<'userPeerId'>) => void;
|
||||
}
|
||||
|
||||
export function registerUserStatus(service: UserStatusDef): void;
|
||||
export function registerUserStatus(service: UserStatusDef): void;
|
||||
export function registerUserStatus(serviceId: string, service: UserStatusDef): void;
|
||||
export function registerUserStatus(peer: FluencePeer, service: UserStatusDef): void;
|
||||
export function registerUserStatus(peer: FluencePeer, serviceId: string, service: UserStatusDef): void;
|
||||
export function registerUserStatus(...args: any) {
|
||||
export function registerUserStatus(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
let service: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
}
|
||||
|
||||
if (typeof args[0] === 'string') {
|
||||
serviceId = args[0];
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
} else {
|
||||
serviceId = 'fluence/fluent-pad/status';
|
||||
}
|
||||
else {
|
||||
serviceId = "fluence/fluent-pad/status"
|
||||
}
|
||||
|
||||
if (!(args[0] instanceof FluencePeer) && typeof args[0] === 'object') {
|
||||
// Figuring out which overload is the service.
|
||||
// If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
// If the first argument is peer, we are checking further. The second argument might either be
|
||||
// an object, that it must be the service object
|
||||
// or a string, which is the service id. In that case the service is the third argument
|
||||
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
service = args[0];
|
||||
} else if (typeof args[1] === 'object') {
|
||||
service = args[1];
|
||||
@ -62,79 +65,90 @@ export function registerUserStatus(...args: any) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (req.fnName === 'notifyOnline') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
userPeerId: req.tetraplets[0],
|
||||
isOnline: req.tetraplets[1],
|
||||
userPeerId: req.tetraplets[0],isOnline: req.tetraplets[1]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
service.notifyOnline(req.args[0], req.args[1], callParams);
|
||||
resp.result = {};
|
||||
service.notifyOnline(req.args[0], req.args[1], callParams); resp.result = {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (req.fnName === 'notifyUserAdded') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
currentUser: req.tetraplets[0],
|
||||
isOnline: req.tetraplets[1],
|
||||
currentUser: req.tetraplets[0],isOnline: req.tetraplets[1]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
service.notifyUserAdded(req.args[0], req.args[1], callParams);
|
||||
resp.result = {};
|
||||
service.notifyUserAdded(req.args[0], req.args[1], callParams); resp.result = {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (req.fnName === 'notifyUserRemoved') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
userPeerId: req.tetraplets[0],
|
||||
userPeerId: req.tetraplets[0]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
service.notifyUserRemoved(req.args[0], callParams);
|
||||
resp.result = {};
|
||||
service.notifyUserRemoved(req.args[0], callParams); resp.result = {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface TextStateDef {
|
||||
notifyTextUpdate: (
|
||||
changes: string,
|
||||
isAuthorized: boolean,
|
||||
callParams: CallParams<'changes' | 'isAuthorized'>,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export function registerTextState(service: TextStateDef): void;
|
||||
|
||||
export interface TextStateDef {
|
||||
notifyTextUpdate: (changes: string, isAuthorized: boolean, callParams: CallParams<'changes' | 'isAuthorized'>) => void;
|
||||
}
|
||||
|
||||
export function registerTextState(service: TextStateDef): void;
|
||||
export function registerTextState(serviceId: string, service: TextStateDef): void;
|
||||
export function registerTextState(peer: FluencePeer, service: TextStateDef): void;
|
||||
export function registerTextState(peer: FluencePeer, serviceId: string, service: TextStateDef): void;
|
||||
export function registerTextState(...args: any) {
|
||||
export function registerTextState(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
let service: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
}
|
||||
|
||||
if (typeof args[0] === 'string') {
|
||||
serviceId = args[0];
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
} else {
|
||||
serviceId = 'fluence/fluent-pad/text-state';
|
||||
}
|
||||
else {
|
||||
serviceId = "fluence/fluent-pad/text-state"
|
||||
}
|
||||
|
||||
if (!(args[0] instanceof FluencePeer) && typeof args[0] === 'object') {
|
||||
// Figuring out which overload is the service.
|
||||
// If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
// If the first argument is peer, we are checking further. The second argument might either be
|
||||
// an object, that it must be the service object
|
||||
// or a string, which is the service id. In that case the service is the third argument
|
||||
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
service = args[0];
|
||||
} else if (typeof args[1] === 'object') {
|
||||
service = args[1];
|
||||
@ -148,53 +162,60 @@ export function registerTextState(...args: any) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (req.fnName === 'notifyTextUpdate') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {
|
||||
changes: req.tetraplets[0],
|
||||
isAuthorized: req.tetraplets[1],
|
||||
changes: req.tetraplets[0],isAuthorized: req.tetraplets[1]
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
service.notifyTextUpdate(req.args[0], req.args[1], callParams);
|
||||
resp.result = {};
|
||||
service.notifyTextUpdate(req.args[0], req.args[1], callParams); resp.result = {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface AppConfigDef {
|
||||
getApp: (callParams: CallParams<null>) => {
|
||||
history: { peer_id: string; service_id: string };
|
||||
user_list: { peer_id: string; service_id: string };
|
||||
};
|
||||
}
|
||||
|
||||
export function registerAppConfig(service: AppConfigDef): void;
|
||||
|
||||
export interface AppConfigDef {
|
||||
getApp: (callParams: CallParams<null>) => {history:{peer_id:string;service_id:string};user_list:{peer_id:string;service_id:string}};
|
||||
}
|
||||
|
||||
export function registerAppConfig(service: AppConfigDef): void;
|
||||
export function registerAppConfig(serviceId: string, service: AppConfigDef): void;
|
||||
export function registerAppConfig(peer: FluencePeer, service: AppConfigDef): void;
|
||||
export function registerAppConfig(peer: FluencePeer, serviceId: string, service: AppConfigDef): void;
|
||||
export function registerAppConfig(...args: any) {
|
||||
export function registerAppConfig(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let serviceId: any;
|
||||
let service: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
}
|
||||
|
||||
if (typeof args[0] === 'string') {
|
||||
serviceId = args[0];
|
||||
} else if (typeof args[1] === 'string') {
|
||||
serviceId = args[1];
|
||||
} else {
|
||||
serviceId = 'fluence/get-config';
|
||||
}
|
||||
else {
|
||||
serviceId = "fluence/get-config"
|
||||
}
|
||||
|
||||
if (!(args[0] instanceof FluencePeer) && typeof args[0] === 'object') {
|
||||
// Figuring out which overload is the service.
|
||||
// If the first argument is not Fluence Peer and it is an object, then it can only be the service def
|
||||
// If the first argument is peer, we are checking further. The second argument might either be
|
||||
// an object, that it must be the service object
|
||||
// or a string, which is the service id. In that case the service is the third argument
|
||||
if (!(FluencePeer.isInstance(args[0])) && typeof args[0] === 'object') {
|
||||
service = args[0];
|
||||
} else if (typeof args[1] === 'object') {
|
||||
service = args[1];
|
||||
@ -208,46 +229,46 @@ export function registerAppConfig(...args: any) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (req.fnName === 'getApp') {
|
||||
|
||||
const callParams = {
|
||||
...req.particleContext,
|
||||
tetraplets: {},
|
||||
tetraplets: {
|
||||
|
||||
},
|
||||
};
|
||||
resp.retCode = ResultCodes.success;
|
||||
resp.result = service.getApp(callParams);
|
||||
resp.result = service.getApp(callParams)
|
||||
|
||||
}
|
||||
|
||||
|
||||
next();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
export function addEntry(
|
||||
entry: string,
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ entry_id: number; err_msg: string; ret_code: number }>;
|
||||
export function addEntry(
|
||||
peer: FluencePeer,
|
||||
entry: string,
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ entry_id: number; err_msg: string; ret_code: number }>;
|
||||
export function addEntry(...args: any) {
|
||||
export function addEntry(entry: string, config?: {ttl?: number}) : Promise<{entry_id:number;err_msg:string;ret_code:number}>;
|
||||
export function addEntry(peer: FluencePeer, entry: string, config?: {ttl?: number}) : Promise<{entry_id:number;err_msg:string;ret_code:number}>;
|
||||
export function addEntry(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let entry: any;
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
entry = args[1];
|
||||
config = args[2];
|
||||
config = args[2];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
entry = args[0];
|
||||
config = args[1];
|
||||
config = args[1];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<{ entry_id: number; err_msg: string; ret_code: number }>((resolve, reject) => {
|
||||
const promise = new Promise<{entry_id:number;err_msg:string;ret_code:number}>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
@ -370,15 +391,13 @@ export function addEntry(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
});
|
||||
h.on('getDataSrv', 'entry', () => {
|
||||
return entry;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'entry', () => {return entry;});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -388,9 +407,9 @@ export function addEntry(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for addEntry');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
@ -398,28 +417,24 @@ export function addEntry(...args: any) {
|
||||
return promise;
|
||||
}
|
||||
|
||||
export function getHistory(config?: {
|
||||
ttl?: number;
|
||||
}): Promise<{ entries: { body: string; id: number }[]; err_msg: string; ret_code: number }>;
|
||||
export function getHistory(
|
||||
peer: FluencePeer,
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ entries: { body: string; id: number }[]; err_msg: string; ret_code: number }>;
|
||||
export function getHistory(...args: any) {
|
||||
|
||||
|
||||
export function getHistory(config?: {ttl?: number}) : Promise<{entries:{body:string;id:number}[];err_msg:string;ret_code:number}>;
|
||||
export function getHistory(peer: FluencePeer, config?: {ttl?: number}) : Promise<{entries:{body:string;id:number}[];err_msg:string;ret_code:number}>;
|
||||
export function getHistory(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
config = args[1];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
config = args[0];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<{ entries: { body: string; id: number }[]; err_msg: string; ret_code: number }>(
|
||||
(resolve, reject) => {
|
||||
const promise = new Promise<{entries:{body:string;id:number}[];err_msg:string;ret_code:number}>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
@ -475,13 +490,13 @@ export function getHistory(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -491,42 +506,36 @@ export function getHistory(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for getHistory');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
},
|
||||
);
|
||||
});
|
||||
peer.internals.initiateFlow(request!);
|
||||
return promise;
|
||||
}
|
||||
|
||||
export function initAfterJoin(
|
||||
me: { name: string; peer_id: string; relay_id: string },
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ name: string; peer_id: string; relay_id: string }[]>;
|
||||
export function initAfterJoin(
|
||||
peer: FluencePeer,
|
||||
me: { name: string; peer_id: string; relay_id: string },
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ name: string; peer_id: string; relay_id: string }[]>;
|
||||
export function initAfterJoin(...args: any) {
|
||||
|
||||
|
||||
export function initAfterJoin(me: {name:string;peer_id:string;relay_id:string}, config?: {ttl?: number}) : Promise<{name:string;peer_id:string;relay_id:string}[]>;
|
||||
export function initAfterJoin(peer: FluencePeer, me: {name:string;peer_id:string;relay_id:string}, config?: {ttl?: number}) : Promise<{name:string;peer_id:string;relay_id:string}[]>;
|
||||
export function initAfterJoin(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let me: any;
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
me = args[1];
|
||||
config = args[2];
|
||||
config = args[2];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
me = args[0];
|
||||
config = args[1];
|
||||
config = args[1];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<{ name: string; peer_id: string; relay_id: string }[]>((resolve, reject) => {
|
||||
const promise = new Promise<{name:string;peer_id:string;relay_id:string}[]>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
@ -631,15 +640,13 @@ export function initAfterJoin(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
});
|
||||
h.on('getDataSrv', 'me', () => {
|
||||
return me;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'me', () => {return me;});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -649,9 +656,9 @@ export function initAfterJoin(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for initAfterJoin');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
@ -659,17 +666,19 @@ export function initAfterJoin(...args: any) {
|
||||
return promise;
|
||||
}
|
||||
|
||||
export function updateOnlineStatuses(config?: { ttl?: number }): Promise<void>;
|
||||
export function updateOnlineStatuses(peer: FluencePeer, config?: { ttl?: number }): Promise<void>;
|
||||
export function updateOnlineStatuses(...args: any) {
|
||||
|
||||
|
||||
export function updateOnlineStatuses(config?: {ttl?: number}) : Promise<void>;
|
||||
export function updateOnlineStatuses(peer: FluencePeer, config?: {ttl?: number}) : Promise<void>;
|
||||
export function updateOnlineStatuses(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
config = args[1];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
config = args[0];
|
||||
}
|
||||
|
||||
@ -747,10 +756,12 @@ export function updateOnlineStatuses(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
|
||||
h.onEvent('callbackSrv', 'response', (args) => {});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -760,9 +771,9 @@ export function updateOnlineStatuses(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for updateOnlineStatuses');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
@ -770,25 +781,24 @@ export function updateOnlineStatuses(...args: any) {
|
||||
return Promise.race([promise, Promise.resolve()]);
|
||||
}
|
||||
|
||||
export function getUserList(config?: { ttl?: number }): Promise<{ name: string; peer_id: string; relay_id: string }[]>;
|
||||
export function getUserList(
|
||||
peer: FluencePeer,
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ name: string; peer_id: string; relay_id: string }[]>;
|
||||
export function getUserList(...args: any) {
|
||||
|
||||
|
||||
export function getUserList(config?: {ttl?: number}) : Promise<{name:string;peer_id:string;relay_id:string}[]>;
|
||||
export function getUserList(peer: FluencePeer, config?: {ttl?: number}) : Promise<{name:string;peer_id:string;relay_id:string}[]>;
|
||||
export function getUserList(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
config = args[1];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
config = args[0];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<{ name: string; peer_id: string; relay_id: string }[]>((resolve, reject) => {
|
||||
const promise = new Promise<{name:string;peer_id:string;relay_id:string}[]>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
@ -829,13 +839,13 @@ export function getUserList(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -845,9 +855,9 @@ export function getUserList(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for getUserList');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
@ -855,17 +865,19 @@ export function getUserList(...args: any) {
|
||||
return promise;
|
||||
}
|
||||
|
||||
export function leave(config?: { ttl?: number }): Promise<void>;
|
||||
export function leave(peer: FluencePeer, config?: { ttl?: number }): Promise<void>;
|
||||
export function leave(...args: any) {
|
||||
|
||||
|
||||
export function leave(config?: {ttl?: number}) : Promise<void>;
|
||||
export function leave(peer: FluencePeer, config?: {ttl?: number}) : Promise<void>;
|
||||
export function leave(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
config = args[1];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
config = args[0];
|
||||
}
|
||||
|
||||
@ -949,10 +961,12 @@ export function leave(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
|
||||
h.onEvent('callbackSrv', 'response', (args) => {});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -962,9 +976,9 @@ export function leave(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for leave');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
@ -972,31 +986,26 @@ export function leave(...args: any) {
|
||||
return Promise.race([promise, Promise.resolve()]);
|
||||
}
|
||||
|
||||
export function join(
|
||||
user: { name: string; peer_id: string; relay_id: string },
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ err_msg: string; ret_code: number }>;
|
||||
export function join(
|
||||
peer: FluencePeer,
|
||||
user: { name: string; peer_id: string; relay_id: string },
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ err_msg: string; ret_code: number }>;
|
||||
export function join(...args: any) {
|
||||
|
||||
|
||||
export function join(user: {name:string;peer_id:string;relay_id:string}, config?: {ttl?: number}) : Promise<{err_msg:string;ret_code:number}>;
|
||||
export function join(peer: FluencePeer, user: {name:string;peer_id:string;relay_id:string}, config?: {ttl?: number}) : Promise<{err_msg:string;ret_code:number}>;
|
||||
export function join(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
let user: any;
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
user = args[1];
|
||||
config = args[2];
|
||||
config = args[2];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
user = args[0];
|
||||
config = args[1];
|
||||
config = args[1];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<{ err_msg: string; ret_code: number }>((resolve, reject) => {
|
||||
const promise = new Promise<{err_msg:string;ret_code:number}>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
@ -1040,15 +1049,13 @@ export function join(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
});
|
||||
h.on('getDataSrv', 'user', () => {
|
||||
return user;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'user', () => {return user;});
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -1058,9 +1065,9 @@ export function join(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for join');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
@ -1068,27 +1075,24 @@ export function join(...args: any) {
|
||||
return promise;
|
||||
}
|
||||
|
||||
export function auth(config?: {
|
||||
ttl?: number;
|
||||
}): Promise<{ err_msg: string; is_authenticated: boolean; ret_code: number }>;
|
||||
export function auth(
|
||||
peer: FluencePeer,
|
||||
config?: { ttl?: number },
|
||||
): Promise<{ err_msg: string; is_authenticated: boolean; ret_code: number }>;
|
||||
export function auth(...args: any) {
|
||||
|
||||
|
||||
export function auth(config?: {ttl?: number}) : Promise<{err_msg:string;is_authenticated:boolean;ret_code:number}>;
|
||||
export function auth(peer: FluencePeer, config?: {ttl?: number}) : Promise<{err_msg:string;is_authenticated:boolean;ret_code:number}>;
|
||||
export function auth(...args: any) {
|
||||
let peer: FluencePeer;
|
||||
|
||||
let config: any;
|
||||
if (args[0] instanceof FluencePeer) {
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
config = args[1];
|
||||
} else {
|
||||
peer = FluencePeer.default;
|
||||
peer = Fluence.getPeer();
|
||||
config = args[0];
|
||||
}
|
||||
|
||||
let request: RequestFlow;
|
||||
const promise = new Promise<{ err_msg: string; is_authenticated: boolean; ret_code: number }>((resolve, reject) => {
|
||||
const promise = new Promise<{err_msg:string;is_authenticated:boolean;ret_code:number}>((resolve, reject) => {
|
||||
const r = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
@ -1129,13 +1133,13 @@ export function auth(...args: any) {
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return peer.connectionInfo.connectedRelay;
|
||||
return peer.getStatus().relayPeerId;
|
||||
});
|
||||
|
||||
h.onEvent('callbackSrv', 'response', (args) => {
|
||||
const [res] = args;
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
const [err] = args;
|
||||
@ -1145,12 +1149,13 @@ export function auth(...args: any) {
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for auth');
|
||||
});
|
||||
if (config && config.ttl) {
|
||||
r.withTTL(config.ttl);
|
||||
})
|
||||
if(config && config.ttl) {
|
||||
r.withTTL(config.ttl)
|
||||
}
|
||||
request = r.build();
|
||||
});
|
||||
peer.internals.initiateFlow(request!);
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
@ -4,23 +4,23 @@
|
||||
"dependencies": [
|
||||
"history_inmemory"
|
||||
],
|
||||
"node": "12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3",
|
||||
"node": "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e",
|
||||
"hashDependencies": [
|
||||
"hash:6ee648216089b876a34353f485f1bf19dd863b861f0d798a0ac0cb65cc3b4e2f"
|
||||
"hash:080ddd728c1d62f2cd7e8460b8db5020b5e4fa40e9eabac18ca883a7ca08bd8e"
|
||||
],
|
||||
"blueprint_id": "5df598924434974291d98c6d72e0922f2e8cbd7f7f291ca44f1b2f8e198f421b",
|
||||
"id": "69f14695-3989-4733-b4f3-9a204a8615b9"
|
||||
"blueprint_id": "4cba09d379488f365cfaf3be4b695c53b5856dd489a063eca65a0cfd36b37dc2",
|
||||
"id": "9c3b441d-f41b-4501-8c61-7bfb5960b109"
|
||||
},
|
||||
"user_list": {
|
||||
"dependencies": [
|
||||
"user_list_inmemory"
|
||||
],
|
||||
"node": "12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3",
|
||||
"node": "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e",
|
||||
"hashDependencies": [
|
||||
"hash:691ebcd74409bd931a9a68d0e0001f8d9d4b8482c8aaac3184e28c2a322e5a82"
|
||||
"hash:f083b600d1f965a4e7862088a67cb1b33a4bcfbfa8fb1d26db56bdd61ae86c60"
|
||||
],
|
||||
"blueprint_id": "d46fb511eb5a5dcea7b5a6777e04f95d48cbbe9fde040bd6bd69b4d9cd8fbb88",
|
||||
"id": "caa3de3e-e5c0-4514-8bc4-efca631becce"
|
||||
"blueprint_id": "a537c1ef87711e8b8cd1d8de30f5a8b125cf73b469727035c6c92e2bd87e699e",
|
||||
"id": "f027e5da-d2f9-4ec5-92fc-ae7f26215846"
|
||||
}
|
||||
},
|
||||
"modules": {
|
||||
@ -34,12 +34,12 @@
|
||||
"history": "/tmp"
|
||||
}
|
||||
},
|
||||
"hash": "6ee648216089b876a34353f485f1bf19dd863b861f0d798a0ac0cb65cc3b4e2f"
|
||||
"hash": "080ddd728c1d62f2cd7e8460b8db5020b5e4fa40e9eabac18ca883a7ca08bd8e"
|
||||
},
|
||||
"user_list_inmemory": {
|
||||
"file": "user_list.wasm",
|
||||
"config": {},
|
||||
"hash": "691ebcd74409bd931a9a68d0e0001f8d9d4b8482c8aaac3184e28c2a322e5a82"
|
||||
"hash": "f083b600d1f965a4e7862088a67cb1b33a4bcfbfa8fb1d26db56bdd61ae86c60"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@ -48,8 +48,7 @@
|
||||
"variables": {
|
||||
"function": "is_authenticated",
|
||||
"json_path": "$.is_authenticated"
|
||||
},
|
||||
"node": "12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"script_storage": {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { FluencePeer } from '@fluencelabs/fluence';
|
||||
import { Fluence } from '@fluencelabs/fluence';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import './App.scss';
|
||||
@ -17,7 +17,7 @@ const App = () => {
|
||||
|
||||
const connect = async () => {
|
||||
try {
|
||||
await FluencePeer.default.init({ connectTo: relayNode });
|
||||
await Fluence.start({ connectTo: relayNode });
|
||||
|
||||
setIsConnected(true);
|
||||
|
||||
@ -43,8 +43,8 @@ const App = () => {
|
||||
|
||||
await withErrorHandlingAsync(async () => {
|
||||
const res = await join( {
|
||||
peer_id: FluencePeer.default.connectionInfo.selfPeerId,
|
||||
relay_id: FluencePeer.default.connectionInfo.connectedRelay!,
|
||||
peer_id: Fluence.getStatus().peerId!,
|
||||
relay_id: Fluence.getStatus().relayPeerId!,
|
||||
name: nickName,
|
||||
});
|
||||
if (CheckResponse(res)) {
|
||||
|
@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';
|
||||
import { withErrorHandlingAsync } from './util';
|
||||
import { initAfterJoin, updateOnlineStatuses } from 'src/_aqua/app';
|
||||
import { registerUserStatus } from 'src/_aqua/app';
|
||||
import { FluencePeer, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
import { Fluence, FluencePeer, PeerIdB58 } from '@fluencelabs/fluence';
|
||||
|
||||
interface User {
|
||||
id: PeerIdB58;
|
||||
@ -71,8 +71,8 @@ export const UserList = (props: { selfName: string }) => {
|
||||
withErrorHandlingAsync(async () => {
|
||||
await initAfterJoin({
|
||||
name: props.selfName,
|
||||
peer_id: FluencePeer.default.connectionInfo.selfPeerId,
|
||||
relay_id: FluencePeer.default.connectionInfo.connectedRelay!,
|
||||
peer_id: Fluence.getStatus().peerId!,
|
||||
relay_id: Fluence.getStatus().relayPeerId!,
|
||||
});
|
||||
});
|
||||
|
||||
@ -90,7 +90,7 @@ export const UserList = (props: { selfName: string }) => {
|
||||
<ul>
|
||||
{usersArray.map((x) => (
|
||||
<li key={x.id}>
|
||||
<span className={x.id === FluencePeer.default.connectionInfo.selfPeerId ? 'bold' : ''}>{x.name}</span>
|
||||
<span className={x.id === Fluence.getStatus().peerId ? 'bold' : ''}>{x.name}</span>
|
||||
<span className={x.isOnline ? 'green' : 'red'}> ({x.isOnline ? 'online' : 'offline'})</span>
|
||||
</li>
|
||||
))}
|
||||
|
3
package-lock.json
generated
3
package-lock.json
generated
@ -1,3 +0,0 @@
|
||||
{
|
||||
"lockfileVersion": 1
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user