cojson 0.7.0 → 0.7.10

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.
package/CHANGELOG.md CHANGED
@@ -1,183 +1,195 @@
1
1
  # cojson
2
2
 
3
+ ## 0.7.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Also cache agent ID in RawControlledAccount
8
+
9
+ ## 0.7.9
10
+
11
+ ### Patch Changes
12
+
13
+ - Cache currentAgentID in RawAccount
14
+
3
15
  ## 0.7.0
4
16
 
5
17
  ### Minor Changes
6
18
 
7
- - e299c3e: New simplified API
19
+ - e299c3e: New simplified API
8
20
 
9
21
  ### Patch Changes
10
22
 
11
- - 1a35307: WIP working-ish version of LSM storage
12
- - 96c494f: Implement profile visibility based on groups & new migration signature
13
- - 19f52b7: Fixed bug with newRandomSessionID being called before crypto was ready
14
- - d8fe2b1: Expose experimental OPFS storage
15
- - 1200aae: CoJSON performance improvement
16
- - 52675c9: Fix CoList.splice / RawCoList.append
17
- - 1a35307: Optimizations for incoming sync messages
18
- - bf0f8ec: Fix noble curves dependency
19
- - c4151fc: Support stricter TS lint rules
20
- - 8636319: Factor out implementation of crypto provider and provide pure JS implementation
21
- - 952982e: Consistent proxy based API
22
- - 21771c4: Reintroduce changes from main
23
- - 69ac514: Use effect schema much less
24
- - f0f6f1b: Clean up API more & re-add jazz-nodejs
25
- - 1a44f87: Refactoring
26
- - 63374cc: Make sure delete on CoMaps deletes keys
23
+ - 1a35307: WIP working-ish version of LSM storage
24
+ - 96c494f: Implement profile visibility based on groups & new migration signature
25
+ - 19f52b7: Fixed bug with newRandomSessionID being called before crypto was ready
26
+ - d8fe2b1: Expose experimental OPFS storage
27
+ - 1200aae: CoJSON performance improvement
28
+ - 52675c9: Fix CoList.splice / RawCoList.append
29
+ - 1a35307: Optimizations for incoming sync messages
30
+ - bf0f8ec: Fix noble curves dependency
31
+ - c4151fc: Support stricter TS lint rules
32
+ - 8636319: Factor out implementation of crypto provider and provide pure JS implementation
33
+ - 952982e: Consistent proxy based API
34
+ - 21771c4: Reintroduce changes from main
35
+ - 69ac514: Use effect schema much less
36
+ - f0f6f1b: Clean up API more & re-add jazz-nodejs
37
+ - 1a44f87: Refactoring
38
+ - 63374cc: Make sure delete on CoMaps deletes keys
27
39
 
28
40
  ## 0.7.0-alpha.42
29
41
 
30
42
  ### Patch Changes
31
43
 
32
- - Fixed bug with newRandomSessionID being called before crypto was ready
44
+ - Fixed bug with newRandomSessionID being called before crypto was ready
33
45
 
34
46
  ## 0.7.0-alpha.39
35
47
 
36
48
  ### Patch Changes
37
49
 
38
- - Fix noble curves dependency
50
+ - Fix noble curves dependency
39
51
 
40
52
  ## 0.7.0-alpha.38
41
53
 
42
54
  ### Patch Changes
43
55
 
44
- - Factor out implementation of crypto provider and provide pure JS implementation
56
+ - Factor out implementation of crypto provider and provide pure JS implementation
45
57
 
46
58
  ## 0.7.0-alpha.37
47
59
 
48
60
  ### Patch Changes
49
61
 
50
- - Expose experimental OPFS storage
62
+ - Expose experimental OPFS storage
51
63
 
52
64
  ## 0.7.0-alpha.36
53
65
 
54
66
  ### Patch Changes
55
67
 
56
- - 1a35307: WIP working-ish version of LSM storage
57
- - 1a35307: Optimizations for incoming sync messages
68
+ - 1a35307: WIP working-ish version of LSM storage
69
+ - 1a35307: Optimizations for incoming sync messages
58
70
 
59
71
  ## 0.7.0-alpha.35
60
72
 
61
73
  ### Patch Changes
62
74
 
63
- - CoJSON performance improvement
75
+ - CoJSON performance improvement
64
76
 
65
77
  ## 0.7.0-alpha.29
66
78
 
67
79
  ### Patch Changes
68
80
 
69
- - Reintroduce changes from main
81
+ - Reintroduce changes from main
70
82
 
71
83
  ## 0.7.0-alpha.28
72
84
 
73
85
  ### Patch Changes
74
86
 
75
- - Implement profile visibility based on groups & new migration signature
87
+ - Implement profile visibility based on groups & new migration signature
76
88
 
77
89
  ## 0.7.0-alpha.27
78
90
 
79
91
  ### Patch Changes
80
92
 
81
- - Fix CoList.splice / RawCoList.append
93
+ - Fix CoList.splice / RawCoList.append
82
94
 
83
95
  ## 0.7.0-alpha.24
84
96
 
85
97
  ### Patch Changes
86
98
 
87
- - Make sure delete on CoMaps deletes keys
99
+ - Make sure delete on CoMaps deletes keys
88
100
 
89
101
  ## 0.7.0-alpha.11
90
102
 
91
103
  ### Patch Changes
92
104
 
93
- - Support stricter TS lint rules
105
+ - Support stricter TS lint rules
94
106
 
95
107
  ## 0.7.0-alpha.10
96
108
 
97
109
  ### Patch Changes
98
110
 
99
- - Clean up API more & re-add jazz-nodejs
111
+ - Clean up API more & re-add jazz-nodejs
100
112
 
101
113
  ## 0.7.0-alpha.7
102
114
 
103
115
  ### Patch Changes
104
116
 
105
- - Consistent proxy based API
117
+ - Consistent proxy based API
106
118
 
107
119
  ## 0.7.0-alpha.5
108
120
 
109
121
  ### Patch Changes
110
122
 
111
- - Refactoring
123
+ - Refactoring
112
124
 
113
125
  ## 0.7.0-alpha.1
114
126
 
115
127
  ### Patch Changes
116
128
 
117
- - Use effect schema much less
129
+ - Use effect schema much less
118
130
 
119
131
  ## 0.7.0-alpha.0
120
132
 
121
133
  ### Minor Changes
122
134
 
123
- - New simplified API
135
+ - New simplified API
124
136
 
125
137
  ## 0.6.6
126
138
 
127
139
  ### Patch Changes
128
140
 
129
- - Fix migration changes being lost on loaded account
141
+ - Fix migration changes being lost on loaded account
130
142
 
131
143
  ## 0.6.5
132
144
 
133
145
  ### Patch Changes
134
146
 
135
- - Fix loading of accounts
147
+ - Fix loading of accounts
136
148
 
137
149
  ## 0.6.4
138
150
 
139
151
  ### Patch Changes
140
152
 
141
- - IndexedDB & timer perf improvements
153
+ - IndexedDB & timer perf improvements
142
154
 
143
155
  ## 0.6.3
144
156
 
145
157
  ### Patch Changes
146
158
 
147
- - Implement passphrase based auth
159
+ - Implement passphrase based auth
148
160
 
149
161
  ## 0.6.2
150
162
 
151
163
  ### Patch Changes
152
164
 
153
- - Add peersToLoadFrom for node creation as well
165
+ - Add peersToLoadFrom for node creation as well
154
166
 
155
167
  ## 0.6.1
156
168
 
157
169
  ### Patch Changes
158
170
 
159
- - Provide localNode to AccountMigrations
171
+ - Provide localNode to AccountMigrations
160
172
 
161
173
  ## 0.6.0
162
174
 
163
175
  ### Minor Changes
164
176
 
165
- - Make addMember and removeMember take loaded Accounts instead of just IDs
177
+ - Make addMember and removeMember take loaded Accounts instead of just IDs
166
178
 
167
179
  ## 0.5.2
168
180
 
169
181
  ### Patch Changes
170
182
 
171
- - Allow account migrations to be async
183
+ - Allow account migrations to be async
172
184
 
173
185
  ## 0.5.1
174
186
 
175
187
  ### Patch Changes
176
188
 
177
- - Fix bug where accounts, profiles and data created in migrations isn't synced on account creation
189
+ - Fix bug where accounts, profiles and data created in migrations isn't synced on account creation
178
190
 
179
191
  ## 0.5.0
180
192
 
181
193
  ### Minor Changes
182
194
 
183
- - Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
195
+ - Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023, Garden Computing, Inc.
1
+ Copyright 2024, Garden Computing, Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -14,10 +14,14 @@ export function accountHeaderForInitialAgentSecret(agentSecret, crypto) {
14
14
  }
15
15
  export class RawAccount extends RawGroup {
16
16
  currentAgentID() {
17
+ if (this._cachedCurrentAgentID) {
18
+ return this._cachedCurrentAgentID;
19
+ }
17
20
  const agents = this.keys().filter((k) => k.startsWith("sealer_"));
18
21
  if (agents.length !== 1) {
19
22
  throw new Error("Expected exactly one agent in account, got " + agents.length);
20
23
  }
24
+ this._cachedCurrentAgentID = agents[0];
21
25
  return agents[0];
22
26
  }
23
27
  }
@@ -39,7 +43,12 @@ export class RawControlledAccount extends RawAccount {
39
43
  return this.core.node.acceptInvite(groupOrOwnedValueID, inviteSecret);
40
44
  }
41
45
  currentAgentID() {
42
- return this.crypto.getAgentID(this.agentSecret);
46
+ if (this._cachedCurrentAgentID) {
47
+ return this._cachedCurrentAgentID;
48
+ }
49
+ const agentID = this.crypto.getAgentID(this.agentSecret);
50
+ this._cachedCurrentAgentID = agentID;
51
+ return agentID;
43
52
  }
44
53
  currentSignerID() {
45
54
  return this.crypto.getAgentSignerID(this.currentAgentID());
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAIpD,MAAM,UAAU,kCAAkC,CAC9C,WAAwB,EACxB,MAAsB;IAEtB,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC7C,OAAO;QACH,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE;QAC/C,IAAI,EAAE;YACF,IAAI,EAAE,SAAS;SAClB;QACD,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;KACnB,CAAC;AACN,CAAC;AAED,MAAM,OAAO,UAEX,SAAQ,QAAc;IACpB,cAAc;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAgB,EAAE,CAClD,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAC1B,CAAC;QAEF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,IAAI,KAAK,CACX,6CAA6C,GAAG,MAAM,CAAC,MAAM,CAChE,CAAC;SACL;QAED,OAAO,MAAM,CAAC,CAAC,CAAE,CAAC;IACtB,CAAC;CACJ;AAaD,cAAc;AACd,MAAM,OAAO,oBACT,SAAQ,UAAgB;IAMxB,YAAY,IAAiB,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
  "type": "module",
7
7
  "license": "MIT",
8
- "version": "0.7.0",
8
+ "version": "0.7.10",
9
9
  "devDependencies": {
10
10
  "@types/jest": "^29.5.3",
11
11
  "@typescript-eslint/eslint-plugin": "^6.2.1",
@@ -33,7 +33,12 @@ export function accountHeaderForInitialAgentSecret(
33
33
  export class RawAccount<
34
34
  Meta extends AccountMeta = AccountMeta,
35
35
  > extends RawGroup<Meta> {
36
+ _cachedCurrentAgentID: AgentID | undefined;
37
+
36
38
  currentAgentID(): AgentID {
39
+ if (this._cachedCurrentAgentID) {
40
+ return this._cachedCurrentAgentID;
41
+ }
37
42
  const agents = this.keys().filter((k): k is AgentID =>
38
43
  k.startsWith("sealer_"),
39
44
  );
@@ -44,6 +49,8 @@ export class RawAccount<
44
49
  );
45
50
  }
46
51
 
52
+ this._cachedCurrentAgentID = agents[0];
53
+
47
54
  return agents[0]!;
48
55
  }
49
56
  }
@@ -90,7 +97,12 @@ export class RawControlledAccount<Meta extends AccountMeta = AccountMeta>
90
97
  }
91
98
 
92
99
  currentAgentID(): AgentID {
93
- return this.crypto.getAgentID(this.agentSecret);
100
+ if (this._cachedCurrentAgentID) {
101
+ return this._cachedCurrentAgentID;
102
+ }
103
+ const agentID = this.crypto.getAgentID(this.agentSecret);
104
+ this._cachedCurrentAgentID = agentID;
105
+ return agentID;
94
106
  }
95
107
 
96
108
  currentSignerID(): SignerID {