@modelprofile.com/authswitch 8.0.0 → 8.1.0
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/authority-import-contract.d.ts +207 -0
- package/dist_ts/authority-import-contract.js +18 -0
- package/dist_ts/classes.authoritycli.d.ts +4 -0
- package/dist_ts/classes.authoritycli.js +148 -11
- package/dist_ts/classes.authorityclient.d.ts +7 -0
- package/dist_ts/classes.authorityclient.js +13 -1
- package/dist_ts/classes.authoritydaemon.d.ts +4 -0
- package/dist_ts/classes.authoritydaemon.js +72 -1
- package/dist_ts/classes.authoritydatabase.d.ts +5 -0
- package/dist_ts/classes.authoritydatabase.js +20 -5
- package/dist_ts/classes.authorityimport.d.ts +161 -0
- package/dist_ts/classes.authorityimport.js +638 -0
- package/dist_ts/classes.authoritymodels.d.ts +12 -0
- package/dist_ts/classes.authoritymodels.js +17 -1
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +6 -3
- package/dist_ts/ts_migration/legacysources/authswitchstores.d.ts +2 -0
- package/dist_ts/ts_migration/legacysources/authswitchstores.js +244 -0
- package/dist_ts/ts_migration/legacysources/index.d.ts +18 -0
- package/dist_ts/ts_migration/legacysources/index.js +24 -0
- package/dist_ts/ts_migration/legacysources/material.d.ts +37 -0
- package/dist_ts/ts_migration/legacysources/material.js +120 -0
- package/dist_ts/ts_migration/legacysources/nativestores.d.ts +2 -0
- package/dist_ts/ts_migration/legacysources/nativestores.js +207 -0
- package/dist_ts/ts_migration/legacysources/shared.d.ts +124 -0
- package/dist_ts/ts_migration/legacysources/shared.js +142 -0
- package/package.json +5 -1
- package/readme.md +46 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/authority-import-contract.ts +216 -0
- package/ts/classes.authoritycli.ts +164 -10
- package/ts/classes.authorityclient.ts +22 -0
- package/ts/classes.authoritydaemon.ts +72 -0
- package/ts/classes.authoritydatabase.ts +20 -4
- package/ts/classes.authorityimport.ts +718 -0
- package/ts/classes.authoritymodels.ts +21 -0
- package/ts/index.ts +5 -2
- package/ts/ts_migration/legacysources/authswitchstores.ts +211 -0
- package/ts/ts_migration/legacysources/index.ts +35 -0
- package/ts/ts_migration/legacysources/material.ts +134 -0
- package/ts/ts_migration/legacysources/nativestores.ts +204 -0
- package/ts/ts_migration/legacysources/shared.ts +220 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
assertStoredAuthorityBinding, assertStoredAuthorityClaudeHandoff, assertStoredAuthorityClaudeHome,
|
|
9
9
|
assertStoredAuthorityEnrollment, assertStoredAuthorityGrant,
|
|
10
10
|
assertStoredAuthorityHandoff, assertStoredAuthorityMigrationLedger, assertStoredAuthorityOperation,
|
|
11
|
-
assertStoredAuthorityUsage,
|
|
11
|
+
assertStoredAuthorityUsage, grantRefresherTransferRefusal, transfersGrantRefresher,
|
|
12
12
|
type IStoredAuthorityAccount, type IStoredAuthorityBinding, type IStoredAuthorityClaudeHandoff,
|
|
13
13
|
type IStoredAuthorityClaudeHome, type IStoredAuthorityCodexHome, type IStoredAuthorityEnrollment,
|
|
14
14
|
type IStoredAuthorityEvent, type IStoredAuthorityGrant, type IStoredAuthorityHandoff,
|
|
@@ -573,6 +573,19 @@ export class AuthSwitchAuthorityDatabase {
|
|
|
573
573
|
return stored.map(item => AuthSwitchAuthorityMigrationLedgerModel.exact.toPersisted(item));
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
+
/** Every migration ledger row in id order, one bounded page at a time. */
|
|
577
|
+
public async migrationLedgerPage(after: string | null,
|
|
578
|
+
limit = 128): Promise<{ rows: IStoredAuthorityMigrationLedger[]; nextCursor: string | null }> {
|
|
579
|
+
this.db();
|
|
580
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 256) throw new Error('Invalid migration page size.');
|
|
581
|
+
const stored = await AuthSwitchAuthorityMigrationLedgerModel.exact.findStored({
|
|
582
|
+
filter: after ? { id: { $gt: after } } : {}, sort: { id: 1 }, limit: limit + 1,
|
|
583
|
+
});
|
|
584
|
+
const rows = stored.slice(0, limit)
|
|
585
|
+
.map(item => AuthSwitchAuthorityMigrationLedgerModel.exact.toPersisted(item));
|
|
586
|
+
return { rows, nextCursor: stored.length > limit ? rows[rows.length - 1].id : null };
|
|
587
|
+
}
|
|
588
|
+
|
|
576
589
|
public async readAccountAndPrimaryGrant(id: string): Promise<{
|
|
577
590
|
account: IStoredAuthorityAccount | null; grant: IStoredAuthorityGrant | null;
|
|
578
591
|
}> {
|
|
@@ -973,9 +986,8 @@ export class AuthSwitchAuthorityDatabase {
|
|
|
973
986
|
if (accountStored && accountStored.primaryGrantId !== grantId) {
|
|
974
987
|
throw new Error('Primary grant identity cannot be replaced.');
|
|
975
988
|
}
|
|
976
|
-
if (grantStored &&
|
|
977
|
-
|
|
978
|
-
throw new Error('Native ownership requires a verified handoff.');
|
|
989
|
+
if (grantStored && transfersGrantRefresher(grantStored.owner, draft.grant.owner)) {
|
|
990
|
+
throw new Error(grantRefresherTransferRefusal(grantStored.owner, draft.grant.owner));
|
|
979
991
|
}
|
|
980
992
|
await this.persistAccount(session, accountStored, draft.account);
|
|
981
993
|
await this.persistGrant(session, grantStored, draft.grant);
|
|
@@ -1124,6 +1136,10 @@ export class AuthSwitchAuthorityDatabase {
|
|
|
1124
1136
|
|| draft.providerId !== account.providerId || draft.updateId !== updateId) {
|
|
1125
1137
|
throw new Error('Secondary grant identity is invalid.');
|
|
1126
1138
|
}
|
|
1139
|
+
// A secondary grant transfers its refresher by a verified handoff as well; one token, one refresher.
|
|
1140
|
+
if (grant && transfersGrantRefresher(grant.owner, draft.owner)) {
|
|
1141
|
+
throw new Error(grantRefresherTransferRefusal(grant.owner, draft.owner));
|
|
1142
|
+
}
|
|
1127
1143
|
await this.persistGrant(session, grantStored, draft);
|
|
1128
1144
|
const updatedAccount = { ...account, revision: account.revision + 1,
|
|
1129
1145
|
statusObservedAt: draft.statusObservedAt, updateId };
|