@hot-updater/vercel 1.2.0-rc.27 → 1.2.0-rc.28
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/function/index.mjs +526 -15
- package/package.json +7 -7
package/dist/function/index.mjs
CHANGED
|
@@ -2478,6 +2478,11 @@ const nativeBuilds = defineTable({
|
|
|
2478
2478
|
maxLength: 255,
|
|
2479
2479
|
ascii: true,
|
|
2480
2480
|
required: false
|
|
2481
|
+
},
|
|
2482
|
+
export_method: {
|
|
2483
|
+
type: "string",
|
|
2484
|
+
maxLength: 16,
|
|
2485
|
+
required: false
|
|
2481
2486
|
}
|
|
2482
2487
|
}, {
|
|
2483
2488
|
key: ["id"],
|
|
@@ -2512,6 +2517,92 @@ const nativeBuilds = defineTable({
|
|
|
2512
2517
|
}
|
|
2513
2518
|
}
|
|
2514
2519
|
});
|
|
2520
|
+
const iosDevices = defineTable({
|
|
2521
|
+
id: {
|
|
2522
|
+
type: "string",
|
|
2523
|
+
maxLength: 36
|
|
2524
|
+
},
|
|
2525
|
+
udid: {
|
|
2526
|
+
type: "string",
|
|
2527
|
+
maxLength: 40,
|
|
2528
|
+
ascii: true,
|
|
2529
|
+
unique: true
|
|
2530
|
+
},
|
|
2531
|
+
name: {
|
|
2532
|
+
type: "string",
|
|
2533
|
+
maxLength: 100
|
|
2534
|
+
},
|
|
2535
|
+
status: {
|
|
2536
|
+
type: "string",
|
|
2537
|
+
maxLength: 16
|
|
2538
|
+
},
|
|
2539
|
+
requested_by: {
|
|
2540
|
+
type: "string",
|
|
2541
|
+
maxLength: 320,
|
|
2542
|
+
required: false
|
|
2543
|
+
},
|
|
2544
|
+
created_at_ms: { type: "integer" },
|
|
2545
|
+
approved_by: {
|
|
2546
|
+
type: "string",
|
|
2547
|
+
maxLength: 320,
|
|
2548
|
+
required: false
|
|
2549
|
+
},
|
|
2550
|
+
approved_at_ms: {
|
|
2551
|
+
type: "integer",
|
|
2552
|
+
required: false
|
|
2553
|
+
},
|
|
2554
|
+
registered_at_ms: {
|
|
2555
|
+
type: "integer",
|
|
2556
|
+
required: false
|
|
2557
|
+
},
|
|
2558
|
+
apple_issuer_id: {
|
|
2559
|
+
type: "string",
|
|
2560
|
+
maxLength: 64,
|
|
2561
|
+
ascii: true,
|
|
2562
|
+
required: false
|
|
2563
|
+
},
|
|
2564
|
+
apple_error: {
|
|
2565
|
+
type: "string",
|
|
2566
|
+
maxLength: 512,
|
|
2567
|
+
required: false
|
|
2568
|
+
},
|
|
2569
|
+
build_id: {
|
|
2570
|
+
type: "string",
|
|
2571
|
+
maxLength: 36,
|
|
2572
|
+
required: false
|
|
2573
|
+
}
|
|
2574
|
+
}, {
|
|
2575
|
+
key: ["id"],
|
|
2576
|
+
indexes: {
|
|
2577
|
+
byStatus: {
|
|
2578
|
+
eq: ["status"],
|
|
2579
|
+
sort: ["id"]
|
|
2580
|
+
},
|
|
2581
|
+
all: {
|
|
2582
|
+
eq: [],
|
|
2583
|
+
sort: ["id"]
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
const iosDeviceAccount = defineTable({
|
|
2588
|
+
id: {
|
|
2589
|
+
type: "string",
|
|
2590
|
+
maxLength: 16,
|
|
2591
|
+
ascii: true
|
|
2592
|
+
},
|
|
2593
|
+
apple_issuer_id: {
|
|
2594
|
+
type: "string",
|
|
2595
|
+
maxLength: 64,
|
|
2596
|
+
ascii: true
|
|
2597
|
+
},
|
|
2598
|
+
claimed_at_ms: { type: "integer" }
|
|
2599
|
+
}, {
|
|
2600
|
+
key: ["id"],
|
|
2601
|
+
indexes: { all: {
|
|
2602
|
+
eq: [],
|
|
2603
|
+
sort: ["id"]
|
|
2604
|
+
} }
|
|
2605
|
+
});
|
|
2515
2606
|
const coreModule = {
|
|
2516
2607
|
id: "core",
|
|
2517
2608
|
schema: {
|
|
@@ -2531,7 +2622,9 @@ const coreModule = {
|
|
|
2531
2622
|
sort: []
|
|
2532
2623
|
} }
|
|
2533
2624
|
}),
|
|
2534
|
-
native_builds: nativeBuilds
|
|
2625
|
+
native_builds: nativeBuilds,
|
|
2626
|
+
ios_devices: iosDevices,
|
|
2627
|
+
ios_device_account: iosDeviceAccount
|
|
2535
2628
|
}
|
|
2536
2629
|
};
|
|
2537
2630
|
//#endregion
|
|
@@ -17638,7 +17731,7 @@ const postgres = (config) => {
|
|
|
17638
17731
|
};
|
|
17639
17732
|
//#endregion
|
|
17640
17733
|
//#region ../../packages/server/dist/version.mjs
|
|
17641
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
17734
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.28";
|
|
17642
17735
|
//#endregion
|
|
17643
17736
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
17644
17737
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -18371,8 +18464,8 @@ const baseBundleIdsOf = (row, range, bundleId, limit) => {
|
|
|
18371
18464
|
//#endregion
|
|
18372
18465
|
//#region ../../packages/server/dist/core/reads.mjs
|
|
18373
18466
|
const PAGE$3 = 500;
|
|
18374
|
-
const pick$
|
|
18375
|
-
const toBundleRow = pick$
|
|
18467
|
+
const pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
18468
|
+
const toBundleRow = pick$2([
|
|
18376
18469
|
"id",
|
|
18377
18470
|
"platform",
|
|
18378
18471
|
"git_commit_hash",
|
|
@@ -18381,7 +18474,7 @@ const toBundleRow = pick$1([
|
|
|
18381
18474
|
"manifest_file_hash",
|
|
18382
18475
|
"asset_base_storage_uri"
|
|
18383
18476
|
]);
|
|
18384
|
-
const toPatchRow = pick$
|
|
18477
|
+
const toPatchRow = pick$2([
|
|
18385
18478
|
"id",
|
|
18386
18479
|
"bundle_id",
|
|
18387
18480
|
"base_bundle_id",
|
|
@@ -18391,7 +18484,7 @@ const toPatchRow = pick$1([
|
|
|
18391
18484
|
"byte_size",
|
|
18392
18485
|
"order_index"
|
|
18393
18486
|
]);
|
|
18394
|
-
const toReleaseRow = pick$
|
|
18487
|
+
const toReleaseRow = pick$2([
|
|
18395
18488
|
"id",
|
|
18396
18489
|
"revision",
|
|
18397
18490
|
"scope_key",
|
|
@@ -18412,7 +18505,7 @@ const toReleaseRow = pick$1([
|
|
|
18412
18505
|
"created_at_ms",
|
|
18413
18506
|
"updated_at_ms"
|
|
18414
18507
|
]);
|
|
18415
|
-
const toCatalogRow = pick$
|
|
18508
|
+
const toCatalogRow = pick$2([
|
|
18416
18509
|
"scope_key",
|
|
18417
18510
|
"catalog_id",
|
|
18418
18511
|
"strategy",
|
|
@@ -18427,7 +18520,7 @@ const toCatalogRow = pick$1([
|
|
|
18427
18520
|
"is_tombstone",
|
|
18428
18521
|
"updated_at_ms"
|
|
18429
18522
|
]);
|
|
18430
|
-
const toChannelRow = pick$
|
|
18523
|
+
const toChannelRow = pick$2(["id", "name"]);
|
|
18431
18524
|
const drain$1 = async (read) => {
|
|
18432
18525
|
const rows = [];
|
|
18433
18526
|
let cursor;
|
|
@@ -18438,7 +18531,14 @@ const drain$1 = async (read) => {
|
|
|
18438
18531
|
} while (cursor !== void 0);
|
|
18439
18532
|
return rows;
|
|
18440
18533
|
};
|
|
18441
|
-
const after = (input) =>
|
|
18534
|
+
const after = (input) => {
|
|
18535
|
+
const asc = (input.order ?? "asc") === "asc";
|
|
18536
|
+
const range = {
|
|
18537
|
+
...input.after === void 0 ? {} : asc ? { gt: input.after } : { lt: input.after },
|
|
18538
|
+
...input.through === void 0 ? {} : asc ? { lte: input.through } : { gte: input.through }
|
|
18539
|
+
};
|
|
18540
|
+
return Object.keys(range).length === 0 ? {} : { range };
|
|
18541
|
+
};
|
|
18442
18542
|
const createCoreReads = (db, storage) => {
|
|
18443
18543
|
const detail = async (row) => {
|
|
18444
18544
|
const count = row._refs_bundle_patches_bundle_id ?? 0;
|
|
@@ -18629,6 +18729,282 @@ const createCoreReads = (db, storage) => {
|
|
|
18629
18729
|
};
|
|
18630
18730
|
};
|
|
18631
18731
|
//#endregion
|
|
18732
|
+
//#region ../../packages/server/dist/core/iosDevices.mjs
|
|
18733
|
+
const UDID = /^(?:[0-9a-f]{40}|[0-9a-f]{8}-[0-9a-f]{16})$/iu;
|
|
18734
|
+
const normalizeIosUdid = (value) => {
|
|
18735
|
+
const trimmed = value.trim();
|
|
18736
|
+
return UDID.test(trimmed) ? trimmed.toLowerCase() : null;
|
|
18737
|
+
};
|
|
18738
|
+
const NAME_MAX_LENGTH = 100;
|
|
18739
|
+
const EMAIL_MAX_LENGTH = 320;
|
|
18740
|
+
const ISSUER_MAX_LENGTH = 64;
|
|
18741
|
+
const ACCOUNT_SCAN_PAGE = 200;
|
|
18742
|
+
const ACCOUNT_ROW = "registry";
|
|
18743
|
+
const ERROR_MAX_LENGTH = 512;
|
|
18744
|
+
const STATUSES = [
|
|
18745
|
+
"pending",
|
|
18746
|
+
"approved",
|
|
18747
|
+
"registered"
|
|
18748
|
+
];
|
|
18749
|
+
const OUTCOMES = [
|
|
18750
|
+
"registered",
|
|
18751
|
+
"refused",
|
|
18752
|
+
"disabled",
|
|
18753
|
+
"missing"
|
|
18754
|
+
];
|
|
18755
|
+
const IOS_DEVICE_DISABLED_ERROR = "Disabled in the Apple account.";
|
|
18756
|
+
const IOS_DEVICE_MISSING_ERROR = "Gone from the Apple account. Approve it again to register it.";
|
|
18757
|
+
var IosDeviceInputError = class extends TypeError {
|
|
18758
|
+
name = "IosDeviceInputError";
|
|
18759
|
+
};
|
|
18760
|
+
const pick$1 = (row) => ({
|
|
18761
|
+
id: row.id,
|
|
18762
|
+
udid: row.udid,
|
|
18763
|
+
name: row.name,
|
|
18764
|
+
status: row.status,
|
|
18765
|
+
requested_by: row.requested_by ?? null,
|
|
18766
|
+
created_at_ms: row.created_at_ms,
|
|
18767
|
+
approved_by: row.approved_by ?? null,
|
|
18768
|
+
approved_at_ms: row.approved_at_ms ?? null,
|
|
18769
|
+
registered_at_ms: row.registered_at_ms ?? null,
|
|
18770
|
+
apple_issuer_id: row.apple_issuer_id ?? null,
|
|
18771
|
+
apple_error: row.apple_error ?? null,
|
|
18772
|
+
build_id: row.build_id ?? null
|
|
18773
|
+
});
|
|
18774
|
+
const udidOf = (udid) => {
|
|
18775
|
+
const key = typeof udid === "string" ? normalizeIosUdid(udid) : null;
|
|
18776
|
+
if (key === null) throw new IosDeviceInputError("Invalid iOS device: udid must be 40 hex digits, or 8 and 16 joined by a hyphen.");
|
|
18777
|
+
return key;
|
|
18778
|
+
};
|
|
18779
|
+
const nameOf = (name) => {
|
|
18780
|
+
const trimmed = typeof name === "string" ? name.trim() : "";
|
|
18781
|
+
if (trimmed.length === 0 || trimmed.length > NAME_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: name must be 1 to ${NAME_MAX_LENGTH} characters.`);
|
|
18782
|
+
return trimmed;
|
|
18783
|
+
};
|
|
18784
|
+
const personOf = (value, field) => {
|
|
18785
|
+
if (value === null) return null;
|
|
18786
|
+
const email = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
18787
|
+
if (email.length === 0 || email.length > EMAIL_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device: ${field} must be an email of at most ${EMAIL_MAX_LENGTH} characters, or null.`);
|
|
18788
|
+
return email;
|
|
18789
|
+
};
|
|
18790
|
+
const errorText = (text) => {
|
|
18791
|
+
const line = text.replace(/\s+/gu, " ").trim();
|
|
18792
|
+
return line.length > ERROR_MAX_LENGTH ? `${line.slice(0, 511)}…` : line;
|
|
18793
|
+
};
|
|
18794
|
+
const createIosDeviceApi = (db, { now = Date.now } = {}) => {
|
|
18795
|
+
const findIosDevice = async (udid) => {
|
|
18796
|
+
const key = normalizeIosUdid(udid);
|
|
18797
|
+
if (key === null) return null;
|
|
18798
|
+
const row = await db.findOne("ios_devices", { udid: key });
|
|
18799
|
+
return row === null ? null : pick$1(row);
|
|
18800
|
+
};
|
|
18801
|
+
const accountOfRows = async () => {
|
|
18802
|
+
let earliest = null;
|
|
18803
|
+
for (let after;;) {
|
|
18804
|
+
const { rows } = await db.findMany("ios_devices", {
|
|
18805
|
+
index: "all",
|
|
18806
|
+
where: {},
|
|
18807
|
+
order: "asc",
|
|
18808
|
+
limit: ACCOUNT_SCAN_PAGE,
|
|
18809
|
+
...after === void 0 ? {} : { range: { gt: after } }
|
|
18810
|
+
});
|
|
18811
|
+
for (const row of rows.map(pick$1)) {
|
|
18812
|
+
if (row.apple_issuer_id === null) continue;
|
|
18813
|
+
if (earliest === null || (row.registered_at_ms ?? 0) < (earliest.registered_at_ms ?? 0)) earliest = row;
|
|
18814
|
+
}
|
|
18815
|
+
if (rows.length < ACCOUNT_SCAN_PAGE) return earliest?.apple_issuer_id ?? null;
|
|
18816
|
+
after = rows.at(-1).id;
|
|
18817
|
+
}
|
|
18818
|
+
};
|
|
18819
|
+
return {
|
|
18820
|
+
async listIosDevices(input) {
|
|
18821
|
+
if (input.status !== void 0 && !STATUSES.includes(input.status)) throw new IosDeviceInputError(`Invalid iOS device status: ${String(input.status)}. Expected ${STATUSES.join(", ")}.`);
|
|
18822
|
+
const page = {
|
|
18823
|
+
order: input.order ?? "asc",
|
|
18824
|
+
limit: input.limit,
|
|
18825
|
+
...after(input)
|
|
18826
|
+
};
|
|
18827
|
+
const { rows } = input.status === void 0 ? await db.findMany("ios_devices", {
|
|
18828
|
+
index: "all",
|
|
18829
|
+
where: {},
|
|
18830
|
+
...page
|
|
18831
|
+
}) : await db.findMany("ios_devices", {
|
|
18832
|
+
index: "byStatus",
|
|
18833
|
+
where: { status: input.status },
|
|
18834
|
+
...page
|
|
18835
|
+
});
|
|
18836
|
+
return rows.map(pick$1);
|
|
18837
|
+
},
|
|
18838
|
+
findIosDevice,
|
|
18839
|
+
async requestIosDevice(input) {
|
|
18840
|
+
const udid = udidOf(input.udid);
|
|
18841
|
+
const name = nameOf(input.name);
|
|
18842
|
+
const requestedBy = personOf(input.requestedBy, "requestedBy");
|
|
18843
|
+
const existing = await db.findOne("ios_devices", { udid });
|
|
18844
|
+
if (existing !== null) return {
|
|
18845
|
+
device: pick$1(existing),
|
|
18846
|
+
created: false
|
|
18847
|
+
};
|
|
18848
|
+
const device = {
|
|
18849
|
+
id: createUUIDv7(),
|
|
18850
|
+
udid,
|
|
18851
|
+
name,
|
|
18852
|
+
status: "pending",
|
|
18853
|
+
requested_by: requestedBy,
|
|
18854
|
+
created_at_ms: now(),
|
|
18855
|
+
approved_by: null,
|
|
18856
|
+
approved_at_ms: null,
|
|
18857
|
+
registered_at_ms: null,
|
|
18858
|
+
apple_issuer_id: null,
|
|
18859
|
+
apple_error: null,
|
|
18860
|
+
build_id: null
|
|
18861
|
+
};
|
|
18862
|
+
try {
|
|
18863
|
+
await db.transaction(async (tx) => {
|
|
18864
|
+
tx.create("ios_devices", device);
|
|
18865
|
+
});
|
|
18866
|
+
} catch (error) {
|
|
18867
|
+
if (error instanceof DatabaseConstraintError && error.reason === "unique") {
|
|
18868
|
+
const winner = await db.findOne("ios_devices", { udid });
|
|
18869
|
+
if (winner !== null) return {
|
|
18870
|
+
device: pick$1(winner),
|
|
18871
|
+
created: false
|
|
18872
|
+
};
|
|
18873
|
+
}
|
|
18874
|
+
throw error;
|
|
18875
|
+
}
|
|
18876
|
+
return {
|
|
18877
|
+
device,
|
|
18878
|
+
created: true
|
|
18879
|
+
};
|
|
18880
|
+
},
|
|
18881
|
+
async approveIosDevice(id, input) {
|
|
18882
|
+
const name = input.name === void 0 ? void 0 : nameOf(input.name);
|
|
18883
|
+
const approvedBy = personOf(input.approvedBy, "approvedBy");
|
|
18884
|
+
return db.transaction(async (tx) => {
|
|
18885
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
18886
|
+
if (row === null) return null;
|
|
18887
|
+
const device = pick$1(row);
|
|
18888
|
+
const set = {
|
|
18889
|
+
...name === void 0 || name === device.name ? {} : { name },
|
|
18890
|
+
...device.status === "pending" ? {
|
|
18891
|
+
status: "approved",
|
|
18892
|
+
approved_by: approvedBy,
|
|
18893
|
+
approved_at_ms: now()
|
|
18894
|
+
} : {}
|
|
18895
|
+
};
|
|
18896
|
+
if (Object.keys(set).length === 0) return device;
|
|
18897
|
+
tx.update("ios_devices", row, set);
|
|
18898
|
+
return {
|
|
18899
|
+
...device,
|
|
18900
|
+
...set
|
|
18901
|
+
};
|
|
18902
|
+
});
|
|
18903
|
+
},
|
|
18904
|
+
async renameIosDevice(id, input) {
|
|
18905
|
+
const name = nameOf(input);
|
|
18906
|
+
return db.transaction(async (tx) => {
|
|
18907
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
18908
|
+
if (row === null) return null;
|
|
18909
|
+
const device = pick$1(row);
|
|
18910
|
+
if (device.name === name) return device;
|
|
18911
|
+
tx.update("ios_devices", row, { name });
|
|
18912
|
+
return {
|
|
18913
|
+
...device,
|
|
18914
|
+
name
|
|
18915
|
+
};
|
|
18916
|
+
});
|
|
18917
|
+
},
|
|
18918
|
+
async recordIosDeviceOutcome({ id, seen, issuerId, outcome, reason }) {
|
|
18919
|
+
if (!OUTCOMES.includes(outcome)) throw new IosDeviceInputError(`Invalid iOS device outcome: ${String(outcome)}. Expected ${OUTCOMES.join(", ")}.`);
|
|
18920
|
+
if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device outcome: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
|
|
18921
|
+
return db.transaction(async (tx) => {
|
|
18922
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
18923
|
+
if (row === null) return null;
|
|
18924
|
+
const device = pick$1(row);
|
|
18925
|
+
if (device.status !== seen.status || device.approved_at_ms !== seen.approvedAtMs || device.apple_issuer_id !== null && device.apple_issuer_id !== issuerId) return null;
|
|
18926
|
+
let set;
|
|
18927
|
+
switch (outcome) {
|
|
18928
|
+
case "registered":
|
|
18929
|
+
if (device.status === "pending") return null;
|
|
18930
|
+
set = {
|
|
18931
|
+
status: "registered",
|
|
18932
|
+
registered_at_ms: device.registered_at_ms ?? now(),
|
|
18933
|
+
apple_issuer_id: issuerId,
|
|
18934
|
+
apple_error: null
|
|
18935
|
+
};
|
|
18936
|
+
break;
|
|
18937
|
+
case "refused":
|
|
18938
|
+
if (device.status !== "approved") return null;
|
|
18939
|
+
set = { apple_error: errorText(reason === void 0 || reason.trim() === "" ? "Apple refused it." : reason) };
|
|
18940
|
+
break;
|
|
18941
|
+
case "disabled":
|
|
18942
|
+
if (device.status === "pending") return null;
|
|
18943
|
+
set = { apple_error: IOS_DEVICE_DISABLED_ERROR };
|
|
18944
|
+
break;
|
|
18945
|
+
case "missing":
|
|
18946
|
+
if (device.status !== "registered") return null;
|
|
18947
|
+
set = {
|
|
18948
|
+
status: "pending",
|
|
18949
|
+
approved_by: null,
|
|
18950
|
+
approved_at_ms: null,
|
|
18951
|
+
apple_error: IOS_DEVICE_MISSING_ERROR
|
|
18952
|
+
};
|
|
18953
|
+
}
|
|
18954
|
+
if (Object.entries(set).some(([column, value]) => device[column] !== (value ?? null))) tx.update("ios_devices", row, set);
|
|
18955
|
+
return {
|
|
18956
|
+
...device,
|
|
18957
|
+
...set
|
|
18958
|
+
};
|
|
18959
|
+
});
|
|
18960
|
+
},
|
|
18961
|
+
async markIosDevicesInBuild({ buildId, ids }) {
|
|
18962
|
+
for (const id of new Set(ids)) await db.transaction(async (tx) => {
|
|
18963
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
18964
|
+
if (row === null || typeof row.build_id === "string" && row.build_id >= buildId) return;
|
|
18965
|
+
tx.update("ios_devices", row, { build_id: buildId });
|
|
18966
|
+
});
|
|
18967
|
+
},
|
|
18968
|
+
async claimIosDeviceAccount(issuerId) {
|
|
18969
|
+
if (typeof issuerId !== "string" || issuerId.trim().length === 0 || issuerId.length > ISSUER_MAX_LENGTH) throw new IosDeviceInputError(`Invalid iOS device account: issuerId must be an App Store Connect issuer of at most ${ISSUER_MAX_LENGTH} characters.`);
|
|
18970
|
+
const answer = (held) => ({
|
|
18971
|
+
issuerId: held,
|
|
18972
|
+
claimed: held === issuerId
|
|
18973
|
+
});
|
|
18974
|
+
const existing = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
|
|
18975
|
+
if (existing !== null) return answer(existing.apple_issuer_id);
|
|
18976
|
+
const holder = await accountOfRows() ?? issuerId;
|
|
18977
|
+
try {
|
|
18978
|
+
await db.transaction(async (tx) => {
|
|
18979
|
+
tx.create("ios_device_account", {
|
|
18980
|
+
id: ACCOUNT_ROW,
|
|
18981
|
+
apple_issuer_id: holder,
|
|
18982
|
+
claimed_at_ms: now()
|
|
18983
|
+
});
|
|
18984
|
+
});
|
|
18985
|
+
return answer(holder);
|
|
18986
|
+
} catch (error) {
|
|
18987
|
+
if (error instanceof DatabaseConstraintError && (error.reason === "exists" || error.reason === "unique")) {
|
|
18988
|
+
const winner = await db.findOne("ios_device_account", { id: ACCOUNT_ROW });
|
|
18989
|
+
if (winner !== null) return answer(winner.apple_issuer_id);
|
|
18990
|
+
}
|
|
18991
|
+
throw error;
|
|
18992
|
+
}
|
|
18993
|
+
},
|
|
18994
|
+
async deleteIosDevice(id, only) {
|
|
18995
|
+
const requestedBy = only?.requestedBy === void 0 ? void 0 : personOf(only.requestedBy, "requestedBy");
|
|
18996
|
+
return db.transaction(async (tx) => {
|
|
18997
|
+
const row = await tx.findOne("ios_devices", { id });
|
|
18998
|
+
if (row === null) return null;
|
|
18999
|
+
const device = pick$1(row);
|
|
19000
|
+
if (only?.status !== void 0 && device.status !== only.status || requestedBy !== void 0 && device.requested_by !== requestedBy) return null;
|
|
19001
|
+
await tx.delete("ios_devices", row);
|
|
19002
|
+
return device;
|
|
19003
|
+
});
|
|
19004
|
+
}
|
|
19005
|
+
};
|
|
19006
|
+
};
|
|
19007
|
+
//#endregion
|
|
18632
19008
|
//#region ../../packages/server/dist/core/nativeBuildDestinations.mjs
|
|
18633
19009
|
const NATIVE_BUILD_SUBMISSION_DESTINATIONS = {
|
|
18634
19010
|
android: [
|
|
@@ -18762,8 +19138,15 @@ const pick = (row) => ({
|
|
|
18762
19138
|
submitted_version: row.submitted_version ?? null,
|
|
18763
19139
|
is_store_build: row.is_store_build === true,
|
|
18764
19140
|
is_sandbox: row.is_sandbox === true,
|
|
18765
|
-
sandbox_url_scheme: row.sandbox_url_scheme ?? null
|
|
19141
|
+
sandbox_url_scheme: row.sandbox_url_scheme ?? null,
|
|
19142
|
+
export_method: row.export_method ?? null
|
|
18766
19143
|
});
|
|
19144
|
+
const EXPORT_METHODS = /* @__PURE__ */ new Set([
|
|
19145
|
+
"app-store",
|
|
19146
|
+
"ad-hoc",
|
|
19147
|
+
"development",
|
|
19148
|
+
"enterprise"
|
|
19149
|
+
]);
|
|
18767
19150
|
const SANDBOX_CHANNEL_PREFIX = "sandbox-";
|
|
18768
19151
|
const OLDER_BUILDS_PAGE = 20;
|
|
18769
19152
|
const MARK_ATTEMPTS = 8;
|
|
@@ -18790,7 +19173,7 @@ const nativeBuildScopeKey = (scope) => {
|
|
|
18790
19173
|
return scopeKey;
|
|
18791
19174
|
};
|
|
18792
19175
|
const isBuiltInBundle = async (db, bundleId) => await db.findOne("native_builds", { min_bundle_id: bundleId }) !== null;
|
|
18793
|
-
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, artifact }) => {
|
|
19176
|
+
const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVersion, gitCommitHash, buildKey, buildNumber, isSandbox, sandboxUrlScheme, exportMethod, artifact }) => {
|
|
18794
19177
|
if (!isUUIDv7(id)) return "id must be a UUIDv7";
|
|
18795
19178
|
if (!isUUIDv7(minBundleId)) return "minBundleId must be the UUIDv7 a release build compiles in";
|
|
18796
19179
|
if (platform !== "ios" && platform !== "android") return "platform must be ios or android";
|
|
@@ -18809,6 +19192,10 @@ const problemOf = ({ id, minBundleId, platform, channel, fingerprintHash, appVer
|
|
|
18809
19192
|
if (buildNumber !== void 0 && buildNumber !== null && (buildNumber.trim().length === 0 || buildNumber.length > BUILD_NUMBER_MAX_LENGTH)) return `buildNumber must be the artifact's build number, up to ${BUILD_NUMBER_MAX_LENGTH} characters, or null`;
|
|
18810
19193
|
const kinds = ARTIFACT_KINDS[platform];
|
|
18811
19194
|
if (!kinds.includes(artifact.kind)) return `artifact.kind of an ${platform} build must be ${kinds.join(" or ")}`;
|
|
19195
|
+
if (exportMethod !== void 0 && exportMethod !== null) {
|
|
19196
|
+
if (artifact.kind !== "ipa") return "exportMethod is an .ipa's, and this artifact isn't one";
|
|
19197
|
+
if (!EXPORT_METHODS.has(exportMethod)) return `exportMethod must be ${[...EXPORT_METHODS].join(", ")}, or null`;
|
|
19198
|
+
}
|
|
18812
19199
|
if (!Number.isSafeInteger(artifact.byteSize) || artifact.byteSize < 0) return "artifact.byteSize must be a byte count";
|
|
18813
19200
|
return null;
|
|
18814
19201
|
};
|
|
@@ -18839,7 +19226,8 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
18839
19226
|
submitted_version: null,
|
|
18840
19227
|
is_store_build: false,
|
|
18841
19228
|
is_sandbox: registration.isSandbox === true,
|
|
18842
|
-
sandbox_url_scheme: registration.sandboxUrlScheme ?? null
|
|
19229
|
+
sandbox_url_scheme: registration.sandboxUrlScheme ?? null,
|
|
19230
|
+
export_method: registration.exportMethod ?? null
|
|
18843
19231
|
};
|
|
18844
19232
|
for (let attempt = 1;; attempt += 1) {
|
|
18845
19233
|
await insertChannel(db, {
|
|
@@ -19553,6 +19941,7 @@ const createCoreApi = (db, storage, options = {}) => {
|
|
|
19553
19941
|
...reads,
|
|
19554
19942
|
...createCoreOperations(purgingCachedRoutes(db, options.onCachedRoutesChange), options),
|
|
19555
19943
|
...createNativeBuildApi(db, options),
|
|
19944
|
+
...createIosDeviceApi(db, options),
|
|
19556
19945
|
ready: async () => {
|
|
19557
19946
|
await reads.listReleaseCatalogs({ limit: 1 });
|
|
19558
19947
|
}
|
|
@@ -19762,10 +20151,12 @@ const keyset = (url, maxValue = LIMITS.maxValue) => {
|
|
|
19762
20151
|
const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
|
|
19763
20152
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
|
|
19764
20153
|
const cursor = url.searchParams.get("cursor");
|
|
20154
|
+
const through = url.searchParams.get("through");
|
|
19765
20155
|
return {
|
|
19766
20156
|
order,
|
|
19767
20157
|
limit,
|
|
19768
|
-
...cursor === null ? {} : { after: cursor }
|
|
20158
|
+
...cursor === null ? {} : { after: cursor },
|
|
20159
|
+
...through === null ? {} : { through }
|
|
19769
20160
|
};
|
|
19770
20161
|
};
|
|
19771
20162
|
const page = (rows, { limit }, keyOf, extra = {}) => json$2({
|
|
@@ -19872,11 +20263,11 @@ const refusingInvalid = async (operation) => {
|
|
|
19872
20263
|
try {
|
|
19873
20264
|
return await operation();
|
|
19874
20265
|
} catch (error) {
|
|
19875
|
-
if (error instanceof NativeBuildInputError) throw new HandlerBadRequestError(error.message);
|
|
20266
|
+
if (error instanceof NativeBuildInputError || error instanceof IosDeviceInputError) throw new HandlerBadRequestError(error.message);
|
|
19876
20267
|
throw error;
|
|
19877
20268
|
}
|
|
19878
20269
|
};
|
|
19879
|
-
const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull$1(value.sandboxUrlScheme)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
|
|
20270
|
+
const isNativeBuildRegistration = (value) => isRecord$5(value) && isText$2(value.id) && isText$2(value.minBundleId) && typeof value.platform === "string" && isPlatform(value.platform) && isText$2(value.channel) && isTextOrNull$1(value.fingerprintHash) && isTextOrNull$1(value.appVersion) && value.fingerprintHash === null !== (value.appVersion === null) && isTextOrNull$1(value.gitCommitHash) && isTextOrNull$1(value.buildKey) && (value.buildNumber === void 0 || isTextOrNull$1(value.buildNumber)) && (value.isSandbox === void 0 || typeof value.isSandbox === "boolean") && (value.sandboxUrlScheme === void 0 || isTextOrNull$1(value.sandboxUrlScheme)) && (value.exportMethod === void 0 || isTextOrNull$1(value.exportMethod)) && isRecord$5(value.artifact) && typeof value.artifact.kind === "string" && NATIVE_BUILD_ARTIFACT_KINDS.has(value.artifact.kind) && isText$2(value.artifact.storageUri) && Number.isSafeInteger(value.artifact.byteSize) && value.artifact.byteSize >= 0 && isRecord$5(value.embeddedBundle) && isText$2(value.embeddedBundle.manifestStorageUri) && isText$2(value.embeddedBundle.manifestFileHash) && isText$2(value.embeddedBundle.assetBaseStorageUri) && (value.embeddedBundle.metadata === void 0 || isRecord$5(value.embeddedBundle.metadata));
|
|
19880
20271
|
const scopeKeyOf = (params) => decodeMaybe(requireRouteParam(params, "scopeKey")) ?? "";
|
|
19881
20272
|
const createAdminRouteHandlers = () => ({
|
|
19882
20273
|
listBundles: onCore(async (core, request) => {
|
|
@@ -20034,6 +20425,81 @@ const createAdminRouteHandlers = () => ({
|
|
|
20034
20425
|
return json$2({ data: await refusingInvalid(() => core.markNativeBuild(requireRouteParam(params, "id"), mark)) });
|
|
20035
20426
|
}),
|
|
20036
20427
|
deleteNativeBuild: onCore(async (core, _request, params) => json$2({ data: await core.deleteNativeBuild(requireRouteParam(params, "id")) })),
|
|
20428
|
+
listIosDevices: onCore(async (core, request) => {
|
|
20429
|
+
const url = new URL(request.url);
|
|
20430
|
+
const input = keyset(url);
|
|
20431
|
+
const status = url.searchParams.get("status");
|
|
20432
|
+
return page(await refusingInvalid(() => core.listIosDevices({
|
|
20433
|
+
...input,
|
|
20434
|
+
...status === null ? {} : { status }
|
|
20435
|
+
})), input, ({ id }) => id);
|
|
20436
|
+
}),
|
|
20437
|
+
findIosDevice: onCore(async (core, _request, params) => json$2({ data: await core.findIosDevice(requireRouteParam(params, "udid")) })),
|
|
20438
|
+
requestIosDevice: onCore(async (core, request) => {
|
|
20439
|
+
const input = await body(request);
|
|
20440
|
+
if (!isText$2(input.udid) || !isText$2(input.name) || !isTextOrNull$1(input.requestedBy)) throw new HandlerBadRequestError("An iOS device request needs udid, name, and requestedBy, an email or null.");
|
|
20441
|
+
const device = {
|
|
20442
|
+
udid: input.udid,
|
|
20443
|
+
name: input.name,
|
|
20444
|
+
requestedBy: input.requestedBy
|
|
20445
|
+
};
|
|
20446
|
+
return json$2({ data: await refusingInvalid(() => core.requestIosDevice(device)) });
|
|
20447
|
+
}),
|
|
20448
|
+
approveIosDevice: onCore(async (core, request, params) => {
|
|
20449
|
+
const input = await body(request);
|
|
20450
|
+
if (!isTextOrNull$1(input.approvedBy) || input.name !== void 0 && !isText$2(input.name)) throw new HandlerBadRequestError("An iOS device approval needs approvedBy, an email or null, and an optional name.");
|
|
20451
|
+
const approval = {
|
|
20452
|
+
approvedBy: input.approvedBy,
|
|
20453
|
+
...input.name === void 0 ? {} : { name: input.name }
|
|
20454
|
+
};
|
|
20455
|
+
return json$2({ data: await refusingInvalid(() => core.approveIosDevice(requireRouteParam(params, "id"), approval)) });
|
|
20456
|
+
}),
|
|
20457
|
+
renameIosDevice: onCore(async (core, request, params) => {
|
|
20458
|
+
const input = await body(request);
|
|
20459
|
+
if (!isText$2(input.name)) throw new HandlerBadRequestError("An iOS device's new name is required.");
|
|
20460
|
+
const name = input.name;
|
|
20461
|
+
return json$2({ data: await refusingInvalid(() => core.renameIosDevice(requireRouteParam(params, "id"), name)) });
|
|
20462
|
+
}),
|
|
20463
|
+
recordIosDeviceOutcome: onCore(async (core, request, params) => {
|
|
20464
|
+
const input = await body(request);
|
|
20465
|
+
const seen = input.seen;
|
|
20466
|
+
if (!isRecord$5(seen) || typeof seen.status !== "string" || !(seen.approvedAtMs === null || Number.isSafeInteger(seen.approvedAtMs)) || !isText$2(input.issuerId) || typeof input.outcome !== "string" || input.reason !== void 0 && typeof input.reason !== "string") throw new HandlerBadRequestError("An iOS device outcome needs seen { status, approvedAtMs }, issuerId, outcome, and an optional reason.");
|
|
20467
|
+
const outcome = {
|
|
20468
|
+
id: requireRouteParam(params, "id"),
|
|
20469
|
+
seen: {
|
|
20470
|
+
status: seen.status,
|
|
20471
|
+
approvedAtMs: seen.approvedAtMs
|
|
20472
|
+
},
|
|
20473
|
+
issuerId: input.issuerId,
|
|
20474
|
+
outcome: input.outcome,
|
|
20475
|
+
...input.reason === void 0 ? {} : { reason: input.reason }
|
|
20476
|
+
};
|
|
20477
|
+
return json$2({ data: await refusingInvalid(() => core.recordIosDeviceOutcome(outcome)) });
|
|
20478
|
+
}),
|
|
20479
|
+
claimIosDeviceAccount: onCore(async (core, request) => {
|
|
20480
|
+
const { issuerId } = await body(request);
|
|
20481
|
+
if (!isText$2(issuerId)) throw new HandlerBadRequestError("Claiming the iOS device account needs issuerId.");
|
|
20482
|
+
return json$2({ data: await refusingInvalid(() => core.claimIosDeviceAccount(issuerId)) });
|
|
20483
|
+
}),
|
|
20484
|
+
markIosDevicesInBuild: onCore(async (core, request) => {
|
|
20485
|
+
const { buildId, ids } = await body(request);
|
|
20486
|
+
if (!isText$2(buildId) || !Array.isArray(ids) || !ids.every((id) => isText$2(id))) throw new HandlerBadRequestError("Marking iOS devices in a build needs buildId and ids.");
|
|
20487
|
+
await core.markIosDevicesInBuild({
|
|
20488
|
+
buildId,
|
|
20489
|
+
ids
|
|
20490
|
+
});
|
|
20491
|
+
return noContent();
|
|
20492
|
+
}),
|
|
20493
|
+
deleteIosDevice: onCore(async (core, request, params) => {
|
|
20494
|
+
const url = new URL(request.url);
|
|
20495
|
+
const status = url.searchParams.get("status");
|
|
20496
|
+
const requestedBy = url.searchParams.get("requestedBy");
|
|
20497
|
+
const only = {
|
|
20498
|
+
...status === null ? {} : { status },
|
|
20499
|
+
...requestedBy === null ? {} : { requestedBy }
|
|
20500
|
+
};
|
|
20501
|
+
return json$2({ data: await refusingInvalid(() => Object.keys(only).length === 0 ? core.deleteIosDevice(requireRouteParam(params, "id")) : core.deleteIosDevice(requireRouteParam(params, "id"), only)) });
|
|
20502
|
+
}),
|
|
20037
20503
|
deleteBundles: onCore(async (core, request) => {
|
|
20038
20504
|
const { ids } = await body(request);
|
|
20039
20505
|
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id.length > 0)) throw new HandlerBadRequestError("Bundle deletion needs ids");
|
|
@@ -20186,6 +20652,51 @@ const ADMIN_ROUTES = [
|
|
|
20186
20652
|
method: "DELETE",
|
|
20187
20653
|
path: "/native-builds/:id",
|
|
20188
20654
|
handler: "deleteNativeBuild"
|
|
20655
|
+
},
|
|
20656
|
+
{
|
|
20657
|
+
method: "GET",
|
|
20658
|
+
path: "/ios-devices",
|
|
20659
|
+
handler: "listIosDevices"
|
|
20660
|
+
},
|
|
20661
|
+
{
|
|
20662
|
+
method: "POST",
|
|
20663
|
+
path: "/ios-devices",
|
|
20664
|
+
handler: "requestIosDevice"
|
|
20665
|
+
},
|
|
20666
|
+
{
|
|
20667
|
+
method: "GET",
|
|
20668
|
+
path: "/ios-devices/udid/:udid",
|
|
20669
|
+
handler: "findIosDevice"
|
|
20670
|
+
},
|
|
20671
|
+
{
|
|
20672
|
+
method: "POST",
|
|
20673
|
+
path: "/ios-devices/in-build",
|
|
20674
|
+
handler: "markIosDevicesInBuild"
|
|
20675
|
+
},
|
|
20676
|
+
{
|
|
20677
|
+
method: "POST",
|
|
20678
|
+
path: "/ios-devices/account",
|
|
20679
|
+
handler: "claimIosDeviceAccount"
|
|
20680
|
+
},
|
|
20681
|
+
{
|
|
20682
|
+
method: "POST",
|
|
20683
|
+
path: "/ios-devices/:id/approval",
|
|
20684
|
+
handler: "approveIosDevice"
|
|
20685
|
+
},
|
|
20686
|
+
{
|
|
20687
|
+
method: "POST",
|
|
20688
|
+
path: "/ios-devices/:id/outcome",
|
|
20689
|
+
handler: "recordIosDeviceOutcome"
|
|
20690
|
+
},
|
|
20691
|
+
{
|
|
20692
|
+
method: "PATCH",
|
|
20693
|
+
path: "/ios-devices/:id",
|
|
20694
|
+
handler: "renameIosDevice"
|
|
20695
|
+
},
|
|
20696
|
+
{
|
|
20697
|
+
method: "DELETE",
|
|
20698
|
+
path: "/ios-devices/:id",
|
|
20699
|
+
handler: "deleteIosDevice"
|
|
20189
20700
|
}
|
|
20190
20701
|
];
|
|
20191
20702
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/vercel",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.28",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@vercel/cli-auth": "0.3.10",
|
|
42
42
|
"@vercel/cli-config": "0.3.1",
|
|
43
43
|
"pg": "8.13.1",
|
|
44
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
45
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
46
|
-
"@hot-updater/postgres": "1.2.0-rc.
|
|
47
|
-
"@hot-updater/
|
|
48
|
-
"@hot-updater/
|
|
44
|
+
"@hot-updater/cli-tools": "1.2.0-rc.28",
|
|
45
|
+
"@hot-updater/plugin-core": "1.2.0-rc.28",
|
|
46
|
+
"@hot-updater/postgres": "1.2.0-rc.28",
|
|
47
|
+
"@hot-updater/protocol": "1.2.0-rc.28",
|
|
48
|
+
"@hot-updater/server": "1.2.0-rc.28"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^20",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"execa": "9.5.2",
|
|
55
55
|
"kysely": "0.28.17",
|
|
56
56
|
"vitest": "4.1.4",
|
|
57
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
57
|
+
"@hot-updater/test-utils": "1.2.0-rc.28"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsdown",
|