@sixb/sqlite 0.1.19 → 0.1.20
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/action-run-storage.d.ts.map +1 -1
- package/dist/agents/agent-storage.d.ts.map +1 -1
- package/dist/ai-limit-storage.d.ts.map +1 -1
- package/dist/ai-usage-storage.d.ts.map +1 -1
- package/dist/auth-storage/auth-storage.d.ts.map +1 -1
- package/dist/auth-storage/magic-links.d.ts.map +1 -1
- package/dist/auth-storage/oidc-attempts.d.ts.map +1 -1
- package/dist/auth-storage/rows.d.ts +0 -3
- package/dist/auth-storage/rows.d.ts.map +1 -1
- package/dist/auth-storage/sessions.d.ts +0 -10
- package/dist/auth-storage/sessions.d.ts.map +1 -1
- package/dist/auth-storage/shared.d.ts +0 -2
- package/dist/auth-storage/shared.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -116
- package/dist/index.js.map +27 -27
- package/dist/migrations.d.ts +2 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/objects/storage.d.ts.map +1 -1
- package/dist/pipeline-run-storage.d.ts.map +1 -1
- package/dist/projection-run-storage.d.ts.map +1 -1
- package/dist/rules-storage.d.ts.map +1 -1
- package/dist/share-grant-storage.d.ts.map +1 -1
- package/dist/share-session-storage.d.ts.map +1 -1
- package/dist/sync-run-storage.d.ts.map +1 -1
- package/dist/timeseries-storage.d.ts.map +1 -1
- package/dist/transactions.d.ts +0 -1
- package/dist/transactions.d.ts.map +1 -1
- package/dist/webhook-run-storage.d.ts.map +1 -1
- package/dist/workflow-intervention-storage.d.ts.map +1 -1
- package/dist/workflow-run-storage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/action-run-storage.ts +0 -5
- package/src/agents/agent-storage.ts +0 -5
- package/src/ai-limit-storage.ts +0 -2
- package/src/ai-usage-storage.ts +0 -4
- package/src/auth-storage/auth-storage.ts +0 -23
- package/src/auth-storage/magic-links.ts +1 -6
- package/src/auth-storage/oidc-attempts.ts +1 -6
- package/src/auth-storage/rows.ts +0 -6
- package/src/auth-storage/sessions.ts +1 -49
- package/src/auth-storage/shared.ts +3 -20
- package/src/index.ts +1 -10
- package/src/migrations/061-drop-auth-audience.sql +16 -0
- package/src/migrations.ts +22 -0
- package/src/objects/storage.ts +0 -5
- package/src/pipeline-run-storage.ts +0 -5
- package/src/projection-run-storage.ts +0 -5
- package/src/rules-storage.ts +0 -5
- package/src/share-grant-storage.ts +0 -2
- package/src/share-session-storage.ts +0 -2
- package/src/sync-run-storage.ts +0 -5
- package/src/timeseries-storage.ts +0 -5
- package/src/transactions.ts +8 -8
- package/src/webhook-run-storage.ts +0 -3
- package/src/workflow-intervention-storage.ts +0 -5
- package/src/workflow-run-storage.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -28,6 +28,11 @@ import { assertActionRunExecution } from "@sixb/core/internal/action-run-storage
|
|
|
28
28
|
import { normalizeRecordActionRunInput, resolveActionRunEffects } from "@sixb/core/internal/storage";
|
|
29
29
|
import { ActionRunError } from "@sixb/core/storage";
|
|
30
30
|
|
|
31
|
+
// src/transactions.ts
|
|
32
|
+
import { Database as SqliteDatabase } from "bun:sqlite";
|
|
33
|
+
import { mkdirSync as mkdirSync2 } from "fs";
|
|
34
|
+
import { dirname as dirname2 } from "path";
|
|
35
|
+
|
|
31
36
|
// src/migrations.ts
|
|
32
37
|
import { Database } from "bun:sqlite";
|
|
33
38
|
import { createHash } from "crypto";
|
|
@@ -5142,6 +5147,25 @@ CREATE INDEX idx_action_runs_project_status_started
|
|
|
5142
5147
|
ON action_runs(project_id, status, started_at DESC);
|
|
5143
5148
|
`;
|
|
5144
5149
|
|
|
5150
|
+
// src/migrations/061-drop-auth-audience.sql
|
|
5151
|
+
var _061_drop_auth_audience_default = `-- A project has one browser app, so sessions, magic links and sign-in attempts no longer name the
|
|
5152
|
+
-- one they belong to. Atlas's browser sessions end here: their cookie is no longer read. Native
|
|
5153
|
+
-- sessions carried Atlas's name only because the column needed a value, so they stay.
|
|
5154
|
+
UPDATE auth_sessions
|
|
5155
|
+
SET revoked_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now')
|
|
5156
|
+
WHERE audience = 'atlas'
|
|
5157
|
+
AND refresh_token_hash IS NULL
|
|
5158
|
+
AND revoked_at IS NULL;
|
|
5159
|
+
|
|
5160
|
+
DROP INDEX idx_auth_sessions_user_active;
|
|
5161
|
+
ALTER TABLE auth_sessions DROP COLUMN audience;
|
|
5162
|
+
CREATE INDEX idx_auth_sessions_user_active
|
|
5163
|
+
ON auth_sessions(project_id, user_id, revoked_at, expires_at);
|
|
5164
|
+
|
|
5165
|
+
ALTER TABLE auth_magic_links DROP COLUMN audience;
|
|
5166
|
+
ALTER TABLE auth_oidc_authorization_attempts DROP COLUMN audience;
|
|
5167
|
+
`;
|
|
5168
|
+
|
|
5145
5169
|
// src/migrations.ts
|
|
5146
5170
|
var MIGRATIONS_TABLE_SQL = `
|
|
5147
5171
|
CREATE TABLE IF NOT EXISTS sixb_migrations (
|
|
@@ -5249,7 +5273,8 @@ var sqliteStorageMigrations = defineMigrations({
|
|
|
5249
5273
|
sqliteSql("057-reranking-model-kind", _057_reranking_model_kind_default),
|
|
5250
5274
|
sqliteSql("058-file-download-grants", _058_file_download_grants_default),
|
|
5251
5275
|
sqliteSql("059-drained-source-versions", _059_drained_source_versions_default),
|
|
5252
|
-
sqliteSql("060-terminal-action-runs", _060_terminal_action_runs_default)
|
|
5276
|
+
sqliteSql("060-terminal-action-runs", _060_terminal_action_runs_default),
|
|
5277
|
+
sqliteSql("061-drop-auth-audience", _061_drop_auth_audience_default)
|
|
5253
5278
|
]
|
|
5254
5279
|
});
|
|
5255
5280
|
function sqliteStoragePath(basePath) {
|
|
@@ -5263,6 +5288,20 @@ function sqliteSql(id, sqlText) {
|
|
|
5263
5288
|
function sqliteStep(id, up, options = {}) {
|
|
5264
5289
|
return step(id, up, options);
|
|
5265
5290
|
}
|
|
5291
|
+
var freshSchema;
|
|
5292
|
+
function freshSqliteDatabase() {
|
|
5293
|
+
if (!freshSchema) {
|
|
5294
|
+
const template = new Database(":memory:");
|
|
5295
|
+
try {
|
|
5296
|
+
template.run("PRAGMA foreign_keys = ON");
|
|
5297
|
+
installFreshSqliteSchema(template);
|
|
5298
|
+
freshSchema = template.serialize();
|
|
5299
|
+
} finally {
|
|
5300
|
+
template.close();
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
return Database.deserialize(freshSchema);
|
|
5304
|
+
}
|
|
5266
5305
|
function installFreshSqliteSchema(db) {
|
|
5267
5306
|
for (const migration of sqliteStorageMigrations.steps) {
|
|
5268
5307
|
const installed = migration.up(db);
|
|
@@ -5480,28 +5519,20 @@ function rollbackQuietly(db) {
|
|
|
5480
5519
|
}
|
|
5481
5520
|
|
|
5482
5521
|
// src/transactions.ts
|
|
5483
|
-
import { Database as SqliteDatabase } from "bun:sqlite";
|
|
5484
|
-
import { mkdirSync as mkdirSync2 } from "fs";
|
|
5485
|
-
import { dirname as dirname2 } from "path";
|
|
5486
5522
|
function openSqliteStoreConnection(options = {}) {
|
|
5487
5523
|
if (options.connection) {
|
|
5488
5524
|
return {
|
|
5489
5525
|
db: options.connection.db,
|
|
5490
|
-
ownsConnection: false
|
|
5491
|
-
installFreshSchema: false
|
|
5526
|
+
ownsConnection: false
|
|
5492
5527
|
};
|
|
5493
5528
|
}
|
|
5494
5529
|
const path = options.path ?? ":memory:";
|
|
5495
5530
|
if (path !== ":memory:" && !options.readonly)
|
|
5496
5531
|
mkdirSync2(dirname2(path), { recursive: true });
|
|
5497
|
-
const db = new SqliteDatabase(path, options.readonly ? { readonly: true } : undefined);
|
|
5532
|
+
const db = path === ":memory:" && !options.readonly ? freshSqliteDatabase() : new SqliteDatabase(path, options.readonly ? { readonly: true } : undefined);
|
|
5498
5533
|
db.run("PRAGMA foreign_keys = ON");
|
|
5499
5534
|
db.run("PRAGMA busy_timeout = 5000");
|
|
5500
|
-
return {
|
|
5501
|
-
db,
|
|
5502
|
-
ownsConnection: true,
|
|
5503
|
-
installFreshSchema: path === ":memory:" && !options.readonly
|
|
5504
|
-
};
|
|
5535
|
+
return { db, ownsConnection: true };
|
|
5505
5536
|
}
|
|
5506
5537
|
function closeSqliteStoreConnection(connection) {
|
|
5507
5538
|
if (connection.ownsConnection) {
|
|
@@ -5582,9 +5613,6 @@ class SqliteActionRunStorage {
|
|
|
5582
5613
|
this.connection = openSqliteStoreConnection(options);
|
|
5583
5614
|
this.db = this.connection.db;
|
|
5584
5615
|
this.executions = options.executions;
|
|
5585
|
-
if (this.connection.installFreshSchema) {
|
|
5586
|
-
installFreshSqliteSchema(this.db);
|
|
5587
|
-
}
|
|
5588
5616
|
}
|
|
5589
5617
|
async record(input) {
|
|
5590
5618
|
const record = normalizeRecordActionRunInput(input);
|
|
@@ -6643,9 +6671,6 @@ class SqliteAgentStorage {
|
|
|
6643
6671
|
connection;
|
|
6644
6672
|
constructor(options) {
|
|
6645
6673
|
this.connection = openSqliteStoreConnection(options);
|
|
6646
|
-
if (this.connection.installFreshSchema) {
|
|
6647
|
-
installFreshSqliteSchema(this.connection.db);
|
|
6648
|
-
}
|
|
6649
6674
|
this.threads = new SqliteAgentThreadStore(this.connection.db);
|
|
6650
6675
|
this.runs = new SqliteAgentRunStore(this.connection.db, options.executions);
|
|
6651
6676
|
this.messages = new SqliteAgentMessageStore(this.connection.db);
|
|
@@ -6777,9 +6802,6 @@ class SqliteAiUsageStorage {
|
|
|
6777
6802
|
connection;
|
|
6778
6803
|
constructor(options = {}) {
|
|
6779
6804
|
this.connection = openSqliteStoreConnection(options);
|
|
6780
|
-
if (this.connection.installFreshSchema) {
|
|
6781
|
-
installFreshSqliteSchema(this.connection.db);
|
|
6782
|
-
}
|
|
6783
6805
|
}
|
|
6784
6806
|
async recordModelCall(input) {
|
|
6785
6807
|
const record = normalizeAiModelCallRecord(input);
|
|
@@ -7511,8 +7533,6 @@ class SqliteAiLimitStorage {
|
|
|
7511
7533
|
connection;
|
|
7512
7534
|
constructor(options = {}) {
|
|
7513
7535
|
this.connection = openSqliteStoreConnection(options);
|
|
7514
|
-
if (this.connection.installFreshSchema)
|
|
7515
|
-
installFreshSqliteSchema(this.connection.db);
|
|
7516
7536
|
}
|
|
7517
7537
|
async createPolicy(input) {
|
|
7518
7538
|
const policy = normalizeCreateAiLimitPolicy(input);
|
|
@@ -8106,7 +8126,6 @@ function rowToSessionRecord(row) {
|
|
|
8106
8126
|
projectId: row.project_id,
|
|
8107
8127
|
userId: row.user_id,
|
|
8108
8128
|
strategyId: row.strategy_id,
|
|
8109
|
-
audience: row.audience,
|
|
8110
8129
|
tokenHash: row.token_hash,
|
|
8111
8130
|
createdAt: new Date(row.created_at),
|
|
8112
8131
|
expiresAt: new Date(row.expires_at),
|
|
@@ -8179,7 +8198,6 @@ function rowToMagicLinkRecord(row) {
|
|
|
8179
8198
|
id: row.id,
|
|
8180
8199
|
projectId: row.project_id,
|
|
8181
8200
|
strategyId: row.strategy_id,
|
|
8182
|
-
audience: row.audience,
|
|
8183
8201
|
email: row.email,
|
|
8184
8202
|
tokenHash: row.token_hash,
|
|
8185
8203
|
returnTo: row.return_to ?? undefined,
|
|
@@ -8194,7 +8212,6 @@ function rowToOidcAuthorizationAttemptRecord(row) {
|
|
|
8194
8212
|
id: row.id,
|
|
8195
8213
|
projectId: row.project_id,
|
|
8196
8214
|
strategyId: row.strategy_id,
|
|
8197
|
-
audience: row.audience,
|
|
8198
8215
|
stateHash: row.state_hash,
|
|
8199
8216
|
nonceHash: row.nonce_hash,
|
|
8200
8217
|
codeVerifier: row.code_verifier,
|
|
@@ -8412,7 +8429,6 @@ function consumeOidcAttempt(db, params) {
|
|
|
8412
8429
|
}
|
|
8413
8430
|
function validateCompleteSessionInput(db, projectId, session) {
|
|
8414
8431
|
const sessionId = assertNonEmpty(session.id, "Session id");
|
|
8415
|
-
assertNonEmpty(session.audience, "Session audience");
|
|
8416
8432
|
assertNonEmpty(session.tokenHash, "Session token hash");
|
|
8417
8433
|
assertSessionIdAvailable(db, projectId, sessionId);
|
|
8418
8434
|
}
|
|
@@ -8426,7 +8442,6 @@ function createSession(db, input) {
|
|
|
8426
8442
|
const projectId = assertNonEmpty(input.projectId, "Project id");
|
|
8427
8443
|
const userId = assertNonEmpty(input.userId, "User id");
|
|
8428
8444
|
const strategyId = assertNonEmpty(input.strategyId, "Strategy id");
|
|
8429
|
-
const audience = assertNonEmpty(input.audience, "Session audience");
|
|
8430
8445
|
const tokenHash = assertNonEmpty(input.tokenHash, "Session token hash");
|
|
8431
8446
|
assertSessionIdAvailable(db, projectId, id);
|
|
8432
8447
|
db.query(`
|
|
@@ -8435,7 +8450,6 @@ function createSession(db, input) {
|
|
|
8435
8450
|
id,
|
|
8436
8451
|
user_id,
|
|
8437
8452
|
strategy_id,
|
|
8438
|
-
audience,
|
|
8439
8453
|
token_hash,
|
|
8440
8454
|
created_at,
|
|
8441
8455
|
expires_at,
|
|
@@ -8445,8 +8459,8 @@ function createSession(db, input) {
|
|
|
8445
8459
|
client_name,
|
|
8446
8460
|
access_expires_at,
|
|
8447
8461
|
refresh_token_hash
|
|
8448
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
8449
|
-
`).run(projectId, id, userId, strategyId,
|
|
8462
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
8463
|
+
`).run(projectId, id, userId, strategyId, tokenHash, toIso(input.createdAt), toIso(input.expiresAt), input.absoluteExpiresAt ? toIso(input.absoluteExpiresAt) : null, input.userAgent ?? null, input.ipAddress ?? null, input.bearer ? assertNonEmpty(input.bearer.clientName, "Session client name") : null, input.bearer ? toIso(input.bearer.accessExpiresAt) : null, input.bearer ? assertNonEmpty(input.bearer.refreshTokenHash, "Refresh token hash") : null);
|
|
8450
8464
|
const session = getSessionById(db, { projectId, id });
|
|
8451
8465
|
if (!session) {
|
|
8452
8466
|
throw new AuthStorageError("missing_session", `[Sixb] Failed to load session '${id}' for project '${projectId}'.`);
|
|
@@ -8455,30 +8469,25 @@ function createSession(db, input) {
|
|
|
8455
8469
|
}
|
|
8456
8470
|
function revokeActiveSessionsForUser(db, params) {
|
|
8457
8471
|
const revokedAt = toIso(params.revokedAt);
|
|
8458
|
-
const audienceCondition = params.audience === undefined ? "" : "AND audience = ?";
|
|
8459
|
-
const selectArgs = params.audience === undefined ? [params.projectId, params.userId, revokedAt, revokedAt] : [params.projectId, params.userId, params.audience, revokedAt, revokedAt];
|
|
8460
|
-
const updateArgs = params.audience === undefined ? [revokedAt, params.projectId, params.userId, revokedAt, revokedAt] : [revokedAt, params.projectId, params.userId, params.audience, revokedAt, revokedAt];
|
|
8461
8472
|
const rows = db.query(`
|
|
8462
8473
|
SELECT *
|
|
8463
8474
|
FROM auth_sessions
|
|
8464
8475
|
WHERE project_id = ?
|
|
8465
8476
|
AND user_id = ?
|
|
8466
|
-
${audienceCondition}
|
|
8467
8477
|
AND revoked_at IS NULL
|
|
8468
8478
|
AND expires_at > ?
|
|
8469
8479
|
AND (absolute_expires_at IS NULL OR absolute_expires_at > ?)
|
|
8470
8480
|
ORDER BY created_at ASC, id ASC
|
|
8471
|
-
`).all(
|
|
8481
|
+
`).all(params.projectId, params.userId, revokedAt, revokedAt);
|
|
8472
8482
|
db.query(`
|
|
8473
8483
|
UPDATE auth_sessions
|
|
8474
8484
|
SET revoked_at = ?
|
|
8475
8485
|
WHERE project_id = ?
|
|
8476
8486
|
AND user_id = ?
|
|
8477
|
-
${audienceCondition}
|
|
8478
8487
|
AND revoked_at IS NULL
|
|
8479
8488
|
AND expires_at > ?
|
|
8480
8489
|
AND (absolute_expires_at IS NULL OR absolute_expires_at > ?)
|
|
8481
|
-
`).run(
|
|
8490
|
+
`).run(revokedAt, params.projectId, params.userId, revokedAt, revokedAt);
|
|
8482
8491
|
return rows.map((row) => rowToSessionRecord({
|
|
8483
8492
|
...row,
|
|
8484
8493
|
revoked_at: revokedAt
|
|
@@ -9056,7 +9065,6 @@ class SqliteAuthInvitationStore {
|
|
|
9056
9065
|
}
|
|
9057
9066
|
|
|
9058
9067
|
// src/auth-storage/magic-links.ts
|
|
9059
|
-
import { resolveAuthSessionAudience } from "@sixb/core";
|
|
9060
9068
|
import { AuthStorageError as AuthStorageError5 } from "@sixb/core/storage";
|
|
9061
9069
|
class SqliteAuthMagicLinkStore {
|
|
9062
9070
|
db;
|
|
@@ -9068,7 +9076,6 @@ class SqliteAuthMagicLinkStore {
|
|
|
9068
9076
|
const id = assertNonEmpty(input.id, "Magic link id");
|
|
9069
9077
|
const projectId = assertNonEmpty(input.projectId, "Project id");
|
|
9070
9078
|
const strategyId = assertNonEmpty(input.strategyId, "Strategy id");
|
|
9071
|
-
const audience = resolveAuthSessionAudience(input.audience);
|
|
9072
9079
|
const email = normalizeEmail(input.email);
|
|
9073
9080
|
const tokenHash = assertNonEmpty(input.tokenHash, "Magic link token hash");
|
|
9074
9081
|
if (getMagicLinkRowById(this.db, { projectId, id })) {
|
|
@@ -9085,14 +9092,13 @@ class SqliteAuthMagicLinkStore {
|
|
|
9085
9092
|
project_id,
|
|
9086
9093
|
id,
|
|
9087
9094
|
strategy_id,
|
|
9088
|
-
audience,
|
|
9089
9095
|
email,
|
|
9090
9096
|
token_hash,
|
|
9091
9097
|
return_to,
|
|
9092
9098
|
created_at,
|
|
9093
9099
|
expires_at
|
|
9094
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?,
|
|
9095
|
-
`).run(projectId, id, strategyId,
|
|
9100
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
9101
|
+
`).run(projectId, id, strategyId, email, tokenHash, input.returnTo ?? null, toIso(input.createdAt), toIso(input.expiresAt));
|
|
9096
9102
|
} catch (error) {
|
|
9097
9103
|
mapUniqueConstraintError(error, "duplicate_magic_link", `[Sixb] Magic link '${id}' already exists for project '${projectId}'.`);
|
|
9098
9104
|
}
|
|
@@ -9100,7 +9106,6 @@ class SqliteAuthMagicLinkStore {
|
|
|
9100
9106
|
id,
|
|
9101
9107
|
projectId,
|
|
9102
9108
|
strategyId,
|
|
9103
|
-
audience,
|
|
9104
9109
|
email,
|
|
9105
9110
|
tokenHash,
|
|
9106
9111
|
returnTo: input.returnTo,
|
|
@@ -9135,7 +9140,6 @@ class SqliteAuthMagicLinkStore {
|
|
|
9135
9140
|
}
|
|
9136
9141
|
|
|
9137
9142
|
// src/auth-storage/oidc-attempts.ts
|
|
9138
|
-
import { resolveAuthSessionAudience as resolveAuthSessionAudience2 } from "@sixb/core";
|
|
9139
9143
|
import { AuthStorageError as AuthStorageError6 } from "@sixb/core/storage";
|
|
9140
9144
|
class SqliteAuthOidcAuthorizationAttemptStore {
|
|
9141
9145
|
db;
|
|
@@ -9147,7 +9151,6 @@ class SqliteAuthOidcAuthorizationAttemptStore {
|
|
|
9147
9151
|
const id = assertNonEmpty(input.id, "OIDC authorization attempt id");
|
|
9148
9152
|
const projectId = assertNonEmpty(input.projectId, "Project id");
|
|
9149
9153
|
const strategyId = assertNonEmpty(input.strategyId, "Strategy id");
|
|
9150
|
-
const audience = resolveAuthSessionAudience2(input.audience);
|
|
9151
9154
|
const stateHash = assertNonEmpty(input.stateHash, "OIDC state hash");
|
|
9152
9155
|
const nonceHash = assertNonEmpty(input.nonceHash, "OIDC nonce hash");
|
|
9153
9156
|
const codeVerifier = assertNonEmpty(input.codeVerifier, "OIDC code verifier");
|
|
@@ -9160,15 +9163,14 @@ class SqliteAuthOidcAuthorizationAttemptStore {
|
|
|
9160
9163
|
project_id,
|
|
9161
9164
|
id,
|
|
9162
9165
|
strategy_id,
|
|
9163
|
-
audience,
|
|
9164
9166
|
state_hash,
|
|
9165
9167
|
nonce_hash,
|
|
9166
9168
|
code_verifier,
|
|
9167
9169
|
return_to,
|
|
9168
9170
|
created_at,
|
|
9169
9171
|
expires_at
|
|
9170
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
|
|
9171
|
-
`).run(projectId, id, strategyId,
|
|
9172
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
9173
|
+
`).run(projectId, id, strategyId, stateHash, nonceHash, codeVerifier, input.returnTo ?? null, toIso(input.createdAt), toIso(input.expiresAt));
|
|
9172
9174
|
} catch (error) {
|
|
9173
9175
|
mapUniqueConstraintError(error, "duplicate_oidc_attempt", `[Sixb] OIDC authorization attempt '${id}' already exists for project '${projectId}'.`);
|
|
9174
9176
|
}
|
|
@@ -9176,7 +9178,6 @@ class SqliteAuthOidcAuthorizationAttemptStore {
|
|
|
9176
9178
|
id,
|
|
9177
9179
|
projectId,
|
|
9178
9180
|
strategyId,
|
|
9179
|
-
audience,
|
|
9180
9181
|
stateHash,
|
|
9181
9182
|
nonceHash,
|
|
9182
9183
|
codeVerifier,
|
|
@@ -9395,21 +9396,6 @@ class SqliteAuthSessionStore {
|
|
|
9395
9396
|
async getById(params) {
|
|
9396
9397
|
return getSessionById(this.db, params);
|
|
9397
9398
|
}
|
|
9398
|
-
async getActiveByUserId(params) {
|
|
9399
|
-
const row = this.db.query(`
|
|
9400
|
-
SELECT *
|
|
9401
|
-
FROM auth_sessions
|
|
9402
|
-
WHERE project_id = ?
|
|
9403
|
-
AND user_id = ?
|
|
9404
|
-
AND audience = ?
|
|
9405
|
-
AND revoked_at IS NULL
|
|
9406
|
-
AND expires_at > ?
|
|
9407
|
-
AND (absolute_expires_at IS NULL OR absolute_expires_at > ?)
|
|
9408
|
-
ORDER BY created_at DESC, id DESC
|
|
9409
|
-
LIMIT 1
|
|
9410
|
-
`).get(params.projectId, params.userId, params.audience, toIso(params.now), toIso(params.now));
|
|
9411
|
-
return row ? rowToSessionRecord(row) : null;
|
|
9412
|
-
}
|
|
9413
9399
|
async listActiveByUserId(params) {
|
|
9414
9400
|
const rows = this.db.query(`
|
|
9415
9401
|
SELECT *
|
|
@@ -9425,7 +9411,7 @@ class SqliteAuthSessionStore {
|
|
|
9425
9411
|
}
|
|
9426
9412
|
async findValidByTokenHash(params) {
|
|
9427
9413
|
const row = getSessionRowById(this.db, params);
|
|
9428
|
-
if (!row || row.refresh_token_hash !== null || row.
|
|
9414
|
+
if (!row || row.refresh_token_hash !== null || row.token_hash !== params.tokenHash || !isLiveSessionRow(row, params.now)) {
|
|
9429
9415
|
return null;
|
|
9430
9416
|
}
|
|
9431
9417
|
return rowToSessionRecord(row);
|
|
@@ -9480,13 +9466,12 @@ class SqliteAuthSessionStore {
|
|
|
9480
9466
|
last_seen_at = ?
|
|
9481
9467
|
WHERE project_id = ?
|
|
9482
9468
|
AND id = ?
|
|
9483
|
-
AND audience = ?
|
|
9484
9469
|
AND token_hash = ?
|
|
9485
9470
|
AND refresh_token_hash IS NULL
|
|
9486
9471
|
AND revoked_at IS NULL
|
|
9487
9472
|
AND expires_at > ?
|
|
9488
9473
|
AND (absolute_expires_at IS NULL OR absolute_expires_at > ?)
|
|
9489
|
-
`).run(expiresAt, expiresAt, now, params.projectId, params.id, params.
|
|
9474
|
+
`).run(expiresAt, expiresAt, now, params.projectId, params.id, params.tokenHash, now, now);
|
|
9490
9475
|
return result.changes === 0 ? null : getSessionById(this.db, params);
|
|
9491
9476
|
});
|
|
9492
9477
|
}
|
|
@@ -9679,9 +9664,6 @@ class SqliteAuthStorage {
|
|
|
9679
9664
|
constructor(options = {}) {
|
|
9680
9665
|
this.connection = openSqliteStoreConnection(options);
|
|
9681
9666
|
this.db = this.connection.db;
|
|
9682
|
-
if (this.connection.installFreshSchema) {
|
|
9683
|
-
installFreshSqliteSchema(this.db);
|
|
9684
|
-
}
|
|
9685
9667
|
this.users = new SqliteAuthUserStore(this.db);
|
|
9686
9668
|
this.identities = new SqliteAuthUserIdentityStore(this.db);
|
|
9687
9669
|
this.serviceAccounts = new SqliteAuthServiceAccountStore(this.db);
|
|
@@ -9760,7 +9742,6 @@ class SqliteAuthStorage {
|
|
|
9760
9742
|
};
|
|
9761
9743
|
}
|
|
9762
9744
|
validateCompleteSessionInput(this.db, projectId, input.session);
|
|
9763
|
-
assertSignInSessionAudience(projectId, input.session.audience, magicLink.audience);
|
|
9764
9745
|
let newUserId;
|
|
9765
9746
|
if (shouldCreateUser) {
|
|
9766
9747
|
newUserId = assertNonEmpty(input.newUserId, "User id");
|
|
@@ -9857,7 +9838,6 @@ class SqliteAuthStorage {
|
|
|
9857
9838
|
};
|
|
9858
9839
|
}
|
|
9859
9840
|
validateCompleteSessionInput(this.db, projectId, input.session);
|
|
9860
|
-
assertSignInSessionAudience(projectId, input.session.audience, attempt.audience);
|
|
9861
9841
|
let newUserId;
|
|
9862
9842
|
if (shouldCreateUser) {
|
|
9863
9843
|
newUserId = assertNonEmpty(input.newUserId, "User id");
|
|
@@ -10076,7 +10056,6 @@ class SqliteAuthStorage {
|
|
|
10076
10056
|
projectId: input.projectId,
|
|
10077
10057
|
userId: input.userId,
|
|
10078
10058
|
strategyId: input.strategyId,
|
|
10079
|
-
audience: input.session.audience,
|
|
10080
10059
|
tokenHash: input.session.tokenHash,
|
|
10081
10060
|
createdAt: input.session.createdAt,
|
|
10082
10061
|
expiresAt: input.session.expiresAt,
|
|
@@ -10121,12 +10100,6 @@ class SqliteAuthStorage {
|
|
|
10121
10100
|
});
|
|
10122
10101
|
}
|
|
10123
10102
|
}
|
|
10124
|
-
function assertSignInSessionAudience(projectId, sessionAudience, storedAudience) {
|
|
10125
|
-
if (sessionAudience === storedAudience) {
|
|
10126
|
-
return;
|
|
10127
|
-
}
|
|
10128
|
-
throw new AuthStorageError11("invalid_input", `[Sixb] Sign-in session audience '${sessionAudience}' does not match stored auth audience '${storedAudience}' for project '${projectId}'.`);
|
|
10129
|
-
}
|
|
10130
10103
|
function assertCompletableDeviceAuthorization(authorization, input) {
|
|
10131
10104
|
if (authorization.deviceCodeHash !== input.deviceCodeHash) {
|
|
10132
10105
|
throw new AuthStorageError11("invalid_device_authorization", "[Sixb] Invalid device authorization.");
|
|
@@ -12785,9 +12758,6 @@ class SqliteObjectStorage {
|
|
|
12785
12758
|
this.connection = openSqliteStoreConnection(options);
|
|
12786
12759
|
this.db = this.connection.db;
|
|
12787
12760
|
this.reader = new SqliteObjectReader(this.db, DEFAULT_OBJECT_QUERY_SOURCE);
|
|
12788
|
-
if (this.connection.installFreshSchema) {
|
|
12789
|
-
installFreshSqliteSchema(this.db);
|
|
12790
|
-
}
|
|
12791
12761
|
}
|
|
12792
12762
|
queryCapabilities() {
|
|
12793
12763
|
return SQLITE_OBJECT_QUERY_CAPABILITIES;
|
|
@@ -16330,9 +16300,6 @@ class SqlitePipelineRunStorage {
|
|
|
16330
16300
|
this.connection = openSqliteStoreConnection(options);
|
|
16331
16301
|
this.db = this.connection.db;
|
|
16332
16302
|
this.executions = options.executions;
|
|
16333
|
-
if (this.connection.installFreshSchema) {
|
|
16334
|
-
installFreshSqliteSchema(this.db);
|
|
16335
|
-
}
|
|
16336
16303
|
}
|
|
16337
16304
|
async queue(input) {
|
|
16338
16305
|
const queuedAt = input.queuedAt ?? new Date;
|
|
@@ -16678,9 +16645,6 @@ class SqliteProjectionRunStorage {
|
|
|
16678
16645
|
this.connection = openSqliteStoreConnection(options);
|
|
16679
16646
|
this.db = this.connection.db;
|
|
16680
16647
|
this.executions = options.executions;
|
|
16681
|
-
if (this.connection.installFreshSchema) {
|
|
16682
|
-
installFreshSqliteSchema(this.db);
|
|
16683
|
-
}
|
|
16684
16648
|
}
|
|
16685
16649
|
async queue(input) {
|
|
16686
16650
|
assertProjectionRunQueueInput(input);
|
|
@@ -17124,9 +17088,6 @@ class SqliteRulesStorage {
|
|
|
17124
17088
|
constructor(options = {}) {
|
|
17125
17089
|
this.connection = openSqliteStoreConnection(options);
|
|
17126
17090
|
this.db = this.connection.db;
|
|
17127
|
-
if (this.connection.installFreshSchema) {
|
|
17128
|
-
installFreshSqliteSchema(this.db);
|
|
17129
|
-
}
|
|
17130
17091
|
}
|
|
17131
17092
|
async getActive(params) {
|
|
17132
17093
|
const row = this.db.query(`
|
|
@@ -17372,8 +17333,6 @@ class SqliteShareGrantStorage {
|
|
|
17372
17333
|
constructor(options = {}) {
|
|
17373
17334
|
this.connection = openSqliteStoreConnection(options);
|
|
17374
17335
|
this.db = this.connection.db;
|
|
17375
|
-
if (this.connection.installFreshSchema)
|
|
17376
|
-
installFreshSqliteSchema(this.db);
|
|
17377
17336
|
}
|
|
17378
17337
|
async create(input) {
|
|
17379
17338
|
const record = normalizeShareGrantCreate(input);
|
|
@@ -17518,8 +17477,6 @@ class SqliteShareSessionStorage {
|
|
|
17518
17477
|
constructor(options = {}) {
|
|
17519
17478
|
this.connection = openSqliteStoreConnection(options);
|
|
17520
17479
|
this.db = this.connection.db;
|
|
17521
|
-
if (this.connection.installFreshSchema)
|
|
17522
|
-
installFreshSqliteSchema(this.db);
|
|
17523
17480
|
}
|
|
17524
17481
|
async create(input) {
|
|
17525
17482
|
const record = normalizeShareSessionCreate(input);
|
|
@@ -17622,9 +17579,6 @@ class SqliteSyncRunStorage {
|
|
|
17622
17579
|
this.connection = openSqliteStoreConnection(options);
|
|
17623
17580
|
this.db = this.connection.db;
|
|
17624
17581
|
this.executions = options.executions;
|
|
17625
|
-
if (this.connection.installFreshSchema) {
|
|
17626
|
-
installFreshSqliteSchema(this.db);
|
|
17627
|
-
}
|
|
17628
17582
|
}
|
|
17629
17583
|
async queue(input) {
|
|
17630
17584
|
const queuedAt = input.queuedAt ?? new Date;
|
|
@@ -17834,9 +17788,6 @@ class SqliteTimeseriesStorage {
|
|
|
17834
17788
|
constructor(options = {}) {
|
|
17835
17789
|
this.connection = openSqliteStoreConnection(options);
|
|
17836
17790
|
this.db = this.connection.db;
|
|
17837
|
-
if (this.connection.installFreshSchema) {
|
|
17838
|
-
installFreshSqliteSchema(this.db);
|
|
17839
|
-
}
|
|
17840
17791
|
}
|
|
17841
17792
|
async getHistory(params) {
|
|
17842
17793
|
let query = `
|
|
@@ -17963,8 +17914,6 @@ class SqliteWebhookRunStorage {
|
|
|
17963
17914
|
this.connection = openSqliteStoreConnection(options);
|
|
17964
17915
|
this.db = this.connection.db;
|
|
17965
17916
|
this.executions = options.executions;
|
|
17966
|
-
if (this.connection.installFreshSchema)
|
|
17967
|
-
installFreshSqliteSchema(this.db);
|
|
17968
17917
|
}
|
|
17969
17918
|
async start(input) {
|
|
17970
17919
|
const startedAt = input.startedAt ?? new Date;
|
|
@@ -18110,9 +18059,6 @@ class SqliteWorkflowInterventionStorage {
|
|
|
18110
18059
|
constructor(options = {}) {
|
|
18111
18060
|
this.connection = openSqliteStoreConnection(options);
|
|
18112
18061
|
this.db = this.connection.db;
|
|
18113
|
-
if (this.connection.installFreshSchema) {
|
|
18114
|
-
installFreshSqliteSchema(this.db);
|
|
18115
|
-
}
|
|
18116
18062
|
}
|
|
18117
18063
|
async create(input) {
|
|
18118
18064
|
assertNonNegativeInteger(input.nodeIndex, "nodeIndex");
|
|
@@ -18347,9 +18293,6 @@ class SqliteWorkflowRunStorage {
|
|
|
18347
18293
|
this.connection = openSqliteStoreConnection(options);
|
|
18348
18294
|
this.db = this.connection.db;
|
|
18349
18295
|
this.executions = options.executions;
|
|
18350
|
-
if (this.connection.installFreshSchema) {
|
|
18351
|
-
installFreshSqliteSchema(this.db);
|
|
18352
|
-
}
|
|
18353
18296
|
this.nodes = new SqliteWorkflowNodeRunStorage(this.db);
|
|
18354
18297
|
this.agentNodes = new SqliteWorkflowAgentNodeRunStorage(this.db, this.executions);
|
|
18355
18298
|
}
|
|
@@ -18995,9 +18938,6 @@ class SqliteStorage {
|
|
|
18995
18938
|
} else {
|
|
18996
18939
|
this.readConnection = this.connection;
|
|
18997
18940
|
}
|
|
18998
|
-
if (this.connection.installFreshSchema) {
|
|
18999
|
-
installFreshSqliteSchema(this.connection.db);
|
|
19000
|
-
}
|
|
19001
18941
|
const stores = createSqliteStores(this.connection, {
|
|
19002
18942
|
runOntologyOperation: async (run) => run(),
|
|
19003
18943
|
transactionContext: null
|
|
@@ -19090,8 +19030,7 @@ class SqliteStorage {
|
|
|
19090
19030
|
return {
|
|
19091
19031
|
...createSqliteStores({
|
|
19092
19032
|
db: this.connection.db,
|
|
19093
|
-
ownsConnection: false
|
|
19094
|
-
installFreshSchema: false
|
|
19033
|
+
ownsConnection: false
|
|
19095
19034
|
}, {
|
|
19096
19035
|
runOntologyOperation: async (run) => run(),
|
|
19097
19036
|
transactionContext
|
|
@@ -19170,4 +19109,4 @@ export {
|
|
|
19170
19109
|
migrateSqliteStorage
|
|
19171
19110
|
};
|
|
19172
19111
|
|
|
19173
|
-
//# debugId=
|
|
19112
|
+
//# debugId=7AEE546F2916C86164756E2164756E21
|