jazz-tools 0.9.9 → 0.9.10
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 +7 -7
- package/CHANGELOG.md +8 -0
- package/dist/{chunk-VQZOWIPU.js → chunk-ICWP2U63.js} +78 -115
- package/dist/chunk-ICWP2U63.js.map +1 -0
- package/dist/index.native.js +1 -1
- package/dist/index.web.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/coMap.ts +0 -2
- package/src/coValues/coPlainText.ts +0 -31
- package/src/coValues/coRichText.ts +1 -0
- package/src/implementation/createContext.ts +86 -109
- package/src/tests/groupsAndAccounts.test.ts +3 -3
- package/tsconfig.native.json +1 -1
- package/tsconfig.web.json +1 -1
- package/dist/chunk-VQZOWIPU.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.9.
|
2
|
+
> jazz-tools@0.9.10 build /home/runner/work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index.web":"src/index.web.ts","index.native":"src/index.native.ts","testing":"src/testing.ts"}
|
@@ -9,12 +9,12 @@
|
|
9
9
|
[34mCLI[39m Target: es2021
|
10
10
|
[34mCLI[39m Cleaning output folder
|
11
11
|
[34mESM[39m Build start
|
12
|
+
[32mESM[39m [1mdist/index.web.js [22m[32m1.15 KB[39m
|
12
13
|
[32mESM[39m [1mdist/index.native.js [22m[32m1.14 KB[39m
|
13
14
|
[32mESM[39m [1mdist/testing.js [22m[32m2.30 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
15
|
-
[32mESM[39m [1mdist/testing.js.map [22m[32m4.89 KB[39m
|
16
|
-
[32mESM[39m [1mdist/index.web.js [22m[32m1.15 KB[39m
|
17
|
-
[32mESM[39m [1mdist/index.native.js.map [22m[32m283.00 B[39m
|
18
|
-
[32mESM[39m [1mdist/chunk-VQZOWIPU.js.map [22m[32m238.27 KB[39m
|
15
|
+
[32mESM[39m [1mdist/chunk-ICWP2U63.js [22m[32m94.94 KB[39m
|
19
16
|
[32mESM[39m [1mdist/index.web.js.map [22m[32m273.00 B[39m
|
20
|
-
[32mESM[39m
|
17
|
+
[32mESM[39m [1mdist/index.native.js.map [22m[32m283.00 B[39m
|
18
|
+
[32mESM[39m [1mdist/testing.js.map [22m[32m4.89 KB[39m
|
19
|
+
[32mESM[39m [1mdist/chunk-ICWP2U63.js.map [22m[32m235.54 KB[39m
|
20
|
+
[32mESM[39m ⚡️ Build success in 88ms
|
package/CHANGELOG.md
CHANGED
@@ -454,110 +454,88 @@ async function randomSessionProvider(accountID, crypto) {
|
|
454
454
|
};
|
455
455
|
}
|
456
456
|
async function createJazzContext(options) {
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
457
|
+
if (!("auth" in options)) {
|
458
|
+
return createAnonymousJazzContext({
|
459
|
+
peersToLoadFrom: options.peersToLoadFrom,
|
460
|
+
crypto: options.crypto
|
461
|
+
});
|
462
|
+
}
|
463
|
+
const { auth, sessionProvider, peersToLoadFrom, crypto } = options;
|
464
|
+
const AccountSchema = options.AccountSchema ?? RegisteredSchemas["Account"];
|
465
|
+
const authResult = await auth.start(crypto);
|
466
|
+
if (authResult.type === "existing") {
|
467
|
+
const { sessionID, sessionDone } = await sessionProvider(
|
468
|
+
authResult.credentials.accountID,
|
469
|
+
crypto
|
470
|
+
);
|
471
|
+
const node = await LocalNode.withLoadedAccount({
|
472
|
+
accountID: authResult.credentials.accountID,
|
473
|
+
accountSecret: authResult.credentials.secret,
|
474
|
+
sessionID,
|
475
|
+
peersToLoadFrom,
|
476
|
+
crypto,
|
477
|
+
migration: async (rawAccount, _node, creationProps) => {
|
478
|
+
const account2 = new AccountSchema({
|
479
|
+
fromRaw: rawAccount
|
480
|
+
});
|
481
|
+
activeAccountContext.set(account2);
|
482
|
+
await account2.applyMigration(creationProps);
|
483
|
+
}
|
484
|
+
});
|
485
|
+
const account = AccountSchema.fromNode(node);
|
486
|
+
activeAccountContext.set(account);
|
487
|
+
if (authResult.saveCredentials) {
|
488
|
+
await authResult.saveCredentials({
|
489
|
+
accountID: node.account.id,
|
490
|
+
secret: node.account.agentSecret
|
462
491
|
});
|
463
492
|
}
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
const { sessionID, sessionDone } = await sessionProvider(
|
476
|
-
authResult.credentials.accountID,
|
477
|
-
crypto
|
478
|
-
);
|
479
|
-
try {
|
480
|
-
const node = await LocalNode.withLoadedAccount({
|
481
|
-
accountID: authResult.credentials.accountID,
|
482
|
-
accountSecret: authResult.credentials.secret,
|
483
|
-
sessionID,
|
484
|
-
peersToLoadFrom,
|
485
|
-
crypto,
|
486
|
-
migration: async (rawAccount, _node, creationProps) => {
|
487
|
-
const account2 = new AccountSchema({
|
488
|
-
fromRaw: rawAccount
|
489
|
-
});
|
490
|
-
activeAccountContext.set(account2);
|
491
|
-
await account2.applyMigration(creationProps);
|
492
|
-
}
|
493
|
-
});
|
494
|
-
const account = AccountSchema.fromNode(node);
|
495
|
-
activeAccountContext.set(account);
|
496
|
-
if (authResult.saveCredentials) {
|
497
|
-
await authResult.saveCredentials({
|
498
|
-
accountID: node.account.id,
|
499
|
-
secret: node.account.agentSecret
|
500
|
-
});
|
501
|
-
}
|
502
|
-
authResult.onSuccess();
|
503
|
-
return {
|
504
|
-
account,
|
505
|
-
done: () => {
|
506
|
-
node.gracefulShutdown();
|
507
|
-
sessionDone();
|
508
|
-
},
|
509
|
-
logOut: () => {
|
510
|
-
node.gracefulShutdown();
|
511
|
-
sessionDone();
|
512
|
-
authResult.logOut();
|
513
|
-
}
|
514
|
-
};
|
515
|
-
} catch (e) {
|
516
|
-
authResult.onError(new Error("Error loading account", { cause: e }));
|
517
|
-
sessionDone();
|
518
|
-
}
|
519
|
-
} catch (e) {
|
520
|
-
authResult.onError(
|
521
|
-
new Error("Error acquiring sessionID", { cause: e })
|
522
|
-
);
|
493
|
+
authResult.onSuccess();
|
494
|
+
return {
|
495
|
+
account,
|
496
|
+
done: () => {
|
497
|
+
node.gracefulShutdown();
|
498
|
+
sessionDone();
|
499
|
+
},
|
500
|
+
logOut: () => {
|
501
|
+
node.gracefulShutdown();
|
502
|
+
sessionDone();
|
503
|
+
authResult.logOut();
|
523
504
|
}
|
524
|
-
}
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
});
|
535
|
-
activeAccountContext.set(account2);
|
536
|
-
await account2.applyMigration(creationProps);
|
537
|
-
}
|
538
|
-
});
|
539
|
-
const account = AccountSchema.fromNode(node);
|
540
|
-
activeAccountContext.set(account);
|
541
|
-
await authResult.saveCredentials({
|
542
|
-
accountID: node.account.id,
|
543
|
-
secret: node.account.agentSecret
|
505
|
+
};
|
506
|
+
} else if (authResult.type === "new") {
|
507
|
+
const { node } = await LocalNode.withNewlyCreatedAccount({
|
508
|
+
creationProps: authResult.creationProps,
|
509
|
+
peersToLoadFrom,
|
510
|
+
crypto,
|
511
|
+
initialAgentSecret: authResult.initialSecret,
|
512
|
+
migration: async (rawAccount, _node, creationProps) => {
|
513
|
+
const account2 = new AccountSchema({
|
514
|
+
fromRaw: rawAccount
|
544
515
|
});
|
545
|
-
|
546
|
-
|
547
|
-
account,
|
548
|
-
done: () => {
|
549
|
-
node.gracefulShutdown();
|
550
|
-
},
|
551
|
-
logOut: () => {
|
552
|
-
node.gracefulShutdown();
|
553
|
-
authResult.logOut();
|
554
|
-
}
|
555
|
-
};
|
556
|
-
} catch (e) {
|
557
|
-
authResult.onError(new Error("Error creating account", { cause: e }));
|
516
|
+
activeAccountContext.set(account2);
|
517
|
+
await account2.applyMigration(creationProps);
|
558
518
|
}
|
559
|
-
}
|
519
|
+
});
|
520
|
+
const account = AccountSchema.fromNode(node);
|
521
|
+
activeAccountContext.set(account);
|
522
|
+
await authResult.saveCredentials({
|
523
|
+
accountID: node.account.id,
|
524
|
+
secret: node.account.agentSecret
|
525
|
+
});
|
526
|
+
authResult.onSuccess();
|
527
|
+
return {
|
528
|
+
account,
|
529
|
+
done: () => {
|
530
|
+
node.gracefulShutdown();
|
531
|
+
},
|
532
|
+
logOut: () => {
|
533
|
+
node.gracefulShutdown();
|
534
|
+
authResult.logOut();
|
535
|
+
}
|
536
|
+
};
|
560
537
|
}
|
538
|
+
throw new Error("Invalid auth result");
|
561
539
|
}
|
562
540
|
async function createAnonymousJazzContext({
|
563
541
|
peersToLoadFrom,
|
@@ -2837,22 +2815,6 @@ var CoPlainText = class extends String {
|
|
2837
2815
|
/**
|
2838
2816
|
* Load a `CoPlainText` with a given ID, as a given account.
|
2839
2817
|
*
|
2840
|
-
* `depth` specifies which (if any) fields that reference other CoValues to load as well before resolving.
|
2841
|
-
* The `DeeplyLoaded` return type guarantees that corresponding referenced CoValues are loaded to the specified depth.
|
2842
|
-
*
|
2843
|
-
* You can pass `[]` or `{}` for shallowly loading only this CoPlainText, or `{ fieldA: depthA, fieldB: depthB }` for recursively loading referenced CoValues.
|
2844
|
-
*
|
2845
|
-
* Check out the `load` methods on `CoMap`/`CoList`/`CoStream`/`Group`/`Account` to see which depth structures are valid to nest.
|
2846
|
-
*
|
2847
|
-
* @example
|
2848
|
-
* ```ts
|
2849
|
-
* const person = await Person.load(
|
2850
|
-
* "co_zdsMhHtfG6VNKt7RqPUPvUtN2Ax",
|
2851
|
-
* me,
|
2852
|
-
* { pet: {} }
|
2853
|
-
* );
|
2854
|
-
* ```
|
2855
|
-
*
|
2856
2818
|
* @category Subscription & Loading
|
2857
2819
|
*/
|
2858
2820
|
static load(id, as) {
|
@@ -3092,6 +3054,7 @@ var CoRichText = class extends CoMap {
|
|
3092
3054
|
end + 1,
|
3093
3055
|
mark.endBefore,
|
3094
3056
|
RangeClass,
|
3057
|
+
// @ts-ignore Some Typescript versions flag this as an error
|
3095
3058
|
{},
|
3096
3059
|
{
|
3097
3060
|
markOwner: mark.sourceMark._owner || this._owner
|
@@ -3417,4 +3380,4 @@ export {
|
|
3417
3380
|
SchemaUnion
|
3418
3381
|
};
|
3419
3382
|
/* istanbul ignore file -- @preserve */
|
3420
|
-
//# sourceMappingURL=chunk-
|
3383
|
+
//# sourceMappingURL=chunk-ICWP2U63.js.map
|