jinaga-server 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/authentication/authentication-device.d.ts +3 -16
  2. package/dist/authentication/authentication-device.js +3 -40
  3. package/dist/authentication/authentication-device.js.map +1 -1
  4. package/dist/authentication/authentication-session.d.ts +3 -15
  5. package/dist/authentication/authentication-session.js +2 -37
  6. package/dist/authentication/authentication-session.js.map +1 -1
  7. package/dist/authorization/authorization-keystore.d.ts +2 -2
  8. package/dist/authorization/authorization-keystore.js.map +1 -1
  9. package/dist/jinaga-server.js +37 -19
  10. package/dist/jinaga-server.js.map +1 -1
  11. package/dist/postgres/postgres-store.d.ts +2 -0
  12. package/dist/postgres/postgres-store.js +6 -0
  13. package/dist/postgres/postgres-store.js.map +1 -1
  14. package/package.json +2 -2
  15. package/src/authentication/authentication-device.ts +3 -65
  16. package/src/authentication/authentication-session.ts +4 -66
  17. package/src/authorization/authorization-keystore.ts +2 -2
  18. package/src/jinaga-server.ts +44 -21
  19. package/src/postgres/postgres-store.ts +8 -0
  20. package/test/authorization/authorizationSpec.ts +2 -4
  21. package/dist/authentication/authentication-impl.d.ts +0 -23
  22. package/dist/authentication/authentication-impl.js +0 -70
  23. package/dist/authentication/authentication-impl.js.map +0 -1
  24. package/dist/authentication/authentication-noop.d.ts +0 -20
  25. package/dist/authentication/authentication-noop.js +0 -52
  26. package/dist/authentication/authentication-noop.js.map +0 -1
  27. package/dist/authentication/authentication.d.ts +0 -5
  28. package/dist/authentication/authentication.js +0 -3
  29. package/dist/authentication/authentication.js.map +0 -1
  30. package/dist/authentication.d.ts +0 -19
  31. package/dist/authentication.js +0 -61
  32. package/dist/authentication.js.map +0 -1
  33. package/src/authentication/authentication-impl.ts +0 -69
  34. package/src/authentication/authentication-noop.ts +0 -65
  35. package/src/authentication/authentication.ts +0 -6
  36. package/src/authentication.ts +0 -68
@@ -1,30 +1,12 @@
1
- import {
2
- AuthorizationEngine,
3
- AuthorizationRules,
4
- Channel,
5
- FactEnvelope,
6
- FactFeed,
7
- FactRecord,
8
- FactReference,
9
- Feed,
10
- LoginResponse,
11
- Observable,
12
- ObservableSource,
13
- ProjectedResult,
14
- Query,
15
- Specification,
16
- SpecificationListener,
17
- UserIdentity,
18
- } from "jinaga";
1
+ import { Authentication, AuthorizationEngine, AuthorizationRules, FactEnvelope, FactRecord, LoginResponse, Storage, UserIdentity } from "jinaga";
19
2
 
20
3
  import { Keystore } from "../keystore";
21
- import { Authentication } from "./authentication";
22
4
 
23
5
  export class AuthenticationSession implements Authentication {
24
6
  private authorizationEngine: AuthorizationEngine | null;
25
7
 
26
8
  constructor(
27
- private inner: ObservableSource,
9
+ private inner: Storage,
28
10
  private keystore: Keystore,
29
11
  authorizationRules: AuthorizationRules | null,
30
12
  private userIdentity: UserIdentity,
@@ -34,11 +16,6 @@ export class AuthenticationSession implements Authentication {
34
16
  this.authorizationEngine = authorizationRules &&
35
17
  new AuthorizationEngine(authorizationRules, inner);
36
18
  }
37
-
38
- async close(): Promise<void> {
39
- await this.inner.close();
40
- await this.keystore.close();
41
- }
42
19
 
43
20
  async login(): Promise<LoginResponse> {
44
21
  const userFact = await this.keystore.getOrCreateUserFact(this.userIdentity);
@@ -62,52 +39,13 @@ export class AuthenticationSession implements Authentication {
62
39
  return deviceFact;
63
40
  }
64
41
 
65
- from(fact: FactReference, query: Query): Observable {
66
- return this.inner.from(fact, query);
67
- }
68
-
69
- addSpecificationListener(specification: Specification, onResult: (results: ProjectedResult[]) => Promise<void>): SpecificationListener {
70
- return this.inner.addSpecificationListener(specification, onResult);
71
- }
72
-
73
- removeSpecificationListener(listener: SpecificationListener): void {
74
- this.inner.removeSpecificationListener(listener);
75
- }
76
-
77
- async save(envelopes: FactEnvelope[]): Promise<FactEnvelope[]> {
42
+ async authorize(envelopes: FactEnvelope[]): Promise<FactEnvelope[]> {
78
43
  const userFact = await this.keystore.getUserFact(this.userIdentity);
79
44
  const facts = envelopes.map(envelope => envelope.fact);
80
45
  const authorizedFacts = this.authorizationEngine
81
46
  ? await this.authorizationEngine.authorizeFacts(facts, userFact)
82
47
  : facts;
83
48
  const signedFacts = await this.keystore.signFacts(this.userIdentity, authorizedFacts);
84
- return await this.inner.save(signedFacts);
85
- }
86
-
87
- query(start: FactReference, query: Query): Promise<FactReference[][]> {
88
- return this.inner.query(start, query);
89
- }
90
-
91
- read(start: FactReference[], specification: Specification): Promise<any[]> {
92
- return this.inner.read(start, specification);
93
- }
94
-
95
- feed(feed: Feed, bookmark: string): Promise<FactFeed> {
96
- return this.inner.feed(feed, bookmark);
97
- }
98
-
99
- whichExist(references: FactReference[]): Promise<FactReference[]> {
100
- throw new Error("WhichExist method not implemented on AuthenticationSession.");
101
- }
102
-
103
- load(references: FactReference[]): Promise<FactRecord[]> {
104
- return this.inner.load(references);
105
- }
106
-
107
- addChannel(fact: FactReference, query: Query): Channel {
108
- return new Channel(async () => {});
109
- }
110
-
111
- removeChannel(channel: Channel): void {
49
+ return signedFacts;
112
50
  }
113
51
  }
@@ -7,9 +7,9 @@ import {
7
7
  FactRecord,
8
8
  FactReference,
9
9
  Feed,
10
- ObservableSource,
11
10
  Query,
12
11
  Specification,
12
+ Storage,
13
13
  UserIdentity
14
14
  } from "jinaga";
15
15
 
@@ -19,7 +19,7 @@ export class AuthorizationKeystore implements Authorization {
19
19
  private authorizationEngine: AuthorizationEngine | null;
20
20
 
21
21
  constructor(
22
- private observableSource: ObservableSource,
22
+ private observableSource: Storage,
23
23
  private keystore: Keystore,
24
24
  authorizationRules: AuthorizationRules | null) {
25
25
 
@@ -1,12 +1,16 @@
1
1
  import { Handler, Request } from "express";
2
2
  import {
3
+ AuthenticationNoOp,
3
4
  Authorization,
4
5
  AuthorizationNoOp,
5
6
  AuthorizationRules,
6
- Cache,
7
+ FactManager,
7
8
  Fork,
9
+ HttpNetwork,
8
10
  Jinaga,
9
11
  MemoryStore,
12
+ Network,
13
+ NetworkNoOp,
10
14
  ObservableSource,
11
15
  ObservableSourceImpl,
12
16
  PassThroughFork,
@@ -14,11 +18,10 @@ import {
14
18
  SyncStatusNotifier,
15
19
  TransientFork,
16
20
  UserIdentity,
17
- WebClient,
21
+ WebClient
18
22
  } from "jinaga";
19
23
 
20
24
  import { AuthenticationDevice } from "./authentication/authentication-device";
21
- import { AuthenticationNoOp } from "./authentication/authentication-noop";
22
25
  import { AuthenticationSession } from "./authentication/authentication-session";
23
26
  import { AuthorizationKeystore } from "./authorization/authorization-keystore";
24
27
  import { NodeHttpConnection } from "./http/node-http";
@@ -54,14 +57,16 @@ export class JinagaServer {
54
57
  const syncStatusNotifier = new SyncStatusNotifier();
55
58
  const store = createStore(config);
56
59
  const source = new ObservableSourceImpl(store);
57
- const fork = createFork(config, source, syncStatusNotifier);
60
+ const fork = createFork(config, store, syncStatusNotifier);
58
61
  const keystore = createKeystore(config);
59
62
  const authorizationRules = config.authorization ? config.authorization(new AuthorizationRules()) : null;
60
- const authorization = createAuthorization(authorizationRules, fork, keystore);
63
+ const authorization = createAuthorization(authorizationRules, store, keystore);
61
64
  const feedCache = new MemoryFeedCache();
62
65
  const router = new HttpRouter(authorization, feedCache);
63
- const authentication = createAuthentication(keystore, fork);
64
- const j: Jinaga = new Jinaga(authentication, syncStatusNotifier);
66
+ const authentication = createAuthentication(keystore);
67
+ const network = createNetwork(config);
68
+ const factManager = new FactManager(authentication, fork, source, store, network);
69
+ const j: Jinaga = new Jinaga(factManager, syncStatusNotifier);
65
70
 
66
71
  async function close() {
67
72
  if (keystore) {
@@ -73,7 +78,7 @@ export class JinagaServer {
73
78
  handler: router.handler,
74
79
  j,
75
80
  withSession: (req, callback) => {
76
- return withSession(source, keystore, authorizationRules, req, callback);
81
+ return withSession(store, keystore, authorizationRules, req, callback);
77
82
  },
78
83
  close
79
84
  }
@@ -83,26 +88,25 @@ export class JinagaServer {
83
88
  function createStore(config: JinagaServerConfig): Storage {
84
89
  if (config.pgStore) {
85
90
  const store = new PostgresStore(config.pgStore);
86
- const cache = new Cache(store);
87
- return cache;
91
+ return store;
88
92
  }
89
93
  else {
90
94
  return new MemoryStore();
91
95
  }
92
96
  }
93
97
 
94
- function createFork(config: JinagaServerConfig, feed: ObservableSource, syncStatusNotifier: SyncStatusNotifier): Fork {
98
+ function createFork(config: JinagaServerConfig, store: Storage, syncStatusNotifier: SyncStatusNotifier): Fork {
95
99
  if (config.httpEndpoint) {
96
100
  const httpConnection = new NodeHttpConnection(config.httpEndpoint);
97
101
  const httpTimeoutSeconds = config.httpTimeoutSeconds || 5;
98
102
  const webClient = new WebClient(httpConnection, syncStatusNotifier, {
99
103
  timeoutSeconds: httpTimeoutSeconds
100
104
  });
101
- const fork = new TransientFork(feed, webClient);
105
+ const fork = new TransientFork(store, webClient);
102
106
  return fork;
103
107
  }
104
108
  else {
105
- return new PassThroughFork(feed);
109
+ return new PassThroughFork(store);
106
110
  }
107
111
  }
108
112
 
@@ -110,28 +114,47 @@ function createKeystore(config: JinagaServerConfig) {
110
114
  return config.pgKeystore ? new PostgresKeystore(config.pgKeystore) : null;
111
115
  }
112
116
 
113
- function createAuthorization(authorizationRules: AuthorizationRules | null, feed: ObservableSource, keystore: Keystore | null): Authorization {
117
+ function createAuthorization(authorizationRules: AuthorizationRules | null, store: Storage, keystore: Keystore | null): Authorization {
114
118
  if (keystore) {
115
- const authorization = new AuthorizationKeystore(feed, keystore, authorizationRules);
119
+ const authorization = new AuthorizationKeystore(store, keystore, authorizationRules);
116
120
  return authorization;
117
121
  }
118
122
  else {
119
- return new AuthorizationNoOp(feed);
123
+ return new AuthorizationNoOp(store);
120
124
  }
121
125
  }
122
126
 
123
- function createAuthentication(keystore: PostgresKeystore | null, fork: Fork) {
124
- return keystore ? new AuthenticationDevice(fork, keystore, localDeviceIdentity) : new AuthenticationNoOp(fork);
127
+ function createAuthentication(keystore: PostgresKeystore | null) {
128
+ return keystore ? new AuthenticationDevice(keystore, localDeviceIdentity) : new AuthenticationNoOp();
125
129
  }
126
130
 
127
- async function withSession(feed: ObservableSource, keystore: Keystore | null, authorizationRules: AuthorizationRules | null, req: Request, callback: ((j: Jinaga) => Promise<void>)) {
131
+ function createNetwork(config: JinagaServerConfig): Network {
132
+ if (config.httpEndpoint) {
133
+ const httpConnection = new NodeHttpConnection(config.httpEndpoint);
134
+ const httpTimeoutSeconds = config.httpTimeoutSeconds || 5;
135
+ const syncStatusNotifier = new SyncStatusNotifier();
136
+ const webClient = new WebClient(httpConnection, syncStatusNotifier, {
137
+ timeoutSeconds: httpTimeoutSeconds
138
+ });
139
+ return new HttpNetwork(webClient);
140
+ }
141
+ else {
142
+ return new NetworkNoOp();
143
+ }
144
+ }
145
+
146
+ async function withSession(store: Storage, keystore: Keystore | null, authorizationRules: AuthorizationRules | null, req: Request, callback: ((j: Jinaga) => Promise<void>)) {
128
147
  const user = <RequestUser>req.user;
129
148
  const userIdentity: UserIdentity = {
130
149
  provider: user.provider,
131
150
  id: user.id
132
151
  }
133
- const authentication = keystore ? new AuthenticationSession(feed, keystore, authorizationRules, userIdentity, user.profile.displayName, localDeviceIdentity) : new AuthenticationNoOp(feed);
152
+ const authentication = keystore ? new AuthenticationSession(store, keystore, authorizationRules, userIdentity, user.profile.displayName, localDeviceIdentity) : new AuthenticationNoOp();
134
153
  const syncStatusNotifier = new SyncStatusNotifier();
135
- const j = new Jinaga(authentication, syncStatusNotifier);
154
+ const fork = new PassThroughFork(store);
155
+ const observableSource = new ObservableSource(store);
156
+ const network = new NetworkNoOp();
157
+ const factManager = new FactManager(authentication, fork, observableSource, store, network);
158
+ const j = new Jinaga(factManager, syncStatusNotifier);
136
159
  await callback(j);
137
160
  }
@@ -468,6 +468,14 @@ export class PostgresStore implements Storage {
468
468
  }
469
469
  return factTypes;
470
470
  }
471
+
472
+ loadBookmark(feed: string): Promise<string> {
473
+ throw new Error("Method not implemented.");
474
+ }
475
+
476
+ saveBookmark(feed: string, bookmark: string): Promise<void> {
477
+ throw new Error("Method not implemented.");
478
+ }
471
479
  }
472
480
 
473
481
  async function executeQueryTree(sqlQueryTree: SqlQueryTree, connection: PoolClient): Promise<ResultSetTree> {
@@ -5,8 +5,7 @@ import {
5
5
  FactRecord,
6
6
  hydrate,
7
7
  Jinaga as j,
8
- MemoryStore,
9
- ObservableSourceImpl,
8
+ MemoryStore
10
9
  } from "jinaga";
11
10
 
12
11
  import { AuthorizationKeystore } from "../../src/authorization/authorization-keystore";
@@ -161,7 +160,6 @@ function givenStorage() {
161
160
  function givenAuthorizationWithStorage(storage: MemoryStore) {
162
161
  const keystore = new MemoryKeystore();
163
162
  keystore.getOrCreateUserFact(givenMockUserIdentity());
164
- const feed = new ObservableSourceImpl(storage);
165
163
  const authorizationRules = new AuthorizationRules()
166
164
  .any('Hashtag')
167
165
  .no('Jinaga.User')
@@ -169,7 +167,7 @@ function givenAuthorizationWithStorage(storage: MemoryStore) {
169
167
  .type('Like', j.for(likeUser))
170
168
  .type('Delete', j.for(deleteSender))
171
169
  ;
172
- return new AuthorizationKeystore(feed, keystore, authorizationRules);
170
+ return new AuthorizationKeystore(storage, keystore, authorizationRules);
173
171
  }
174
172
 
175
173
  function givenOtherUser() {
@@ -1,23 +0,0 @@
1
- import { Channel, FactEnvelope, FactFeed, FactRecord, FactReference, Feed, Fork, Observable, ProjectedResult, Query, Specification, SpecificationListener, WebClient } from "jinaga";
2
- import { Authentication } from "./authentication";
3
- export declare class Principal {
4
- }
5
- export declare class AuthenticationImpl implements Authentication {
6
- private inner;
7
- private client;
8
- constructor(inner: Fork, client: WebClient);
9
- close(): Promise<void>;
10
- login(): Promise<import("jinaga").LoginResponse>;
11
- local(): Promise<FactRecord>;
12
- save(envelopes: FactEnvelope[]): Promise<FactEnvelope[]>;
13
- query(start: FactReference, query: Query): Promise<import("jinaga").FactPath[]>;
14
- read(start: FactReference[], specification: Specification): Promise<any[]>;
15
- feed(feed: Feed, bookmark: string): Promise<FactFeed>;
16
- whichExist(references: FactReference[]): Promise<FactReference[]>;
17
- load(references: FactReference[]): Promise<FactRecord[]>;
18
- from(fact: FactReference, query: Query): Observable;
19
- addSpecificationListener(specification: Specification, onResult: (results: ProjectedResult[]) => Promise<void>): SpecificationListener;
20
- removeSpecificationListener(listener: SpecificationListener): void;
21
- addChannel(fact: FactReference, query: Query): Channel;
22
- removeChannel(channel: Channel): void;
23
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AuthenticationImpl = exports.Principal = void 0;
13
- class Principal {
14
- }
15
- exports.Principal = Principal;
16
- class AuthenticationImpl {
17
- constructor(inner, client) {
18
- this.inner = inner;
19
- this.client = client;
20
- }
21
- close() {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- yield this.inner.close();
24
- });
25
- }
26
- login() {
27
- return this.client.login();
28
- }
29
- local() {
30
- throw new Error('Local device has no persistence.');
31
- }
32
- save(envelopes) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const saved = yield this.inner.save(envelopes);
35
- return saved;
36
- });
37
- }
38
- query(start, query) {
39
- return this.inner.query(start, query);
40
- }
41
- read(start, specification) {
42
- return this.inner.read(start, specification);
43
- }
44
- feed(feed, bookmark) {
45
- return this.inner.feed(feed, bookmark);
46
- }
47
- whichExist(references) {
48
- throw new Error("whichExist method not implemented on AuthenticationImpl.");
49
- }
50
- load(references) {
51
- return this.inner.load(references);
52
- }
53
- from(fact, query) {
54
- return this.inner.from(fact, query);
55
- }
56
- addSpecificationListener(specification, onResult) {
57
- return this.inner.addSpecificationListener(specification, onResult);
58
- }
59
- removeSpecificationListener(listener) {
60
- this.inner.removeSpecificationListener(listener);
61
- }
62
- addChannel(fact, query) {
63
- return this.inner.addChannel(fact, query);
64
- }
65
- removeChannel(channel) {
66
- this.inner.removeChannel(channel);
67
- }
68
- }
69
- exports.AuthenticationImpl = AuthenticationImpl;
70
- //# sourceMappingURL=authentication-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authentication-impl.js","sourceRoot":"","sources":["../../src/authentication/authentication-impl.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,MAAa,SAAS;CAErB;AAFD,8BAEC;AAED,MAAa,kBAAkB;IAC3B,YAAoB,KAAW,EAAU,MAAiB;QAAtC,UAAK,GAAL,KAAK,CAAM;QAAU,WAAM,GAAN,MAAM,CAAW;IAC1D,CAAC;IAEK,KAAK;;YACP,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;KAAA;IAED,KAAK;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK;QACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACxD,CAAC;IAEK,IAAI,CAAC,SAAyB;;YAChC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC/C,OAAO,KAAK,CAAC;QACjB,CAAC;KAAA;IAED,KAAK,CAAC,KAAoB,EAAE,KAAY;QACpC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC,KAAsB,EAAE,aAA4B;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,CAAC,IAAU,EAAE,QAAgB;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED,UAAU,CAAC,UAA2B;QAClC,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,CAAC,UAA2B;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,IAAmB,EAAE,KAAY;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,wBAAwB,CAAC,aAA4B,EAAE,QAAuD;QAC1G,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;IAED,2BAA2B,CAAC,QAA+B;QACvD,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,CAAC,IAAmB,EAAE,KAAY;QACxC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,aAAa,CAAC,OAAgB;QAC1B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACJ;AA5DD,gDA4DC"}
@@ -1,20 +0,0 @@
1
- import { Channel, FactEnvelope, FactFeed, FactPath, FactRecord, FactReference, Feed, LoginResponse, Observable, ObservableSource, ProjectedResult, Query, Specification, SpecificationListener } from "jinaga";
2
- import { Authentication } from "./authentication";
3
- export declare class AuthenticationNoOp implements Authentication {
4
- private inner;
5
- constructor(inner: ObservableSource);
6
- login(): Promise<LoginResponse>;
7
- local(): Promise<FactRecord>;
8
- addChannel(fact: FactReference, query: Query): Channel;
9
- removeChannel(channel: Channel): void;
10
- from(fact: FactReference, query: Query): Observable;
11
- addSpecificationListener(specification: Specification, onResult: (results: ProjectedResult[]) => Promise<void>): SpecificationListener;
12
- removeSpecificationListener(listener: SpecificationListener): void;
13
- close(): Promise<void>;
14
- save(envelopes: FactEnvelope[]): Promise<FactEnvelope[]>;
15
- query(start: FactReference, query: Query): Promise<FactPath[]>;
16
- read(start: FactReference[], specification: Specification): Promise<ProjectedResult[]>;
17
- feed(feed: Feed, bookmark: string): Promise<FactFeed>;
18
- whichExist(references: FactReference[]): Promise<FactReference[]>;
19
- load(references: FactReference[]): Promise<FactRecord[]>;
20
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthenticationNoOp = void 0;
4
- class AuthenticationNoOp {
5
- constructor(inner) {
6
- this.inner = inner;
7
- }
8
- login() {
9
- throw new Error("No keystore is configured.");
10
- }
11
- local() {
12
- throw new Error("No keystore is configured.");
13
- }
14
- addChannel(fact, query) {
15
- throw new Error("No keystore is configured.");
16
- }
17
- removeChannel(channel) {
18
- throw new Error("No keystore is configured.");
19
- }
20
- from(fact, query) {
21
- return this.inner.from(fact, query);
22
- }
23
- addSpecificationListener(specification, onResult) {
24
- return this.inner.addSpecificationListener(specification, onResult);
25
- }
26
- removeSpecificationListener(listener) {
27
- return this.inner.removeSpecificationListener(listener);
28
- }
29
- close() {
30
- return this.inner.close();
31
- }
32
- save(envelopes) {
33
- return this.inner.save(envelopes);
34
- }
35
- query(start, query) {
36
- return this.inner.query(start, query);
37
- }
38
- read(start, specification) {
39
- return this.inner.read(start, specification);
40
- }
41
- feed(feed, bookmark) {
42
- return this.inner.feed(feed, bookmark);
43
- }
44
- whichExist(references) {
45
- return this.inner.whichExist(references);
46
- }
47
- load(references) {
48
- return this.inner.load(references);
49
- }
50
- }
51
- exports.AuthenticationNoOp = AuthenticationNoOp;
52
- //# sourceMappingURL=authentication-noop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authentication-noop.js","sourceRoot":"","sources":["../../src/authentication/authentication-noop.ts"],"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CAAC;IAED,IAAI,CAAC,IAAU,EAAE,QAAgB;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED,UAAU,CAAC,UAA2B;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,UAA2B;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACJ;AA7DD,gDA6DC"}
@@ -1,5 +0,0 @@
1
- import { FactRecord, Fork, LoginResponse } from "jinaga";
2
- export interface Authentication extends Fork {
3
- login(): Promise<LoginResponse>;
4
- local(): Promise<FactRecord>;
5
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=authentication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../src/authentication/authentication.ts"],"names":[],"mappings":""}
@@ -1,19 +0,0 @@
1
- import { FactEnvelope, FactFeed, FactRecord, FactReference, Feed, Observable, ObservableSource, ProjectedResult, Query, Specification, SpecificationListener, WebClient } from "jinaga";
2
- export declare class Principal {
3
- }
4
- export declare class Authentication implements ObservableSource {
5
- private inner;
6
- private client;
7
- constructor(inner: ObservableSource, client: WebClient);
8
- close(): Promise<void>;
9
- login(): Promise<import("jinaga").LoginResponse>;
10
- save(envelopes: FactEnvelope[]): Promise<FactEnvelope[]>;
11
- query(start: FactReference, query: Query): Promise<import("jinaga").FactPath[]>;
12
- read(start: FactReference[], specification: Specification): Promise<any[]>;
13
- feed(feed: Feed, bookmark: string): Promise<FactFeed>;
14
- whichExist(references: FactReference[]): Promise<FactReference[]>;
15
- load(references: FactReference[]): Promise<FactRecord[]>;
16
- from(fact: FactReference, query: Query): Observable;
17
- addSpecificationListener(specification: Specification, onResult: (results: ProjectedResult[]) => Promise<void>): SpecificationListener;
18
- removeSpecificationListener(listener: SpecificationListener): void;
19
- }
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Authentication = exports.Principal = void 0;
13
- class Principal {
14
- }
15
- exports.Principal = Principal;
16
- class Authentication {
17
- constructor(inner, client) {
18
- this.inner = inner;
19
- this.client = client;
20
- }
21
- close() {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- yield this.inner.close();
24
- });
25
- }
26
- login() {
27
- return this.client.login();
28
- }
29
- save(envelopes) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const saved = yield this.inner.save(envelopes);
32
- return saved;
33
- });
34
- }
35
- query(start, query) {
36
- return this.inner.query(start, query);
37
- }
38
- read(start, specification) {
39
- return this.inner.read(start, specification);
40
- }
41
- feed(feed, bookmark) {
42
- return this.inner.feed(feed, bookmark);
43
- }
44
- whichExist(references) {
45
- throw new Error("whichExist method not implemented on Authentication.");
46
- }
47
- load(references) {
48
- return this.inner.load(references);
49
- }
50
- from(fact, query) {
51
- return this.inner.from(fact, query);
52
- }
53
- addSpecificationListener(specification, onResult) {
54
- return this.inner.addSpecificationListener(specification, onResult);
55
- }
56
- removeSpecificationListener(listener) {
57
- this.inner.removeSpecificationListener(listener);
58
- }
59
- }
60
- exports.Authentication = Authentication;
61
- //# sourceMappingURL=authentication.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authentication.js","s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AC;IAED,wBAAwB,CAAC,aAA4B,EAAE,QAAuD;QAC1G,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;IAED,2BAA2B,CAAC,QAA+B;QACvD,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;CACJ;AAhDD,wCAgDC"}
@@ -1,69 +0,0 @@
1
- import { Channel, FactEnvelope, FactFeed, FactRecord, FactReference, Feed, Fork, Observable, ProjectedResult, Query, Specification, SpecificationListener, WebClient } from "jinaga";
2
-
3
- import { Authentication } from "./authentication";
4
-
5
- export class Principal {
6
-
7
- }
8
-
9
- export class AuthenticationImpl implements Authentication {
10
- constructor(private inner: Fork, private client: WebClient) {
11
- }
12
-
13
- async close(): Promise<void> {
14
- await this.inner.close();
15
- }
16
-
17
- login() {
18
- return this.client.login();
19
- }
20
-
21
- local(): Promise<FactRecord> {
22
- throw new Error('Local device has no persistence.');
23
- }
24
-
25
- async save(envelopes: FactEnvelope[]): Promise<FactEnvelope[]> {
26
- const saved = await this.inner.save(envelopes);
27
- return saved;
28
- }
29
-
30
- query(start: FactReference, query: Query) {
31
- return this.inner.query(start, query);
32
- }
33
-
34
- read(start: FactReference[], specification: Specification): Promise<any[]> {
35
- return this.inner.read(start, specification);
36
- }
37
-
38
- feed(feed: Feed, bookmark: string): Promise<FactFeed> {
39
- return this.inner.feed(feed, bookmark);
40
- }
41
-
42
- whichExist(references: FactReference[]): Promise<FactReference[]> {
43
- throw new Error("whichExist method not implemented on AuthenticationImpl.");
44
- }
45
-
46
- load(references: FactReference[]): Promise<FactRecord[]> {
47
- return this.inner.load(references);
48
- }
49
-
50
- from(fact: FactReference, query: Query): Observable {
51
- return this.inner.from(fact, query);
52
- }
53
-
54
- addSpecificationListener(specification: Specification, onResult: (results: ProjectedResult[]) => Promise<void>): SpecificationListener {
55
- return this.inner.addSpecificationListener(specification, onResult);
56
- }
57
-
58
- removeSpecificationListener(listener: SpecificationListener): void {
59
- this.inner.removeSpecificationListener(listener);
60
- }
61
-
62
- addChannel(fact: FactReference, query: Query): Channel {
63
- return this.inner.addChannel(fact, query);
64
- }
65
-
66
- removeChannel(channel: Channel) {
67
- this.inner.removeChannel(channel);
68
- }
69
- }