@novasamatech/host-chat 0.10.1 → 0.10.2
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-chat",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.2",
|
|
5
5
|
"description": "Host statement store chat integration",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"README.md"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@novasamatech/host-papp": "0.10.
|
|
41
|
-
"@novasamatech/scale": "0.10.
|
|
42
|
-
"@novasamatech/statement-store": "0.10.
|
|
43
|
-
"@novasamatech/storage-adapter": "0.10.
|
|
40
|
+
"@novasamatech/host-papp": "0.10.2",
|
|
41
|
+
"@novasamatech/scale": "0.10.2",
|
|
42
|
+
"@novasamatech/statement-store": "0.10.2",
|
|
43
|
+
"@novasamatech/storage-adapter": "0.10.2",
|
|
44
44
|
"nanoid": "6.0.1",
|
|
45
45
|
"neverthrow": "^8.2.0",
|
|
46
46
|
"polkadot-api": ">=3"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `Resources.Consumers.identifier_key` — a peer's chat encryption key as the chain
|
|
3
|
-
* records it (CHAT-RFC-0004 §4).
|
|
4
|
-
*
|
|
5
|
-
* The 65-byte width predates X25519: it is what an uncompressed P-256 point occupied,
|
|
6
|
-
* and it stayed when the curve changed. Only the keypair type and the key width moved
|
|
7
|
-
* (0x04 + 64 → 0x00 + 32), so the field is still `SizedHex<65>` in runtime metadata.
|
|
8
|
-
*
|
|
9
|
-
* Padding is carried as a field because the RFC requires readers to ignore it rather
|
|
10
|
-
* than validate it. Decoding throws on a keypair type this SDK does not implement —
|
|
11
|
-
* `decodeIdentifierKey` in `accountService.ts` maps that to `null`, since a peer on a
|
|
12
|
-
* curve we can't encrypt to is a normal condition, not a fault.
|
|
13
|
-
*/
|
|
14
|
-
export declare const IdentifierKey: import("scale-ts").Codec<{
|
|
15
|
-
tag: "X25519";
|
|
16
|
-
value: {
|
|
17
|
-
key: Uint8Array<ArrayBufferLike>;
|
|
18
|
-
padding: Uint8Array<ArrayBufferLike>;
|
|
19
|
-
};
|
|
20
|
-
}>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Bytes, Enum } from '@novasamatech/scale';
|
|
2
|
-
import { Struct } from 'scale-ts';
|
|
3
|
-
/**
|
|
4
|
-
* `Resources.Consumers.identifier_key` — a peer's chat encryption key as the chain
|
|
5
|
-
* records it (CHAT-RFC-0004 §4).
|
|
6
|
-
*
|
|
7
|
-
* The 65-byte width predates X25519: it is what an uncompressed P-256 point occupied,
|
|
8
|
-
* and it stayed when the curve changed. Only the keypair type and the key width moved
|
|
9
|
-
* (0x04 + 64 → 0x00 + 32), so the field is still `SizedHex<65>` in runtime metadata.
|
|
10
|
-
*
|
|
11
|
-
* Padding is carried as a field because the RFC requires readers to ignore it rather
|
|
12
|
-
* than validate it. Decoding throws on a keypair type this SDK does not implement —
|
|
13
|
-
* `decodeIdentifierKey` in `accountService.ts` maps that to `null`, since a peer on a
|
|
14
|
-
* curve we can't encrypt to is a normal condition, not a fault.
|
|
15
|
-
*/
|
|
16
|
-
export const IdentifierKey = Enum({
|
|
17
|
-
X25519: Struct({ key: Bytes(32), padding: Bytes(32) }),
|
|
18
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { IdentifierKey } from './identifierKey.js';
|
|
3
|
-
// CHAT-RFC-0004 §4 container: keypair-type byte ++ key(32) ++ padding(32). Built by
|
|
4
|
-
// hand rather than through the codec — encoding with the thing under test would assert
|
|
5
|
-
// it agrees with itself, not with the RFC. Matches Android `AccountEcdhKeyScaleTest`.
|
|
6
|
-
const container = (keypairType, key, padding = new Uint8Array(32)) => {
|
|
7
|
-
const out = new Uint8Array(65);
|
|
8
|
-
out[0] = keypairType;
|
|
9
|
-
out.set(key, 1);
|
|
10
|
-
out.set(padding, 33);
|
|
11
|
-
return out;
|
|
12
|
-
};
|
|
13
|
-
const KEY = new Uint8Array(32).fill(0xab);
|
|
14
|
-
describe('IdentifierKey', () => {
|
|
15
|
-
it('reads the x25519 key out of the container', () => {
|
|
16
|
-
expect(IdentifierKey.dec(container(0x00, KEY)).value.key).toStrictEqual(KEY);
|
|
17
|
-
});
|
|
18
|
-
it('ignores the padding, as the RFC requires', () => {
|
|
19
|
-
expect(IdentifierKey.dec(container(0x00, KEY, new Uint8Array(32).fill(0x7f))).value.key).toStrictEqual(KEY);
|
|
20
|
-
});
|
|
21
|
-
it('round-trips', () => {
|
|
22
|
-
const value = { tag: 'X25519', value: { key: KEY, padding: new Uint8Array(32) } };
|
|
23
|
-
expect(IdentifierKey.enc(value)).toStrictEqual(container(0x00, KEY));
|
|
24
|
-
expect(IdentifierKey.dec(IdentifierKey.enc(value))).toStrictEqual(value);
|
|
25
|
-
});
|
|
26
|
-
it('rejects a keypair type this SDK does not implement', () => {
|
|
27
|
-
expect(() => IdentifierKey.dec(container(0x04, KEY))).toThrow();
|
|
28
|
-
});
|
|
29
|
-
// The container width is not the key width — reading the field as a bare X25519 key
|
|
30
|
-
// is what broke peer lookup for every account.
|
|
31
|
-
it('rejects a bare 32-byte key', () => {
|
|
32
|
-
expect(() => IdentifierKey.dec(KEY)).toThrow();
|
|
33
|
-
});
|
|
34
|
-
});
|