feat: importer IMVU accounts and settings from the console (#14)
Release / release (push) Successful in 4s
CI / test (push) Successful in 1m25s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 6s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 14s

Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #14.
This commit is contained in:
dhkatz authored and dhkatz committed 2026-11-07 19:00:01 +00:00
1 parent 7ece681eef
commit e6a97be894
16 files changed
+5538 -13

No files matched your search

@@ -0,0 +1,27 @@
CREATE TABLE "importer_account" (
"id" text PRIMARY KEY NOT NULL,
"catalog_id" text NOT NULL,
"imvu_id" bigint NOT NULL,
"username" text NOT NULL,
"position" integer NOT NULL,
"sealed" text,
"sealed_for" text,
"sealed_at" timestamp with time zone,
"state" text DEFAULT 'waiting' NOT NULL,
"state_message" text DEFAULT '' NOT NULL,
"state_at" timestamp with time zone DEFAULT now() NOT NULL,
"access_pass" boolean DEFAULT false NOT NULL,
"age_verified" boolean DEFAULT false NOT NULL,
"added_by" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "catalog" ADD COLUMN "importer_public_key" text;--> statement-breakpoint
ALTER TABLE "catalog" ADD COLUMN "importer_fingerprint" text;--> statement-breakpoint
ALTER TABLE "catalog" ADD COLUMN "importer_version" text DEFAULT '' NOT NULL;--> statement-breakpoint
ALTER TABLE "catalog" ADD COLUMN "importer_seen_at" timestamp with time zone;--> statement-breakpoint
ALTER TABLE "catalog" ADD COLUMN "importer_settings" jsonb DEFAULT '{"rate":2,"concurrency":2}'::jsonb NOT NULL;--> statement-breakpoint
ALTER TABLE "importer_account" ADD CONSTRAINT "importer_account_catalog_id_catalog_id_fk" FOREIGN KEY ("catalog_id") REFERENCES "public"."catalog"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "importer_account" ADD CONSTRAINT "importer_account_added_by_user_id_fk" FOREIGN KEY ("added_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "importer_account_imvu" ON "importer_account" USING btree ("catalog_id","imvu_id");
File diff suppressed because it is too large. Load diff
+7
View File
@@ -120,6 +120,13 @@
"when": 1793935614967,
"tag": "0016_imports",
"breakpoints": true
},
{
"idx": 17,
"version": "7",
"when": 1794073227716,
"tag": "0017_importer_accounts",
"breakpoints": true
}
]
}
+1 -1
View File
@@ -11,7 +11,7 @@ import { fileURLToPath } from "node:url";
import * as schema from "./schema";
export { schema };
export type { AuditTags, DecorationItem, FileEntry, InfoChange, ParentInfo, RoomModerator, SceneItem, TokenGrant } from "./schema";
export type { AuditTags, DecorationItem, FileEntry, ImporterSettings, InfoChange, ParentInfo, RoomModerator, SceneItem, TokenGrant } from "./schema";
export * from "drizzle-orm";
const migrationsFolder = fileURLToPath(new URL("../drizzle", import.meta.url));
+40
View File
@@ -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(),