@atproto/pds 0.4.116 → 0.4.118
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/CHANGELOG.md +25 -0
- package/dist/account-manager/account-manager.d.ts +5 -2
- package/dist/account-manager/account-manager.d.ts.map +1 -1
- package/dist/account-manager/account-manager.js.map +1 -1
- package/dist/actor-store/blob/transactor.d.ts +2 -1
- package/dist/actor-store/blob/transactor.d.ts.map +1 -1
- package/dist/actor-store/blob/transactor.js +19 -5
- package/dist/actor-store/blob/transactor.js.map +1 -1
- package/dist/api/com/atproto/repo/uploadBlob.d.ts.map +1 -1
- package/dist/api/com/atproto/repo/uploadBlob.js +1 -0
- package/dist/api/com/atproto/repo/uploadBlob.js.map +1 -1
- package/dist/config/env.d.ts +1 -0
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +1 -0
- package/dist/config/env.js.map +1 -1
- package/dist/config/secrets.d.ts +1 -0
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +1 -0
- package/dist/config/secrets.js.map +1 -1
- package/dist/context.d.ts +3 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +19 -0
- package/dist/context.js.map +1 -1
- package/dist/lexicon/index.d.ts +10 -0
- package/dist/lexicon/index.d.ts.map +1 -1
- package/dist/lexicon/index.js +20 -0
- package/dist/lexicon/index.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +536 -4
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +286 -2
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/defs.d.ts +27 -0
- package/dist/lexicon/types/app/bsky/unspecced/defs.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/defs.js +18 -0
- package/dist/lexicon/types/app/bsky/unspecced/defs.js.map +1 -1
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacks.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacks.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacks.js +7 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacks.js.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacksSkeleton.d.ts +37 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacksSkeleton.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacksSkeleton.js +7 -0
- package/dist/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacksSkeleton.js.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrends.d.ts +36 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrends.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrends.js +7 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrends.js.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrendsSkeleton.d.ts +38 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrendsSkeleton.d.ts.map +1 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrendsSkeleton.js +7 -0
- package/dist/lexicon/types/app/bsky/unspecced/getTrendsSkeleton.js.map +1 -0
- package/dist/lexicon/types/chat/bsky/convo/defs.d.ts +5 -1
- package/dist/lexicon/types/chat/bsky/convo/defs.d.ts.map +1 -1
- package/dist/lexicon/types/chat/bsky/convo/defs.js.map +1 -1
- package/dist/lexicon/types/com/atproto/admin/updateAccountSigningKey.d.ts +31 -0
- package/dist/lexicon/types/com/atproto/admin/updateAccountSigningKey.d.ts.map +1 -0
- package/dist/lexicon/types/com/atproto/admin/updateAccountSigningKey.js +7 -0
- package/dist/lexicon/types/com/atproto/admin/updateAccountSigningKey.js.map +1 -0
- package/dist/repo/prepare.d.ts.map +1 -1
- package/dist/repo/prepare.js +1 -0
- package/dist/repo/prepare.js.map +1 -1
- package/dist/repo/types.d.ts +1 -0
- package/dist/repo/types.d.ts.map +1 -1
- package/dist/repo/types.js.map +1 -1
- package/dist/scripts/index.d.ts +8 -1
- package/dist/scripts/index.d.ts.map +1 -1
- package/dist/scripts/index.js +11 -0
- package/dist/scripts/index.js.map +1 -1
- package/dist/scripts/publish-identity.d.ts +8 -0
- package/dist/scripts/publish-identity.d.ts.map +1 -0
- package/dist/scripts/publish-identity.js +46 -0
- package/dist/scripts/publish-identity.js.map +1 -0
- package/dist/scripts/rebuild-repo.d.ts +10 -2
- package/dist/scripts/rebuild-repo.d.ts.map +1 -1
- package/dist/scripts/rebuild-repo.js +21 -12
- package/dist/scripts/rebuild-repo.js.map +1 -1
- package/dist/scripts/rotate-keys.d.ts +18 -0
- package/dist/scripts/rotate-keys.d.ts.map +1 -0
- package/dist/scripts/rotate-keys.js +115 -0
- package/dist/scripts/rotate-keys.js.map +1 -0
- package/dist/scripts/sequencer-recovery/index.d.ts +3 -0
- package/dist/scripts/sequencer-recovery/index.d.ts.map +1 -0
- package/dist/scripts/sequencer-recovery/index.js +17 -0
- package/dist/scripts/sequencer-recovery/index.js.map +1 -0
- package/dist/scripts/sequencer-recovery/recoverer.d.ts +27 -0
- package/dist/scripts/sequencer-recovery/recoverer.d.ts.map +1 -0
- package/dist/scripts/sequencer-recovery/recoverer.js +235 -0
- package/dist/scripts/sequencer-recovery/recoverer.js.map +1 -0
- package/dist/scripts/sequencer-recovery/recovery-db.d.ts +18 -0
- package/dist/scripts/sequencer-recovery/recovery-db.d.ts.map +1 -0
- package/dist/scripts/sequencer-recovery/recovery-db.js +45 -0
- package/dist/scripts/sequencer-recovery/recovery-db.js.map +1 -0
- package/dist/scripts/sequencer-recovery/repair-repos.d.ts +3 -0
- package/dist/scripts/sequencer-recovery/repair-repos.d.ts.map +1 -0
- package/dist/scripts/sequencer-recovery/repair-repos.js +45 -0
- package/dist/scripts/sequencer-recovery/repair-repos.js.map +1 -0
- package/dist/scripts/sequencer-recovery/user-queues.d.ts +12 -0
- package/dist/scripts/sequencer-recovery/user-queues.d.ts.map +1 -0
- package/dist/scripts/sequencer-recovery/user-queues.js +54 -0
- package/dist/scripts/sequencer-recovery/user-queues.js.map +1 -0
- package/dist/scripts/util.d.ts +2 -0
- package/dist/scripts/util.d.ts.map +1 -0
- package/dist/scripts/util.js +12 -0
- package/dist/scripts/util.js.map +1 -0
- package/dist/sequencer/sequencer.d.ts +2 -0
- package/dist/sequencer/sequencer.d.ts.map +1 -1
- package/dist/sequencer/sequencer.js +52 -42
- package/dist/sequencer/sequencer.js.map +1 -1
- package/package.json +10 -10
- package/src/account-manager/account-manager.ts +6 -2
- package/src/actor-store/blob/transactor.ts +25 -7
- package/src/api/com/atproto/repo/uploadBlob.ts +1 -0
- package/src/config/env.ts +2 -0
- package/src/config/secrets.ts +2 -0
- package/src/context.ts +23 -0
- package/src/lexicon/index.ts +62 -0
- package/src/lexicon/lexicons.ts +294 -2
- package/src/lexicon/types/app/bsky/unspecced/defs.ts +45 -0
- package/src/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacks.ts +54 -0
- package/src/lexicon/types/app/bsky/unspecced/getSuggestedStarterPacksSkeleton.ts +55 -0
- package/src/lexicon/types/app/bsky/unspecced/getTrends.ts +54 -0
- package/src/lexicon/types/app/bsky/unspecced/getTrendsSkeleton.ts +56 -0
- package/src/lexicon/types/chat/bsky/convo/defs.ts +2 -1
- package/src/lexicon/types/com/atproto/admin/updateAccountSigningKey.ts +48 -0
- package/src/repo/prepare.ts +1 -0
- package/src/repo/types.ts +1 -0
- package/src/scripts/README.md +40 -0
- package/src/scripts/index.ts +15 -0
- package/src/scripts/publish-identity.ts +54 -0
- package/src/scripts/rebuild-repo.ts +39 -12
- package/src/scripts/rotate-keys.ts +141 -0
- package/src/scripts/sequencer-recovery/index.ts +23 -0
- package/src/scripts/sequencer-recovery/recoverer.ts +289 -0
- package/src/scripts/sequencer-recovery/recovery-db.ts +64 -0
- package/src/scripts/sequencer-recovery/repair-repos.ts +48 -0
- package/src/scripts/sequencer-recovery/user-queues.ts +41 -0
- package/src/scripts/util.ts +7 -0
- package/src/sequencer/sequencer.ts +43 -40
- package/tests/recovery.test.ts +178 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.tests.tsbuildinfo +1 -1
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.getAndMigrateRecoveryDb = exports.getRecoveryDbFromSequencerLoc = void 0;
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
8
|
+
const db_1 = require("../../db");
|
9
|
+
const getRecoveryDbFromSequencerLoc = (sequencerLoc) => {
|
10
|
+
const recoveryDbLoc = node_path_1.default.join(node_path_1.default.dirname(sequencerLoc), 'recovery.sqlite');
|
11
|
+
return (0, exports.getAndMigrateRecoveryDb)(recoveryDbLoc);
|
12
|
+
};
|
13
|
+
exports.getRecoveryDbFromSequencerLoc = getRecoveryDbFromSequencerLoc;
|
14
|
+
const getAndMigrateRecoveryDb = async (location, disableWalAutoCheckpoint = false) => {
|
15
|
+
const pragmas = disableWalAutoCheckpoint
|
16
|
+
? { wal_autocheckpoint: '0' }
|
17
|
+
: {};
|
18
|
+
const db = db_1.Database.sqlite(location, pragmas);
|
19
|
+
const migrator = new db_1.Migrator(db.db, migrations);
|
20
|
+
await migrator.migrateToLatestOrThrow();
|
21
|
+
return db;
|
22
|
+
};
|
23
|
+
exports.getAndMigrateRecoveryDb = getAndMigrateRecoveryDb;
|
24
|
+
const migrations = {
|
25
|
+
'001': {
|
26
|
+
up: async (db) => {
|
27
|
+
await db.schema
|
28
|
+
.createTable('new_account')
|
29
|
+
.addColumn('did', 'varchar', (col) => col.primaryKey())
|
30
|
+
.addColumn('published', 'int2', (col) => col.notNull())
|
31
|
+
.execute();
|
32
|
+
await db.schema
|
33
|
+
.createTable('failed')
|
34
|
+
.addColumn('did', 'varchar', (col) => col.primaryKey())
|
35
|
+
.addColumn('error', 'varchar')
|
36
|
+
.addColumn('fixed', 'int2', (col) => col.notNull())
|
37
|
+
.execute();
|
38
|
+
},
|
39
|
+
down: async (db) => {
|
40
|
+
await db.schema.dropTable('new_account').execute();
|
41
|
+
await db.schema.dropTable('failed').execute();
|
42
|
+
},
|
43
|
+
},
|
44
|
+
};
|
45
|
+
//# sourceMappingURL=recovery-db.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"recovery-db.js","sourceRoot":"","sources":["../../../src/scripts/sequencer-recovery/recovery-db.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,iCAA6C;AAoBtC,MAAM,6BAA6B,GAAG,CAC3C,YAAoB,EACC,EAAE;IACvB,MAAM,aAAa,GAAG,mBAAI,CAAC,IAAI,CAAC,mBAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC,CAAA;IAC9E,OAAO,IAAA,+BAAuB,EAAC,aAAa,CAAC,CAAA;AAC/C,CAAC,CAAA;AALY,QAAA,6BAA6B,iCAKzC;AAEM,MAAM,uBAAuB,GAAG,KAAK,EAC1C,QAAgB,EAChB,wBAAwB,GAAG,KAAK,EACX,EAAE;IACvB,MAAM,OAAO,GAA2B,wBAAwB;QAC9D,CAAC,CAAC,EAAE,kBAAkB,EAAE,GAAG,EAAE;QAC7B,CAAC,CAAC,EAAE,CAAA;IACN,MAAM,EAAE,GAAG,aAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC7C,MAAM,QAAQ,GAAG,IAAI,aAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;IAChD,MAAM,QAAQ,CAAC,sBAAsB,EAAE,CAAA;IACvC,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAXY,QAAA,uBAAuB,2BAWnC;AAED,MAAM,UAA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use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.repairRepos = void 0;
|
4
|
+
const sequencer_1 = require("../../sequencer");
|
5
|
+
const rebuild_repo_1 = require("../rebuild-repo");
|
6
|
+
const recoverer_1 = require("./recoverer");
|
7
|
+
const recovery_db_1 = require("./recovery-db");
|
8
|
+
const repairRepos = async (ctx) => {
|
9
|
+
const recoveryDb = await (0, recovery_db_1.getRecoveryDbFromSequencerLoc)(ctx.sequencer.dbLocation);
|
10
|
+
const repairRes = await recoveryDb.db
|
11
|
+
.selectFrom('failed')
|
12
|
+
.select('did')
|
13
|
+
.where('failed.fixed', '=', 0)
|
14
|
+
.execute();
|
15
|
+
const dids = repairRes.map((row) => row.did);
|
16
|
+
let fixed = 0;
|
17
|
+
for (const did of dids) {
|
18
|
+
await (0, rebuild_repo_1.rebuildRepo)(ctx, did, false);
|
19
|
+
await recoverFromSequencer({ ...ctx, recoveryDb }, did);
|
20
|
+
fixed++;
|
21
|
+
console.log(`${fixed}/${dids.length}`);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
exports.repairRepos = repairRepos;
|
25
|
+
const recoverFromSequencer = async (ctx, did) => {
|
26
|
+
const didEvts = await ctx.sequencer.db.db
|
27
|
+
.selectFrom('repo_seq')
|
28
|
+
.selectAll()
|
29
|
+
.where('did', '=', did)
|
30
|
+
.orderBy('seq', 'asc')
|
31
|
+
.execute();
|
32
|
+
const seqEvts = (0, sequencer_1.parseRepoSeqRows)(didEvts);
|
33
|
+
for (const evt of seqEvts) {
|
34
|
+
await (0, recoverer_1.processSeqEvt)(ctx, evt);
|
35
|
+
}
|
36
|
+
await ctx.recoveryDb.db
|
37
|
+
.updateTable('failed')
|
38
|
+
.set({
|
39
|
+
fixed: 1,
|
40
|
+
error: null,
|
41
|
+
})
|
42
|
+
.where('did', '=', did)
|
43
|
+
.execute();
|
44
|
+
};
|
45
|
+
//# sourceMappingURL=repair-repos.js.map
|
@@ -0,0 +1 @@
|
|
1
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,GAAG,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,EAAE,CAAA;IACZ,MAAM,OAAO,GAAG,IAAA,4BAAgB,EAAC,OAAO,CAAC,CAAA;IACzC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,IAAA,yBAAa,EAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC/B,CAAC;IACD,MAAM,GAAG,CAAC,UAAU,CAAC,EAAE;SACpB,WAAW,CAAC,QAAQ,CAAC;SACrB,GAAG,CAAC;QACH,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,IAAI;KACZ,CAAC;SACD,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC;SACtB,OAAO,EAAE,CAAA;AACd,CAAC,CAAA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import PQueue from 'p-queue';
|
2
|
+
export declare class UserQueues {
|
3
|
+
main: PQueue;
|
4
|
+
queues: Map<string, PQueue<import("p-queue/dist/priority-queue").default, import("p-queue").DefaultAddOptions>>;
|
5
|
+
constructor(concurrency: number);
|
6
|
+
addToUser(did: string, task: () => Promise<void>): Promise<void>;
|
7
|
+
private getQueue;
|
8
|
+
onEmpty(): Promise<void>;
|
9
|
+
processAll(): Promise<void>;
|
10
|
+
destroy(): Promise<void>;
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=user-queues.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"user-queues.d.ts","sourceRoot":"","sources":["../../../src/scripts/sequencer-recovery/user-queues.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,qBAAa,UAAU;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,0GAA4B;gBAEtB,WAAW,EAAE,MAAM;IAIzB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAOtD,OAAO,CAAC,QAAQ;IAUV,OAAO;IAIP,UAAU;IAIV,OAAO;CAMd"}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.UserQueues = void 0;
|
7
|
+
const p_queue_1 = __importDefault(require("p-queue"));
|
8
|
+
class UserQueues {
|
9
|
+
constructor(concurrency) {
|
10
|
+
Object.defineProperty(this, "main", {
|
11
|
+
enumerable: true,
|
12
|
+
configurable: true,
|
13
|
+
writable: true,
|
14
|
+
value: void 0
|
15
|
+
});
|
16
|
+
Object.defineProperty(this, "queues", {
|
17
|
+
enumerable: true,
|
18
|
+
configurable: true,
|
19
|
+
writable: true,
|
20
|
+
value: new Map()
|
21
|
+
});
|
22
|
+
this.main = new p_queue_1.default({ concurrency });
|
23
|
+
}
|
24
|
+
async addToUser(did, task) {
|
25
|
+
if (this.main.isPaused)
|
26
|
+
return;
|
27
|
+
return this.main.add(() => {
|
28
|
+
return this.getQueue(did).add(task);
|
29
|
+
});
|
30
|
+
}
|
31
|
+
getQueue(did) {
|
32
|
+
let queue = this.queues.get(did);
|
33
|
+
if (!queue) {
|
34
|
+
queue = new p_queue_1.default({ concurrency: 1 });
|
35
|
+
queue.once('idle', () => this.queues.delete(did));
|
36
|
+
this.queues.set(did, queue);
|
37
|
+
}
|
38
|
+
return queue;
|
39
|
+
}
|
40
|
+
async onEmpty() {
|
41
|
+
await this.main.onEmpty();
|
42
|
+
}
|
43
|
+
async processAll() {
|
44
|
+
await this.main.onIdle();
|
45
|
+
}
|
46
|
+
async destroy() {
|
47
|
+
this.main.pause();
|
48
|
+
this.main.clear();
|
49
|
+
this.queues.forEach((q) => q.clear());
|
50
|
+
await this.processAll();
|
51
|
+
}
|
52
|
+
}
|
53
|
+
exports.UserQueues = UserQueues;
|
54
|
+
//# sourceMappingURL=user-queues.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"user-queues.js","sourceRoot":"","sources":["../../../src/scripts/sequencer-recovery/user-queues.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAC5B,MAAa,UAAU;IAIrB,YAAY,WAAmB;QAH/B;;;;;WAAY;QACZ;;;;mBAAS,IAAI,GAAG,EAAkB;WAAA;QAGhC,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAW,EAAE,IAAyB;QACpD,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAM;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;YACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,QAAQ,CAAC,GAAW;QAC1B,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,KAAK,GAAG,IAAI,iBAAM,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAA;YACtC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;YACjD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC7B,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAA;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QACjB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;QACrC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;IACzB,CAAC;CACF;AAvCD,gCAuCC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/scripts/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAMzC,CAAA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.parseIntArg = void 0;
|
4
|
+
const parseIntArg = (arg) => {
|
5
|
+
const parsed = parseInt(arg, 10);
|
6
|
+
if (isNaN(parsed)) {
|
7
|
+
throw new Error(`Invalid arg, expected number: ${arg}`);
|
8
|
+
}
|
9
|
+
return parsed;
|
10
|
+
};
|
11
|
+
exports.parseIntArg = parseIntArg;
|
12
|
+
//# sourceMappingURL=util.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/scripts/util.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE;IACjD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAChC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AANY,QAAA,WAAW,eAMvB"}
|
@@ -7,6 +7,7 @@ import { SeqEvt } from './events';
|
|
7
7
|
export * from './events';
|
8
8
|
declare const Sequencer_base: new () => SequencerEmitter;
|
9
9
|
export declare class Sequencer extends Sequencer_base {
|
10
|
+
dbLocation: string;
|
10
11
|
crawlers: Crawlers;
|
11
12
|
lastSeen: number;
|
12
13
|
db: SequencerDb;
|
@@ -34,6 +35,7 @@ export declare class Sequencer extends Sequencer_base {
|
|
34
35
|
sequenceAccountEvt(did: string, status: AccountStatus): Promise<number>;
|
35
36
|
deleteAllForUser(did: string, excludingSeqs?: number[]): Promise<void>;
|
36
37
|
}
|
38
|
+
export declare const parseRepoSeqRows: (rows: RepoSeqEntry[]) => SeqEvt[];
|
37
39
|
type SeqRow = RepoSeqEntry;
|
38
40
|
type SequencerEvents = {
|
39
41
|
events: (evts: SeqEvt[]) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EAGZ,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,MAAM,EAMP,MAAM,UAAU,CAAA;AAEjB,cAAc,UAAU,CAAA;wCAEkC,gBAAgB;AAA1E,qBAAa,SAAU,SAAQ,cAA4C;
|
1
|
+
{"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,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EAAE,MAAM,EAAE,IAAI,EAAE,WAAW;IAK9C,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKlE,kBAAkB,CACtB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,CAAC;IAKZ,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,GAAE,MAAM,EAAO;CAUjE;AAED,eAAO,MAAM,gBAAgB,SAAU,YAAY,EAAE,KAAG,MAAM,EAuC7D,CAAA;AAED,KAAK,MAAM,GAAG,YAAY,CAAA;AAE1B,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAChC,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,eAAe,CAAC,CAAA;AAE5D,eAAe,SAAS,CAAA"}
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
18
|
};
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.Sequencer = void 0;
|
20
|
+
exports.parseRepoSeqRows = exports.Sequencer = void 0;
|
21
21
|
const node_events_1 = __importDefault(require("node:events"));
|
22
22
|
const common_1 = require("@atproto/common");
|
23
23
|
const logger_1 = require("../logger");
|
@@ -27,6 +27,12 @@ __exportStar(require("./events"), exports);
|
|
27
27
|
class Sequencer extends node_events_1.default {
|
28
28
|
constructor(dbLocation, crawlers, lastSeen = 0, disableWalAutoCheckpoint = false) {
|
29
29
|
super();
|
30
|
+
Object.defineProperty(this, "dbLocation", {
|
31
|
+
enumerable: true,
|
32
|
+
configurable: true,
|
33
|
+
writable: true,
|
34
|
+
value: dbLocation
|
35
|
+
});
|
30
36
|
Object.defineProperty(this, "crawlers", {
|
31
37
|
enumerable: true,
|
32
38
|
configurable: true,
|
@@ -136,47 +142,7 @@ class Sequencer extends node_events_1.default {
|
|
136
142
|
if (rows.length < 1) {
|
137
143
|
return [];
|
138
144
|
}
|
139
|
-
|
140
|
-
for (const row of rows) {
|
141
|
-
// should never hit this because of WHERE clause
|
142
|
-
if (row.seq === null) {
|
143
|
-
continue;
|
144
|
-
}
|
145
|
-
const evt = (0, common_1.cborDecode)(row.event);
|
146
|
-
if (row.eventType === 'append') {
|
147
|
-
seqEvts.push({
|
148
|
-
type: 'commit',
|
149
|
-
seq: row.seq,
|
150
|
-
time: row.sequencedAt,
|
151
|
-
evt: evt,
|
152
|
-
});
|
153
|
-
}
|
154
|
-
else if (row.eventType === 'sync') {
|
155
|
-
seqEvts.push({
|
156
|
-
type: 'sync',
|
157
|
-
seq: row.seq,
|
158
|
-
time: row.sequencedAt,
|
159
|
-
evt: evt,
|
160
|
-
});
|
161
|
-
}
|
162
|
-
else if (row.eventType === 'identity') {
|
163
|
-
seqEvts.push({
|
164
|
-
type: 'identity',
|
165
|
-
seq: row.seq,
|
166
|
-
time: row.sequencedAt,
|
167
|
-
evt: evt,
|
168
|
-
});
|
169
|
-
}
|
170
|
-
else if (row.eventType === 'account') {
|
171
|
-
seqEvts.push({
|
172
|
-
type: 'account',
|
173
|
-
seq: row.seq,
|
174
|
-
time: row.sequencedAt,
|
175
|
-
evt: evt,
|
176
|
-
});
|
177
|
-
}
|
178
|
-
}
|
179
|
-
return seqEvts;
|
145
|
+
return (0, exports.parseRepoSeqRows)(rows);
|
180
146
|
}
|
181
147
|
async pollDb() {
|
182
148
|
if (this.destroyed)
|
@@ -238,5 +204,49 @@ class Sequencer extends node_events_1.default {
|
|
238
204
|
}
|
239
205
|
}
|
240
206
|
exports.Sequencer = Sequencer;
|
207
|
+
const parseRepoSeqRows = (rows) => {
|
208
|
+
const seqEvts = [];
|
209
|
+
for (const row of rows) {
|
210
|
+
// should never hit this because of WHERE clause
|
211
|
+
if (row.seq === null) {
|
212
|
+
continue;
|
213
|
+
}
|
214
|
+
const evt = (0, common_1.cborDecode)(row.event);
|
215
|
+
if (row.eventType === 'append') {
|
216
|
+
seqEvts.push({
|
217
|
+
type: 'commit',
|
218
|
+
seq: row.seq,
|
219
|
+
time: row.sequencedAt,
|
220
|
+
evt: evt,
|
221
|
+
});
|
222
|
+
}
|
223
|
+
else if (row.eventType === 'sync') {
|
224
|
+
seqEvts.push({
|
225
|
+
type: 'sync',
|
226
|
+
seq: row.seq,
|
227
|
+
time: row.sequencedAt,
|
228
|
+
evt: evt,
|
229
|
+
});
|
230
|
+
}
|
231
|
+
else if (row.eventType === 'identity') {
|
232
|
+
seqEvts.push({
|
233
|
+
type: 'identity',
|
234
|
+
seq: row.seq,
|
235
|
+
time: row.sequencedAt,
|
236
|
+
evt: evt,
|
237
|
+
});
|
238
|
+
}
|
239
|
+
else if (row.eventType === 'account') {
|
240
|
+
seqEvts.push({
|
241
|
+
type: 'account',
|
242
|
+
seq: row.seq,
|
243
|
+
time: row.sequencedAt,
|
244
|
+
evt: evt,
|
245
|
+
});
|
246
|
+
}
|
247
|
+
}
|
248
|
+
return seqEvts;
|
249
|
+
};
|
250
|
+
exports.parseRepoSeqRows = parseRepoSeqRows;
|
241
251
|
exports.default = Sequencer;
|
242
252
|
//# sourceMappingURL=sequencer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sequencer.js","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;AAEtC,4CAA0D;AAG1D,sCAA4C;AAE5C,6BAMa;AACb,qCAUiB;AAEjB,2CAAwB;AAExB,MAAa,SAAU,SAAS,qBAA2C;IAMzE,
|
1
|
+
{"version":3,"file":"sequencer.js","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;AAEtC,4CAA0D;AAG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,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atproto/pds",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.118",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "Reference implementation of atproto Personal Data Server (PDS)",
|
6
6
|
"keywords": [
|
@@ -49,18 +49,18 @@
|
|
49
49
|
"undici": "^6.19.8",
|
50
50
|
"zod": "^3.23.8",
|
51
51
|
"@atproto-labs/fetch-node": "0.1.8",
|
52
|
-
"@atproto-labs/xrpc-utils": "0.0.
|
53
|
-
"@atproto/api": "^0.14.
|
54
|
-
"@atproto/aws": "^0.2.
|
55
|
-
"@atproto/common": "^0.4.
|
52
|
+
"@atproto-labs/xrpc-utils": "0.0.10",
|
53
|
+
"@atproto/api": "^0.14.17",
|
54
|
+
"@atproto/aws": "^0.2.19",
|
55
|
+
"@atproto/common": "^0.4.9",
|
56
56
|
"@atproto/crypto": "^0.4.4",
|
57
57
|
"@atproto/identity": "^0.4.6",
|
58
58
|
"@atproto/lexicon": "^0.4.9",
|
59
|
-
"@atproto/oauth-provider": "^0.6.
|
60
|
-
"@atproto/repo": "^0.7.
|
59
|
+
"@atproto/oauth-provider": "^0.6.5",
|
60
|
+
"@atproto/repo": "^0.7.3",
|
61
61
|
"@atproto/syntax": "^0.4.0",
|
62
62
|
"@atproto/xrpc": "^0.6.11",
|
63
|
-
"@atproto/xrpc-server": "^0.7.
|
63
|
+
"@atproto/xrpc-server": "^0.7.14"
|
64
64
|
},
|
65
65
|
"devDependencies": {
|
66
66
|
"@atproto/pds-entryway": "npm:@atproto/pds@0.3.0-entryway.3",
|
@@ -78,8 +78,8 @@
|
|
78
78
|
"ts-node": "^10.8.2",
|
79
79
|
"typescript": "^5.6.3",
|
80
80
|
"ws": "^8.12.0",
|
81
|
-
"@atproto/api": "^0.14.
|
82
|
-
"@atproto/bsky": "^0.0.
|
81
|
+
"@atproto/api": "^0.14.17",
|
82
|
+
"@atproto/bsky": "^0.0.134",
|
83
83
|
"@atproto/lex-cli": "^0.7.1",
|
84
84
|
"@atproto/oauth-client-browser-example": "0.0.2"
|
85
85
|
},
|
@@ -5,7 +5,6 @@ import { IdResolver } from '@atproto/identity'
|
|
5
5
|
import { isValidTld } from '@atproto/syntax'
|
6
6
|
import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
|
7
7
|
import { AuthScope } from '../auth-verifier'
|
8
|
-
import { DatabaseConfig } from '../config'
|
9
8
|
import { softDeleted } from '../db'
|
10
9
|
import { hasExplicitSlur } from '../handle/explicit-slurs'
|
11
10
|
import {
|
@@ -27,6 +26,11 @@ import * as token from './helpers/token'
|
|
27
26
|
|
28
27
|
export { AccountStatus, formatAccountStatus } from './helpers/account'
|
29
28
|
|
29
|
+
export type AccountManagerDbConfig = {
|
30
|
+
accountDbLoc: string
|
31
|
+
disableWalAutoCheckpoint: boolean
|
32
|
+
}
|
33
|
+
|
30
34
|
export class AccountManager {
|
31
35
|
readonly db: AccountDb
|
32
36
|
|
@@ -35,7 +39,7 @@ export class AccountManager {
|
|
35
39
|
readonly jwtKey: KeyObject,
|
36
40
|
readonly serviceDid: string,
|
37
41
|
readonly serviceHandleDomains: string[],
|
38
|
-
db:
|
42
|
+
db: AccountManagerDbConfig,
|
39
43
|
) {
|
40
44
|
this.db = getDb(db.accountDbLoc, db.disableWalAutoCheckpoint)
|
41
45
|
}
|
@@ -150,7 +150,10 @@ export class BlobTransactor extends BlobReader {
|
|
150
150
|
}
|
151
151
|
}
|
152
152
|
|
153
|
-
async deleteDereferencedBlobs(
|
153
|
+
async deleteDereferencedBlobs(
|
154
|
+
writes: PreparedWrite[],
|
155
|
+
skipBlobStore?: boolean,
|
156
|
+
) {
|
154
157
|
const deletes = writes.filter(
|
155
158
|
(w) => w.action === WriteOpAction.Delete,
|
156
159
|
) as PreparedDelete[]
|
@@ -195,13 +198,15 @@ export class BlobTransactor extends BlobReader {
|
|
195
198
|
.deleteFrom('blob')
|
196
199
|
.where('cid', 'in', cidsToDelete)
|
197
200
|
.execute()
|
198
|
-
|
199
|
-
this.
|
200
|
-
|
201
|
-
|
202
|
-
|
201
|
+
if (!skipBlobStore) {
|
202
|
+
this.db.onCommit(() => {
|
203
|
+
this.backgroundQueue.add(async () => {
|
204
|
+
await Promise.allSettled(
|
205
|
+
cidsToDelete.map((cid) => this.blobstore.delete(CID.parse(cid))),
|
206
|
+
)
|
207
|
+
})
|
203
208
|
})
|
204
|
-
}
|
209
|
+
}
|
205
210
|
}
|
206
211
|
|
207
212
|
async verifyBlobAndMakePermanent(blob: PreparedBlobRef): Promise<void> {
|
@@ -228,6 +233,19 @@ export class BlobTransactor extends BlobReader {
|
|
228
233
|
}
|
229
234
|
}
|
230
235
|
|
236
|
+
async insertBlobMetadata(blob: PreparedBlobRef): Promise<void> {
|
237
|
+
await this.db.db
|
238
|
+
.insertInto('blob')
|
239
|
+
.values({
|
240
|
+
cid: blob.cid.toString(),
|
241
|
+
mimeType: blob.mimeType,
|
242
|
+
size: blob.size,
|
243
|
+
createdAt: new Date().toISOString(),
|
244
|
+
})
|
245
|
+
.onConflict((oc) => oc.doNothing())
|
246
|
+
.execute()
|
247
|
+
}
|
248
|
+
|
231
249
|
async associateBlob(blob: PreparedBlobRef, recordUri: AtUri): Promise<void> {
|
232
250
|
await this.db.db
|
233
251
|
.insertInto('record_blob')
|
package/src/config/env.ts
CHANGED
@@ -115,6 +115,7 @@ export const readEnv = (): ServerEnvironment => {
|
|
115
115
|
dpopSecret: envStr('PDS_DPOP_SECRET'),
|
116
116
|
jwtSecret: envStr('PDS_JWT_SECRET'),
|
117
117
|
adminPassword: envStr('PDS_ADMIN_PASSWORD'),
|
118
|
+
entrywayAdminToken: envStr('PDS_ENTRYWAY_ADMIN_TOKEN'),
|
118
119
|
|
119
120
|
// kms
|
120
121
|
plcRotationKeyKmsKeyId: envStr('PDS_PLC_ROTATION_KEY_KMS_KEY_ID'),
|
@@ -251,6 +252,7 @@ export type ServerEnvironment = {
|
|
251
252
|
dpopSecret?: string
|
252
253
|
jwtSecret?: string
|
253
254
|
adminPassword?: string
|
255
|
+
entrywayAdminToken?: string
|
254
256
|
|
255
257
|
// keys
|
256
258
|
plcRotationKeyKmsKeyId?: string
|
package/src/config/secrets.ts
CHANGED
@@ -31,6 +31,7 @@ export const envToSecrets = (env: ServerEnvironment): ServerSecrets => {
|
|
31
31
|
jwtSecret: env.jwtSecret,
|
32
32
|
adminPassword: env.adminPassword,
|
33
33
|
plcRotationKey,
|
34
|
+
entrywayAdminToken: env.entrywayAdminToken ?? env.adminPassword,
|
34
35
|
}
|
35
36
|
}
|
36
37
|
|
@@ -39,6 +40,7 @@ export type ServerSecrets = {
|
|
39
40
|
jwtSecret: string
|
40
41
|
adminPassword: string
|
41
42
|
plcRotationKey: SigningKeyKms | SigningKeyMemory
|
43
|
+
entrywayAdminToken?: string
|
42
44
|
}
|
43
45
|
|
44
46
|
export type SigningKeyKms = {
|
package/src/context.ts
CHANGED
@@ -3,6 +3,7 @@ import * as plc from '@did-plc/lib'
|
|
3
3
|
import express from 'express'
|
4
4
|
import { Redis } from 'ioredis'
|
5
5
|
import * as nodemailer from 'nodemailer'
|
6
|
+
import * as ui8 from 'uint8arrays'
|
6
7
|
import * as undici from 'undici'
|
7
8
|
import { AtpAgent } from '@atproto/api'
|
8
9
|
import { KmsKeypair, S3BlobStore } from '@atproto/aws'
|
@@ -71,6 +72,7 @@ export type AppContextOptions = {
|
|
71
72
|
moderationAgent?: AtpAgent
|
72
73
|
reportingAgent?: AtpAgent
|
73
74
|
entrywayAgent?: AtpAgent
|
75
|
+
entrywayAdminAgent?: AtpAgent
|
74
76
|
proxyAgent: undici.Dispatcher
|
75
77
|
safeFetch: Fetch
|
76
78
|
oauthProvider?: OAuthProvider
|
@@ -98,6 +100,7 @@ export class AppContext {
|
|
98
100
|
public moderationAgent: AtpAgent | undefined
|
99
101
|
public reportingAgent: AtpAgent | undefined
|
100
102
|
public entrywayAgent: AtpAgent | undefined
|
103
|
+
public entrywayAdminAgent: AtpAgent | undefined
|
101
104
|
public proxyAgent: undici.Dispatcher
|
102
105
|
public safeFetch: Fetch
|
103
106
|
public authVerifier: AuthVerifier
|
@@ -124,6 +127,7 @@ export class AppContext {
|
|
124
127
|
this.moderationAgent = opts.moderationAgent
|
125
128
|
this.reportingAgent = opts.reportingAgent
|
126
129
|
this.entrywayAgent = opts.entrywayAgent
|
130
|
+
this.entrywayAdminAgent = opts.entrywayAdminAgent
|
127
131
|
this.proxyAgent = opts.proxyAgent
|
128
132
|
this.safeFetch = opts.safeFetch
|
129
133
|
this.authVerifier = opts.authVerifier
|
@@ -235,6 +239,14 @@ export class AppContext {
|
|
235
239
|
const entrywayAgent = cfg.entryway
|
236
240
|
? new AtpAgent({ service: cfg.entryway.url })
|
237
241
|
: undefined
|
242
|
+
let entrywayAdminAgent: AtpAgent | undefined
|
243
|
+
if (cfg.entryway && secrets.entrywayAdminToken) {
|
244
|
+
entrywayAdminAgent = new AtpAgent({ service: cfg.entryway.url })
|
245
|
+
entrywayAdminAgent.api.setHeader(
|
246
|
+
'authorization',
|
247
|
+
basicAuthHeader('admin', secrets.entrywayAdminToken),
|
248
|
+
)
|
249
|
+
}
|
238
250
|
|
239
251
|
const jwtSecretKey = createSecretKeyObject(secrets.jwtSecret)
|
240
252
|
const jwtPublicKey = cfg.entryway
|
@@ -405,6 +417,7 @@ export class AppContext {
|
|
405
417
|
moderationAgent,
|
406
418
|
reportingAgent,
|
407
419
|
entrywayAgent,
|
420
|
+
entrywayAdminAgent,
|
408
421
|
proxyAgent,
|
409
422
|
safeFetch,
|
410
423
|
authVerifier,
|
@@ -454,3 +467,13 @@ export class AppContext {
|
|
454
467
|
})
|
455
468
|
}
|
456
469
|
}
|
470
|
+
|
471
|
+
const basicAuthHeader = (username: string, password: string) => {
|
472
|
+
const encoded = ui8.toString(
|
473
|
+
ui8.fromString(`${username}:${password}`, 'utf8'),
|
474
|
+
'base64pad',
|
475
|
+
)
|
476
|
+
return `Basic ${encoded}`
|
477
|
+
}
|
478
|
+
|
479
|
+
export default AppContext
|