jazz-tools 0.10.0 → 0.10.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/.turbo/turbo-build.log +9 -11
- package/CHANGELOG.md +8 -0
- package/dist/{chunk-UBD75Z27.js → chunk-24EJ3CKA.js} +1 -1
- package/dist/chunk-24EJ3CKA.js.map +1 -0
- package/dist/{index.native.js → index.js} +4 -7
- package/dist/index.js.map +1 -0
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/package.json +8 -14
- package/src/implementation/schema.ts +3 -3
- package/src/index.ts +3 -0
- package/src/testing.ts +1 -1
- package/src/tests/ContextManager.test.ts +3 -3
- package/src/tests/coFeed.test.ts +4 -3
- package/src/tests/coList.test.ts +5 -4
- package/src/tests/coMap.test.ts +4 -3
- package/src/tests/coPlainText.test.ts +4 -3
- package/src/tests/coRichText.test.ts +3 -3
- package/src/tests/createContext.test.ts +2 -2
- package/src/tests/deepLoading.test.ts +3 -3
- package/src/tests/groupsAndAccounts.test.ts +1 -1
- package/src/tests/schema.test.ts +1 -1
- package/src/tests/schemaUnion.test.ts +2 -2
- package/src/tests/subscribe.test.ts +1 -1
- package/src/tests/utils.ts +2 -2
- package/tsconfig.json +3 -1
- package/tsup.config.ts +1 -2
- package/dist/chunk-UBD75Z27.js.map +0 -1
- package/dist/index.native.js.map +0 -1
- package/dist/index.web.js +0 -85
- package/dist/index.web.js.map +0 -1
- package/src/index.native.ts +0 -6
- package/src/index.web.ts +0 -3
- package/tsconfig.native.json +0 -5
- package/tsconfig.web.json +0 -5
@@ -35,13 +35,10 @@ import {
|
|
35
35
|
parseInviteLink,
|
36
36
|
randomSessionProvider,
|
37
37
|
subscribeToCoValue
|
38
|
-
} from "./chunk-
|
38
|
+
} from "./chunk-24EJ3CKA.js";
|
39
39
|
|
40
|
-
// src/index.
|
41
|
-
import {
|
42
|
-
MAX_RECOMMENDED_TX_SIZE,
|
43
|
-
cojsonInternals
|
44
|
-
} from "cojson/native";
|
40
|
+
// src/index.ts
|
41
|
+
import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from "cojson";
|
45
42
|
export {
|
46
43
|
Account,
|
47
44
|
AnonymousJazzAgent,
|
@@ -84,4 +81,4 @@ export {
|
|
84
81
|
randomSessionProvider,
|
85
82
|
subscribeToCoValue
|
86
83
|
};
|
87
|
-
//# sourceMappingURL=index.
|
84
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./exports.js\";\n\nexport { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from \"cojson\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,yBAAyB,uBAAuB;","names":[]}
|
package/dist/testing.js
CHANGED
@@ -5,12 +5,12 @@ import {
|
|
5
5
|
createAnonymousJazzContext,
|
6
6
|
createJazzContext,
|
7
7
|
randomSessionProvider
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-24EJ3CKA.js";
|
9
9
|
|
10
10
|
// src/testing.ts
|
11
11
|
import { LocalNode } from "cojson";
|
12
12
|
import { cojsonInternals } from "cojson";
|
13
|
-
import { PureJSCrypto } from "cojson/crypto";
|
13
|
+
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
14
14
|
var syncServer = { current: null };
|
15
15
|
var TestJSCrypto = class extends PureJSCrypto {
|
16
16
|
static async create() {
|
package/dist/testing.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { AgentSecret, CryptoProvider, LocalNode, Peer } from \"cojson\";\nimport { cojsonInternals } from \"cojson\";\nimport { PureJSCrypto } from \"cojson/crypto\";\nimport {\n Account,\n AccountClass,\n JazzContextManagerAuthProps,\n} from \"./exports.js\";\nimport {\n JazzContextManager,\n JazzContextManagerBaseProps,\n} from \"./implementation/ContextManager.js\";\nimport { activeAccountContext } from \"./implementation/activeAccountContext.js\";\nimport {\n type AnonymousJazzAgent,\n type CoValueClass,\n createAnonymousJazzContext,\n createJazzContext,\n randomSessionProvider,\n} from \"./internal.js\";\n\nconst syncServer: { current: LocalNode | null } = { current: null };\n\ntype TestAccountSchema<Acc extends Account> = CoValueClass<Acc> & {\n fromNode: (typeof Account)[\"fromNode\"];\n create: (options: {\n creationProps: { name: string };\n initialAgentSecret?: AgentSecret;\n peersToLoadFrom?: Peer[];\n crypto: CryptoProvider;\n }) => Promise<Acc>;\n};\n\nexport class TestJSCrypto extends PureJSCrypto {\n static async create() {\n if (\"navigator\" in globalThis && navigator.userAgent?.includes(\"jsdom\")) {\n // Mocking crypto seal & encrypt to make it work with JSDom. Getting \"Error: Uint8Array expected\" there\n const crypto = new PureJSCrypto();\n\n crypto.seal = (options) =>\n `sealed_U${cojsonInternals.stableStringify(options.message)}` as any;\n crypto.unseal = (sealed) =>\n JSON.parse(sealed.substring(\"sealed_U\".length));\n crypto.encrypt = (message) =>\n `encrypted_U${cojsonInternals.stableStringify(message)}` as any;\n crypto.decryptRaw = (encrypted) =>\n encrypted.substring(\"encrypted_U\".length) as any;\n\n return crypto;\n }\n\n // For non-jsdom environments, we use the real crypto\n return new PureJSCrypto();\n }\n}\n\nexport function getPeerConnectedToTestSyncServer() {\n if (!syncServer.current) {\n throw new Error(\"Sync server not initialized\");\n }\n\n const [aPeer, bPeer] = cojsonInternals.connectedPeers(\n Math.random().toString(),\n Math.random().toString(),\n {\n peer1role: \"server\",\n peer2role: \"server\",\n },\n );\n syncServer.current.syncManager.addPeer(aPeer);\n\n return bPeer;\n}\n\nconst SecretSeedMap = new Map<string, Uint8Array>();\nlet isMigrationActive = false;\n\nexport async function createJazzTestAccount<Acc extends Account>(options?: {\n isCurrentActiveAccount?: boolean;\n AccountSchema?: CoValueClass<Acc>;\n creationProps?: Record<string, unknown>;\n}): Promise<Acc> {\n const AccountSchema = (options?.AccountSchema ??\n Account) as unknown as TestAccountSchema<Acc>;\n const peers = [];\n if (syncServer.current) {\n peers.push(getPeerConnectedToTestSyncServer());\n }\n\n const crypto = await TestJSCrypto.create();\n const secretSeed = crypto.newRandomSecretSeed();\n\n const { node } = await LocalNode.withNewlyCreatedAccount({\n creationProps: {\n name: \"Test Account\",\n ...options?.creationProps,\n },\n initialAgentSecret: crypto.agentSecretFromSecretSeed(secretSeed),\n crypto,\n peersToLoadFrom: peers,\n migration: async (rawAccount, _node, creationProps) => {\n if (isMigrationActive) {\n throw new Error(\n \"It is not possible to create multiple accounts in parallel inside the test environment.\",\n );\n }\n\n isMigrationActive = true;\n\n const account = new AccountSchema({\n fromRaw: rawAccount,\n });\n\n // We need to set the account as current because the migration\n // will probably rely on the global me\n const prevActiveAccount = activeAccountContext.maybeGet();\n activeAccountContext.set(account);\n\n await account.applyMigration?.(creationProps);\n\n if (!options?.isCurrentActiveAccount) {\n activeAccountContext.set(prevActiveAccount);\n }\n\n isMigrationActive = false;\n },\n });\n\n const account = AccountSchema.fromNode(node);\n SecretSeedMap.set(account.id, secretSeed);\n\n if (options?.isCurrentActiveAccount) {\n activeAccountContext.set(account);\n }\n\n return account;\n}\n\nexport function setActiveAccount(account: Account) {\n activeAccountContext.set(account);\n}\n\nexport async function createJazzTestGuest() {\n const ctx = await createAnonymousJazzContext({\n crypto: await PureJSCrypto.create(),\n peersToLoadFrom: [],\n });\n\n return {\n guest: ctx.agent,\n };\n}\n\nexport type TestJazzContextManagerProps<Acc extends Account> =\n JazzContextManagerBaseProps<Acc> & {\n defaultProfileName?: string;\n AccountSchema?: AccountClass<Acc>;\n isAuthenticated?: boolean;\n };\n\nexport class TestJazzContextManager<\n Acc extends Account,\n> extends JazzContextManager<Acc, TestJazzContextManagerProps<Acc>> {\n static fromAccountOrGuest<Acc extends Account>(\n account?: Acc | { guest: AnonymousJazzAgent },\n props?: TestJazzContextManagerProps<Acc>,\n ) {\n if (account && \"guest\" in account) {\n return this.fromGuest<Acc>(account, props);\n }\n\n return this.fromAccount<Acc>(account ?? (Account.getMe() as Acc), props);\n }\n\n static fromAccount<Acc extends Account>(\n account: Acc,\n props?: TestJazzContextManagerProps<Acc>,\n ) {\n const context = new TestJazzContextManager<Acc>();\n\n const provider = props?.isAuthenticated ? \"testProvider\" : \"anonymous\";\n const storage = context.getAuthSecretStorage();\n const node = account._raw.core.node;\n\n storage.set({\n accountID: account.id,\n accountSecret: node.account.agentSecret,\n secretSeed: SecretSeedMap.get(account.id),\n provider,\n });\n storage.isAuthenticated = Boolean(props?.isAuthenticated);\n\n context.updateContext(\n {\n AccountSchema: account.constructor as AccountClass<Acc>,\n ...props,\n },\n {\n me: account,\n node,\n done: () => {\n node.gracefulShutdown();\n },\n logOut: async () => {\n node.gracefulShutdown();\n },\n },\n );\n\n return context;\n }\n\n static fromGuest<Acc extends Account>(\n { guest }: { guest: AnonymousJazzAgent },\n props: TestJazzContextManagerProps<Acc> = {},\n ) {\n const context = new TestJazzContextManager<Acc>();\n const node = guest.node;\n\n context.updateContext(props, {\n guest,\n node,\n done: () => {\n node.gracefulShutdown();\n },\n logOut: async () => {\n node.gracefulShutdown();\n },\n });\n\n return context;\n }\n\n async createContext(\n props: TestJazzContextManagerProps<Acc>,\n authProps?: JazzContextManagerAuthProps,\n ) {\n this.props = props;\n\n if (!syncServer.current) {\n throw new Error(\n \"You need to setup a test sync server with setupJazzTestSync to use the Auth functions\",\n );\n }\n\n const context = await createJazzContext<Acc>({\n credentials: authProps?.credentials,\n defaultProfileName: props.defaultProfileName,\n newAccountProps: authProps?.newAccountProps,\n peersToLoadFrom: [getPeerConnectedToTestSyncServer()],\n crypto: await TestJSCrypto.create(),\n sessionProvider: randomSessionProvider,\n authSecretStorage: this.getAuthSecretStorage(),\n AccountSchema: props.AccountSchema,\n });\n\n this.updateContext(props, {\n me: context.account,\n node: context.node,\n done: () => {\n context.done();\n },\n logOut: () => {\n return context.logOut();\n },\n });\n }\n}\n\nexport function linkAccounts(\n a: Account,\n b: Account,\n aRole: \"server\" | \"client\" = \"server\",\n bRole: \"server\" | \"client\" = \"server\",\n) {\n const [aPeer, bPeer] = cojsonInternals.connectedPeers(b.id, a.id, {\n peer1role: aRole,\n peer2role: bRole,\n });\n\n a._raw.core.node.syncManager.addPeer(aPeer);\n b._raw.core.node.syncManager.addPeer(bPeer);\n}\n\nexport async function setupJazzTestSync() {\n if (syncServer.current) {\n syncServer.current.gracefulShutdown();\n }\n\n const account = await Account.create({\n creationProps: {\n name: \"Test Account\",\n },\n crypto: await TestJSCrypto.create(),\n });\n\n syncServer.current = account._raw.core.node;\n\n return account;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAsC,iBAAuB;AAC7D,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAmB7B,IAAM,aAA4C,EAAE,SAAS,KAAK;AAY3D,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,aAAa,SAAS;AACpB,QAAI,eAAe,cAAc,UAAU,WAAW,SAAS,OAAO,GAAG;AAEvE,YAAM,SAAS,IAAI,aAAa;AAEhC,aAAO,OAAO,CAAC,YACb,WAAW,gBAAgB,gBAAgB,QAAQ,OAAO,CAAC;AAC7D,aAAO,SAAS,CAAC,WACf,KAAK,MAAM,OAAO,UAAU,WAAW,MAAM,CAAC;AAChD,aAAO,UAAU,CAAC,YAChB,cAAc,gBAAgB,gBAAgB,OAAO,CAAC;AACxD,aAAO,aAAa,CAAC,cACnB,UAAU,UAAU,cAAc,MAAM;AAE1C,aAAO;AAAA,IACT;AAGA,WAAO,IAAI,aAAa;AAAA,EAC1B;AACF;AAEO,SAAS,mCAAmC;AACjD,MAAI,CAAC,WAAW,SAAS;AACvB,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAEA,QAAM,CAAC,OAAO,KAAK,IAAI,gBAAgB;AAAA,IACrC,KAAK,OAAO,EAAE,SAAS;AAAA,IACvB,KAAK,OAAO,EAAE,SAAS;AAAA,IACvB;AAAA,MACE,WAAW;AAAA,MACX,WAAW;AAAA,IACb;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AU,QAAQ,KAAK,KAAK;AAEvC,SAAO;AACT;","names":["account"]}
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { AgentSecret, CryptoProvider, LocalNode, Peer } from \"cojson\";\nimport { cojsonInternals } from \"cojson\";\nimport { PureJSCrypto } from \"cojson/dist/crypto/PureJSCrypto\";\nimport {\n Account,\n AccountClass,\n JazzContextManagerAuthProps,\n} from \"./exports.js\";\nimport {\n JazzContextManager,\n JazzContextManagerBaseProps,\n} from \"./implementation/ContextManager.js\";\nimport { activeAccountContext } from \"./implementation/activeAccountContext.js\";\nimport {\n type AnonymousJazzAgent,\n type CoValueClass,\n createAnonymousJazzContext,\n createJazzContext,\n randomSessionProvider,\n} from \"./internal.js\";\n\nconst syncServer: { current: LocalNode | null } = { current: null };\n\ntype TestAccountSchema<Acc extends Account> = CoValueClass<Acc> & {\n fromNode: (typeof Account)[\"fromNode\"];\n create: (options: {\n creationProps: { name: string };\n initialAgentSecret?: AgentSecret;\n peersToLoadFrom?: Peer[];\n crypto: CryptoProvider;\n }) => Promise<Acc>;\n};\n\nexport class TestJSCrypto extends PureJSCrypto {\n static async create() {\n if (\"navigator\" in globalThis && navigator.userAgent?.includes(\"jsdom\")) {\n // Mocking crypto seal & encrypt to make it work with JSDom. Getting \"Error: Uint8Array expected\" there\n const crypto = new PureJSCrypto();\n\n crypto.seal = (options) =>\n `sealed_U${cojsonInternals.stableStringify(options.message)}` as any;\n crypto.unseal = (sealed) =>\n JSON.parse(sealed.substring(\"sealed_U\".length));\n crypto.encrypt = (message) =>\n `encrypted_U${cojsonInternals.stableStringify(message)}` as any;\n crypto.decryptRaw = (encrypted) =>\n encrypted.substring(\"encrypted_U\".length) as any;\n\n return crypto;\n }\n\n // For non-jsdom environments, we use the real crypto\n return new PureJSCrypto();\n }\n}\n\nexport function getPeerConnectedToTestSyncServer() {\n if (!syncServer.current) {\n throw new Error(\"Sync server not initialized\");\n }\n\n const [aPeer, bPeer] = cojsonInternals.connectedPeers(\n Math.random().toString(),\n Math.random().toString(),\n {\n peer1role: \"server\",\n peer2role: \"server\",\n },\n );\n syncServer.current.syncManager.addPeer(aPeer);\n\n return bPeer;\n}\n\nconst SecretSeedMap = new Map<string, Uint8Array>();\nlet isMigrationActive = false;\n\nexport async function createJazzTestAccount<Acc extends Account>(options?: {\n isCurrentActiveAccount?: boolean;\n AccountSchema?: CoValueClass<Acc>;\n creationProps?: Record<string, unknown>;\n}): Promise<Acc> {\n const AccountSchema = (options?.AccountSchema ??\n Account) as unknown as TestAccountSchema<Acc>;\n const peers = [];\n if (syncServer.current) {\n peers.push(getPeerConnectedToTestSyncServer());\n }\n\n const crypto = await TestJSCrypto.create();\n const secretSeed = crypto.newRandomSecretSeed();\n\n const { node } = await LocalNode.withNewlyCreatedAccount({\n creationProps: {\n name: \"Test Account\",\n ...options?.creationProps,\n },\n initialAgentSecret: crypto.agentSecretFromSecretSeed(secretSeed),\n crypto,\n peersToLoadFrom: peers,\n migration: async (rawAccount, _node, creationProps) => {\n if (isMigrationActive) {\n throw new Error(\n \"It is not possible to create multiple accounts in parallel inside the test environment.\",\n );\n }\n\n isMigrationActive = true;\n\n const account = new AccountSchema({\n fromRaw: rawAccount,\n });\n\n // We need to set the account as current because the migration\n // will probably rely on the global me\n const prevActiveAccount = activeAccountContext.maybeGet();\n activeAccountContext.set(account);\n\n await account.applyMigration?.(creationProps);\n\n if (!options?.isCurrentActiveAccount) {\n activeAccountContext.set(prevActiveAccount);\n }\n\n isMigrationActive = false;\n },\n });\n\n const account = AccountSchema.fromNode(node);\n SecretSeedMap.set(account.id, secretSeed);\n\n if (options?.isCurrentActiveAccount) {\n activeAccountContext.set(account);\n }\n\n return account;\n}\n\nexport function setActiveAccount(account: Account) {\n activeAccountContext.set(account);\n}\n\nexport async function createJazzTestGuest() {\n const ctx = await createAnonymousJazzContext({\n crypto: await PureJSCrypto.create(),\n peersToLoadFrom: [],\n });\n\n return {\n guest: ctx.agent,\n };\n}\n\nexport type TestJazzContextManagerProps<Acc extends Account> =\n JazzContextManagerBaseProps<Acc> & {\n defaultProfileName?: string;\n AccountSchema?: AccountClass<Acc>;\n isAuthenticated?: boolean;\n };\n\nexport class TestJazzContextManager<\n Acc extends Account,\n> extends JazzContextManager<Acc, TestJazzContextManagerProps<Acc>> {\n static fromAccountOrGuest<Acc extends Account>(\n account?: Acc | { guest: AnonymousJazzAgent },\n props?: TestJazzContextManagerProps<Acc>,\n ) {\n if (account && \"guest\" in account) {\n return this.fromGuest<Acc>(account, props);\n }\n\n return this.fromAccount<Acc>(account ?? (Account.getMe() as Acc), props);\n }\n\n static fromAccount<Acc extends Account>(\n account: Acc,\n props?: TestJazzContextManagerProps<Acc>,\n ) {\n const context = new TestJazzContextManager<Acc>();\n\n const provider = props?.isAuthenticated ? \"testProvider\" : \"anonymous\";\n const storage = context.getAuthSecretStorage();\n const node = account._raw.core.node;\n\n storage.set({\n accountID: account.id,\n accountSecret: node.account.agentSecret,\n secretSeed: SecretSeedMap.get(account.id),\n provider,\n });\n storage.isAuthenticated = Boolean(props?.isAuthenticated);\n\n context.updateContext(\n {\n AccountSchema: account.constructor as AccountClass<Acc>,\n ...props,\n },\n {\n me: account,\n node,\n done: () => {\n node.gracefulShutdown();\n },\n logOut: async () => {\n node.gracefulShutdown();\n },\n },\n );\n\n return context;\n }\n\n static fromGuest<Acc extends Account>(\n { guest }: { guest: AnonymousJazzAgent },\n props: TestJazzContextManagerProps<Acc> = {},\n ) {\n const context = new TestJazzContextManager<Acc>();\n const node = guest.node;\n\n context.updateContext(props, {\n guest,\n node,\n done: () => {\n node.gracefulShutdown();\n },\n logOut: async () => {\n node.gracefulShutdown();\n },\n });\n\n return context;\n }\n\n async createContext(\n props: TestJazzContextManagerProps<Acc>,\n authProps?: JazzContextManagerAuthProps,\n ) {\n this.props = props;\n\n if (!syncServer.current) {\n throw new Error(\n \"You need to setup a test sync server with setupJazzTestSync to use the Auth functions\",\n );\n }\n\n const context = await createJazzContext<Acc>({\n credentials: authProps?.credentials,\n defaultProfileName: props.defaultProfileName,\n newAccountProps: authProps?.newAccountProps,\n peersToLoadFrom: [getPeerConnectedToTestSyncServer()],\n crypto: await TestJSCrypto.create(),\n sessionProvider: randomSessionProvider,\n authSecretStorage: this.getAuthSecretStorage(),\n AccountSchema: props.AccountSchema,\n });\n\n this.updateContext(props, {\n me: context.account,\n node: context.node,\n done: () => {\n context.done();\n },\n logOut: () => {\n return context.logOut();\n },\n });\n }\n}\n\nexport function linkAccounts(\n a: Account,\n b: Account,\n aRole: \"server\" | \"client\" = \"server\",\n bRole: \"server\" | \"client\" = \"server\",\n) {\n const [aPeer, bPeer] = cojsonInternals.connectedPeers(b.id, a.id, {\n peer1role: aRole,\n peer2role: bRole,\n });\n\n a._raw.core.node.syncManager.addPeer(aPeer);\n b._raw.core.node.syncManager.addPeer(bPeer);\n}\n\nexport async function setupJazzTestSync() {\n if (syncServer.current) {\n syncServer.current.gracefulShutdown();\n }\n\n const account = await Account.create({\n creationProps: {\n name: \"Test Account\",\n },\n crypto: await TestJSCrypto.create(),\n });\n\n syncServer.current = account._raw.core.node;\n\n return account;\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAsC,iBAAuB;AAC7D,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAmB7B,IAAM,aAA4C,EAAE,SAAS,KAAK;AAY3D,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,aAAa,SAAS;AACpB,QAAI,eAAe,cAAc,UAAU,WAAW,SAAS,OAAO,GAAG;AAEvE,YAAM,SAAS,IAAI,aAAa;AAEhC,aAAO,OAAO,CAAC,YACb,WAAW,gBAAgB,gBAAgB,QAAQ,OAAO,CAAC;AAC7D,aAAO,SAAS,CAAC,WACf,KAAK,MAAM,OAAO,UAAU,WAAW,MAAM,CAAC;AAChD,aAAO,UAAU,CAAC,YAChB,cAAc,gBAAgB,gBAAgB,OAAO,CAAC;AACxD,aAAO,aAAa,CAAC,cACnB,UAAU,UAAU,cAAc,MAAM;AAE1C,a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K,KAAK,KAAK,YAAY,QAAQ,KAAK;AAC1C,IAAE,KAAK,KAAK,KAAK,YAAY,QAAQ,KAAK;AAC5C;AAEA,eAAsB,oBAAoB;AACxC,MAAI,WAAW,SAAS;AACtB,eAAW,QAAQ,iBAAiB;AAAA,EACtC;AAEA,QAAM,UAAU,MAAM,QAAQ,OAAO;AAAA,IACnC,eAAe;AAAA,MACb,MAAM;AAAA,IACR;AAAA,IACA,QAAQ,MAAM,aAAa,OAAO;AAAA,EACpC,CAAC;AAED,aAAW,UAAU,QAAQ,KAAK,KAAK;AAEvC,SAAO;AACT;","names":["account"]}
|
package/package.json
CHANGED
@@ -1,32 +1,26 @@
|
|
1
1
|
{
|
2
2
|
"name": "jazz-tools",
|
3
|
-
"module": "dist/
|
4
|
-
"main": "dist/
|
5
|
-
"types": "src/index.
|
6
|
-
"react-native": "dist/native/index.native.js",
|
3
|
+
"module": "dist/index.js",
|
4
|
+
"main": "dist/index.js",
|
5
|
+
"types": "src/index.ts",
|
7
6
|
"exports": {
|
8
7
|
".": {
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"default": "./dist/index.web.js"
|
12
|
-
},
|
13
|
-
"./native": {
|
14
|
-
"react-native": "./dist/index.native.js",
|
15
|
-
"types": "./src/index.native.ts",
|
16
|
-
"default": "./dist/index.native.js"
|
8
|
+
"types": "./src/index.ts",
|
9
|
+
"default": "./dist/index.js"
|
17
10
|
},
|
18
11
|
"./testing": {
|
19
12
|
"types": "./src/testing.ts",
|
20
13
|
"default": "./dist/testing.js"
|
21
14
|
},
|
15
|
+
"./dist/*": "./dist/*",
|
22
16
|
"./src/*": "./src/*"
|
23
17
|
},
|
24
18
|
"type": "module",
|
25
19
|
"license": "MIT",
|
26
|
-
"version": "0.10.
|
20
|
+
"version": "0.10.1",
|
27
21
|
"dependencies": {
|
28
22
|
"@scure/bip39": "^1.3.0",
|
29
|
-
"cojson": "0.10.
|
23
|
+
"cojson": "0.10.1"
|
30
24
|
},
|
31
25
|
"devDependencies": {
|
32
26
|
"tsup": "8.3.5",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { JsonValue, RawCoValue } from "cojson";
|
2
|
-
import {
|
2
|
+
import { CojsonInternalTypes } from "cojson";
|
3
3
|
import {
|
4
4
|
type CoValue,
|
5
5
|
type CoValueClass,
|
@@ -33,7 +33,7 @@ export type UnCo<T> = T extends co<infer A> ? A : T;
|
|
33
33
|
|
34
34
|
const optional = {
|
35
35
|
ref: optionalRef,
|
36
|
-
json<T extends CoJsonValue<T>>(): co<T | undefined> {
|
36
|
+
json<T extends CojsonInternalTypes.CoJsonValue<T>>(): co<T | undefined> {
|
37
37
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
38
38
|
return { [SchemaInit]: "json" satisfies Schema } as any;
|
39
39
|
},
|
@@ -85,7 +85,7 @@ export const co = {
|
|
85
85
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
86
86
|
return { [SchemaInit]: "json" satisfies Schema } as any;
|
87
87
|
},
|
88
|
-
json<T extends CoJsonValue<T>>(): co<T> {
|
88
|
+
json<T extends CojsonInternalTypes.CoJsonValue<T>>(): co<T> {
|
89
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
90
90
|
return { [SchemaInit]: "json" satisfies Schema } as any;
|
91
91
|
},
|
package/src/index.ts
ADDED
package/src/testing.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { WasmCrypto } from "cojson";
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { beforeEach, describe, expect, test, vi } from "vitest";
|
3
3
|
import {
|
4
4
|
Account,
|
@@ -59,8 +59,8 @@ class TestJazzContextManager<Acc extends Account> extends JazzContextManager<
|
|
59
59
|
done: () => {
|
60
60
|
context.done();
|
61
61
|
},
|
62
|
-
logOut: () => {
|
63
|
-
context.logOut();
|
62
|
+
logOut: async () => {
|
63
|
+
await context.logOut();
|
64
64
|
},
|
65
65
|
});
|
66
66
|
}
|
package/src/tests/coFeed.test.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, test } from "vitest";
|
3
3
|
import {
|
4
4
|
Account,
|
@@ -6,11 +6,10 @@ import {
|
|
6
6
|
FileStream,
|
7
7
|
Group,
|
8
8
|
ID,
|
9
|
-
WasmCrypto,
|
10
9
|
co,
|
11
10
|
cojsonInternals,
|
12
11
|
isControlledAccount,
|
13
|
-
} from "../index.
|
12
|
+
} from "../index.js";
|
14
13
|
import {
|
15
14
|
createJazzContextFromExistingCredentials,
|
16
15
|
randomSessionProvider,
|
@@ -20,6 +19,8 @@ import { setupTwoNodes } from "./utils.js";
|
|
20
19
|
|
21
20
|
const Crypto = await WasmCrypto.create();
|
22
21
|
|
22
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
23
|
+
|
23
24
|
describe("Simple CoFeed operations", async () => {
|
24
25
|
const me = await Account.create({
|
25
26
|
creationProps: { name: "Hermes Puggington" },
|
package/src/tests/coList.test.ts
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { cojsonInternals } from "cojson";
|
2
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
3
|
import { describe, expect, test } from "vitest";
|
3
4
|
import {
|
4
5
|
Account,
|
5
6
|
CoList,
|
6
7
|
Group,
|
7
|
-
WasmCrypto,
|
8
8
|
co,
|
9
|
-
cojsonInternals,
|
10
9
|
createJazzContextFromExistingCredentials,
|
11
10
|
isControlledAccount,
|
12
|
-
} from "../index.
|
11
|
+
} from "../index.js";
|
13
12
|
import { randomSessionProvider } from "../internal.js";
|
14
13
|
|
14
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
15
|
+
|
15
16
|
const Crypto = await WasmCrypto.create();
|
16
17
|
|
17
18
|
describe("Simple CoList operations", async () => {
|
package/src/tests/coMap.test.ts
CHANGED
@@ -1,18 +1,19 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, expectTypeOf, test } from "vitest";
|
3
3
|
import { Group, randomSessionProvider } from "../exports.js";
|
4
4
|
import {
|
5
5
|
Account,
|
6
6
|
CoMap,
|
7
7
|
Encoders,
|
8
|
-
WasmCrypto,
|
9
8
|
co,
|
10
9
|
cojsonInternals,
|
11
10
|
createJazzContextFromExistingCredentials,
|
12
11
|
isControlledAccount,
|
13
|
-
} from "../index.
|
12
|
+
} from "../index.js";
|
14
13
|
import { setupTwoNodes } from "./utils.js";
|
15
14
|
|
15
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
16
|
+
|
16
17
|
const Crypto = await WasmCrypto.create();
|
17
18
|
|
18
19
|
class TestMap extends CoMap {
|
@@ -1,17 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, test } from "vitest";
|
3
3
|
import {
|
4
4
|
Account,
|
5
5
|
CoPlainText,
|
6
|
-
WasmCrypto,
|
7
6
|
cojsonInternals,
|
8
7
|
createJazzContextFromExistingCredentials,
|
9
8
|
isControlledAccount,
|
10
|
-
} from "../index.
|
9
|
+
} from "../index.js";
|
11
10
|
import { randomSessionProvider } from "../internal.js";
|
12
11
|
|
13
12
|
const Crypto = await WasmCrypto.create();
|
14
13
|
|
14
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
15
|
+
|
15
16
|
describe("CoPlainText", () => {
|
16
17
|
const initNodeAndText = async () => {
|
17
18
|
const me = await Account.create({
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { describe, expect, test } from "vitest";
|
3
3
|
import { splitNode } from "../coValues/coRichText.js";
|
4
4
|
import {
|
@@ -7,13 +7,13 @@ import {
|
|
7
7
|
Marks,
|
8
8
|
type TextPos,
|
9
9
|
type TreeNode,
|
10
|
-
WasmCrypto,
|
11
10
|
cojsonInternals,
|
12
11
|
createJazzContextFromExistingCredentials,
|
13
12
|
isControlledAccount,
|
14
|
-
} from "../index.
|
13
|
+
} from "../index.js";
|
15
14
|
import { randomSessionProvider } from "../internal.js";
|
16
15
|
|
16
|
+
const connectedPeers = cojsonInternals.connectedPeers;
|
17
17
|
const Crypto = await WasmCrypto.create();
|
18
18
|
|
19
19
|
describe("CoRichText", async () => {
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import { AgentSecret
|
1
|
+
import { AgentSecret } from "cojson";
|
2
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
3
|
import { beforeEach, describe, expect, test, vi } from "vitest";
|
3
4
|
import {
|
4
5
|
Account,
|
@@ -21,7 +22,6 @@ import {
|
|
21
22
|
setupJazzTestSync,
|
22
23
|
} from "../testing";
|
23
24
|
import { loadCoValueOrFail } from "./utils";
|
24
|
-
|
25
25
|
const Crypto = await WasmCrypto.create();
|
26
26
|
|
27
27
|
KvStoreContext.getInstance().initialize(new InMemoryKVStore());
|
@@ -1,5 +1,5 @@
|
|
1
|
-
const Crypto = await WasmCrypto.create();
|
2
1
|
import { cojsonInternals } from "cojson";
|
2
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
3
3
|
import { describe, expect, expectTypeOf, test } from "vitest";
|
4
4
|
import {
|
5
5
|
Account,
|
@@ -9,13 +9,13 @@ import {
|
|
9
9
|
ID,
|
10
10
|
Profile,
|
11
11
|
SessionID,
|
12
|
-
WasmCrypto,
|
13
12
|
co,
|
14
13
|
createJazzContextFromExistingCredentials,
|
15
14
|
isControlledAccount,
|
16
|
-
} from "../index.
|
15
|
+
} from "../index.js";
|
17
16
|
import { randomSessionProvider } from "../internal.js";
|
18
17
|
|
18
|
+
const Crypto = await WasmCrypto.create();
|
19
19
|
const { connectedPeers } = cojsonInternals;
|
20
20
|
|
21
21
|
class TestMap extends CoMap {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { WasmCrypto } from "cojson";
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
2
|
import { beforeEach, describe, expect, test } from "vitest";
|
3
3
|
import { Account, CoMap, Group, Profile, co } from "../exports.js";
|
4
4
|
import { createJazzTestAccount } from "../testing.js";
|
package/src/tests/schema.test.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { WasmCrypto } from "cojson";
|
2
|
-
import { beforeAll, describe, expect,
|
1
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
2
|
+
import { beforeAll, describe, expect, it } from "vitest";
|
3
3
|
import { SchemaUnion } from "../coValues/schemaUnion.js";
|
4
4
|
import {
|
5
5
|
Account,
|
package/src/tests/utils.ts
CHANGED
@@ -2,12 +2,12 @@ import { isControlledAccount } from "../coValues/account";
|
|
2
2
|
|
3
3
|
import { CoID, LocalNode, RawCoValue } from "cojson";
|
4
4
|
import { cojsonInternals } from "cojson";
|
5
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
5
6
|
import {
|
6
7
|
Account,
|
7
|
-
WasmCrypto,
|
8
8
|
createJazzContextFromExistingCredentials,
|
9
9
|
randomSessionProvider,
|
10
|
-
} from "../index
|
10
|
+
} from "../index";
|
11
11
|
|
12
12
|
const Crypto = await WasmCrypto.create();
|
13
13
|
|
package/tsconfig.json
CHANGED
package/tsup.config.ts
CHANGED