Move bootstrap, default, and inform scripts from inline template strings in lib/init.ts to standalone files under seed/, loaded via an esbuild text-loader plugin. Add type-checking (provisions.d.ts, tsconfig.json) and ESLint config for the seed scripts. Set tsconfig module to Preserve to support import attributes.
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
// Device ID as user name
|
|
const username = declare("DeviceID.ID", { value: 1 }).value[0];
|
|
|
|
// Password will be fixed for a given device because Math.random() is seeded with device ID by default.
|
|
const password = Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER).toString(
|
|
36,
|
|
);
|
|
|
|
const informInterval = 300;
|
|
|
|
// Refresh values daily
|
|
const daily = Date.now(86400000);
|
|
|
|
// Unique inform offset per device for better load distribution
|
|
const informTime = daily % 86400000;
|
|
|
|
declare(
|
|
"InternetGatewayDevice.ManagementServer.ConnectionRequestUsername",
|
|
{ value: daily },
|
|
{ value: username },
|
|
);
|
|
declare(
|
|
"InternetGatewayDevice.ManagementServer.ConnectionRequestPassword",
|
|
{ value: daily },
|
|
{ value: password },
|
|
);
|
|
declare(
|
|
"InternetGatewayDevice.ManagementServer.PeriodicInformEnable",
|
|
{ value: daily },
|
|
{ value: true },
|
|
);
|
|
declare(
|
|
"InternetGatewayDevice.ManagementServer.PeriodicInformInterval",
|
|
{ value: daily },
|
|
{ value: informInterval },
|
|
);
|
|
declare(
|
|
"InternetGatewayDevice.ManagementServer.PeriodicInformTime",
|
|
{ value: daily },
|
|
{ value: informTime },
|
|
);
|
|
|
|
declare(
|
|
"Device.ManagementServer.ConnectionRequestUsername",
|
|
{ value: daily },
|
|
{ value: username },
|
|
);
|
|
declare(
|
|
"Device.ManagementServer.ConnectionRequestPassword",
|
|
{ value: daily },
|
|
{ value: password },
|
|
);
|
|
declare(
|
|
"Device.ManagementServer.PeriodicInformEnable",
|
|
{ value: daily },
|
|
{ value: true },
|
|
);
|
|
declare(
|
|
"Device.ManagementServer.PeriodicInformInterval",
|
|
{ value: daily },
|
|
{ value: informInterval },
|
|
);
|
|
declare(
|
|
"Device.ManagementServer.PeriodicInformTime",
|
|
{ value: daily },
|
|
{ value: informTime },
|
|
);
|