jinaga-server 2.6.1 → 3.0.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 (32) hide show
  1. package/dist/authentication/authentication-device.js +27 -6
  2. package/dist/authentication/authentication-device.js.map +1 -1
  3. package/dist/authentication/authentication-session.js +27 -6
  4. package/dist/authentication/authentication-session.js.map +1 -1
  5. package/dist/authorization/authorization-keystore.d.ts +4 -5
  6. package/dist/authorization/authorization-keystore.js +42 -18
  7. package/dist/authorization/authorization-keystore.js.map +1 -1
  8. package/dist/http/router.d.ts +1 -2
  9. package/dist/http/router.js +14 -18
  10. package/dist/http/router.js.map +1 -1
  11. package/dist/jinaga-server.js +5 -6
  12. package/dist/jinaga-server.js.map +1 -1
  13. package/dist/postgres/postgres-store.d.ts +2 -5
  14. package/dist/postgres/postgres-store.js +44 -121
  15. package/dist/postgres/postgres-store.js.map +1 -1
  16. package/http/sans-auth/Feed sites.http +1 -1
  17. package/integration-test/jinaga-test/jinaga.test.js +247 -231
  18. package/integration-test/jinaga-test/package-lock.json +16 -59
  19. package/integration-test/jinaga-test/package.json +2 -5
  20. package/package.json +3 -4
  21. package/src/authentication/authentication-device.ts +29 -7
  22. package/src/authentication/authentication-session.ts +29 -7
  23. package/src/authorization/authorization-keystore.ts +42 -22
  24. package/src/http/router.ts +14 -24
  25. package/src/jinaga-server.ts +5 -6
  26. package/src/postgres/postgres-store.ts +63 -149
  27. package/test/authorization/authorizationSpec.ts +75 -89
  28. package/dist/postgres/sql.d.ts +0 -10
  29. package/dist/postgres/sql.js +0 -408
  30. package/dist/postgres/sql.js.map +0 -1
  31. package/src/postgres/sql.ts +0 -498
  32. package/test/postgres/postgresSpec.ts +0 -391
@@ -13,12 +13,9 @@
13
13
  "express": "^4.17.2",
14
14
  "jest": "^29.7.0",
15
15
  "jest-compact-reporter": "^1.2.9",
16
- "jinaga": "^5.6.0",
16
+ "jinaga": "^6.0.0",
17
17
  "node-forge": "^1.3.0",
18
- "passport": "^0.6.0",
19
- "pg": "^8.11.1",
20
- "tweetnacl": "^1.0.3",
21
- "tweetnacl-util": "^0.15.1"
18
+ "pg": "^8.11.3"
22
19
  }
23
20
  },
24
21
  "node_modules/@ampproject/remapping": {
@@ -1031,9 +1028,9 @@
1031
1028
  }
1032
1029
  },
1033
1030
  "node_modules/@stablelib/utf8": {
1034
- "version": "1.0.1",
1035
- "resolved": "https://registry.npmjs.org/@stablelib/utf8/-/utf8-1.0.1.tgz",
1036
- "integrity": "sha512-FrYD1xadah/TtAP6VJ04lDD5h9rdDj/d8wH/jMYTtHqZBv9z2btdvEU8vTxdjdkFmo1b/BH+t3R1wi/mYhCCNg=="
1031
+ "version": "1.0.2",
1032
+ "resolved": "https://registry.npmjs.org/@stablelib/utf8/-/utf8-1.0.2.tgz",
1033
+ "integrity": "sha512-sDL1aB2U8FIpj7SjQJMxbOFIFkKvDKQGPHSrYejHZhtLNSK3qHe6ZIfa0woWkOiaJsdYslFzrc0VWXJZHmSIQQ=="
1037
1034
  },
1038
1035
  "node_modules/@stablelib/wipe": {
1039
1036
  "version": "1.0.1",
@@ -2894,13 +2891,13 @@
2894
2891
  }
2895
2892
  },
2896
2893
  "node_modules/jinaga": {
2897
- "version": "5.6.0",
2898
- "resolved": "https://registry.npmjs.org/jinaga/-/jinaga-5.6.0.tgz",
2899
- "integrity": "sha512-cw78Ik0TI6yq8ndAyXdlSaAeLdasPid+r+xpU0kuKXCxV43XAXxBfaoeHHG0iNrZwsq8hm1PmbYtfgb2zt39sw==",
2894
+ "version": "6.0.0",
2895
+ "resolved": "https://registry.npmjs.org/jinaga/-/jinaga-6.0.0.tgz",
2896
+ "integrity": "sha512-LWUCAO5L3FQgM+SBVHQYlZ2ot1TkPgdDp3SzhfmhgPN9Vapv5l15zKtUs0ggPHECvAskRMmAZIDXWHC3rt0pmg==",
2900
2897
  "dependencies": {
2901
2898
  "@stablelib/base64": "^1.0.1",
2902
2899
  "@stablelib/sha512": "^1.0.1",
2903
- "@stablelib/utf8": "^1.0.1"
2900
+ "@stablelib/utf8": "^1.0.2"
2904
2901
  },
2905
2902
  "engines": {
2906
2903
  "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
@@ -3302,31 +3299,6 @@
3302
3299
  "node": ">= 0.8"
3303
3300
  }
3304
3301
  },
3305
- "node_modules/passport": {
3306
- "version": "0.6.0",
3307
- "resolved": "https://registry.npmjs.org/passport/-/passport-0.6.0.tgz",
3308
- "integrity": "sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug==",
3309
- "dependencies": {
3310
- "passport-strategy": "1.x.x",
3311
- "pause": "0.0.1",
3312
- "utils-merge": "^1.0.1"
3313
- },
3314
- "engines": {
3315
- "node": ">= 0.4.0"
3316
- },
3317
- "funding": {
3318
- "type": "github",
3319
- "url": "https://github.com/sponsors/jaredhanson"
3320
- }
3321
- },
3322
- "node_modules/passport-strategy": {
3323
- "version": "1.0.0",
3324
- "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
3325
- "integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==",
3326
- "engines": {
3327
- "node": ">= 0.4.0"
3328
- }
3329
- },
3330
3302
  "node_modules/path-exists": {
3331
3303
  "version": "4.0.0",
3332
3304
  "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -3361,19 +3333,14 @@
3361
3333
  "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
3362
3334
  "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
3363
3335
  },
3364
- "node_modules/pause": {
3365
- "version": "0.0.1",
3366
- "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
3367
- "integrity": "sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg=="
3368
- },
3369
3336
  "node_modules/pg": {
3370
- "version": "8.11.1",
3371
- "resolved": "https://registry.npmjs.org/pg/-/pg-8.11.1.tgz",
3372
- "integrity": "sha512-utdq2obft07MxaDg0zBJI+l/M3mBRfIpEN3iSemsz0G5F2/VXx+XzqF4oxrbIZXQxt2AZzIUzyVg/YM6xOP/WQ==",
3337
+ "version": "8.11.3",
3338
+ "resolved": "https://registry.npmjs.org/pg/-/pg-8.11.3.tgz",
3339
+ "integrity": "sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g==",
3373
3340
  "dependencies": {
3374
3341
  "buffer-writer": "2.0.0",
3375
3342
  "packet-reader": "1.0.0",
3376
- "pg-connection-string": "^2.6.1",
3343
+ "pg-connection-string": "^2.6.2",
3377
3344
  "pg-pool": "^3.6.1",
3378
3345
  "pg-protocol": "^1.6.0",
3379
3346
  "pg-types": "^2.1.0",
@@ -3401,9 +3368,9 @@
3401
3368
  "optional": true
3402
3369
  },
3403
3370
  "node_modules/pg-connection-string": {
3404
- "version": "2.6.1",
3405
- "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.1.tgz",
3406
- "integrity": "sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg=="
3371
+ "version": "2.6.2",
3372
+ "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.2.tgz",
3373
+ "integrity": "sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA=="
3407
3374
  },
3408
3375
  "node_modules/pg-int8": {
3409
3376
  "version": "1.0.1",
@@ -3982,16 +3949,6 @@
3982
3949
  "node": ">=0.6"
3983
3950
  }
3984
3951
  },
3985
- "node_modules/tweetnacl": {
3986
- "version": "1.0.3",
3987
- "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
3988
- "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="
3989
- },
3990
- "node_modules/tweetnacl-util": {
3991
- "version": "0.15.1",
3992
- "resolved": "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz",
3993
- "integrity": "sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw=="
3994
- },
3995
3952
  "node_modules/type-detect": {
3996
3953
  "version": "4.0.8",
3997
3954
  "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
@@ -17,11 +17,8 @@
17
17
  "express": "^4.17.2",
18
18
  "jest": "^29.7.0",
19
19
  "jest-compact-reporter": "^1.2.9",
20
- "jinaga": "^5.6.0",
20
+ "jinaga": "^6.0.0",
21
21
  "node-forge": "^1.3.0",
22
- "passport": "^0.6.0",
23
- "pg": "^8.11.1",
24
- "tweetnacl": "^1.0.3",
25
- "tweetnacl-util": "^0.15.1"
22
+ "pg": "^8.11.3"
26
23
  }
27
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinaga-server",
3
- "version": "2.6.1",
3
+ "version": "3.0.0",
4
4
  "description": "Data management for web and mobile applications.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -48,9 +48,8 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "express": "^4.18.2",
51
- "jinaga": "^5.6.0",
51
+ "jinaga": "^6.0.0",
52
52
  "node-forge": "^1.3.1",
53
- "passport": "^0.6.0",
54
- "pg": "^8.11.0"
53
+ "pg": "^8.11.3"
55
54
  }
56
55
  }
@@ -1,4 +1,4 @@
1
- import { Authentication, AuthorizationEngine, AuthorizationRules, FactEnvelope, FactRecord, LoginResponse, Storage, UserIdentity } from "jinaga";
1
+ import { Authentication, AuthorizationEngine, AuthorizationRules, FactEnvelope, FactRecord, LoginResponse, Storage, UserIdentity, factReferenceEquals } from "jinaga";
2
2
 
3
3
  import { Keystore } from "../keystore";
4
4
 
@@ -33,11 +33,33 @@ export class AuthenticationDevice implements Authentication {
33
33
 
34
34
  async authorize(envelopes: FactEnvelope[]): Promise<FactEnvelope[]> {
35
35
  const deviceFact = await this.keystore.getOrCreateDeviceFact(this.localDeviceIdentity);
36
- const facts = envelopes.map(envelope => envelope.fact);
37
- const authorizedFacts = this.authorizationEngine
38
- ? await this.authorizationEngine.authorizeFacts(facts, deviceFact)
39
- : facts;
40
- const signedFacts = await this.keystore.signFacts(this.localDeviceIdentity, authorizedFacts);
41
- return signedFacts;
36
+
37
+ if (this.authorizationEngine) {
38
+ const results = await this.authorizationEngine.authorizeFacts(envelopes, deviceFact);
39
+ const authorizedEnvelopes: FactEnvelope[] = results.map(r => {
40
+ const isFact = factReferenceEquals(r.fact);
41
+ const envelope = envelopes.find(e => isFact(e.fact));
42
+ if (!envelope) {
43
+ throw new Error("Fact not found in envelopes.");
44
+ }
45
+ if (r.verdict === "Accept") {
46
+ return {
47
+ fact: r.fact,
48
+ signatures: envelope.signatures
49
+ .filter(s => r.newPublicKeys.includes(s.publicKey))
50
+ };
51
+ }
52
+ else if (r.verdict === "Existing") {
53
+ return envelope;
54
+ }
55
+ else {
56
+ throw new Error("Unexpected verdict.");
57
+ }
58
+ });
59
+ return authorizedEnvelopes;
60
+ }
61
+ else {
62
+ return envelopes;
63
+ }
42
64
  }
43
65
  }
@@ -1,4 +1,4 @@
1
- import { Authentication, AuthorizationEngine, AuthorizationRules, FactEnvelope, FactRecord, LoginResponse, Storage, UserIdentity } from "jinaga";
1
+ import { Authentication, AuthorizationEngine, AuthorizationRules, FactEnvelope, FactRecord, LoginResponse, Storage, UserIdentity, factReferenceEquals } from "jinaga";
2
2
 
3
3
  import { Keystore } from "../keystore";
4
4
 
@@ -41,11 +41,33 @@ export class AuthenticationSession implements Authentication {
41
41
 
42
42
  async authorize(envelopes: FactEnvelope[]): Promise<FactEnvelope[]> {
43
43
  const userFact = await this.keystore.getUserFact(this.userIdentity);
44
- const facts = envelopes.map(envelope => envelope.fact);
45
- const authorizedFacts = this.authorizationEngine
46
- ? await this.authorizationEngine.authorizeFacts(facts, userFact)
47
- : facts;
48
- const signedFacts = await this.keystore.signFacts(this.userIdentity, authorizedFacts);
49
- return signedFacts;
44
+
45
+ if (this.authorizationEngine) {
46
+ const results = await this.authorizationEngine.authorizeFacts(envelopes, userFact);
47
+ const authorizedEnvelopes: FactEnvelope[] = results.map(r => {
48
+ const isFact = factReferenceEquals(r.fact);
49
+ const envelope = envelopes.find(e => isFact(e.fact));
50
+ if (!envelope) {
51
+ throw new Error("Fact not found in envelopes.");
52
+ }
53
+ if (r.verdict === "Accept") {
54
+ return {
55
+ fact: r.fact,
56
+ signatures: envelope.signatures
57
+ .filter(s => r.newPublicKeys.includes(s.publicKey))
58
+ };
59
+ }
60
+ else if (r.verdict === "Existing") {
61
+ return envelope;
62
+ }
63
+ else {
64
+ throw new Error("Unexpected verdict.");
65
+ }
66
+ });
67
+ return authorizedEnvelopes;
68
+ }
69
+ else {
70
+ return envelopes;
71
+ }
50
72
  }
51
73
  }
@@ -7,10 +7,8 @@ import {
7
7
  FactEnvelope,
8
8
  FactFeed,
9
9
  FactManager,
10
- FactRecord,
11
10
  FactReference,
12
11
  Forbidden,
13
- Query,
14
12
  ReferencesByName,
15
13
  Specification,
16
14
  Storage,
@@ -52,10 +50,6 @@ export class AuthorizationKeystore implements Authorization {
52
50
  return userFact;
53
51
  }
54
52
 
55
- query(userIdentity: UserIdentity | null, start: FactReference, query: Query) {
56
- return this.factManager.query(start, query);
57
- }
58
-
59
53
  async read(userIdentity: UserIdentity | null, start: FactReference[], specification: Specification) {
60
54
  if (this.distributionEngine) {
61
55
  const userReference: FactReference | null = userIdentity
@@ -111,24 +105,50 @@ export class AuthorizationKeystore implements Authorization {
111
105
  return await this.factManager.load(references);
112
106
  }
113
107
 
114
- async save(userIdentity: UserIdentity | null, facts: FactRecord[]) {
115
- if (!this.authorizationEngine) {
116
- const envelopes = await this.factManager.save(facts.map(fact => ({
117
- fact,
118
- signatures: []
119
- })));
120
- return envelopes.map(envelope => envelope.fact);
121
- }
122
-
123
- const userFact = userIdentity ? await this.keystore.getUserFact(userIdentity) : null;
124
- const authorizedFacts = await this.authorizationEngine.authorizeFacts(facts, userFact);
125
- if (userIdentity) {
126
- const signedFacts = await this.keystore.signFacts(userIdentity, authorizedFacts);
127
- const envelopes = await this.factManager.save(signedFacts);
128
- return envelopes.map(envelope => envelope.fact);
108
+ async save(userIdentity: UserIdentity | null, envelopes: FactEnvelope[]): Promise<FactEnvelope[]> {
109
+ if (this.authorizationEngine) {
110
+ const userFact = userIdentity ? await this.keystore.getUserFact(userIdentity) : null;
111
+ const results = await this.authorizationEngine.authorizeFacts(envelopes, userFact);
112
+ const userKeys : string[] = (userFact && userFact.fields.hasOwnProperty("publicKey"))
113
+ ? [ userFact.fields.publicKey ]
114
+ : [];
115
+ const factsToSign = results
116
+ .filter(r => r.verdict === "Accept" && r.newPublicKeys.some(k => userKeys.includes(k)))
117
+ .map(r => r.fact);
118
+ const signedFacts = (userIdentity && factsToSign.length > 0)
119
+ ? await this.keystore.signFacts(userIdentity, factsToSign)
120
+ : [];
121
+ const authorizedEnvelopes: FactEnvelope[] = results.map(r => {
122
+ const isFact = factReferenceEquals(r.fact);
123
+ const envelope = envelopes.find(e => isFact(e.fact));
124
+ if (!envelope) {
125
+ throw new Error("Fact not found in envelopes.");
126
+ }
127
+ if (r.verdict === "Accept") {
128
+ const signedFact = signedFacts.find(f => isFact(f.fact));
129
+ const userSignatures = signedFact
130
+ ? signedFact.signatures
131
+ : [];
132
+ return {
133
+ fact: r.fact,
134
+ signatures: envelope.signatures
135
+ .filter(s => r.newPublicKeys.includes(s.publicKey))
136
+ .concat(userSignatures)
137
+ };
138
+ }
139
+ else if (r.verdict === "Existing") {
140
+ return envelope;
141
+ }
142
+ else {
143
+ throw new Error("Unexpected verdict.");
144
+ }
145
+ });
146
+ const savedEnvelopes = await this.factManager.save(authorizedEnvelopes);
147
+ return savedEnvelopes;
129
148
  }
130
149
  else {
131
- return authorizedFacts;
150
+ const savedEnvelopes = await this.factManager.save(envelopes);
151
+ return savedEnvelopes;
132
152
  }
133
153
  }
134
154
 
@@ -14,8 +14,6 @@ import {
14
14
  LoadResponse,
15
15
  ProfileMessage,
16
16
  ProjectedResult,
17
- QueryMessage,
18
- QueryResponse,
19
17
  ReferencesByName,
20
18
  SaveMessage,
21
19
  Specification,
@@ -25,10 +23,8 @@ import {
25
23
  buildFeeds,
26
24
  computeObjectHash,
27
25
  computeTupleSubsetHash,
28
- fromDescriptiveString,
29
26
  invertSpecification,
30
27
  parseLoadMessage,
31
- parseQueryMessage,
32
28
  parseSaveMessage
33
29
  } from "jinaga";
34
30
 
@@ -68,7 +64,7 @@ function getOrStream<U>(
68
64
  })
69
65
  .done(() => {
70
66
  clearTimeout(timeout);
71
- next();
67
+ res.socket.end();
72
68
  });
73
69
  }
74
70
  })
@@ -285,15 +281,9 @@ export interface RequestUser {
285
281
  export class HttpRouter {
286
282
  handler: Handler;
287
283
 
288
- constructor(private factManager: FactManager, private authorization: Authorization, private feedCache: FeedCache, backwardCompatible: boolean) {
284
+ constructor(private factManager: FactManager, private authorization: Authorization, private feedCache: FeedCache) {
289
285
  const router = Router();
290
286
  router.get('/login', getAuthenticate(user => this.login(user)));
291
- if (backwardCompatible) {
292
- router.post('/query', post(
293
- parseQueryMessage,
294
- (user, queryMessage) => this.query(user, queryMessage)
295
- ));
296
- }
297
287
  router.post('/load', post(
298
288
  parseLoadMessage,
299
289
  (user, loadMessage) => this.load(user, loadMessage)
@@ -327,26 +317,22 @@ export class HttpRouter {
327
317
  };
328
318
  }
329
319
 
330
- private async query(user: RequestUser | null, queryMessage: QueryMessage): Promise<QueryResponse> {
331
- const userIdentity = serializeUserIdentity(user);
332
- const query = fromDescriptiveString(queryMessage.query);
333
- const result = await this.authorization.query(userIdentity, queryMessage.start, query);
334
- return {
335
- results: result
336
- };
337
- }
338
-
339
320
  private async load(user: RequestUser, loadMessage: LoadMessage): Promise<LoadResponse> {
340
321
  const userIdentity = serializeUserIdentity(user);
341
322
  const result = await this.authorization.load(userIdentity, loadMessage.references);
323
+ const facts = result.map(r => r.fact);
342
324
  return {
343
- facts: result
325
+ facts
344
326
  };
345
327
  }
346
328
 
347
329
  private async save(user: RequestUser | null, saveMessage: SaveMessage): Promise<void> {
348
330
  const userIdentity = serializeUserIdentity(user);
349
- await this.authorization.save(userIdentity, saveMessage.facts);
331
+ await this.authorization.save(userIdentity, saveMessage.facts
332
+ .map(fact => ({
333
+ fact: fact,
334
+ signatures: []
335
+ })));
350
336
  }
351
337
 
352
338
  private async read(user: RequestUser | null, input: string): Promise<any[]> {
@@ -379,7 +365,11 @@ export class HttpRouter {
379
365
  }
380
366
 
381
367
  const userIdentity = serializeUserIdentity(user);
382
- await this.authorization.save(userIdentity, factRecords);
368
+ await this.authorization.save(userIdentity, factRecords
369
+ .map(fact => ({
370
+ fact: fact,
371
+ signatures: []
372
+ })));
383
373
  }
384
374
 
385
375
  private async feeds(user: RequestUser | null, input: string): Promise<FeedsResponse> {
@@ -65,11 +65,10 @@ export class JinagaServer {
65
65
  const feedCache = new FeedCache();
66
66
  const authentication = createAuthentication(store, keystore, authorizationRules);
67
67
  const network = new NetworkNoOp();
68
- const factManager = new FactManager(authentication, fork, source, store, network);
68
+ const factManager = new FactManager(fork, source, store, network);
69
69
  const authorization = createAuthorization(authorizationRules, distributionRules, factManager, store, keystore);
70
- // Retain backward compatibility until the user provides distribution rules.
71
- const router = new HttpRouter(factManager, authorization, feedCache, distributionRules === null);
72
- const j: Jinaga = new Jinaga(factManager, syncStatusNotifier);
70
+ const router = new HttpRouter(factManager, authorization, feedCache);
71
+ const j: Jinaga = new Jinaga(authentication, factManager, syncStatusNotifier);
73
72
 
74
73
  async function close() {
75
74
  for (const pool of Object.values(pools)) {
@@ -187,8 +186,8 @@ async function withSession(store: Storage, keystore: Keystore | null, authorizat
187
186
  const fork = new PassThroughFork(store);
188
187
  const observableSource = new ObservableSource(store);
189
188
  const network = new NetworkNoOp();
190
- const factManager = new FactManager(authentication, fork, observableSource, store, network);
191
- const j = new Jinaga(factManager, syncStatusNotifier);
189
+ const factManager = new FactManager(fork, observableSource, store, network);
190
+ const j = new Jinaga(authentication, factManager, syncStatusNotifier);
192
191
  await callback(j);
193
192
  }
194
193