@open-e2ee/signal-protocol-sdk 12.0.1 → 13.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 (165) hide show
  1. package/ADAPTERS.md +3 -0
  2. package/ARCHITECTURE.md +4 -4
  3. package/CHANGELOG.md +141 -0
  4. package/README.md +1 -1
  5. package/SECURITY.md +2 -2
  6. package/client/README.md +40 -0
  7. package/device/README.md +40 -4
  8. package/dist/client/client.d.ts +8 -0
  9. package/dist/client/client.d.ts.map +1 -1
  10. package/dist/client/client.js +19 -1
  11. package/dist/client/client.js.map +1 -1
  12. package/dist/client/config.d.ts +6 -2
  13. package/dist/client/config.d.ts.map +1 -1
  14. package/dist/client/config.js.map +1 -1
  15. package/dist/client/event-hooks.d.ts +28 -0
  16. package/dist/client/event-hooks.d.ts.map +1 -1
  17. package/dist/client/event-hooks.js +1 -0
  18. package/dist/client/event-hooks.js.map +1 -1
  19. package/dist/client/group-init-status.d.ts +21 -0
  20. package/dist/client/group-init-status.d.ts.map +1 -0
  21. package/dist/client/group-init-status.js +156 -0
  22. package/dist/client/group-init-status.js.map +1 -0
  23. package/dist/client/hosted-device-link-transport.d.ts +11 -0
  24. package/dist/client/hosted-device-link-transport.d.ts.map +1 -0
  25. package/dist/client/hosted-device-link-transport.js +25 -0
  26. package/dist/client/hosted-device-link-transport.js.map +1 -0
  27. package/dist/client/hosted-device-link.d.ts +97 -0
  28. package/dist/client/hosted-device-link.d.ts.map +1 -0
  29. package/dist/client/hosted-device-link.js +149 -0
  30. package/dist/client/hosted-device-link.js.map +1 -0
  31. package/dist/client/hosted-http-error.d.ts +30 -0
  32. package/dist/client/hosted-http-error.d.ts.map +1 -0
  33. package/dist/client/hosted-http-error.js +34 -0
  34. package/dist/client/hosted-http-error.js.map +1 -0
  35. package/dist/client/hosted-presence.js +1 -1
  36. package/dist/client/hosted-presence.js.map +1 -1
  37. package/dist/client/hosted-profile-keys.js +1 -1
  38. package/dist/client/hosted-profile-keys.js.map +1 -1
  39. package/dist/client/hosted-sandbox-identity.d.ts +3 -3
  40. package/dist/client/hosted-sandbox-identity.js +3 -3
  41. package/dist/client/hosted-transport.d.ts +12 -13
  42. package/dist/client/hosted-transport.d.ts.map +1 -1
  43. package/dist/client/hosted-transport.js +111 -17
  44. package/dist/client/hosted-transport.js.map +1 -1
  45. package/dist/client/hosted.d.ts +57 -8
  46. package/dist/client/hosted.d.ts.map +1 -1
  47. package/dist/client/hosted.js +170 -19
  48. package/dist/client/hosted.js.map +1 -1
  49. package/dist/client/index.d.ts +2 -1
  50. package/dist/client/index.d.ts.map +1 -1
  51. package/dist/client/index.js +1 -1
  52. package/dist/client/index.js.map +1 -1
  53. package/dist/client/receive-queue.d.ts +4 -2
  54. package/dist/client/receive-queue.d.ts.map +1 -1
  55. package/dist/client/receive-queue.js +26 -22
  56. package/dist/client/receive-queue.js.map +1 -1
  57. package/dist/index.d.ts +2 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/local/store/conformance/cases/ciphertext.d.ts +7 -0
  62. package/dist/local/store/conformance/cases/ciphertext.d.ts.map +1 -0
  63. package/dist/local/store/conformance/cases/ciphertext.js +55 -0
  64. package/dist/local/store/conformance/cases/ciphertext.js.map +1 -0
  65. package/dist/local/store/conformance/cases/durability.d.ts +6 -0
  66. package/dist/local/store/conformance/cases/durability.d.ts.map +1 -0
  67. package/dist/local/store/conformance/cases/durability.js +34 -0
  68. package/dist/local/store/conformance/cases/durability.js.map +1 -0
  69. package/dist/local/store/conformance/cases/identity.d.ts +7 -0
  70. package/dist/local/store/conformance/cases/identity.d.ts.map +1 -0
  71. package/dist/local/store/conformance/cases/identity.js +84 -0
  72. package/dist/local/store/conformance/cases/identity.js.map +1 -0
  73. package/dist/local/store/conformance/cases/metadata.d.ts +7 -0
  74. package/dist/local/store/conformance/cases/metadata.d.ts.map +1 -0
  75. package/dist/local/store/conformance/cases/metadata.js +48 -0
  76. package/dist/local/store/conformance/cases/metadata.js.map +1 -0
  77. package/dist/local/store/conformance/cases/protection.d.ts +7 -0
  78. package/dist/local/store/conformance/cases/protection.d.ts.map +1 -0
  79. package/dist/local/store/conformance/cases/protection.js +14 -0
  80. package/dist/local/store/conformance/cases/protection.js.map +1 -0
  81. package/dist/local/store/conformance/cases/receive-work.d.ts +8 -0
  82. package/dist/local/store/conformance/cases/receive-work.d.ts.map +1 -0
  83. package/dist/local/store/conformance/cases/receive-work.js +152 -0
  84. package/dist/local/store/conformance/cases/receive-work.js.map +1 -0
  85. package/dist/local/store/conformance/cases/sender-key.d.ts +7 -0
  86. package/dist/local/store/conformance/cases/sender-key.d.ts.map +1 -0
  87. package/dist/local/store/conformance/cases/sender-key.js +59 -0
  88. package/dist/local/store/conformance/cases/sender-key.js.map +1 -0
  89. package/dist/local/store/conformance/cases/session-trust.d.ts +7 -0
  90. package/dist/local/store/conformance/cases/session-trust.d.ts.map +1 -0
  91. package/dist/local/store/conformance/cases/session-trust.js +64 -0
  92. package/dist/local/store/conformance/cases/session-trust.js.map +1 -0
  93. package/dist/local/store/conformance/checks.d.ts +15 -0
  94. package/dist/local/store/conformance/checks.d.ts.map +1 -0
  95. package/dist/local/store/conformance/checks.js +67 -0
  96. package/dist/local/store/conformance/checks.js.map +1 -0
  97. package/dist/local/store/conformance/index.d.ts +30 -0
  98. package/dist/local/store/conformance/index.d.ts.map +1 -0
  99. package/dist/local/store/conformance/index.js +29 -0
  100. package/dist/local/store/conformance/index.js.map +1 -0
  101. package/dist/local/store/conformance/records.d.ts +36 -0
  102. package/dist/local/store/conformance/records.d.ts.map +1 -0
  103. package/dist/local/store/conformance/records.js +109 -0
  104. package/dist/local/store/conformance/records.js.map +1 -0
  105. package/dist/local/store/conformance/run.d.ts +24 -0
  106. package/dist/local/store/conformance/run.d.ts.map +1 -0
  107. package/dist/local/store/conformance/run.js +156 -0
  108. package/dist/local/store/conformance/run.js.map +1 -0
  109. package/dist/local/store/conformance/types.d.ts +55 -0
  110. package/dist/local/store/conformance/types.d.ts.map +1 -0
  111. package/dist/local/store/conformance/types.js +6 -0
  112. package/dist/local/store/conformance/types.js.map +1 -0
  113. package/dist/local/store/expo/adapter.d.ts +2 -1
  114. package/dist/local/store/expo/adapter.d.ts.map +1 -1
  115. package/dist/local/store/expo/adapter.js.map +1 -1
  116. package/dist/local/store/node/adapter.d.ts +2 -2
  117. package/dist/local/store/react-native/adapter.d.ts +2 -1
  118. package/dist/local/store/react-native/adapter.d.ts.map +1 -1
  119. package/dist/local/store/react-native/adapter.js.map +1 -1
  120. package/dist/local/store/sqlite/convert-plaintext.d.ts +62 -0
  121. package/dist/local/store/sqlite/convert-plaintext.d.ts.map +1 -0
  122. package/dist/local/store/sqlite/convert-plaintext.js +236 -0
  123. package/dist/local/store/sqlite/convert-plaintext.js.map +1 -0
  124. package/dist/local/store/sqlite/encryption.d.ts +21 -0
  125. package/dist/local/store/sqlite/encryption.d.ts.map +1 -1
  126. package/dist/local/store/sqlite/encryption.js.map +1 -1
  127. package/dist/local/store/sqlite/errors.d.ts.map +1 -1
  128. package/dist/local/store/sqlite/errors.js +2 -1
  129. package/dist/local/store/sqlite/errors.js.map +1 -1
  130. package/dist/local/store/sqlite/key-storage/identity-keys.d.ts +3 -1
  131. package/dist/local/store/sqlite/key-storage/identity-keys.d.ts.map +1 -1
  132. package/dist/local/store/sqlite/key-storage/identity-keys.js +3 -1
  133. package/dist/local/store/sqlite/key-storage/identity-keys.js.map +1 -1
  134. package/dist/local/store/sqlite/open-store.d.ts +36 -4
  135. package/dist/local/store/sqlite/open-store.d.ts.map +1 -1
  136. package/dist/local/store/sqlite/open-store.js +326 -21
  137. package/dist/local/store/sqlite/open-store.js.map +1 -1
  138. package/dist/local/store/sqlite/web/worker.d.ts +5 -0
  139. package/dist/local/store/sqlite/web/worker.d.ts.map +1 -1
  140. package/dist/local/store/sqlite/web/worker.js +99 -20
  141. package/dist/local/store/sqlite/web/worker.js.map +1 -1
  142. package/dist/local/store/web-sqlite/adapter.d.ts +3 -2
  143. package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -1
  144. package/dist/local/store/web-sqlite/adapter.js +12 -2
  145. package/dist/local/store/web-sqlite/adapter.js.map +1 -1
  146. package/dist/remote/relay/types.d.ts +4 -2
  147. package/dist/remote/relay/types.d.ts.map +1 -1
  148. package/dist/types/api.d.ts +20 -4
  149. package/dist/types/api.d.ts.map +1 -1
  150. package/docs/ASSURANCE.md +25 -7
  151. package/docs/DEVIATIONS.md +35 -3
  152. package/docs/ERROR_HANDLING.md +8 -6
  153. package/docs/GETTING_STARTED.md +25 -8
  154. package/docs/INTERFACES.md +3 -1
  155. package/docs/PACKAGE_SURFACE.md +1 -0
  156. package/docs/RECIPES.md +44 -0
  157. package/docs/SECURITY.md +23 -5
  158. package/keys/README.md +3 -1
  159. package/local/store/README.md +92 -12
  160. package/local/store/expo/README.md +63 -6
  161. package/local/store/key-value/README.md +3 -2
  162. package/local/store/node/README.md +68 -6
  163. package/local/store/react-native/README.md +62 -4
  164. package/local/store/web-sqlite/README.md +101 -4
  165. package/package.json +5 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receive-work.d.ts","sourceRoot":"","sources":["../../../../../local/store/conformance/cases/receive-work.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA4D1D,eAAO,MAAM,gBAAgB,EAAE,SAAS,yBAAyB,EA8MhE,CAAC"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * The receive record cases: the insert and the compare-and-set of one
3
+ * record, the listing in arrival order, and the atomic completion with its
4
+ * usage counts.
5
+ */
6
+ import { assertAbsent, assertEqual, expectRejection } from '../checks.js';
7
+ import { receiveWork } from '../records.js';
8
+ /** The number of records of the listing case. It is one above the default page size. */
9
+ const LISTED_RECORDS = 101;
10
+ function compareWorkIds(a, b) {
11
+ return a < b ? -1 : a > b ? 1 : 0;
12
+ }
13
+ function inArrivalOrder(a, b) {
14
+ return a.arrivalSeq - b.arrivalSeq || compareWorkIds(a.workId, b.workId);
15
+ }
16
+ function isAfter(record, cursor) {
17
+ return inArrivalOrder(record, cursor) > 0;
18
+ }
19
+ function workIds(records) {
20
+ return records.map(function workIdOf(record) {
21
+ return record.workId;
22
+ });
23
+ }
24
+ function usageOf(records) {
25
+ let bytes = 0;
26
+ for (const record of records)
27
+ bytes += record.sizeBytes;
28
+ return { items: records.length, bytes: bytes };
29
+ }
30
+ /**
31
+ * The records of the listing case. The work IDs have no zero padding, so
32
+ * their text order is not their number order. Groups of three records share
33
+ * one arrival sequence, and the insert order is not the arrival order.
34
+ */
35
+ function listedRecords() {
36
+ const stages = ['decrypted', 'receipt-due', 'awaiting-completion'];
37
+ const records = [];
38
+ for (let index = 0; index < LISTED_RECORDS; index += 1) {
39
+ const stage = stages[index % stages.length];
40
+ records.push(receiveWork('conformance-list-' + ((index * 37) % LISTED_RECORDS), {
41
+ arrivalSeq: Math.floor(((index * 53) % LISTED_RECORDS) / 3) + 1,
42
+ stage: stage,
43
+ dueAt: 1_000 + (index % 5) * 100,
44
+ plaintext: stage === 'receipt-due' ? undefined : 'listed content ' + index,
45
+ }));
46
+ }
47
+ return records;
48
+ }
49
+ async function expectListing(list, query, expected, label) {
50
+ assertEqual(workIds(await list(query)), workIds(expected), label);
51
+ }
52
+ export const receiveWorkCases = [
53
+ {
54
+ name: 'receive record insert and compare-and-set',
55
+ run: async function receiveRecordInsert(context) {
56
+ const store = context.store;
57
+ const first = receiveWork('conformance-put');
58
+ assertEqual(await store.putReceiveWork(first, null), true, 'an insert of a new record');
59
+ assertEqual(await store.getReceiveWork(first.workId), first, 'the inserted record');
60
+ const clash = receiveWork('conformance-put', { arrivalSeq: 2, plaintext: 'other content' });
61
+ assertEqual(await store.putReceiveWork(clash, null), false, 'an insert over an existing record');
62
+ assertEqual(await store.getReceiveWork(first.workId), first, 'the record after an insert over it');
63
+ const second = receiveWork('conformance-put', { revision: 1, stage: 'awaiting-completion' });
64
+ assertEqual(await store.putReceiveWork(second, 0), true, 'a replace that names the stored revision');
65
+ assertEqual(await store.getReceiveWork(first.workId), second, 'the replaced record');
66
+ const stale = receiveWork('conformance-put', { revision: 2, stage: 'receipt-due', plaintext: undefined });
67
+ assertEqual(await store.putReceiveWork(stale, 0), false, 'a replace that names a stale revision');
68
+ assertEqual(await store.getReceiveWork(first.workId), second, 'the record after a replace that names a stale revision');
69
+ const missing = receiveWork('conformance-put-missing', { revision: 1 });
70
+ assertEqual(await store.putReceiveWork(missing, 0), false, 'a replace of an absent record');
71
+ assertAbsent(await store.getReceiveWork(missing.workId), 'the record of a replace of an absent record');
72
+ },
73
+ },
74
+ {
75
+ name: 'receive record listing',
76
+ run: async function receiveRecordListing(context) {
77
+ const store = context.store;
78
+ const list = function list(query) {
79
+ return store.listReceiveWork(query);
80
+ };
81
+ const records = listedRecords();
82
+ for (const record of records)
83
+ await store.putReceiveWork(record, null);
84
+ const ordered = records.slice().sort(inArrivalOrder);
85
+ assertEqual(await list(), ordered.slice(0, 100), 'the first page of records');
86
+ await expectListing(list, { limit: 200 }, ordered, 'every record in arrival order');
87
+ await expectListing(list, { limit: 7 }, ordered.slice(0, 7), 'a page with a limit');
88
+ for (const position of [0, 49, 50, LISTED_RECORDS - 2]) {
89
+ const cursor = ordered[position];
90
+ await expectListing(list, { after: { arrivalSeq: cursor.arrivalSeq, workId: cursor.workId }, limit: 200 }, ordered.slice(position + 1), 'the records after the record at position ' + position);
91
+ }
92
+ const last = ordered[LISTED_RECORDS - 1];
93
+ await expectListing(list, { after: { arrivalSeq: last.arrivalSeq, workId: last.workId } }, [], 'the records after the last record');
94
+ for (const stage of ['decrypted', 'receipt-due', 'awaiting-completion']) {
95
+ await expectListing(list, { stage: stage, limit: 200 }, ordered.filter(function inStage(record) {
96
+ return record.stage === stage;
97
+ }), 'the records in stage ' + stage);
98
+ }
99
+ await expectListing(list, { dueBy: 1_200, limit: 200 }, ordered.filter(function due(record) {
100
+ return record.dueAt <= 1_200;
101
+ }), 'the records due at a time');
102
+ const cursor = ordered[10];
103
+ await expectListing(list, {
104
+ stage: 'decrypted',
105
+ dueBy: 1_300,
106
+ after: { arrivalSeq: cursor.arrivalSeq, workId: cursor.workId },
107
+ limit: 5,
108
+ }, ordered
109
+ .filter(function matches(record) {
110
+ return record.stage === 'decrypted' && record.dueAt <= 1_300 && isAfter(record, cursor);
111
+ })
112
+ .slice(0, 5), 'a page of the filtered records after a cursor');
113
+ await expectRejection(list({ limit: 0 }), 'a listing with a limit of zero');
114
+ },
115
+ },
116
+ {
117
+ name: 'receive record completion and usage',
118
+ run: async function receiveRecordCompletion(context) {
119
+ const store = context.store;
120
+ const groupId = 'conformance-completion-group';
121
+ const plain = receiveWork('conformance-complete-plain', { arrivalSeq: 1 });
122
+ const blocked = receiveWork('conformance-complete-blocked', {
123
+ arrivalSeq: 2,
124
+ groupId: groupId,
125
+ blockedOn: 'group-update',
126
+ });
127
+ const waiting = receiveWork('conformance-complete-waiting', { arrivalSeq: 3, groupId: groupId });
128
+ for (const record of [plain, blocked, waiting])
129
+ await store.putReceiveWork(record, null);
130
+ await store.setMetadata('conformance-complete-deleted', 'old');
131
+ assertEqual(await store.receiveWorkUsage(), usageOf([plain, blocked, waiting]), 'the usage of every record');
132
+ assertEqual(await store.receiveWorkUsage({ groupId: groupId }), usageOf([blocked]), 'the usage of the records that wait for a group update');
133
+ assertEqual(await store.completeReceiveWork(plain.workId, 1, [
134
+ { key: 'conformance-complete-set', value: 'done' },
135
+ ]), false, 'a completion that names a stale revision');
136
+ assertEqual(await store.getReceiveWork(plain.workId), plain, 'the record after a completion that names a stale revision');
137
+ assertAbsent(await store.getMetadata('conformance-complete-set'), 'the metadata of a completion that names a stale revision');
138
+ assertEqual(await store.completeReceiveWork(plain.workId, 0, [
139
+ { key: 'conformance-complete-set', value: 'done' },
140
+ { key: 'conformance-complete-deleted', value: null },
141
+ ]), true, 'a completion that names the stored revision');
142
+ assertAbsent(await store.getReceiveWork(plain.workId), 'a completed record');
143
+ assertEqual(await store.getMetadata('conformance-complete-set'), 'done', 'the metadata that a completion sets');
144
+ assertAbsent(await store.getMetadata('conformance-complete-deleted'), 'the metadata that a completion deletes');
145
+ assertEqual(await store.receiveWorkUsage(), usageOf([blocked, waiting]), 'the usage after a completion');
146
+ assertEqual(await store.completeReceiveWork(blocked.workId, 0), true, 'a completion of a record that waits for a group update');
147
+ assertEqual(await store.receiveWorkUsage({ groupId: groupId }), usageOf([]), 'the group usage after a completion');
148
+ assertEqual(await store.completeReceiveWork(plain.workId, 0), false, 'a completion of an absent record');
149
+ },
150
+ },
151
+ ];
152
+ //# sourceMappingURL=receive-work.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receive-work.js","sourceRoot":"","sources":["../../../../../local/store/conformance/cases/receive-work.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,wFAAwF;AACxF,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,SAAS,cAAc,CAAC,CAAS,EAAE,CAAS;IAC1C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,cAAc,CAAC,CAAoB,EAAE,CAAoB;IAChE,OAAO,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,IAAI,cAAc,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,OAAO,CAAC,MAAyB,EAAE,MAAyB;IACnE,OAAO,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;AAC5C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, and the rollback of that commit.
4
+ */
5
+ import type { LocalStoreConformanceCase } from '../types.js';
6
+ export declare const senderKeyCases: readonly LocalStoreConformanceCase[];
7
+ //# sourceMappingURL=sender-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sender-key.d.ts","sourceRoot":"","sources":["../../../../../local/store/conformance/cases/sender-key.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAc1D,eAAO,MAAM,cAAc,EAAE,SAAS,yBAAyB,EAyG9D,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The sender key cases: the atomic commit of a sender key record with its
3
+ * receive effects, and the rollback of that commit.
4
+ */
5
+ import { assertAbsent, assertEqual, expectRejection } from '../checks.js';
6
+ import { receiveWork, SENDER_KEY_ID, senderKeyState, skippedMessageKey, } from '../records.js';
7
+ const GROUP_ID = 'conformance-group';
8
+ const MEMBER_ID = 'conformance-member';
9
+ const DEVICE_ID = 1;
10
+ function skippedKey(chainIndex) {
11
+ return { senderKeyId: SENDER_KEY_ID, chainIndex: chainIndex, messageKey: skippedMessageKey(chainIndex) };
12
+ }
13
+ export const senderKeyCases = [
14
+ {
15
+ name: 'sender key receive commit',
16
+ run: async function senderKeyReceiveCommit(context) {
17
+ const store = context.store;
18
+ await store.storeSkippedSenderKey(GROUP_ID, MEMBER_ID, DEVICE_ID, SENDER_KEY_ID, 1, skippedMessageKey(1));
19
+ const work = receiveWork('conformance-sender-key-work', { groupId: GROUP_ID });
20
+ await store.storeSenderKeyRecord(GROUP_ID, MEMBER_ID, DEVICE_ID, [senderKeyState(2)], {
21
+ work: work,
22
+ consumedSkippedKey: { senderKeyId: SENDER_KEY_ID, chainIndex: 1 },
23
+ });
24
+ assertEqual(await store.getSenderKeyRecord(GROUP_ID, MEMBER_ID, DEVICE_ID), [senderKeyState(2)], 'the sender key record of a receive commit');
25
+ assertEqual(await store.getReceiveWork(work.workId), work, 'the receive record of a sender key commit');
26
+ assertAbsent(await store.getSkippedSenderKey(GROUP_ID, MEMBER_ID, DEVICE_ID, SENDER_KEY_ID, 1), 'the consumed skipped key');
27
+ const evictingMember = 'conformance-evicting-member';
28
+ await store.storeSenderKeyRecord(GROUP_ID, evictingMember, DEVICE_ID, [senderKeyState(4)], {
29
+ skippedKeys: { maxSkippedKeys: 2, keys: [skippedKey(1), skippedKey(2), skippedKey(3)] },
30
+ });
31
+ assertEqual(await store.countSkippedSenderKeys(GROUP_ID, evictingMember, DEVICE_ID), 2, 'the skipped key count after an eviction');
32
+ assertAbsent(await store.getSkippedSenderKey(GROUP_ID, evictingMember, DEVICE_ID, SENDER_KEY_ID, 1), 'the skipped key with the lowest chain index after an eviction');
33
+ for (const chainIndex of [2, 3]) {
34
+ assertEqual(await store.getSkippedSenderKey(GROUP_ID, evictingMember, DEVICE_ID, SENDER_KEY_ID, chainIndex), skippedMessageKey(chainIndex), 'the kept skipped key at chain index ' + chainIndex + ' after an eviction');
35
+ }
36
+ },
37
+ },
38
+ {
39
+ name: 'sender key receive commit rollback',
40
+ needs: 'armWriteFailure',
41
+ run: async function senderKeyReceiveCommitRollback(context) {
42
+ const store = context.store;
43
+ await store.storeSenderKeyRecord(GROUP_ID, MEMBER_ID, DEVICE_ID, [senderKeyState(1)]);
44
+ await store.storeSkippedSenderKey(GROUP_ID, MEMBER_ID, DEVICE_ID, SENDER_KEY_ID, 3, skippedMessageKey(3));
45
+ const work = receiveWork('conformance-lost-sender-key-work', { groupId: GROUP_ID });
46
+ context.armWriteFailure();
47
+ await expectRejection(store.storeSenderKeyRecord(GROUP_ID, MEMBER_ID, DEVICE_ID, [senderKeyState(5)], {
48
+ work: work,
49
+ consumedSkippedKey: { senderKeyId: SENDER_KEY_ID, chainIndex: 3 },
50
+ skippedKeys: { maxSkippedKeys: 10, keys: [skippedKey(4)] },
51
+ }), 'a sender key commit with an armed write failure');
52
+ assertEqual(await store.getSenderKeyRecord(GROUP_ID, MEMBER_ID, DEVICE_ID), [senderKeyState(1)], 'the sender key record after a failed commit');
53
+ assertEqual(await store.getSkippedSenderKey(GROUP_ID, MEMBER_ID, DEVICE_ID, SENDER_KEY_ID, 3), skippedMessageKey(3), 'the skipped key that a failed commit consumed');
54
+ assertAbsent(await store.getSkippedSenderKey(GROUP_ID, MEMBER_ID, DEVICE_ID, SENDER_KEY_ID, 4), 'the skipped key that a failed commit added');
55
+ assertAbsent(await store.getReceiveWork(work.workId), 'the receive record of a failed sender key commit');
56
+ },
57
+ },
58
+ ];
59
+ //# sourceMappingURL=sender-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sender-key.js","sourceRoot":"","sources":["../../../../../local/store/conformance/cases/sender-key.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,MAAM,QAAQ,GAAG,mBAAmB,CAAC;AACrC,MAAM,SAAS,GAAG,oBAAoB,CAAC;AACvC,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,SAAS,UAAU,CAAC,UAAkB;IAKpC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;AAC3G,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAyC;IAClE;QACE,IAAI,EAAE,2BAA2B;QACjC,GAAG,EAAE,KAAK,UAAU,sBAAsB,CAAC,OAAO;YAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;YAC5B,MAAM,KAAK,CAAC,qBAAqB,CAC/B,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,CAAC,EACD,iBAAiB,CAAC,CAAC,CAAC,CACrB,CAAC;YACF,MAAM,IAAI,GAAG,WA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,CAAC,EAAE;aAC3D,CAAC,EACF,iDAAiD,CAClD,CAAC;YACF,WAAW,CACT,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAC9D,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACnB,6CAA6C,CAC9C,CAAC;YACF,WAAW,CACT,MAAM,KAAK,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,EACjF,iBAAiB,CAAC,CAAC,CAAC,EACpB,+CAA+C,CAChD,CAAC;YACF,YAAY,CACV,MAAM,KAAK,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,EACjF,4CAA4C,CAC7C,CAAC;YACF,YAAY,CACV,MAAM,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EACvC,kDAAkD,CACnD,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The session trust cases: the atomic commit of a session, its contact
3
+ * identity, and its receive record, and the rollback of that commit.
4
+ */
5
+ import type { LocalStoreConformanceCase } from '../types.js';
6
+ export declare const sessionTrustCases: readonly LocalStoreConformanceCase[];
7
+ //# sourceMappingURL=session-trust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-trust.d.ts","sourceRoot":"","sources":["../../../../../local/store/conformance/cases/session-trust.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AA6B1D,eAAO,MAAM,iBAAiB,EAAE,SAAS,yBAAyB,EAuFjE,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The session trust cases: the atomic commit of a session, its contact
3
+ * identity, and its receive record, and the rollback of that commit.
4
+ */
5
+ import { ProtocolAddress } from '../../../../types/address.js';
6
+ import { assertAbsent, assertEqual, expectRejection } from '../checks.js';
7
+ import { contactIdentity, receiveWork, sessionRecord } from '../records.js';
8
+ /** A one-time prekey ID that no case stores. */
9
+ const MISSING_ONE_TIME_PREKEY_ID = 4242;
10
+ function trustCommit(address, receivedMessages, contactSeed, extra = {}) {
11
+ return {
12
+ address: address,
13
+ record: sessionRecord(address, receivedMessages),
14
+ contactIdentity: contactIdentity(contactSeed),
15
+ contactIdentityType: 'aci',
16
+ localIdentityType: 'aci',
17
+ ...extra,
18
+ };
19
+ }
20
+ async function pinnedContact(store, address) {
21
+ const record = await store.getContactIdentity(address, 'aci');
22
+ return record === null || record === undefined ? null : record.identity;
23
+ }
24
+ export const sessionTrustCases = [
25
+ {
26
+ name: 'session trust commit',
27
+ run: async function sessionTrustCommit(context) {
28
+ const store = context.store;
29
+ const address = ProtocolAddress.create('conformance-trust-user', 1);
30
+ await store.commitSessionTrust(trustCommit(address, 1, 1));
31
+ assertEqual(await store.getSessionRecord(address), sessionRecord(address, 1), 'the session of a commit');
32
+ assertEqual(await pinnedContact(store, address), contactIdentity(1), 'the pinned contact identity');
33
+ await expectRejection(store.commitSessionTrust(trustCommit(address, 2, 11)), 'a commit with a changed contact identity');
34
+ assertEqual(await store.getSessionRecord(address), sessionRecord(address, 1), 'the session after a commit with a changed contact identity');
35
+ assertEqual(await pinnedContact(store, address), contactIdentity(1), 'the contact identity after a commit with a changed contact identity');
36
+ const refused = ProtocolAddress.create('conformance-refused-user', 1);
37
+ await expectRejection(store.commitSessionTrust(trustCommit(refused, 1, 1, { oneTimePreKeyId: MISSING_ONE_TIME_PREKEY_ID })), 'a commit that consumes a missing one-time prekey');
38
+ assertAbsent(await store.getSessionRecord(refused), 'the session of a commit that consumes a missing one-time prekey');
39
+ assertAbsent(await pinnedContact(store, refused), 'the contact identity of a commit that consumes a missing one-time prekey');
40
+ },
41
+ },
42
+ {
43
+ name: 'session trust commit rollback',
44
+ needs: 'armWriteFailure',
45
+ run: async function sessionTrustCommitRollback(context) {
46
+ const store = context.store;
47
+ const known = ProtocolAddress.create('conformance-rollback-known-user', 1);
48
+ await store.commitSessionTrust(trustCommit(known, 1, 1));
49
+ const knownWork = receiveWork('conformance-rollback-known-work');
50
+ context.armWriteFailure();
51
+ await expectRejection(store.commitSessionTrust(trustCommit(known, 2, 1, { receiveWork: knownWork })), 'a commit of a known session with an armed write failure');
52
+ assertEqual(await store.getSessionRecord(known), sessionRecord(known, 1), 'the session after a failed commit');
53
+ assertAbsent(await store.getReceiveWork(knownWork.workId), 'the receive record of a failed commit');
54
+ const fresh = ProtocolAddress.create('conformance-rollback-new-user', 1);
55
+ const freshWork = receiveWork('conformance-rollback-new-work');
56
+ context.armWriteFailure();
57
+ await expectRejection(store.commitSessionTrust(trustCommit(fresh, 1, 21, { receiveWork: freshWork })), 'a first commit with an armed write failure');
58
+ assertAbsent(await store.getSessionRecord(fresh), 'the session of a failed first commit');
59
+ assertAbsent(await pinnedContact(store, fresh), 'the contact identity of a failed first commit');
60
+ assertAbsent(await store.getReceiveWork(freshWork.workId), 'the receive record of a failed first commit');
61
+ },
62
+ },
63
+ ];
64
+ //# sourceMappingURL=session-trust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-trust.js","sourceRoot":"","sources":["../../../../../local/store/conformance/cases/session-trust.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGzE,gDAAgD;AAChD,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAExC,SAAS,WAAW,CAClB,OAAwB,EACxB,gBAAwB,EACxB,WAAmB,EACnB,KAAK,GAAgC,EAAE;IAEvC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,aAAa,CAAC,OAAO,E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MAAM,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACnC,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC,EACvB,mCAAmC,CACpC,CAAC;YACF,YAAY,CACV,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,EAC5C,uCAAuC,CACxC,CAAC;YAEF,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC,+BAA+B,EAAE,CAAC,CAAC,CAAC;YACzE,MAAM,SAAS,GAAG,WAAW,CAAC,+BAA+B,CAAC,CAAC;YAC/D,OAAO,CAAC,eAAe,EAAE,CAAC;YAC1B,MAAM,eAAe,CACnB,KAAK,CAAC,kBAAkB,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,EAC/E,4CAA4C,CAC7C,CAAC;YACF,YAAY,CAAC,MAAM,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,sCAAsC,CAAC,CAAC;YAC1F,YAAY,CACV,MAAM,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,EACjC,+CAA+C,CAChD,CAAC;YACF,YAAY,CACV,MAAM,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,EAC5C,6CAA6C,CAC9C,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The checks of the local store conformance kit. A failed check throws an
3
+ * error that names what the store did wrong. The checks avoid class syntax,
4
+ * so they run under any JavaScript engine.
5
+ */
6
+ export declare function fail(message: string): never;
7
+ export declare function sameValue(actual: unknown, expected: unknown): boolean;
8
+ export declare function assertEqual(actual: unknown, expected: unknown, context: string): void;
9
+ /** Fail unless `value` is null or undefined, the two forms of an absent value. */
10
+ export declare function assertAbsent(value: unknown, context: string): void;
11
+ /** Wait for `promise` and fail when it resolves. */
12
+ export declare function expectRejection(promise: Promise<unknown>, context: string): Promise<unknown>;
13
+ /** The message of a thrown value. */
14
+ export declare function errorMessage(error: unknown): string;
15
+ //# sourceMappingURL=checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../../../local/store/conformance/checks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAE3C;AAuBD,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAErE;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAUrF;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIlE;AAED,oDAAoD;AACpD,wBAAsB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAYlG;AAED,qCAAqC;AACrC,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAInD"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The checks of the local store conformance kit. A failed check throws an
3
+ * error that names what the store did wrong. The checks avoid class syntax,
4
+ * so they run under any JavaScript engine.
5
+ */
6
+ export function fail(message) {
7
+ throw new Error(message);
8
+ }
9
+ /**
10
+ * A stable text of a value: object keys in sorted order, bytes as a list of
11
+ * numbers, and undefined properties left out. Two stores that return equal
12
+ * data in a different key order give the same text.
13
+ */
14
+ function canonical(value) {
15
+ if (ArrayBuffer.isView(value)) {
16
+ return { bytes: Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength)) };
17
+ }
18
+ if (Array.isArray(value))
19
+ return value.map(canonical);
20
+ if (value !== null && typeof value === 'object') {
21
+ const sorted = {};
22
+ for (const key of Object.keys(value).sort()) {
23
+ const item = value[key];
24
+ if (item !== undefined)
25
+ sorted[key] = canonical(item);
26
+ }
27
+ return sorted;
28
+ }
29
+ return value;
30
+ }
31
+ export function sameValue(actual, expected) {
32
+ return JSON.stringify(canonical(actual)) === JSON.stringify(canonical(expected));
33
+ }
34
+ export function assertEqual(actual, expected, context) {
35
+ if (!sameValue(actual, expected)) {
36
+ fail(context +
37
+ ': expected ' +
38
+ JSON.stringify(canonical(expected)) +
39
+ ', got ' +
40
+ JSON.stringify(canonical(actual)));
41
+ }
42
+ }
43
+ /** Fail unless `value` is null or undefined, the two forms of an absent value. */
44
+ export function assertAbsent(value, context) {
45
+ if (value !== null && value !== undefined) {
46
+ fail(context + ': expected no value, got ' + JSON.stringify(canonical(value)));
47
+ }
48
+ }
49
+ /** Wait for `promise` and fail when it resolves. */
50
+ export async function expectRejection(promise, context) {
51
+ let error = null;
52
+ let rejected = false;
53
+ await promise.then(function resolved() { }, function caught(reason) {
54
+ rejected = true;
55
+ error = reason;
56
+ });
57
+ if (!rejected)
58
+ fail(context + ': expected the call to reject, but it resolved');
59
+ return error;
60
+ }
61
+ /** The message of a thrown value. */
62
+ export function errorMessage(error) {
63
+ return error !== null && typeof error === 'object' && 'message' in error
64
+ ? String(error.message)
65
+ : String(error);
66
+ }
67
+ //# sourceMappingURL=checks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.js","sourceRoot":"","sources":["../../../../local/store/conformance/checks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MA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AAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,2BAA2B,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAyB,EAAE,OAAe;IAC9E,IAAI,KAAK,GAAY,IAAI,CAAC;IAC1B,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,OAAO,CAAC,IAAI,CAChB,SAAS,QAAQ,KAAI,CAAC,EACtB,SAAS,MAAM,CAAC,MAAe;QAC7B,QAAQ,GAAG,IAAI,CAAC;QAChB,KAAK,GAAG,MAAM,CAAC;IACjB,CAAC,CACF,CAAC;IACF,IAAI,CAAC,QAAQ;QAAE,IAAI,CAAC,OAAO,GAAG,gDAAgD,CAAC,CAAC;IAChF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK;QACtE,CAAC,CAAC,MAAM,CAAE,KAA8B,CAAC,OAAO,CAAC;QACjD,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Conformance kit for a custom local store.
3
+ *
4
+ * An application that implements `SignalProtocolLocalStore` itself runs this
5
+ * kit against its store. The kit checks the identity overwrite, the atomic
6
+ * session trust and sender key commits and their rollback, metadata
7
+ * compare-and-set, the receive records, durability after a reopen, the
8
+ * stored bytes of a store that declares a cipher, and the protection
9
+ * declaration. It does not check the sender key handoffs, the message
10
+ * records, or the group send log.
11
+ *
12
+ * The kit has no framework or platform dependencies. It runs unchanged under
13
+ * jest, Node, a browser, or Hermes.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { assertLocalStoreConformance } from '@open-e2ee/signal-protocol-sdk/local/store/conformance';
18
+ *
19
+ * await assertLocalStoreConformance({
20
+ * createStore: () => openMyStore({ name: freshName() }),
21
+ * reopen: (store) => reopenMyStore(store),
22
+ * armWriteFailure: (store) => failNextReceiveRecordWrite(store),
23
+ * readRawBytes: (store) => readMyStoreFiles(store),
24
+ * closeStore: (store) => store.close(),
25
+ * });
26
+ * ```
27
+ */
28
+ export { assertLocalStoreConformance, runLocalStoreConformance } from './run.js';
29
+ export type { LocalStoreConformanceFailure, LocalStoreConformanceOptions, LocalStoreConformanceResult, } from './types.js';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../local/store/conformance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAC9E,YAAY,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,SAAS,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Conformance kit for a custom local store.
3
+ *
4
+ * An application that implements `SignalProtocolLocalStore` itself runs this
5
+ * kit against its store. The kit checks the identity overwrite, the atomic
6
+ * session trust and sender key commits and their rollback, metadata
7
+ * compare-and-set, the receive records, durability after a reopen, the
8
+ * stored bytes of a store that declares a cipher, and the protection
9
+ * declaration. It does not check the sender key handoffs, the message
10
+ * records, or the group send log.
11
+ *
12
+ * The kit has no framework or platform dependencies. It runs unchanged under
13
+ * jest, Node, a browser, or Hermes.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { assertLocalStoreConformance } from '@open-e2ee/signal-protocol-sdk/local/store/conformance';
18
+ *
19
+ * await assertLocalStoreConformance({
20
+ * createStore: () => openMyStore({ name: freshName() }),
21
+ * reopen: (store) => reopenMyStore(store),
22
+ * armWriteFailure: (store) => failNextReceiveRecordWrite(store),
23
+ * readRawBytes: (store) => readMyStoreFiles(store),
24
+ * closeStore: (store) => store.close(),
25
+ * });
26
+ * ```
27
+ */
28
+ export { assertLocalStoreConformance, runLocalStoreConformance } from './run.js';
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../local/store/conformance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The records that the local store conformance cases write. Each one is a
3
+ * valid value that every store accepts, and none comes from a live protocol
4
+ * run.
5
+ */
6
+ import type { SenderKeyState } from '../../../internal/protocol/sender-keys/manager.js';
7
+ import type { CompositeIdentityV1 } from '../../../keys/index.js';
8
+ import { ProtocolAddress } from '../../../types/address.js';
9
+ import type { ReceiveWorkRecord } from '../../../types/api.js';
10
+ import { type SessionRecord } from '../../../types/session.js';
11
+ /**
12
+ * A text that no store writes on its own. The ciphertext scan writes it in
13
+ * values that a cipher must protect, then looks for it in the stored bytes.
14
+ */
15
+ export declare const PLAINTEXT_MARKER = "local-store-conformance-plaintext-marker";
16
+ /** A 32-byte key in base64. Each seed gives a different key. */
17
+ export declare function testKey(seed: number): string;
18
+ /** A contact identity. Each seed gives a different identity. */
19
+ export declare function contactIdentity(seed: number): CompositeIdentityV1;
20
+ /**
21
+ * A current session record for `address`. The received message count
22
+ * tells two records apart.
23
+ */
24
+ export declare function sessionRecord(address: ProtocolAddress, receivedMessages: number): SessionRecord;
25
+ /** The sender key ID of every sender key state of the kit. */
26
+ export declare const SENDER_KEY_ID = "00000000-0000-4000-8000-0000000000c1";
27
+ /** A sender key state at `chainIndex`. */
28
+ export declare function senderKeyState(chainIndex: number, chainKey?: string): SenderKeyState;
29
+ /** A skipped message key. Each index gives a different key. */
30
+ export declare function skippedMessageKey(index: number): {
31
+ cipherKey: string;
32
+ iv: string;
33
+ };
34
+ /** A valid receive record with its size set. Each override replaces one field. */
35
+ export declare function receiveWork(workId: string, overrides?: Partial<ReceiveWorkRecord>): ReceiveWorkRecord;
36
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../../local/store/conformance/records.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAyB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5F;;;GAGG;AACH,eAAO,MAAM,gBAAgB,6CAA6C,CAAC;AAE3E,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAMjE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,GAAG,aAAa,CA0C/F;AAED,8DAA8D;AAC9D,eAAO,MAAM,aAAa,yCAAyC,CAAC;AAEpE,0CAA0C;AAC1C,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,SAA4B,GAAG,cAAc,CAYvG;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAElF;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,OAAO,CAAC,iBAAiB,CAAM,GACzC,iBAAiB,CAanB"}