@logto/cli 1.39.0 → 1.40.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/lib/commands/database/seed/index.d.ts +8 -1
- package/lib/commands/database/seed/index.js +15 -4
- package/lib/commands/database/seed/options.d.ts +1 -0
- package/lib/commands/database/seed/options.js +6 -0
- package/lib/commands/database/seed/tables.d.ts +2 -1
- package/lib/commands/database/seed/tables.js +2 -2
- package/lib/commands/install/index.d.ts +2 -0
- package/lib/commands/install/index.js +20 -4
- package/lib/commands/install/utils.d.ts +6 -1
- package/lib/commands/install/utils.js +2 -2
- package/lib/package-json.js +1 -1
- package/package.json +3 -3
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { DatabasePool } from '@silverhand/slonik';
|
|
2
2
|
import type { CommandModule } from 'yargs';
|
|
3
|
-
|
|
3
|
+
type SeedByPoolOptions = {
|
|
4
|
+
cloud?: boolean;
|
|
5
|
+
test?: boolean;
|
|
6
|
+
encryptBaseRole?: boolean;
|
|
7
|
+
disablePwnedPasswordCheck?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const seedByPool: (pool: DatabasePool, { cloud, test, encryptBaseRole, disablePwnedPasswordCheck, }?: SeedByPoolOptions) => Promise<void>;
|
|
4
10
|
declare const seed: CommandModule<Record<string, unknown>, {
|
|
5
11
|
swe?: boolean;
|
|
6
12
|
cloud?: boolean;
|
|
7
13
|
test?: boolean;
|
|
8
14
|
'legacy-test-data'?: boolean;
|
|
9
15
|
'encrypt-base-role'?: boolean;
|
|
16
|
+
dapc?: boolean;
|
|
10
17
|
}>;
|
|
11
18
|
export default seed;
|
|
@@ -3,8 +3,9 @@ import { doesConfigsTableExist } from '../../../queries/logto-config.js';
|
|
|
3
3
|
import { consoleLog, oraPromise } from '../../../utils.js';
|
|
4
4
|
import { getLatestAlterationTimestamp } from '../alteration/index.js';
|
|
5
5
|
import { getAlterationDirectory } from '../alteration/utils.js';
|
|
6
|
+
import { disableAdminPwnedPasswordCheckDescription } from './options.js';
|
|
6
7
|
import { createTables, seedCloud, seedTables, seedTest } from './tables.js';
|
|
7
|
-
export const seedByPool = async (pool, cloud = false, test = false, encryptBaseRole = false) => {
|
|
8
|
+
export const seedByPool = async (pool, { cloud = false, test = false, encryptBaseRole = false, disablePwnedPasswordCheck = false, } = {}) => {
|
|
8
9
|
await pool.transaction(async (connection) => {
|
|
9
10
|
// Check alteration scripts available in order to insert correct timestamp
|
|
10
11
|
const latestTimestamp = await getLatestAlterationTimestamp();
|
|
@@ -18,7 +19,7 @@ export const seedByPool = async (pool, cloud = false, test = false, encryptBaseR
|
|
|
18
19
|
if (tableInfo.password.length > 0) {
|
|
19
20
|
consoleLog.info('base role password:', tableInfo.password);
|
|
20
21
|
}
|
|
21
|
-
await seedTables(connection, latestTimestamp, cloud);
|
|
22
|
+
await seedTables(connection, latestTimestamp, cloud, { disablePwnedPasswordCheck });
|
|
22
23
|
if (cloud) {
|
|
23
24
|
await seedCloud(connection);
|
|
24
25
|
}
|
|
@@ -56,8 +57,13 @@ const seed = {
|
|
|
56
57
|
.option('encrypt-base-role', {
|
|
57
58
|
describe: 'Seed base role with password',
|
|
58
59
|
type: 'boolean',
|
|
60
|
+
})
|
|
61
|
+
.option('dapc', {
|
|
62
|
+
describe: disableAdminPwnedPasswordCheckDescription,
|
|
63
|
+
alias: 'disable-admin-pwned-password-check',
|
|
64
|
+
type: 'boolean',
|
|
59
65
|
}),
|
|
60
|
-
handler: async ({ swe, cloud, test, legacyTestData, encryptBaseRole }) => {
|
|
66
|
+
handler: async ({ swe, cloud, test, legacyTestData, encryptBaseRole, dapc }) => {
|
|
61
67
|
const pool = await createPoolAndDatabaseIfNeeded();
|
|
62
68
|
if (legacyTestData) {
|
|
63
69
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
@@ -74,7 +80,12 @@ const seed = {
|
|
|
74
80
|
return;
|
|
75
81
|
}
|
|
76
82
|
try {
|
|
77
|
-
await seedByPool(pool,
|
|
83
|
+
await seedByPool(pool, {
|
|
84
|
+
cloud,
|
|
85
|
+
test,
|
|
86
|
+
encryptBaseRole,
|
|
87
|
+
disablePwnedPasswordCheck: dapc,
|
|
88
|
+
});
|
|
78
89
|
}
|
|
79
90
|
catch (error) {
|
|
80
91
|
consoleLog.error(error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const disableAdminPwnedPasswordCheckDescription: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const disableAdminPwnedPasswordCheckDescription = "Seed the admin tenant's sign-in experience with the Have I Been Pwned (HIBP) " +
|
|
2
|
+
'password breach check disabled. Use this for air-gapped or offline OSS deployments ' +
|
|
3
|
+
'where api.pwnedpasswords.com is unreachable, otherwise creating the first admin ' +
|
|
4
|
+
'user from the Welcome page will hang on the breach check. Scope: admin tenant only ' +
|
|
5
|
+
"— the default tenant's password policy is unaffected and stays admin-controlled " +
|
|
6
|
+
'via the Admin Console.';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type AdminSignInExperienceSeedOptions } from '@logto/schemas';
|
|
1
2
|
import type { DatabaseTransactionConnection } from '@silverhand/slonik';
|
|
2
3
|
export declare const createTables: (connection: DatabaseTransactionConnection, encryptBaseRole: boolean) => Promise<{
|
|
3
4
|
password: string;
|
|
4
5
|
}>;
|
|
5
|
-
export declare const seedTables: (connection: DatabaseTransactionConnection, latestTimestamp: number, isCloud: boolean) => Promise<void>;
|
|
6
|
+
export declare const seedTables: (connection: DatabaseTransactionConnection, latestTimestamp: number, isCloud: boolean, options?: AdminSignInExperienceSeedOptions) => Promise<void>;
|
|
6
7
|
export declare const seedCloud: (connection: DatabaseTransactionConnection) => Promise<void>;
|
|
7
8
|
/**
|
|
8
9
|
* Seed additional test data for integration or alteration tests.
|
|
@@ -79,7 +79,7 @@ export const createTables = async (connection, encryptBaseRole) => {
|
|
|
79
79
|
await runLifecycleQuery('after_all', { database });
|
|
80
80
|
return { password };
|
|
81
81
|
};
|
|
82
|
-
export const seedTables = async (connection, latestTimestamp, isCloud) => {
|
|
82
|
+
export const seedTables = async (connection, latestTimestamp, isCloud, options = {}) => {
|
|
83
83
|
await createTenant(connection, defaultTenantId);
|
|
84
84
|
await seedOidcConfigs(connection, defaultTenantId);
|
|
85
85
|
await seedAdminData(connection, defaultManagementApi);
|
|
@@ -115,7 +115,7 @@ export const seedTables = async (connection, latestTimestamp, isCloud) => {
|
|
|
115
115
|
connection.query(insertInto(createDefaultIdTokenConfig(defaultTenantId), LogtoConfigs.table)),
|
|
116
116
|
connection.query(insertInto(createDefaultIdTokenConfig(adminTenantId), LogtoConfigs.table)),
|
|
117
117
|
connection.query(insertInto(createDefaultSignInExperience(defaultTenantId, isCloud), SignInExperiences.table)),
|
|
118
|
-
connection.query(insertInto(createAdminTenantSignInExperience(), SignInExperiences.table)),
|
|
118
|
+
connection.query(insertInto(createAdminTenantSignInExperience(options), SignInExperiences.table)),
|
|
119
119
|
connection.query(insertInto(createDefaultAdminConsoleApplication(), Applications.table)),
|
|
120
120
|
connection.query(insertInto(createDefaultAccountCenter(defaultTenantId), AccountCenters.table)),
|
|
121
121
|
connection.query(insertInto(createAdminTenantAccountCenter(), AccountCenters.table)),
|
|
@@ -4,11 +4,13 @@ export type InstallArgs = {
|
|
|
4
4
|
skipSeed: boolean;
|
|
5
5
|
cloud: boolean;
|
|
6
6
|
downloadUrl?: string;
|
|
7
|
+
disableAdminPwnedPasswordCheck?: boolean;
|
|
7
8
|
};
|
|
8
9
|
declare const install: CommandModule<unknown, {
|
|
9
10
|
p?: string;
|
|
10
11
|
ss: boolean;
|
|
11
12
|
cloud: boolean;
|
|
12
13
|
du?: string;
|
|
14
|
+
dapc?: boolean;
|
|
13
15
|
}>;
|
|
14
16
|
export default install;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { getDatabaseUrlFromConfig } from '../../database.js';
|
|
3
3
|
import { consoleLog } from '../../utils.js';
|
|
4
|
+
import { disableAdminPwnedPasswordCheckDescription } from '../database/seed/options.js';
|
|
4
5
|
import { validateNodeVersion, inquireInstallPath, validateDatabase, downloadRelease, seedDatabase, createEnv, logFinale, decompress, isUrl, } from './utils.js';
|
|
5
|
-
const installLogto = async ({ path, skipSeed, downloadUrl, cloud }) => {
|
|
6
|
+
const installLogto = async ({ path, skipSeed, downloadUrl, cloud, disableAdminPwnedPasswordCheck, }) => {
|
|
6
7
|
validateNodeVersion();
|
|
7
8
|
// Get install location path
|
|
8
9
|
const installPath = await inquireInstallPath(path);
|
|
@@ -16,7 +17,10 @@ const installLogto = async ({ path, skipSeed, downloadUrl, cloud }) => {
|
|
|
16
17
|
consoleLog.info(`Skipped database seeding.\n\n' + ' You can use the ${chalk.green('db seed')} command to seed database when ready.\n`);
|
|
17
18
|
}
|
|
18
19
|
else {
|
|
19
|
-
await seedDatabase(installPath,
|
|
20
|
+
await seedDatabase(installPath, {
|
|
21
|
+
cloud,
|
|
22
|
+
disablePwnedPasswordCheck: disableAdminPwnedPasswordCheck,
|
|
23
|
+
});
|
|
20
24
|
}
|
|
21
25
|
// Save to dot env
|
|
22
26
|
await createEnv(installPath, await getDatabaseUrlFromConfig());
|
|
@@ -50,9 +54,21 @@ const install = {
|
|
|
50
54
|
type: 'string',
|
|
51
55
|
hidden: true,
|
|
52
56
|
},
|
|
57
|
+
dapc: {
|
|
58
|
+
describe: disableAdminPwnedPasswordCheckDescription,
|
|
59
|
+
alias: 'disable-admin-pwned-password-check',
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
default: false,
|
|
62
|
+
},
|
|
53
63
|
}),
|
|
54
|
-
handler: async ({ p, ss, cloud, du }) => {
|
|
55
|
-
await installLogto({
|
|
64
|
+
handler: async ({ p, ss, cloud, du, dapc }) => {
|
|
65
|
+
await installLogto({
|
|
66
|
+
path: p,
|
|
67
|
+
skipSeed: ss,
|
|
68
|
+
cloud,
|
|
69
|
+
downloadUrl: du,
|
|
70
|
+
disableAdminPwnedPasswordCheck: dapc,
|
|
71
|
+
});
|
|
56
72
|
},
|
|
57
73
|
};
|
|
58
74
|
export default install;
|
|
@@ -3,7 +3,12 @@ export declare const inquireInstallPath: (initialPath?: string) => Promise<strin
|
|
|
3
3
|
export declare const validateDatabase: () => Promise<void>;
|
|
4
4
|
export declare const downloadRelease: (url?: string) => Promise<string>;
|
|
5
5
|
export declare const decompress: (toPath: string, tarPath: string) => Promise<void>;
|
|
6
|
-
|
|
6
|
+
type SeedDatabaseOptions = {
|
|
7
|
+
cloud: boolean;
|
|
8
|
+
disablePwnedPasswordCheck?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const seedDatabase: (instancePath: string, { cloud, disablePwnedPasswordCheck }: SeedDatabaseOptions) => Promise<void>;
|
|
7
11
|
export declare const createEnv: (installPath: string, databaseUrl: string) => Promise<void>;
|
|
8
12
|
export declare const logFinale: (installPath: string) => void;
|
|
9
13
|
export declare const isUrl: (string: string) => boolean;
|
|
14
|
+
export {};
|
|
@@ -114,10 +114,10 @@ export const decompress = async (toPath, tarPath) => {
|
|
|
114
114
|
text: `Decompress to ${toPath}`,
|
|
115
115
|
}, true);
|
|
116
116
|
};
|
|
117
|
-
export const seedDatabase = async (instancePath, cloud) => {
|
|
117
|
+
export const seedDatabase = async (instancePath, { cloud, disablePwnedPasswordCheck }) => {
|
|
118
118
|
try {
|
|
119
119
|
const pool = await createPoolAndDatabaseIfNeeded();
|
|
120
|
-
await seedByPool(pool, cloud);
|
|
120
|
+
await seedByPool(pool, { cloud, disablePwnedPasswordCheck });
|
|
121
121
|
await pool.end();
|
|
122
122
|
}
|
|
123
123
|
catch (error) {
|
package/lib/package-json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.0",
|
|
4
4
|
"description": "Logto CLI.",
|
|
5
5
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
6
6
|
"homepage": "https://github.com/logto-io/logto#readme",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"tar": "^7.5.7",
|
|
46
46
|
"yargs": "^17.6.0",
|
|
47
47
|
"zod": "3.24.3",
|
|
48
|
-
"@logto/connector-kit": "^5.0.0",
|
|
49
48
|
"@logto/core-kit": "^2.9.0",
|
|
50
|
-
"@logto/schemas": "1.
|
|
49
|
+
"@logto/schemas": "1.40.0",
|
|
50
|
+
"@logto/connector-kit": "^5.0.1",
|
|
51
51
|
"@logto/shared": "^3.4.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|