@casual-simulation/aux-common 3.2.6 → 3.2.7-alpha.6227012901

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 (212) hide show
  1. package/Errors.d.ts +29 -0
  2. package/Errors.js +2 -0
  3. package/Errors.js.map +1 -0
  4. package/{aux-format-2 → bots}/AuxStateHelpers.d.ts +2 -33
  5. package/{aux-format-2 → bots}/AuxStateHelpers.js +1 -116
  6. package/bots/AuxStateHelpers.js.map +1 -0
  7. package/bots/Bot.d.ts +1 -1
  8. package/bots/BotCalculations.d.ts +4 -1
  9. package/bots/BotCalculations.js +62 -0
  10. package/bots/BotCalculations.js.map +1 -1
  11. package/bots/BotEvents.d.ts +859 -3401
  12. package/bots/BotEvents.js +133 -1529
  13. package/bots/BotEvents.js.map +1 -1
  14. package/bots/StateUpdatedEvent.d.ts +1 -1
  15. package/bots/StateUpdatedEvent.js +1 -1
  16. package/bots/StateUpdatedEvent.js.map +1 -1
  17. package/bots/index.d.ts +1 -0
  18. package/bots/index.js +1 -0
  19. package/bots/index.js.map +1 -1
  20. package/common/Action.d.ts +17 -0
  21. package/common/Action.js +2 -0
  22. package/common/Action.js.map +1 -0
  23. package/common/ConnectionIndicator.d.ts +29 -0
  24. package/common/ConnectionIndicator.js +23 -0
  25. package/common/ConnectionIndicator.js.map +1 -0
  26. package/common/ConnectionInfo.d.ts +30 -0
  27. package/common/ConnectionInfo.js +14 -0
  28. package/common/ConnectionInfo.js.map +1 -0
  29. package/common/ConnectionToken.d.ts +37 -0
  30. package/common/ConnectionToken.js +93 -0
  31. package/common/ConnectionToken.js.map +1 -0
  32. package/common/CurrentVersion.d.ts +26 -0
  33. package/common/CurrentVersion.js +2 -0
  34. package/common/CurrentVersion.js.map +1 -0
  35. package/common/Iterators.d.ts +19 -0
  36. package/common/Iterators.js +39 -0
  37. package/common/Iterators.js.map +1 -0
  38. package/common/LoadingProgress.d.ts +26 -0
  39. package/common/LoadingProgress.js +2 -0
  40. package/common/LoadingProgress.js.map +1 -0
  41. package/common/RemoteActions.d.ts +558 -0
  42. package/common/RemoteActions.js +128 -0
  43. package/common/RemoteActions.js.map +1 -0
  44. package/common/StatusUpdate.d.ts +108 -0
  45. package/common/StatusUpdate.js +2 -0
  46. package/common/StatusUpdate.js.map +1 -0
  47. package/common/StatusUpdateUtils.d.ts +3 -0
  48. package/common/StatusUpdateUtils.js +11 -0
  49. package/common/StatusUpdateUtils.js.map +1 -0
  50. package/common/index.d.ts +11 -0
  51. package/common/index.js +11 -0
  52. package/common/index.js.map +1 -0
  53. package/index.d.ts +4 -1
  54. package/index.js +4 -1
  55. package/index.js.map +1 -1
  56. package/package.json +3 -4
  57. package/partitions/AuxPartition.d.ts +1 -11
  58. package/partitions/AuxPartition.js.map +1 -1
  59. package/partitions/AuxPartitionConfig.d.ts +39 -123
  60. package/partitions/MemoryPartition.d.ts +2 -2
  61. package/partitions/MemoryPartition.js +2 -2
  62. package/partitions/MemoryPartition.js.map +1 -1
  63. package/partitions/OtherPlayersPartition.d.ts +6 -7
  64. package/partitions/OtherPlayersPartition.js +40 -54
  65. package/partitions/OtherPlayersPartition.js.map +1 -1
  66. package/partitions/PartitionUtils.d.ts +28 -1
  67. package/partitions/PartitionUtils.js +174 -1
  68. package/partitions/PartitionUtils.js.map +1 -1
  69. package/partitions/ProxyBridgePartition.d.ts +1 -3
  70. package/partitions/ProxyBridgePartition.js +0 -14
  71. package/partitions/ProxyBridgePartition.js.map +1 -1
  72. package/partitions/RemoteYjsPartition.d.ts +7 -6
  73. package/partitions/RemoteYjsPartition.js +55 -75
  74. package/partitions/RemoteYjsPartition.js.map +1 -1
  75. package/partitions/YjsPartition.d.ts +1 -2
  76. package/partitions/YjsPartition.js +3 -6
  77. package/partitions/YjsPartition.js.map +1 -1
  78. package/partitions/index.d.ts +1 -7
  79. package/partitions/index.js +1 -7
  80. package/partitions/index.js.map +1 -1
  81. package/test/FuzzingHelpers.d.ts +1 -1
  82. package/test/FuzzingHelpers.js +1 -1
  83. package/test/FuzzingHelpers.js.map +1 -1
  84. package/test/TestHelpers.d.ts +8 -0
  85. package/test/TestHelpers.js +23 -0
  86. package/test/TestHelpers.js.map +1 -1
  87. package/utils.d.ts +10 -5
  88. package/utils.js +19 -7
  89. package/utils.js.map +1 -1
  90. package/websockets/AuthenticatedConnectionClient.d.ts +26 -0
  91. package/websockets/AuthenticatedConnectionClient.js +61 -0
  92. package/websockets/AuthenticatedConnectionClient.js.map +1 -0
  93. package/websockets/ConnectionClient.d.ts +59 -0
  94. package/websockets/ConnectionClient.js +2 -0
  95. package/websockets/ConnectionClient.js.map +1 -0
  96. package/websockets/InstRecordsClient.d.ts +118 -0
  97. package/websockets/InstRecordsClient.js +387 -0
  98. package/websockets/InstRecordsClient.js.map +1 -0
  99. package/websockets/InstRecordsClientTimeSyncConnection.d.ts +13 -0
  100. package/websockets/InstRecordsClientTimeSyncConnection.js +16 -0
  101. package/websockets/InstRecordsClientTimeSyncConnection.js.map +1 -0
  102. package/websockets/MemoryConnectionClient.d.ts +19 -0
  103. package/websockets/MemoryConnectionClient.js +41 -0
  104. package/websockets/MemoryConnectionClient.js.map +1 -0
  105. package/websockets/WebsocketEvents.d.ts +2670 -0
  106. package/websockets/WebsocketEvents.js +189 -0
  107. package/websockets/WebsocketEvents.js.map +1 -0
  108. package/websockets/index.d.ts +7 -0
  109. package/websockets/index.js +7 -0
  110. package/websockets/index.js.map +1 -0
  111. package/yjs/YjsHelpers.d.ts +1 -1
  112. package/LoadingProgress.d.ts +0 -54
  113. package/LoadingProgress.js +0 -105
  114. package/LoadingProgress.js.map +0 -1
  115. package/aux-format-2/AuxCausalTree2.d.ts +0 -98
  116. package/aux-format-2/AuxCausalTree2.js +0 -616
  117. package/aux-format-2/AuxCausalTree2.js.map +0 -1
  118. package/aux-format-2/AuxOpTypes.d.ts +0 -268
  119. package/aux-format-2/AuxOpTypes.js +0 -240
  120. package/aux-format-2/AuxOpTypes.js.map +0 -1
  121. package/aux-format-2/AuxStateHelpers.js.map +0 -1
  122. package/aux-format-2/AuxWeaveHelpers.d.ts +0 -132
  123. package/aux-format-2/AuxWeaveHelpers.js +0 -335
  124. package/aux-format-2/AuxWeaveHelpers.js.map +0 -1
  125. package/aux-format-2/AuxWeaveReducer.d.ts +0 -37
  126. package/aux-format-2/AuxWeaveReducer.js +0 -980
  127. package/aux-format-2/AuxWeaveReducer.js.map +0 -1
  128. package/aux-format-2/index.d.ts +0 -7
  129. package/aux-format-2/index.js +0 -7
  130. package/aux-format-2/index.js.map +0 -1
  131. package/partitions/AuxPartitionRealtimeEditModeProvider.d.ts +0 -9
  132. package/partitions/AuxPartitionRealtimeEditModeProvider.js +0 -21
  133. package/partitions/AuxPartitionRealtimeEditModeProvider.js.map +0 -1
  134. package/partitions/BotClient.d.ts +0 -24
  135. package/partitions/BotClient.js +0 -2
  136. package/partitions/BotClient.js.map +0 -1
  137. package/partitions/BotPartition.d.ts +0 -45
  138. package/partitions/BotPartition.js +0 -186
  139. package/partitions/BotPartition.js.map +0 -1
  140. package/partitions/CausalRepoPartition.d.ts +0 -45
  141. package/partitions/CausalRepoPartition.js +0 -157
  142. package/partitions/CausalRepoPartition.js.map +0 -1
  143. package/partitions/MemoryBotClient.d.ts +0 -11
  144. package/partitions/MemoryBotClient.js +0 -41
  145. package/partitions/MemoryBotClient.js.map +0 -1
  146. package/partitions/RemoteCausalRepoHistoryPartition.d.ts +0 -53
  147. package/partitions/RemoteCausalRepoHistoryPartition.js +0 -206
  148. package/partitions/RemoteCausalRepoHistoryPartition.js.map +0 -1
  149. package/partitions/RemoteCausalRepoPartition.d.ts +0 -72
  150. package/partitions/RemoteCausalRepoPartition.js +0 -468
  151. package/partitions/RemoteCausalRepoPartition.js.map +0 -1
  152. package/runtime/AuxCompiler.d.ts +0 -258
  153. package/runtime/AuxCompiler.js +0 -722
  154. package/runtime/AuxCompiler.js.map +0 -1
  155. package/runtime/AuxDevice.d.ts +0 -28
  156. package/runtime/AuxDevice.js +0 -2
  157. package/runtime/AuxDevice.js.map +0 -1
  158. package/runtime/AuxGlobalContext.d.ts +0 -571
  159. package/runtime/AuxGlobalContext.js +0 -606
  160. package/runtime/AuxGlobalContext.js.map +0 -1
  161. package/runtime/AuxLibrary.d.ts +0 -2702
  162. package/runtime/AuxLibrary.js +0 -11046
  163. package/runtime/AuxLibrary.js.map +0 -1
  164. package/runtime/AuxLibraryDefinitions.def +0 -13139
  165. package/runtime/AuxRealtimeEditModeProvider.d.ts +0 -35
  166. package/runtime/AuxRealtimeEditModeProvider.js +0 -34
  167. package/runtime/AuxRealtimeEditModeProvider.js.map +0 -1
  168. package/runtime/AuxResults.d.ts +0 -77
  169. package/runtime/AuxResults.js +0 -6
  170. package/runtime/AuxResults.js.map +0 -1
  171. package/runtime/AuxRuntime.d.ts +0 -253
  172. package/runtime/AuxRuntime.js +0 -2700
  173. package/runtime/AuxRuntime.js.map +0 -1
  174. package/runtime/AuxRuntimeDynamicImports.d.ts +0 -14
  175. package/runtime/AuxRuntimeDynamicImports.js +0 -24
  176. package/runtime/AuxRuntimeDynamicImports.js.map +0 -1
  177. package/runtime/AuxVersion.d.ts +0 -39
  178. package/runtime/AuxVersion.js +0 -2
  179. package/runtime/AuxVersion.js.map +0 -1
  180. package/runtime/CasualOSError.d.ts +0 -37
  181. package/runtime/CasualOSError.js +0 -25
  182. package/runtime/CasualOSError.js.map +0 -1
  183. package/runtime/CompiledBot.d.ts +0 -106
  184. package/runtime/CompiledBot.js +0 -44
  185. package/runtime/CompiledBot.js.map +0 -1
  186. package/runtime/PerformanceNowPolyfill.d.ts +0 -1
  187. package/runtime/PerformanceNowPolyfill.js +0 -8
  188. package/runtime/PerformanceNowPolyfill.js.map +0 -1
  189. package/runtime/RuntimeBot.d.ts +0 -176
  190. package/runtime/RuntimeBot.js +0 -732
  191. package/runtime/RuntimeBot.js.map +0 -1
  192. package/runtime/RuntimeStateVersion.d.ts +0 -23
  193. package/runtime/RuntimeStateVersion.js +0 -22
  194. package/runtime/RuntimeStateVersion.js.map +0 -1
  195. package/runtime/Transpiler.d.ts +0 -174
  196. package/runtime/Transpiler.js +0 -611
  197. package/runtime/Transpiler.js.map +0 -1
  198. package/runtime/Utils.d.ts +0 -74
  199. package/runtime/Utils.js +0 -488
  200. package/runtime/Utils.js.map +0 -1
  201. package/runtime/index.d.ts +0 -9
  202. package/runtime/index.js +0 -9
  203. package/runtime/index.js.map +0 -1
  204. package/runtime/test/RuntimeTestHelpers.d.ts +0 -11
  205. package/runtime/test/RuntimeTestHelpers.js +0 -26
  206. package/runtime/test/RuntimeTestHelpers.js.map +0 -1
  207. package/runtime/test/TestScriptBotFactory.d.ts +0 -16
  208. package/runtime/test/TestScriptBotFactory.js +0 -107
  209. package/runtime/test/TestScriptBotFactory.js.map +0 -1
  210. /package/{runtime/BlobPolyfill.d.ts → BlobPolyfill.d.ts} +0 -0
  211. /package/{runtime/BlobPolyfill.js → BlobPolyfill.js} +0 -0
  212. /package/{runtime/BlobPolyfill.js.map → BlobPolyfill.js.map} +0 -0
@@ -1,268 +0,0 @@
1
- import { AtomId, Atom } from '@casual-simulation/causal-trees';
2
- /**
3
- * The list of operation types.
4
- */
5
- export declare enum AuxOpType {
6
- Root = 0,
7
- Bot = 1,
8
- Tag = 2,
9
- Value = 3,
10
- Delete = 4,
11
- Insert = 5,
12
- Certificate = 6,
13
- Revocation = 7,
14
- Signature = 8,
15
- TagMask = 9
16
- }
17
- /**
18
- * Defines a union of all the possible op types.
19
- */
20
- export type AuxOp = BotOp | TagOp | ValueOp | InsertOp | DeleteOp | CertificateOp | SignatureOp | RevocationOp | TagMaskOp;
21
- /**
22
- * Defines an interface for all the AUX atom values.
23
- */
24
- export interface AuxOpBase {
25
- /**
26
- * The type of the operation.
27
- */
28
- type: AuxOpType;
29
- }
30
- /**
31
- * Defines an atom value that instructs the system to create a bot.
32
- */
33
- export interface BotOp extends AuxOpBase {
34
- type: AuxOpType.Bot;
35
- /**
36
- * Gets the ID of the bot.
37
- */
38
- id: string;
39
- }
40
- /**
41
- * Defines an atom value that instructs the system to create a tag on a bot.
42
- */
43
- export interface TagOp extends AuxOpBase {
44
- type: AuxOpType.Tag;
45
- /**
46
- * The name of the tag.
47
- */
48
- name: string;
49
- }
50
- /**
51
- * Defines an atom value that serves as the root for changes to the value of a tag.
52
- */
53
- export interface ValueOp extends AuxOpBase {
54
- type: AuxOpType.Value;
55
- /**
56
- * The initial value.
57
- */
58
- value: any;
59
- }
60
- /**
61
- * Defines an atom value that instructs the system to insert a set of text into a tag.
62
- * When inserting into a ValueOp this acts as inserting text into the value part of a tag.
63
- * When inserting into a TagOp this acts as inserting text into the name part of a tag.
64
- */
65
- export interface InsertOp extends AuxOpBase {
66
- type: AuxOpType.Insert;
67
- /**
68
- * The index that the text should be inserted into.
69
- * Note that this index refers to the previous insertion operation and
70
- * not the full text string.
71
- */
72
- index: number;
73
- /**
74
- * The text to insert.
75
- */
76
- text: string;
77
- }
78
- /**
79
- * Defines an atom value that instructs the system to delete an item.
80
- * If applied onto a bot, the bot will be deleted.
81
- * If applied to an insert operation, the specified substring will be deleted from that insertion's text.
82
- */
83
- export interface DeleteOp extends AuxOpBase {
84
- type: AuxOpType.Delete;
85
- /**
86
- * The start index of the substring to delete.
87
- * If not specified the entire parent element will be tombstoned.
88
- */
89
- start?: number;
90
- /**
91
- * The end index of the substring to delete.
92
- */
93
- end?: number;
94
- }
95
- /**
96
- * Defines an atom value that instructs the system to create a certificate. (See https://en.wikipedia.org/wiki/Public_key_certificate)
97
- * Certificates create a chain of trust (https://en.wikipedia.org/wiki/Chain_of_trust) that can be used to validate that specific tag values have been created by a particular certificate.
98
- */
99
- export interface CertificateOp extends AuxOpBase {
100
- type: AuxOpType.Certificate;
101
- /**
102
- * The keypair that is stored in the certificate.
103
- * Stores both the public and private keys in the format specified in
104
- * the crypto package.
105
- * The public key is unencrypted and available for anyone to use
106
- * while the private key is encrypted with a password.
107
- */
108
- keypair: string;
109
- /**
110
- * The signature that is applied to this certificate.
111
- * Must be from the atom's cause.
112
- */
113
- signature: string;
114
- }
115
- /**
116
- * Defines an atom value that represents a signature applied to a value.
117
- */
118
- export interface SignatureOp extends AuxOpBase {
119
- type: AuxOpType.Signature;
120
- /**
121
- * The ID of the atom that created this signature was created for.
122
- */
123
- valueId: AtomId;
124
- /**
125
- * The hash of the atom that this signature was created for.
126
- */
127
- valueHash: string;
128
- /**
129
- * The signature data that was created by the certificate.
130
- */
131
- signature: string;
132
- }
133
- /**
134
- * Defines an atom value that represents the revocation of a certificate.
135
- */
136
- export interface RevocationOp extends AuxOpBase {
137
- type: AuxOpType.Revocation;
138
- /**
139
- * The ID of the certificate that created this revocation.
140
- */
141
- certId: AtomId;
142
- /**
143
- * The hash of the certificate that created this revocation.
144
- */
145
- certHash: string;
146
- /**
147
- * The signature data that was created by the certificate.
148
- */
149
- signature: string;
150
- }
151
- /**
152
- * Defines an atom value that instructs the system to create a tag mask.
153
- */
154
- export interface TagMaskOp extends AuxOpBase {
155
- type: AuxOpType.TagMask;
156
- /**
157
- * The ID of the bot that this tag mask applies to.
158
- */
159
- botId: string;
160
- /**
161
- * The name of the tag.
162
- */
163
- name: string;
164
- }
165
- /**
166
- * Creates a bot atom op.
167
- */
168
- export declare function bot(id: string): BotOp;
169
- /**
170
- * Creates a tag atom op.
171
- */
172
- export declare function tag(name: string): TagOp;
173
- /**
174
- * Creates a value op.
175
- * @param value The initial value for the tag.
176
- */
177
- export declare function value(value: any): ValueOp;
178
- /**
179
- * Creates an insert op.
180
- * @param index The index to insert the text at.
181
- * @param text The text to insert.
182
- */
183
- export declare function insertOp(index: number, text: string): InsertOp;
184
- /**
185
- * Creates a delete op.
186
- * @param index The index to insert the text at.
187
- */
188
- export declare function deleteOp(start?: number, end?: number): DeleteOp;
189
- /**
190
- * Creates a certificate op.
191
- * @param keypair The keypair for the certificate.
192
- * @param signature The signature for the certificate.
193
- */
194
- export declare function cert(keypair: string, signature?: string): CertificateOp;
195
- /**
196
- * Creates a signature op.
197
- * @param valueId The ID of the value that signature was created for.
198
- * @param valueHash The hash of the value that the signature was created for.
199
- * @param signature The signature.
200
- */
201
- export declare function sig(valueId: AtomId, valueHash: string, signature: string): SignatureOp;
202
- /**
203
- * Creates a revocation op.
204
- * @param certId The ID of the cert that created the signature.
205
- * @param certHash The hash of the certificate.
206
- * @param signature The signature.
207
- */
208
- export declare function revocation(certId: AtomId, certHash: string, signature: string): RevocationOp;
209
- /**
210
- * Creates a tag mask op.
211
- * @param botId The ID of the bot that the tag mask is for.
212
- * @param name The name of the tag.
213
- */
214
- export declare function tagMask(botId: string, name: string): TagMaskOp;
215
- export declare function op<T extends AuxOp>(type: T['type'], extra: Partial<T>): T;
216
- /**
217
- * Creates a certificate that is self signed.
218
- * @param password The password used to encrypt the keypair.
219
- */
220
- export declare function selfSignedCert(password: string): CertificateOp;
221
- /**
222
- * Calculates a signature for the given keypair that can be used for a certificate.
223
- * Returns a signature that can validate that a certificate was signed by another cert.
224
- * @param signingCert The certificate that is signing the keypair. If null then the certKeypair will be signed with itself.
225
- * @param signingPassword The password that is needed to decrypt the keypair in the signing certificate.
226
- * @param certKeypair The keypair that should be signed.
227
- */
228
- export declare function signedCert(signingCert: Atom<CertificateOp> | null, signingPassword: string, certKeypair: string): CertificateOp;
229
- /**
230
- * Validates that the given signed cert was signed with the given signing cert.
231
- * @param signingCert The cert that created the signature.
232
- * @param signedCert The cert that was signed.
233
- */
234
- export declare function validateCertSignature(signingCert: Atom<CertificateOp> | null, signedCert: Atom<CertificateOp>): boolean;
235
- /**
236
- * Creates a signature for the given value atom.
237
- * @param signingCert The certificate that is signing the value.
238
- * @param signingPassword The password used to decrypt the private key.
239
- * @param value The value to sign.
240
- */
241
- export declare function signedValue(signingCert: Atom<CertificateOp>, signingPassword: string, value: Atom<ValueOp>): SignatureOp;
242
- /**
243
- * Validates that the given signature was signed with the given certificate.
244
- * @param signingCert
245
- * @param signature
246
- */
247
- export declare function validateSignedValue(signingCert: Atom<CertificateOp>, signature: Atom<SignatureOp>, value: Atom<ValueOp>): boolean;
248
- /**
249
- * Creates a revocation for the given certificate or signature atom.
250
- * @param signingCert The certificate that is signing the value.
251
- * @param signingPassword The password used to decrypt the private key.
252
- * @param atom The value to revoke.
253
- */
254
- export declare function signedRevocation(signingCert: Atom<CertificateOp>, signingPassword: string, atom: Atom<CertificateOp> | Atom<SignatureOp>): RevocationOp;
255
- /**
256
- * Validates that the given revocation was signed with the given certificate.
257
- * @param signingCert
258
- * @param revocation
259
- */
260
- export declare function validateRevocation(signingCert: Atom<CertificateOp>, revocation: Atom<RevocationOp>, atom: Atom<CertificateOp> | Atom<SignatureOp>): boolean;
261
- /**
262
- * Gets the hash for the given tag and value.
263
- * @param botId The ID of the bot.
264
- * @param tag The tag.
265
- * @param value The value.
266
- */
267
- export declare function tagValueHash(botId: string, tag: string, value: any): string;
268
- //# sourceMappingURL=AuxOpTypes.d.ts.map
@@ -1,240 +0,0 @@
1
- import { assign } from 'lodash';
2
- import { sign, verify, keypair, getHash } from '@casual-simulation/crypto';
3
- import stringify from '@casual-simulation/fast-json-stable-stringify';
4
- /**
5
- * The list of operation types.
6
- */
7
- export var AuxOpType;
8
- (function (AuxOpType) {
9
- AuxOpType[AuxOpType["Root"] = 0] = "Root";
10
- AuxOpType[AuxOpType["Bot"] = 1] = "Bot";
11
- AuxOpType[AuxOpType["Tag"] = 2] = "Tag";
12
- AuxOpType[AuxOpType["Value"] = 3] = "Value";
13
- AuxOpType[AuxOpType["Delete"] = 4] = "Delete";
14
- AuxOpType[AuxOpType["Insert"] = 5] = "Insert";
15
- AuxOpType[AuxOpType["Certificate"] = 6] = "Certificate";
16
- AuxOpType[AuxOpType["Revocation"] = 7] = "Revocation";
17
- AuxOpType[AuxOpType["Signature"] = 8] = "Signature";
18
- AuxOpType[AuxOpType["TagMask"] = 9] = "TagMask";
19
- })(AuxOpType || (AuxOpType = {}));
20
- /**
21
- * Creates a bot atom op.
22
- */
23
- export function bot(id) {
24
- return op(AuxOpType.Bot, {
25
- id,
26
- });
27
- }
28
- /**
29
- * Creates a tag atom op.
30
- */
31
- export function tag(name) {
32
- return op(AuxOpType.Tag, {
33
- name,
34
- });
35
- }
36
- /**
37
- * Creates a value op.
38
- * @param value The initial value for the tag.
39
- */
40
- export function value(value) {
41
- return op(AuxOpType.Value, {
42
- value,
43
- });
44
- }
45
- /**
46
- * Creates an insert op.
47
- * @param index The index to insert the text at.
48
- * @param text The text to insert.
49
- */
50
- export function insertOp(index, text) {
51
- return op(AuxOpType.Insert, {
52
- index,
53
- text,
54
- });
55
- }
56
- /**
57
- * Creates a delete op.
58
- * @param index The index to insert the text at.
59
- */
60
- export function deleteOp(start, end) {
61
- return op(AuxOpType.Delete, {
62
- start,
63
- end,
64
- });
65
- }
66
- /**
67
- * Creates a certificate op.
68
- * @param keypair The keypair for the certificate.
69
- * @param signature The signature for the certificate.
70
- */
71
- export function cert(keypair, signature) {
72
- return op(AuxOpType.Certificate, {
73
- keypair,
74
- signature: signature || null,
75
- });
76
- }
77
- /**
78
- * Creates a signature op.
79
- * @param valueId The ID of the value that signature was created for.
80
- * @param valueHash The hash of the value that the signature was created for.
81
- * @param signature The signature.
82
- */
83
- export function sig(valueId, valueHash, signature) {
84
- return op(AuxOpType.Signature, {
85
- valueId,
86
- valueHash,
87
- signature,
88
- });
89
- }
90
- /**
91
- * Creates a revocation op.
92
- * @param certId The ID of the cert that created the signature.
93
- * @param certHash The hash of the certificate.
94
- * @param signature The signature.
95
- */
96
- export function revocation(certId, certHash, signature) {
97
- return op(AuxOpType.Revocation, {
98
- certId,
99
- certHash,
100
- signature,
101
- });
102
- }
103
- /**
104
- * Creates a tag mask op.
105
- * @param botId The ID of the bot that the tag mask is for.
106
- * @param name The name of the tag.
107
- */
108
- export function tagMask(botId, name) {
109
- return op(AuxOpType.TagMask, {
110
- botId,
111
- name,
112
- });
113
- }
114
- export function op(type, extra) {
115
- return assign({
116
- type: type,
117
- }, extra);
118
- }
119
- /**
120
- * Creates a certificate that is self signed.
121
- * @param password The password used to encrypt the keypair.
122
- */
123
- export function selfSignedCert(password) {
124
- const keys = keypair(password);
125
- return signedCert(null, password, keys);
126
- }
127
- /**
128
- * Calculates a signature for the given keypair that can be used for a certificate.
129
- * Returns a signature that can validate that a certificate was signed by another cert.
130
- * @param signingCert The certificate that is signing the keypair. If null then the certKeypair will be signed with itself.
131
- * @param signingPassword The password that is needed to decrypt the keypair in the signing certificate.
132
- * @param certKeypair The keypair that should be signed.
133
- */
134
- export function signedCert(signingCert, signingPassword, certKeypair) {
135
- const bytes = certSigningBytes(signingCert, certKeypair);
136
- const sig = sign(signingCert ? signingCert.value.keypair : certKeypair, signingPassword, bytes);
137
- if (!sig) {
138
- throw new Error('Unable to sign the certificate.');
139
- }
140
- return cert(certKeypair, sig);
141
- }
142
- /**
143
- * Validates that the given signed cert was signed with the given signing cert.
144
- * @param signingCert The cert that created the signature.
145
- * @param signedCert The cert that was signed.
146
- */
147
- export function validateCertSignature(signingCert, signedCert) {
148
- const bytes = certSigningBytes(signingCert, signedCert.value.keypair);
149
- try {
150
- return verify(signingCert ? signingCert.value.keypair : signedCert.value.keypair, signedCert.value.signature, bytes);
151
- }
152
- catch (err) {
153
- return false;
154
- }
155
- }
156
- /**
157
- * Creates a signature for the given value atom.
158
- * @param signingCert The certificate that is signing the value.
159
- * @param signingPassword The password used to decrypt the private key.
160
- * @param value The value to sign.
161
- */
162
- export function signedValue(signingCert, signingPassword, value) {
163
- const bytes = valueSigningBytes(signingCert, value);
164
- const signature = sign(signingCert.value.keypair, signingPassword, bytes);
165
- if (!signature) {
166
- throw new Error('Unable to sign the value.');
167
- }
168
- return sig(value.id, value.hash, signature);
169
- }
170
- /**
171
- * Validates that the given signature was signed with the given certificate.
172
- * @param signingCert
173
- * @param signature
174
- */
175
- export function validateSignedValue(signingCert, signature, value) {
176
- try {
177
- const bytes = valueSigningBytes(signingCert, value);
178
- return verify(signingCert.value.keypair, signature.value.signature, bytes);
179
- }
180
- catch (err) {
181
- return false;
182
- }
183
- }
184
- /**
185
- * Creates a revocation for the given certificate or signature atom.
186
- * @param signingCert The certificate that is signing the value.
187
- * @param signingPassword The password used to decrypt the private key.
188
- * @param atom The value to revoke.
189
- */
190
- export function signedRevocation(signingCert, signingPassword, atom) {
191
- const bytes = revocationSigningBytes(signingCert, atom);
192
- const signature = sign(signingCert.value.keypair, signingPassword, bytes);
193
- if (!signature) {
194
- throw new Error('Unable to sign the value.');
195
- }
196
- return revocation(signingCert.id, signingCert.hash, signature);
197
- }
198
- /**
199
- * Validates that the given revocation was signed with the given certificate.
200
- * @param signingCert
201
- * @param revocation
202
- */
203
- export function validateRevocation(signingCert, revocation, atom) {
204
- try {
205
- const bytes = revocationSigningBytes(signingCert, atom);
206
- return verify(signingCert.value.keypair, revocation.value.signature, bytes);
207
- }
208
- catch (err) {
209
- return false;
210
- }
211
- }
212
- function certSigningBytes(signingCert, certKeypair) {
213
- if (!signingCert) {
214
- return signingBytes([certKeypair]);
215
- }
216
- else {
217
- return signingBytes([signingCert.hash, certKeypair]);
218
- }
219
- }
220
- function valueSigningBytes(signingCert, value) {
221
- return signingBytes([signingCert.hash, value.hash]);
222
- }
223
- function revocationSigningBytes(signingCert, value) {
224
- return signingBytes([signingCert.hash, value.hash]);
225
- }
226
- function signingBytes(data) {
227
- const json = stringify(data);
228
- const encoder = new TextEncoder();
229
- return encoder.encode(json);
230
- }
231
- /**
232
- * Gets the hash for the given tag and value.
233
- * @param botId The ID of the bot.
234
- * @param tag The tag.
235
- * @param value The value.
236
- */
237
- export function tagValueHash(botId, tag, value) {
238
- return getHash([botId, tag, value]);
239
- }
240
- //# sourceMappingURL=AuxOpTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuxOpTypes.js","sourceRoot":"","sources":["AuxOpTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2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,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAC7B,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;gBACzC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;aAC3B;iBAAM;gBACH,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;aAC9C;SACJ;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -1,132 +0,0 @@
1
- import { AuxOp, TagOp, ValueOp, BotOp, TagMaskOp, InsertOp } from './AuxOpTypes';
2
- import { Weave, WeaveNode, VersionVector } from '@casual-simulation/causal-trees/core2';
3
- /**
4
- * Finds the first weave node that defines a bot with the given ID.
5
- * @param weave The weave to search through.
6
- * @param id The bot ID.
7
- */
8
- export declare function findBotNode(weave: Weave<AuxOp>, id: string): WeaveNode<BotOp>;
9
- /**
10
- * Finds all of the weave nodes that define a bot with the given ID.
11
- * @param weave The weave to search through.
12
- * @param id The bot ID.
13
- */
14
- export declare function findBotNodes(weave: Weave<AuxOp>, id: string): IterableIterator<WeaveNode<BotOp>>;
15
- /**
16
- * Finds the weave node that represents the given tag on the given bot node.
17
- * @param bot The bot node that should be searched.
18
- * @param tag The tag to find.
19
- */
20
- export declare function findTagNode(bot: WeaveNode<AuxOp>, tag: string): WeaveNode<TagOp>;
21
- /**
22
- * Finds the tag mask node for the given bot ID and tag.
23
- * @param weave The weave.
24
- * @param botId The ID of the bot.
25
- * @param tag The tag.
26
- */
27
- export declare function findTagMaskNodes(weave: Weave<AuxOp>, botId: string, tag: string): IterableIterator<WeaveNode<TagMaskOp>>;
28
- /**
29
- * Finds the first value weave node for the given tag node.
30
- * @param tag The tag node that should be searched.
31
- */
32
- export declare function findValueNode(tag: WeaveNode<AuxOp>): WeaveNode<ValueOp>;
33
- /**
34
- * Finds the first value weave node for the given tag node and value.
35
- * @param tag The tag node that should be searched.
36
- * @param value The value that should be matched.
37
- */
38
- export declare function findValueNodeByValue(tag: WeaveNode<AuxOp>, value: any): WeaveNode<ValueOp>;
39
- /**
40
- * Finds the node and index at which the given edit should happen at.
41
- * Useful for applying edits to a causal tree.
42
- * @param value The value node.
43
- * @param version The last timestamps that were available when the edit was made.
44
- * @param index The index at which the edit should happen.
45
- */
46
- export declare function findEditPosition(value: WeaveNode<AuxOp>, version: VersionVector, index: number): EditPosition;
47
- /**
48
- * Finds the nodes and indexes at which the given edit should happen at.
49
- * Useful for applying edits to a causal tree.
50
- * @param value The value node.
51
- * @param version The last timestamps that were available when the edit was made.
52
- * @param index The index at which the edit should happen.
53
- * @param deleteCount The number of characters that get deleted starting at the index.
54
- */
55
- export declare function findEditPosition(value: WeaveNode<AuxOp>, version: VersionVector, index: number, deleteCount: number): EditPosition[];
56
- /**
57
- * Finds the list of edit positions that an edit at the given index and the given delete count should cover.
58
- * @param index The index.
59
- * @param deleteCount The delete count.
60
- * @param edits The text segments.
61
- * @param afinity Whether edits that fall directly between two segments should be associated with the left edit or the right edit.
62
- */
63
- export declare function findMultipleEditPositions(index: number, deleteCount: number, edits: TextSegment[], afinity: 'left' | 'right'): IterableIterator<EditPosition>;
64
- /**
65
- * Finds the single position that an edit at the given index should be added at.
66
- * @param index The index.
67
- * @param edits The edits.
68
- */
69
- export declare function findSingleEditPosition(index: number, edits: TextSegment[]): EditPosition;
70
- /**
71
- * Calculates the list of ordered edits for the given value node.
72
- * This iterates each insert op and delete op and returns a list of text segments that have been derived from the value.
73
- * @param nodes The list of nodes that the edits should be calculated from.
74
- * @param preserveEmptyEdits Whether to preserve empty edits in the output list.
75
- */
76
- export declare function calculateOrderedEdits(nodes: WeaveNode<AuxOp>[], preserveEmptyEdits?: boolean): TextSegment[];
77
- /**
78
- * Calculates the final text value for the given value node.
79
- * @param weave The weave.
80
- * @param value The value node.
81
- */
82
- export declare function calculateFinalEditValue(value: WeaveNode<ValueOp>): string;
83
- /**
84
- * Defines an interface that represents a segment of text that has been derived from a node.
85
- */
86
- export interface TextSegment {
87
- /**
88
- * The text of the edit.
89
- */
90
- text: string;
91
- /**
92
- * The index offset that this segment starts at.
93
- * Useful when the node was split into two segments.
94
- */
95
- offset: number;
96
- /**
97
- * The text that includes null characters to indicate characters that were deleted.
98
- */
99
- marked: string;
100
- /**
101
- * The node that the edit text was produced from.
102
- */
103
- node: WeaveNode<ValueOp | InsertOp>;
104
- }
105
- /**
106
- * Defines an interface that contains extra information about a text segment.
107
- */
108
- export interface TextSegmentInfo {
109
- /**
110
- * The text of the edit.
111
- */
112
- text: string;
113
- /**
114
- * The total length of text sequences.
115
- */
116
- totalLength: number;
117
- /**
118
- * The index offset that this segment starts at.
119
- * Useful when the node was split into two segments.
120
- */
121
- offset: number;
122
- /**
123
- * The node that the edit text was produced from.
124
- */
125
- node: WeaveNode<ValueOp | InsertOp>;
126
- }
127
- export interface EditPosition {
128
- node: WeaveNode<AuxOp>;
129
- index: number;
130
- count?: number;
131
- }
132
- //# sourceMappingURL=AuxWeaveHelpers.d.ts.map