Compare commits

..

8 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
39ed2dbd73 1.0.103 2020-09-30 00:33:58 +00:00
b1defd95a3 fix(core): update 2020-09-30 00:33:57 +00:00
9 changed files with 1495 additions and 1648 deletions

3063
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartuniverse",
"version": "1.0.102",
"version": "1.0.106",
"private": false,
"description": "messaging service for your micro services",
"main": "dist_ts/index.js",
@ -15,9 +15,9 @@
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.48",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.11.2",
"@types/node": "^14.14.22",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
@ -26,18 +26,16 @@
},
"dependencies": {
"@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/smartexpress": "^3.0.76",
"@pushrocks/smartfile": "^8.0.0",
"@pushrocks/smarthash": "^2.1.6",
"@pushrocks/smartexpress": "^3.0.100",
"@pushrocks/smartlog": "^2.0.39",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrequest": "^1.1.51",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrx": "^2.0.19",
"@pushrocks/smartsocket": "^1.1.63",
"@pushrocks/smarttime": "^3.0.35",
"@pushrocks/smartunique": "^3.0.3"
"@pushrocks/smartsocket": "^1.2.3",
"@pushrocks/smarttime": "^3.0.38"
},
"files": [
"ts/**/*",

View File

@ -90,7 +90,7 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
public async postMessage(messageArg: interfaces.IMessageCreator) {
await this.clientUniverseRef.start(); // its ok to call this multiple times
const universeMessageToSend: interfaces.IUniverseMessage = {
id: plugins.smartunique.shortId(),
id: plugins.isounique.uni(),
timestamp: Date.now(),
passphrase: this.passphrase,
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 reactionResult = new ReactionResult<T>();
const requestId = plugins.smartunique.shortId();
const requestId = plugins.isounique.uni();
for (const channel of channelsArg) {
subscriptionMap.add(
channel.subscribe(

View File

@ -4,8 +4,6 @@ import * as pluginsTyped from './smartuniverse.pluginstyped';
import { Handler, Route, Server } from '@pushrocks/smartexpress';
import { UniverseCache, UniverseChannel, UniverseMessage } from './';
import * as paths from './smartuniverse.paths';
import * as interfaces from './interfaces';
import { UniverseConnection } from './smartuniverse.classes.universeconnection';
import { logger } from './smartuniverse.logging';
@ -49,7 +47,7 @@ export class Universe {
/**
* get the currently running version of smartuniverse
*/
public getUniverseVersion() {
/* public getUniverseVersion() {
if (this.universeVersionStore) {
return this.universeVersionStore;
} else {
@ -57,7 +55,7 @@ export class Universe {
this.universeVersionStore = packageJson.version;
return this.universeVersionStore;
}
}
} */
/**
* adds a channel to the Universe
@ -79,7 +77,13 @@ export class Universe {
/**
* 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
this.smartsocket = new plugins.smartsocket.Smartsocket({
port: portArg
@ -94,7 +98,7 @@ export class Universe {
// add a role for the clients
const ClientRole = new plugins.smartsocket.SocketRole({
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
@ -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
funcName: 'processMessage',
funcDef: async (dataArg: interfaces.IUniverseMessage, socketConnectionArg) => {
funcDef: async (messageDataArg: interfaces.IUniverseMessage, socketConnectionArg) => {
const universeConnection = UniverseConnection.findUniverseConnectionBySocketConnection(
this.universeCache,
socketConnectionArg
@ -136,7 +140,7 @@ export class Universe {
}
const unauthenticatedMessage = UniverseMessage.createMessageFromPayload(
socketConnectionArg,
dataArg
messageDataArg
);
const foundChannel = await UniverseChannel.authorizeAMessageForAChannel(
this.universeCache,

View File

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

View File

@ -1,7 +1,5 @@
import * as plugins from './smartuniverse.plugins';
import * as interfaces from './interfaces';
import { Timer, TimeStamp } from '@pushrocks/smarttime';
import { Universe } from './smartuniverse.classes.universe';
import { UniverseChannel } from './smartuniverse.classes.universechannel';
import { UniverseCache } from './smartuniverse.classes.universecache';
@ -24,7 +22,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
public id: string;
public timestamp: number;
public smartTimestamp: TimeStamp;
public smartTimestamp: plugins.smarttime.TimeStamp;
public messageText: string;
public passphrase: string;
public payload: T;
@ -49,7 +47,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
/**
* 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
@ -57,7 +55,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
* @param attachedPayloadArg
*/
constructor(messageDescriptor: interfaces.IUniverseMessage) {
this.smartTimestamp = new TimeStamp(this.timestamp);
this.smartTimestamp = new plugins.smarttime.TimeStamp(this.timestamp);
this.messageText = messageDescriptor.messageText;
this.targetChannelName = messageDescriptor.targetChannelName;
this.passphrase = messageDescriptor.passphrase;
@ -74,7 +72,7 @@ export class UniverseMessage<T> implements interfaces.IUniverseMessage {
public setDestructionTimer(selfdestructAfterArg?: number) {
if (selfdestructAfterArg) {
this.destructionTimer = new Timer(selfdestructAfterArg);
this.destructionTimer = new plugins.smarttime.Timer(selfdestructAfterArg);
this.destructionTimer.start();
// set up self destruction by removing this from the parent messageCache
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
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
@ -10,27 +5,23 @@ export { typedrequestInterfaces };
// pushrocks scope
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 smartfile from '@pushrocks/smartfile';
import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartrx from '@pushrocks/smartrx';
import * as smartsocket from '@pushrocks/smartsocket';
import * as smarttime from '@pushrocks/smarttime';
import * as smartunique from '@pushrocks/smartunique';
import * as isounique from '@pushrocks/isounique';
export {
lik,
smarthash,
isohash,
smartdelay,
smartfile,
smartlog,
smartpromise,
smartrx,
smartrequest,
smartsocket,
smarttime,
smartunique,
isounique,
};