cojson 0.4.1 → 0.4.5

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 (67) hide show
  1. package/dist/coValue.js +1 -1
  2. package/dist/coValue.js.map +1 -1
  3. package/dist/coValues/coList.js +1 -1
  4. package/dist/coValues/coList.js.map +1 -1
  5. package/dist/coValues/coMap.js +1 -1
  6. package/dist/coValues/coMap.js.map +1 -1
  7. package/dist/coValues/coStream.js +1 -1
  8. package/dist/coValues/coStream.js.map +1 -1
  9. package/dist/coValues/group.js.map +1 -1
  10. package/dist/index.js +2 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/localNode.js +1 -14
  13. package/dist/localNode.js.map +1 -1
  14. package/package.json +4 -4
  15. package/src/coValue.ts +10 -7
  16. package/src/coValues/coList.ts +1 -1
  17. package/src/coValues/coMap.ts +1 -1
  18. package/src/coValues/coStream.ts +1 -3
  19. package/src/coValues/group.ts +4 -4
  20. package/src/index.ts +16 -16
  21. package/src/localNode.ts +6 -47
  22. package/src/tests/coValue.test.ts +5 -5
  23. package/src/tests/group.test.ts +1 -1
  24. package/dist/base64url.d.ts +0 -2
  25. package/dist/coValue.d.ts +0 -38
  26. package/dist/coValueCore.d.ts +0 -103
  27. package/dist/coValues/account.d.ts +0 -62
  28. package/dist/coValues/coList.d.ts +0 -179
  29. package/dist/coValues/coMap.d.ts +0 -149
  30. package/dist/coValues/coStream.d.ts +0 -123
  31. package/dist/coValues/group.d.ts +0 -111
  32. package/dist/crypto.d.ts +0 -120
  33. package/dist/ids.d.ts +0 -11
  34. package/dist/index.d.ts +0 -67
  35. package/dist/jsonStringify.d.ts +0 -6
  36. package/dist/jsonValue.d.ts +0 -7
  37. package/dist/localNode.d.ts +0 -101
  38. package/dist/media.d.ts +0 -7
  39. package/dist/permissions.d.ts +0 -20
  40. package/dist/queriedCoValues/queriedAccount.d.ts +0 -13
  41. package/dist/queriedCoValues/queriedAccount.js +0 -24
  42. package/dist/queriedCoValues/queriedAccount.js.map +0 -1
  43. package/dist/queriedCoValues/queriedCoList.d.ts +0 -66
  44. package/dist/queriedCoValues/queriedCoList.js +0 -116
  45. package/dist/queriedCoValues/queriedCoList.js.map +0 -1
  46. package/dist/queriedCoValues/queriedCoMap.d.ts +0 -40
  47. package/dist/queriedCoValues/queriedCoMap.js +0 -82
  48. package/dist/queriedCoValues/queriedCoMap.js.map +0 -1
  49. package/dist/queriedCoValues/queriedCoStream.d.ts +0 -36
  50. package/dist/queriedCoValues/queriedCoStream.js +0 -97
  51. package/dist/queriedCoValues/queriedCoStream.js.map +0 -1
  52. package/dist/queriedCoValues/queriedGroup.d.ts +0 -29
  53. package/dist/queriedCoValues/queriedGroup.js +0 -54
  54. package/dist/queriedCoValues/queriedGroup.js.map +0 -1
  55. package/dist/queries.d.ts +0 -62
  56. package/dist/queries.js +0 -142
  57. package/dist/queries.js.map +0 -1
  58. package/dist/streamUtils.d.ts +0 -8
  59. package/dist/sync.d.ts +0 -80
  60. package/dist/tests/testUtils.d.ts +0 -37
  61. package/src/queriedCoValues/queriedAccount.ts +0 -40
  62. package/src/queriedCoValues/queriedCoList.ts +0 -240
  63. package/src/queriedCoValues/queriedCoMap.ts +0 -168
  64. package/src/queriedCoValues/queriedCoStream.ts +0 -151
  65. package/src/queriedCoValues/queriedGroup.ts +0 -90
  66. package/src/queries.ts +0 -263
  67. package/src/tests/queries.test.ts +0 -398
@@ -1,149 +0,0 @@
1
- import { JsonObject, JsonValue } from "../jsonValue.js";
2
- import { AgentID, TransactionID } from "../ids.js";
3
- import { CoID, CoValue } from "../coValue.js";
4
- import { CoValueCore } from "../coValueCore.js";
5
- import { AccountID } from "./account.js";
6
- import { Group } from "./group.js";
7
- type MapOp<K extends string, V extends JsonValue | undefined> = {
8
- txID: TransactionID;
9
- madeAt: number;
10
- changeIdx: number;
11
- } & MapOpPayload<K, V>;
12
- export type MapOpPayload<K extends string, V extends JsonValue | undefined> = {
13
- op: "set";
14
- key: K;
15
- value: V;
16
- } | {
17
- op: "del";
18
- key: K;
19
- };
20
- export declare class CoMapView<Shape extends {
21
- [key: string]: JsonValue | undefined;
22
- } = {
23
- [key: string]: JsonValue | undefined;
24
- }, Meta extends JsonObject | null = JsonObject | null> implements CoValue {
25
- /** @category 6. Meta */
26
- id: CoID<this>;
27
- /** @category 6. Meta */
28
- type: "comap";
29
- /** @category 6. Meta */
30
- core: CoValueCore;
31
- /** @internal */
32
- ops: {
33
- [Key in keyof Shape & string]?: MapOp<Key, Shape[Key]>[];
34
- };
35
- /** @internal */
36
- atTimeFilter?: number;
37
- /** @category 6. Meta */
38
- readonly _shape: Shape;
39
- /** @internal */
40
- constructor(core: CoValueCore, options?: {
41
- ignorePrivateTransactions: true;
42
- });
43
- /** @category 6. Meta */
44
- get meta(): Meta;
45
- /** @category 6. Meta */
46
- get group(): Group;
47
- /** @category 4. Time travel */
48
- atTime(time: number): this;
49
- /** @internal */
50
- timeFilteredOps<K extends keyof Shape & string>(key: K): MapOp<K, Shape[K]>[] | undefined;
51
- /**
52
- * Get all keys currently in the map.
53
- *
54
- * @category 1. Reading */
55
- keys<K extends (keyof Shape & string) = (keyof Shape & string)>(): K[];
56
- /**
57
- * Returns the current value for the given key.
58
- *
59
- * @category 1. Reading
60
- **/
61
- get<K extends keyof Shape & string>(key: K): Shape[K] | undefined;
62
- /** @category 1. Reading */
63
- asObject(): {
64
- [K in keyof Shape & string]: Shape[K];
65
- };
66
- /** @category 1. Reading */
67
- toJSON(): {
68
- [K in keyof Shape & string]: Shape[K];
69
- };
70
- /** @category 5. Edit history */
71
- nthEditAt<K extends keyof Shape & string>(key: K, n: number): {
72
- by: AccountID | AgentID;
73
- tx: TransactionID;
74
- at: Date;
75
- value?: Shape[K];
76
- } | undefined;
77
- /** @category 5. Edit history */
78
- lastEditAt<K extends keyof Shape & string>(key: K): {
79
- by: AccountID | AgentID;
80
- tx: TransactionID;
81
- at: Date;
82
- value?: Shape[K];
83
- } | undefined;
84
- /** @category 5. Edit history */
85
- editsAt<K extends keyof Shape & string>(key: K): Generator<{
86
- by: AccountID | `sealer_z${string}/signer_z${string}`;
87
- tx: TransactionID;
88
- at: Date;
89
- value?: Shape[K] | undefined;
90
- }, void, unknown>;
91
- /** @category 3. Subscription */
92
- subscribe(listener: (coMap: this) => void): () => void;
93
- }
94
- /** A collaborative map with precise shape `Shape` and optional static metadata `Meta` */
95
- export declare class CoMap<Shape extends {
96
- [key: string]: JsonValue | undefined;
97
- } = {
98
- [key: string]: JsonValue | undefined;
99
- }, Meta extends JsonObject | null = JsonObject | null> extends CoMapView<Shape, Meta> implements CoValue {
100
- /** Returns a new version of this CoMap with a new value for the given key.
101
- *
102
- * If `privacy` is `"private"` **(default)**, both `key` and `value` are encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
103
- *
104
- * If `privacy` is `"trusting"`, both `key` and `value` are stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
105
- *
106
- * @category 2. Editing
107
- **/
108
- set<K extends keyof Shape & string>(key: K, value: Shape[K], privacy?: "private" | "trusting"): this;
109
- set(kv: {
110
- [K in keyof Shape & string]?: Shape[K];
111
- }, privacy?: "private" | "trusting"): this;
112
- /** Returns a new version of this CoMap with the given key deleted (setting it to undefined).
113
- *
114
- * If `privacy` is `"private"` **(default)**, `key` is encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
115
- *
116
- * If `privacy` is `"trusting"`, `key` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
117
- *
118
- * @category 2. Editing
119
- **/
120
- delete(key: keyof Shape & string, privacy?: "private" | "trusting"): this;
121
- /** @category 2. Editing */
122
- mutate(mutator: (mutable: MutableCoMap<Shape, Meta>) => void): this;
123
- /** @deprecated Use `mutate` instead. */
124
- edit(mutator: (mutable: MutableCoMap<Shape, Meta>) => void): this;
125
- }
126
- export declare class MutableCoMap<Shape extends {
127
- [key: string]: JsonValue | undefined;
128
- } = {
129
- [key: string]: JsonValue | undefined;
130
- }, Meta extends JsonObject | null = JsonObject | null> extends CoMapView<Shape, Meta> implements CoValue {
131
- /** Sets a new value for the given key.
132
- *
133
- * If `privacy` is `"private"` **(default)**, both `key` and `value` are encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
134
- *
135
- * If `privacy` is `"trusting"`, both `key` and `value` are stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
136
- *
137
- * @category 2. Mutation
138
- */
139
- set<K extends keyof Shape & string>(key: K, value: Shape[K], privacy?: "private" | "trusting"): void;
140
- /** Deletes the value for the given key (setting it to undefined).
141
- *
142
- * If `privacy` is `"private"` **(default)**, `key` is encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
143
- *
144
- * If `privacy` is `"trusting"`, `key` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
145
- * @category 2. Mutation
146
- */
147
- delete(key: keyof Shape & string, privacy?: "private" | "trusting"): void;
148
- }
149
- export {};
@@ -1,123 +0,0 @@
1
- import { JsonObject, JsonValue } from "../jsonValue.js";
2
- import { CoValue, CoID } from "../coValue.js";
3
- import { CoValueCore } from "../coValueCore.js";
4
- import { Group } from "./group.js";
5
- import { AgentID, SessionID, TransactionID } from "../ids.js";
6
- import { AccountID } from "./account.js";
7
- export type BinaryStreamInfo = {
8
- mimeType: string;
9
- fileName?: string;
10
- totalSizeBytes?: number;
11
- };
12
- export type BinaryStreamStart = {
13
- type: "start";
14
- } & BinaryStreamInfo;
15
- export type BinaryStreamChunk = {
16
- type: "chunk";
17
- chunk: `binary_U${string}`;
18
- };
19
- export type BinaryStreamEnd = {
20
- type: "end";
21
- };
22
- export type BinaryCoStreamMeta = JsonObject & {
23
- type: "binary";
24
- };
25
- export type BinaryStreamItem = BinaryStreamStart | BinaryStreamChunk | BinaryStreamEnd;
26
- export type CoStreamItem<Item extends JsonValue> = {
27
- value: Item;
28
- tx: TransactionID;
29
- madeAt: number;
30
- };
31
- export declare class CoStreamView<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> implements CoValue {
32
- id: CoID<this>;
33
- type: "costream";
34
- core: CoValueCore;
35
- items: {
36
- [key: SessionID]: CoStreamItem<Item>[];
37
- };
38
- readonly _item: Item;
39
- constructor(core: CoValueCore);
40
- get meta(): Meta;
41
- get group(): Group;
42
- /** Not yet implemented */
43
- atTime(_time: number): this;
44
- /** @internal */
45
- protected fillFromCoValue(): void;
46
- getSingleStream(): (Item)[] | undefined;
47
- sessions(): SessionID[];
48
- accounts(): Set<AccountID>;
49
- nthItemIn(sessionID: SessionID, n: number): {
50
- by: AccountID | AgentID;
51
- tx: TransactionID;
52
- at: Date;
53
- value: Item;
54
- } | undefined;
55
- lastItemIn(sessionID: SessionID): {
56
- by: AccountID | AgentID;
57
- tx: TransactionID;
58
- at: Date;
59
- value: Item;
60
- } | undefined;
61
- itemsIn(sessionID: SessionID): Generator<{
62
- by: AccountID | `sealer_z${string}/signer_z${string}`;
63
- tx: TransactionID;
64
- at: Date;
65
- value: Item;
66
- }, void, unknown>;
67
- lastItemBy(account: AccountID | AgentID): {
68
- by: AccountID | AgentID;
69
- tx: TransactionID;
70
- at: Date;
71
- value: Item;
72
- } | undefined;
73
- itemsBy(account: AccountID | AgentID): Generator<{
74
- by: AccountID | `sealer_z${string}/signer_z${string}`;
75
- tx: TransactionID;
76
- at: Date;
77
- value: Item;
78
- in: `co_z${string}_session_z${string}` | `sealer_z${string}/signer_z${string}_session_z${string}`;
79
- }, void, unknown>;
80
- toJSON(): {
81
- [key: SessionID]: (Item)[];
82
- };
83
- subscribe(listener: (coStream: this) => void): () => void;
84
- }
85
- export declare class CoStream<Item extends JsonValue = JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoStreamView<Item, Meta> implements CoValue {
86
- push(item: Item, privacy?: "private" | "trusting"): this;
87
- mutate(mutator: (mutable: MutableCoStream<Item, Meta>) => void): this;
88
- /** @deprecated Use `mutate` instead. */
89
- edit(mutator: (mutable: MutableCoStream<Item, Meta>) => void): this;
90
- }
91
- export declare class MutableCoStream<Item extends JsonValue, Meta extends JsonObject | null = JsonObject | null> extends CoStreamView<Item, Meta> implements CoValue {
92
- push(item: Item, privacy?: "private" | "trusting"): void;
93
- }
94
- export declare class BinaryCoStreamView<Meta extends BinaryCoStreamMeta = {
95
- type: "binary";
96
- }> extends CoStreamView<BinaryStreamItem, Meta> implements CoValue {
97
- id: CoID<this>;
98
- getBinaryChunks(allowUnfinished?: boolean): (BinaryStreamInfo & {
99
- chunks: Uint8Array[];
100
- finished: boolean;
101
- }) | undefined;
102
- }
103
- export declare class BinaryCoStream<Meta extends BinaryCoStreamMeta = {
104
- type: "binary";
105
- }> extends BinaryCoStreamView<Meta> implements CoValue {
106
- /** @internal */
107
- push(item: BinaryStreamItem, privacy?: "private" | "trusting"): this;
108
- startBinaryStream(settings: BinaryStreamInfo, privacy?: "private" | "trusting"): this;
109
- pushBinaryStreamChunk(chunk: Uint8Array, privacy?: "private" | "trusting"): this;
110
- endBinaryStream(privacy?: "private" | "trusting"): this;
111
- mutate(mutator: (mutable: MutableBinaryCoStream<Meta>) => void): this;
112
- /** @deprecated Use `mutate` instead. */
113
- edit(mutator: (mutable: MutableBinaryCoStream<Meta>) => void): this;
114
- }
115
- export declare class MutableBinaryCoStream<Meta extends BinaryCoStreamMeta = {
116
- type: "binary";
117
- }> extends BinaryCoStreamView<Meta> implements CoValue {
118
- /** @internal */
119
- push(item: BinaryStreamItem, privacy?: "private" | "trusting"): void;
120
- startBinaryStream(settings: BinaryStreamInfo, privacy?: "private" | "trusting"): void;
121
- pushBinaryStreamChunk(chunk: Uint8Array, privacy?: "private" | "trusting"): void;
122
- endBinaryStream(privacy?: "private" | "trusting"): void;
123
- }
@@ -1,111 +0,0 @@
1
- import { CoID, CoValue } from "../coValue.js";
2
- import { CoMap } from "./coMap.js";
3
- import { CoList } from "./coList.js";
4
- import { JsonObject } from "../jsonValue.js";
5
- import { BinaryCoStream, CoStream } from "./coStream.js";
6
- import { Encrypted, KeyID, KeySecret, Sealed } from "../crypto.js";
7
- import { AgentID } from "../ids.js";
8
- import { AccountID, Profile } from "./account.js";
9
- import { Role } from "../permissions.js";
10
- export declare const EVERYONE: "everyone";
11
- export type Everyone = "everyone";
12
- export type GroupShape<P extends Profile, R extends CoMap> = {
13
- profile?: CoID<P> | null;
14
- root?: CoID<R> | null;
15
- [key: AccountID | AgentID]: Role;
16
- [EVERYONE]?: Role;
17
- readKey?: KeyID;
18
- [revelationFor: `${KeyID}_for_${AccountID | AgentID}`]: Sealed<KeySecret>;
19
- [revelationFor: `${KeyID}_for_${Everyone}`]: KeySecret;
20
- [oldKeyForNewKey: `${KeyID}_for_${KeyID}`]: Encrypted<KeySecret, {
21
- encryptedID: KeyID;
22
- encryptingID: KeyID;
23
- }>;
24
- };
25
- export declare function expectGroup(content: CoValue): Group;
26
- /** A `Group` is a scope for permissions of its members (`"reader" | "writer" | "admin"`), applying to objects owned by that group.
27
- *
28
- * A `Group` object exposes methods for permission management and allows you to create new CoValues owned by that group.
29
- *
30
- * (Internally, a `Group` is also just a `CoMap`, mapping member accounts to roles and containing some
31
- * state management for making cryptographic keys available to current members)
32
- *
33
- * @example
34
- * You typically get a group from a CoValue that you already have loaded:
35
- *
36
- * ```typescript
37
- * const group = coMap.group;
38
- * ```
39
- *
40
- * @example
41
- * Or, you can create a new group with a `LocalNode`:
42
- *
43
- * ```typescript
44
- * const localNode.createGroup();
45
- * ```
46
- * */
47
- export declare class Group<P extends Profile = Profile, R extends CoMap = CoMap, Meta extends JsonObject | null = JsonObject | null> extends CoMap<GroupShape<P, R>, Meta> {
48
- /**
49
- * Returns the current role of a given account.
50
- *
51
- * @category 1. Role reading
52
- */
53
- roleOf(accountID: AccountID): Role | undefined;
54
- /** @internal */
55
- roleOfInternal(accountID: AccountID | AgentID): Role | undefined;
56
- /**
57
- * Returns the role of the current account in the group.
58
- *
59
- * @category 1. Role reading
60
- */
61
- myRole(): Role | undefined;
62
- /**
63
- * Directly grants a new member a role in the group. The current account must be an
64
- * admin to be able to do so. Throws otherwise.
65
- *
66
- * @category 2. Role changing
67
- */
68
- addMember(accountID: AccountID | Everyone, role: Role): this;
69
- /** @internal */
70
- addMemberInternal(accountID: AccountID | AgentID | Everyone, role: Role): this;
71
- /** @internal */
72
- rotateReadKey(): this;
73
- /**
74
- * Strips the specified member of all roles (preventing future writes in
75
- * the group and owned values) and rotates the read encryption key for that group
76
- * (preventing reads of new content in the group and owned values)
77
- *
78
- * @category 2. Role changing
79
- */
80
- removeMember(accountID: AccountID): this;
81
- /** @internal */
82
- removeMemberInternal(accountID: AccountID | AgentID): this;
83
- /**
84
- * Creates an invite for new members to indirectly join the group,
85
- * allowing them to grant themselves the specified role with the InviteSecret
86
- * (a string starting with "inviteSecret_") - use `LocalNode.acceptInvite()` for this purpose.
87
- *
88
- * @category 2. Role changing
89
- */
90
- createInvite(role: "reader" | "writer" | "admin"): InviteSecret;
91
- /**
92
- * Creates a new `CoMap` within this group, with the specified specialized
93
- * `CoMap` type `M` and optional static metadata.
94
- *
95
- * @category 3. Value creation
96
- */
97
- createMap<M extends CoMap>(init?: M["_shape"], meta?: M["meta"], initPrivacy?: "trusting" | "private"): M;
98
- /**
99
- * Creates a new `CoList` within this group, with the specified specialized
100
- * `CoList` type `L` and optional static metadata.
101
- *
102
- * @category 3. Value creation
103
- */
104
- createList<L extends CoList>(init?: L["_item"][], meta?: L["meta"], initPrivacy?: "trusting" | "private"): L;
105
- /** @category 3. Value creation */
106
- createStream<C extends CoStream>(meta?: C["meta"]): C;
107
- /** @category 3. Value creation */
108
- createBinaryStream<C extends BinaryCoStream>(meta?: C["meta"]): C;
109
- }
110
- export type InviteSecret = `inviteSecret_z${string}`;
111
- export declare function secretSeedFromInviteSecret(inviteSecret: InviteSecret): Uint8Array;
package/dist/crypto.d.ts DELETED
@@ -1,120 +0,0 @@
1
- import { JsonValue } from "./jsonValue.js";
2
- import { AgentID, RawCoID, TransactionID } from "./ids.js";
3
- import { Stringified } from "./jsonStringify.js";
4
- export declare const cryptoReady: Promise<void>;
5
- export type SignerSecret = `signerSecret_z${string}`;
6
- export type SignerID = `signer_z${string}`;
7
- export type Signature = `signature_z${string}`;
8
- export type SealerSecret = `sealerSecret_z${string}`;
9
- export type SealerID = `sealer_z${string}`;
10
- export type Sealed<T> = `sealed_U${string}` & {
11
- __type: T;
12
- };
13
- export type AgentSecret = `${SealerSecret}/${SignerSecret}`;
14
- export declare function newRandomSigner(): SignerSecret;
15
- export declare function signerSecretToBytes(secret: SignerSecret): Uint8Array;
16
- export declare function signerSecretFromBytes(bytes: Uint8Array): SignerSecret;
17
- export declare function getSignerID(secret: SignerSecret): SignerID;
18
- export declare function sign(secret: SignerSecret, message: JsonValue): Signature;
19
- export declare function verify(signature: Signature, message: JsonValue, id: SignerID): boolean;
20
- export declare function newRandomSealer(): SealerSecret;
21
- export declare function sealerSecretToBytes(secret: SealerSecret): Uint8Array;
22
- export declare function sealerSecretFromBytes(bytes: Uint8Array): SealerSecret;
23
- export declare function getSealerID(secret: SealerSecret): SealerID;
24
- export declare function newRandomAgentSecret(): AgentSecret;
25
- export declare function agentSecretToBytes(secret: AgentSecret): Uint8Array;
26
- export declare function agentSecretFromBytes(bytes: Uint8Array): AgentSecret;
27
- export declare function getAgentID(secret: AgentSecret): AgentID;
28
- export declare function getAgentSignerID(agentId: AgentID): SignerID;
29
- export declare function getAgentSignerSecret(agentSecret: AgentSecret): SignerSecret;
30
- export declare function getAgentSealerID(agentId: AgentID): SealerID;
31
- export declare function getAgentSealerSecret(agentSecret: AgentSecret): SealerSecret;
32
- export declare function seal<T extends JsonValue>({ message, from, to, nOnceMaterial, }: {
33
- message: T;
34
- from: SealerSecret;
35
- to: SealerID;
36
- nOnceMaterial: {
37
- in: RawCoID;
38
- tx: TransactionID;
39
- };
40
- }): Sealed<T>;
41
- export declare function unseal<T extends JsonValue>(sealed: Sealed<T>, sealer: SealerSecret, from: SealerID, nOnceMaterial: {
42
- in: RawCoID;
43
- tx: TransactionID;
44
- }): T | undefined;
45
- export type Hash = `hash_z${string}`;
46
- export declare function secureHash(value: JsonValue): Hash;
47
- export declare class StreamingHash {
48
- state: Uint8Array;
49
- constructor(fromClone?: Uint8Array);
50
- update(value: JsonValue): void;
51
- digest(): Hash;
52
- clone(): StreamingHash;
53
- }
54
- export type ShortHash = `shortHash_z${string}`;
55
- export declare const shortHashLength = 19;
56
- export declare function shortHash(value: JsonValue): ShortHash;
57
- export type Encrypted<T extends JsonValue, N extends JsonValue> = `encrypted_U${string}` & {
58
- __type: T;
59
- __nOnceMaterial: N;
60
- };
61
- export type KeySecret = `keySecret_z${string}`;
62
- export type KeyID = `key_z${string}`;
63
- export declare function newRandomKeySecret(): {
64
- secret: KeySecret;
65
- id: KeyID;
66
- };
67
- export declare function encryptForTransaction<T extends JsonValue>(value: T, keySecret: KeySecret, nOnceMaterial: {
68
- in: RawCoID;
69
- tx: TransactionID;
70
- }): Encrypted<T, {
71
- in: RawCoID;
72
- tx: TransactionID;
73
- }>;
74
- export declare function encryptKeySecret(keys: {
75
- toEncrypt: {
76
- id: KeyID;
77
- secret: KeySecret;
78
- };
79
- encrypting: {
80
- id: KeyID;
81
- secret: KeySecret;
82
- };
83
- }): {
84
- encryptedID: KeyID;
85
- encryptingID: KeyID;
86
- encrypted: Encrypted<KeySecret, {
87
- encryptedID: KeyID;
88
- encryptingID: KeyID;
89
- }>;
90
- };
91
- export declare function decryptRawForTransaction<T extends JsonValue>(encrypted: Encrypted<T, {
92
- in: RawCoID;
93
- tx: TransactionID;
94
- }>, keySecret: KeySecret, nOnceMaterial: {
95
- in: RawCoID;
96
- tx: TransactionID;
97
- }): Stringified<T> | undefined;
98
- export declare function decryptForTransaction<T extends JsonValue>(encrypted: Encrypted<T, {
99
- in: RawCoID;
100
- tx: TransactionID;
101
- }>, keySecret: KeySecret, nOnceMaterial: {
102
- in: RawCoID;
103
- tx: TransactionID;
104
- }): T | undefined;
105
- export declare function decryptKeySecret(encryptedInfo: {
106
- encryptedID: KeyID;
107
- encryptingID: KeyID;
108
- encrypted: Encrypted<KeySecret, {
109
- encryptedID: KeyID;
110
- encryptingID: KeyID;
111
- }>;
112
- }, sealingSecret: KeySecret): KeySecret | undefined;
113
- export declare function uniquenessForHeader(): `z${string}`;
114
- export declare function createdNowUnique(): {
115
- createdAt: `2${string}`;
116
- uniqueness: `z${string}`;
117
- };
118
- export declare const secretSeedLength = 32;
119
- export declare function newRandomSecretSeed(): Uint8Array;
120
- export declare function agentSecretFromSecretSeed(secretSeed: Uint8Array): AgentSecret;
package/dist/ids.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { AccountID } from './coValues/account.js';
2
- export type RawCoID = `co_z${string}`;
3
- export declare function rawCoIDtoBytes(id: RawCoID): Uint8Array;
4
- export declare function rawCoIDfromBytes(bytes: Uint8Array): RawCoID;
5
- export type TransactionID = {
6
- sessionID: SessionID;
7
- txIndex: number;
8
- };
9
- export type AgentID = `sealer_z${string}/signer_z${string}`;
10
- export declare function isAgentID(id: string): id is AgentID;
11
- export type SessionID = `${AccountID | AgentID}_session_z${string}`;
package/dist/index.d.ts DELETED
@@ -1,67 +0,0 @@
1
- import { CoValueCore, newRandomSessionID, MAX_RECOMMENDED_TX_SIZE, accountOrAgentIDfromSessionID } from "./coValueCore.js";
2
- import { LocalNode } from "./localNode.js";
3
- import type { CoValue } from "./coValue.js";
4
- import { CoMap, MutableCoMap } from "./coValues/coMap.js";
5
- import { CoList, MutableCoList } from "./coValues/coList.js";
6
- import { CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream } from "./coValues/coStream.js";
7
- import { agentSecretFromBytes, agentSecretToBytes, getAgentID, newRandomAgentSecret, newRandomSecretSeed, agentSecretFromSecretSeed, cryptoReady } from "./crypto.js";
8
- import { connectedPeers } from "./streamUtils.js";
9
- import { AnonymousControlledAccount, ControlledAccount } from "./coValues/account.js";
10
- import { rawCoIDtoBytes, rawCoIDfromBytes } from "./ids.js";
11
- import { Group, expectGroup, EVERYONE } from "./coValues/group.js";
12
- import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
13
- import { parseJSON } from "./jsonStringify.js";
14
- import { Account, Profile, isAccountID } from "./coValues/account.js";
15
- import type { SessionID, AgentID } from "./ids.js";
16
- import type { CoID, AnyCoValue } from "./coValue.js";
17
- import type { Queried, QueryExtension } from "./queries.js";
18
- import type { QueriedCoStream } from "./queriedCoValues/queriedCoStream.js";
19
- import type { QueriedCoList } from "./queriedCoValues/queriedCoList.js";
20
- import type { QueriedCoMap } from "./queriedCoValues/queriedCoMap.js";
21
- import { QueriedAccount } from "./queriedCoValues/queriedAccount.js";
22
- import { QueriedGroup } from "./queriedCoValues/queriedGroup.js";
23
- import type { BinaryStreamInfo, BinaryCoStreamMeta } from "./coValues/coStream.js";
24
- import type { JsonValue } from "./jsonValue.js";
25
- import type { SyncMessage, Peer } from "./sync.js";
26
- import type { AgentSecret } from "./crypto.js";
27
- import type { AccountID, AccountMeta, AccountMigration, ProfileMeta } from "./coValues/account.js";
28
- import type { InviteSecret } from "./coValues/group.js";
29
- import type * as Media from "./media.js";
30
- type Value = JsonValue | AnyCoValue;
31
- /** @hidden */
32
- export declare const cojsonInternals: {
33
- agentSecretFromBytes: typeof agentSecretFromBytes;
34
- agentSecretToBytes: typeof agentSecretToBytes;
35
- newRandomSessionID: typeof newRandomSessionID;
36
- newRandomAgentSecret: typeof newRandomAgentSecret;
37
- connectedPeers: typeof connectedPeers;
38
- getAgentID: typeof getAgentID;
39
- rawCoIDtoBytes: typeof rawCoIDtoBytes;
40
- rawCoIDfromBytes: typeof rawCoIDfromBytes;
41
- newRandomSecretSeed: typeof newRandomSecretSeed;
42
- agentSecretFromSecretSeed: typeof agentSecretFromSecretSeed;
43
- secretSeedLength: number;
44
- shortHashLength: number;
45
- expectGroup: typeof expectGroup;
46
- base64URLtoBytes: typeof base64URLtoBytes;
47
- bytesToBase64url: typeof bytesToBase64url;
48
- parseJSON: typeof parseJSON;
49
- accountOrAgentIDfromSessionID: typeof accountOrAgentIDfromSessionID;
50
- isAccountID: typeof isAccountID;
51
- };
52
- export { LocalNode, Group, EVERYONE, CoMap, MutableCoMap, CoList, MutableCoList, CoStream, MutableCoStream, BinaryCoStream, MutableBinaryCoStream, CoValue, CoID, AnyCoValue, Queried, QueriedCoMap, QueriedCoList, QueriedCoStream, QueriedGroup, QueriedAccount, Account, AccountID, AccountMeta, AccountMigration, Profile, ProfileMeta, SessionID, Media, CoValueCore, AnonymousControlledAccount, ControlledAccount, cryptoReady as cojsonReady, MAX_RECOMMENDED_TX_SIZE, Value, JsonValue, Peer, BinaryStreamInfo, BinaryCoStreamMeta, AgentID, AgentSecret, InviteSecret, SyncMessage, QueryExtension, };
53
- export declare namespace CojsonInternalTypes {
54
- type CoValueKnownState = import("./sync.js").CoValueKnownState;
55
- type DoneMessage = import("./sync.js").DoneMessage;
56
- type KnownStateMessage = import("./sync.js").KnownStateMessage;
57
- type LoadMessage = import("./sync.js").LoadMessage;
58
- type NewContentMessage = import("./sync.js").NewContentMessage;
59
- type CoValueHeader = import("./coValueCore.js").CoValueHeader;
60
- type Transaction = import("./coValueCore.js").Transaction;
61
- type Signature = import("./crypto.js").Signature;
62
- type RawCoID = import("./ids.js").RawCoID;
63
- type ProfileShape = import("./coValues/account.js").ProfileShape;
64
- type ProfileMeta = import("./coValues/account.js").ProfileMeta;
65
- type SealerSecret = import("./crypto.js").SealerSecret;
66
- type SignerSecret = import("./crypto.js").SignerSecret;
67
- }
@@ -1,6 +0,0 @@
1
- export type Stringified<T> = string & {
2
- __type: T;
3
- };
4
- export declare function stableStringify<T>(data: T): Stringified<T>;
5
- export declare function stableStringify(data: undefined): undefined;
6
- export declare function parseJSON<T>(json: Stringified<T>): T;
@@ -1,7 +0,0 @@
1
- import { RawCoID } from './ids.js';
2
- export type JsonAtom = string | number | boolean | null;
3
- export type JsonValue = JsonAtom | JsonArray | JsonObject | RawCoID;
4
- export type JsonArray = JsonValue[];
5
- export type JsonObject = {
6
- [key: string]: JsonValue | undefined;
7
- };