feat: importer IMVU accounts and settings from the console (#14)
Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #14.
This commit is contained in:
1 parent
7ece681eef
commit
e6a97be894
16 files changed
+5538
-13
No files matched your search
@@ -292,6 +292,14 @@ export const catalog = pgTable(
|
||||
// Imports (docs/imports.md): "off", "on" or "paused" (the hub hands its importer no jobs); the importer's key.
|
||||
importer: text("importer").notNull().default("off"),
|
||||
importerKeyHash: text("importer_key_hash"), // sha256, hex
|
||||
// The importer program (docs/imports.md "IMVU accounts"): its RSA public key (SPKI, base64) that IMVU passwords
|
||||
// are sealed for, the key's fingerprint (sha256 of the SPKI, hex), its version, when it last called, and its
|
||||
// settings, set on the console.
|
||||
importerPublicKey: text("importer_public_key"),
|
||||
importerFingerprint: text("importer_fingerprint"),
|
||||
importerVersion: text("importer_version").notNull().default(""),
|
||||
importerSeenAt: timestamp("importer_seen_at", { withTimezone: true }),
|
||||
importerSettings: jsonb("importer_settings").$type<ImporterSettings>().notNull().default({ rate: 2, concurrency: 2 }),
|
||||
createdAt: createdAt(),
|
||||
updatedAt: updatedAt(),
|
||||
},
|
||||
@@ -800,6 +808,38 @@ export const importJob = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
/** An importer's settings: requests a second to IMVU, and jobs worked on at once. */
|
||||
export type ImporterSettings = { rate: number; concurrency: number };
|
||||
|
||||
// An IMVU account a catalog's importer signs in with (docs/imports.md "IMVU accounts"). Its password is never stored
|
||||
// readable: the console seals it in the browser for the importer's public key, and the hub keeps that sealed copy
|
||||
// only until the importer has it.
|
||||
export const importerAccount = pgTable(
|
||||
"importer_account",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
catalogId: text("catalog_id")
|
||||
.notNull()
|
||||
.references(() => catalog.id, { onDelete: "cascade" }),
|
||||
imvuId: bigint("imvu_id", { mode: "number" }).notNull(),
|
||||
username: text("username").notNull(),
|
||||
position: integer("position").notNull(), // the importer tries accounts in this order
|
||||
sealed: text("sealed"), // the password sealed for the importer (RSA-OAEP, base64), until it has it
|
||||
sealedFor: text("sealed_for"), // the fingerprint of the key it was sealed for
|
||||
sealedAt: timestamp("sealed_at", { withTimezone: true }),
|
||||
// "waiting" (sealed, not yet with the importer), "received", "ok", "sign_in_failed", "needs_password"
|
||||
state: text("state").notNull().default("waiting"),
|
||||
stateMessage: text("state_message").notNull().default(""),
|
||||
stateAt: timestamp("state_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
accessPass: boolean("access_pass").notNull().default(false), // as IMVU shows it (the importer's report wins)
|
||||
ageVerified: boolean("age_verified").notNull().default(false),
|
||||
addedBy: text("added_by").references(() => user.id, { onDelete: "set null" }),
|
||||
createdAt: createdAt(),
|
||||
updatedAt: updatedAt(),
|
||||
},
|
||||
(t) => [uniqueIndex("importer_account_imvu").on(t.catalogId, t.imvuId)],
|
||||
);
|
||||
|
||||
// IMVU products' public info, as imports and requests need it (looked up again after a day).
|
||||
export const imvuProductInfo = pgTable("imvu_product_info", {
|
||||
id: bigint("id", { mode: "number" }).primaryKey(),
|
||||
|
||||
Reference in new issue
Block a user