@agora-sdk/secure-chat-crypto 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2025 Replyke
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1 @@
1
+ export type { SecureChatCrypto, DeviceIdentity, KeyPackageBundle, GroupHandle, TargetedWelcome, CommitResult, PassphraseBackup, } from "./interface";
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,82 @@
1
+ /** A device's long-lived MLS identity (one device = one leaf). The public half is published to
2
+ * the server; the private half stays on the device (and in the passphrase backup). */
3
+ export interface DeviceIdentity {
4
+ deviceId: string;
5
+ signaturePublicKey: Uint8Array;
6
+ credential: Uint8Array;
7
+ ciphersuite: number;
8
+ }
9
+ /** A one-time KeyPackage others consume to add this device to a group. */
10
+ export interface KeyPackageBundle {
11
+ keyPackageRef: string;
12
+ keyPackage: Uint8Array;
13
+ ciphersuite: number;
14
+ expiresAt?: string;
15
+ }
16
+ /** A handle to a local MLS group the client holds the secrets for. */
17
+ export interface GroupHandle {
18
+ mlsGroupId: Uint8Array;
19
+ epoch: bigint;
20
+ }
21
+ /** A Welcome destined for exactly one new-member device (the one whose KeyPackage was used). */
22
+ export interface TargetedWelcome {
23
+ targetDeviceId: string;
24
+ payload: Uint8Array;
25
+ }
26
+ /** The output of a group mutation: a Commit to broadcast + per-device Welcomes to deliver. */
27
+ export interface CommitResult {
28
+ commit: Uint8Array;
29
+ welcomes: TargetedWelcome[];
30
+ epoch: bigint;
31
+ }
32
+ /** A serialized, passphrase-encrypted backup of all local key material (history-restore on a new
33
+ * browser; also the basis for cross-device history sync later). */
34
+ export interface PassphraseBackup {
35
+ blob: Uint8Array;
36
+ kdf: string;
37
+ kdfParams: Record<string, unknown>;
38
+ cipher: string;
39
+ nonce: Uint8Array;
40
+ version: number;
41
+ }
42
+ export interface SecureChatCrypto {
43
+ generateDeviceIdentity(opts: {
44
+ deviceId: string;
45
+ ciphersuite?: number;
46
+ }): Promise<{
47
+ identity: DeviceIdentity;
48
+ privateState: Uint8Array;
49
+ }>;
50
+ generateKeyPackages(count: number): Promise<KeyPackageBundle[]>;
51
+ createGroup(opts: {
52
+ mlsGroupId?: Uint8Array;
53
+ initialMembers: {
54
+ deviceId: string;
55
+ keyPackage: Uint8Array;
56
+ }[];
57
+ }): Promise<{
58
+ group: GroupHandle;
59
+ welcomes: TargetedWelcome[];
60
+ }>;
61
+ addMember(group: GroupHandle, newDevice: {
62
+ deviceId: string;
63
+ keyPackage: Uint8Array;
64
+ }): Promise<CommitResult>;
65
+ removeMember(group: GroupHandle, leafDeviceId: string): Promise<CommitResult>;
66
+ encryptMessage(group: GroupHandle, plaintext: Uint8Array): Promise<{
67
+ ciphertext: Uint8Array;
68
+ epoch: bigint;
69
+ }>;
70
+ decryptMessage(group: GroupHandle, ciphertext: Uint8Array): Promise<{
71
+ plaintext: Uint8Array;
72
+ senderDeviceId: string;
73
+ epoch: bigint;
74
+ }>;
75
+ processWelcome(welcome: Uint8Array): Promise<GroupHandle>;
76
+ processCommit(group: GroupHandle, commit: Uint8Array): Promise<GroupHandle>;
77
+ processProposal(group: GroupHandle, proposal: Uint8Array): Promise<void>;
78
+ exportGroupState(group: GroupHandle): Promise<Uint8Array>;
79
+ importGroupState(state: Uint8Array): Promise<GroupHandle>;
80
+ exportBackup(passphrase: string): Promise<PassphraseBackup>;
81
+ importBackup(passphrase: string, backup: PassphraseBackup): Promise<void>;
82
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // The `SecureChatCrypto` seam — the canonical client crypto interface for Agora secure chat.
3
+ //
4
+ // All MLS (RFC 9420) crypto lives CLIENT-side behind this one interface. The Agora server is a
5
+ // blind Delivery Service and depends on none of it — it only relays opaque base64 blobs. The
6
+ // concrete core — ts-mls (pure TS) or OpenMLS compiled to WASM — is a swappable implementation;
7
+ // this abstraction lets that choice be deferred and changed without touching call sites.
8
+ //
9
+ // This package is the home of record for the seam. The agora-server repo consumes it as a
10
+ // (dev)dependency for its integration tests — the server is a CONSUMER of this client crypto, not
11
+ // its owner. Binary is `Uint8Array` IN MEMORY; the network layer base64-encodes at the wire
12
+ // boundary. MLS epochs are u64 → `bigint`.
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/interface.ts"],"names":[],"mappings":";AAAA,6FAA6F;AAC7F,EAAE;AACF,+FAA+F;AAC/F,6FAA6F;AAC7F,gGAAgG;AAChG,yFAAyF;AACzF,EAAE;AACF,0FAA0F;AAC1F,kGAAkG;AAClG,4FAA4F;AAC5F,2CAA2C"}
@@ -0,0 +1,46 @@
1
+ import type { SecureChatCrypto, DeviceIdentity, KeyPackageBundle, GroupHandle, CommitResult, PassphraseBackup, TargetedWelcome } from "./interface";
2
+ export declare class MockSecureChatCrypto implements SecureChatCrypto {
3
+ private identity?;
4
+ private privateState?;
5
+ private groups;
6
+ private kpCounter;
7
+ generateDeviceIdentity(opts: {
8
+ deviceId: string;
9
+ ciphersuite?: number;
10
+ }): Promise<{
11
+ identity: DeviceIdentity;
12
+ privateState: Uint8Array<ArrayBufferLike>;
13
+ }>;
14
+ generateKeyPackages(count: number): Promise<KeyPackageBundle[]>;
15
+ createGroup(opts: {
16
+ mlsGroupId?: Uint8Array;
17
+ initialMembers: {
18
+ deviceId: string;
19
+ keyPackage: Uint8Array;
20
+ }[];
21
+ }): Promise<{
22
+ group: GroupHandle;
23
+ welcomes: TargetedWelcome[];
24
+ }>;
25
+ addMember(group: GroupHandle, newDevice: {
26
+ deviceId: string;
27
+ keyPackage: Uint8Array;
28
+ }): Promise<CommitResult>;
29
+ removeMember(group: GroupHandle, _leafDeviceId: string): Promise<CommitResult>;
30
+ encryptMessage(group: GroupHandle, plaintext: Uint8Array): Promise<{
31
+ ciphertext: Uint8Array;
32
+ epoch: bigint;
33
+ }>;
34
+ decryptMessage(group: GroupHandle, ciphertext: Uint8Array): Promise<{
35
+ plaintext: Uint8Array;
36
+ senderDeviceId: string;
37
+ epoch: bigint;
38
+ }>;
39
+ processWelcome(welcome: Uint8Array): Promise<GroupHandle>;
40
+ processCommit(group: GroupHandle, commit: Uint8Array): Promise<GroupHandle>;
41
+ processProposal(_group: GroupHandle, _proposal: Uint8Array): Promise<void>;
42
+ exportGroupState(group: GroupHandle): Promise<Uint8Array>;
43
+ importGroupState(state: Uint8Array): Promise<GroupHandle>;
44
+ exportBackup(passphrase: string): Promise<PassphraseBackup>;
45
+ importBackup(passphrase: string, backup: PassphraseBackup): Promise<void>;
46
+ }
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockSecureChatCrypto = void 0;
4
+ const enc = new TextEncoder();
5
+ const dec = new TextDecoder();
6
+ const BACKUP_MAGIC = "AGORA_MOCK_BACKUP_V1";
7
+ function toHex(b) {
8
+ let s = "";
9
+ for (const x of b)
10
+ s += x.toString(16).padStart(2, "0");
11
+ return s;
12
+ }
13
+ function fromHex(s) {
14
+ const out = new Uint8Array(s.length / 2);
15
+ for (let i = 0; i < out.length; i++)
16
+ out[i] = parseInt(s.slice(i * 2, i * 2 + 2), 16);
17
+ return out;
18
+ }
19
+ /** Deterministic non-zero keystream (FNV-seeded LCG). Non-zero guarantees ciphertext≠plaintext. */
20
+ function keystream(seed, len) {
21
+ let state = 2166136261 >>> 0;
22
+ for (const b of seed)
23
+ state = ((state ^ b) * 16777619) >>> 0;
24
+ const out = new Uint8Array(len);
25
+ for (let i = 0; i < len; i++) {
26
+ state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
27
+ out[i] = (state >>> 24) & 0xff;
28
+ if (out[i] === 0)
29
+ out[i] = 0xa5;
30
+ }
31
+ return out;
32
+ }
33
+ function bytesFrom(s, len) {
34
+ return keystream(enc.encode(s), len);
35
+ }
36
+ function xor(data, key) {
37
+ const out = new Uint8Array(data.length);
38
+ for (let i = 0; i < data.length; i++)
39
+ out[i] = data[i] ^ key[i % key.length];
40
+ return out;
41
+ }
42
+ function jsonBytes(v) {
43
+ return enc.encode(JSON.stringify(v));
44
+ }
45
+ function parseJson(b) {
46
+ return JSON.parse(dec.decode(b));
47
+ }
48
+ class MockSecureChatCrypto {
49
+ constructor() {
50
+ this.groups = new Map(); // groupIdHex -> state
51
+ this.kpCounter = 0;
52
+ }
53
+ async generateDeviceIdentity(opts) {
54
+ const ciphersuite = opts.ciphersuite ?? 1;
55
+ const identity = {
56
+ deviceId: opts.deviceId,
57
+ signaturePublicKey: bytesFrom(`sig:${opts.deviceId}`, 32),
58
+ credential: enc.encode(opts.deviceId), // mock credential = the device id
59
+ ciphersuite,
60
+ };
61
+ this.identity = identity;
62
+ this.privateState = bytesFrom(`priv:${opts.deviceId}`, 32);
63
+ return { identity, privateState: this.privateState };
64
+ }
65
+ async generateKeyPackages(count) {
66
+ const did = this.identity?.deviceId ?? "unknown";
67
+ const cs = this.identity?.ciphersuite ?? 1;
68
+ const out = [];
69
+ for (let i = 0; i < count; i++) {
70
+ const ref = `${did}:kp:${this.kpCounter++}`;
71
+ out.push({ keyPackageRef: ref, keyPackage: bytesFrom(`kp:${ref}`, 48), ciphersuite: cs });
72
+ }
73
+ return out;
74
+ }
75
+ async createGroup(opts) {
76
+ const did = this.identity?.deviceId ?? "creator";
77
+ const mlsGroupId = opts.mlsGroupId ??
78
+ bytesFrom(`grp:${did}:${opts.initialMembers.map((m) => m.deviceId).join(",")}`, 16);
79
+ const idHex = toHex(mlsGroupId);
80
+ const secret = bytesFrom(`secret:${idHex}:${did}`, 32);
81
+ this.groups.set(idHex, { secret, epoch: 0n });
82
+ const welcomes = opts.initialMembers.map((m) => ({
83
+ targetDeviceId: m.deviceId,
84
+ payload: jsonBytes({
85
+ groupId: idHex,
86
+ secret: toHex(secret),
87
+ epoch: "0",
88
+ }),
89
+ }));
90
+ return { group: { mlsGroupId, epoch: 0n }, welcomes };
91
+ }
92
+ async addMember(group, newDevice) {
93
+ const idHex = toHex(group.mlsGroupId);
94
+ const st = this.groups.get(idHex);
95
+ if (!st)
96
+ throw new Error("mock: unknown group");
97
+ st.epoch += 1n;
98
+ const epoch = st.epoch;
99
+ return {
100
+ commit: jsonBytes({ type: "commit", groupId: idHex, epoch: epoch.toString() }),
101
+ welcomes: [
102
+ {
103
+ targetDeviceId: newDevice.deviceId,
104
+ payload: jsonBytes({
105
+ groupId: idHex,
106
+ secret: toHex(st.secret),
107
+ epoch: epoch.toString(),
108
+ }),
109
+ },
110
+ ],
111
+ epoch,
112
+ };
113
+ }
114
+ async removeMember(group, _leafDeviceId) {
115
+ const idHex = toHex(group.mlsGroupId);
116
+ const st = this.groups.get(idHex);
117
+ if (!st)
118
+ throw new Error("mock: unknown group");
119
+ st.epoch += 1n;
120
+ return {
121
+ commit: jsonBytes({ type: "commit", groupId: idHex, epoch: st.epoch.toString() }),
122
+ welcomes: [],
123
+ epoch: st.epoch,
124
+ };
125
+ }
126
+ async encryptMessage(group, plaintext) {
127
+ const idHex = toHex(group.mlsGroupId);
128
+ const st = this.groups.get(idHex);
129
+ if (!st)
130
+ throw new Error("mock: unknown group");
131
+ const sender = this.identity?.deviceId ?? "unknown";
132
+ const ks = keystream(st.secret, plaintext.length);
133
+ const body = xor(plaintext, ks);
134
+ const header = enc.encode(`${sender}|${st.epoch}|`);
135
+ const ciphertext = new Uint8Array(header.length + body.length);
136
+ ciphertext.set(header, 0);
137
+ ciphertext.set(body, header.length);
138
+ return { ciphertext, epoch: st.epoch };
139
+ }
140
+ async decryptMessage(group, ciphertext) {
141
+ const idHex = toHex(group.mlsGroupId);
142
+ const st = this.groups.get(idHex);
143
+ if (!st)
144
+ throw new Error("mock: unknown group");
145
+ // header = "<deviceId>|<epoch>|" — split on the SECOND pipe.
146
+ let pipes = 0;
147
+ let cut = -1;
148
+ for (let i = 0; i < ciphertext.length; i++) {
149
+ if (ciphertext[i] === 0x7c /* | */) {
150
+ pipes++;
151
+ if (pipes === 2) {
152
+ cut = i + 1;
153
+ break;
154
+ }
155
+ }
156
+ }
157
+ if (cut < 0)
158
+ throw new Error("mock: malformed ciphertext");
159
+ const [senderDeviceId, epochStr] = dec.decode(ciphertext.slice(0, cut - 1)).split("|");
160
+ const body = ciphertext.slice(cut);
161
+ const ks = keystream(st.secret, body.length);
162
+ return {
163
+ plaintext: xor(body, ks),
164
+ senderDeviceId: senderDeviceId ?? "",
165
+ epoch: BigInt(epochStr ?? "0"),
166
+ };
167
+ }
168
+ async processWelcome(welcome) {
169
+ const w = parseJson(welcome);
170
+ this.groups.set(w.groupId, { secret: fromHex(w.secret), epoch: BigInt(w.epoch) });
171
+ return { mlsGroupId: fromHex(w.groupId), epoch: BigInt(w.epoch) };
172
+ }
173
+ async processCommit(group, commit) {
174
+ const c = parseJson(commit);
175
+ const idHex = toHex(group.mlsGroupId);
176
+ const st = this.groups.get(idHex);
177
+ if (st)
178
+ st.epoch = BigInt(c.epoch);
179
+ return { mlsGroupId: group.mlsGroupId, epoch: BigInt(c.epoch) };
180
+ }
181
+ async processProposal(_group, _proposal) {
182
+ /* mock: proposals are no-ops until their Commit arrives */
183
+ }
184
+ async exportGroupState(group) {
185
+ const idHex = toHex(group.mlsGroupId);
186
+ const st = this.groups.get(idHex);
187
+ if (!st)
188
+ throw new Error("mock: unknown group");
189
+ return jsonBytes({ groupId: idHex, secret: toHex(st.secret), epoch: st.epoch.toString() });
190
+ }
191
+ async importGroupState(state) {
192
+ const s = parseJson(state);
193
+ this.groups.set(s.groupId, { secret: fromHex(s.secret), epoch: BigInt(s.epoch) });
194
+ return { mlsGroupId: fromHex(s.groupId), epoch: BigInt(s.epoch) };
195
+ }
196
+ async exportBackup(passphrase) {
197
+ const groups = [...this.groups.entries()].map(([id, st]) => ({
198
+ id,
199
+ secret: toHex(st.secret),
200
+ epoch: st.epoch.toString(),
201
+ }));
202
+ const plain = jsonBytes({
203
+ magic: BACKUP_MAGIC,
204
+ identityPriv: this.privateState ? toHex(this.privateState) : null,
205
+ deviceId: this.identity?.deviceId ?? null,
206
+ groups,
207
+ });
208
+ const salt = bytesFrom(`salt:${passphrase}`, 16);
209
+ const key = keystream(enc.encode(`${passphrase}:${toHex(salt)}`), plain.length);
210
+ return {
211
+ blob: xor(plain, key),
212
+ kdf: "argon2id",
213
+ kdfParams: { salt: toHex(salt), m: 65536, t: 3, p: 1 },
214
+ cipher: "xchacha20poly1305",
215
+ nonce: bytesFrom(`nonce:${passphrase}`, 24),
216
+ version: 1,
217
+ };
218
+ }
219
+ async importBackup(passphrase, backup) {
220
+ const salt = backup.kdfParams.salt ?? toHex(bytesFrom(`salt:${passphrase}`, 16));
221
+ const key = keystream(enc.encode(`${passphrase}:${salt}`), backup.blob.length);
222
+ const plain = xor(backup.blob, key);
223
+ let parsed;
224
+ try {
225
+ parsed = parseJson(plain);
226
+ }
227
+ catch {
228
+ throw new Error("mock: backup decrypt failed (wrong passphrase?)");
229
+ }
230
+ if (parsed.magic !== BACKUP_MAGIC) {
231
+ throw new Error("mock: backup decrypt failed (wrong passphrase?)");
232
+ }
233
+ if (parsed.identityPriv)
234
+ this.privateState = fromHex(parsed.identityPriv);
235
+ for (const g of parsed.groups) {
236
+ this.groups.set(g.id, { secret: fromHex(g.secret), epoch: BigInt(g.epoch) });
237
+ }
238
+ }
239
+ }
240
+ exports.MockSecureChatCrypto = MockSecureChatCrypto;
241
+ //# sourceMappingURL=mock-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-crypto.js","sourceRoot":"","sources":["../../src/mock-crypto.ts"],"names":[],"mappings":";;;AA0BA,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC9B,MAAM,GA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true });
3
+ exports.MockSecureChatCrypto = void 0;
4
+ // @agora-sdk/secure-chat-crypto/testing — the deterministic mock, kept off the main entry.
5
+ //
6
+ // NOT cryptographically secure. Use it in tests and early UI work (and the agora-server integration
7
+ // suite consumes it from here). Never ship it as production crypto.
8
+ var mock_crypto_1 = require("./mock-crypto");
9
+ Object.defineProperty(exports, "MockSecureChatCrypto", { enumerable: true, get: function () { return mock_crypto_1.MockSecureChatCrypto; } });
10
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/testing.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC3F,EAAE;AACF,oGAAoG;AACpG,oEAAoE;AACpE,6CAAqD;AAA5C,mHAAA,oBAAoB,OAAA"}
@@ -0,0 +1 @@
1
+ export type { SecureChatCrypto, DeviceIdentity, KeyPackageBundle, GroupHandle, TargetedWelcome, CommitResult, PassphraseBackup, } from "./interface";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,82 @@
1
+ /** A device's long-lived MLS identity (one device = one leaf). The public half is published to
2
+ * the server; the private half stays on the device (and in the passphrase backup). */
3
+ export interface DeviceIdentity {
4
+ deviceId: string;
5
+ signaturePublicKey: Uint8Array;
6
+ credential: Uint8Array;
7
+ ciphersuite: number;
8
+ }
9
+ /** A one-time KeyPackage others consume to add this device to a group. */
10
+ export interface KeyPackageBundle {
11
+ keyPackageRef: string;
12
+ keyPackage: Uint8Array;
13
+ ciphersuite: number;
14
+ expiresAt?: string;
15
+ }
16
+ /** A handle to a local MLS group the client holds the secrets for. */
17
+ export interface GroupHandle {
18
+ mlsGroupId: Uint8Array;
19
+ epoch: bigint;
20
+ }
21
+ /** A Welcome destined for exactly one new-member device (the one whose KeyPackage was used). */
22
+ export interface TargetedWelcome {
23
+ targetDeviceId: string;
24
+ payload: Uint8Array;
25
+ }
26
+ /** The output of a group mutation: a Commit to broadcast + per-device Welcomes to deliver. */
27
+ export interface CommitResult {
28
+ commit: Uint8Array;
29
+ welcomes: TargetedWelcome[];
30
+ epoch: bigint;
31
+ }
32
+ /** A serialized, passphrase-encrypted backup of all local key material (history-restore on a new
33
+ * browser; also the basis for cross-device history sync later). */
34
+ export interface PassphraseBackup {
35
+ blob: Uint8Array;
36
+ kdf: string;
37
+ kdfParams: Record<string, unknown>;
38
+ cipher: string;
39
+ nonce: Uint8Array;
40
+ version: number;
41
+ }
42
+ export interface SecureChatCrypto {
43
+ generateDeviceIdentity(opts: {
44
+ deviceId: string;
45
+ ciphersuite?: number;
46
+ }): Promise<{
47
+ identity: DeviceIdentity;
48
+ privateState: Uint8Array;
49
+ }>;
50
+ generateKeyPackages(count: number): Promise<KeyPackageBundle[]>;
51
+ createGroup(opts: {
52
+ mlsGroupId?: Uint8Array;
53
+ initialMembers: {
54
+ deviceId: string;
55
+ keyPackage: Uint8Array;
56
+ }[];
57
+ }): Promise<{
58
+ group: GroupHandle;
59
+ welcomes: TargetedWelcome[];
60
+ }>;
61
+ addMember(group: GroupHandle, newDevice: {
62
+ deviceId: string;
63
+ keyPackage: Uint8Array;
64
+ }): Promise<CommitResult>;
65
+ removeMember(group: GroupHandle, leafDeviceId: string): Promise<CommitResult>;
66
+ encryptMessage(group: GroupHandle, plaintext: Uint8Array): Promise<{
67
+ ciphertext: Uint8Array;
68
+ epoch: bigint;
69
+ }>;
70
+ decryptMessage(group: GroupHandle, ciphertext: Uint8Array): Promise<{
71
+ plaintext: Uint8Array;
72
+ senderDeviceId: string;
73
+ epoch: bigint;
74
+ }>;
75
+ processWelcome(welcome: Uint8Array): Promise<GroupHandle>;
76
+ processCommit(group: GroupHandle, commit: Uint8Array): Promise<GroupHandle>;
77
+ processProposal(group: GroupHandle, proposal: Uint8Array): Promise<void>;
78
+ exportGroupState(group: GroupHandle): Promise<Uint8Array>;
79
+ importGroupState(state: Uint8Array): Promise<GroupHandle>;
80
+ exportBackup(passphrase: string): Promise<PassphraseBackup>;
81
+ importBackup(passphrase: string, backup: PassphraseBackup): Promise<void>;
82
+ }
@@ -0,0 +1,13 @@
1
+ // The `SecureChatCrypto` seam — the canonical client crypto interface for Agora secure chat.
2
+ //
3
+ // All MLS (RFC 9420) crypto lives CLIENT-side behind this one interface. The Agora server is a
4
+ // blind Delivery Service and depends on none of it — it only relays opaque base64 blobs. The
5
+ // concrete core — ts-mls (pure TS) or OpenMLS compiled to WASM — is a swappable implementation;
6
+ // this abstraction lets that choice be deferred and changed without touching call sites.
7
+ //
8
+ // This package is the home of record for the seam. The agora-server repo consumes it as a
9
+ // (dev)dependency for its integration tests — the server is a CONSUMER of this client crypto, not
10
+ // its owner. Binary is `Uint8Array` IN MEMORY; the network layer base64-encodes at the wire
11
+ // boundary. MLS epochs are u64 → `bigint`.
12
+ export {};
13
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/interface.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,EAAE;AACF,+FAA+F;AAC/F,6FAA6F;AAC7F,gGAAgG;AAChG,yFAAyF;AACzF,EAAE;AACF,0FAA0F;AAC1F,kGAAkG;AAClG,4FAA4F;AAC5F,2CAA2C"}
@@ -0,0 +1,46 @@
1
+ import type { SecureChatCrypto, DeviceIdentity, KeyPackageBundle, GroupHandle, CommitResult, PassphraseBackup, TargetedWelcome } from "./interface";
2
+ export declare class MockSecureChatCrypto implements SecureChatCrypto {
3
+ private identity?;
4
+ private privateState?;
5
+ private groups;
6
+ private kpCounter;
7
+ generateDeviceIdentity(opts: {
8
+ deviceId: string;
9
+ ciphersuite?: number;
10
+ }): Promise<{
11
+ identity: DeviceIdentity;
12
+ privateState: Uint8Array<ArrayBufferLike>;
13
+ }>;
14
+ generateKeyPackages(count: number): Promise<KeyPackageBundle[]>;
15
+ createGroup(opts: {
16
+ mlsGroupId?: Uint8Array;
17
+ initialMembers: {
18
+ deviceId: string;
19
+ keyPackage: Uint8Array;
20
+ }[];
21
+ }): Promise<{
22
+ group: GroupHandle;
23
+ welcomes: TargetedWelcome[];
24
+ }>;
25
+ addMember(group: GroupHandle, newDevice: {
26
+ deviceId: string;
27
+ keyPackage: Uint8Array;
28
+ }): Promise<CommitResult>;
29
+ removeMember(group: GroupHandle, _leafDeviceId: string): Promise<CommitResult>;
30
+ encryptMessage(group: GroupHandle, plaintext: Uint8Array): Promise<{
31
+ ciphertext: Uint8Array;
32
+ epoch: bigint;
33
+ }>;
34
+ decryptMessage(group: GroupHandle, ciphertext: Uint8Array): Promise<{
35
+ plaintext: Uint8Array;
36
+ senderDeviceId: string;
37
+ epoch: bigint;
38
+ }>;
39
+ processWelcome(welcome: Uint8Array): Promise<GroupHandle>;
40
+ processCommit(group: GroupHandle, commit: Uint8Array): Promise<GroupHandle>;
41
+ processProposal(_group: GroupHandle, _proposal: Uint8Array): Promise<void>;
42
+ exportGroupState(group: GroupHandle): Promise<Uint8Array>;
43
+ importGroupState(state: Uint8Array): Promise<GroupHandle>;
44
+ exportBackup(passphrase: string): Promise<PassphraseBackup>;
45
+ importBackup(passphrase: string, backup: PassphraseBackup): Promise<void>;
46
+ }
@@ -0,0 +1,237 @@
1
+ const enc = new TextEncoder();
2
+ const dec = new TextDecoder();
3
+ const BACKUP_MAGIC = "AGORA_MOCK_BACKUP_V1";
4
+ function toHex(b) {
5
+ let s = "";
6
+ for (const x of b)
7
+ s += x.toString(16).padStart(2, "0");
8
+ return s;
9
+ }
10
+ function fromHex(s) {
11
+ const out = new Uint8Array(s.length / 2);
12
+ for (let i = 0; i < out.length; i++)
13
+ out[i] = parseInt(s.slice(i * 2, i * 2 + 2), 16);
14
+ return out;
15
+ }
16
+ /** Deterministic non-zero keystream (FNV-seeded LCG). Non-zero guarantees ciphertext≠plaintext. */
17
+ function keystream(seed, len) {
18
+ let state = 2166136261 >>> 0;
19
+ for (const b of seed)
20
+ state = ((state ^ b) * 16777619) >>> 0;
21
+ const out = new Uint8Array(len);
22
+ for (let i = 0; i < len; i++) {
23
+ state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
24
+ out[i] = (state >>> 24) & 0xff;
25
+ if (out[i] === 0)
26
+ out[i] = 0xa5;
27
+ }
28
+ return out;
29
+ }
30
+ function bytesFrom(s, len) {
31
+ return keystream(enc.encode(s), len);
32
+ }
33
+ function xor(data, key) {
34
+ const out = new Uint8Array(data.length);
35
+ for (let i = 0; i < data.length; i++)
36
+ out[i] = data[i] ^ key[i % key.length];
37
+ return out;
38
+ }
39
+ function jsonBytes(v) {
40
+ return enc.encode(JSON.stringify(v));
41
+ }
42
+ function parseJson(b) {
43
+ return JSON.parse(dec.decode(b));
44
+ }
45
+ export class MockSecureChatCrypto {
46
+ constructor() {
47
+ this.groups = new Map(); // groupIdHex -> state
48
+ this.kpCounter = 0;
49
+ }
50
+ async generateDeviceIdentity(opts) {
51
+ const ciphersuite = opts.ciphersuite ?? 1;
52
+ const identity = {
53
+ deviceId: opts.deviceId,
54
+ signaturePublicKey: bytesFrom(`sig:${opts.deviceId}`, 32),
55
+ credential: enc.encode(opts.deviceId), // mock credential = the device id
56
+ ciphersuite,
57
+ };
58
+ this.identity = identity;
59
+ this.privateState = bytesFrom(`priv:${opts.deviceId}`, 32);
60
+ return { identity, privateState: this.privateState };
61
+ }
62
+ async generateKeyPackages(count) {
63
+ const did = this.identity?.deviceId ?? "unknown";
64
+ const cs = this.identity?.ciphersuite ?? 1;
65
+ const out = [];
66
+ for (let i = 0; i < count; i++) {
67
+ const ref = `${did}:kp:${this.kpCounter++}`;
68
+ out.push({ keyPackageRef: ref, keyPackage: bytesFrom(`kp:${ref}`, 48), ciphersuite: cs });
69
+ }
70
+ return out;
71
+ }
72
+ async createGroup(opts) {
73
+ const did = this.identity?.deviceId ?? "creator";
74
+ const mlsGroupId = opts.mlsGroupId ??
75
+ bytesFrom(`grp:${did}:${opts.initialMembers.map((m) => m.deviceId).join(",")}`, 16);
76
+ const idHex = toHex(mlsGroupId);
77
+ const secret = bytesFrom(`secret:${idHex}:${did}`, 32);
78
+ this.groups.set(idHex, { secret, epoch: 0n });
79
+ const welcomes = opts.initialMembers.map((m) => ({
80
+ targetDeviceId: m.deviceId,
81
+ payload: jsonBytes({
82
+ groupId: idHex,
83
+ secret: toHex(secret),
84
+ epoch: "0",
85
+ }),
86
+ }));
87
+ return { group: { mlsGroupId, epoch: 0n }, welcomes };
88
+ }
89
+ async addMember(group, newDevice) {
90
+ const idHex = toHex(group.mlsGroupId);
91
+ const st = this.groups.get(idHex);
92
+ if (!st)
93
+ throw new Error("mock: unknown group");
94
+ st.epoch += 1n;
95
+ const epoch = st.epoch;
96
+ return {
97
+ commit: jsonBytes({ type: "commit", groupId: idHex, epoch: epoch.toString() }),
98
+ welcomes: [
99
+ {
100
+ targetDeviceId: newDevice.deviceId,
101
+ payload: jsonBytes({
102
+ groupId: idHex,
103
+ secret: toHex(st.secret),
104
+ epoch: epoch.toString(),
105
+ }),
106
+ },
107
+ ],
108
+ epoch,
109
+ };
110
+ }
111
+ async removeMember(group, _leafDeviceId) {
112
+ const idHex = toHex(group.mlsGroupId);
113
+ const st = this.groups.get(idHex);
114
+ if (!st)
115
+ throw new Error("mock: unknown group");
116
+ st.epoch += 1n;
117
+ return {
118
+ commit: jsonBytes({ type: "commit", groupId: idHex, epoch: st.epoch.toString() }),
119
+ welcomes: [],
120
+ epoch: st.epoch,
121
+ };
122
+ }
123
+ async encryptMessage(group, plaintext) {
124
+ const idHex = toHex(group.mlsGroupId);
125
+ const st = this.groups.get(idHex);
126
+ if (!st)
127
+ throw new Error("mock: unknown group");
128
+ const sender = this.identity?.deviceId ?? "unknown";
129
+ const ks = keystream(st.secret, plaintext.length);
130
+ const body = xor(plaintext, ks);
131
+ const header = enc.encode(`${sender}|${st.epoch}|`);
132
+ const ciphertext = new Uint8Array(header.length + body.length);
133
+ ciphertext.set(header, 0);
134
+ ciphertext.set(body, header.length);
135
+ return { ciphertext, epoch: st.epoch };
136
+ }
137
+ async decryptMessage(group, ciphertext) {
138
+ const idHex = toHex(group.mlsGroupId);
139
+ const st = this.groups.get(idHex);
140
+ if (!st)
141
+ throw new Error("mock: unknown group");
142
+ // header = "<deviceId>|<epoch>|" — split on the SECOND pipe.
143
+ let pipes = 0;
144
+ let cut = -1;
145
+ for (let i = 0; i < ciphertext.length; i++) {
146
+ if (ciphertext[i] === 0x7c /* | */) {
147
+ pipes++;
148
+ if (pipes === 2) {
149
+ cut = i + 1;
150
+ break;
151
+ }
152
+ }
153
+ }
154
+ if (cut < 0)
155
+ throw new Error("mock: malformed ciphertext");
156
+ const [senderDeviceId, epochStr] = dec.decode(ciphertext.slice(0, cut - 1)).split("|");
157
+ const body = ciphertext.slice(cut);
158
+ const ks = keystream(st.secret, body.length);
159
+ return {
160
+ plaintext: xor(body, ks),
161
+ senderDeviceId: senderDeviceId ?? "",
162
+ epoch: BigInt(epochStr ?? "0"),
163
+ };
164
+ }
165
+ async processWelcome(welcome) {
166
+ const w = parseJson(welcome);
167
+ this.groups.set(w.groupId, { secret: fromHex(w.secret), epoch: BigInt(w.epoch) });
168
+ return { mlsGroupId: fromHex(w.groupId), epoch: BigInt(w.epoch) };
169
+ }
170
+ async processCommit(group, commit) {
171
+ const c = parseJson(commit);
172
+ const idHex = toHex(group.mlsGroupId);
173
+ const st = this.groups.get(idHex);
174
+ if (st)
175
+ st.epoch = BigInt(c.epoch);
176
+ return { mlsGroupId: group.mlsGroupId, epoch: BigInt(c.epoch) };
177
+ }
178
+ async processProposal(_group, _proposal) {
179
+ /* mock: proposals are no-ops until their Commit arrives */
180
+ }
181
+ async exportGroupState(group) {
182
+ const idHex = toHex(group.mlsGroupId);
183
+ const st = this.groups.get(idHex);
184
+ if (!st)
185
+ throw new Error("mock: unknown group");
186
+ return jsonBytes({ groupId: idHex, secret: toHex(st.secret), epoch: st.epoch.toString() });
187
+ }
188
+ async importGroupState(state) {
189
+ const s = parseJson(state);
190
+ this.groups.set(s.groupId, { secret: fromHex(s.secret), epoch: BigInt(s.epoch) });
191
+ return { mlsGroupId: fromHex(s.groupId), epoch: BigInt(s.epoch) };
192
+ }
193
+ async exportBackup(passphrase) {
194
+ const groups = [...this.groups.entries()].map(([id, st]) => ({
195
+ id,
196
+ secret: toHex(st.secret),
197
+ epoch: st.epoch.toString(),
198
+ }));
199
+ const plain = jsonBytes({
200
+ magic: BACKUP_MAGIC,
201
+ identityPriv: this.privateState ? toHex(this.privateState) : null,
202
+ deviceId: this.identity?.deviceId ?? null,
203
+ groups,
204
+ });
205
+ const salt = bytesFrom(`salt:${passphrase}`, 16);
206
+ const key = keystream(enc.encode(`${passphrase}:${toHex(salt)}`), plain.length);
207
+ return {
208
+ blob: xor(plain, key),
209
+ kdf: "argon2id",
210
+ kdfParams: { salt: toHex(salt), m: 65536, t: 3, p: 1 },
211
+ cipher: "xchacha20poly1305",
212
+ nonce: bytesFrom(`nonce:${passphrase}`, 24),
213
+ version: 1,
214
+ };
215
+ }
216
+ async importBackup(passphrase, backup) {
217
+ const salt = backup.kdfParams.salt ?? toHex(bytesFrom(`salt:${passphrase}`, 16));
218
+ const key = keystream(enc.encode(`${passphrase}:${salt}`), backup.blob.length);
219
+ const plain = xor(backup.blob, key);
220
+ let parsed;
221
+ try {
222
+ parsed = parseJson(plain);
223
+ }
224
+ catch {
225
+ throw new Error("mock: backup decrypt failed (wrong passphrase?)");
226
+ }
227
+ if (parsed.magic !== BACKUP_MAGIC) {
228
+ throw new Error("mock: backup decrypt failed (wrong passphrase?)");
229
+ }
230
+ if (parsed.identityPriv)
231
+ this.privateState = fromHex(parsed.identityPriv);
232
+ for (const g of parsed.groups) {
233
+ this.groups.set(g.id, { secret: fromHex(g.secret), epoch: BigInt(g.epoch) });
234
+ }
235
+ }
236
+ }
237
+ //# sourceMappingURL=mock-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-crypto.js","sourceRoot":"","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 export { MockSecureChatCrypto } from "./mock-crypto";
@@ -0,0 +1,6 @@
1
+ // @agora-sdk/secure-chat-crypto/testing — the deterministic mock, kept off the main entry.
2
+ //
3
+ // NOT cryptographically secure. Use it in tests and early UI work (and the agora-server integration
4
+ // suite consumes it from here). Never ship it as production crypto.
5
+ export { MockSecureChatCrypto } from "./mock-crypto";
6
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../../src/testing.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,oGAAoG;AACpG,oEAAoE;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@agora-sdk/secure-chat-crypto",
3
+ "version": "0.1.1",
4
+ "private": false,
5
+ "license": "Apache-2.0",
6
+ "author": "Agora SDK Plus, maintained by Jenova Marie",
7
+ "description": "The SecureChatCrypto seam for Agora end-to-end-encrypted chat (MLS / RFC 9420): the client crypto interface + a deterministic mock. Dependency-free; the real ts-mls/OpenMLS cores plug in behind the interface.",
8
+ "keywords": [
9
+ "agora",
10
+ "secure-chat",
11
+ "e2ee",
12
+ "mls",
13
+ "rfc9420",
14
+ "crypto",
15
+ "typescript"
16
+ ],
17
+ "bugs": {
18
+ "url": "https://github.com/jenova-marie/agora-sdk-plus/issues"
19
+ },
20
+ "homepage": "https://github.com/jenova-marie/agora-sdk-plus",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/jenova-marie/agora-sdk-plus.git",
24
+ "directory": "packages/secure-chat/crypto"
25
+ },
26
+ "main": "dist/cjs/index.js",
27
+ "module": "dist/esm/index.js",
28
+ "types": "dist/esm/index.d.ts",
29
+ "type": "module",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/esm/index.d.ts",
33
+ "import": "./dist/esm/index.js",
34
+ "require": "./dist/cjs/index.js"
35
+ },
36
+ "./testing": {
37
+ "types": "./dist/esm/testing.d.ts",
38
+ "import": "./dist/esm/testing.js",
39
+ "require": "./dist/cjs/testing.js"
40
+ }
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "scripts": {
49
+ "build:esm": "tsc -p tsconfig.esm.json",
50
+ "build:cjs": "tsc -p tsconfig.cjs.json",
51
+ "build": "rimraf dist && pnpm run build:esm && pnpm run build:cjs",
52
+ "prepublish": "pnpm run build"
53
+ }
54
+ }