@ultrst-armada/kloks 1.2.1 → 1.3.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.
@@ -96,6 +96,38 @@ interface AdaptedStorageConnection {
96
96
  s3Region?: string;
97
97
  s3Endpoint?: string;
98
98
  }
99
+ interface KeyMaterial {
100
+ secretHex: string;
101
+ cipher: 'aes-256-gcm';
102
+ envelope: 'salt_iv_tag_ciphertext';
103
+ }
104
+ interface SrklVaultAccessResponse {
105
+ success: boolean;
106
+ appId: string;
107
+ workspaceId: string;
108
+ workspaceName: string;
109
+ folderPrefix: string;
110
+ storageProvider: 'backblaze_b2' | 'cloudflare_r2' | 'aws_s3' | string;
111
+ presignedUrl: string;
112
+ keyMaterial: KeyMaterial;
113
+ supportedServices: string[];
114
+ expiresAt: string;
115
+ ttlSeconds: number;
116
+ }
117
+ interface ServiceAccountEntry {
118
+ id: string;
119
+ serviceId: string;
120
+ name: string;
121
+ credentials: Record<string, any>;
122
+ status?: string;
123
+ lastSync?: string;
124
+ metadata?: Record<string, any>;
125
+ createdAt?: string;
126
+ updatedAt?: string;
127
+ }
128
+ interface CredentialRegistryMap {
129
+ [serviceId: string]: ServiceAccountEntry[];
130
+ }
99
131
 
100
132
  /**
101
133
  * @file SrklClient.ts
@@ -188,4 +220,79 @@ interface UseSrklServicesResult {
188
220
  }
189
221
  declare function useSrklServices(options: UseSrklServicesOptions): UseSrklServicesResult;
190
222
 
191
- export { type AdaptedStorageConnection, type AppAccountManifest, type AppServiceDeclaration, CANONICAL_SRKL_URL, type EcosystemAccount, type EcosystemAccountsRequest, type EcosystemAccountsResponse, type EcosystemServiceCategory, SrklClient, type SrklClientOptions, type SrklEcosystemQueryOptions, type SrklEcosystemResponse, type SrklServiceAccount, type UseSrklServicesOptions, type UseSrklServicesResult, createSrklClient, getPrimarySrklDeploymentUrl, getSrklAccounts, srklListBackblazeBuckets, useSrklServices };
223
+ declare function hexToBytes(hex: string): Uint8Array;
224
+ /**
225
+ * Decrypt an AES-256-GCM vault envelope in browser memory using Web Crypto API.
226
+ */
227
+ declare function decryptVaultBufferInBrowser(envelopeBuffer: ArrayBuffer | Uint8Array, secretHex: string): Promise<Uint8Array>;
228
+
229
+ declare class SrklCredentialRegistry {
230
+ private registry;
231
+ constructor();
232
+ /**
233
+ * Populate the in-memory registry directly from an initialized sql.js Database instance.
234
+ * Performs the set intersection: DB.services ∩ DEPM.supported_services.
235
+ */
236
+ populateFromSqlite(db: any, supportedServices: string[]): void;
237
+ /**
238
+ * Register a service account in volatile memory (for manual entry or synced accounts)
239
+ */
240
+ registerServiceAccount(account: ServiceAccountEntry): void;
241
+ getAccountsForService(serviceId: string): ServiceAccountEntry[];
242
+ getPrimaryAccount(serviceId: string): ServiceAccountEntry | null;
243
+ hasCredentials(serviceId: string): boolean;
244
+ listAvailableServices(): string[];
245
+ toMap(): CredentialRegistryMap;
246
+ clear(): void;
247
+ }
248
+ declare const globalCredentialRegistry: SrklCredentialRegistry;
249
+
250
+ interface VaultAccessClientOptions {
251
+ srklApiBaseUrl: string;
252
+ appId: string;
253
+ supportedServices: string[];
254
+ }
255
+ declare class SrklVaultAccessClient {
256
+ private readonly options;
257
+ private registry;
258
+ private activeGrant;
259
+ private sqlEngine;
260
+ constructor(options: VaultAccessClientOptions);
261
+ /**
262
+ * Initialize sql.js engine (WASM).
263
+ * Consumers can pass pre-loaded initSqlJs or let this load from window or CDN.
264
+ */
265
+ initSqlEngine(customInitSqlJs?: any): Promise<any>;
266
+ /**
267
+ * Full pipeline: Authorize → Presigned URL → Direct Download → Decrypt → SQLite Query → Registry.
268
+ */
269
+ loadCredentials(userSessionToken: string, workspaceId?: string, customInitSqlJs?: any): Promise<SrklCredentialRegistry>;
270
+ getRegistry(): SrklCredentialRegistry;
271
+ getActiveGrant(): SrklVaultAccessResponse | null;
272
+ clear(): void;
273
+ }
274
+
275
+ declare function syncSrklAccounts(userId: string, sessionToken: string, srklUrl?: string): Promise<{
276
+ success: boolean;
277
+ accounts?: any[];
278
+ error?: string;
279
+ sourceUrl?: string;
280
+ }>;
281
+
282
+ declare const srklService: {
283
+ name: string;
284
+ description: string;
285
+ runtime: {
286
+ VaultAccessClient: typeof SrklVaultAccessClient;
287
+ CredentialRegistry: typeof SrklCredentialRegistry;
288
+ decryptVaultBufferInBrowser: typeof decryptVaultBufferInBrowser;
289
+ hexToBytes: typeof hexToBytes;
290
+ };
291
+ deployment: {
292
+ target: string;
293
+ supportedEngines: string[];
294
+ version: string;
295
+ };
296
+ };
297
+
298
+ export { type AdaptedStorageConnection, type AppAccountManifest, type AppServiceDeclaration, CANONICAL_SRKL_URL, type CredentialRegistryMap, type EcosystemAccount, type EcosystemAccountsRequest, type EcosystemAccountsResponse, type EcosystemServiceCategory, type KeyMaterial, type ServiceAccountEntry, SrklClient, type SrklClientOptions, SrklCredentialRegistry, type SrklEcosystemQueryOptions, type SrklEcosystemResponse, type SrklServiceAccount, SrklVaultAccessClient, type SrklVaultAccessResponse, type UseSrklServicesOptions, type UseSrklServicesResult, type VaultAccessClientOptions, createSrklClient, decryptVaultBufferInBrowser, getPrimarySrklDeploymentUrl, getSrklAccounts, globalCredentialRegistry, hexToBytes, srklListBackblazeBuckets, srklService, syncSrklAccounts, useSrklServices };
@@ -1,19 +1,33 @@
1
1
  import {
2
2
  CANONICAL_SRKL_URL,
3
3
  SrklClient,
4
+ SrklCredentialRegistry,
5
+ SrklVaultAccessClient,
4
6
  createSrklClient,
7
+ decryptVaultBufferInBrowser,
5
8
  getPrimarySrklDeploymentUrl,
6
9
  getSrklAccounts,
10
+ globalCredentialRegistry,
11
+ hexToBytes,
7
12
  srklListBackblazeBuckets,
13
+ srklService,
14
+ syncSrklAccounts,
8
15
  useSrklServices
9
- } from "../chunk-MN54ZIKZ.js";
16
+ } from "../chunk-KX3OTBQ3.js";
10
17
  import "../chunk-4QEMALXF.js";
11
18
  export {
12
19
  CANONICAL_SRKL_URL,
13
20
  SrklClient,
21
+ SrklCredentialRegistry,
22
+ SrklVaultAccessClient,
14
23
  createSrklClient,
24
+ decryptVaultBufferInBrowser,
15
25
  getPrimarySrklDeploymentUrl,
16
26
  getSrklAccounts,
27
+ globalCredentialRegistry,
28
+ hexToBytes,
17
29
  srklListBackblazeBuckets,
30
+ srklService,
31
+ syncSrklAccounts,
18
32
  useSrklServices
19
33
  };
@@ -13,7 +13,6 @@ import {
13
13
  SkipoExecutionEngine,
14
14
  useCommand
15
15
  } from "./chunk-ZTHBPV24.js";
16
- import "./chunk-RHRXPY2U.js";
17
16
  import {
18
17
  AttractionEngine,
19
18
  GhostInferenceEngine,
@@ -23,12 +22,23 @@ import {
23
22
  getBeamPoints,
24
23
  useMagneticTraces
25
24
  } from "./chunk-JXDJZSFW.js";
25
+ import "./chunk-RHRXPY2U.js";
26
26
  import {
27
27
  ConnectionRuleStore,
28
28
  HandleTypeRegistry,
29
29
  WireTypeRegistry,
30
30
  initializeDefaultGraphRules
31
31
  } from "./chunk-TZOL3RN7.js";
32
+ import "./chunk-Q5I42UX7.js";
33
+ import {
34
+ LifecycleCycleError,
35
+ LifecycleGraph,
36
+ SKIPO_STATE,
37
+ SkipoStateEngine,
38
+ useLifecycleScope,
39
+ useSkipoBind,
40
+ useSkipoState
41
+ } from "./chunk-SHIBCPGQ.js";
32
42
  import {
33
43
  CommandApi,
34
44
  GhostStore,
@@ -56,16 +66,6 @@ import {
56
66
  import {
57
67
  CompatibilityMatrix
58
68
  } from "./chunk-ISFNY7EZ.js";
59
- import "./chunk-Q5I42UX7.js";
60
- import {
61
- LifecycleCycleError,
62
- LifecycleGraph,
63
- SKIPO_STATE,
64
- SkipoStateEngine,
65
- useLifecycleScope,
66
- useSkipoBind,
67
- useSkipoState
68
- } from "./chunk-SHIBCPGQ.js";
69
69
  import "./chunk-3RG5ZIWI.js";
70
70
 
71
71
  // ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.0/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
@@ -1,149 +0,0 @@
1
- import {
2
- createService,
3
- createServiceDefinition,
4
- createServiceProxy
5
- } from "./chunk-IPP4VURQ.js";
6
-
7
- // src/services/ServiceBoundary.ts
8
- function createLocalService(definition) {
9
- return createService(createServiceDefinition(definition));
10
- }
11
- function createRemoteService(definition, adapter, endpoint) {
12
- return createServiceProxy(definition, adapter, endpoint);
13
- }
14
-
15
- // src/services/CompositeBackend.ts
16
- var CompositeBackend = class {
17
- id;
18
- name;
19
- version;
20
- services = /* @__PURE__ */ new Map();
21
- capabilitiesList = [];
22
- constructor(name, version = "1.0.0") {
23
- this.name = name;
24
- this.id = `backend-${name}`;
25
- this.version = version;
26
- }
27
- registerService(service) {
28
- this.services.set(service.name, service);
29
- return this;
30
- }
31
- getService(name) {
32
- return this.services.get(name);
33
- }
34
- getServices() {
35
- return Array.from(this.services.values());
36
- }
37
- registerCapability(capability) {
38
- if (!this.capabilitiesList.includes(capability)) {
39
- this.capabilitiesList.push(capability);
40
- }
41
- return this;
42
- }
43
- async start() {
44
- for (const service of this.services.values()) {
45
- await service.start();
46
- }
47
- }
48
- async stop() {
49
- for (const service of this.services.values()) {
50
- await service.stop();
51
- }
52
- }
53
- async call(op, input, ctx) {
54
- const firstDot = op.indexOf(".");
55
- if (firstDot === -1) {
56
- throw new Error(`[CompositeBackend] Invalid operation '${op}'. Expected 'service.operation'.`);
57
- }
58
- const serviceName = op.slice(0, firstDot);
59
- const operationName = op.slice(firstDot + 1);
60
- const service = this.services.get(serviceName);
61
- if (!service) {
62
- throw new Error(`[CompositeBackend] Service '${serviceName}' not registered in '${this.name}'.`);
63
- }
64
- return await service.call(operationName, input, ctx);
65
- }
66
- getState() {
67
- const aggregated = {};
68
- for (const [name, service] of this.services) {
69
- aggregated[name] = service.getState();
70
- }
71
- return Object.freeze(aggregated);
72
- }
73
- setState(_mutation) {
74
- }
75
- on(event, handler) {
76
- const [serviceName, eventName] = event.split(".");
77
- const service = this.services.get(serviceName);
78
- if (!service) return () => {
79
- };
80
- return service.on(eventName, handler);
81
- }
82
- emit(event, payload) {
83
- const [serviceName, eventName] = event.split(".");
84
- const service = this.services.get(serviceName);
85
- if (service) {
86
- service.emit(eventName, payload);
87
- }
88
- }
89
- getDefinition() {
90
- const ops = {};
91
- for (const service of this.services.values()) {
92
- const def = service.getDefinition();
93
- for (const [opKey, opDef] of Object.entries(def.operations)) {
94
- ops[`${service.name}.${opKey}`] = opDef;
95
- }
96
- }
97
- return {
98
- id: this.id,
99
- name: this.name,
100
- version: this.version,
101
- operations: ops,
102
- capabilities: this.capabilitiesList.map((c) => ({
103
- id: c,
104
- name: c,
105
- protocols: ["http", "ws", "udp", "p2p"]
106
- })),
107
- protocols: ["http", "ws", "udp", "p2p"]
108
- };
109
- }
110
- };
111
-
112
- // src/services/EndpointGenerator.ts
113
- var EndpointGenerator = class {
114
- static generateEndpoints(backend, basePort = 8e3) {
115
- const def = backend.getDefinition();
116
- const ops = Object.keys(def.operations);
117
- return {
118
- httpRoutes: ops.map((op) => `/api/${op.replace(".", "/")}`),
119
- wsChannels: ops.map((op) => `channel:${op}`),
120
- udpEndpoints: [`udp://127.0.0.1:${basePort}`],
121
- p2pBindings: ops.map((op) => `p2p://${backend.name}/${op}`)
122
- };
123
- }
124
- static generateDescriptors(backend, host = "127.0.0.1", port = 8080) {
125
- return [
126
- { protocol: "http", address: host, port, capabilities: ["requestResponse"] },
127
- { protocol: "ws", address: host, port, capabilities: ["requestResponse", "pubSub"] },
128
- { protocol: "udp", address: host, port, capabilities: ["datagram"] },
129
- { protocol: "p2p", address: `p2p://${backend.name}`, capabilities: ["peerToPeer"] }
130
- ];
131
- }
132
- };
133
-
134
- // src/services/ServiceGenerators.ts
135
- function createBackend(name) {
136
- return new CompositeBackend(name);
137
- }
138
- function createCompositeService(name) {
139
- return new CompositeBackend(name);
140
- }
141
-
142
- export {
143
- createLocalService,
144
- createRemoteService,
145
- CompositeBackend,
146
- EndpointGenerator,
147
- createBackend,
148
- createCompositeService
149
- };
@@ -1,3 +1,7 @@
1
+ import {
2
+ createService,
3
+ createServiceDefinition
4
+ } from "./chunk-IPP4VURQ.js";
1
5
  import {
2
6
  StorageAdapterFactory
3
7
  } from "./chunk-J2J24JVC.js";
@@ -13,10 +17,6 @@ import {
13
17
  ExecutableBackendFacade,
14
18
  WorkerExecutionBoundary
15
19
  } from "./chunk-QGHDJGYS.js";
16
- import {
17
- createService,
18
- createServiceDefinition
19
- } from "./chunk-IPP4VURQ.js";
20
20
 
21
21
  // src/krnl-services.ts
22
22
  var AuthServiceDefinition = createServiceDefinition({