@hot-updater/plugin-core 1.1.3 → 1.2.0-rc.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/coreApi.d.cts +96 -5
- package/dist/coreApi.d.mts +96 -5
- package/dist/engine/core/schema.cjs +365 -235
- package/dist/engine/core/schema.d.cts +105 -0
- package/dist/engine/core/schema.d.mts +105 -0
- package/dist/engine/core/schema.mjs +365 -235
- package/dist/engine/createEngine.cjs +2 -2
- package/dist/engine/createEngine.mjs +2 -2
- package/dist/engine/database/fence.cjs +32 -6
- package/dist/engine/database/fence.mjs +32 -6
- package/dist/engine/db/engineMigrator.cjs +2 -2
- package/dist/engine/db/engineMigrator.mjs +2 -2
- package/dist/engine/db/engineSqlMigrator.cjs +2 -2
- package/dist/engine/db/engineSqlMigrator.mjs +2 -2
- package/dist/engine/db/settingsMigrator.cjs +2 -2
- package/dist/engine/db/settingsMigrator.mjs +2 -2
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/remoteBundleSigning.cjs +87 -24
- package/dist/remoteBundleSigning.d.cts +10 -2
- package/dist/remoteBundleSigning.d.mts +10 -2
- package/dist/remoteBundleSigning.mjs +87 -24
- package/dist/types/databaseRows.d.cts +41 -1
- package/dist/types/databaseRows.d.mts +41 -1
- package/dist/types/index.d.cts +110 -10
- package/dist/types/index.d.mts +110 -10
- package/dist/types/models.d.cts +13 -2
- package/dist/types/models.d.mts +13 -2
- package/dist/types/public.d.cts +3 -3
- package/dist/types/public.d.mts +3 -3
- package/package.json +3 -3
|
@@ -34,12 +34,17 @@ const SETTINGS_TABLE = {
|
|
|
34
34
|
const ENGINE_SCHEMA_KEY = "schema.engine";
|
|
35
35
|
const CORE_SCHEMA_KEY = "schema.core";
|
|
36
36
|
const stored = ({ key, expected, found }) => `"${key}" is ${found === null ? "missing" : `"${found}"`}; expected "${expected}"`;
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* How to migrate a database the fence refused: doctor names the command for
|
|
39
|
+
* it, init again for a deployment init manages, or the database's own
|
|
40
|
+
* tooling in the server's project.
|
|
41
|
+
*/
|
|
42
|
+
const MIGRATE_SCHEMA_FIX = "Run `npx hot-updater doctor` in the project whose hot-updater.config.ts names this database: it names the command that migrates it. In a server project, `hot-updater db migrate` migrates the database its server file names.";
|
|
43
|
+
const settingMessage = (adapterName, { key, expected, found }) => `Hot Updater schema setting "${key}" for ${adapterName} is ${found === null ? "missing" : `"${found}"`}; expected "${expected}". ${MIGRATE_SCHEMA_FIX}`;
|
|
38
44
|
/** The plugin a `schema.<id>` setting belongs to; undefined for core's and the engine's. */
|
|
39
45
|
const pluginOf = ({ key }) => key.startsWith("schema.") && key !== "schema.engine" && key !== CORE_SCHEMA_KEY ? key.slice(7) : void 0;
|
|
40
46
|
const listed = (items) => items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
41
|
-
|
|
42
|
-
const PLUGIN_TABLES_FIX = "Run `hot-updater db migrate`. A managed server runs only its provider's plugins, and rerunning `hot-updater init --provider <provider>` applies the provider's migrations. Run `hot-updater db` commands in the server's project: they load the server file named on the command line, or src/hotUpdater.* or src/db.*, and don't read hot-updater.config.ts.";
|
|
47
|
+
const settingsMessage = (adapterName, settings) => `Hot Updater schema settings for ${adapterName} are not migrated: ${settings.map(stored).join(", and ")}. ${MIGRATE_SCHEMA_FIX}`;
|
|
43
48
|
const pluginsMessage = (adapterName, plugins, settings, fix) => `The tables of ${plugins.length === 1 ? "plugin" : "plugins"} ${listed(plugins.map((id) => `"${id}"`))} are not migrated on ${adapterName}: schema ${settings.length === 1 ? "setting" : "settings"} ${settings.map(stored).join(", and ")}. ${fix}`;
|
|
44
49
|
/** The database needs `hot-updater db migrate`, or a new database; the handler answers 503. */
|
|
45
50
|
var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
@@ -56,7 +61,7 @@ var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
|
56
61
|
constructor(adapterName, currentVersion, setting, options) {
|
|
57
62
|
const settings = options?.settings ?? (setting === void 0 ? [] : [setting]);
|
|
58
63
|
const plugins = settings.flatMap((mismatch) => pluginOf(mismatch) ?? []);
|
|
59
|
-
super(setting === void 0 ? currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}.
|
|
64
|
+
super(setting === void 0 ? currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. ${MIGRATE_SCHEMA_FIX}` : `Hot Updater v1 cannot migrate schema ${currentVersion} in place. Create a new empty database and run \`hot-updater db migrate\`.` : plugins.length > 0 && plugins.length === settings.length ? pluginsMessage(adapterName, plugins, settings, options?.fix ?? MIGRATE_SCHEMA_FIX) : settings.length > 1 && !(setting.key === "schema.engine" && setting.found === null) ? settingsMessage(adapterName, settings) : settingMessage(adapterName, setting), options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
60
65
|
this.adapterName = adapterName;
|
|
61
66
|
this.currentVersion = currentVersion;
|
|
62
67
|
this.setting = setting;
|
|
@@ -120,17 +125,37 @@ const checkSchemaFence = async (adapter, adapterName, expected, fix) => {
|
|
|
120
125
|
};
|
|
121
126
|
/** The database name a fenced adapter carries, so a server can fence its plugins' rows too. */
|
|
122
127
|
const FENCED = Symbol.for("@hot-updater/server/schema-fence");
|
|
128
|
+
/**
|
|
129
|
+
* The adapter a fence reads its settings through and the settings it
|
|
130
|
+
* expects, so a fence over it checks them with its own in one read. Another
|
|
131
|
+
* key than `FENCED`, whose value another copy of plugin-core reads as the
|
|
132
|
+
* name.
|
|
133
|
+
*/
|
|
134
|
+
const FENCED_SETTINGS = Symbol.for("@hot-updater/server/schema-fence-settings");
|
|
123
135
|
/** The database name an adapter behind the schema fence reports under. */
|
|
124
136
|
const fencedName = (adapter) => adapter[FENCED];
|
|
125
137
|
/**
|
|
126
138
|
* The adapter behind the schema fence: a process's first read or write
|
|
127
139
|
* checks the settings first. Success is kept; a failure is checked again on
|
|
128
|
-
* the next call.
|
|
140
|
+
* the next call. A fence over another one, as a server's plugins' over
|
|
141
|
+
* core's, checks the inner fence's settings with its own in that one read,
|
|
142
|
+
* so its refusal lists every setting missing or different.
|
|
129
143
|
*/
|
|
130
144
|
const withSchemaFence = (adapter, adapterName, expected, fix) => {
|
|
145
|
+
const inner = adapter[FENCED_SETTINGS];
|
|
146
|
+
const settings = inner === void 0 ? {
|
|
147
|
+
adapter,
|
|
148
|
+
expected
|
|
149
|
+
} : {
|
|
150
|
+
adapter: inner.adapter,
|
|
151
|
+
expected: {
|
|
152
|
+
...inner.expected,
|
|
153
|
+
...expected
|
|
154
|
+
}
|
|
155
|
+
};
|
|
131
156
|
let ready;
|
|
132
157
|
const fence = () => {
|
|
133
|
-
ready ??= checkSchemaFence(adapter, adapterName, expected, fix).catch((error) => {
|
|
158
|
+
ready ??= checkSchemaFence(settings.adapter, adapterName, settings.expected, fix).catch((error) => {
|
|
134
159
|
ready = void 0;
|
|
135
160
|
throw error;
|
|
136
161
|
});
|
|
@@ -139,6 +164,7 @@ const withSchemaFence = (adapter, adapterName, expected, fix) => {
|
|
|
139
164
|
return {
|
|
140
165
|
...adapter,
|
|
141
166
|
[FENCED]: adapterName,
|
|
167
|
+
[FENCED_SETTINGS]: settings,
|
|
142
168
|
get: (table, keys) => fence().then(() => adapter.get(table, keys)),
|
|
143
169
|
query: (table, request) => fence().then(() => adapter.query(table, request)),
|
|
144
170
|
write: (ops) => fence().then(() => adapter.write(ops)),
|
|
@@ -34,12 +34,17 @@ const SETTINGS_TABLE = {
|
|
|
34
34
|
const ENGINE_SCHEMA_KEY = "schema.engine";
|
|
35
35
|
const CORE_SCHEMA_KEY = "schema.core";
|
|
36
36
|
const stored = ({ key, expected, found }) => `"${key}" is ${found === null ? "missing" : `"${found}"`}; expected "${expected}"`;
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* How to migrate a database the fence refused: doctor names the command for
|
|
39
|
+
* it, init again for a deployment init manages, or the database's own
|
|
40
|
+
* tooling in the server's project.
|
|
41
|
+
*/
|
|
42
|
+
const MIGRATE_SCHEMA_FIX = "Run `npx hot-updater doctor` in the project whose hot-updater.config.ts names this database: it names the command that migrates it. In a server project, `hot-updater db migrate` migrates the database its server file names.";
|
|
43
|
+
const settingMessage = (adapterName, { key, expected, found }) => `Hot Updater schema setting "${key}" for ${adapterName} is ${found === null ? "missing" : `"${found}"`}; expected "${expected}". ${MIGRATE_SCHEMA_FIX}`;
|
|
38
44
|
/** The plugin a `schema.<id>` setting belongs to; undefined for core's and the engine's. */
|
|
39
45
|
const pluginOf = ({ key }) => key.startsWith("schema.") && key !== "schema.engine" && key !== CORE_SCHEMA_KEY ? key.slice(7) : void 0;
|
|
40
46
|
const listed = (items) => items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
41
|
-
|
|
42
|
-
const PLUGIN_TABLES_FIX = "Run `hot-updater db migrate`. A managed server runs only its provider's plugins, and rerunning `hot-updater init --provider <provider>` applies the provider's migrations. Run `hot-updater db` commands in the server's project: they load the server file named on the command line, or src/hotUpdater.* or src/db.*, and don't read hot-updater.config.ts.";
|
|
47
|
+
const settingsMessage = (adapterName, settings) => `Hot Updater schema settings for ${adapterName} are not migrated: ${settings.map(stored).join(", and ")}. ${MIGRATE_SCHEMA_FIX}`;
|
|
43
48
|
const pluginsMessage = (adapterName, plugins, settings, fix) => `The tables of ${plugins.length === 1 ? "plugin" : "plugins"} ${listed(plugins.map((id) => `"${id}"`))} are not migrated on ${adapterName}: schema ${settings.length === 1 ? "setting" : "settings"} ${settings.map(stored).join(", and ")}. ${fix}`;
|
|
44
49
|
/** The database needs `hot-updater db migrate`, or a new database; the handler answers 503. */
|
|
45
50
|
var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
@@ -56,7 +61,7 @@ var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
|
56
61
|
constructor(adapterName, currentVersion, setting, options) {
|
|
57
62
|
const settings = options?.settings ?? (setting === void 0 ? [] : [setting]);
|
|
58
63
|
const plugins = settings.flatMap((mismatch) => pluginOf(mismatch) ?? []);
|
|
59
|
-
super(setting === void 0 ? currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}.
|
|
64
|
+
super(setting === void 0 ? currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. ${MIGRATE_SCHEMA_FIX}` : `Hot Updater v1 cannot migrate schema ${currentVersion} in place. Create a new empty database and run \`hot-updater db migrate\`.` : plugins.length > 0 && plugins.length === settings.length ? pluginsMessage(adapterName, plugins, settings, options?.fix ?? MIGRATE_SCHEMA_FIX) : settings.length > 1 && !(setting.key === "schema.engine" && setting.found === null) ? settingsMessage(adapterName, settings) : settingMessage(adapterName, setting), options?.cause === void 0 ? void 0 : { cause: options.cause });
|
|
60
65
|
this.adapterName = adapterName;
|
|
61
66
|
this.currentVersion = currentVersion;
|
|
62
67
|
this.setting = setting;
|
|
@@ -120,17 +125,37 @@ const checkSchemaFence = async (adapter, adapterName, expected, fix) => {
|
|
|
120
125
|
};
|
|
121
126
|
/** The database name a fenced adapter carries, so a server can fence its plugins' rows too. */
|
|
122
127
|
const FENCED = Symbol.for("@hot-updater/server/schema-fence");
|
|
128
|
+
/**
|
|
129
|
+
* The adapter a fence reads its settings through and the settings it
|
|
130
|
+
* expects, so a fence over it checks them with its own in one read. Another
|
|
131
|
+
* key than `FENCED`, whose value another copy of plugin-core reads as the
|
|
132
|
+
* name.
|
|
133
|
+
*/
|
|
134
|
+
const FENCED_SETTINGS = Symbol.for("@hot-updater/server/schema-fence-settings");
|
|
123
135
|
/** The database name an adapter behind the schema fence reports under. */
|
|
124
136
|
const fencedName = (adapter) => adapter[FENCED];
|
|
125
137
|
/**
|
|
126
138
|
* The adapter behind the schema fence: a process's first read or write
|
|
127
139
|
* checks the settings first. Success is kept; a failure is checked again on
|
|
128
|
-
* the next call.
|
|
140
|
+
* the next call. A fence over another one, as a server's plugins' over
|
|
141
|
+
* core's, checks the inner fence's settings with its own in that one read,
|
|
142
|
+
* so its refusal lists every setting missing or different.
|
|
129
143
|
*/
|
|
130
144
|
const withSchemaFence = (adapter, adapterName, expected, fix) => {
|
|
145
|
+
const inner = adapter[FENCED_SETTINGS];
|
|
146
|
+
const settings = inner === void 0 ? {
|
|
147
|
+
adapter,
|
|
148
|
+
expected
|
|
149
|
+
} : {
|
|
150
|
+
adapter: inner.adapter,
|
|
151
|
+
expected: {
|
|
152
|
+
...inner.expected,
|
|
153
|
+
...expected
|
|
154
|
+
}
|
|
155
|
+
};
|
|
131
156
|
let ready;
|
|
132
157
|
const fence = () => {
|
|
133
|
-
ready ??= checkSchemaFence(adapter, adapterName, expected, fix).catch((error) => {
|
|
158
|
+
ready ??= checkSchemaFence(settings.adapter, adapterName, settings.expected, fix).catch((error) => {
|
|
134
159
|
ready = void 0;
|
|
135
160
|
throw error;
|
|
136
161
|
});
|
|
@@ -139,6 +164,7 @@ const withSchemaFence = (adapter, adapterName, expected, fix) => {
|
|
|
139
164
|
return {
|
|
140
165
|
...adapter,
|
|
141
166
|
[FENCED]: adapterName,
|
|
167
|
+
[FENCED_SETTINGS]: settings,
|
|
142
168
|
get: (table, keys) => fence().then(() => adapter.get(table, keys)),
|
|
143
169
|
query: (table, request) => fence().then(() => adapter.query(table, request)),
|
|
144
170
|
write: (ops) => fence().then(() => adapter.write(ops)),
|
|
@@ -35,14 +35,14 @@ const createEngineMigrator = (options) => {
|
|
|
35
35
|
return {
|
|
36
36
|
getVersion,
|
|
37
37
|
getNameVariants: async () => void 0,
|
|
38
|
-
next: async () => await getVersion() === "1.
|
|
38
|
+
next: async () => await getVersion() === "1.2.0" ? void 0 : { version: require_schema.HOT_UPDATER_SCHEMA_VERSION },
|
|
39
39
|
previous: async () => void 0,
|
|
40
40
|
up: makeResult,
|
|
41
41
|
down: async () => {
|
|
42
42
|
throw new Error("No previous schema to migrate to.");
|
|
43
43
|
},
|
|
44
44
|
migrateTo: async (version, migrate) => {
|
|
45
|
-
if (version !== "1.
|
|
45
|
+
if (version !== "1.2.0") throw new Error(`Invalid version ${version}`);
|
|
46
46
|
return makeResult(migrate);
|
|
47
47
|
},
|
|
48
48
|
migrateToLatest: makeResult
|
|
@@ -35,14 +35,14 @@ const createEngineMigrator = (options) => {
|
|
|
35
35
|
return {
|
|
36
36
|
getVersion,
|
|
37
37
|
getNameVariants: async () => void 0,
|
|
38
|
-
next: async () => await getVersion() === "1.
|
|
38
|
+
next: async () => await getVersion() === "1.2.0" ? void 0 : { version: HOT_UPDATER_SCHEMA_VERSION },
|
|
39
39
|
previous: async () => void 0,
|
|
40
40
|
up: makeResult,
|
|
41
41
|
down: async () => {
|
|
42
42
|
throw new Error("No previous schema to migrate to.");
|
|
43
43
|
},
|
|
44
44
|
migrateTo: async (version, migrate) => {
|
|
45
|
-
if (version !== "1.
|
|
45
|
+
if (version !== "1.2.0") throw new Error(`Invalid version ${version}`);
|
|
46
46
|
return makeResult(migrate);
|
|
47
47
|
},
|
|
48
48
|
migrateToLatest: makeResult
|
|
@@ -49,14 +49,14 @@ const createEngineSqlMigrator = (options) => {
|
|
|
49
49
|
return {
|
|
50
50
|
getVersion,
|
|
51
51
|
getNameVariants: async () => void 0,
|
|
52
|
-
next: async () => await getVersion() === "1.
|
|
52
|
+
next: async () => await getVersion() === "1.2.0" ? void 0 : { version: require_schema.HOT_UPDATER_SCHEMA_VERSION },
|
|
53
53
|
previous: async () => void 0,
|
|
54
54
|
up: makeResult,
|
|
55
55
|
down: async () => {
|
|
56
56
|
throw new Error("No previous schema to migrate to.");
|
|
57
57
|
},
|
|
58
58
|
migrateTo: async (version, migrate) => {
|
|
59
|
-
if (version !== "1.
|
|
59
|
+
if (version !== "1.2.0") throw new Error(`Invalid version ${version}`);
|
|
60
60
|
return makeResult(migrate);
|
|
61
61
|
},
|
|
62
62
|
migrateToLatest: makeResult
|
|
@@ -49,14 +49,14 @@ const createEngineSqlMigrator = (options) => {
|
|
|
49
49
|
return {
|
|
50
50
|
getVersion,
|
|
51
51
|
getNameVariants: async () => void 0,
|
|
52
|
-
next: async () => await getVersion() === "1.
|
|
52
|
+
next: async () => await getVersion() === "1.2.0" ? void 0 : { version: HOT_UPDATER_SCHEMA_VERSION },
|
|
53
53
|
previous: async () => void 0,
|
|
54
54
|
up: makeResult,
|
|
55
55
|
down: async () => {
|
|
56
56
|
throw new Error("No previous schema to migrate to.");
|
|
57
57
|
},
|
|
58
58
|
migrateTo: async (version, migrate) => {
|
|
59
|
-
if (version !== "1.
|
|
59
|
+
if (version !== "1.2.0") throw new Error(`Invalid version ${version}`);
|
|
60
60
|
return makeResult(migrate);
|
|
61
61
|
},
|
|
62
62
|
migrateToLatest: makeResult
|
|
@@ -71,14 +71,14 @@ const createSettingsMigrator = (options) => {
|
|
|
71
71
|
return {
|
|
72
72
|
getVersion,
|
|
73
73
|
getNameVariants: async () => void 0,
|
|
74
|
-
next: async () => await getVersion() === "1.
|
|
74
|
+
next: async () => await getVersion() === "1.2.0" ? void 0 : { version: require_schema.HOT_UPDATER_SCHEMA_VERSION },
|
|
75
75
|
previous: async () => void 0,
|
|
76
76
|
up: makeResult,
|
|
77
77
|
down: async () => {
|
|
78
78
|
throw new Error("No previous schema to migrate to.");
|
|
79
79
|
},
|
|
80
80
|
migrateTo: async (version, migrate) => {
|
|
81
|
-
if (version !== "1.
|
|
81
|
+
if (version !== "1.2.0") throw new Error(`Invalid version ${version}`);
|
|
82
82
|
return makeResult(migrate);
|
|
83
83
|
},
|
|
84
84
|
migrateToLatest: makeResult
|
|
@@ -71,14 +71,14 @@ const createSettingsMigrator = (options) => {
|
|
|
71
71
|
return {
|
|
72
72
|
getVersion,
|
|
73
73
|
getNameVariants: async () => void 0,
|
|
74
|
-
next: async () => await getVersion() === "1.
|
|
74
|
+
next: async () => await getVersion() === "1.2.0" ? void 0 : { version: HOT_UPDATER_SCHEMA_VERSION },
|
|
75
75
|
previous: async () => void 0,
|
|
76
76
|
up: makeResult,
|
|
77
77
|
down: async () => {
|
|
78
78
|
throw new Error("No previous schema to migrate to.");
|
|
79
79
|
},
|
|
80
80
|
migrateTo: async (version, migrate) => {
|
|
81
|
-
if (version !== "1.
|
|
81
|
+
if (version !== "1.2.0") throw new Error(`Invalid version ${version}`);
|
|
82
82
|
return makeResult(migrate);
|
|
83
83
|
},
|
|
84
84
|
migrateToLatest: makeResult
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getMani
|
|
|
3
3
|
import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.cjs";
|
|
4
4
|
import { getContentType } from "./contentType.cjs";
|
|
5
5
|
import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases } from "./releaseCatalogCompiler.cjs";
|
|
6
|
-
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
|
|
6
|
+
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.cjs";
|
|
7
7
|
import { CoreReads, ReleaseCatalogRequest } from "./serverPlugin/coreReads.cjs";
|
|
8
8
|
import { DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalRetention, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, expiresAt, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey } from "./database/adapter.cjs";
|
|
9
9
|
import { FieldDefinition, FieldReference, FieldType, IndexDefinition, ReferenceAction } from "./serverPlugin/definitions.cjs";
|
|
@@ -17,11 +17,11 @@ import { RetryOptions } from "./engine/database/engineTransaction.cjs";
|
|
|
17
17
|
import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./types/databaseConfig.cjs";
|
|
18
18
|
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.cjs";
|
|
19
19
|
import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.cjs";
|
|
20
|
-
import { ChannelDeleteResult, ChannelInsertResult } from "./types/models.cjs";
|
|
21
|
-
import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, BundleSigningAdapter, ConfigInput, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.cjs";
|
|
20
|
+
import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult } from "./types/models.cjs";
|
|
21
|
+
import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, BundleSigningAdapter, ConfigInput, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.cjs";
|
|
22
22
|
import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.cjs";
|
|
23
23
|
import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.cjs";
|
|
24
|
-
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.cjs";
|
|
24
|
+
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.cjs";
|
|
25
25
|
import { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError } from "./databaseErrors.cjs";
|
|
26
26
|
import { createStorageKeyBuilder } from "./createStorageKeyBuilder.cjs";
|
|
27
27
|
import { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter } from "./createStorageAdapter.cjs";
|
|
@@ -52,4 +52,4 @@ import { EngineSqlOptions, generateEngineSql } from "./engine/db/engineSql.cjs";
|
|
|
52
52
|
import { EngineSqlMigratorOptions, createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.cjs";
|
|
53
53
|
import { writeSchemaSettings } from "./engine/db/schemaSettings.cjs";
|
|
54
54
|
import { createSettingsMigrator } from "./engine/db/settingsMigrator.cjs";
|
|
55
|
-
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningAdapter, BundleSigningHandlerOptions, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleSigningHandler, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
|
55
|
+
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningAdapter, BundleSigningHandlerOptions, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, NativeBuildIosScheme, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleSigningHandler, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { createStorageUriWithRelativePath, getManifestAssetDownloadPath, getMani
|
|
|
3
3
|
import { CONTENT_ADDRESSED_ASSET_PREFIX, getContentAddressedAssetStoragePath, isContentAddressedAssetFileHash } from "./contentAddressedAssets.mjs";
|
|
4
4
|
import { getContentType } from "./contentType.mjs";
|
|
5
5
|
import { CatalogVersionBound, CompiledCatalogSegment, CompiledReleaseCatalog, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, canonicalizeAppVersion, compileReleaseCatalog, projectCompiledCatalog, projectCompiledRollbackCatalog, referenceCompatibleReleases } from "./releaseCatalogCompiler.mjs";
|
|
6
|
-
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
|
|
6
|
+
import { BundlePatchRow, BundleRow, ChannelRow, DatabaseBundleMetadata, DatabaseJsonObject, DatabaseJsonValue, NativeBuildArtifactKind, NativeBuildRow, NativeBuildSubmissionDestination, ReleaseCatalogRow, ReleaseRow } from "./types/databaseRows.mjs";
|
|
7
7
|
import { CoreReads, ReleaseCatalogRequest } from "./serverPlugin/coreReads.mjs";
|
|
8
8
|
import { DATABASE_VERSION_COLUMN, DatabaseAdapter, DatabaseJson, DatabaseKey, DatabaseKeyValue, DatabaseSchemaError, DatabaseValue, PhysicalColumn, PhysicalColumnType, PhysicalIndex, PhysicalRetention, PhysicalTable, QueryBound, QueryRequest, StoredRow, WriteGuard, WriteOp, WriteResult, expiresAt, findPhysicalColumn, findPhysicalIndex, indexOrderColumns, rowKey } from "./database/adapter.mjs";
|
|
9
9
|
import { FieldDefinition, FieldReference, FieldType, IndexDefinition, ReferenceAction } from "./serverPlugin/definitions.mjs";
|
|
@@ -17,11 +17,11 @@ import { RetryOptions } from "./engine/database/engineTransaction.mjs";
|
|
|
17
17
|
import { AggregateBatching, ConfiguredDatabase, EngineDatabase, RemoteDatabase, isRemoteDatabase } from "./types/databaseConfig.mjs";
|
|
18
18
|
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./types/utils.mjs";
|
|
19
19
|
import { BundleRowUpdate, ReleaseCatalogRowUpdate, ReleaseRowUpdate } from "./types/databaseOperations.mjs";
|
|
20
|
-
import { ChannelDeleteResult, ChannelInsertResult } from "./types/models.mjs";
|
|
21
|
-
import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, BundleSigningAdapter, ConfigInput, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.mjs";
|
|
20
|
+
import { ChannelDeleteResult, ChannelInsertResult, NativeBuildDeleteResult } from "./types/models.mjs";
|
|
21
|
+
import { ApplePlatform, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, Bundle, BundleSigningAdapter, ConfigInput, FingerprintExtraSources, IosBuildDestination, LocalSigningConfig, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, Platform, PlatformConfig, SecretsAdapter, SecretsContext, SigningConfig, StorageAdapter, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StoragePutInput, StoragePutResult, supportedIosPlatforms } from "./types/index.mjs";
|
|
22
22
|
import { ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, ReleaseCatalogScope } from "./releaseCatalogMutation.mjs";
|
|
23
23
|
import { PromoteReleaseResult, ReleaseManagementError, ReleasePolicyPatch } from "./releaseManagement.mjs";
|
|
24
|
-
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.mjs";
|
|
24
|
+
import { BundleDeployment, BundleDetail, DeployReleasePolicy, Deployment, HotUpdaterCoreApi, KeysetInput, NativeBuildRegistration, NativeBuildScope, ReleaseFilter, ReleaseTarget, StoredBundleDeployment } from "./coreApi.mjs";
|
|
25
25
|
import { DatabaseAdapterInputError, DatabaseAdapterInputErrorCode, DatabaseBundleNotFoundError, DatabaseRowReferencedError } from "./databaseErrors.mjs";
|
|
26
26
|
import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
|
|
27
27
|
import { CreateStorageAdapterOptions, StorageAdapterWith, StorageOperation, assertStorageOperations, createStorageAdapter } from "./createStorageAdapter.mjs";
|
|
@@ -52,4 +52,4 @@ import { EngineSqlOptions, generateEngineSql } from "./engine/db/engineSql.mjs";
|
|
|
52
52
|
import { EngineSqlMigratorOptions, createEngineSqlMigrator } from "./engine/db/engineSqlMigrator.mjs";
|
|
53
53
|
import { writeSchemaSettings } from "./engine/db/schemaSettings.mjs";
|
|
54
54
|
import { createSettingsMigrator } from "./engine/db/settingsMigrator.mjs";
|
|
55
|
-
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningAdapter, BundleSigningHandlerOptions, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleSigningHandler, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
|
55
|
+
export { type AggregateBatching, type AggregateChanges, type AggregateDefinition, type AggregateIdentity, type AggregateRow, type AnyHotUpdaterPlugin, ApplePlatform, BUNDLE_STORAGE_PREFIX, type BaseCandidateQuery, type BaseCandidateTarget, BuildAdapter, BuildAdapterArgs, BuildAdapterConfig, BuiltIns, type Bundle, type BundleDeployment, type BundleDetail, type BundlePatchRow, type BundleRow, BundleRowHydrationError, BundleRowHydrationErrorReason, type BundleRowUpdate, BundleSigningAdapter, BundleSigningHandlerOptions, CONTENT_ADDRESSED_ASSET_PREFIX, CatalogVersionBound, type ChannelDeleteResult, type ChannelInsertResult, type ChannelRow, type ClientAuth, CompiledCatalogSegment, CompiledReleaseCatalog, ConfigInput, type ConfiguredDatabase, type ConstraintReason, type CoreReader, type CoreReads, type CoreSchema, type CreateRow, CreateStorageAdapterOptions, CreateStorageUriInput, DATABASE_VERSION_COLUMN, type DatabaseAdapter, DatabaseAdapterContractError, DatabaseAdapterInputError, type DatabaseAdapterInputErrorCode, DatabaseAmbiguousCommitError, type DatabaseBundleMetadata, DatabaseBundleNotFoundError, DatabaseConflictError, DatabaseConstraintError, DatabaseCursorError, type DatabaseJson, type DatabaseJsonObject, type DatabaseJsonValue, type DatabaseKey, type DatabaseKeyValue, DatabaseQueryError, type DatabaseReadCount, type DatabaseReadMeter, DatabaseRowReferencedError, DatabaseSchemaError, type DatabaseTooling, DatabaseTransactionError, type DatabaseValue, type DeployReleasePolicy, type Deployment, type DerivedDefinition, type DerivedFields, type Engine, type EngineColumns, type EngineDatabase, type EngineDatabaseOptions, type EngineOptions, type EngineReadCount, type EngineSqlMigratorOptions, type EngineSqlOptions, type FieldDefinition, type FieldReference, type FieldType, type FieldValue, type FindAggregatesModel, type FindManyModel, FingerprintExtraSources, HasMultipleCallSignatures, HotUpdaterConfigError, type HotUpdaterCoreApi, type HotUpdaterDatabase, type HotUpdaterPlugin, HotUpdaterSchemaMigrationRequiredError, type HotUpdaterTransaction, type IndexDefinition, IosBuildDestination, type KeyLookup, type KeyValueStore, type KeysetInput, type KvAdapterOptions, type KvCondition, type KvItem, type KvKey, type KvOp, type KvRange, LocalSigningConfig, type Lookup, type MemoryAdapterOptions, type MeteredDatabase, type MigrateOptions, type MigrationResult, type Migrator, type ModelDefinition, type ModuleSchema, NativeBuildAndroidScheme, NativeBuildArgs, type NativeBuildArtifactKind, type NativeBuildDeleteResult, NativeBuildIosScheme, NativeBuildOptions, type NativeBuildRegistration, type NativeBuildRow, type NativeBuildScope, type NativeBuildSubmissionDestination, NativeFingerprint, NativeFingerprintOptions, NativeFingerprintProvider, NativeFingerprintSource, type NormalizeOptions, type Page, ParsedStorageUri, type PhysicalColumn, type PhysicalColumnType, type PhysicalIndex, type PhysicalRetention, type PhysicalTable, type Platform, PlatformConfig, type PluginApis, type PluginCli, type PluginClientCredential, type PluginClientPlugin, type PluginContext, type PluginEndpoint, type PluginEndpointMethod, type PluginInstance, type PluginProvides, type PluginTables, Primitive, PromoteReleaseResult, type QueryBound, type QueryRequest, REMOTE_BUNDLE_SIGNING_ALGORITHM, REMOTE_BUNDLE_SIGNING_PATH, REMOTE_BUNDLE_SIGNING_PROTOCOL_VERSION, REMOTE_BUNDLE_SIGNING_TOKEN_HEADER, type ReadMeasurement, type ReadOptions, type ReadRow, type ReferenceAction, ReleaseCatalogCompilation, ReleaseCatalogCompilationError, ReleaseCatalogCompilerDiagnostics, ReleaseCatalogMutationError, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildPreflight, ReleaseCatalogRebuildResult, type ReleaseCatalogRequest, type ReleaseCatalogRow, type ReleaseCatalogRowUpdate, ReleaseCatalogScope, type ReleaseFilter, ReleaseManagementError, ReleasePolicyPatch, type ReleaseRow, type ReleaseRowUpdate, type ReleaseTarget, type RemoteDatabase, RemoteSigningOptions, RequiredDeep, type ResolvedModel, type ResolvedSchema, type RetentionDefinition, type RetryOptions, type RowOf, SETTINGS_TABLE, type SchemaGenerator, type SchemaSettings, SecretsAdapter, SecretsContext, SigningConfig, type SqlAdapterOptions, type SqlColumnShape, type SqlConnection, type SqlDialect, type SqlExecutor, type SqlResult, type SqlStatement, type SqlTableShape, StorageAdapter, StorageAdapterWith, StorageDeleteInput, StorageDeleteResult, StorageExistsInput, StorageExistsResult, StorageGetDownloadUrlInput, StorageGetDownloadUrlResult, StorageGetInput, StorageGetResult, StorageObject, StorageOperation, StoragePutInput, StoragePutResult, type StoredBundleDeployment, type StoredRow, type TableDefinition, type TableRow, type ToolingDatabase, type ToolingTarget, type UpdateSet, type VerifiedDatabaseAdapter, type VerifyAdapterOptions, WRITE_GUARD_TABLE, type WriteGuard, type WriteOp, type WriteResult, addDistinct, aggregateBatchingTables, assertStorageOperations, bundleToPatchRows, bundleToRow, canonicalizeAppVersion, compareUtf8, compileReleaseCatalog, coreSchema, coreSettings, coreTarget, countDistinct, createBundleSigningHandler, createBundleStorageKey, createEngine, createEngineDatabase, createEngineSqlMigrator, createKvAdapter, createMemoryAdapter, createSettingsMigrator, createSqlAdapter, createStorageAdapter, createStorageKeyBuilder, createStorageRootUriWithPath, createStorageUri, createStorageUriWithRelativePath, createTableStatements, createUUIDv7, createUUIDv7After, createUUIDv7WithSameTimestamp, defineAggregate, definePlugin, defineTable, encodeKvKey, expiresAt, extractTimestampFromUUIDv7, findPhysicalColumn, findPhysicalIndex, generateEngineSql, generateMinBundleId, getBundleArchiveStorageUri, getContentAddressedAssetStoragePath, getContentType, getManifestAssetDownloadPath, getManifestAssetStoragePath, indexOrderColumns, isBrotliManifestAssetPath, isContentAddressedAssetFileHash, isDatabaseBusyError, isDatabaseJsonObject, isDatabaseMetadataObject, isMultiIndex, isRemoteDatabase, isUUIDv7, mergeDistinct, meterReads, migrateCoreSchema, normalizeStoredRow, parseBaseCandidateKey, parseStorageUri, projectCompiledCatalog, projectCompiledRollbackCatalog, quoteSql, referenceCompatibleReleases, releaseRowToRelease, releaseToRow, remoteSigning, replaceStorageUriKeySuffix, resolveManifestAssetStorageFileHash, resolveManifestAssetStorageUri, rowKey, rowToBundle, rowsToBundles, semverSatisfies, sqlTableShapes, supportedIosPlatforms, targetBaseCandidateKey, toolingTargetOf, verifyAdapter, writeSchemaSettings };
|
|
@@ -12,6 +12,23 @@ const REQUEST_TIMEOUT_MS = 3e4;
|
|
|
12
12
|
const JSON_CONTENT_TYPE_PATTERN = /^application\/json(?:\s*;|$)/iu;
|
|
13
13
|
const BASE64_PATTERN = /^(?:[A-Za-z\d+/]{4})*(?:[A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/u;
|
|
14
14
|
const PUBLIC_KEY_PATTERN = /^-----BEGIN PUBLIC KEY-----\s+([A-Za-z\d+/=\s]+)\s+-----END PUBLIC KEY-----$/u;
|
|
15
|
+
/**
|
|
16
|
+
* The name of the errors `remoteSigning` throws with a reason it wrote itself,
|
|
17
|
+
* which never holds the token or what an upstream library threw. The CLI
|
|
18
|
+
* shows these, and redacts any other signing adapter error, by this name.
|
|
19
|
+
*/
|
|
20
|
+
const REMOTE_SIGNING_ERROR_NAME = "HotUpdaterRemoteSigningError";
|
|
21
|
+
const ERROR_RESPONSE_BODY_LIMIT = 4096;
|
|
22
|
+
const ERROR_MESSAGE_LENGTH_LIMIT = 300;
|
|
23
|
+
const MISSING_TOKEN_MESSAGE = "remoteSigning requires signingToken or HOT_UPDATER_SIGNING_TOKEN.";
|
|
24
|
+
/** A failure whose reason is safe to show: it names no secret. */
|
|
25
|
+
var RemoteSigningFailure = class extends Error {};
|
|
26
|
+
const remoteSigningError = (summary, error) => {
|
|
27
|
+
if (!(error instanceof RemoteSigningFailure)) return new Error(summary);
|
|
28
|
+
const named = /* @__PURE__ */ new Error(`${summary} ${error.message}`);
|
|
29
|
+
named.name = REMOTE_SIGNING_ERROR_NAME;
|
|
30
|
+
return named;
|
|
31
|
+
};
|
|
15
32
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
33
|
const hasExactKeys = (value, expected) => {
|
|
17
34
|
const actual = Object.keys(value).sort();
|
|
@@ -69,21 +86,26 @@ const assertSafePath = (path) => {
|
|
|
69
86
|
if (decoded === "." || decoded === ".." || decoded.includes("/") || decoded.includes("\\") || decoded.includes("\0")) throw new Error("invalid path");
|
|
70
87
|
}
|
|
71
88
|
};
|
|
89
|
+
const invalidEndpoint = () => {
|
|
90
|
+
const error = /* @__PURE__ */ new Error("Remote bundle signing requires a valid endpoint.");
|
|
91
|
+
error.name = REMOTE_SIGNING_ERROR_NAME;
|
|
92
|
+
return error;
|
|
93
|
+
};
|
|
72
94
|
const normalizeEndpoint = (endpoint) => {
|
|
73
95
|
let url;
|
|
74
96
|
try {
|
|
75
97
|
url = new URL(endpoint);
|
|
76
98
|
} catch {
|
|
77
|
-
throw
|
|
99
|
+
throw invalidEndpoint();
|
|
78
100
|
}
|
|
79
101
|
const rawPath = /^https?:\/\/[^/?#]*(\/[^?#]*)?/iu.exec(endpoint)?.[1] ?? "/";
|
|
80
102
|
try {
|
|
81
103
|
assertSafePath(rawPath);
|
|
82
104
|
} catch {
|
|
83
|
-
throw
|
|
105
|
+
throw invalidEndpoint();
|
|
84
106
|
}
|
|
85
107
|
const isLoopback = url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]";
|
|
86
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopback) || url.username || url.password || url.search || url.hash) throw
|
|
108
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopback) || url.username || url.password || url.search || url.hash) throw invalidEndpoint();
|
|
87
109
|
const prefix = url.pathname.replace(/\/+$/u, "");
|
|
88
110
|
url.pathname = `${prefix}${REMOTE_BUNDLE_SIGNING_PATH}`;
|
|
89
111
|
return url.href;
|
|
@@ -146,34 +168,67 @@ const parseMetadata = async (value) => {
|
|
|
146
168
|
const remoteRequest = async (fetchImplementation, endpoint, resolveToken, init) => {
|
|
147
169
|
const token = await resolveToken();
|
|
148
170
|
if (typeof token !== "string" || !token.trim()) throw new Error("missing token");
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
let response;
|
|
172
|
+
try {
|
|
173
|
+
response = await fetchImplementation(endpoint, {
|
|
174
|
+
...init,
|
|
175
|
+
headers: {
|
|
176
|
+
Accept: "application/json",
|
|
177
|
+
...init.headers,
|
|
178
|
+
[REMOTE_BUNDLE_SIGNING_TOKEN_HEADER]: token
|
|
179
|
+
},
|
|
180
|
+
redirect: "error",
|
|
181
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
182
|
+
});
|
|
183
|
+
} catch {
|
|
184
|
+
throw new RemoteSigningFailure(`Could not reach ${endpoint}.`);
|
|
185
|
+
}
|
|
186
|
+
if (response.status !== 200) {
|
|
187
|
+
const refusal = await describeRefusal(response, token);
|
|
188
|
+
throw new RemoteSigningFailure(`${endpoint} answered ${refusal}${/[.!?]$/u.test(refusal) ? "" : "."}`);
|
|
189
|
+
}
|
|
160
190
|
return parseJsonBody(response.body, response.headers, RESPONSE_BODY_LIMIT);
|
|
161
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* A refusal's status, with the `{ error }` or `{ error: { code, message } }`
|
|
194
|
+
* a signing server answers it with, such as a scope refusal.
|
|
195
|
+
* The token is masked and the message shortened to one line.
|
|
196
|
+
*/
|
|
197
|
+
const describeRefusal = async (response, token) => {
|
|
198
|
+
let code;
|
|
199
|
+
let message;
|
|
200
|
+
try {
|
|
201
|
+
const body = await parseJsonBody(response.body, response.headers, ERROR_RESPONSE_BODY_LIMIT);
|
|
202
|
+
const error = isRecord(body) ? body.error : void 0;
|
|
203
|
+
if (typeof error === "string") message = error;
|
|
204
|
+
else if (isRecord(error)) {
|
|
205
|
+
code = error.code;
|
|
206
|
+
message = error.message;
|
|
207
|
+
}
|
|
208
|
+
} catch {}
|
|
209
|
+
const status = typeof code === "string" && /^[a-z][a-z0-9_]{0,63}$/u.test(code) ? `${response.status} ${code}` : String(response.status);
|
|
210
|
+
if (typeof message !== "string") return status;
|
|
211
|
+
const text = message.split(token).join("********").replace(/\p{Cc}+/gu, " ").trim();
|
|
212
|
+
if (!text) return status;
|
|
213
|
+
return `${status}: ${text.length > ERROR_MESSAGE_LENGTH_LIMIT ? `${text.slice(0, ERROR_MESSAGE_LENGTH_LIMIT)}…` : text}`;
|
|
214
|
+
};
|
|
162
215
|
/** Signs through a server implementing the Hot Updater signing protocol. */
|
|
163
216
|
const remoteSigning = ({ endpoint, fetch: fetchImplementation = globalThis.fetch, signingToken }) => {
|
|
164
217
|
if (typeof fetchImplementation !== "function") throw new Error("Remote bundle signing requires fetch.");
|
|
165
|
-
|
|
218
|
+
let normalizedEndpoint;
|
|
219
|
+
const endpointUrl = () => normalizedEndpoint ??= normalizeEndpoint(endpoint);
|
|
166
220
|
let resolvedKey;
|
|
167
221
|
const resolveToken = async () => {
|
|
168
222
|
const token = typeof signingToken === "function" ? await signingToken() : signingToken ?? process.env.HOT_UPDATER_SIGNING_TOKEN;
|
|
169
|
-
if (!token?.trim()) throw new
|
|
223
|
+
if (!token?.trim()) throw new RemoteSigningFailure(MISSING_TOKEN_MESSAGE);
|
|
170
224
|
return token;
|
|
171
225
|
};
|
|
172
226
|
const getResolvedKey = () => {
|
|
173
227
|
if (resolvedKey) return resolvedKey;
|
|
174
|
-
|
|
228
|
+
const url = endpointUrl();
|
|
229
|
+
resolvedKey = remoteRequest(fetchImplementation, url, resolveToken, { method: "GET" }).then(parseMetadata).catch((error) => {
|
|
175
230
|
resolvedKey = void 0;
|
|
176
|
-
throw
|
|
231
|
+
throw remoteSigningError("Failed to load the remote bundle signing public key.", error);
|
|
177
232
|
});
|
|
178
233
|
return resolvedKey;
|
|
179
234
|
};
|
|
@@ -188,7 +243,7 @@ const remoteSigning = ({ endpoint, fetch: fetchImplementation = globalThis.fetch
|
|
|
188
243
|
const resolved = await getResolvedKey();
|
|
189
244
|
let value;
|
|
190
245
|
try {
|
|
191
|
-
value = await remoteRequest(fetchImplementation,
|
|
246
|
+
value = await remoteRequest(fetchImplementation, endpointUrl(), resolveToken, {
|
|
192
247
|
body: JSON.stringify({
|
|
193
248
|
algorithm: REMOTE_BUNDLE_SIGNING_ALGORITHM,
|
|
194
249
|
keyId: resolved.keyId,
|
|
@@ -198,8 +253,8 @@ const remoteSigning = ({ endpoint, fetch: fetchImplementation = globalThis.fetch
|
|
|
198
253
|
headers: { "Content-Type": "application/json" },
|
|
199
254
|
method: "POST"
|
|
200
255
|
});
|
|
201
|
-
} catch {
|
|
202
|
-
throw
|
|
256
|
+
} catch (error) {
|
|
257
|
+
throw remoteSigningError("Remote bundle signer failed to sign the message.", error);
|
|
203
258
|
}
|
|
204
259
|
if (!isRecord(value) || !hasExactKeys(value, [
|
|
205
260
|
"algorithm",
|
|
@@ -221,8 +276,9 @@ const jsonResponse = (value, status = 200, headers) => Response.json(value, {
|
|
|
221
276
|
},
|
|
222
277
|
status
|
|
223
278
|
});
|
|
279
|
+
const isTokenSized = (value) => new TextEncoder().encode(value).byteLength <= TOKEN_BYTES_LIMIT;
|
|
224
280
|
const tokensMatch = async (expected, actual) => {
|
|
225
|
-
if (!expected || actual === null ||
|
|
281
|
+
if (!expected || actual === null || !isTokenSized(expected) || !isTokenSized(actual)) return false;
|
|
226
282
|
const [expectedHash, actualHash] = await Promise.all([crypto.subtle.digest("SHA-256", new TextEncoder().encode(expected)), crypto.subtle.digest("SHA-256", new TextEncoder().encode(actual))]);
|
|
227
283
|
const left = new Uint8Array(expectedHash);
|
|
228
284
|
const right = new Uint8Array(actualHash);
|
|
@@ -236,11 +292,18 @@ const createBundleSigningHandler = async ({ endpointPath = REMOTE_BUNDLE_SIGNING
|
|
|
236
292
|
const url = new URL(request.url);
|
|
237
293
|
if (url.pathname !== normalizedEndpointPath) return null;
|
|
238
294
|
if (url.search || url.hash) return jsonResponse({ error: "Bad request" }, 400);
|
|
239
|
-
|
|
295
|
+
const presented = request.headers.get(REMOTE_BUNDLE_SIGNING_TOKEN_HEADER);
|
|
296
|
+
let accepted;
|
|
297
|
+
try {
|
|
298
|
+
accepted = typeof token === "function" ? presented !== null && presented.length > 0 && isTokenSized(presented) && await token(presented) === true : await tokensMatch(token, presented);
|
|
299
|
+
} catch {
|
|
300
|
+
return jsonResponse({ error: "Signing service unavailable" }, 503);
|
|
301
|
+
}
|
|
302
|
+
if (!accepted) return jsonResponse({ error: "Unauthorized" }, 401);
|
|
240
303
|
if (request.method !== "GET" && request.method !== "POST") return jsonResponse({ error: "Method not allowed" }, 405, { Allow: "GET, POST" });
|
|
241
304
|
let resolved;
|
|
242
305
|
try {
|
|
243
|
-
resolved = await canonicalizePublicKey(publicKey);
|
|
306
|
+
resolved = await canonicalizePublicKey(typeof publicKey === "function" ? await publicKey() : publicKey);
|
|
244
307
|
} catch {
|
|
245
308
|
return jsonResponse({ error: "Signing service unavailable" }, 503);
|
|
246
309
|
}
|
|
@@ -17,10 +17,18 @@ interface RemoteSigningOptions {
|
|
|
17
17
|
interface BundleSigningHandlerOptions {
|
|
18
18
|
/** Exact request pathname. Defaults to the root managed signing path. */
|
|
19
19
|
readonly endpointPath?: string;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The SPKI public key in PEM, or a function that returns it, called only
|
|
22
|
+
* once the token is accepted, such as for a key chosen by the token.
|
|
23
|
+
*/
|
|
24
|
+
readonly publicKey: string | (() => string | Promise<string>);
|
|
21
25
|
readonly request: Request;
|
|
22
26
|
readonly sign: (message: Uint8Array) => Uint8Array | Promise<Uint8Array>;
|
|
23
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The dedicated signing token, or a function that accepts or refuses the
|
|
29
|
+
* token a request presents, such as one that looks it up in a store.
|
|
30
|
+
*/
|
|
31
|
+
readonly token: string | ((presented: string) => boolean | Promise<boolean>);
|
|
24
32
|
}
|
|
25
33
|
/** Signs through a server implementing the Hot Updater signing protocol. */
|
|
26
34
|
declare const remoteSigning: ({ endpoint, fetch: fetchImplementation, signingToken }: RemoteSigningOptions) => BundleSigningAdapter;
|