Skip to content

Commit 3706daf

Browse files
authored
Merge pull request #198 from reTHINK-project/develop
Develop
2 parents 251895d + b5c2b53 commit 3706daf

File tree

17 files changed

+632
-493
lines changed

17 files changed

+632
-493
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@
1515
- [Tasks](#tasks)
1616

1717
## <a id="note">Note</a>
18-
In order to try speed up the instalation process, we remove the first verification of global modules, so, if you want install this repository, you should install globaly this modules:
18+
In order to speed up the installation process, we have removed the first verification of global modules, so, if you want to install this repository, you should globally install this module:
1919

2020
```shell
2121
npm install -g karma-cli
2222
```
2323

2424
## <a id="overview">Overview</a>
2525

26-
This repository contains the source code and associated documentation of the core components required to support the deployment and execution of Hyperties in user devices or in network servers. More information about the Hyperty concept and the reTHINK framework in general is provided [here](https://github.com/reTHINK-project/dev-service-framework/blob/master/README.md).
26+
This repository contains the source code and associated documentation of the core components required to support the deployment and execution of Hyperties in user devices or in network servers. The full specification is provided [here]().
2727

28-
The Hyperty Runtime architecture follows a security by design approach since it was highly influenced by a careful [security analysis](docs/specs/securityanalysis.md) where different types of components are executed in isolated sandboxes. Thus, components downloaded from a specific Service Provider are executed in sandboxes that are different from the sandboxes used to execute components downloaded from another service provider. Communication between components running in different sandboxes is only possible through messages exchanged through a Message Bus functionality provided by the Hyperty Runtime Core Sandbox. On the other hand, and according to the [ProtoOFly concept](https://github.com/reTHINK-project/dev-service-framework/blob/master/docs/manuals/hyperty-messaging-framework.md#protocol-on-the-fly-protofly-and-protostubs), the protocol stub is executed in isolated sandbox and provides the bridge for the Hperty Runtime to communicate with associated Service Provider. The detailed specification of the Hyperty Runtime Core is provided [here](docs/specs/readme.md).
28+
The Hyperty Runtime architecture follows a security by design approach where different types of components are executed in isolated sandboxes. Thus, components downloaded from a specific Service Provider are executed in sandboxes that are different from the sandboxes used to execute components downloaded from another service provider. Communication between components running in different sandboxes is only possible through messages exchanged through a Message Bus functionality provided by the Hyperty Runtime Core Sandbox. On the other hand, and according to the ProtoOFly concept, the protocol stub is executed in isolated sandbox and provides the bridge for the Hperty Runtime to communicate with associated Service Provider.
2929

3030
Hyperty Core Runtime components are platform agnostic and are to be included in platform specific Hyperty Runtimes, like Web Browsers and Nodejs based platforms.
3131

32+
The detailed specification of the Hyperty Runtime Core is provided [here](https://github.com/reTHINK-project/specs/blob/master/runtime/readme.md) and the full reTHINK Framework is provided [here](https://github.com/reTHINK-project/specs).
33+
3234
## <a id="user-view">User View</a>
3335

3436
**How to include the Hyperty Runtime Core in other Projects**
@@ -65,7 +67,7 @@ console.log('MiniBus: ', MiniBus);
6567

6668
```
6769

68-
if you found some issues, please submit them into the respective repository;
70+
if you find some issues, please submit them into the respective repository;
6971

7072
---
7173

dist/PEP.js

Lines changed: 26 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ReThinkCtx.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Runtime.js

Lines changed: 175 additions & 175 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/minibus.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sandbox.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "runtime-core",
3-
"version": "0.8.0",
3+
"version": "0.8.1",
44
"description": "core runtime development",
55
"files": [
66
"dist"
@@ -34,7 +34,7 @@
3434
},
3535
"homepage": "https://rethink-project.eu/",
3636
"dependencies": {
37-
"service-framework": "github:rethink-project/dev-service-framework#v0.6.0"
37+
"service-framework": "github:rethink-project/dev-service-framework#v0.6.1"
3838
},
3939
"devDependencies": {
4040
"babel-core": "^6.21.0",

src/policy/context/RuntimeCoreCtx.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,21 @@ class RuntimeCoreCtx extends ReThinkCtx {
161161
return new Promise((resolve, reject) => {
162162
console.log('[Policy.RuntimeCoreCtx.prepareToForward]', message);
163163

164+
// uncomment this to enable mutual authentication
165+
return resolve(message);
166+
164167
// TODO remove this validation. When the Nodejs auth was completed this should work like browser;
165168
this.runtimeCapabilities.isAvailable('node').then((result) => {
166169

167-
console.log('[RuntimeCoreCtx - isAvailable - node] - ', result);
170+
console.log('[RuntimeCoreCtx - isAvailable - node] - ', result);
168171
if (result) {
169172
return resolve(message);
170173
} else {
171174
if (isIncoming) {
172175
let isSubscription = message.type === 'subscribe';
173176
let isFromRemoteSM = _this.isFromRemoteSM(message.from);
174177

175-
if (isSubscription & isFromRemoteSM) {
178+
if (isSubscription & isFromRemoteSM) {
176179
// TODO: should verify why the mutualAuthentication is not working
177180
// TODO: this should uncommented
178181
_this.doMutualAuthentication(message).then(() => {

src/registry/Registry.js

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import AddressAllocation from '../allocation/AddressAllocation';
2727
import HypertyInstance from './HypertyInstance';
2828

2929
import {MessageFactory} from 'service-framework/dist/MessageFactory';
30-
import {divideURL, isHypertyURL, isURL, isUserURL, generateGUID, getUserIdentityDomain, isBackendServiceURL} from '../utils/utils.js';
30+
import {divideURL, isHypertyURL, isURL, isUserURL, generateGUID, getUserIdentityDomain, isBackendServiceURL, deepClone} from '../utils/utils.js';
3131

3232
import 'proxy-observe';
3333
import { WatchingYou } from 'service-framework/dist/Utils';
@@ -328,7 +328,7 @@ class Registry {
328328
let preAuth = [];
329329

330330
if (dataObject) {
331-
preAuth = dataObject.preAuth;
331+
preAuth = dataObject.authorise;
332332
}
333333
return preAuth;
334334
}
@@ -417,6 +417,8 @@ class Registry {
417417
let dataObject = _this.dataObjectList[dataObjectURL];
418418

419419
if (dataObject) {
420+
if (!dataObject.subscribers) { dataObject.subscribers = []; }
421+
420422
dataObject.subscribers.push(subscriberURL);
421423
_this.dataObjectList[dataObjectURL] = dataObject;
422424
}
@@ -447,13 +449,16 @@ class Registry {
447449
* @param {Array} resources dataObject resources
448450
* @param {Array} authorise list of pre authorised authorised IDs
449451
*/
450-
registerDataObject(identifier, dataObjectschema, dataObjectUrl, dataObjectReporter, resources, addressURL, authorise) {
452+
//registerDataObject(identifier, dataObjectschema, dataObjectUrl, dataObjectReporter, resources, addressURL, authorise) {
453+
registerDataObject(objectRegistration) {
451454
let _this = this;
452455

456+
let registration = deepClone(objectRegistration);
457+
453458
return new Promise(function(resolve, reject) {
454459

455460
let dataScheme = [];
456-
let filteredDataScheme = dataObjectUrl.split(':');
461+
let filteredDataScheme = registration.url.split(':');
457462
dataScheme.push(filteredDataScheme[0]);
458463

459464
_this.storageManager.get('registry:DataObjectURLs').then((urlsList) => {
@@ -463,7 +468,7 @@ class Registry {
463468
}
464469

465470
//update the list with the new elements
466-
urlsList[identifier + dataObjectschema + resources + dataObjectReporter] = addressURL.address;
471+
urlsList[objectRegistration.name + objectRegistration.schema + objectRegistration.resources + objectRegistration.reporter] = objectRegistration.url;
467472

468473
let p2pHandler;
469474
let p2pRequester;
@@ -473,59 +478,47 @@ class Registry {
473478
p2pRequester = runtimeUtils.runtimeDescriptor.p2pRequesterStub;
474479
}
475480

476-
let runtime = _this.runtimeURL;
477-
let status = 'live';
478-
479-
//message to register the new data object, within the domain registry
480-
let messageValue = {
481-
name: identifier,
482-
resources: resources,
483-
dataSchemes: dataScheme,
484-
schema: dataObjectschema,
485-
url: dataObjectUrl,
486-
expires: _this.expiresTime,
487-
reporter: dataObjectReporter,
488-
preAuth: authorise,
489-
subscribers: [],
490-
runtime: runtime,
491-
status: status
492-
};
481+
registration.startingTime = registration.created;
482+
483+
delete registration.authorise;
484+
delete registration.created;
485+
delete registration.mutual;
486+
delete registration.resume;
487+
488+
registration.expires = _this.expiresTime;
489+
registration.dataSchemes = dataScheme;
493490

494491
if (p2pHandler) {
495-
messageValue.p2pHandler = p2pHandler;
496-
messageValue.p2pRequester = p2pRequester;
492+
registration.p2pHandler = p2pHandler;
493+
registration.p2pRequester = p2pRequester;
497494
}
498495

499-
if (_this.isInterworkingProtoStub(dataObjectReporter)) {
500-
messageValue.interworking = true;
496+
if (_this.isInterworkingProtoStub(registration.reporter)) {
497+
registration.interworking = true;
501498
}
502499

503500
let message;
504501

505-
if (addressURL.newAddress) {
502+
if (!registration.resume) {
506503

507-
console.log('[Registry] registering new data object URL', dataObjectUrl);
504+
console.log('[Registry.registerDataObject] registering new data object URL', objectRegistration);
508505

509-
message = {type: 'create', from: _this.registryURL, to: 'domain://registry.' + _this.registryDomain + '/', body: {value: messageValue, policy: 'policy'}};
506+
message = {type: 'create', from: _this.registryURL, to: 'domain://registry.' + _this.registryDomain + '/', body: {value: registration, policy: 'policy'}};
510507

511508
} else {
512509

513-
console.log('[Registry] registering previously registered data object URL', dataObjectUrl);
514-
515-
/*messageValue = {name: identifier, resources: resources, dataSchemes: dataScheme, schema: dataObjectschema, url: dataObjectUrl, expires: _this.expiresTime, reporter: dataObjectReporter, preAuth: authorise, subscribers: []};
516-
517-
message = {type:'create', from: _this.registryURL, to: 'domain://registry.' + _this.registryDomain + '/', body: {value: messageValue, policy: 'policy'}};*/
510+
console.log('[Registry.registerDataObject] registering previously registered data object URL', objectRegistration);
518511

519512
message = {
520513
type: 'update',
521514
to: 'domain://registry.' + _this.registryDomain + '/',
522515
from: _this.registryURL,
523-
body: {resource: dataObjectUrl, value: {status: 'live'} }
516+
body: {resource: objectRegistration.url, value: {status: 'live'} }
524517
};
525518

526519
}
527520

528-
_this.dataObjectList[dataObjectUrl] = messageValue;
521+
_this.dataObjectList[objectRegistration.url] = objectRegistration;
529522

530523
// step to obtain the list of all URL registered to updated with the new one.
531524
_this.storageManager.set('registry:DataObjectURLs', 0, urlsList).then(() => {
@@ -538,7 +531,7 @@ class Registry {
538531
);*/
539532

540533
_this._messageBus.postMessage(message, (reply) => {
541-
console.log('[Registry] ===> registerDataObject Reply: ', reply);
534+
console.log('[Registry.registerDataObject] ===> registerDataObject Reply: ', reply);
542535
if (reply.body.code === 200) {
543536
resolve('ok');
544537
} else {

src/runtime/RuntimeUA.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class RuntimeUA {
104104
} else {
105105
throw new Error('Check your Runtime Factory because it need the Storage Manager implementation');
106106
}
107+
107108
if (typeof runtimeFactory.runtimeCapabilities === 'function') {
108109
this.runtimeCapabilities = runtimeFactory.runtimeCapabilities(this.storageManager);
109110
} else {

0 commit comments

Comments
 (0)