@absolutejs/auth 0.57.5 → 0.57.7
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/README.md +4 -0
- package/dist/agents/index.js.map +6 -6
- package/dist/cli/migrate.js +21 -11
- package/dist/cli/migrate.js.map +12 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -23
- package/dist/index.js.map +18 -18
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/runner.d.ts +11 -2
- package/dist/oidc/index.js.map +2 -2
- package/dist/server.js +37 -23
- package/dist/server.js.map +19 -19
- package/dist/sso/postgresSsoConnectionStore.d.ts +2 -1
- package/dist/vault/index.js.map +2 -2
- package/package.json +58 -20
package/dist/server.js
CHANGED
|
@@ -36711,13 +36711,16 @@ var toSamlConfig = (value) => {
|
|
|
36711
36711
|
idpX509Cert
|
|
36712
36712
|
};
|
|
36713
36713
|
};
|
|
36714
|
-
var toConnection = (row) => {
|
|
36714
|
+
var toConnection = async (row, cipher) => {
|
|
36715
36715
|
if (row.type === "oidc") {
|
|
36716
36716
|
const config2 = toOidcConfig(row.config);
|
|
36717
36717
|
if (config2 === undefined)
|
|
36718
36718
|
return;
|
|
36719
36719
|
const connection2 = {
|
|
36720
|
-
config:
|
|
36720
|
+
config: {
|
|
36721
|
+
...config2,
|
|
36722
|
+
clientSecret: cipher ? await cipher.decrypt(config2.clientSecret) : config2.clientSecret
|
|
36723
|
+
},
|
|
36721
36724
|
connectionId: row.connection_id,
|
|
36722
36725
|
createdAt: row.created_at_ms,
|
|
36723
36726
|
enabled: row.enabled,
|
|
@@ -36741,8 +36744,11 @@ var toConnection = (row) => {
|
|
|
36741
36744
|
};
|
|
36742
36745
|
return connection;
|
|
36743
36746
|
};
|
|
36744
|
-
var toValues3 = (connection) => ({
|
|
36745
|
-
config: connection.
|
|
36747
|
+
var toValues3 = async (connection, cipher) => ({
|
|
36748
|
+
config: connection.type === "oidc" && cipher ? {
|
|
36749
|
+
...connection.config,
|
|
36750
|
+
clientSecret: await cipher.encrypt(connection.config.clientSecret)
|
|
36751
|
+
} : connection.config,
|
|
36746
36752
|
connection_id: connection.connectionId,
|
|
36747
36753
|
created_at_ms: connection.createdAt,
|
|
36748
36754
|
enabled: connection.enabled,
|
|
@@ -36751,27 +36757,25 @@ var toValues3 = (connection) => ({
|
|
|
36751
36757
|
updated_at_ms: connection.updatedAt
|
|
36752
36758
|
});
|
|
36753
36759
|
var createNeonSsoConnectionStore = (databaseUrl) => createPostgresSsoConnectionStore(createNeonDatabase(databaseUrl));
|
|
36754
|
-
var createPostgresSsoConnectionStore = (db) => ({
|
|
36760
|
+
var createPostgresSsoConnectionStore = (db, cipher) => ({
|
|
36755
36761
|
deleteConnection: async (connectionId) => {
|
|
36756
36762
|
await db.delete(ssoConnectionsTable).where(eq(ssoConnectionsTable.connection_id, connectionId));
|
|
36757
36763
|
},
|
|
36758
36764
|
getConnection: async (connectionId) => {
|
|
36759
36765
|
const [row] = await db.select().from(ssoConnectionsTable).where(eq(ssoConnectionsTable.connection_id, connectionId)).limit(1);
|
|
36760
|
-
return row ? toConnection(row) : undefined;
|
|
36766
|
+
return row ? toConnection(row, cipher) : undefined;
|
|
36761
36767
|
},
|
|
36762
36768
|
getConnectionByOrganization: async (organizationId, type) => {
|
|
36763
36769
|
const [row] = await db.select().from(ssoConnectionsTable).where(and(eq(ssoConnectionsTable.organization_id, organizationId), eq(ssoConnectionsTable.enabled, true), type === undefined ? undefined : eq(ssoConnectionsTable.type, type))).orderBy(desc(ssoConnectionsTable.updated_at_ms)).limit(1);
|
|
36764
|
-
return row ? toConnection(row) : undefined;
|
|
36770
|
+
return row ? toConnection(row, cipher) : undefined;
|
|
36765
36771
|
},
|
|
36766
36772
|
listConnectionsByOrganization: async (organizationId) => {
|
|
36767
36773
|
const rows = await db.select().from(ssoConnectionsTable).where(eq(ssoConnectionsTable.organization_id, organizationId)).orderBy(desc(ssoConnectionsTable.updated_at_ms));
|
|
36768
|
-
|
|
36769
|
-
|
|
36770
|
-
return connection === undefined ? [] : [connection];
|
|
36771
|
-
});
|
|
36774
|
+
const connections = await Promise.all(rows.map((row) => toConnection(row, cipher)));
|
|
36775
|
+
return connections.filter((connection) => connection !== undefined);
|
|
36772
36776
|
},
|
|
36773
36777
|
saveConnection: async (connection) => {
|
|
36774
|
-
const values = toValues3(connection);
|
|
36778
|
+
const values = await toValues3(connection, cipher);
|
|
36775
36779
|
await db.insert(ssoConnectionsTable).values(values).onConflictDoUpdate({
|
|
36776
36780
|
set: values,
|
|
36777
36781
|
target: ssoConnectionsTable.connection_id
|
|
@@ -36944,30 +36948,40 @@ var JOURNAL_DDL = `CREATE TABLE IF NOT EXISTS "auth_migrations" (
|
|
|
36944
36948
|
var isJournalRow = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "id") === "string";
|
|
36945
36949
|
var isBlockName = (value) => Object.hasOwn(blockMigrations, value);
|
|
36946
36950
|
var allBlockNames = () => Object.keys(blockMigrations).filter(isBlockName);
|
|
36947
|
-
var applyOne = async (
|
|
36948
|
-
await
|
|
36949
|
-
await
|
|
36951
|
+
var applyOne = async (client, id, sql2, log) => {
|
|
36952
|
+
await client.query(sql2);
|
|
36953
|
+
await client.query(`INSERT INTO "auth_migrations" ("id", "applied_at_ms") VALUES ($1, $2)`, [id, Date.now()]);
|
|
36950
36954
|
log(`apply ${id}`);
|
|
36951
36955
|
};
|
|
36952
|
-
var runOne = async (
|
|
36956
|
+
var runOne = async (client, id, sql2, applied, result, log) => {
|
|
36953
36957
|
if (applied.has(id)) {
|
|
36954
36958
|
result.skipped.push(id);
|
|
36955
36959
|
log(`skip ${id}`);
|
|
36956
36960
|
return;
|
|
36957
36961
|
}
|
|
36958
|
-
await applyOne(
|
|
36962
|
+
await applyOne(client, id, sql2, log);
|
|
36959
36963
|
result.applied.push(id);
|
|
36960
36964
|
};
|
|
36961
36965
|
var runMigrations = async ({
|
|
36962
36966
|
blocks,
|
|
36967
|
+
client,
|
|
36963
36968
|
databaseUrl,
|
|
36964
36969
|
log = console.log
|
|
36965
36970
|
}) => {
|
|
36966
|
-
|
|
36971
|
+
let ownedPool;
|
|
36972
|
+
let migrationClient;
|
|
36973
|
+
if (client !== undefined) {
|
|
36974
|
+
migrationClient = client;
|
|
36975
|
+
} else {
|
|
36976
|
+
if (databaseUrl === undefined)
|
|
36977
|
+
throw new Error("runMigrations requires databaseUrl or client");
|
|
36978
|
+
ownedPool = new Ln({ connectionString: databaseUrl });
|
|
36979
|
+
migrationClient = ownedPool;
|
|
36980
|
+
}
|
|
36967
36981
|
const result = { applied: [], skipped: [] };
|
|
36968
36982
|
try {
|
|
36969
|
-
await
|
|
36970
|
-
const journal = await
|
|
36983
|
+
await migrationClient.query(JOURNAL_DDL);
|
|
36984
|
+
const journal = await migrationClient.query(`SELECT "id" FROM "auth_migrations"`);
|
|
36971
36985
|
const applied = new Set(journal.rows.filter(isJournalRow).map((row) => row.id));
|
|
36972
36986
|
const selected = blocks ?? allBlockNames();
|
|
36973
36987
|
const flat = selected.flatMap((block) => blockMigrations[block].migrations.map((migration) => ({
|
|
@@ -36976,10 +36990,10 @@ var runMigrations = async ({
|
|
|
36976
36990
|
})));
|
|
36977
36991
|
await flat.reduce(async (prior, item) => {
|
|
36978
36992
|
await prior;
|
|
36979
|
-
return runOne(
|
|
36993
|
+
return runOne(migrationClient, item.id, item.sql, applied, result, log);
|
|
36980
36994
|
}, Promise.resolve());
|
|
36981
36995
|
} finally {
|
|
36982
|
-
await
|
|
36996
|
+
await ownedPool?.end();
|
|
36983
36997
|
}
|
|
36984
36998
|
return result;
|
|
36985
36999
|
};
|
|
@@ -38038,5 +38052,5 @@ export {
|
|
|
38038
38052
|
auth2 as auth
|
|
38039
38053
|
};
|
|
38040
38054
|
|
|
38041
|
-
//# debugId=
|
|
38055
|
+
//# debugId=365532246DA9FA0C64756E2164756E21
|
|
38042
38056
|
//# sourceMappingURL=server.js.map
|