Compare commits

..

6 Commits

Author SHA1 Message Date
b5fcefa93b 1.0.106 2021-01-26 01:59:07 +00:00
67f60187ae fix(core): update 2021-01-26 01:59:06 +00:00
176c6ba261 1.0.105 2020-09-30 17:39:30 +00:00
af6c634deb fix(core): update 2020-09-30 17:39:29 +00:00
a5ce7b18e8 1.0.104 2020-09-30 00:50:44 +00:00
b6b482f7db fix(core): update 2020-09-30 00:50:43 +00:00
9 changed files with 1493 additions and 1663 deletions

3076
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartuniverse", "name": "@pushrocks/smartuniverse",
"version": "1.0.103", "version": "1.0.106",
"private": false, "private": false,
"description": "messaging service for your micro services", "description": "messaging service for your micro services",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -15,9 +15,9 @@
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.48", "@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.11.2", "@types/node": "^14.14.22",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
@ -26,18 +26,16 @@
}, },
"dependencies": { "dependencies": {
"@apiglobal/typedrequest-interfaces": "^1.0.15", "@apiglobal/typedrequest-interfaces": "^1.0.15",
"@pushrocks/lik": "^4.0.17", "@pushrocks/isohash": "^1.0.2",
"@pushrocks/isounique": "^1.0.4",
"@pushrocks/lik": "^4.0.20",
"@pushrocks/smartdelay": "^2.0.10", "@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartexpress": "^3.0.76", "@pushrocks/smartexpress": "^3.0.100",
"@pushrocks/smartfile": "^8.0.0",
"@pushrocks/smarthash": "^2.1.6",
"@pushrocks/smartlog": "^2.0.39", "@pushrocks/smartlog": "^2.0.39",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrequest": "^1.1.51",
"@pushrocks/smartrx": "^2.0.19", "@pushrocks/smartrx": "^2.0.19",
"@pushrocks/smartsocket": "^1.1.67", "@pushrocks/smartsocket": "^1.2.3",
"@pushrocks/smarttime": "^3.0.35", "@pushrocks/smarttime": "^3.0.38"
"@pushrocks/smartunique": "^3.0.3"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

View File

@ -90,7 +90,7 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
public async postMessage(messageArg: interfaces.IMessageCreator) { public async postMessage(messageArg: interfaces.IMessageCreator) {
await this.clientUniverseRef.start(); // its ok to call this multiple times await this.clientUniverseRef.start(); // its ok to call this multiple times
const universeMessageToSend: interfaces.IUniverseMessage = { const universeMessageToSend: interfaces.IUniverseMessage = {
id: plugins.smartunique.shortId(), id: plugins.isounique.uni(),
timestamp: Date.now(), timestamp: Date.now(),
passphrase: this.passphrase, passphrase: this.passphrase,
targetChannelName: this.name, targetChannelName: this.name,

View File

@ -37,7 +37,7 @@ export class ReactionRequest<T extends plugins.typedrequestInterfaces.ITypedRequ
) { ) {
const subscriptionMap = new plugins.lik.ObjectMap<plugins.smartrx.rxjs.Subscription>(); const subscriptionMap = new plugins.lik.ObjectMap<plugins.smartrx.rxjs.Subscription>();
const reactionResult = new ReactionResult<T>(); const reactionResult = new ReactionResult<T>();
const requestId = plugins.smartunique.shortId(); const requestId = plugins.isounique.uni();
for (const channel of channelsArg) { for (const channel of channelsArg) {
subscriptionMap.add( subscriptionMap.add(
channel.subscribe( channel.subscribe(

View File

@ -4,8 +4,6 @@ import * as pluginsTyped from './smartuniverse.pluginstyped';
import { Handler, Route, Server } from '@pushrocks/smartexpress'; import { Handler, Route, Server } from '@pushrocks/smartexpress';
import { UniverseCache, UniverseChannel, UniverseMessage } from './'; import { UniverseCache, UniverseChannel, UniverseMessage } from './';
import * as paths from './smartuniverse.paths';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces';
import { UniverseConnection } from './smartuniverse.classes.universeconnection'; import { UniverseConnection } from './smartuniverse.classes.universeconnection';
import { logger } from './smartuniverse.logging'; import { logger } from './smartuniverse.logging';
@ -49,7 +47,7 @@ export class Universe {
/** /**
* get the currently running version of smartuniverse * get the currently running version of smartuniverse
*/ */
public getUniverseVersion() { /* public getUniverseVersion() {
if (this.universeVersionStore) { if (this.universeVersionStore) {
return this.universeVersionStore; return this.universeVersionStore;
} else { } else {
@ -57,7 +55,7 @@ export class Universe {
this.universeVersionStore = packageJson.version; this.universeVersionStore = packageJson.version;
return this.universeVersionStore; return this.universeVersionStore;
} }
} } */
/** /**
* adds a channel to the Universe * adds a channel to the Universe
@ -79,7 +77,13 @@ export class Universe {
/** /**
* initiates a server * initiates a server
*/ */
public async start(portArg: number) { public async start(portArg?: number) {
if (!this.options.externalServer && !portArg) {
throw new Error(`You supplied an external error. You need to specify a portArg to start on.`);
}
portArg = portArg || 3000; // TODO: remove
// add websocket upgrade // add websocket upgrade
this.smartsocket = new plugins.smartsocket.Smartsocket({ this.smartsocket = new plugins.smartsocket.Smartsocket({
port: portArg port: portArg
@ -94,7 +98,7 @@ export class Universe {
// add a role for the clients // add a role for the clients
const ClientRole = new plugins.smartsocket.SocketRole({ const ClientRole = new plugins.smartsocket.SocketRole({
name: 'UniverseClient', name: 'UniverseClient',
passwordHash: plugins.smarthash.sha256FromStringSync('UniverseClient'), // authentication happens on another level passwordHash: await plugins.isohash.sha256FromString('UniverseClient'), // authentication happens on another level
}); });
// add the role to smartsocket // add the role to smartsocket
@ -118,10 +122,10 @@ export class Universe {
}, },
}); });
const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction({ const socketFunctionProcessMessage = new plugins.smartsocket.SocketFunction<any>({ // TODO proper ITypedRequest here instead of any
allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level allowedRoles: [ClientRole], // there is only one client role, Authentication happens on another level
funcName: 'processMessage', funcName: 'processMessage',
funcDef: async (dataArg: interfaces.IUniverseMessage, socketConnectionArg) => { funcDef: async (messageDataArg: interfaces.IUniverseMessage, socketConnectionArg) => {
const universeConnection = UniverseConnection.findUniverseConnectionBySocketConnection( const universeConnection = UniverseConnection.findUniverseConnectionBySocketConnection(
this.universeCache, this.universeCache,
socketConnectionArg socketConnectionArg
@ -136,7 +140,7 @@ export class Universe {
} }
const unauthenticatedMessage = UniverseMessage.createMessageFromPayload( const unauthenticatedMessage = UniverseMessage.createMessageFromPayload(
socketConnectionArg, socketConnectionArg,
dataArg messageDataArg
); );
const foundChannel = await UniverseChannel.authorizeAMessageForAChannel( const foundChannel = await UniverseChannel.authorizeAMessageForAChannel(
this.universeCache, this.universeCache,

View File

@ -157,7 +157,7 @@ export class UniverseChannel {
*/ */
public async postMessage(messageDescriptor: interfaces.IMessageCreator) { public async postMessage(messageDescriptor: interfaces.IMessageCreator) {
const messageToSend = new UniverseMessage({ const messageToSend = new UniverseMessage({
id: plugins.smartunique.shortId(), id: plugins.isounique.uni(),
messageText: messageDescriptor.messageText, messageText: messageDescriptor.messageText,
payload: messageDescriptor.payload, payload: messageDescriptor.payload,
targetChannelName: this.name, targetChannelName: this.name,

View File

@ -1,7 +1,5 @@
import * as plugins from './smartuniverse.plugins'; import * as plugins from './smartuniverse.plugins';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces';
import { Timer, TimeStamp } from '@pushrocks/smarttime';
import { Universe } from './smartuniverse.classes.universe'; import { Universe } from './smartuniverse.classes.universe';
import { UniverseChannel } from './smartuniverse.classes.universechannel'; import { UniverseChannel } from './smartuniverse.classes.universechannel';
import { UniverseCache } from './smartuniverse.classes.universecache'; import { UniverseCache } from './smartuniverse.classes.universecache';
@ -24,7 +22,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
public id: string; public id: string;
public timestamp: number; public timestamp: number;
public smartTimestamp: TimeStamp; public smartTimestamp: plugins.smarttime.TimeStamp;
public messageText: string; public messageText: string;
public passphrase: string; public passphrase: string;
public payload: T; public payload: T;
@ -49,7 +47,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
/** /**
* a destruction timer for this message * a destruction timer for this message
*/ */
public destructionTimer: Timer; // a timer to take care of message destruction public destructionTimer: plugins.smarttime.Timer; // a timer to take care of message destruction
/** /**
* the constructor to create a universe message * the constructor to create a universe message
@ -57,7 +55,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
* @param attachedPayloadArg * @param attachedPayloadArg
*/ */
constructor(messageDescriptor: interfaces.IUniverseMessage) { constructor(messageDescriptor: interfaces.IUniverseMessage) {
this.smartTimestamp = new TimeStamp(this.timestamp); this.smartTimestamp = new plugins.smarttime.TimeStamp(this.timestamp);
this.messageText = messageDescriptor.messageText; this.messageText = messageDescriptor.messageText;
this.targetChannelName = messageDescriptor.targetChannelName; this.targetChannelName = messageDescriptor.targetChannelName;
this.passphrase = messageDescriptor.passphrase; this.passphrase = messageDescriptor.passphrase;
@ -74,7 +72,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
public setDestructionTimer(selfdestructAfterArg?: number) { public setDestructionTimer(selfdestructAfterArg?: number) {
if (selfdestructAfterArg) { if (selfdestructAfterArg) {
this.destructionTimer = new Timer(selfdestructAfterArg); this.destructionTimer = new plugins.smarttime.Timer(selfdestructAfterArg);
this.destructionTimer.start(); this.destructionTimer.start();
// set up self destruction by removing this from the parent messageCache // set up self destruction by removing this from the parent messageCache
this.destructionTimer.completed this.destructionTimer.completed

View File

@ -1,3 +0,0 @@
import * as plugins from './smartuniverse.plugins';
export const packageJson = plugins.path.join(__dirname, '../package.json');

View File

@ -1,8 +1,3 @@
// node native
import * as path from 'path';
export { path };
// apiglobal scope // apiglobal scope
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces'; import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
@ -10,27 +5,23 @@ export { typedrequestInterfaces };
// pushrocks scope // pushrocks scope
import * as lik from '@pushrocks/lik'; import * as lik from '@pushrocks/lik';
import * as smarthash from '@pushrocks/smarthash'; import * as isohash from '@pushrocks/isohash';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartfile from '@pushrocks/smartfile';
import * as smartlog from '@pushrocks/smartlog'; import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartrx from '@pushrocks/smartrx'; import * as smartrx from '@pushrocks/smartrx';
import * as smartsocket from '@pushrocks/smartsocket'; import * as smartsocket from '@pushrocks/smartsocket';
import * as smarttime from '@pushrocks/smarttime'; import * as smarttime from '@pushrocks/smarttime';
import * as smartunique from '@pushrocks/smartunique'; import * as isounique from '@pushrocks/isounique';
export { export {
lik, lik,
smarthash, isohash,
smartdelay, smartdelay,
smartfile,
smartlog, smartlog,
smartpromise, smartpromise,
smartrx, smartrx,
smartrequest,
smartsocket, smartsocket,
smarttime, smarttime,
smartunique, isounique,
}; };