Compare commits

..

5 Commits

Author SHA1 Message Date
Anselm
72fce45b2b Publish
- jazz-example-pets@0.0.21
 - jazz-example-todo@0.0.45
 - jazz-example-twit@0.0.8
 - cojson@0.4.8
 - cojson-simple-sync@0.4.8
 - cojson-storage-indexeddb@0.4.8
 - cojson-storage-sqlite@0.4.8
 - jazz-autosub@0.4.8
 - jazz-browser@0.4.8
 - jazz-browser-auth-local@0.4.8
 - jazz-browser-media-images@0.4.9
 - jazz-react@0.4.8
 - jazz-react-auth-local@0.4.8
2023-10-04 22:01:28 +01:00
Anselm
1f49d7fda6 Actually fix circular issues for esbuild/vite 2023-10-04 22:00:38 +01:00
Anselm
eec8ee7027 Publish
- jazz-example-pets@0.0.20
 - jazz-example-todo@0.0.44
 - jazz-example-twit@0.0.7
 - cojson@0.4.7
 - cojson-simple-sync@0.4.7
 - cojson-storage-indexeddb@0.4.7
 - cojson-storage-sqlite@0.4.7
 - jazz-autosub@0.4.7
 - jazz-browser@0.4.7
 - jazz-browser-auth-local@0.4.7
 - jazz-browser-media-images@0.4.8
 - jazz-react@0.4.7
 - jazz-react-auth-local@0.4.7
2023-10-04 21:23:52 +01:00
Anselm
188eb2e1e3 Update docs 2023-10-04 21:23:28 +01:00
Anselm
62867b32d9 Get rid of more cyclic imports 2023-10-04 21:22:52 +01:00
30 changed files with 169 additions and 154 deletions

110
DOCS.md
View File

@@ -2902,9 +2902,9 @@ class Group<P, R, Meta> {
asObject(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -2923,9 +2923,9 @@ class Group<P, R, Meta> {
toJSON(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -3027,9 +3027,9 @@ class Group<P, R, Meta> {
set(
kv: {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
},
privacy?: "private" | "trusting"
): Group<P, R, Meta> {...}
@@ -3043,9 +3043,9 @@ TODO: document
| name | description |
| ----: | ---- |
| `kv.everyone` | TODO: document |
| `kv.readKey` | TODO: document |
| `kv.profile` | TODO: document |
| `kv.root` | TODO: document |
| `kv.readKey` | TODO: document |
| `privacy?` | TODO: document |
</details>
@@ -3374,7 +3374,7 @@ class Group<P, R, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -3404,7 +3404,7 @@ class Group<P, R, Meta> {
lastEditAt<K extends Object>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -3433,7 +3433,7 @@ class Group<P, R, Meta> {
editsAt<K extends Object>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -3880,7 +3880,7 @@ class CoMap<Shape, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -3910,7 +3910,7 @@ class CoMap<Shape, Meta> {
lastEditAt<K extends string>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -3939,7 +3939,7 @@ class CoMap<Shape, Meta> {
editsAt<K extends string>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4324,7 +4324,7 @@ class MutableCoMap<Shape, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4354,7 +4354,7 @@ class MutableCoMap<Shape, Meta> {
lastEditAt<K extends string>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4383,7 +4383,7 @@ class MutableCoMap<Shape, Meta> {
editsAt<K extends string>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -4782,7 +4782,7 @@ class CoList<Item, Meta> {
editAt(
idx: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -4809,7 +4809,7 @@ TODO: document
class CoList<Item, Meta> {
deletionEdits(): {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
}[] {...}
@@ -5211,7 +5211,7 @@ class MutableCoList<Item, Meta> {
editAt(
idx: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5238,7 +5238,7 @@ TODO: document
class MutableCoList<Item, Meta> {
deletionEdits(): {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
}[] {...}
@@ -5608,7 +5608,7 @@ class CoStream<Item, Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5638,7 +5638,7 @@ class CoStream<Item, Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5667,7 +5667,7 @@ class CoStream<Item, Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5694,9 +5694,9 @@ TODO: document
class CoStream<Item, Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -5723,9 +5723,9 @@ TODO: document
class CoStream<Item, Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6074,7 +6074,7 @@ class MutableCoStream<Item, Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6104,7 +6104,7 @@ class MutableCoStream<Item, Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6133,7 +6133,7 @@ class MutableCoStream<Item, Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6160,9 +6160,9 @@ TODO: document
class MutableCoStream<Item, Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6189,9 +6189,9 @@ TODO: document
class MutableCoStream<Item, Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: Item,
@@ -6669,7 +6669,7 @@ class BinaryCoStream<Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6699,7 +6699,7 @@ class BinaryCoStream<Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6728,7 +6728,7 @@ class BinaryCoStream<Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6755,9 +6755,9 @@ TODO: document
class BinaryCoStream<Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -6784,9 +6784,9 @@ TODO: document
class BinaryCoStream<Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7214,7 +7214,7 @@ class MutableBinaryCoStream<Meta> {
sessionID: SessionID,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7244,7 +7244,7 @@ class MutableBinaryCoStream<Meta> {
lastItemIn(
sessionID: SessionID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7273,7 +7273,7 @@ class MutableBinaryCoStream<Meta> {
itemsIn(
sessionID: SessionID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7300,9 +7300,9 @@ TODO: document
class MutableBinaryCoStream<Meta> {
lastItemBy(
account: AccountID | AgentID
account: AgentID | AccountID
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7329,9 +7329,9 @@ TODO: document
class MutableBinaryCoStream<Meta> {
itemsBy(
account: AccountID | AgentID
account: AgentID | AccountID
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value: BinaryStreamItem,
@@ -7578,9 +7578,9 @@ class Account<P, R, Meta> {
asObject(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -7599,9 +7599,9 @@ class Account<P, R, Meta> {
toJSON(): {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
} {...}
}
@@ -7703,9 +7703,9 @@ class Account<P, R, Meta> {
set(
kv: {
everyone: undefined | Role,
readKey: undefined | `key_z${string}`,
profile: undefined | null | CoID<P>,
root: undefined | null | CoID<R>,
readKey: undefined | `key_z${string}`,
},
privacy?: "private" | "trusting"
): Account<P, R, Meta> {...}
@@ -7719,9 +7719,9 @@ TODO: document
| name | description |
| ----: | ---- |
| `kv.everyone` | TODO: document |
| `kv.readKey` | TODO: document |
| `kv.profile` | TODO: document |
| `kv.root` | TODO: document |
| `kv.readKey` | TODO: document |
| `privacy?` | TODO: document |
</details>
@@ -8050,7 +8050,7 @@ class Account<P, R, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -8080,7 +8080,7 @@ class Account<P, R, Meta> {
lastEditAt<K extends Object>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -8109,7 +8109,7 @@ class Account<P, R, Meta> {
editsAt<K extends Object>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: GroupShape<P, R>[K],
@@ -8571,7 +8571,7 @@ class Profile<Shape, Meta> {
key: K,
n: number
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -8601,7 +8601,7 @@ class Profile<Shape, Meta> {
lastEditAt<K extends string>(
key: K
): undefined | {
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],
@@ -8630,7 +8630,7 @@ class Profile<Shape, Meta> {
editsAt<K extends string>(
key: K
): Generator<{
by: AccountID | AgentID,
by: AgentID | AccountID,
tx: TransactionID,
at: Date,
value?: Shape[K],

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.19",
"version": "0.0.21",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,9 +16,9 @@
"@types/qrcode": "^1.5.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-browser-media-images": "^0.4.7",
"jazz-react": "^0.4.6",
"jazz-react-auth-local": "^0.4.6",
"jazz-browser-media-images": "^0.4.9",
"jazz-react": "^0.4.8",
"jazz-react-auth-local": "^0.4.8",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-todo",
"private": true,
"version": "0.0.43",
"version": "0.0.45",
"type": "module",
"scripts": {
"dev": "vite",
@@ -16,8 +16,8 @@
"@types/qrcode": "^1.5.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"jazz-react": "^0.4.6",
"jazz-react-auth-local": "^0.4.6",
"jazz-react": "^0.4.8",
"jazz-react-auth-local": "^0.4.8",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-twit",
"private": true,
"version": "0.0.6",
"version": "0.0.8",
"type": "module",
"scripts": {
"dev": "vite",
@@ -18,9 +18,9 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"javascript-time-ago": "^2.5.9",
"jazz-browser-media-images": "^0.4.7",
"jazz-react": "^0.4.6",
"jazz-react-auth-local": "^0.4.6",
"jazz-browser-media-images": "^0.4.9",
"jazz-react": "^0.4.8",
"jazz-react-auth-local": "^0.4.8",
"lucide-react": "^0.274.0",
"qrcode": "^1.5.3",
"react": "^18.2.0",

View File

@@ -4,7 +4,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.4.6",
"version": "0.4.8",
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/ws": "^8.5.5",
@@ -16,8 +16,8 @@
"typescript": "5.0.2"
},
"dependencies": {
"cojson": "^0.4.6",
"cojson-storage-sqlite": "^0.4.6",
"cojson": "^0.4.8",
"cojson-storage-sqlite": "^0.4.8",
"ws": "^8.13.0"
},
"scripts": {

View File

@@ -1,11 +1,11 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.4.6",
"version": "0.4.8",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.4.6",
"cojson": "^0.4.8",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

@@ -1,13 +1,13 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.4.6",
"version": "0.4.8",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"better-sqlite3": "^8.5.2",
"cojson": "^0.4.6",
"cojson": "^0.4.8",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -5,7 +5,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.4.6",
"version": "0.4.8",
"devDependencies": {
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.2.1",

View File

@@ -1,7 +1,5 @@
import { randomBytes } from "@noble/hashes/utils";
import { AnyCoValue, CoValue } from "./coValue.js";
import { BinaryCoStream, CoStream } from "./coValues/coStream.js";
import { CoMap } from "./coValues/coMap.js";
import {
Encrypted,
Hash,
@@ -26,19 +24,19 @@ import {
determineValidTransactions,
isKeyForKeyField,
} from "./permissions.js";
import { Group, expectGroup } from "./coValues/group.js";
import { Group } from "./coValues/group.js";
import { LocalNode } from "./localNode.js";
import { CoValueKnownState, NewContentMessage } from "./sync.js";
import { AgentID, RawCoID, SessionID, TransactionID } from "./ids.js";
import { CoList } from "./coValues/coList.js";
import {
Account,
AccountID,
GeneralizedControlledAccount,
isAccountID,
} from "./coValues/account.js";
import { Stringified, stableStringify } from "./jsonStringify.js";
import { coreToCoValue } from "./coreToCoValue.js";
import { expectGroup } from "./typeUtils/expectGroup.js";
import { isAccountID } from "./typeUtils/isAccountID.js";
import { accountOrAgentIDfromSessionID } from "./typeUtils/accountOrAgentIDfromSessionID.js";
export const MAX_RECOMMENDED_TX_SIZE = 100 * 1024;
@@ -55,12 +53,6 @@ export function idforHeader(header: CoValueHeader): RawCoID {
return `co_z${hash.slice("shortHash_z".length)}`;
}
export function accountOrAgentIDfromSessionID(
sessionID: SessionID
): AccountID | AgentID {
return sessionID.split("_session")[0] as AccountID | AgentID;
}
export function newRandomSessionID(accountID: AccountID | AgentID): SessionID {
return `${accountID}_session_z${base58.encode(randomBytes(8))}`;
}

View File

@@ -153,10 +153,6 @@ export class AnonymousControlledAccount
export type AccountMeta = { type: "account" };
export type AccountID = CoID<Account>;
export function isAccountID(id: AccountID | AgentID): id is AccountID {
return id.startsWith("co_");
}
export type ProfileShape = {
name: string;
};

View File

@@ -1,7 +1,8 @@
import { JsonObject, JsonValue } from "../jsonValue.js";
import { CoID, CoValue } from "../coValue.js";
import { isCoValue } from "../isCoValue.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { isCoValue } from "../typeUtils/isCoValue.js";
import { CoValueCore } from "../coValueCore.js";
import { accountOrAgentIDfromSessionID } from "../typeUtils/accountOrAgentIDfromSessionID.js";
import { AgentID, SessionID, TransactionID } from "../ids.js";
import { AccountID } from "./account.js";
import { parseJSON } from "../jsonStringify.js";

View File

@@ -1,11 +1,12 @@
import { JsonObject, JsonValue } from "../jsonValue.js";
import { AgentID, TransactionID } from "../ids.js";
import { CoID, CoValue } from "../coValue.js";
import { isCoValue } from "../isCoValue.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { isCoValue } from "../typeUtils/isCoValue.js";
import { CoValueCore } from "../coValueCore.js";
import { accountOrAgentIDfromSessionID } from "../typeUtils/accountOrAgentIDfromSessionID.js";
import { AccountID } from "./account.js";
import { parseJSON } from "../jsonStringify.js";
import { Group } from "./group.js";
import type { Group } from "./group.js";
type MapOp<K extends string, V extends JsonValue | undefined> = {
txID: TransactionID;

View File

@@ -1,11 +1,13 @@
import { JsonObject, JsonValue } from "../jsonValue.js";
import { CoValue, CoID } from "../coValue.js";
import { isCoValue } from "../isCoValue.js";
import { CoValueCore, accountOrAgentIDfromSessionID } from "../coValueCore.js";
import { isAccountID } from "../typeUtils/isAccountID.js";
import { isCoValue } from "../typeUtils/isCoValue.js";
import { CoValueCore } from "../coValueCore.js";
import { accountOrAgentIDfromSessionID } from "../typeUtils/accountOrAgentIDfromSessionID.js";
import { Group } from "./group.js";
import { AgentID, SessionID, TransactionID } from "../ids.js";
import { base64URLtoBytes, bytesToBase64url } from "../base64url.js";
import { AccountID, isAccountID } from "./account.js";
import { AccountID } from "./account.js";
import { parseJSON } from "../jsonStringify.js";
export type BinaryStreamInfo = {

View File

@@ -1,4 +1,4 @@
import { CoID, CoValue, expectMap } from "../coValue.js";
import { CoID } from "../coValue.js";
import { CoMap } from "./coMap.js";
import { CoList } from "./coList.js";
import { JsonObject } from "../jsonValue.js";
@@ -39,19 +39,6 @@ export type GroupShape<P extends Profile, R extends CoMap> = {
>;
};
export function expectGroup(content: CoValue): Group {
const map = expectMap(content);
if (map.core.header.ruleset.type !== "group") {
throw new Error("Expected group ruleset in group");
}
if (!(map instanceof Group)) {
throw new Error("Expected group");
}
return map;
}
/** A `Group` is a scope for permissions of its members (`"reader" | "writer" | "admin"`), applying to objects owned by that group.
*
* A `Group` object exposes methods for permission management and allows you to create new CoValues owned by that group.

View File

@@ -1,4 +1,4 @@
import { CoValueCore } from "./coValueCore.js";
import type { CoValueCore } from "./coValueCore.js";
import { Account } from "./coValues/account.js";
import { Group } from "./coValues/group.js";
import { CoMap } from "./coValues/coMap.js";

View File

@@ -2,8 +2,8 @@ import {
CoValueCore,
newRandomSessionID,
MAX_RECOMMENDED_TX_SIZE,
accountOrAgentIDfromSessionID,
} from "./coValueCore.js";
import { accountOrAgentIDfromSessionID } from "./typeUtils/accountOrAgentIDfromSessionID.js";
import { LocalNode } from "./localNode.js";
import type { CoValue } from "./coValue.js";
import { CoMap, MutableCoMap } from "./coValues/coMap.js";
@@ -32,11 +32,13 @@ import {
} from "./coValues/account.js";
import type { Role } from "./permissions.js";
import { rawCoIDtoBytes, rawCoIDfromBytes } from "./ids.js";
import { Group, expectGroup, EVERYONE } from "./coValues/group.js";
import { Group, EVERYONE } from "./coValues/group.js";
import type { Everyone } from "./coValues/group.js";
import { base64URLtoBytes, bytesToBase64url } from "./base64url.js";
import { parseJSON } from "./jsonStringify.js";
import { Account, Profile, isAccountID } from "./coValues/account.js";
import { Account, Profile } from "./coValues/account.js";
import { expectGroup } from "./typeUtils/expectGroup.js";
import { isAccountID } from "./typeUtils/isAccountID.js";
import type { SessionID, AgentID } from "./ids.js";
import type { CoID, AnyCoValue } from "./coValue.js";

View File

@@ -1,16 +0,0 @@
import { JsonValue } from "./jsonValue.js";
import { CoMap } from "./coValues/coMap.js";
import { BinaryCoStream, CoStream } from "./coValues/coStream.js";
import { CoList } from "./coValues/coList.js";
import { CoValue } from "./coValue.js";
export function isCoValue(
value: JsonValue | CoValue | undefined
): value is CoValue {
return (
value instanceof CoMap ||
value instanceof CoList ||
value instanceof CoStream ||
value instanceof BinaryCoStream
);
}

View File

@@ -17,7 +17,6 @@ import {
import {
InviteSecret,
Group,
expectGroup,
secretSeedFromInviteSecret,
} from "./coValues/group.js";
import { Peer, SyncManager } from "./sync.js";
@@ -36,6 +35,7 @@ import {
} from "./coValues/account.js";
import { CoMap } from "./coValues/coMap.js";
import { CoValue } from "./index.js";
import { expectGroup } from "./typeUtils/expectGroup.js";
/** A `LocalNode` represents a local view of a set of loaded `CoValue`s, from the perspective of a particular account (or primitive cryptographic agent).

View File

@@ -5,12 +5,13 @@ import { KeyID } from "./crypto.js";
import {
CoValueCore,
Transaction,
accountOrAgentIDfromSessionID,
} from "./coValueCore.js";
import { accountOrAgentIDfromSessionID } from "./typeUtils/accountOrAgentIDfromSessionID.js";
import { AgentID, RawCoID, SessionID, TransactionID } from "./ids.js";
import { Account, AccountID, Profile } from "./coValues/account.js";
import { parseJSON } from "./jsonStringify.js";
import { EVERYONE, Everyone, expectGroup } from "./coValues/group.js";
import { EVERYONE, Everyone } from "./coValues/group.js";
import { expectGroup } from "./typeUtils/expectGroup.js";
export type PermissionsDef =
| { type: "group"; initialAdmin: AccountID | AgentID }

View File

@@ -1,7 +1,7 @@
import { AgentSecret, createdNowUnique, getAgentID, newRandomAgentSecret } from "../crypto.js";
import { newRandomSessionID } from "../coValueCore.js";
import { LocalNode } from "../localNode.js";
import { expectGroup } from "../coValues/group.js";
import { expectGroup } from "../typeUtils/expectGroup.js";
import { AnonymousControlledAccount } from "../coValues/account.js";
import { SessionID } from "../ids.js";
// @ts-ignore

View File

@@ -0,0 +1,9 @@
import { AgentID, SessionID } from "../ids.js";
import { AccountID } from "../coValues/account.js";
export function accountOrAgentIDfromSessionID(
sessionID: SessionID
): AccountID | AgentID {
return sessionID.split("_session")[0] as AccountID | AgentID;
}

View File

@@ -0,0 +1,15 @@
import { expectMap, type CoValue } from "../coValue.js";
import { Group } from "../coValues/group.js";
export function expectGroup(content: CoValue): Group {
const map = expectMap(content);
if (map.core.header.ruleset.type !== "group") {
throw new Error("Expected group ruleset in group");
}
if (!(map instanceof Group)) {
throw new Error("Expected group");
}
return map;
}

View File

@@ -0,0 +1,7 @@
import type { AccountID } from "../coValues/account.js";
import type { AgentID } from "../ids.js";
export function isAccountID(id: AccountID | AgentID): id is AccountID {
return id.startsWith("co_");
}

View File

@@ -0,0 +1,18 @@
import { type CoValue } from "../coValue.js";
import type { JsonValue } from "../jsonValue.js";
import { CoMap } from "../coValues/coMap.js";
import { CoList } from "../coValues/coList.js";
import { CoStream } from "../coValues/coStream.js";
import { BinaryCoStream } from "../coValues/coStream.js";
export function isCoValue(
value: JsonValue | CoValue | undefined
): value is CoValue {
return (
value instanceof CoMap ||
value instanceof CoList ||
value instanceof CoStream ||
value instanceof BinaryCoStream
);
}

View File

@@ -5,9 +5,9 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.4.6",
"version": "0.4.8",
"dependencies": {
"cojson": "^0.4.6"
"cojson": "^0.4.8"
},
"scripts": {
"test": "jest",

View File

@@ -1,11 +1,11 @@
{
"name": "jazz-browser-auth-local",
"version": "0.4.6",
"version": "0.4.8",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"jazz-browser": "^0.4.6",
"jazz-browser": "^0.4.8",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,15 +1,15 @@
{
"name": "jazz-browser-media-images",
"version": "0.4.7",
"version": "0.4.9",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"@types/image-blob-reduce": "^4.1.1",
"cojson": "^0.4.6",
"cojson": "^0.4.8",
"image-blob-reduce": "^4.1.0",
"jazz-autosub": "^0.4.6",
"jazz-browser": "^0.4.6",
"jazz-autosub": "^0.4.8",
"jazz-browser": "^0.4.8",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,13 +1,13 @@
{
"name": "jazz-browser",
"version": "0.4.6",
"version": "0.4.8",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.4.6",
"cojson-storage-indexeddb": "^0.4.6",
"jazz-autosub": "^0.4.6",
"cojson": "^0.4.8",
"cojson-storage-indexeddb": "^0.4.8",
"jazz-autosub": "^0.4.8",
"typescript": "^5.1.6"
},
"scripts": {

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-react-auth-local",
"version": "0.4.6",
"version": "0.4.8",
"main": "dist/index.js",
"types": "src/index.tsx",
"license": "MIT",
"dependencies": {
"jazz-browser-auth-local": "^0.4.6",
"jazz-react": "^0.4.6",
"jazz-browser-auth-local": "^0.4.8",
"jazz-react": "^0.4.8",
"typescript": "^5.1.6"
},
"devDependencies": {

View File

@@ -1,12 +1,12 @@
{
"name": "jazz-react",
"version": "0.4.6",
"version": "0.4.8",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",
"dependencies": {
"cojson": "^0.4.6",
"jazz-browser": "^0.4.6",
"cojson": "^0.4.8",
"jazz-browser": "^0.4.8",
"typescript": "^5.1.6"
},
"devDependencies": {