@dbx-tools/core-rs 0.6.188

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,2794 @@
1
+ // GENERATED by UniFFI binding generation - DO NOT EDIT.
2
+ // Regenerated from the dbx-tools-core Rust exports.
3
+ // Hand edits are overwritten on the next watch; this file is read-only.
4
+
5
+ /* eslint-disable */
6
+ // @ts-nocheck
7
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
8
+ // Trust me, you don't want to mess with it!
9
+ import nativeModule from "./_bindings-ffi.ts";
10
+ import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiForeignFutureResultRustBuffer, type UniffiForeignFutureCompleterustBuffer, type UniffiForeignFutureResultVoid, type UniffiForeignFutureCompletevoid, type UniffiVTableCallbackInterfaceDbxToolsCoreStorageAdapter,
11
+ } from "./_bindings-ffi.ts";
12
+ import { type FfiConverter, type UniffiByteArray, type UniffiGcObject, type UniffiHandle, type UniffiObjectFactory, type UniffiReferenceHolder, type UniffiRustCallStatus, AbstractFfiConverterByteArray, Cursor, FfiConverterArray, FfiConverterBool, FfiConverterInt64, FfiConverterMap, FfiConverterObject, FfiConverterObjectWithCallbacks, FfiConverterOptional, FfiConverterUInt16, FfiConverterUInt64, FfiConverterUInt8, RustBuffer, UniffiAbstractObject, UniffiEnum, UniffiError, UniffiInternalError, UniffiResult, UniffiRustCaller, destructorGuardSymbol, pointerLiteralSymbol, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiRustCallAsync, uniffiTraitInterfaceCall, uniffiTraitInterfaceCallAsyncWithError, uniffiTypeNameSymbol, variantOrdinalSymbol,
13
+ } from "@ubjs/core";
14
+ const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
15
+
16
+ const uniffiIsDebug =
17
+ // @ts-ignore -- The process global might not be defined
18
+ typeof process !== "object" ||
19
+ // @ts-ignore -- The process global might not be defined
20
+ process?.env?.NODE_ENV !== "production" ||
21
+ false;
22
+
23
+ // Public interface members begin here.
24
+
25
+ /**
26
+ * Trim, sort, and deduplicate scopes for requests and credential identities.
27
+ */
28
+ export function canonicalScopes(scopes: Array<string>): Array<string> {
29
+ const __rb: Uint8Array = uniffiCaller.rustCall(
30
+ /*caller:*/ (callStatus) => {
31
+ return nativeModule().uniffi_dbx_tools_core_fn_func_canonical_scopes(
32
+ FfiConverterSequenceString.lower(scopes, nativeModule().rustbuffer_alloc),
33
+ callStatus);
34
+ },
35
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
36
+ );
37
+ try {
38
+ return FfiConverterSequenceString.lift(__rb);
39
+ } finally {
40
+ nativeModule().rustbuffer_free(__rb);
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Resolve a Databricks profile and open built-in credential storage.
46
+ */
47
+ export async function createPersistentAuth(options: DatabricksAuthOptions, storage: Storage | undefined = undefined, asyncOpts_?: { signal: AbortSignal }): Promise<PersistentAuthLike> /*throws*/ {
48
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
49
+ try {
50
+ return await uniffiRustCallAsync(
51
+ /*rustCaller:*/ uniffiCaller,
52
+ /*rustFutureFunc:*/ () => {
53
+ return nativeModule().uniffi_dbx_tools_core_fn_func_create_persistent_auth(FfiConverterTypeDatabricksAuthOptions.lower(options, nativeModule().rustbuffer_alloc),FfiConverterOptionalTypeStorage.lower(storage, nativeModule().rustbuffer_alloc)
54
+ );
55
+ },
56
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_u64,
57
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_u64,
58
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_u64,
59
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_u64,
60
+ // Async returns always go through the JS-side converter: the
61
+ // FFI symbol returns the future handle (u64), and the user-level
62
+ // RustBuffer comes back via the shared `rust_future_complete_*`
63
+ // export. The bytes the runtime hands back must be deserialized
64
+ // here using the per-callable return-type converter.
65
+ /*liftFunc:*/ FfiConverterTypePersistentAuth.lift.bind(FfiConverterTypePersistentAuth),
66
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
67
+ /*asyncOpts:*/ asyncOpts_,
68
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
69
+ );
70
+ } catch (__error: any) {
71
+ if (uniffiIsDebug && __error instanceof Error) {
72
+ __error.stack = __stack;
73
+ }
74
+ throw __error;
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Resolve a Databricks profile using a shared owning-library storage handle.
80
+ */
81
+ export async function createPersistentAuthWithStorage(options: DatabricksAuthOptions, storage: StorageHandleLike, asyncOpts_?: { signal: AbortSignal }): Promise<PersistentAuthLike> /*throws*/ {
82
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
83
+ try {
84
+ return await uniffiRustCallAsync(
85
+ /*rustCaller:*/ uniffiCaller,
86
+ /*rustFutureFunc:*/ () => {
87
+ return nativeModule().uniffi_dbx_tools_core_fn_func_create_persistent_auth_with_storage(FfiConverterTypeDatabricksAuthOptions.lower(options, nativeModule().rustbuffer_alloc),FfiConverterTypeStorageHandle.lower(storage, nativeModule().rustbuffer_alloc)
88
+ );
89
+ },
90
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_u64,
91
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_u64,
92
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_u64,
93
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_u64,
94
+ // Async returns always go through the JS-side converter: the
95
+ // FFI symbol returns the future handle (u64), and the user-level
96
+ // RustBuffer comes back via the shared `rust_future_complete_*`
97
+ // export. The bytes the runtime hands back must be deserialized
98
+ // here using the per-callable return-type converter.
99
+ /*liftFunc:*/ FfiConverterTypePersistentAuth.lift.bind(FfiConverterTypePersistentAuth),
100
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
101
+ /*asyncOpts:*/ asyncOpts_,
102
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
103
+ );
104
+ } catch (__error: any) {
105
+ if (uniffiIsDebug && __error instanceof Error) {
106
+ __error.stack = __stack;
107
+ }
108
+ throw __error;
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Construct a provider with built-in persistent storage and shared lifecycle defaults.
114
+ */
115
+ export async function createProviderAuth(options: ProviderOptions, asyncOpts_?: { signal: AbortSignal }): Promise<ProviderAuthLike> /*throws*/ {
116
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
117
+ try {
118
+ return await uniffiRustCallAsync(
119
+ /*rustCaller:*/ uniffiCaller,
120
+ /*rustFutureFunc:*/ () => {
121
+ return nativeModule().uniffi_dbx_tools_core_fn_func_create_provider_auth(FfiConverterTypeProviderOptions.lower(options, nativeModule().rustbuffer_alloc)
122
+ );
123
+ },
124
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_u64,
125
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_u64,
126
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_u64,
127
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_u64,
128
+ // Async returns always go through the JS-side converter: the
129
+ // FFI symbol returns the future handle (u64), and the user-level
130
+ // RustBuffer comes back via the shared `rust_future_complete_*`
131
+ // export. The bytes the runtime hands back must be deserialized
132
+ // here using the per-callable return-type converter.
133
+ /*liftFunc:*/ FfiConverterTypeProviderAuth.lift.bind(FfiConverterTypeProviderAuth),
134
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
135
+ /*asyncOpts:*/ asyncOpts_,
136
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
137
+ );
138
+ } catch (__error: any) {
139
+ if (uniffiIsDebug && __error instanceof Error) {
140
+ __error.stack = __stack;
141
+ }
142
+ throw __error;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Construct a provider from the same owning-library storage handle used by Databricks auth.
148
+ */
149
+ export async function createProviderAuthWithStorage(options: ProviderOptions, storage: StorageHandleLike, asyncOpts_?: { signal: AbortSignal }): Promise<ProviderAuthLike> /*throws*/ {
150
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
151
+ try {
152
+ return await uniffiRustCallAsync(
153
+ /*rustCaller:*/ uniffiCaller,
154
+ /*rustFutureFunc:*/ () => {
155
+ return nativeModule().uniffi_dbx_tools_core_fn_func_create_provider_auth_with_storage(FfiConverterTypeProviderOptions.lower(options, nativeModule().rustbuffer_alloc),FfiConverterTypeStorageHandle.lower(storage, nativeModule().rustbuffer_alloc)
156
+ );
157
+ },
158
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_u64,
159
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_u64,
160
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_u64,
161
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_u64,
162
+ // Async returns always go through the JS-side converter: the
163
+ // FFI symbol returns the future handle (u64), and the user-level
164
+ // RustBuffer comes back via the shared `rust_future_complete_*`
165
+ // export. The bytes the runtime hands back must be deserialized
166
+ // here using the per-callable return-type converter.
167
+ /*liftFunc:*/ FfiConverterTypeProviderAuth.lift.bind(FfiConverterTypeProviderAuth),
168
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
169
+ /*asyncOpts:*/ asyncOpts_,
170
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
171
+ );
172
+ } catch (__error: any) {
173
+ if (uniffiIsDebug && __error instanceof Error) {
174
+ __error.stack = __stack;
175
+ }
176
+ throw __error;
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Wrap custom storage before passing it into another provider's native library.
182
+ */
183
+ export function createStorageHandle(storage: StorageAdapter): StorageHandleLike {
184
+ return FfiConverterTypeStorageHandle.lift(uniffiCaller.rustCall(
185
+ /*caller:*/ (callStatus) => {
186
+ return nativeModule().uniffi_dbx_tools_core_fn_func_create_storage_handle(
187
+ FfiConverterTypeStorageAdapter.lower(storage, nativeModule().rustbuffer_alloc),
188
+ callStatus);
189
+ },
190
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
191
+ ));
192
+ }
193
+
194
+ /**
195
+ * Derive a stable provider/profile/scope-set identity without storing raw scopes in the key.
196
+ */
197
+ export function credentialKey(provider: string, profile: string | undefined, scopes: Array<string>): string {
198
+ const __rb: Uint8Array = uniffiCaller.rustCall(
199
+ /*caller:*/ (callStatus) => {
200
+ return nativeModule().uniffi_dbx_tools_core_fn_func_credential_key(
201
+ FfiConverterString.lower(provider, nativeModule().rustbuffer_alloc),
202
+ FfiConverterOptionalString.lower(profile, nativeModule().rustbuffer_alloc),
203
+ FfiConverterSequenceString.lower(scopes, nativeModule().rustbuffer_alloc),
204
+ callStatus);
205
+ },
206
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
207
+ );
208
+ try {
209
+ return FfiConverterString.lift(__rb);
210
+ } finally {
211
+ nativeModule().rustbuffer_free(__rb);
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Whether `databricks auth --help` succeeds in this process environment.
217
+ */
218
+ export function databricksCliAvailable(): boolean {
219
+ return FfiConverterBool.lift(uniffiCaller.rustCall(
220
+ /*caller:*/ (callStatus) => {
221
+ return nativeModule().uniffi_dbx_tools_core_fn_func_databricks_cli_available(
222
+ callStatus);
223
+ },
224
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
225
+ ));
226
+ }
227
+
228
+ /**
229
+ * Detect whether the current process is running as a Databricks App.
230
+ */
231
+ export function isDatabricksApp(): boolean {
232
+ return FfiConverterBool.lift(uniffiCaller.rustCall(
233
+ /*caller:*/ (callStatus) => {
234
+ return nativeModule().uniffi_dbx_tools_core_fn_func_is_databricks_app(
235
+ callStatus);
236
+ },
237
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
238
+ ));
239
+ }
240
+
241
+ /**
242
+ * Parse a PostgreSQL URL, Lakebase resource path, hostname, or project id.
243
+ */
244
+ export function parseAddress(input: string | undefined): ParsedAddress {
245
+ const __rb: Uint8Array = uniffiCaller.rustCall(
246
+ /*caller:*/ (callStatus) => {
247
+ return nativeModule().uniffi_dbx_tools_core_fn_func_parse_address(
248
+ FfiConverterOptionalString.lower(input, nativeModule().rustbuffer_alloc),
249
+ callStatus);
250
+ },
251
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
252
+ );
253
+ try {
254
+ return FfiConverterTypeParsedAddress.lift(__rb);
255
+ } finally {
256
+ nativeModule().rustbuffer_free(__rb);
257
+ }
258
+ }
259
+
260
+ /**
261
+ * Parse a canonical Lakebase `projects/...` resource path.
262
+ */
263
+ export function parseResourcePath(input: string | undefined): ParsedAddress {
264
+ const __rb: Uint8Array = uniffiCaller.rustCall(
265
+ /*caller:*/ (callStatus) => {
266
+ return nativeModule().uniffi_dbx_tools_core_fn_func_parse_resource_path(
267
+ FfiConverterOptionalString.lower(input, nativeModule().rustbuffer_alloc),
268
+ callStatus);
269
+ },
270
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
271
+ );
272
+ try {
273
+ return FfiConverterTypeParsedAddress.lift(__rb);
274
+ } finally {
275
+ nativeModule().rustbuffer_free(__rb);
276
+ }
277
+ }
278
+
279
+ const stringConverter = (() => {
280
+ const encoder = new TextEncoder();
281
+ const decoder = new TextDecoder();
282
+ return {
283
+ stringToBytes: (s: string) => encoder.encode(s),
284
+ bytesToString: (ab: UniffiByteArray) => decoder.decode(ab),
285
+ stringByteLength: (s: string) => encoder.encode(s).byteLength,
286
+ writeStringIntoBuffer: (s: string, buf: any, offset: number): number => {
287
+ const view = new Uint8Array(
288
+ buf.arrayBuffer,
289
+ offset,
290
+ buf.arrayBuffer.byteLength - offset,
291
+ );
292
+ return encoder.encodeInto(s, view).written;
293
+ },
294
+ readStringFromBuffer: (buf: any, offset: number, length: number): string =>
295
+ decoder.decode(new Uint8Array(buf.arrayBuffer, offset, length)),
296
+ };
297
+ })();
298
+ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
299
+
300
+ /**
301
+ * Public credential result; deliberately excludes the refresh token.
302
+ */
303
+ export type AccessToken = {
304
+ /**
305
+ * Access token secret presented to protected resources.
306
+ */
307
+ accessToken: string,
308
+ /**
309
+ * OAuth token type returned by the provider.
310
+ */
311
+ tokenType: string,
312
+ /**
313
+ * Formatted absolute expiry, when known.
314
+ */
315
+ expiry?: string,
316
+ /**
317
+ * Scopes granted to the credential.
318
+ */
319
+ scopes: Array<string>
320
+ }
321
+
322
+ /**
323
+ * Generated factory for {@link AccessToken} record objects.
324
+ */
325
+ export const AccessToken = (() => {
326
+ const defaults = () => ({
327
+ });
328
+ const create = (() => {
329
+ return uniffiCreateRecord<AccessToken, ReturnType<typeof defaults>>(defaults);
330
+ })();
331
+ return Object.freeze({
332
+ create,
333
+ new: create,
334
+ defaults: () => Object.freeze(defaults()) as Partial<AccessToken>,
335
+ });
336
+ })();
337
+
338
+ const FfiConverterTypeAccessToken = (() => {
339
+ type TypeName = AccessToken;
340
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
341
+ readFromCursor(c: Cursor): TypeName {
342
+ return {
343
+ accessToken: FfiConverterString.readFromCursor(c),
344
+ tokenType: FfiConverterString.readFromCursor(c),
345
+ expiry: FfiConverterOptionalString.readFromCursor(c),
346
+ scopes: FfiConverterSequenceString.readFromCursor(c)
347
+ };
348
+ }
349
+ writeIntoCursor(value: TypeName, c: Cursor): void {
350
+ FfiConverterString.writeIntoCursor(value.accessToken, c);
351
+ FfiConverterString.writeIntoCursor(value.tokenType, c);
352
+ FfiConverterOptionalString.writeIntoCursor(value.expiry, c);
353
+ FfiConverterSequenceString.writeIntoCursor(value.scopes, c);
354
+ }
355
+ allocationSize(value: TypeName): number {
356
+ return FfiConverterString.allocationSize(value.accessToken) +
357
+ FfiConverterString.allocationSize(value.tokenType) +
358
+ FfiConverterOptionalString.allocationSize(value.expiry) +
359
+ FfiConverterSequenceString.allocationSize(value.scopes);
360
+
361
+ }
362
+ };
363
+ return new FFIConverter();
364
+ })();
365
+
366
+ /**
367
+ * Shared lifecycle configuration embedded by every provider's binding options.
368
+ */
369
+ export type AuthOptions = {
370
+ /**
371
+ * Renew credentials this many seconds before expiry; negative values are allowed.
372
+ */
373
+ refreshBufferSeconds: bigint,
374
+ /**
375
+ * Maximum time spent waiting for the credential store's refresh lock.
376
+ */
377
+ lockTimeoutSeconds: bigint,
378
+ /**
379
+ * Maximum time allowed for a new interactive login.
380
+ */
381
+ loginTimeoutSeconds: bigint,
382
+ /**
383
+ * Logo URL or data URI displayed by the browser callback page.
384
+ */
385
+ callbackImageSrc?: string
386
+ }
387
+
388
+ /**
389
+ * Generated factory for {@link AuthOptions} record objects.
390
+ */
391
+ export const AuthOptions = (() => {
392
+ const defaults = () => ({
393
+ refreshBufferSeconds: BigInt("300"),
394
+ lockTimeoutSeconds: BigInt("30"),
395
+ loginTimeoutSeconds: BigInt("3600"),
396
+ callbackImageSrc: undefined
397
+ });
398
+ const create = (() => {
399
+ return uniffiCreateRecord<AuthOptions, ReturnType<typeof defaults>>(defaults);
400
+ })();
401
+ return Object.freeze({
402
+ create,
403
+ new: create,
404
+ defaults: () => Object.freeze(defaults()) as Partial<AuthOptions>,
405
+ });
406
+ })();
407
+
408
+ const FfiConverterTypeAuthOptions = (() => {
409
+ type TypeName = AuthOptions;
410
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
411
+ readFromCursor(c: Cursor): TypeName {
412
+ return {
413
+ refreshBufferSeconds: FfiConverterInt64.readFromCursor(c),
414
+ lockTimeoutSeconds: FfiConverterUInt64.readFromCursor(c),
415
+ loginTimeoutSeconds: FfiConverterUInt64.readFromCursor(c),
416
+ callbackImageSrc: FfiConverterOptionalString.readFromCursor(c)
417
+ };
418
+ }
419
+ writeIntoCursor(value: TypeName, c: Cursor): void {
420
+ FfiConverterInt64.writeIntoCursor(value.refreshBufferSeconds, c);
421
+ FfiConverterUInt64.writeIntoCursor(value.lockTimeoutSeconds, c);
422
+ FfiConverterUInt64.writeIntoCursor(value.loginTimeoutSeconds, c);
423
+ FfiConverterOptionalString.writeIntoCursor(value.callbackImageSrc, c);
424
+ }
425
+ allocationSize(value: TypeName): number {
426
+ return FfiConverterInt64.allocationSize(value.refreshBufferSeconds) +
427
+ FfiConverterUInt64.allocationSize(value.lockTimeoutSeconds) +
428
+ FfiConverterUInt64.allocationSize(value.loginTimeoutSeconds) +
429
+ FfiConverterOptionalString.allocationSize(value.callbackImageSrc);
430
+
431
+ }
432
+ };
433
+ return new FFIConverter();
434
+ })();
435
+
436
+ /**
437
+ * Configuration shared by the generated Node and Python auth bindings.
438
+ */
439
+ export type DatabricksAuthOptions = {
440
+ /**
441
+ * Explicit profile name; explicit choices are never remapped to another profile.
442
+ */
443
+ profile?: string,
444
+ /**
445
+ * Override the workspace or account host.
446
+ */
447
+ host?: string,
448
+ /**
449
+ * Account identifier for account-scoped authentication.
450
+ */
451
+ accountId?: string,
452
+ /**
453
+ * Workspace identifier for unified authentication.
454
+ */
455
+ workspaceId?: string,
456
+ /**
457
+ * Override the Databricks CLI configuration file.
458
+ */
459
+ configFile?: string,
460
+ /**
461
+ * Override the OAuth application identifier.
462
+ */
463
+ clientId?: string,
464
+ /**
465
+ * Optional group role requested by M2M token generation.
466
+ */
467
+ groupId?: string,
468
+ /**
469
+ * Explicit Databricks authentication strategy.
470
+ */
471
+ authType?: string,
472
+ /**
473
+ * Override profile scopes; omission preserves profile/default scope resolution.
474
+ */
475
+ scopes?: Array<string>,
476
+ /**
477
+ * Target kind: workspace, account, or unified.
478
+ */
479
+ target?: string,
480
+ /**
481
+ * Override the directory containing the shared CLI token cache.
482
+ */
483
+ cacheDir?: string,
484
+ /**
485
+ * Shared lifecycle configuration; omission uses `AuthOptions::default()`.
486
+ */
487
+ auth?: AuthOptions,
488
+ /**
489
+ * Request headers available to request-scoped authentication.
490
+ */
491
+ requestHeaders?: Map<string, string>,
492
+ /**
493
+ * Header selected from `request_headers`; defaults to `authorization`.
494
+ */
495
+ accessTokenHeader?: string,
496
+ /**
497
+ * Whether implicit M2M defaults should select one matching U2M profile.
498
+ */
499
+ preferUserToMachine: boolean
500
+ }
501
+
502
+ /**
503
+ * Generated factory for {@link DatabricksAuthOptions} record objects.
504
+ */
505
+ export const DatabricksAuthOptions = (() => {
506
+ const defaults = () => ({
507
+ profile: undefined,
508
+ host: undefined,
509
+ accountId: undefined,
510
+ workspaceId: undefined,
511
+ configFile: undefined,
512
+ clientId: undefined,
513
+ groupId: undefined,
514
+ authType: undefined,
515
+ scopes: undefined,
516
+ target: undefined,
517
+ cacheDir: undefined,
518
+ auth: undefined,
519
+ requestHeaders: undefined,
520
+ accessTokenHeader: undefined,
521
+ preferUserToMachine: true
522
+ });
523
+ const create = (() => {
524
+ return uniffiCreateRecord<DatabricksAuthOptions, ReturnType<typeof defaults>>(defaults);
525
+ })();
526
+ return Object.freeze({
527
+ create,
528
+ new: create,
529
+ defaults: () => Object.freeze(defaults()) as Partial<DatabricksAuthOptions>,
530
+ });
531
+ })();
532
+
533
+ const FfiConverterTypeDatabricksAuthOptions = (() => {
534
+ type TypeName = DatabricksAuthOptions;
535
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
536
+ readFromCursor(c: Cursor): TypeName {
537
+ return {
538
+ profile: FfiConverterOptionalString.readFromCursor(c),
539
+ host: FfiConverterOptionalString.readFromCursor(c),
540
+ accountId: FfiConverterOptionalString.readFromCursor(c),
541
+ workspaceId: FfiConverterOptionalString.readFromCursor(c),
542
+ configFile: FfiConverterOptionalString.readFromCursor(c),
543
+ clientId: FfiConverterOptionalString.readFromCursor(c),
544
+ groupId: FfiConverterOptionalString.readFromCursor(c),
545
+ authType: FfiConverterOptionalString.readFromCursor(c),
546
+ scopes: FfiConverterOptionalSequenceString.readFromCursor(c),
547
+ target: FfiConverterOptionalString.readFromCursor(c),
548
+ cacheDir: FfiConverterOptionalString.readFromCursor(c),
549
+ auth: FfiConverterOptionalTypeAuthOptions.readFromCursor(c),
550
+ requestHeaders: FfiConverterOptionalMapStringString.readFromCursor(c),
551
+ accessTokenHeader: FfiConverterOptionalString.readFromCursor(c),
552
+ preferUserToMachine: FfiConverterBool.readFromCursor(c)
553
+ };
554
+ }
555
+ writeIntoCursor(value: TypeName, c: Cursor): void {
556
+ FfiConverterOptionalString.writeIntoCursor(value.profile, c);
557
+ FfiConverterOptionalString.writeIntoCursor(value.host, c);
558
+ FfiConverterOptionalString.writeIntoCursor(value.accountId, c);
559
+ FfiConverterOptionalString.writeIntoCursor(value.workspaceId, c);
560
+ FfiConverterOptionalString.writeIntoCursor(value.configFile, c);
561
+ FfiConverterOptionalString.writeIntoCursor(value.clientId, c);
562
+ FfiConverterOptionalString.writeIntoCursor(value.groupId, c);
563
+ FfiConverterOptionalString.writeIntoCursor(value.authType, c);
564
+ FfiConverterOptionalSequenceString.writeIntoCursor(value.scopes, c);
565
+ FfiConverterOptionalString.writeIntoCursor(value.target, c);
566
+ FfiConverterOptionalString.writeIntoCursor(value.cacheDir, c);
567
+ FfiConverterOptionalTypeAuthOptions.writeIntoCursor(value.auth, c);
568
+ FfiConverterOptionalMapStringString.writeIntoCursor(value.requestHeaders, c);
569
+ FfiConverterOptionalString.writeIntoCursor(value.accessTokenHeader, c);
570
+ FfiConverterBool.writeIntoCursor(value.preferUserToMachine, c);
571
+ }
572
+ allocationSize(value: TypeName): number {
573
+ return FfiConverterOptionalString.allocationSize(value.profile) +
574
+ FfiConverterOptionalString.allocationSize(value.host) +
575
+ FfiConverterOptionalString.allocationSize(value.accountId) +
576
+ FfiConverterOptionalString.allocationSize(value.workspaceId) +
577
+ FfiConverterOptionalString.allocationSize(value.configFile) +
578
+ FfiConverterOptionalString.allocationSize(value.clientId) +
579
+ FfiConverterOptionalString.allocationSize(value.groupId) +
580
+ FfiConverterOptionalString.allocationSize(value.authType) +
581
+ FfiConverterOptionalSequenceString.allocationSize(value.scopes) +
582
+ FfiConverterOptionalString.allocationSize(value.target) +
583
+ FfiConverterOptionalString.allocationSize(value.cacheDir) +
584
+ FfiConverterOptionalTypeAuthOptions.allocationSize(value.auth) +
585
+ FfiConverterOptionalMapStringString.allocationSize(value.requestHeaders) +
586
+ FfiConverterOptionalString.allocationSize(value.accessTokenHeader) +
587
+ FfiConverterBool.allocationSize(value.preferUserToMachine);
588
+
589
+ }
590
+ };
591
+ return new FFIConverter();
592
+ })();
593
+
594
+ /**
595
+ * Built-in credential storage backend.
596
+ */
597
+ export enum Storage {
598
+ /**
599
+ * Select file storage.
600
+ */
601
+ Auto,
602
+ /**
603
+ * Keep credentials in process memory.
604
+ */
605
+ Memory,
606
+ /**
607
+ * Persist credentials in the configured directory.
608
+ */
609
+ File
610
+ }
611
+
612
+ const FfiConverterTypeStorage = (() => {
613
+ type TypeName = Storage;
614
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
615
+ readFromCursor(c: Cursor): TypeName {
616
+ switch (c.readI32()) {
617
+ case 1: return Storage.Auto;
618
+ case 2: return Storage.Memory;
619
+ case 3: return Storage.File;
620
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
621
+ }
622
+ }
623
+ writeIntoCursor(value: TypeName, c: Cursor): void {
624
+ switch (value) {
625
+ case Storage.Auto: return c.writeI32(1);
626
+ case Storage.Memory: return c.writeI32(2);
627
+ case Storage.File: return c.writeI32(3);
628
+ }
629
+ }
630
+ allocationSize(value: TypeName): number {
631
+ return 4;
632
+ }
633
+ }
634
+ return new FFIConverter();
635
+ })();
636
+
637
+ /**
638
+ * Resolved Databricks identity and active storage backend.
639
+ */
640
+ export type DatabricksAuthStatus = {
641
+ /**
642
+ * Resolved Databricks CLI profile name.
643
+ */
644
+ profile: string,
645
+ /**
646
+ * Resolved workspace or accounts host.
647
+ */
648
+ host: string,
649
+ /**
650
+ * Credential storage backend used by the authentication session.
651
+ */
652
+ storage: Storage
653
+ }
654
+
655
+ /**
656
+ * Generated factory for {@link DatabricksAuthStatus} record objects.
657
+ */
658
+ export const DatabricksAuthStatus = (() => {
659
+ const defaults = () => ({
660
+ });
661
+ const create = (() => {
662
+ return uniffiCreateRecord<DatabricksAuthStatus, ReturnType<typeof defaults>>(defaults);
663
+ })();
664
+ return Object.freeze({
665
+ create,
666
+ new: create,
667
+ defaults: () => Object.freeze(defaults()) as Partial<DatabricksAuthStatus>,
668
+ });
669
+ })();
670
+
671
+ const FfiConverterTypeDatabricksAuthStatus = (() => {
672
+ type TypeName = DatabricksAuthStatus;
673
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
674
+ readFromCursor(c: Cursor): TypeName {
675
+ return {
676
+ profile: FfiConverterString.readFromCursor(c),
677
+ host: FfiConverterString.readFromCursor(c),
678
+ storage: FfiConverterTypeStorage.readFromCursor(c)
679
+ };
680
+ }
681
+ writeIntoCursor(value: TypeName, c: Cursor): void {
682
+ FfiConverterString.writeIntoCursor(value.profile, c);
683
+ FfiConverterString.writeIntoCursor(value.host, c);
684
+ FfiConverterTypeStorage.writeIntoCursor(value.storage, c);
685
+ }
686
+ allocationSize(value: TypeName): number {
687
+ return FfiConverterString.allocationSize(value.profile) +
688
+ FfiConverterString.allocationSize(value.host) +
689
+ FfiConverterTypeStorage.allocationSize(value.storage);
690
+
691
+ }
692
+ };
693
+ return new FFIConverter();
694
+ })();
695
+
696
+ /**
697
+ * PostgreSQL TLS modes recognized in Lakebase connection URLs.
698
+ */
699
+ export enum SslMode {
700
+ /**
701
+ * Require a TLS connection.
702
+ */
703
+ Require,
704
+ /**
705
+ * Disable TLS for a local proxy connection.
706
+ */
707
+ Disable,
708
+ /**
709
+ * Prefer TLS when the server supports it.
710
+ */
711
+ Prefer
712
+ }
713
+
714
+ const FfiConverterTypeSslMode = (() => {
715
+ type TypeName = SslMode;
716
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
717
+ readFromCursor(c: Cursor): TypeName {
718
+ switch (c.readI32()) {
719
+ case 1: return SslMode.Require;
720
+ case 2: return SslMode.Disable;
721
+ case 3: return SslMode.Prefer;
722
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
723
+ }
724
+ }
725
+ writeIntoCursor(value: TypeName, c: Cursor): void {
726
+ switch (value) {
727
+ case SslMode.Require: return c.writeI32(1);
728
+ case SslMode.Disable: return c.writeI32(2);
729
+ case SslMode.Prefer: return c.writeI32(3);
730
+ }
731
+ }
732
+ allocationSize(value: TypeName): number {
733
+ return 4;
734
+ }
735
+ }
736
+ return new FFIConverter();
737
+ })();
738
+
739
+ /**
740
+ * Connection and resource fields recovered from a Lakebase address.
741
+ */
742
+ export type ParsedAddress = {
743
+ /**
744
+ * Lakebase Postgres project identifier.
745
+ */
746
+ project?: string,
747
+ /**
748
+ * Branch identifier within the project.
749
+ */
750
+ branch?: string,
751
+ /**
752
+ * Canonical endpoint resource path.
753
+ */
754
+ endpoint?: string,
755
+ /**
756
+ * Endpoint leaf identifier.
757
+ */
758
+ endpointId?: string,
759
+ /**
760
+ * PostgreSQL database name.
761
+ */
762
+ database?: string,
763
+ /**
764
+ * Database resource leaf identifier.
765
+ */
766
+ databaseResourceId?: string,
767
+ /**
768
+ * PostgreSQL user or Databricks profile from a URL.
769
+ */
770
+ user?: string,
771
+ /**
772
+ * Endpoint or local proxy host.
773
+ */
774
+ host?: string,
775
+ /**
776
+ * PostgreSQL port.
777
+ */
778
+ port?: number,
779
+ /**
780
+ * PostgreSQL TLS mode.
781
+ */
782
+ sslMode?: SslMode
783
+ }
784
+
785
+ /**
786
+ * Generated factory for {@link ParsedAddress} record objects.
787
+ */
788
+ export const ParsedAddress = (() => {
789
+ const defaults = () => ({
790
+ });
791
+ const create = (() => {
792
+ return uniffiCreateRecord<ParsedAddress, ReturnType<typeof defaults>>(defaults);
793
+ })();
794
+ return Object.freeze({
795
+ create,
796
+ new: create,
797
+ defaults: () => Object.freeze(defaults()) as Partial<ParsedAddress>,
798
+ });
799
+ })();
800
+
801
+ const FfiConverterTypeParsedAddress = (() => {
802
+ type TypeName = ParsedAddress;
803
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
804
+ readFromCursor(c: Cursor): TypeName {
805
+ return {
806
+ project: FfiConverterOptionalString.readFromCursor(c),
807
+ branch: FfiConverterOptionalString.readFromCursor(c),
808
+ endpoint: FfiConverterOptionalString.readFromCursor(c),
809
+ endpointId: FfiConverterOptionalString.readFromCursor(c),
810
+ database: FfiConverterOptionalString.readFromCursor(c),
811
+ databaseResourceId: FfiConverterOptionalString.readFromCursor(c),
812
+ user: FfiConverterOptionalString.readFromCursor(c),
813
+ host: FfiConverterOptionalString.readFromCursor(c),
814
+ port: FfiConverterOptionalUInt16.readFromCursor(c),
815
+ sslMode: FfiConverterOptionalTypeSslMode.readFromCursor(c)
816
+ };
817
+ }
818
+ writeIntoCursor(value: TypeName, c: Cursor): void {
819
+ FfiConverterOptionalString.writeIntoCursor(value.project, c);
820
+ FfiConverterOptionalString.writeIntoCursor(value.branch, c);
821
+ FfiConverterOptionalString.writeIntoCursor(value.endpoint, c);
822
+ FfiConverterOptionalString.writeIntoCursor(value.endpointId, c);
823
+ FfiConverterOptionalString.writeIntoCursor(value.database, c);
824
+ FfiConverterOptionalString.writeIntoCursor(value.databaseResourceId, c);
825
+ FfiConverterOptionalString.writeIntoCursor(value.user, c);
826
+ FfiConverterOptionalString.writeIntoCursor(value.host, c);
827
+ FfiConverterOptionalUInt16.writeIntoCursor(value.port, c);
828
+ FfiConverterOptionalTypeSslMode.writeIntoCursor(value.sslMode, c);
829
+ }
830
+ allocationSize(value: TypeName): number {
831
+ return FfiConverterOptionalString.allocationSize(value.project) +
832
+ FfiConverterOptionalString.allocationSize(value.branch) +
833
+ FfiConverterOptionalString.allocationSize(value.endpoint) +
834
+ FfiConverterOptionalString.allocationSize(value.endpointId) +
835
+ FfiConverterOptionalString.allocationSize(value.database) +
836
+ FfiConverterOptionalString.allocationSize(value.databaseResourceId) +
837
+ FfiConverterOptionalString.allocationSize(value.user) +
838
+ FfiConverterOptionalString.allocationSize(value.host) +
839
+ FfiConverterOptionalUInt16.allocationSize(value.port) +
840
+ FfiConverterOptionalTypeSslMode.allocationSize(value.sslMode);
841
+
842
+ }
843
+ };
844
+ return new FFIConverter();
845
+ })();
846
+
847
+ /**
848
+ * OAuth grant used to acquire and renew credentials.
849
+ */
850
+ export enum OAuthGrant {
851
+ /**
852
+ * Browser authorization-code grant with PKCE and refresh-token renewal.
853
+ */
854
+ AuthorizationCode,
855
+ /**
856
+ * Noninteractive client-credentials grant renewed by repeating the exchange.
857
+ */
858
+ ClientCredentials
859
+ }
860
+
861
+ const FfiConverterTypeOAuthGrant = (() => {
862
+ type TypeName = OAuthGrant;
863
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
864
+ readFromCursor(c: Cursor): TypeName {
865
+ switch (c.readI32()) {
866
+ case 1: return OAuthGrant.AuthorizationCode;
867
+ case 2: return OAuthGrant.ClientCredentials;
868
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
869
+ }
870
+ }
871
+ writeIntoCursor(value: TypeName, c: Cursor): void {
872
+ switch (value) {
873
+ case OAuthGrant.AuthorizationCode: return c.writeI32(1);
874
+ case OAuthGrant.ClientCredentials: return c.writeI32(2);
875
+ }
876
+ }
877
+ allocationSize(value: TypeName): number {
878
+ return 4;
879
+ }
880
+ }
881
+ return new FFIConverter();
882
+ })();
883
+
884
+ /**
885
+ * File organization used by the persistent credential store.
886
+ */
887
+ export enum FileLayout {
888
+ /**
889
+ * Store all credentials in one token cache.
890
+ */
891
+ Single,
892
+ /**
893
+ * Store each credential in an independent hashed directory.
894
+ */
895
+ PerCredential
896
+ }
897
+
898
+ const FfiConverterTypeFileLayout = (() => {
899
+ type TypeName = FileLayout;
900
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
901
+ readFromCursor(c: Cursor): TypeName {
902
+ switch (c.readI32()) {
903
+ case 1: return FileLayout.Single;
904
+ case 2: return FileLayout.PerCredential;
905
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
906
+ }
907
+ }
908
+ writeIntoCursor(value: TypeName, c: Cursor): void {
909
+ switch (value) {
910
+ case FileLayout.Single: return c.writeI32(1);
911
+ case FileLayout.PerCredential: return c.writeI32(2);
912
+ }
913
+ }
914
+ allocationSize(value: TypeName): number {
915
+ return 4;
916
+ }
917
+ }
918
+ return new FFIConverter();
919
+ })();
920
+
921
+ /**
922
+ * Provider-specific OAuth identity, endpoints, storage, and shared lifecycle options.
923
+ */
924
+ export type ProviderOptions = {
925
+ /**
926
+ * Stable provider identity used to isolate stored credentials.
927
+ */
928
+ provider: string,
929
+ /**
930
+ * OAuth application identifier.
931
+ */
932
+ clientId: string,
933
+ /**
934
+ * Provider's token exchange endpoint.
935
+ */
936
+ tokenEndpoint: string,
937
+ /**
938
+ * Required browser authorization endpoint for authorization-code grants.
939
+ */
940
+ authorizationEndpoint?: string,
941
+ /**
942
+ * Secret for confidential clients; never returned in access-token results.
943
+ */
944
+ clientSecret?: string,
945
+ /**
946
+ * Optional namespace for multiple accounts under one provider.
947
+ */
948
+ profile?: string,
949
+ /**
950
+ * Requested scopes, trimmed, sorted, and deduplicated before use.
951
+ */
952
+ scopes: Array<string>,
953
+ /**
954
+ * Defaults to authorization code with PKCE when omitted.
955
+ */
956
+ grant?: OAuthGrant,
957
+ /**
958
+ * Override the provider-neutral credential directory.
959
+ */
960
+ cacheDir?: string,
961
+ /**
962
+ * Select a built-in store; omission uses file storage.
963
+ */
964
+ storage?: Storage,
965
+ /**
966
+ * Select a shared cache file or independent credential files.
967
+ */
968
+ fileLayout?: FileLayout,
969
+ /**
970
+ * Shared lifecycle configuration; omission uses `AuthOptions::default()`.
971
+ */
972
+ auth?: AuthOptions
973
+ }
974
+
975
+ /**
976
+ * Generated factory for {@link ProviderOptions} record objects.
977
+ */
978
+ export const ProviderOptions = (() => {
979
+ const defaults = () => ({
980
+ authorizationEndpoint: undefined,
981
+ clientSecret: undefined,
982
+ profile: undefined,
983
+ scopes: [],
984
+ grant: undefined,
985
+ cacheDir: undefined,
986
+ storage: undefined,
987
+ fileLayout: undefined,
988
+ auth: undefined
989
+ });
990
+ const create = (() => {
991
+ return uniffiCreateRecord<ProviderOptions, ReturnType<typeof defaults>>(defaults);
992
+ })();
993
+ return Object.freeze({
994
+ create,
995
+ new: create,
996
+ defaults: () => Object.freeze(defaults()) as Partial<ProviderOptions>,
997
+ });
998
+ })();
999
+
1000
+ const FfiConverterTypeProviderOptions = (() => {
1001
+ type TypeName = ProviderOptions;
1002
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1003
+ readFromCursor(c: Cursor): TypeName {
1004
+ return {
1005
+ provider: FfiConverterString.readFromCursor(c),
1006
+ clientId: FfiConverterString.readFromCursor(c),
1007
+ tokenEndpoint: FfiConverterString.readFromCursor(c),
1008
+ authorizationEndpoint: FfiConverterOptionalString.readFromCursor(c),
1009
+ clientSecret: FfiConverterOptionalString.readFromCursor(c),
1010
+ profile: FfiConverterOptionalString.readFromCursor(c),
1011
+ scopes: FfiConverterSequenceString.readFromCursor(c),
1012
+ grant: FfiConverterOptionalTypeOAuthGrant.readFromCursor(c),
1013
+ cacheDir: FfiConverterOptionalString.readFromCursor(c),
1014
+ storage: FfiConverterOptionalTypeStorage.readFromCursor(c),
1015
+ fileLayout: FfiConverterOptionalTypeFileLayout.readFromCursor(c),
1016
+ auth: FfiConverterOptionalTypeAuthOptions.readFromCursor(c)
1017
+ };
1018
+ }
1019
+ writeIntoCursor(value: TypeName, c: Cursor): void {
1020
+ FfiConverterString.writeIntoCursor(value.provider, c);
1021
+ FfiConverterString.writeIntoCursor(value.clientId, c);
1022
+ FfiConverterString.writeIntoCursor(value.tokenEndpoint, c);
1023
+ FfiConverterOptionalString.writeIntoCursor(value.authorizationEndpoint, c);
1024
+ FfiConverterOptionalString.writeIntoCursor(value.clientSecret, c);
1025
+ FfiConverterOptionalString.writeIntoCursor(value.profile, c);
1026
+ FfiConverterSequenceString.writeIntoCursor(value.scopes, c);
1027
+ FfiConverterOptionalTypeOAuthGrant.writeIntoCursor(value.grant, c);
1028
+ FfiConverterOptionalString.writeIntoCursor(value.cacheDir, c);
1029
+ FfiConverterOptionalTypeStorage.writeIntoCursor(value.storage, c);
1030
+ FfiConverterOptionalTypeFileLayout.writeIntoCursor(value.fileLayout, c);
1031
+ FfiConverterOptionalTypeAuthOptions.writeIntoCursor(value.auth, c);
1032
+ }
1033
+ allocationSize(value: TypeName): number {
1034
+ return FfiConverterString.allocationSize(value.provider) +
1035
+ FfiConverterString.allocationSize(value.clientId) +
1036
+ FfiConverterString.allocationSize(value.tokenEndpoint) +
1037
+ FfiConverterOptionalString.allocationSize(value.authorizationEndpoint) +
1038
+ FfiConverterOptionalString.allocationSize(value.clientSecret) +
1039
+ FfiConverterOptionalString.allocationSize(value.profile) +
1040
+ FfiConverterSequenceString.allocationSize(value.scopes) +
1041
+ FfiConverterOptionalTypeOAuthGrant.allocationSize(value.grant) +
1042
+ FfiConverterOptionalString.allocationSize(value.cacheDir) +
1043
+ FfiConverterOptionalTypeStorage.allocationSize(value.storage) +
1044
+ FfiConverterOptionalTypeFileLayout.allocationSize(value.fileLayout) +
1045
+ FfiConverterOptionalTypeAuthOptions.allocationSize(value.auth);
1046
+
1047
+ }
1048
+ };
1049
+ return new FFIConverter();
1050
+ })();
1051
+
1052
+
1053
+ // Error type: AuthError
1054
+ export enum AuthError_Tags {
1055
+ Failure = "Failure"
1056
+ }
1057
+ /**
1058
+ * Authentication failure exposed through language bindings.
1059
+ */
1060
+ export const AuthError = (() => {
1061
+
1062
+ type Failure__interface = {
1063
+ tag: AuthError_Tags.Failure;
1064
+ inner:
1065
+ Readonly<{message: string}>
1066
+ };
1067
+ /**
1068
+ * Native authentication, storage, configuration, or callback failure.
1069
+ */
1070
+ class Failure_ extends UniffiError implements Failure__interface {
1071
+ /**
1072
+ * @private
1073
+ * This field is private and should not be used, use `tag` instead.
1074
+ */
1075
+ readonly [uniffiTypeNameSymbol] = "AuthError";
1076
+ readonly tag = AuthError_Tags.Failure;
1077
+ readonly inner:
1078
+ Readonly<{message: string}>;
1079
+ constructor(
1080
+ inner: {message: string }) {
1081
+ super("AuthError", "Failure");
1082
+
1083
+ this.inner = Object.freeze(inner);
1084
+ }
1085
+ static new(
1086
+ inner: {message: string }): Failure_ {
1087
+ return new Failure_(inner);
1088
+ }
1089
+
1090
+ static instanceOf(obj: any): obj is Failure_ {
1091
+ return obj.tag === AuthError_Tags.Failure;
1092
+ }
1093
+ static hasInner(obj: any): obj is Failure_ {
1094
+ return Failure_.instanceOf(obj);
1095
+ }
1096
+
1097
+ static getInner(obj: Failure_):
1098
+ Readonly<{message: string}> {
1099
+ return obj.inner;
1100
+ }
1101
+
1102
+ }
1103
+
1104
+ function instanceOf(obj: any): obj is AuthError {
1105
+ return obj[uniffiTypeNameSymbol] === "AuthError";
1106
+ }
1107
+
1108
+ return Object.freeze({
1109
+ instanceOf,
1110
+ Failure: Failure_
1111
+ });
1112
+
1113
+ })();
1114
+ /**
1115
+ * Authentication failure exposed through language bindings.
1116
+ */
1117
+ export type AuthError = InstanceType<
1118
+ typeof AuthError['Failure']
1119
+ >;
1120
+
1121
+ // FfiConverter for enum AuthError
1122
+ const FfiConverterTypeAuthError = (() => {
1123
+ type TypeName = AuthError;
1124
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1125
+ readFromCursor(c: Cursor): TypeName {
1126
+ switch (c.readI32()) {
1127
+ case 1: return new AuthError.Failure({message: FfiConverterString.readFromCursor(c) });
1128
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
1129
+ }
1130
+ }
1131
+ writeIntoCursor(value: TypeName, c: Cursor): void {
1132
+ switch (value.tag) {
1133
+ case AuthError_Tags.Failure: {
1134
+ c.writeI32(1);
1135
+ const inner = value.inner;
1136
+ FfiConverterString.writeIntoCursor(inner.message, c);
1137
+ return;
1138
+ }
1139
+ default:
1140
+ // Throwing from here means that AuthError_Tags hasn't matched an ordinal.
1141
+ throw new UniffiInternalError.UnexpectedEnumCase();
1142
+ }
1143
+ }
1144
+ allocationSize(value: TypeName): number {
1145
+ switch (value.tag) {
1146
+ case AuthError_Tags.Failure: {
1147
+ const inner = value.inner;
1148
+ let size = 4;
1149
+ size += FfiConverterString.allocationSize(inner.message);
1150
+ return size;
1151
+ }
1152
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
1153
+ }
1154
+ }
1155
+ }
1156
+ return new FFIConverter();
1157
+ })();
1158
+
1159
+ /**
1160
+ * Databricks binding facade over the shared persistent authentication lifecycle.
1161
+ */
1162
+ export interface PersistentAuthLike {
1163
+
1164
+ /**
1165
+ * Return a current authorization header when the request URL matches the profile origin.
1166
+ */
1167
+ authorizationHeaderForUrl(requestUrl: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string | undefined>;
1168
+ /**
1169
+ * Start an explicit login and persist the resulting credential.
1170
+ */
1171
+ challenge(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1172
+ /**
1173
+ * Renew the stored credential even before its refresh window.
1174
+ */
1175
+ forceRefreshToken(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
1176
+ /**
1177
+ * Delete the credential while holding the store's refresh lock.
1178
+ */
1179
+ logout(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1180
+ /**
1181
+ * Reuse another caller's replacement or renew the rejected token.
1182
+ */
1183
+ refreshRejectedToken(staleAccessToken: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
1184
+ /**
1185
+ * Return the resolved identity and active built-in storage backend.
1186
+ */
1187
+ status(): DatabricksAuthStatus;
1188
+ /**
1189
+ * True forces login, false forbids interactive login, and omission permits missing-token login.
1190
+ */
1191
+ token(login?: boolean | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
1192
+ }
1193
+ /**
1194
+ * @deprecated Use `PersistentAuthLike` instead.
1195
+ */
1196
+ export type PersistentAuthInterface = PersistentAuthLike;
1197
+
1198
+
1199
+ /**
1200
+ * Databricks binding facade over the shared persistent authentication lifecycle.
1201
+ */
1202
+ export class PersistentAuth extends UniffiAbstractObject implements PersistentAuthLike {
1203
+
1204
+ readonly [uniffiTypeNameSymbol] = "PersistentAuth";
1205
+ readonly [destructorGuardSymbol]: UniffiGcObject;
1206
+ readonly [pointerLiteralSymbol]: UniffiHandle;
1207
+ // No primary constructor declared for this class.
1208
+ private constructor(pointer: UniffiHandle) {
1209
+ super();
1210
+ this[pointerLiteralSymbol] = pointer;
1211
+ this[destructorGuardSymbol] = uniffiTypePersistentAuthObjectFactory.bless(pointer);
1212
+ }
1213
+
1214
+
1215
+
1216
+
1217
+ /**
1218
+ * Return a current authorization header when the request URL matches the profile origin.
1219
+ */
1220
+ async authorizationHeaderForUrl(requestUrl: string, asyncOpts_?: { signal: AbortSignal }): Promise<string | undefined> /*throws*/ {
1221
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1222
+ try {
1223
+ return await uniffiRustCallAsync(
1224
+ /*rustCaller:*/ uniffiCaller,
1225
+ /*rustFutureFunc:*/ () => {
1226
+ return nativeModule().uniffi_dbx_tools_core_fn_method_persistentauth_authorization_header_for_url(
1227
+ uniffiTypePersistentAuthObjectFactory.clonePointer(this),FfiConverterString.lower(requestUrl, nativeModule().rustbuffer_alloc)
1228
+ );
1229
+ },
1230
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1231
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1232
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1233
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1234
+ // Async returns always go through the JS-side converter: the
1235
+ // FFI symbol returns the future handle (u64), and the user-level
1236
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1237
+ // export. The bytes the runtime hands back must be deserialized
1238
+ // here using the per-callable return-type converter.
1239
+ // Borrowed view over foreign memory: the call site owns the free,
1240
+ // as on the sync paths. Unconditional — a no-op where buffers are
1241
+ // already JS-owned.
1242
+ /*liftFunc:*/ (__rb) => {
1243
+ try {
1244
+ return FfiConverterOptionalString.lift(__rb);
1245
+ } finally {
1246
+ nativeModule().rustbuffer_free(__rb);
1247
+ }
1248
+ },
1249
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1250
+ /*asyncOpts:*/ asyncOpts_,
1251
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1252
+ );
1253
+ } catch (__error: any) {
1254
+ if (uniffiIsDebug && __error instanceof Error) {
1255
+ __error.stack = __stack;
1256
+ }
1257
+ throw __error;
1258
+ }
1259
+ }
1260
+
1261
+ /**
1262
+ * Start an explicit login and persist the resulting credential.
1263
+ */
1264
+ async challenge(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1265
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1266
+ try {
1267
+ return await uniffiRustCallAsync(
1268
+ /*rustCaller:*/ uniffiCaller,
1269
+ /*rustFutureFunc:*/ () => {
1270
+ return nativeModule().uniffi_dbx_tools_core_fn_method_persistentauth_challenge(
1271
+ uniffiTypePersistentAuthObjectFactory.clonePointer(this)
1272
+ );
1273
+ },
1274
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_void,
1275
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_void,
1276
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_void,
1277
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_void,
1278
+ /*liftFunc:*/ (_v) => {},
1279
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1280
+ /*asyncOpts:*/ asyncOpts_,
1281
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1282
+ );
1283
+ } catch (__error: any) {
1284
+ if (uniffiIsDebug && __error instanceof Error) {
1285
+ __error.stack = __stack;
1286
+ }
1287
+ throw __error;
1288
+ }
1289
+ }
1290
+
1291
+ /**
1292
+ * Renew the stored credential even before its refresh window.
1293
+ */
1294
+ async forceRefreshToken(asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
1295
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1296
+ try {
1297
+ return await uniffiRustCallAsync(
1298
+ /*rustCaller:*/ uniffiCaller,
1299
+ /*rustFutureFunc:*/ () => {
1300
+ return nativeModule().uniffi_dbx_tools_core_fn_method_persistentauth_force_refresh_token(
1301
+ uniffiTypePersistentAuthObjectFactory.clonePointer(this)
1302
+ );
1303
+ },
1304
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1305
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1306
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1307
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1308
+ // Async returns always go through the JS-side converter: the
1309
+ // FFI symbol returns the future handle (u64), and the user-level
1310
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1311
+ // export. The bytes the runtime hands back must be deserialized
1312
+ // here using the per-callable return-type converter.
1313
+ // Borrowed view over foreign memory: the call site owns the free,
1314
+ // as on the sync paths. Unconditional — a no-op where buffers are
1315
+ // already JS-owned.
1316
+ /*liftFunc:*/ (__rb) => {
1317
+ try {
1318
+ return FfiConverterTypeAccessToken.lift(__rb);
1319
+ } finally {
1320
+ nativeModule().rustbuffer_free(__rb);
1321
+ }
1322
+ },
1323
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1324
+ /*asyncOpts:*/ asyncOpts_,
1325
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1326
+ );
1327
+ } catch (__error: any) {
1328
+ if (uniffiIsDebug && __error instanceof Error) {
1329
+ __error.stack = __stack;
1330
+ }
1331
+ throw __error;
1332
+ }
1333
+ }
1334
+
1335
+ /**
1336
+ * Delete the credential while holding the store's refresh lock.
1337
+ */
1338
+ async logout(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1339
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1340
+ try {
1341
+ return await uniffiRustCallAsync(
1342
+ /*rustCaller:*/ uniffiCaller,
1343
+ /*rustFutureFunc:*/ () => {
1344
+ return nativeModule().uniffi_dbx_tools_core_fn_method_persistentauth_logout(
1345
+ uniffiTypePersistentAuthObjectFactory.clonePointer(this)
1346
+ );
1347
+ },
1348
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_void,
1349
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_void,
1350
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_void,
1351
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_void,
1352
+ /*liftFunc:*/ (_v) => {},
1353
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1354
+ /*asyncOpts:*/ asyncOpts_,
1355
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1356
+ );
1357
+ } catch (__error: any) {
1358
+ if (uniffiIsDebug && __error instanceof Error) {
1359
+ __error.stack = __stack;
1360
+ }
1361
+ throw __error;
1362
+ }
1363
+ }
1364
+
1365
+ /**
1366
+ * Reuse another caller's replacement or renew the rejected token.
1367
+ */
1368
+ async refreshRejectedToken(staleAccessToken: string, asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
1369
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1370
+ try {
1371
+ return await uniffiRustCallAsync(
1372
+ /*rustCaller:*/ uniffiCaller,
1373
+ /*rustFutureFunc:*/ () => {
1374
+ return nativeModule().uniffi_dbx_tools_core_fn_method_persistentauth_refresh_rejected_token(
1375
+ uniffiTypePersistentAuthObjectFactory.clonePointer(this),FfiConverterString.lower(staleAccessToken, nativeModule().rustbuffer_alloc)
1376
+ );
1377
+ },
1378
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1379
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1380
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1381
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1382
+ // Async returns always go through the JS-side converter: the
1383
+ // FFI symbol returns the future handle (u64), and the user-level
1384
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1385
+ // export. The bytes the runtime hands back must be deserialized
1386
+ // here using the per-callable return-type converter.
1387
+ // Borrowed view over foreign memory: the call site owns the free,
1388
+ // as on the sync paths. Unconditional — a no-op where buffers are
1389
+ // already JS-owned.
1390
+ /*liftFunc:*/ (__rb) => {
1391
+ try {
1392
+ return FfiConverterTypeAccessToken.lift(__rb);
1393
+ } finally {
1394
+ nativeModule().rustbuffer_free(__rb);
1395
+ }
1396
+ },
1397
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1398
+ /*asyncOpts:*/ asyncOpts_,
1399
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1400
+ );
1401
+ } catch (__error: any) {
1402
+ if (uniffiIsDebug && __error instanceof Error) {
1403
+ __error.stack = __stack;
1404
+ }
1405
+ throw __error;
1406
+ }
1407
+ }
1408
+
1409
+ /**
1410
+ * Return the resolved identity and active built-in storage backend.
1411
+ */
1412
+ status(): DatabricksAuthStatus {
1413
+ const __rb: Uint8Array = uniffiCaller.rustCall(
1414
+ /*caller:*/ (callStatus) => {
1415
+ return nativeModule().uniffi_dbx_tools_core_fn_method_persistentauth_status(
1416
+ uniffiTypePersistentAuthObjectFactory.clonePointer(this),
1417
+ callStatus);
1418
+ },
1419
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1420
+ );
1421
+ try {
1422
+ return FfiConverterTypeDatabricksAuthStatus.lift(__rb);
1423
+ } finally {
1424
+ nativeModule().rustbuffer_free(__rb);
1425
+ }
1426
+ }
1427
+
1428
+ /**
1429
+ * True forces login, false forbids interactive login, and omission permits missing-token login.
1430
+ */
1431
+ async token(login: boolean | undefined = undefined, asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
1432
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1433
+ try {
1434
+ return await uniffiRustCallAsync(
1435
+ /*rustCaller:*/ uniffiCaller,
1436
+ /*rustFutureFunc:*/ () => {
1437
+ return nativeModule().uniffi_dbx_tools_core_fn_method_persistentauth_token(
1438
+ uniffiTypePersistentAuthObjectFactory.clonePointer(this),FfiConverterOptionalBoolean.lower(login, nativeModule().rustbuffer_alloc)
1439
+ );
1440
+ },
1441
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1442
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1443
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1444
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1445
+ // Async returns always go through the JS-side converter: the
1446
+ // FFI symbol returns the future handle (u64), and the user-level
1447
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1448
+ // export. The bytes the runtime hands back must be deserialized
1449
+ // here using the per-callable return-type converter.
1450
+ // Borrowed view over foreign memory: the call site owns the free,
1451
+ // as on the sync paths. Unconditional — a no-op where buffers are
1452
+ // already JS-owned.
1453
+ /*liftFunc:*/ (__rb) => {
1454
+ try {
1455
+ return FfiConverterTypeAccessToken.lift(__rb);
1456
+ } finally {
1457
+ nativeModule().rustbuffer_free(__rb);
1458
+ }
1459
+ },
1460
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1461
+ /*asyncOpts:*/ asyncOpts_,
1462
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1463
+ );
1464
+ } catch (__error: any) {
1465
+ if (uniffiIsDebug && __error instanceof Error) {
1466
+ __error.stack = __stack;
1467
+ }
1468
+ throw __error;
1469
+ }
1470
+ }
1471
+
1472
+
1473
+ uniffiDestroy(): void {
1474
+ const ptr = (this as any)[destructorGuardSymbol];
1475
+ if (ptr !== undefined) {
1476
+ const pointer = uniffiTypePersistentAuthObjectFactory.pointer(this);
1477
+ uniffiTypePersistentAuthObjectFactory.freePointer(pointer);
1478
+ uniffiTypePersistentAuthObjectFactory.unbless(ptr);
1479
+ delete (this as any)[destructorGuardSymbol];
1480
+ }
1481
+ }
1482
+
1483
+ static instanceOf(obj_: any): obj_ is PersistentAuth {
1484
+ return uniffiTypePersistentAuthObjectFactory.isConcreteType(obj_);
1485
+ }
1486
+
1487
+
1488
+ }
1489
+
1490
+ const uniffiTypePersistentAuthObjectFactory: UniffiObjectFactory<PersistentAuthLike> = (() => {
1491
+
1492
+ /// <reference lib="es2021" />
1493
+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
1494
+ uniffiTypePersistentAuthObjectFactory.freePointer(heldValue);
1495
+ }) : null;
1496
+
1497
+ return {
1498
+ create(pointer: UniffiHandle): PersistentAuthLike {
1499
+ const instance = Object.create(PersistentAuth.prototype);
1500
+ instance[pointerLiteralSymbol] = pointer;
1501
+ instance[destructorGuardSymbol] = this.bless(pointer);
1502
+ instance[uniffiTypeNameSymbol] = "PersistentAuth";
1503
+ return instance;
1504
+ },
1505
+
1506
+
1507
+ bless(p: UniffiHandle): UniffiGcObject {
1508
+ const ptr = {
1509
+ p, // make sure this object doesn't get optimized away.
1510
+ markDestroyed: () => undefined,
1511
+ };
1512
+ if (registry) {
1513
+ registry.register(ptr, p, ptr);
1514
+ }
1515
+ return ptr;
1516
+ },
1517
+
1518
+ unbless(ptr_: UniffiGcObject) {
1519
+ if (registry) {
1520
+ registry.unregister(ptr_);
1521
+ }
1522
+ },
1523
+
1524
+ pointer(obj_: PersistentAuthLike): UniffiHandle {
1525
+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {
1526
+ throw new UniffiInternalError.UnexpectedNullPointer();
1527
+ }
1528
+ return (obj_ as any)[pointerLiteralSymbol];
1529
+ },
1530
+
1531
+ clonePointer(obj_: PersistentAuthLike): UniffiHandle {
1532
+ const pointer = this.pointer(obj_);
1533
+ return uniffiCaller.rustCall(
1534
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_clone_persistentauth(pointer, callStatus),
1535
+ /*liftString:*/ FfiConverterString.lift
1536
+ );
1537
+ },
1538
+
1539
+ freePointer(pointer: UniffiHandle): void {
1540
+ uniffiCaller.rustCall(
1541
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_free_persistentauth(pointer, callStatus),
1542
+ /*liftString:*/ FfiConverterString.lift
1543
+ );
1544
+ },
1545
+
1546
+ isConcreteType(obj_: any): obj_ is PersistentAuthLike {
1547
+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "PersistentAuth";
1548
+ },
1549
+ }})();
1550
+ const FfiConverterTypePersistentAuth = new FfiConverterObject(uniffiTypePersistentAuthObjectFactory);
1551
+
1552
+ /**
1553
+ * Generic OAuth provider using the shared persistent credential lifecycle.
1554
+ */
1555
+ export interface ProviderAuthLike {
1556
+
1557
+ /**
1558
+ * Renew the credential even if it has not entered its refresh window.
1559
+ */
1560
+ forceRefreshToken(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
1561
+ /**
1562
+ * Delete the stored credential while holding its refresh lock.
1563
+ */
1564
+ logout(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1565
+ /**
1566
+ * Reuse a concurrent replacement or renew the rejected access token.
1567
+ */
1568
+ refreshRejectedToken(staleAccessToken: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
1569
+ /**
1570
+ * True forces login, false forbids interactive login, and omission permits missing-token login.
1571
+ */
1572
+ token(login?: boolean | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
1573
+ }
1574
+ /**
1575
+ * @deprecated Use `ProviderAuthLike` instead.
1576
+ */
1577
+ export type ProviderAuthInterface = ProviderAuthLike;
1578
+
1579
+
1580
+ /**
1581
+ * Generic OAuth provider using the shared persistent credential lifecycle.
1582
+ */
1583
+ export class ProviderAuth extends UniffiAbstractObject implements ProviderAuthLike {
1584
+
1585
+ readonly [uniffiTypeNameSymbol] = "ProviderAuth";
1586
+ readonly [destructorGuardSymbol]: UniffiGcObject;
1587
+ readonly [pointerLiteralSymbol]: UniffiHandle;
1588
+ // No primary constructor declared for this class.
1589
+ private constructor(pointer: UniffiHandle) {
1590
+ super();
1591
+ this[pointerLiteralSymbol] = pointer;
1592
+ this[destructorGuardSymbol] = uniffiTypeProviderAuthObjectFactory.bless(pointer);
1593
+ }
1594
+
1595
+
1596
+
1597
+
1598
+ /**
1599
+ * Renew the credential even if it has not entered its refresh window.
1600
+ */
1601
+ async forceRefreshToken(asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
1602
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1603
+ try {
1604
+ return await uniffiRustCallAsync(
1605
+ /*rustCaller:*/ uniffiCaller,
1606
+ /*rustFutureFunc:*/ () => {
1607
+ return nativeModule().uniffi_dbx_tools_core_fn_method_providerauth_force_refresh_token(
1608
+ uniffiTypeProviderAuthObjectFactory.clonePointer(this)
1609
+ );
1610
+ },
1611
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1612
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1613
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1614
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1615
+ // Async returns always go through the JS-side converter: the
1616
+ // FFI symbol returns the future handle (u64), and the user-level
1617
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1618
+ // export. The bytes the runtime hands back must be deserialized
1619
+ // here using the per-callable return-type converter.
1620
+ // Borrowed view over foreign memory: the call site owns the free,
1621
+ // as on the sync paths. Unconditional — a no-op where buffers are
1622
+ // already JS-owned.
1623
+ /*liftFunc:*/ (__rb) => {
1624
+ try {
1625
+ return FfiConverterTypeAccessToken.lift(__rb);
1626
+ } finally {
1627
+ nativeModule().rustbuffer_free(__rb);
1628
+ }
1629
+ },
1630
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1631
+ /*asyncOpts:*/ asyncOpts_,
1632
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1633
+ );
1634
+ } catch (__error: any) {
1635
+ if (uniffiIsDebug && __error instanceof Error) {
1636
+ __error.stack = __stack;
1637
+ }
1638
+ throw __error;
1639
+ }
1640
+ }
1641
+
1642
+ /**
1643
+ * Delete the stored credential while holding its refresh lock.
1644
+ */
1645
+ async logout(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1646
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1647
+ try {
1648
+ return await uniffiRustCallAsync(
1649
+ /*rustCaller:*/ uniffiCaller,
1650
+ /*rustFutureFunc:*/ () => {
1651
+ return nativeModule().uniffi_dbx_tools_core_fn_method_providerauth_logout(
1652
+ uniffiTypeProviderAuthObjectFactory.clonePointer(this)
1653
+ );
1654
+ },
1655
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_void,
1656
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_void,
1657
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_void,
1658
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_void,
1659
+ /*liftFunc:*/ (_v) => {},
1660
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1661
+ /*asyncOpts:*/ asyncOpts_,
1662
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1663
+ );
1664
+ } catch (__error: any) {
1665
+ if (uniffiIsDebug && __error instanceof Error) {
1666
+ __error.stack = __stack;
1667
+ }
1668
+ throw __error;
1669
+ }
1670
+ }
1671
+
1672
+ /**
1673
+ * Reuse a concurrent replacement or renew the rejected access token.
1674
+ */
1675
+ async refreshRejectedToken(staleAccessToken: string, asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
1676
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1677
+ try {
1678
+ return await uniffiRustCallAsync(
1679
+ /*rustCaller:*/ uniffiCaller,
1680
+ /*rustFutureFunc:*/ () => {
1681
+ return nativeModule().uniffi_dbx_tools_core_fn_method_providerauth_refresh_rejected_token(
1682
+ uniffiTypeProviderAuthObjectFactory.clonePointer(this),FfiConverterString.lower(staleAccessToken, nativeModule().rustbuffer_alloc)
1683
+ );
1684
+ },
1685
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1686
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1687
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1688
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1689
+ // Async returns always go through the JS-side converter: the
1690
+ // FFI symbol returns the future handle (u64), and the user-level
1691
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1692
+ // export. The bytes the runtime hands back must be deserialized
1693
+ // here using the per-callable return-type converter.
1694
+ // Borrowed view over foreign memory: the call site owns the free,
1695
+ // as on the sync paths. Unconditional — a no-op where buffers are
1696
+ // already JS-owned.
1697
+ /*liftFunc:*/ (__rb) => {
1698
+ try {
1699
+ return FfiConverterTypeAccessToken.lift(__rb);
1700
+ } finally {
1701
+ nativeModule().rustbuffer_free(__rb);
1702
+ }
1703
+ },
1704
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1705
+ /*asyncOpts:*/ asyncOpts_,
1706
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1707
+ );
1708
+ } catch (__error: any) {
1709
+ if (uniffiIsDebug && __error instanceof Error) {
1710
+ __error.stack = __stack;
1711
+ }
1712
+ throw __error;
1713
+ }
1714
+ }
1715
+
1716
+ /**
1717
+ * True forces login, false forbids interactive login, and omission permits missing-token login.
1718
+ */
1719
+ async token(login: boolean | undefined = undefined, asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
1720
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1721
+ try {
1722
+ return await uniffiRustCallAsync(
1723
+ /*rustCaller:*/ uniffiCaller,
1724
+ /*rustFutureFunc:*/ () => {
1725
+ return nativeModule().uniffi_dbx_tools_core_fn_method_providerauth_token(
1726
+ uniffiTypeProviderAuthObjectFactory.clonePointer(this),FfiConverterOptionalBoolean.lower(login, nativeModule().rustbuffer_alloc)
1727
+ );
1728
+ },
1729
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1730
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1731
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1732
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1733
+ // Async returns always go through the JS-side converter: the
1734
+ // FFI symbol returns the future handle (u64), and the user-level
1735
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1736
+ // export. The bytes the runtime hands back must be deserialized
1737
+ // here using the per-callable return-type converter.
1738
+ // Borrowed view over foreign memory: the call site owns the free,
1739
+ // as on the sync paths. Unconditional — a no-op where buffers are
1740
+ // already JS-owned.
1741
+ /*liftFunc:*/ (__rb) => {
1742
+ try {
1743
+ return FfiConverterTypeAccessToken.lift(__rb);
1744
+ } finally {
1745
+ nativeModule().rustbuffer_free(__rb);
1746
+ }
1747
+ },
1748
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1749
+ /*asyncOpts:*/ asyncOpts_,
1750
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1751
+ );
1752
+ } catch (__error: any) {
1753
+ if (uniffiIsDebug && __error instanceof Error) {
1754
+ __error.stack = __stack;
1755
+ }
1756
+ throw __error;
1757
+ }
1758
+ }
1759
+
1760
+
1761
+ uniffiDestroy(): void {
1762
+ const ptr = (this as any)[destructorGuardSymbol];
1763
+ if (ptr !== undefined) {
1764
+ const pointer = uniffiTypeProviderAuthObjectFactory.pointer(this);
1765
+ uniffiTypeProviderAuthObjectFactory.freePointer(pointer);
1766
+ uniffiTypeProviderAuthObjectFactory.unbless(ptr);
1767
+ delete (this as any)[destructorGuardSymbol];
1768
+ }
1769
+ }
1770
+
1771
+ static instanceOf(obj_: any): obj_ is ProviderAuth {
1772
+ return uniffiTypeProviderAuthObjectFactory.isConcreteType(obj_);
1773
+ }
1774
+
1775
+
1776
+ }
1777
+
1778
+ const uniffiTypeProviderAuthObjectFactory: UniffiObjectFactory<ProviderAuthLike> = (() => {
1779
+
1780
+ /// <reference lib="es2021" />
1781
+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
1782
+ uniffiTypeProviderAuthObjectFactory.freePointer(heldValue);
1783
+ }) : null;
1784
+
1785
+ return {
1786
+ create(pointer: UniffiHandle): ProviderAuthLike {
1787
+ const instance = Object.create(ProviderAuth.prototype);
1788
+ instance[pointerLiteralSymbol] = pointer;
1789
+ instance[destructorGuardSymbol] = this.bless(pointer);
1790
+ instance[uniffiTypeNameSymbol] = "ProviderAuth";
1791
+ return instance;
1792
+ },
1793
+
1794
+
1795
+ bless(p: UniffiHandle): UniffiGcObject {
1796
+ const ptr = {
1797
+ p, // make sure this object doesn't get optimized away.
1798
+ markDestroyed: () => undefined,
1799
+ };
1800
+ if (registry) {
1801
+ registry.register(ptr, p, ptr);
1802
+ }
1803
+ return ptr;
1804
+ },
1805
+
1806
+ unbless(ptr_: UniffiGcObject) {
1807
+ if (registry) {
1808
+ registry.unregister(ptr_);
1809
+ }
1810
+ },
1811
+
1812
+ pointer(obj_: ProviderAuthLike): UniffiHandle {
1813
+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {
1814
+ throw new UniffiInternalError.UnexpectedNullPointer();
1815
+ }
1816
+ return (obj_ as any)[pointerLiteralSymbol];
1817
+ },
1818
+
1819
+ clonePointer(obj_: ProviderAuthLike): UniffiHandle {
1820
+ const pointer = this.pointer(obj_);
1821
+ return uniffiCaller.rustCall(
1822
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_clone_providerauth(pointer, callStatus),
1823
+ /*liftString:*/ FfiConverterString.lift
1824
+ );
1825
+ },
1826
+
1827
+ freePointer(pointer: UniffiHandle): void {
1828
+ uniffiCaller.rustCall(
1829
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_free_providerauth(pointer, callStatus),
1830
+ /*liftString:*/ FfiConverterString.lift
1831
+ );
1832
+ },
1833
+
1834
+ isConcreteType(obj_: any): obj_ is ProviderAuthLike {
1835
+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "ProviderAuth";
1836
+ },
1837
+ }})();
1838
+ const FfiConverterTypeProviderAuth = new FfiConverterObject(uniffiTypeProviderAuthObjectFactory);
1839
+
1840
+ /**
1841
+ * Foreign-language persistence contract; implement every method in Node or Python.
1842
+ *
1843
+ * UniFFI callback interfaces do not inherit Rust default method bodies. A store
1844
+ * must explicitly implement locking and may implement `prepare_write` as a no-op
1845
+ * when writes need no preflight. Credential JSON can contain refresh tokens.
1846
+ */
1847
+ export interface StorageAdapter {
1848
+
1849
+ /**
1850
+ * Load credential JSON, returning None when the key does not exist.
1851
+ */
1852
+ load(profile: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string | undefined>;
1853
+ /**
1854
+ * Check write readiness before a provider rotates a refresh token.
1855
+ */
1856
+ prepareWrite(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1857
+ /**
1858
+ * Persist credential JSON without discarding unrelated keys.
1859
+ */
1860
+ save(profile: string, token: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1861
+ /**
1862
+ * Delete only the specified credential.
1863
+ */
1864
+ remove(profile: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1865
+ /**
1866
+ * Acquire an exclusive refresh lease or fail within the timeout.
1867
+ */
1868
+ acquireLock(profile: string, timeoutMillis: bigint, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
1869
+ /**
1870
+ * Release the lease returned by `acquire_lock`.
1871
+ */
1872
+ releaseLock(lease: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1873
+ /**
1874
+ * Return a human-readable backend identifier.
1875
+ */
1876
+ name(): string;
1877
+ }
1878
+
1879
+
1880
+ /**
1881
+ * Foreign-language persistence contract; implement every method in Node or Python.
1882
+ *
1883
+ * UniFFI callback interfaces do not inherit Rust default method bodies. A store
1884
+ * must explicitly implement locking and may implement `prepare_write` as a no-op
1885
+ * when writes need no preflight. Credential JSON can contain refresh tokens.
1886
+ */
1887
+ export class StorageAdapterImpl extends UniffiAbstractObject implements StorageAdapter {
1888
+
1889
+ readonly [uniffiTypeNameSymbol] = "StorageAdapterImpl";
1890
+ readonly [destructorGuardSymbol]: UniffiGcObject;
1891
+ readonly [pointerLiteralSymbol]: UniffiHandle;
1892
+ // No primary constructor declared for this class.
1893
+ private constructor(pointer: UniffiHandle) {
1894
+ super();
1895
+ this[pointerLiteralSymbol] = pointer;
1896
+ this[destructorGuardSymbol] = uniffiTypeStorageAdapterImplObjectFactory.bless(pointer);
1897
+ }
1898
+
1899
+
1900
+
1901
+
1902
+ /**
1903
+ * Load credential JSON, returning None when the key does not exist.
1904
+ */
1905
+ async load(profile: string, asyncOpts_?: { signal: AbortSignal }): Promise<string | undefined> /*throws*/ {
1906
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1907
+ try {
1908
+ return await uniffiRustCallAsync(
1909
+ /*rustCaller:*/ uniffiCaller,
1910
+ /*rustFutureFunc:*/ () => {
1911
+ return nativeModule().uniffi_dbx_tools_core_fn_method_storageadapter_load(
1912
+ uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc)
1913
+ );
1914
+ },
1915
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
1916
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
1917
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
1918
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
1919
+ // Async returns always go through the JS-side converter: the
1920
+ // FFI symbol returns the future handle (u64), and the user-level
1921
+ // RustBuffer comes back via the shared `rust_future_complete_*`
1922
+ // export. The bytes the runtime hands back must be deserialized
1923
+ // here using the per-callable return-type converter.
1924
+ // Borrowed view over foreign memory: the call site owns the free,
1925
+ // as on the sync paths. Unconditional — a no-op where buffers are
1926
+ // already JS-owned.
1927
+ /*liftFunc:*/ (__rb) => {
1928
+ try {
1929
+ return FfiConverterOptionalString.lift(__rb);
1930
+ } finally {
1931
+ nativeModule().rustbuffer_free(__rb);
1932
+ }
1933
+ },
1934
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1935
+ /*asyncOpts:*/ asyncOpts_,
1936
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1937
+ );
1938
+ } catch (__error: any) {
1939
+ if (uniffiIsDebug && __error instanceof Error) {
1940
+ __error.stack = __stack;
1941
+ }
1942
+ throw __error;
1943
+ }
1944
+ }
1945
+
1946
+ /**
1947
+ * Check write readiness before a provider rotates a refresh token.
1948
+ */
1949
+ async prepareWrite(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1950
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1951
+ try {
1952
+ return await uniffiRustCallAsync(
1953
+ /*rustCaller:*/ uniffiCaller,
1954
+ /*rustFutureFunc:*/ () => {
1955
+ return nativeModule().uniffi_dbx_tools_core_fn_method_storageadapter_prepare_write(
1956
+ uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this)
1957
+ );
1958
+ },
1959
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_void,
1960
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_void,
1961
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_void,
1962
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_void,
1963
+ /*liftFunc:*/ (_v) => {},
1964
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1965
+ /*asyncOpts:*/ asyncOpts_,
1966
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1967
+ );
1968
+ } catch (__error: any) {
1969
+ if (uniffiIsDebug && __error instanceof Error) {
1970
+ __error.stack = __stack;
1971
+ }
1972
+ throw __error;
1973
+ }
1974
+ }
1975
+
1976
+ /**
1977
+ * Persist credential JSON without discarding unrelated keys.
1978
+ */
1979
+ async save(profile: string, token: string, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1980
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1981
+ try {
1982
+ return await uniffiRustCallAsync(
1983
+ /*rustCaller:*/ uniffiCaller,
1984
+ /*rustFutureFunc:*/ () => {
1985
+ return nativeModule().uniffi_dbx_tools_core_fn_method_storageadapter_save(
1986
+ uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc),FfiConverterString.lower(token, nativeModule().rustbuffer_alloc)
1987
+ );
1988
+ },
1989
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_void,
1990
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_void,
1991
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_void,
1992
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_void,
1993
+ /*liftFunc:*/ (_v) => {},
1994
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
1995
+ /*asyncOpts:*/ asyncOpts_,
1996
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
1997
+ );
1998
+ } catch (__error: any) {
1999
+ if (uniffiIsDebug && __error instanceof Error) {
2000
+ __error.stack = __stack;
2001
+ }
2002
+ throw __error;
2003
+ }
2004
+ }
2005
+
2006
+ /**
2007
+ * Delete only the specified credential.
2008
+ */
2009
+ async remove(profile: string, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
2010
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
2011
+ try {
2012
+ return await uniffiRustCallAsync(
2013
+ /*rustCaller:*/ uniffiCaller,
2014
+ /*rustFutureFunc:*/ () => {
2015
+ return nativeModule().uniffi_dbx_tools_core_fn_method_storageadapter_remove(
2016
+ uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc)
2017
+ );
2018
+ },
2019
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_void,
2020
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_void,
2021
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_void,
2022
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_void,
2023
+ /*liftFunc:*/ (_v) => {},
2024
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
2025
+ /*asyncOpts:*/ asyncOpts_,
2026
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
2027
+ );
2028
+ } catch (__error: any) {
2029
+ if (uniffiIsDebug && __error instanceof Error) {
2030
+ __error.stack = __stack;
2031
+ }
2032
+ throw __error;
2033
+ }
2034
+ }
2035
+
2036
+ /**
2037
+ * Acquire an exclusive refresh lease or fail within the timeout.
2038
+ */
2039
+ async acquireLock(profile: string, timeoutMillis: bigint, asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
2040
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
2041
+ try {
2042
+ return await uniffiRustCallAsync(
2043
+ /*rustCaller:*/ uniffiCaller,
2044
+ /*rustFutureFunc:*/ () => {
2045
+ return nativeModule().uniffi_dbx_tools_core_fn_method_storageadapter_acquire_lock(
2046
+ uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc),FfiConverterUInt64.lower(timeoutMillis, nativeModule().rustbuffer_alloc)
2047
+ );
2048
+ },
2049
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_rust_buffer,
2050
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_rust_buffer,
2051
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_rust_buffer,
2052
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_rust_buffer,
2053
+ // Async returns always go through the JS-side converter: the
2054
+ // FFI symbol returns the future handle (u64), and the user-level
2055
+ // RustBuffer comes back via the shared `rust_future_complete_*`
2056
+ // export. The bytes the runtime hands back must be deserialized
2057
+ // here using the per-callable return-type converter.
2058
+ // Borrowed view over foreign memory: the call site owns the free,
2059
+ // as on the sync paths. Unconditional — a no-op where buffers are
2060
+ // already JS-owned.
2061
+ /*liftFunc:*/ (__rb) => {
2062
+ try {
2063
+ return FfiConverterString.lift(__rb);
2064
+ } finally {
2065
+ nativeModule().rustbuffer_free(__rb);
2066
+ }
2067
+ },
2068
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
2069
+ /*asyncOpts:*/ asyncOpts_,
2070
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
2071
+ );
2072
+ } catch (__error: any) {
2073
+ if (uniffiIsDebug && __error instanceof Error) {
2074
+ __error.stack = __stack;
2075
+ }
2076
+ throw __error;
2077
+ }
2078
+ }
2079
+
2080
+ /**
2081
+ * Release the lease returned by `acquire_lock`.
2082
+ */
2083
+ async releaseLock(lease: string, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
2084
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
2085
+ try {
2086
+ return await uniffiRustCallAsync(
2087
+ /*rustCaller:*/ uniffiCaller,
2088
+ /*rustFutureFunc:*/ () => {
2089
+ return nativeModule().uniffi_dbx_tools_core_fn_method_storageadapter_release_lock(
2090
+ uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(lease, nativeModule().rustbuffer_alloc)
2091
+ );
2092
+ },
2093
+ /*pollFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_poll_void,
2094
+ /*cancelFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_cancel_void,
2095
+ /*completeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_complete_void,
2096
+ /*freeFunc:*/ nativeModule().ffi_dbx_tools_core_rust_future_free_void,
2097
+ /*liftFunc:*/ (_v) => {},
2098
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
2099
+ /*asyncOpts:*/ asyncOpts_,
2100
+ /*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
2101
+ );
2102
+ } catch (__error: any) {
2103
+ if (uniffiIsDebug && __error instanceof Error) {
2104
+ __error.stack = __stack;
2105
+ }
2106
+ throw __error;
2107
+ }
2108
+ }
2109
+
2110
+ /**
2111
+ * Return a human-readable backend identifier.
2112
+ */
2113
+ name(): string {
2114
+ const __rb: Uint8Array = uniffiCaller.rustCall(
2115
+ /*caller:*/ (callStatus) => {
2116
+ return nativeModule().uniffi_dbx_tools_core_fn_method_storageadapter_name(
2117
+ uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),
2118
+ callStatus);
2119
+ },
2120
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
2121
+ );
2122
+ try {
2123
+ return FfiConverterString.lift(__rb);
2124
+ } finally {
2125
+ nativeModule().rustbuffer_free(__rb);
2126
+ }
2127
+ }
2128
+
2129
+
2130
+ uniffiDestroy(): void {
2131
+ const ptr = (this as any)[destructorGuardSymbol];
2132
+ if (ptr !== undefined) {
2133
+ const pointer = uniffiTypeStorageAdapterImplObjectFactory.pointer(this);
2134
+ uniffiTypeStorageAdapterImplObjectFactory.freePointer(pointer);
2135
+ uniffiTypeStorageAdapterImplObjectFactory.unbless(ptr);
2136
+ delete (this as any)[destructorGuardSymbol];
2137
+ }
2138
+ }
2139
+
2140
+ static instanceOf(obj_: any): obj_ is StorageAdapterImpl {
2141
+ return uniffiTypeStorageAdapterImplObjectFactory.isConcreteType(obj_);
2142
+ }
2143
+
2144
+
2145
+ }
2146
+
2147
+ const uniffiTypeStorageAdapterImplObjectFactory: UniffiObjectFactory<StorageAdapter> = (() => {
2148
+
2149
+ /// <reference lib="es2021" />
2150
+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
2151
+ uniffiTypeStorageAdapterImplObjectFactory.freePointer(heldValue);
2152
+ }) : null;
2153
+
2154
+ return {
2155
+ create(pointer: UniffiHandle): StorageAdapter {
2156
+ const instance = Object.create(StorageAdapterImpl.prototype);
2157
+ instance[pointerLiteralSymbol] = pointer;
2158
+ instance[destructorGuardSymbol] = this.bless(pointer);
2159
+ instance[uniffiTypeNameSymbol] = "StorageAdapterImpl";
2160
+ return instance;
2161
+ },
2162
+
2163
+
2164
+ bless(p: UniffiHandle): UniffiGcObject {
2165
+ const ptr = {
2166
+ p, // make sure this object doesn't get optimized away.
2167
+ markDestroyed: () => undefined,
2168
+ };
2169
+ if (registry) {
2170
+ registry.register(ptr, p, ptr);
2171
+ }
2172
+ return ptr;
2173
+ },
2174
+
2175
+ unbless(ptr_: UniffiGcObject) {
2176
+ if (registry) {
2177
+ registry.unregister(ptr_);
2178
+ }
2179
+ },
2180
+
2181
+ pointer(obj_: StorageAdapter): UniffiHandle {
2182
+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {
2183
+ throw new UniffiInternalError.UnexpectedNullPointer();
2184
+ }
2185
+ return (obj_ as any)[pointerLiteralSymbol];
2186
+ },
2187
+
2188
+ clonePointer(obj_: StorageAdapter): UniffiHandle {
2189
+ const pointer = this.pointer(obj_);
2190
+ return uniffiCaller.rustCall(
2191
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_clone_storageadapter(pointer, callStatus),
2192
+ /*liftString:*/ FfiConverterString.lift
2193
+ );
2194
+ },
2195
+
2196
+ freePointer(pointer: UniffiHandle): void {
2197
+ uniffiCaller.rustCall(
2198
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_free_storageadapter(pointer, callStatus),
2199
+ /*liftString:*/ FfiConverterString.lift
2200
+ );
2201
+ },
2202
+
2203
+ isConcreteType(obj_: any): obj_ is StorageAdapter {
2204
+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "StorageAdapterImpl";
2205
+ },
2206
+ }})();
2207
+ const FfiConverterTypeStorageAdapter = new FfiConverterObjectWithCallbacks(uniffiTypeStorageAdapterImplObjectFactory);
2208
+
2209
+ // Add a vtable for the callbacks that go in StorageAdapter.
2210
+
2211
+ // Put the implementation in a struct so we don't pollute the top-level namespace
2212
+ const uniffiCallbackInterfaceStorageAdapter: { vtable: any; register: () => void; } = {
2213
+ // Create the VTable using a series of closures.
2214
+ // ts automatically converts these into C callback functions.
2215
+ vtable: {
2216
+ load: (
2217
+ uniffiHandle: bigint,
2218
+ profile: Uint8Array,
2219
+ uniffiFutureCallback: UniffiForeignFutureCompleterustBuffer,
2220
+ uniffiCallbackData: bigint) => {
2221
+ const uniffiMakeCall =
2222
+ async (signal: AbortSignal)
2223
+ : Promise<string | undefined> => {
2224
+ const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
2225
+ return await jsCallback.load(
2226
+ FfiConverterString.lift(profile), { signal }
2227
+ )
2228
+ };
2229
+ const uniffiHandleSuccess = (returnValue: string | undefined) => {
2230
+ uniffiFutureCallback.call(
2231
+ uniffiFutureCallback,
2232
+ uniffiCallbackData,
2233
+ /* UniffiForeignFutureResultRustBuffer */{
2234
+ return_value: FfiConverterOptionalString.lower(returnValue, nativeModule().rustbuffer_alloc),
2235
+ call_status: uniffiCaller.createCallStatus()
2236
+ }
2237
+ );
2238
+ };
2239
+ const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
2240
+ uniffiFutureCallback.call(
2241
+ uniffiFutureCallback,
2242
+ uniffiCallbackData,
2243
+ /* UniffiForeignFutureResultRustBuffer */{
2244
+ return_value: /*empty*/ new Uint8Array(0),
2245
+ // TODO create callstatus with error.
2246
+ call_status: uniffiCaller.createErrorStatus(code, errorBuf),
2247
+ }
2248
+ );
2249
+ };
2250
+ const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
2251
+ /*makeCall:*/ uniffiMakeCall,
2252
+ /*handleSuccess:*/ uniffiHandleSuccess,
2253
+ /*handleError:*/ uniffiHandleError,
2254
+ /*isErrorType:*/ AuthError.instanceOf,
2255
+ /*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
2256
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2257
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
2258
+ );
2259
+ return uniffiForeignFuture;
2260
+ },
2261
+ prepare_write: (
2262
+ uniffiHandle: bigint,
2263
+ uniffiFutureCallback: UniffiForeignFutureCompletevoid,
2264
+ uniffiCallbackData: bigint) => {
2265
+ const uniffiMakeCall =
2266
+ async (signal: AbortSignal)
2267
+ : Promise<void> => {
2268
+ const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
2269
+ return await jsCallback.prepareWrite({ signal }
2270
+ )
2271
+ };
2272
+ const uniffiHandleSuccess = (returnValue: void) => {
2273
+ uniffiFutureCallback.call(
2274
+ uniffiFutureCallback,
2275
+ uniffiCallbackData,
2276
+ /* UniffiForeignFutureResultVoid */{
2277
+ call_status: uniffiCaller.createCallStatus()
2278
+ }
2279
+ );
2280
+ };
2281
+ const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
2282
+ uniffiFutureCallback.call(
2283
+ uniffiFutureCallback,
2284
+ uniffiCallbackData,
2285
+ /* UniffiForeignFutureResultVoid */{
2286
+ // TODO create callstatus with error.
2287
+ call_status: uniffiCaller.createErrorStatus(code, errorBuf),
2288
+ }
2289
+ );
2290
+ };
2291
+ const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
2292
+ /*makeCall:*/ uniffiMakeCall,
2293
+ /*handleSuccess:*/ uniffiHandleSuccess,
2294
+ /*handleError:*/ uniffiHandleError,
2295
+ /*isErrorType:*/ AuthError.instanceOf,
2296
+ /*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
2297
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2298
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
2299
+ );
2300
+ return uniffiForeignFuture;
2301
+ },
2302
+ save: (
2303
+ uniffiHandle: bigint,
2304
+ profile: Uint8Array,
2305
+ token: Uint8Array,
2306
+ uniffiFutureCallback: UniffiForeignFutureCompletevoid,
2307
+ uniffiCallbackData: bigint) => {
2308
+ const uniffiMakeCall =
2309
+ async (signal: AbortSignal)
2310
+ : Promise<void> => {
2311
+ const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
2312
+ return await jsCallback.save(
2313
+ FfiConverterString.lift(profile),
2314
+ FfiConverterString.lift(token), { signal }
2315
+ )
2316
+ };
2317
+ const uniffiHandleSuccess = (returnValue: void) => {
2318
+ uniffiFutureCallback.call(
2319
+ uniffiFutureCallback,
2320
+ uniffiCallbackData,
2321
+ /* UniffiForeignFutureResultVoid */{
2322
+ call_status: uniffiCaller.createCallStatus()
2323
+ }
2324
+ );
2325
+ };
2326
+ const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
2327
+ uniffiFutureCallback.call(
2328
+ uniffiFutureCallback,
2329
+ uniffiCallbackData,
2330
+ /* UniffiForeignFutureResultVoid */{
2331
+ // TODO create callstatus with error.
2332
+ call_status: uniffiCaller.createErrorStatus(code, errorBuf),
2333
+ }
2334
+ );
2335
+ };
2336
+ const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
2337
+ /*makeCall:*/ uniffiMakeCall,
2338
+ /*handleSuccess:*/ uniffiHandleSuccess,
2339
+ /*handleError:*/ uniffiHandleError,
2340
+ /*isErrorType:*/ AuthError.instanceOf,
2341
+ /*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
2342
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2343
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
2344
+ );
2345
+ return uniffiForeignFuture;
2346
+ },
2347
+ remove: (
2348
+ uniffiHandle: bigint,
2349
+ profile: Uint8Array,
2350
+ uniffiFutureCallback: UniffiForeignFutureCompletevoid,
2351
+ uniffiCallbackData: bigint) => {
2352
+ const uniffiMakeCall =
2353
+ async (signal: AbortSignal)
2354
+ : Promise<void> => {
2355
+ const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
2356
+ return await jsCallback.remove(
2357
+ FfiConverterString.lift(profile), { signal }
2358
+ )
2359
+ };
2360
+ const uniffiHandleSuccess = (returnValue: void) => {
2361
+ uniffiFutureCallback.call(
2362
+ uniffiFutureCallback,
2363
+ uniffiCallbackData,
2364
+ /* UniffiForeignFutureResultVoid */{
2365
+ call_status: uniffiCaller.createCallStatus()
2366
+ }
2367
+ );
2368
+ };
2369
+ const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
2370
+ uniffiFutureCallback.call(
2371
+ uniffiFutureCallback,
2372
+ uniffiCallbackData,
2373
+ /* UniffiForeignFutureResultVoid */{
2374
+ // TODO create callstatus with error.
2375
+ call_status: uniffiCaller.createErrorStatus(code, errorBuf),
2376
+ }
2377
+ );
2378
+ };
2379
+ const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
2380
+ /*makeCall:*/ uniffiMakeCall,
2381
+ /*handleSuccess:*/ uniffiHandleSuccess,
2382
+ /*handleError:*/ uniffiHandleError,
2383
+ /*isErrorType:*/ AuthError.instanceOf,
2384
+ /*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
2385
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2386
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
2387
+ );
2388
+ return uniffiForeignFuture;
2389
+ },
2390
+ acquire_lock: (
2391
+ uniffiHandle: bigint,
2392
+ profile: Uint8Array,
2393
+ timeoutMillis: bigint,
2394
+ uniffiFutureCallback: UniffiForeignFutureCompleterustBuffer,
2395
+ uniffiCallbackData: bigint) => {
2396
+ const uniffiMakeCall =
2397
+ async (signal: AbortSignal)
2398
+ : Promise<string> => {
2399
+ const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
2400
+ return await jsCallback.acquireLock(
2401
+ FfiConverterString.lift(profile),
2402
+ FfiConverterUInt64.lift(timeoutMillis), { signal }
2403
+ )
2404
+ };
2405
+ const uniffiHandleSuccess = (returnValue: string) => {
2406
+ uniffiFutureCallback.call(
2407
+ uniffiFutureCallback,
2408
+ uniffiCallbackData,
2409
+ /* UniffiForeignFutureResultRustBuffer */{
2410
+ return_value: FfiConverterString.lower(returnValue, nativeModule().rustbuffer_alloc),
2411
+ call_status: uniffiCaller.createCallStatus()
2412
+ }
2413
+ );
2414
+ };
2415
+ const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
2416
+ uniffiFutureCallback.call(
2417
+ uniffiFutureCallback,
2418
+ uniffiCallbackData,
2419
+ /* UniffiForeignFutureResultRustBuffer */{
2420
+ return_value: /*empty*/ new Uint8Array(0),
2421
+ // TODO create callstatus with error.
2422
+ call_status: uniffiCaller.createErrorStatus(code, errorBuf),
2423
+ }
2424
+ );
2425
+ };
2426
+ const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
2427
+ /*makeCall:*/ uniffiMakeCall,
2428
+ /*handleSuccess:*/ uniffiHandleSuccess,
2429
+ /*handleError:*/ uniffiHandleError,
2430
+ /*isErrorType:*/ AuthError.instanceOf,
2431
+ /*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
2432
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2433
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
2434
+ );
2435
+ return uniffiForeignFuture;
2436
+ },
2437
+ release_lock: (
2438
+ uniffiHandle: bigint,
2439
+ lease: Uint8Array,
2440
+ uniffiFutureCallback: UniffiForeignFutureCompletevoid,
2441
+ uniffiCallbackData: bigint) => {
2442
+ const uniffiMakeCall =
2443
+ async (signal: AbortSignal)
2444
+ : Promise<void> => {
2445
+ const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
2446
+ return await jsCallback.releaseLock(
2447
+ FfiConverterString.lift(lease), { signal }
2448
+ )
2449
+ };
2450
+ const uniffiHandleSuccess = (returnValue: void) => {
2451
+ uniffiFutureCallback.call(
2452
+ uniffiFutureCallback,
2453
+ uniffiCallbackData,
2454
+ /* UniffiForeignFutureResultVoid */{
2455
+ call_status: uniffiCaller.createCallStatus()
2456
+ }
2457
+ );
2458
+ };
2459
+ const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
2460
+ uniffiFutureCallback.call(
2461
+ uniffiFutureCallback,
2462
+ uniffiCallbackData,
2463
+ /* UniffiForeignFutureResultVoid */{
2464
+ // TODO create callstatus with error.
2465
+ call_status: uniffiCaller.createErrorStatus(code, errorBuf),
2466
+ }
2467
+ );
2468
+ };
2469
+ const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
2470
+ /*makeCall:*/ uniffiMakeCall,
2471
+ /*handleSuccess:*/ uniffiHandleSuccess,
2472
+ /*handleError:*/ uniffiHandleError,
2473
+ /*isErrorType:*/ AuthError.instanceOf,
2474
+ /*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
2475
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2476
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
2477
+ );
2478
+ return uniffiForeignFuture;
2479
+ },
2480
+ name: (
2481
+ uniffiHandle: bigint,) => {
2482
+ const uniffiMakeCall =
2483
+ ()
2484
+ : string => {
2485
+ const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
2486
+ return jsCallback.name(
2487
+ )
2488
+ };
2489
+ const uniffiResult = UniffiResult.ready<Uint8Array>();
2490
+ const uniffiHandleSuccess = (obj: any) => {
2491
+ UniffiResult.writeSuccess(uniffiResult, FfiConverterString.lower(obj, nativeModule().rustbuffer_alloc));
2492
+ };
2493
+ const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => {
2494
+ UniffiResult.writeError(uniffiResult, code, errBuf);
2495
+ };
2496
+ uniffiTraitInterfaceCall(
2497
+ /*makeCall:*/ uniffiMakeCall,
2498
+ /*handleSuccess:*/ uniffiHandleSuccess,
2499
+ /*handleError:*/ uniffiHandleError,
2500
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2501
+ /*alloc:*/ nativeModule().rustbuffer_alloc,
2502
+ )
2503
+ return uniffiResult;
2504
+ },
2505
+ uniffi_free: (uniffiHandle: UniffiHandle): void => {
2506
+ // this will throw a stale handle error if the handle isn't found.
2507
+ FfiConverterTypeStorageAdapter.drop(uniffiHandle);
2508
+ },
2509
+ uniffi_clone: (uniffiHandle: UniffiHandle): UniffiHandle => {
2510
+ return FfiConverterTypeStorageAdapter.clone(uniffiHandle);
2511
+ }
2512
+ },
2513
+ register: () => {nativeModule().uniffi_dbx_tools_core_fn_init_callback_vtable_storageadapter(
2514
+ uniffiCallbackInterfaceStorageAdapter.vtable
2515
+ );
2516
+ },
2517
+ };
2518
+
2519
+ /**
2520
+ * Keeps storage callbacks in the native library that owns their converters.
2521
+ */
2522
+ export interface StorageHandleLike {
2523
+
2524
+ }
2525
+ /**
2526
+ * @deprecated Use `StorageHandleLike` instead.
2527
+ */
2528
+ export type StorageHandleInterface = StorageHandleLike;
2529
+
2530
+
2531
+ /**
2532
+ * Keeps storage callbacks in the native library that owns their converters.
2533
+ */
2534
+ export class StorageHandle extends UniffiAbstractObject implements StorageHandleLike {
2535
+
2536
+ readonly [uniffiTypeNameSymbol] = "StorageHandle";
2537
+ readonly [destructorGuardSymbol]: UniffiGcObject;
2538
+ readonly [pointerLiteralSymbol]: UniffiHandle;
2539
+ // No primary constructor declared for this class.
2540
+ private constructor(pointer: UniffiHandle) {
2541
+ super();
2542
+ this[pointerLiteralSymbol] = pointer;
2543
+ this[destructorGuardSymbol] = uniffiTypeStorageHandleObjectFactory.bless(pointer);
2544
+ }
2545
+
2546
+
2547
+
2548
+
2549
+
2550
+ uniffiDestroy(): void {
2551
+ const ptr = (this as any)[destructorGuardSymbol];
2552
+ if (ptr !== undefined) {
2553
+ const pointer = uniffiTypeStorageHandleObjectFactory.pointer(this);
2554
+ uniffiTypeStorageHandleObjectFactory.freePointer(pointer);
2555
+ uniffiTypeStorageHandleObjectFactory.unbless(ptr);
2556
+ delete (this as any)[destructorGuardSymbol];
2557
+ }
2558
+ }
2559
+
2560
+ static instanceOf(obj_: any): obj_ is StorageHandle {
2561
+ return uniffiTypeStorageHandleObjectFactory.isConcreteType(obj_);
2562
+ }
2563
+
2564
+
2565
+ }
2566
+
2567
+ const uniffiTypeStorageHandleObjectFactory: UniffiObjectFactory<StorageHandleLike> = (() => {
2568
+
2569
+ /// <reference lib="es2021" />
2570
+ const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
2571
+ uniffiTypeStorageHandleObjectFactory.freePointer(heldValue);
2572
+ }) : null;
2573
+
2574
+ return {
2575
+ create(pointer: UniffiHandle): StorageHandleLike {
2576
+ const instance = Object.create(StorageHandle.prototype);
2577
+ instance[pointerLiteralSymbol] = pointer;
2578
+ instance[destructorGuardSymbol] = this.bless(pointer);
2579
+ instance[uniffiTypeNameSymbol] = "StorageHandle";
2580
+ return instance;
2581
+ },
2582
+
2583
+
2584
+ bless(p: UniffiHandle): UniffiGcObject {
2585
+ const ptr = {
2586
+ p, // make sure this object doesn't get optimized away.
2587
+ markDestroyed: () => undefined,
2588
+ };
2589
+ if (registry) {
2590
+ registry.register(ptr, p, ptr);
2591
+ }
2592
+ return ptr;
2593
+ },
2594
+
2595
+ unbless(ptr_: UniffiGcObject) {
2596
+ if (registry) {
2597
+ registry.unregister(ptr_);
2598
+ }
2599
+ },
2600
+
2601
+ pointer(obj_: StorageHandleLike): UniffiHandle {
2602
+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {
2603
+ throw new UniffiInternalError.UnexpectedNullPointer();
2604
+ }
2605
+ return (obj_ as any)[pointerLiteralSymbol];
2606
+ },
2607
+
2608
+ clonePointer(obj_: StorageHandleLike): UniffiHandle {
2609
+ const pointer = this.pointer(obj_);
2610
+ return uniffiCaller.rustCall(
2611
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_clone_storagehandle(pointer, callStatus),
2612
+ /*liftString:*/ FfiConverterString.lift
2613
+ );
2614
+ },
2615
+
2616
+ freePointer(pointer: UniffiHandle): void {
2617
+ uniffiCaller.rustCall(
2618
+ /*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_core_fn_free_storagehandle(pointer, callStatus),
2619
+ /*liftString:*/ FfiConverterString.lift
2620
+ );
2621
+ },
2622
+
2623
+ isConcreteType(obj_: any): obj_ is StorageHandleLike {
2624
+ return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "StorageHandle";
2625
+ },
2626
+ }})();
2627
+ const FfiConverterTypeStorageHandle = new FfiConverterObject(uniffiTypeStorageHandleObjectFactory);
2628
+
2629
+ // FfiConverter for string | undefined
2630
+ const FfiConverterOptionalString = new FfiConverterOptional(FfiConverterString);
2631
+
2632
+ // FfiConverter for Array<string>
2633
+ const FfiConverterSequenceString = new FfiConverterArray(FfiConverterString);
2634
+
2635
+ // FfiConverter for Array<string> | undefined
2636
+ const FfiConverterOptionalSequenceString = new FfiConverterOptional(FfiConverterSequenceString);
2637
+
2638
+ // FfiConverter for AuthOptions | undefined
2639
+ const FfiConverterOptionalTypeAuthOptions = new FfiConverterOptional(FfiConverterTypeAuthOptions);
2640
+
2641
+ // FfiConverter for Map<string, string>
2642
+ const FfiConverterMapStringString = new FfiConverterMap(FfiConverterString, FfiConverterString);
2643
+
2644
+ // FfiConverter for Map<string, string> | undefined
2645
+ const FfiConverterOptionalMapStringString = new FfiConverterOptional(FfiConverterMapStringString);
2646
+
2647
+ // FfiConverter for number | undefined
2648
+ const FfiConverterOptionalUInt16 = new FfiConverterOptional(FfiConverterUInt16);
2649
+
2650
+ // FfiConverter for SslMode | undefined
2651
+ const FfiConverterOptionalTypeSslMode = new FfiConverterOptional(FfiConverterTypeSslMode);
2652
+
2653
+ // FfiConverter for OAuthGrant | undefined
2654
+ const FfiConverterOptionalTypeOAuthGrant = new FfiConverterOptional(FfiConverterTypeOAuthGrant);
2655
+
2656
+ // FfiConverter for Storage | undefined
2657
+ const FfiConverterOptionalTypeStorage = new FfiConverterOptional(FfiConverterTypeStorage);
2658
+
2659
+ // FfiConverter for FileLayout | undefined
2660
+ const FfiConverterOptionalTypeFileLayout = new FfiConverterOptional(FfiConverterTypeFileLayout);
2661
+
2662
+ // FfiConverter for boolean | undefined
2663
+ const FfiConverterOptionalBoolean = new FfiConverterOptional(FfiConverterBool);
2664
+
2665
+
2666
+ /**
2667
+ * This should be called before anything else.
2668
+ *
2669
+ * It is likely that this is being done for you by the library's `index.ts`.
2670
+ *
2671
+ * It checks versions of uniffi between when the Rust scaffolding was generated
2672
+ * and when the bindings were generated.
2673
+ *
2674
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
2675
+ */
2676
+ function uniffiEnsureInitialized() {
2677
+ // Get the bindings contract version from our ComponentInterface
2678
+ const bindingsContractVersion = 30;
2679
+ // Get the scaffolding contract version by calling the into the dylib
2680
+ const scaffoldingContractVersion = nativeModule().ffi_dbx_tools_core_uniffi_contract_version();
2681
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
2682
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
2683
+ }
2684
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_canonical_scopes() !== 62077) {
2685
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_canonical_scopes");
2686
+ }
2687
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_create_persistent_auth() !== 18830) {
2688
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_create_persistent_auth");
2689
+ }
2690
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_create_persistent_auth_with_storage() !== 22339) {
2691
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_create_persistent_auth_with_storage");
2692
+ }
2693
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_create_provider_auth() !== 4445) {
2694
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_create_provider_auth");
2695
+ }
2696
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_create_provider_auth_with_storage() !== 46166) {
2697
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_create_provider_auth_with_storage");
2698
+ }
2699
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_create_storage_handle() !== 15610) {
2700
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_create_storage_handle");
2701
+ }
2702
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_credential_key() !== 36458) {
2703
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_credential_key");
2704
+ }
2705
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_databricks_cli_available() !== 27788) {
2706
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_databricks_cli_available");
2707
+ }
2708
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_is_databricks_app() !== 52373) {
2709
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_is_databricks_app");
2710
+ }
2711
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_parse_address() !== 9538) {
2712
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_parse_address");
2713
+ }
2714
+ if (nativeModule().uniffi_dbx_tools_core_checksum_func_parse_resource_path() !== 62884) {
2715
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_func_parse_resource_path");
2716
+ }
2717
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_persistentauth_authorization_header_for_url() !== 39071) {
2718
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_persistentauth_authorization_header_for_url");
2719
+ }
2720
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_persistentauth_challenge() !== 32194) {
2721
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_persistentauth_challenge");
2722
+ }
2723
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_persistentauth_force_refresh_token() !== 34839) {
2724
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_persistentauth_force_refresh_token");
2725
+ }
2726
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_persistentauth_logout() !== 22550) {
2727
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_persistentauth_logout");
2728
+ }
2729
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_persistentauth_refresh_rejected_token() !== 25961) {
2730
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_persistentauth_refresh_rejected_token");
2731
+ }
2732
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_persistentauth_status() !== 3099) {
2733
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_persistentauth_status");
2734
+ }
2735
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_persistentauth_token() !== 38242) {
2736
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_persistentauth_token");
2737
+ }
2738
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_providerauth_force_refresh_token() !== 12705) {
2739
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_providerauth_force_refresh_token");
2740
+ }
2741
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_providerauth_logout() !== 64726) {
2742
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_providerauth_logout");
2743
+ }
2744
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_providerauth_refresh_rejected_token() !== 47589) {
2745
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_providerauth_refresh_rejected_token");
2746
+ }
2747
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_providerauth_token() !== 37517) {
2748
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_providerauth_token");
2749
+ }
2750
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_storageadapter_load() !== 54668) {
2751
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_storageadapter_load");
2752
+ }
2753
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_storageadapter_prepare_write() !== 45067) {
2754
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_storageadapter_prepare_write");
2755
+ }
2756
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_storageadapter_save() !== 63958) {
2757
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_storageadapter_save");
2758
+ }
2759
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_storageadapter_remove() !== 16750) {
2760
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_storageadapter_remove");
2761
+ }
2762
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_storageadapter_acquire_lock() !== 64986) {
2763
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_storageadapter_acquire_lock");
2764
+ }
2765
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_storageadapter_release_lock() !== 64198) {
2766
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_storageadapter_release_lock");
2767
+ }
2768
+ if (nativeModule().uniffi_dbx_tools_core_checksum_method_storageadapter_name() !== 6080) {
2769
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_core_checksum_method_storageadapter_name");
2770
+ }
2771
+
2772
+ uniffiCallbackInterfaceStorageAdapter.register();
2773
+ }
2774
+
2775
+ export default Object.freeze({
2776
+ initialize: uniffiEnsureInitialized,
2777
+ converters: {
2778
+ FfiConverterTypeAccessToken,
2779
+ FfiConverterTypeAuthError,
2780
+ FfiConverterTypeAuthOptions,
2781
+ FfiConverterTypeDatabricksAuthOptions,
2782
+ FfiConverterTypeDatabricksAuthStatus,
2783
+ FfiConverterTypeFileLayout,
2784
+ FfiConverterTypeOAuthGrant,
2785
+ FfiConverterTypeParsedAddress,
2786
+ FfiConverterTypePersistentAuth,
2787
+ FfiConverterTypeProviderAuth,
2788
+ FfiConverterTypeProviderOptions,
2789
+ FfiConverterTypeSslMode,
2790
+ FfiConverterTypeStorage,
2791
+ FfiConverterTypeStorageAdapter,
2792
+ FfiConverterTypeStorageHandle,
2793
+ }
2794
+ });