@ultrst-armada/kloks 1.7.1 → 1.8.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.
@@ -0,0 +1,205 @@
1
+ // src/auth/SessionManager.ts
2
+ var SessionManager = class {
3
+ ttl;
4
+ constructor(ttlMs = 864e5) {
5
+ this.ttl = ttlMs;
6
+ }
7
+ generateToken(userId) {
8
+ return `sess::${userId}::${Date.now()}::${Math.random().toString(36).substring(2, 9)}`;
9
+ }
10
+ createSession(userId, role) {
11
+ return {
12
+ token: this.generateToken(userId),
13
+ userId,
14
+ role,
15
+ expiresAt: Date.now() + this.ttl
16
+ };
17
+ }
18
+ isValid(session) {
19
+ return Date.now() < session.expiresAt;
20
+ }
21
+ };
22
+
23
+ // src/auth/RateLimiter.ts
24
+ var RateLimiter = class {
25
+ attempts = /* @__PURE__ */ new Map();
26
+ windowMs;
27
+ maxUser;
28
+ maxAdmin;
29
+ constructor(windowMs = 9e5, maxUser = 5, maxAdmin = 3) {
30
+ this.windowMs = windowMs;
31
+ this.maxUser = maxUser;
32
+ this.maxAdmin = maxAdmin;
33
+ }
34
+ check(identifier, isAdminAttempt = false) {
35
+ const now = Date.now();
36
+ let record = this.attempts.get(identifier);
37
+ if (!record || now - record.windowStart > this.windowMs) {
38
+ record = { count: 0, windowStart: now };
39
+ this.attempts.set(identifier, record);
40
+ }
41
+ record.count++;
42
+ const limit = isAdminAttempt ? this.maxAdmin : this.maxUser;
43
+ if (record.count > limit) {
44
+ throw new Error("Too many requests. Please try again later.");
45
+ }
46
+ }
47
+ reset(identifier) {
48
+ this.attempts.delete(identifier);
49
+ }
50
+ };
51
+
52
+ // src/auth/CanonicalAuthClient.ts
53
+ var cleanBaseUrl = (value) => value.trim().replace(/\/+$/, "");
54
+ var CanonicalAuthClient = class {
55
+ baseUrl;
56
+ fetcher;
57
+ credentials;
58
+ constructor(options) {
59
+ if (!options.baseUrl?.trim()) throw new Error("Canonical auth base URL is required.");
60
+ this.baseUrl = cleanBaseUrl(options.baseUrl);
61
+ this.fetcher = options.fetcher ?? fetch;
62
+ this.credentials = options.credentials ?? "include";
63
+ }
64
+ async request(path, init = {}) {
65
+ const response = await this.fetcher(`${this.baseUrl}/api/auth${path}`, {
66
+ ...init,
67
+ credentials: this.credentials,
68
+ headers: { "Content-Type": "application/json", ...init.headers ?? {} }
69
+ });
70
+ const text = await response.text();
71
+ let data = {};
72
+ try {
73
+ data = text ? JSON.parse(text) : {};
74
+ } catch {
75
+ data = { message: text };
76
+ }
77
+ return { status: response.status, data };
78
+ }
79
+ async signInEmail(email, password) {
80
+ const result = await this.request("/sign-in/email", {
81
+ method: "POST",
82
+ body: JSON.stringify({ email: email.trim().toLowerCase(), password })
83
+ });
84
+ if (result.status >= 400 || result.data?.error) {
85
+ return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Authentication failed." };
86
+ }
87
+ return { success: true, status: result.status, user: result.data?.user, session: result.data?.session };
88
+ }
89
+ async signUpEmail(email, password, name) {
90
+ const result = await this.request("/sign-up/email", {
91
+ method: "POST",
92
+ body: JSON.stringify({ email: email.trim().toLowerCase(), password, name: name.trim() })
93
+ });
94
+ if (result.status >= 400 || result.data?.error) {
95
+ return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Registration failed." };
96
+ }
97
+ return { success: true, status: result.status, user: result.data?.user, session: result.data?.session };
98
+ }
99
+ async signInGoogle(callbackURL) {
100
+ const result = await this.request("/sign-in/social", {
101
+ method: "POST",
102
+ body: JSON.stringify({ provider: "google", callbackURL })
103
+ });
104
+ if (result.status >= 400 || result.data?.error) {
105
+ return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Google sign-in failed." };
106
+ }
107
+ return {
108
+ success: true,
109
+ status: result.status,
110
+ user: result.data?.user,
111
+ session: result.data?.session,
112
+ redirectUrl: result.data?.url ?? result.data?.redirect
113
+ };
114
+ }
115
+ async requestGoogleDriveAccess(callbackURL) {
116
+ const result = await this.request("/link-social", {
117
+ method: "POST",
118
+ body: JSON.stringify({
119
+ provider: "google",
120
+ scopes: ["https://www.googleapis.com/auth/drive.file"],
121
+ ...callbackURL ? { callbackURL } : {}
122
+ })
123
+ });
124
+ if (result.status >= 400 || result.data?.error) {
125
+ return { success: false, status: result.status, error: result.data?.error?.message ?? result.data?.message ?? "Google Drive authorization failed." };
126
+ }
127
+ return { success: true, status: result.status, user: result.data?.user, session: result.data?.session };
128
+ }
129
+ async getSession(cookie) {
130
+ const headers = {};
131
+ if (cookie) headers.Cookie = cookie;
132
+ const result = await this.request("/get-session", { headers });
133
+ if (result.status >= 400 || !result.data?.user) return null;
134
+ return result.data;
135
+ }
136
+ async signOut() {
137
+ const result = await this.request("/sign-out", { method: "POST", body: "{}" });
138
+ return result.status < 400 && !result.data?.error;
139
+ }
140
+ };
141
+ function createCanonicalAuthClient(baseUrl, fetcher) {
142
+ return new CanonicalAuthClient({ baseUrl, fetcher });
143
+ }
144
+
145
+ // src/auth/UnifiedAuthCore.ts
146
+ function requireAuthBaseUrl(env) {
147
+ const baseUrl = String(env?.SRKL_AUTH_BASE_URL ?? (typeof process !== "undefined" ? process.env.SRKL_AUTH_BASE_URL : "") ?? "").trim();
148
+ if (!baseUrl) {
149
+ throw new Error("SRKL_AUTH_BASE_URL is required. Local application auth is not supported.");
150
+ }
151
+ return baseUrl;
152
+ }
153
+ async function loginSystemUser(email, rawPass, isAdmin, _queryDb, env) {
154
+ if (!email?.trim() || !rawPass) return { success: false, status: 400, error: "Email and password are required" };
155
+ try {
156
+ const client = createCanonicalAuthClient(requireAuthBaseUrl(env));
157
+ const result = await client.signInEmail(email, rawPass);
158
+ if (!result.success || !result.user) {
159
+ return { success: false, status: result.status, error: result.error ?? "Invalid email or password" };
160
+ }
161
+ if (isAdmin && result.user.role !== "admin") {
162
+ return { success: false, status: 403, error: "Insufficient administrative privileges" };
163
+ }
164
+ return {
165
+ success: true,
166
+ status: result.status,
167
+ user: {
168
+ ...result.user,
169
+ username: result.user.username ?? result.user.email.split("@")[0],
170
+ role: result.user.role ?? "user",
171
+ status: result.user.status ?? "ACTIVE"
172
+ },
173
+ token: typeof result.session?.token === "string" ? result.session.token : void 0
174
+ };
175
+ } catch (error) {
176
+ return { success: false, status: 503, error: error instanceof Error ? error.message : "Canonical authentication service unavailable" };
177
+ }
178
+ }
179
+ async function resolveUserFromToken(tokenOrUserId, _queryDb, env) {
180
+ if (!tokenOrUserId) return null;
181
+ try {
182
+ const client = createCanonicalAuthClient(requireAuthBaseUrl(env));
183
+ const session = await client.getSession(
184
+ tokenOrUserId.startsWith("Bearer ") ? `better-auth.session_token=${tokenOrUserId.slice(7).trim()}` : void 0
185
+ );
186
+ if (!session?.user) return null;
187
+ return {
188
+ ...session.user,
189
+ username: session.user.username ?? session.user.email.split("@")[0],
190
+ role: session.user.role ?? "user",
191
+ status: session.user.status ?? "ACTIVE"
192
+ };
193
+ } catch {
194
+ return null;
195
+ }
196
+ }
197
+
198
+ export {
199
+ SessionManager,
200
+ RateLimiter,
201
+ CanonicalAuthClient,
202
+ createCanonicalAuthClient,
203
+ loginSystemUser,
204
+ resolveUserFromToken
205
+ };
@@ -1,10 +1,12 @@
1
1
  import {
2
- BaseStorageAdapter,
3
2
  ensureS3DirectoryMarker,
4
3
  permanentDeleteS3Folder,
5
4
  permanentDeleteS3Object,
6
5
  renameS3Folder
7
- } from "./chunk-R45CEV46.js";
6
+ } from "./chunk-SHZAQTIT.js";
7
+ import {
8
+ BaseStorageAdapter
9
+ } from "./chunk-KKRWZDMN.js";
8
10
 
9
11
  // src/storage/S3Adapter.ts
10
12
  var S3Client;
@@ -1,53 +1,7 @@
1
- // src/storage/BaseStorageAdapter.ts
2
- import { SkipoBase } from "@ultrst-armada/kloks/functions";
3
- var BaseStorageAdapter = class extends SkipoBase {
4
- config;
5
- constructor(config) {
6
- super({ name: "BaseStorageAdapter" });
7
- this.config = config;
8
- }
9
- async deleteFolder(pathStr) {
10
- const items = await this.list(pathStr);
11
- let count = 0;
12
- for (const item of items) {
13
- await this.delete(item.path);
14
- count++;
15
- }
16
- return { success: true, deletedCount: count };
17
- }
18
- async renameFolder(oldPath, newPath) {
19
- const items = await this.list(oldPath);
20
- let count = 0;
21
- for (const item of items) {
22
- const rel = item.path.startsWith(oldPath) ? item.path.slice(oldPath.length).replace(/^\/+/, "") : item.path;
23
- const target = `${newPath.replace(/\/+$/, "")}/${rel}`;
24
- const data = await this.read(item.path);
25
- await this.write(target, data);
26
- await this.delete(item.path);
27
- count++;
28
- }
29
- return { success: true, movedCount: count };
30
- }
31
- async ensureDirectory(pathStr) {
32
- await this.mkdir(pathStr);
33
- }
34
- async testConnection() {
35
- const start = performance.now();
36
- try {
37
- await this.list("");
38
- return { ok: true, latencyMs: Math.round(performance.now() - start) };
39
- } catch (e) {
40
- return { ok: false, latencyMs: Math.round(performance.now() - start), error: e.message };
41
- }
42
- }
43
- normalizePath(p) {
44
- return p.replace(/\\/g, "/").replace(/^\/+/, "");
45
- }
46
- getExtension(p) {
47
- const parts = p.split(".");
48
- return parts.length > 1 ? parts[parts.length - 1] : "";
49
- }
50
- };
1
+ import {
2
+ BaseStorageAdapter,
3
+ GoogleDriveAdapter
4
+ } from "./chunk-KKRWZDMN.js";
51
5
 
52
6
  // src/storage/LocalFSAdapter.ts
53
7
  import { promises as fs } from "fs";
@@ -495,185 +449,6 @@ var BackblazeB2Adapter = class extends BaseStorageAdapter {
495
449
  }
496
450
  };
497
451
 
498
- // src/storage/GoogleDriveOAuth.ts
499
- var AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
500
- var TOKEN_URL = "https://oauth2.googleapis.com/token";
501
- function createGoogleDriveAuthorizationUrl(config, state, codeChallenge) {
502
- const params = new URLSearchParams({
503
- client_id: config.clientId,
504
- redirect_uri: config.redirectUri,
505
- response_type: "code",
506
- access_type: "offline",
507
- prompt: "consent",
508
- scope: (config.scopes || ["https://www.googleapis.com/auth/drive.file"]).join(" "),
509
- state
510
- });
511
- if (codeChallenge) {
512
- params.set("code_challenge", codeChallenge);
513
- params.set("code_challenge_method", "S256");
514
- }
515
- return `${AUTH_URL}?${params.toString()}`;
516
- }
517
- async function exchangeGoogleDriveCode(config, code, codeVerifier) {
518
- const body = new URLSearchParams({
519
- client_id: config.clientId,
520
- redirect_uri: config.redirectUri,
521
- code,
522
- grant_type: "authorization_code"
523
- });
524
- if (config.clientSecret) body.set("client_secret", config.clientSecret);
525
- if (codeVerifier) body.set("code_verifier", codeVerifier);
526
- const response = await fetch(TOKEN_URL, {
527
- method: "POST",
528
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
529
- body
530
- });
531
- if (!response.ok) throw new Error(`Google OAuth token exchange failed: ${response.status}`);
532
- const data = await response.json();
533
- return {
534
- accessToken: data.access_token,
535
- refreshToken: data.refresh_token,
536
- expiresAt: data.expires_in ? Date.now() + Number(data.expires_in) * 1e3 : void 0,
537
- tokenType: data.token_type
538
- };
539
- }
540
- async function refreshGoogleDriveAccessToken(clientId, refreshToken) {
541
- const body = new URLSearchParams({
542
- client_id: clientId,
543
- refresh_token: refreshToken,
544
- grant_type: "refresh_token"
545
- });
546
- const response = await fetch(TOKEN_URL, {
547
- method: "POST",
548
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
549
- body
550
- });
551
- if (!response.ok) throw new Error(`Google OAuth refresh failed: ${response.status}`);
552
- const data = await response.json();
553
- return {
554
- accessToken: data.access_token,
555
- expiresAt: data.expires_in ? Date.now() + Number(data.expires_in) * 1e3 : void 0,
556
- tokenType: data.token_type
557
- };
558
- }
559
-
560
- // src/storage/GoogleDriveAdapter.ts
561
- var GoogleDriveAdapter = class extends BaseStorageAdapter {
562
- async token() {
563
- const accessToken = this.config.googleAccessToken || this.config.accessKey;
564
- const expiresAt = Number(this.config.googleAccessTokenExpiresAt || 0);
565
- if (accessToken && (!expiresAt || expiresAt > Date.now() + 6e4)) return accessToken;
566
- const refreshToken = this.config.googleRefreshToken;
567
- const clientId = this.config.googleClientId;
568
- if (!refreshToken || !clientId) throw new Error("Google Drive OAuth credentials are incomplete.");
569
- const refreshed = await refreshGoogleDriveAccessToken(clientId, refreshToken);
570
- this.config.googleAccessToken = refreshed.accessToken;
571
- this.config.googleAccessTokenExpiresAt = refreshed.expiresAt;
572
- return refreshed.accessToken;
573
- }
574
- async request(url, init = {}) {
575
- const headers = new Headers(init.headers);
576
- headers.set("Authorization", `Bearer ${await this.token()}`);
577
- return fetch(url, { ...init, headers });
578
- }
579
- async findChild(parentId, name) {
580
- const q = `'${parentId}' in parents and name = '${name.replace(/'/g, "\\'")}' and trashed = false`;
581
- const res = await this.request(`https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(q)}&fields=files(id,name,size,modifiedTime,mimeType)&pageSize=10`);
582
- if (!res.ok) throw new Error(`Google Drive lookup failed: ${res.status}`);
583
- const data = await res.json();
584
- return data.files?.[0] || null;
585
- }
586
- async resolveParent(relativeDir, create = false) {
587
- let parent = this.config.googleRootFolderId || this.config.rootFolderId || "root";
588
- for (const part of this.normalizePath(relativeDir).split("/").filter(Boolean)) {
589
- let child = await this.findChild(parent, part);
590
- if (!child && create) {
591
- const res = await this.request("https://www.googleapis.com/drive/v3/files", {
592
- method: "POST",
593
- headers: { "Content-Type": "application/json" },
594
- body: JSON.stringify({ name: part, mimeType: "application/vnd.google-apps.folder", parents: [parent] })
595
- });
596
- if (!res.ok) throw new Error(`Google Drive folder creation failed: ${res.status}`);
597
- child = await res.json();
598
- }
599
- if (!child) throw new Error(`Google Drive directory not found: ${part}`);
600
- parent = child.id;
601
- }
602
- return parent;
603
- }
604
- split(pathStr) {
605
- const key = this.normalizePath(pathStr);
606
- const i = key.lastIndexOf("/");
607
- return i < 0 ? { dir: "", name: key } : { dir: key.slice(0, i), name: key.slice(i + 1) };
608
- }
609
- async read(pathStr) {
610
- const { dir, name } = this.split(pathStr);
611
- const parent = await this.resolveParent(dir);
612
- const file = await this.findChild(parent, name);
613
- if (!file) throw new Error(`Google Drive file not found: ${pathStr}`);
614
- const res = await this.request(`https://www.googleapis.com/drive/v3/files/${file.id}?alt=media`);
615
- if (!res.ok) throw new Error(`Google Drive download failed: ${res.status}`);
616
- return new Uint8Array(await res.arrayBuffer());
617
- }
618
- async write(pathStr, data, contentType = "application/octet-stream") {
619
- const { dir, name } = this.split(pathStr);
620
- const parent = await this.resolveParent(dir, true);
621
- const existing = await this.findChild(parent, name);
622
- const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
623
- const form = new FormData();
624
- form.append("metadata", new Blob([JSON.stringify({ name, mimeType: contentType, ...existing ? {} : { parents: [parent] } })], { type: "application/json" }));
625
- form.append("file", new Blob([bytes], { type: contentType }));
626
- const url = existing ? `https://www.googleapis.com/upload/drive/v3/files/${existing.id}?uploadType=multipart` : "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart";
627
- const res = await this.request(url, { method: existing ? "PATCH" : "POST", body: form });
628
- if (!res.ok) throw new Error(`Google Drive upload failed: ${res.status}`);
629
- }
630
- async delete(pathStr) {
631
- const { dir, name } = this.split(pathStr);
632
- const parent = await this.resolveParent(dir);
633
- const file = await this.findChild(parent, name);
634
- if (!file) return;
635
- const res = await this.request(`https://www.googleapis.com/drive/v3/files/${file.id}`, { method: "DELETE" });
636
- if (!res.ok && res.status !== 404) throw new Error(`Google Drive delete failed: ${res.status}`);
637
- }
638
- async exists(pathStr) {
639
- try {
640
- await this.stat(pathStr);
641
- return true;
642
- } catch {
643
- return false;
644
- }
645
- }
646
- async list(pathStr = "") {
647
- const parent = await this.resolveParent(pathStr);
648
- const q = `'${parent}' in parents and trashed = false`;
649
- const res = await this.request(`https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(q)}&fields=files(id,name,size,modifiedTime,mimeType)&pageSize=1000`);
650
- if (!res.ok) throw new Error(`Google Drive list failed: ${res.status}`);
651
- const data = await res.json();
652
- return (data.files || []).map((f) => ({ path: this.normalizePath(pathStr ? `${pathStr}/${f.name}` : f.name), size: Number(f.size || 0), modifiedAt: f.modifiedTime ? Date.parse(f.modifiedTime) : 0 }));
653
- }
654
- async stat(pathStr) {
655
- const { dir, name } = this.split(pathStr);
656
- const parent = await this.resolveParent(dir);
657
- const file = await this.findChild(parent, name);
658
- if (!file) throw new Error(`Google Drive file not found: ${pathStr}`);
659
- return { path: pathStr, size: Number(file.size || 0), modifiedAt: file.modifiedTime ? Date.parse(file.modifiedTime) : 0 };
660
- }
661
- async mkdir(pathStr) {
662
- await this.resolveParent(pathStr, true);
663
- }
664
- async testConnection() {
665
- const start = performance.now();
666
- try {
667
- const res = await this.request("https://www.googleapis.com/drive/v3/about?fields=user");
668
- if (!res.ok) throw new Error(`Google Drive authorization failed: ${res.status}`);
669
- const data = await res.json();
670
- return { ok: true, latencyMs: Math.round(performance.now() - start), details: { email: data.user?.emailAddress } };
671
- } catch (e) {
672
- return { ok: false, latencyMs: Math.round(performance.now() - start), error: e.message };
673
- }
674
- }
675
- };
676
-
677
452
  // src/storage/SupabaseStorageAdapter.ts
678
453
  var createClient;
679
454
  var SupabaseStorageAdapter = class extends BaseStorageAdapter {
@@ -769,7 +544,6 @@ var StorageAdapterFactory = class {
769
544
  };
770
545
 
771
546
  export {
772
- BaseStorageAdapter,
773
547
  LocalFSAdapter,
774
548
  ensureS3DirectoryMarker,
775
549
  permanentDeleteS3Object,
@@ -779,10 +553,6 @@ export {
779
553
  resolveBackblazeEndpoint,
780
554
  normalizeBackblazeCredentials,
781
555
  BackblazeB2Adapter,
782
- createGoogleDriveAuthorizationUrl,
783
- exchangeGoogleDriveCode,
784
- refreshGoogleDriveAccessToken,
785
- GoogleDriveAdapter,
786
556
  SupabaseStorageAdapter,
787
557
  StorageAdapterFactory
788
558
  };
@@ -1,6 +1,6 @@
1
1
  export { A as AuthCredentials, a as AuthSession, B as BaseAccountProvider, C as CreateUserData, R as RateLimiter, S as SessionManager, b as SignupInput, U as User, c as UserRole } from './BaseAccountProvider-DduKf5HG.js';
2
- export { AdminGuard, LocalAccountProvider, PasswordHasher, SystemUser, loginSystemUser, resolveUserFromToken } from './auth/index.js';
3
- export { B as BaseStorageAdapter, C as ConnectionTestResult, D as DeleteFolderResult, F as FileInfo, R as RenameFolderResult, S as StorageConfig, a as StorageMode, b as StorageProviderType, U as UploadResult } from './BaseStorageAdapter-6x_BQiB3.js';
2
+ export { AdminGuard, AuthEnvironment, AuthResult, CanonicalAuthClient, CanonicalAuthClientOptions, CanonicalAuthSession, CanonicalAuthUser, LocalAccountProvider, PasswordHasher, SystemUser, createCanonicalAuthClient, loginSystemUser, resolveUserFromToken } from './auth/index.js';
3
+ export { B as BaseStorageAdapter, C as ConnectionTestResult, D as DeleteFolderResult, F as FileInfo, R as RenameFolderResult, S as StorageConfig, a as StorageMode, b as StorageProviderType, U as UploadResult } from './BaseStorageAdapter-EUCSvJse.js';
4
4
  export { B2AuthToken, BackblazeB2Adapter, GoogleDriveAdapter, GoogleDriveOAuthConfig, GoogleDriveTokenSet, LocalFSAdapter, S3Adapter, StorageAdapterFactory, SupabaseStorageAdapter, authorizeB2, b2DownloadFile, b2ListBuckets, b2ListFileNames, b2UploadFile, createGoogleDriveAuthorizationUrl, ensureS3DirectoryMarker, exchangeGoogleDriveCode, isSecretMasked, normalizeBackblazeCredentials, permanentDeleteS3Folder, permanentDeleteS3Object, refreshGoogleDriveAccessToken, renameS3Folder, resolveBackblazeEndpoint } from './storage/index.js';
5
5
  export { CloneReplicationResult, ConflictPolicy, RemoteWorkspaceService, SyncEngine, SyncState, WorkingWorkspaceService, WorkspaceCloneSyncEngine, WorkspaceConfig, WorkspaceDescriptor, WorkspaceFS, WorkspaceFileEntry, WorkspaceListResult, WorkspaceLookupResult, WorkspaceMutationResult, WorkspaceSecondaryClone, WorkspaceService, WorkspaceSyncSummary, formatCanonicalWorkspaceFolderName, remoteWorkspaceService, sanitizeWorkspaceName, workingWorkspaceService } from './workspace/index.js';
6
6
  export { AuditEvent, AuditLogger, ClusterConfig, ControlPlaneManager, DatabaseClusterManager, HealthStatus, detectDatabaseEngine, getSystemDatabaseUrls, resolveSystemDatabaseClusterNodes } from './control-plane/index.js';
@@ -228,7 +228,7 @@ interface WorkspaceSyncSummary {
228
228
  workspaceId: string;
229
229
  folderKey: string;
230
230
  workingDir: string;
231
- persistenceType: 'backblaze_b2' | 'local_fs';
231
+ persistenceType: 'backblaze_b2' | 'local_fs' | 'google_drive';
232
232
  targetLocation: string;
233
233
  syncedFiles: SyncFileResult[];
234
234
  uploadedCount: number;
@@ -1,17 +1,3 @@
1
- import {
2
- CompositeBackend,
3
- EndpointGenerator,
4
- LOCAL_STORAGE_GRAPHS_PREFIX,
5
- NodeGraphPersistenceService,
6
- createBackend,
7
- createCompositeService,
8
- createLocalService,
9
- createRemoteService,
10
- exportGraphAsJsonFile,
11
- nodeGraphPersistence,
12
- parseGraphJsonFile,
13
- validateGraphDocument
14
- } from "./chunk-RBF2OGMC.js";
15
1
  import {
16
2
  CANONICAL_SRKL_URL,
17
3
  SrklClient,
@@ -31,8 +17,19 @@ import {
31
17
  useSrklServices
32
18
  } from "./chunk-3IUA66RS.js";
33
19
  import {
34
- S3Adapter
35
- } from "./chunk-JUPWFW7V.js";
20
+ CompositeBackend,
21
+ EndpointGenerator,
22
+ LOCAL_STORAGE_GRAPHS_PREFIX,
23
+ NodeGraphPersistenceService,
24
+ createBackend,
25
+ createCompositeService,
26
+ createLocalService,
27
+ createRemoteService,
28
+ exportGraphAsJsonFile,
29
+ nodeGraphPersistence,
30
+ parseGraphJsonFile,
31
+ validateGraphDocument
32
+ } from "./chunk-RBF2OGMC.js";
36
33
  import {
37
34
  RemoteWorkspaceService,
38
35
  SyncEngine,
@@ -48,7 +45,10 @@ import {
48
45
  setWorkingWorkspaceConfig,
49
46
  syncWorkspace,
50
47
  workingWorkspaceService
51
- } from "./chunk-6W7OAGNV.js";
48
+ } from "./chunk-BTMIK44G.js";
49
+ import {
50
+ S3Adapter
51
+ } from "./chunk-RBQ4CW3T.js";
52
52
  import {
53
53
  AuthServiceDefinition,
54
54
  AuthServiceFacade,
@@ -82,40 +82,15 @@ import {
82
82
  krnlWorkspaceGraphServiceFacade,
83
83
  krnlWorkspaceServiceDefinition,
84
84
  krnlWorkspaceServiceFacade
85
- } from "./chunk-7ZT2ZPPH.js";
86
- import {
87
- workspaceGraphService
88
- } from "./chunk-F6IDQLC2.js";
85
+ } from "./chunk-BPFZCDS4.js";
89
86
  import {
90
87
  getPrimarySrklDeploymentUrl,
91
88
  getSrklAccounts,
92
89
  srklListBackblazeBuckets
93
90
  } from "./chunk-XHADDA75.js";
94
91
  import {
95
- BackblazeB2Adapter,
96
- BaseStorageAdapter,
97
- GoogleDriveAdapter,
98
- LocalFSAdapter,
99
- StorageAdapterFactory,
100
- SupabaseStorageAdapter,
101
- createGoogleDriveAuthorizationUrl,
102
- ensureS3DirectoryMarker,
103
- exchangeGoogleDriveCode,
104
- isSecretMasked,
105
- normalizeBackblazeCredentials,
106
- permanentDeleteS3Folder,
107
- permanentDeleteS3Object,
108
- refreshGoogleDriveAccessToken,
109
- renameS3Folder,
110
- resolveBackblazeEndpoint
111
- } from "./chunk-R45CEV46.js";
112
- import {
113
- authorizeB2,
114
- b2DownloadFile,
115
- b2ListBuckets,
116
- b2ListFileNames,
117
- b2UploadFile
118
- } from "./chunk-4QEMALXF.js";
92
+ workspaceGraphService
93
+ } from "./chunk-5RXXC6GE.js";
119
94
  import {
120
95
  formatCanonicalWorkspaceFolderName,
121
96
  sanitizeWorkspaceName
@@ -150,6 +125,33 @@ import {
150
125
  getUnifiedDbUrl,
151
126
  queryUnifiedDb
152
127
  } from "./chunk-VAFCR2MS.js";
128
+ import {
129
+ authorizeB2,
130
+ b2DownloadFile,
131
+ b2ListBuckets,
132
+ b2ListFileNames,
133
+ b2UploadFile
134
+ } from "./chunk-4QEMALXF.js";
135
+ import {
136
+ BackblazeB2Adapter,
137
+ LocalFSAdapter,
138
+ StorageAdapterFactory,
139
+ SupabaseStorageAdapter,
140
+ ensureS3DirectoryMarker,
141
+ isSecretMasked,
142
+ normalizeBackblazeCredentials,
143
+ permanentDeleteS3Folder,
144
+ permanentDeleteS3Object,
145
+ renameS3Folder,
146
+ resolveBackblazeEndpoint
147
+ } from "./chunk-SHZAQTIT.js";
148
+ import {
149
+ BaseStorageAdapter,
150
+ GoogleDriveAdapter,
151
+ createGoogleDriveAuthorizationUrl,
152
+ exchangeGoogleDriveCode,
153
+ refreshGoogleDriveAccessToken
154
+ } from "./chunk-KKRWZDMN.js";
153
155
  import {
154
156
  BaseApiRoute,
155
157
  createSSEResponse,
@@ -161,13 +163,15 @@ import {
161
163
  BaseAccountProvider,
162
164
  LocalAccountProvider,
163
165
  PasswordHasher
164
- } from "./chunk-MPYASJ5A.js";
166
+ } from "./chunk-HT2SEDHD.js";
165
167
  import {
168
+ CanonicalAuthClient,
166
169
  RateLimiter,
167
170
  SessionManager,
171
+ createCanonicalAuthClient,
168
172
  loginSystemUser,
169
173
  resolveUserFromToken
170
- } from "./chunk-ZDH4XI7W.js";
174
+ } from "./chunk-M4GSR46Y.js";
171
175
  import {
172
176
  BackendProvider,
173
177
  useBackend,
@@ -4210,6 +4214,7 @@ export {
4210
4214
  BaseStorageAdapter,
4211
4215
  CANONICAL_SRKL_URL,
4212
4216
  CallbackRegistry,
4217
+ CanonicalAuthClient,
4213
4218
  CloudflareResourceFetcher,
4214
4219
  CodeDiagnosticsService,
4215
4220
  CodeValidationRuntime,
@@ -4308,6 +4313,7 @@ export {
4308
4313
  createAssetSubfolder,
4309
4314
  createBackend,
4310
4315
  createBackendClient,
4316
+ createCanonicalAuthClient,
4311
4317
  createCompositeService,
4312
4318
  createCredential,
4313
4319
  createEmptyContract,
@@ -31,15 +31,16 @@ import {
31
31
  krnlWorkspaceGraphServiceFacade,
32
32
  krnlWorkspaceServiceDefinition,
33
33
  krnlWorkspaceServiceFacade
34
- } from "./chunk-7ZT2ZPPH.js";
35
- import "./chunk-F6IDQLC2.js";
34
+ } from "./chunk-BPFZCDS4.js";
36
35
  import "./chunk-XHADDA75.js";
37
- import "./chunk-R45CEV46.js";
38
- import "./chunk-4QEMALXF.js";
36
+ import "./chunk-5RXXC6GE.js";
39
37
  import "./chunk-FZKBTF34.js";
40
38
  import "./chunk-6K75XXFD.js";
41
39
  import "./chunk-VAFCR2MS.js";
42
- import "./chunk-ZDH4XI7W.js";
40
+ import "./chunk-4QEMALXF.js";
41
+ import "./chunk-SHZAQTIT.js";
42
+ import "./chunk-KKRWZDMN.js";
43
+ import "./chunk-M4GSR46Y.js";
43
44
  import "./chunk-TY32TUNI.js";
44
45
  export {
45
46
  AuthServiceDefinition,