Skip to content

Commit 7861fcc

Browse files
authored
Merge pull request #98 from m-ld/security-prototype
Added statute "prover" extension loading via "extension subjects"
2 parents 2994186 + 242d0eb commit 7861fcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1305
-583
lines changed

compliance/test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const { fork } = require('child_process');
22
const { createWriteStream } = require('fs');
3-
const { join } = require('path');
3+
const { dirname, join } = require('path');
44
const inspector = require('inspector');
55
const LOG = require('loglevel');
66

7-
const COMPLIANCE_DIR = '../node_modules/@m-ld/m-ld-spec/compliance'.split('/');
8-
const COMPLIANCE_PATH = join(__dirname, ...COMPLIANCE_DIR);
7+
const COMPLIANCE_PATH = dirname(require.resolve('@m-ld/m-ld-spec/compliance/jasmine.json'));
98
const Jasmine = require(require.resolve('jasmine', { paths: [COMPLIANCE_PATH] }));
109
const jasmine = new Jasmine();
1110

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"types": "dist/index.d.ts",
77
"exports": {
88
".": "./dist/index.js",
9+
"./dist/orm": "./dist/orm/index.js",
910
"./dist/mqtt": "./dist/mqtt/index.js",
1011
"./dist/socket.io": "./dist/socket.io/index.js",
1112
"./dist/socket.io-server": "./dist/socket.io/server/index.js",

src/ably/AblyRemotes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class AblyRemotes extends PubsubRemotes {
4141

4242
constructor(
4343
config: MeldAblyConfig,
44-
extensions: MeldExtensions,
44+
extensions: () => Promise<MeldExtensions>,
4545
connect = ablyConnect
4646
) {
4747
super(config, extensions);

src/ably/AblyWrtcRemotes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class AblyWrtcRemotes extends AblyRemotes implements PeerSignaller {
88

99
constructor(
1010
config: MeldAblyConfig & MeldWrtcConfig,
11-
extensions: MeldExtensions,
11+
extensions: () => Promise<MeldExtensions>,
1212
connect = ablyConnect
1313
) {
1414
super(config, extensions, connect);

src/api.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { QueryableRdfSource } from './rdfjs-support';
1111
import { Consumable, each, flow, Flowable } from 'rx-flowable';
1212
import { Future, tapComplete } from './engine/util';
1313
import { MeldMessageType } from './ns/m-ld';
14-
import { MeldApp, MeldConfig } from './config';
14+
import { MeldApp } from './config';
1515

1616
/**
1717
* A convenience type for a struct with a `@insert` and `@delete` property, like
@@ -433,6 +433,32 @@ export interface MeldClone extends MeldStateMachine {
433433
close(err?: any): Promise<unknown>;
434434
}
435435

436+
/**
437+
* Some component of type `T` that is loaded from domain state. The current
438+
* value may change as the domain evolves; and may also be temporarily
439+
* unavailable during an update.
440+
* @internal
441+
*/
442+
export interface StateManaged<T> {
443+
/**
444+
* Get the current or next available value, ready for use (or a rejection,
445+
* e.g. if the clone is shutting down).
446+
*/
447+
ready(): Promise<T>;
448+
/**
449+
* Initialises the extensions against the given clone state. This method could
450+
* be used to read significant state into memory for the efficient
451+
* implementation of an extension's function.
452+
*/
453+
readonly initialise?: StateProc;
454+
/**
455+
* Called to inform the extensions of an update to the state, _after_ it has
456+
* been applied. If available, this procedure will be called for every state
457+
* after that passed to {@link initialise}.
458+
*/
459+
readonly onUpdate?: UpdateProc<MeldPreUpdate>;
460+
}
461+
436462
/**
437463
* Extensions applied to a **m-ld** clone.
438464
*
@@ -444,9 +470,6 @@ export interface MeldClone extends MeldStateMachine {
444470
* to prevent outdated clones from acting incorrectly in ways that could cause
445471
* data corruption or compromise security. Consult the extension's documentation
446472
* for safe operation.
447-
*
448-
* @experimental
449-
* @category Experimental
450473
*/
451474
export interface MeldExtensions {
452475
/**
@@ -470,25 +493,6 @@ export interface MeldExtensions {
470493
* @experimental
471494
*/
472495
readonly transportSecurity?: MeldTransportSecurity;
473-
/**
474-
* Initialises the extensions against the given clone state. This method could
475-
* be used to read significant state into memory for the efficient
476-
* implementation of an extension's function.
477-
*/
478-
readonly initialise?: StateProc;
479-
/**
480-
* Called to inform the extensions of an update to the state, _after_ it has
481-
* been applied. If available, this procedure will be called for every state
482-
* after that passed to {@link initialise}.
483-
*/
484-
readonly onUpdate?: UpdateProc<MeldPreUpdate>;
485-
}
486-
487-
/**
488-
* Required constructor form for **m-ld** extension classes
489-
*/
490-
export interface ConstructMeldExtensions {
491-
new(config: MeldConfig, app: MeldApp): MeldExtensions;
492496
}
493497

494498
/**

0 commit comments

Comments
 (0)