@dbx-tools/auth 0.6.161 → 0.6.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -45
- package/index.ts +3 -4
- package/lib/index.js +1631 -7
- package/package.json +16 -40
- package/src/_bindings-ffi.ts +715 -0
- package/src/_bindings.ts +1794 -0
- package/src/bindings.ts +12 -0
- package/lib/index.d.ts +0 -5
- package/lib/src/auth.d.ts +0 -47
- package/lib/src/auth.js +0 -217
- package/lib/src/storage.d.ts +0 -31
- package/lib/src/storage.js +0 -120
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/src/auth.ts +0 -265
- package/src/storage.ts +0 -161
package/src/_bindings.ts
ADDED
|
@@ -0,0 +1,1794 @@
|
|
|
1
|
+
// GENERATED by UniFFI binding generation - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the dbx-tools-auth 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 UniffiVTableCallbackInterfaceDbxToolsAuthStorageAdapter,
|
|
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, FfiConverterObject, FfiConverterObjectWithCallbacks, FfiConverterOptional, 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_auth_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
|
+
* Construct a provider with built-in persistent storage and shared lifecycle defaults.
|
|
46
|
+
*/
|
|
47
|
+
export async function createProviderAuth(options: ProviderOptions, asyncOpts_?: { signal: AbortSignal }): Promise<ProviderAuthLike> /*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_auth_fn_func_create_provider_auth(FfiConverterTypeProviderOptions.lower(options, nativeModule().rustbuffer_alloc)
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_u64,
|
|
57
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_u64,
|
|
58
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_u64,
|
|
59
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_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:*/ FfiConverterTypeProviderAuth.lift.bind(FfiConverterTypeProviderAuth),
|
|
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
|
+
* Construct a provider from the same owning-library storage handle used by Databricks auth.
|
|
80
|
+
*/
|
|
81
|
+
export async function createProviderAuthWithStorage(options: ProviderOptions, storage: StorageHandleLike, asyncOpts_?: { signal: AbortSignal }): Promise<ProviderAuthLike> /*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_auth_fn_func_create_provider_auth_with_storage(FfiConverterTypeProviderOptions.lower(options, nativeModule().rustbuffer_alloc),FfiConverterTypeStorageHandle.lower(storage, nativeModule().rustbuffer_alloc)
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_u64,
|
|
91
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_u64,
|
|
92
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_u64,
|
|
93
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_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:*/ FfiConverterTypeProviderAuth.lift.bind(FfiConverterTypeProviderAuth),
|
|
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
|
+
* Wrap custom storage before passing it into another provider's native library.
|
|
114
|
+
*/
|
|
115
|
+
export function createStorageHandle(storage: StorageAdapter): StorageHandleLike {
|
|
116
|
+
return FfiConverterTypeStorageHandle.lift(uniffiCaller.rustCall(
|
|
117
|
+
/*caller:*/ (callStatus) => {
|
|
118
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_func_create_storage_handle(
|
|
119
|
+
FfiConverterTypeStorageAdapter.lower(storage, nativeModule().rustbuffer_alloc),
|
|
120
|
+
callStatus);
|
|
121
|
+
},
|
|
122
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
123
|
+
));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Derive a stable provider/profile/scope-set identity without storing raw scopes in the key.
|
|
128
|
+
*/
|
|
129
|
+
export function credentialKey(provider: string, profile: string | undefined, scopes: Array<string>): string {
|
|
130
|
+
const __rb: Uint8Array = uniffiCaller.rustCall(
|
|
131
|
+
/*caller:*/ (callStatus) => {
|
|
132
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_func_credential_key(
|
|
133
|
+
FfiConverterString.lower(provider, nativeModule().rustbuffer_alloc),
|
|
134
|
+
FfiConverterOptionalString.lower(profile, nativeModule().rustbuffer_alloc),
|
|
135
|
+
FfiConverterSequenceString.lower(scopes, nativeModule().rustbuffer_alloc),
|
|
136
|
+
callStatus);
|
|
137
|
+
},
|
|
138
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
139
|
+
);
|
|
140
|
+
try {
|
|
141
|
+
return FfiConverterString.lift(__rb);
|
|
142
|
+
} finally {
|
|
143
|
+
nativeModule().rustbuffer_free(__rb);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const stringConverter = (() => {
|
|
148
|
+
const encoder = new TextEncoder();
|
|
149
|
+
const decoder = new TextDecoder();
|
|
150
|
+
return {
|
|
151
|
+
stringToBytes: (s: string) => encoder.encode(s),
|
|
152
|
+
bytesToString: (ab: UniffiByteArray) => decoder.decode(ab),
|
|
153
|
+
stringByteLength: (s: string) => encoder.encode(s).byteLength,
|
|
154
|
+
writeStringIntoBuffer: (s: string, buf: any, offset: number): number => {
|
|
155
|
+
const view = new Uint8Array(
|
|
156
|
+
buf.arrayBuffer,
|
|
157
|
+
offset,
|
|
158
|
+
buf.arrayBuffer.byteLength - offset,
|
|
159
|
+
);
|
|
160
|
+
return encoder.encodeInto(s, view).written;
|
|
161
|
+
},
|
|
162
|
+
readStringFromBuffer: (buf: any, offset: number, length: number): string =>
|
|
163
|
+
decoder.decode(new Uint8Array(buf.arrayBuffer, offset, length)),
|
|
164
|
+
};
|
|
165
|
+
})();
|
|
166
|
+
const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Public credential result; deliberately excludes the refresh token.
|
|
170
|
+
*/
|
|
171
|
+
export type AccessToken = {
|
|
172
|
+
accessToken: string,
|
|
173
|
+
tokenType: string,
|
|
174
|
+
expiry?: string,
|
|
175
|
+
scopes: Array<string>
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Generated factory for {@link AccessToken} record objects.
|
|
180
|
+
*/
|
|
181
|
+
export const AccessToken = (() => {
|
|
182
|
+
const defaults = () => ({
|
|
183
|
+
});
|
|
184
|
+
const create = (() => {
|
|
185
|
+
return uniffiCreateRecord<AccessToken, ReturnType<typeof defaults>>(defaults);
|
|
186
|
+
})();
|
|
187
|
+
return Object.freeze({
|
|
188
|
+
create,
|
|
189
|
+
new: create,
|
|
190
|
+
defaults: () => Object.freeze(defaults()) as Partial<AccessToken>,
|
|
191
|
+
});
|
|
192
|
+
})();
|
|
193
|
+
|
|
194
|
+
const FfiConverterTypeAccessToken = (() => {
|
|
195
|
+
type TypeName = AccessToken;
|
|
196
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
197
|
+
readFromCursor(c: Cursor): TypeName {
|
|
198
|
+
return {
|
|
199
|
+
accessToken: FfiConverterString.readFromCursor(c),
|
|
200
|
+
tokenType: FfiConverterString.readFromCursor(c),
|
|
201
|
+
expiry: FfiConverterOptionalString.readFromCursor(c),
|
|
202
|
+
scopes: FfiConverterSequenceString.readFromCursor(c)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
206
|
+
FfiConverterString.writeIntoCursor(value.accessToken, c);
|
|
207
|
+
FfiConverterString.writeIntoCursor(value.tokenType, c);
|
|
208
|
+
FfiConverterOptionalString.writeIntoCursor(value.expiry, c);
|
|
209
|
+
FfiConverterSequenceString.writeIntoCursor(value.scopes, c);
|
|
210
|
+
}
|
|
211
|
+
allocationSize(value: TypeName): number {
|
|
212
|
+
return FfiConverterString.allocationSize(value.accessToken) +
|
|
213
|
+
FfiConverterString.allocationSize(value.tokenType) +
|
|
214
|
+
FfiConverterOptionalString.allocationSize(value.expiry) +
|
|
215
|
+
FfiConverterSequenceString.allocationSize(value.scopes);
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
return new FFIConverter();
|
|
220
|
+
})();
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Shared lifecycle configuration embedded by every provider's binding options.
|
|
224
|
+
*/
|
|
225
|
+
export type AuthOptions = {
|
|
226
|
+
/**
|
|
227
|
+
* Renew credentials this many seconds before expiry; negative values are allowed.
|
|
228
|
+
*/
|
|
229
|
+
refreshBufferSeconds: bigint,
|
|
230
|
+
/**
|
|
231
|
+
* Maximum time spent waiting for the credential store's refresh lock.
|
|
232
|
+
*/
|
|
233
|
+
lockTimeoutSeconds: bigint,
|
|
234
|
+
/**
|
|
235
|
+
* Maximum time allowed for a new interactive login.
|
|
236
|
+
*/
|
|
237
|
+
loginTimeoutSeconds: bigint,
|
|
238
|
+
/**
|
|
239
|
+
* Logo URL or data URI displayed by the browser callback page.
|
|
240
|
+
*/
|
|
241
|
+
callbackImageSrc?: string
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Generated factory for {@link AuthOptions} record objects.
|
|
246
|
+
*/
|
|
247
|
+
export const AuthOptions = (() => {
|
|
248
|
+
const defaults = () => ({
|
|
249
|
+
refreshBufferSeconds: BigInt("300"),
|
|
250
|
+
lockTimeoutSeconds: BigInt("30"),
|
|
251
|
+
loginTimeoutSeconds: BigInt("3600"),
|
|
252
|
+
callbackImageSrc: undefined
|
|
253
|
+
});
|
|
254
|
+
const create = (() => {
|
|
255
|
+
return uniffiCreateRecord<AuthOptions, ReturnType<typeof defaults>>(defaults);
|
|
256
|
+
})();
|
|
257
|
+
return Object.freeze({
|
|
258
|
+
create,
|
|
259
|
+
new: create,
|
|
260
|
+
defaults: () => Object.freeze(defaults()) as Partial<AuthOptions>,
|
|
261
|
+
});
|
|
262
|
+
})();
|
|
263
|
+
|
|
264
|
+
const FfiConverterTypeAuthOptions = (() => {
|
|
265
|
+
type TypeName = AuthOptions;
|
|
266
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
267
|
+
readFromCursor(c: Cursor): TypeName {
|
|
268
|
+
return {
|
|
269
|
+
refreshBufferSeconds: FfiConverterInt64.readFromCursor(c),
|
|
270
|
+
lockTimeoutSeconds: FfiConverterUInt64.readFromCursor(c),
|
|
271
|
+
loginTimeoutSeconds: FfiConverterUInt64.readFromCursor(c),
|
|
272
|
+
callbackImageSrc: FfiConverterOptionalString.readFromCursor(c)
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
276
|
+
FfiConverterInt64.writeIntoCursor(value.refreshBufferSeconds, c);
|
|
277
|
+
FfiConverterUInt64.writeIntoCursor(value.lockTimeoutSeconds, c);
|
|
278
|
+
FfiConverterUInt64.writeIntoCursor(value.loginTimeoutSeconds, c);
|
|
279
|
+
FfiConverterOptionalString.writeIntoCursor(value.callbackImageSrc, c);
|
|
280
|
+
}
|
|
281
|
+
allocationSize(value: TypeName): number {
|
|
282
|
+
return FfiConverterInt64.allocationSize(value.refreshBufferSeconds) +
|
|
283
|
+
FfiConverterUInt64.allocationSize(value.lockTimeoutSeconds) +
|
|
284
|
+
FfiConverterUInt64.allocationSize(value.loginTimeoutSeconds) +
|
|
285
|
+
FfiConverterOptionalString.allocationSize(value.callbackImageSrc);
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
return new FFIConverter();
|
|
290
|
+
})();
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* OAuth grant used to acquire and renew credentials.
|
|
294
|
+
*/
|
|
295
|
+
export enum OAuthGrant {
|
|
296
|
+
AuthorizationCode,
|
|
297
|
+
ClientCredentials
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const FfiConverterTypeOAuthGrant = (() => {
|
|
301
|
+
type TypeName = OAuthGrant;
|
|
302
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
303
|
+
readFromCursor(c: Cursor): TypeName {
|
|
304
|
+
switch (c.readI32()) {
|
|
305
|
+
case 1: return OAuthGrant.AuthorizationCode;
|
|
306
|
+
case 2: return OAuthGrant.ClientCredentials;
|
|
307
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
311
|
+
switch (value) {
|
|
312
|
+
case OAuthGrant.AuthorizationCode: return c.writeI32(1);
|
|
313
|
+
case OAuthGrant.ClientCredentials: return c.writeI32(2);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
allocationSize(value: TypeName): number {
|
|
317
|
+
return 4;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return new FFIConverter();
|
|
321
|
+
})();
|
|
322
|
+
|
|
323
|
+
export enum Storage {
|
|
324
|
+
Auto,
|
|
325
|
+
Memory,
|
|
326
|
+
File
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const FfiConverterTypeStorage = (() => {
|
|
330
|
+
type TypeName = Storage;
|
|
331
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
332
|
+
readFromCursor(c: Cursor): TypeName {
|
|
333
|
+
switch (c.readI32()) {
|
|
334
|
+
case 1: return Storage.Auto;
|
|
335
|
+
case 2: return Storage.Memory;
|
|
336
|
+
case 3: return Storage.File;
|
|
337
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
341
|
+
switch (value) {
|
|
342
|
+
case Storage.Auto: return c.writeI32(1);
|
|
343
|
+
case Storage.Memory: return c.writeI32(2);
|
|
344
|
+
case Storage.File: return c.writeI32(3);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
allocationSize(value: TypeName): number {
|
|
348
|
+
return 4;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return new FFIConverter();
|
|
352
|
+
})();
|
|
353
|
+
|
|
354
|
+
export enum FileLayout {
|
|
355
|
+
Single,
|
|
356
|
+
PerCredential
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const FfiConverterTypeFileLayout = (() => {
|
|
360
|
+
type TypeName = FileLayout;
|
|
361
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
362
|
+
readFromCursor(c: Cursor): TypeName {
|
|
363
|
+
switch (c.readI32()) {
|
|
364
|
+
case 1: return FileLayout.Single;
|
|
365
|
+
case 2: return FileLayout.PerCredential;
|
|
366
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
370
|
+
switch (value) {
|
|
371
|
+
case FileLayout.Single: return c.writeI32(1);
|
|
372
|
+
case FileLayout.PerCredential: return c.writeI32(2);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
allocationSize(value: TypeName): number {
|
|
376
|
+
return 4;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return new FFIConverter();
|
|
380
|
+
})();
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Provider-specific OAuth identity, endpoints, storage, and shared lifecycle options.
|
|
384
|
+
*/
|
|
385
|
+
export type ProviderOptions = {
|
|
386
|
+
/**
|
|
387
|
+
* Stable provider identity used to isolate stored credentials.
|
|
388
|
+
*/
|
|
389
|
+
provider: string,
|
|
390
|
+
/**
|
|
391
|
+
* OAuth application identifier.
|
|
392
|
+
*/
|
|
393
|
+
clientId: string,
|
|
394
|
+
/**
|
|
395
|
+
* Provider's token exchange endpoint.
|
|
396
|
+
*/
|
|
397
|
+
tokenEndpoint: string,
|
|
398
|
+
/**
|
|
399
|
+
* Required browser authorization endpoint for authorization-code grants.
|
|
400
|
+
*/
|
|
401
|
+
authorizationEndpoint?: string,
|
|
402
|
+
/**
|
|
403
|
+
* Secret for confidential clients; never returned in access-token results.
|
|
404
|
+
*/
|
|
405
|
+
clientSecret?: string,
|
|
406
|
+
/**
|
|
407
|
+
* Optional namespace for multiple accounts under one provider.
|
|
408
|
+
*/
|
|
409
|
+
profile?: string,
|
|
410
|
+
/**
|
|
411
|
+
* Requested scopes, trimmed, sorted, and deduplicated before use.
|
|
412
|
+
*/
|
|
413
|
+
scopes: Array<string>,
|
|
414
|
+
/**
|
|
415
|
+
* Defaults to authorization code with PKCE when omitted.
|
|
416
|
+
*/
|
|
417
|
+
grant?: OAuthGrant,
|
|
418
|
+
/**
|
|
419
|
+
* Override the provider-neutral credential directory.
|
|
420
|
+
*/
|
|
421
|
+
cacheDir?: string,
|
|
422
|
+
/**
|
|
423
|
+
* Select a built-in store; omission uses file storage.
|
|
424
|
+
*/
|
|
425
|
+
storage?: Storage,
|
|
426
|
+
/**
|
|
427
|
+
* Select a shared cache file or independent credential files.
|
|
428
|
+
*/
|
|
429
|
+
fileLayout?: FileLayout,
|
|
430
|
+
/**
|
|
431
|
+
* Shared lifecycle configuration; omission uses `AuthOptions::default()`.
|
|
432
|
+
*/
|
|
433
|
+
auth?: AuthOptions
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Generated factory for {@link ProviderOptions} record objects.
|
|
438
|
+
*/
|
|
439
|
+
export const ProviderOptions = (() => {
|
|
440
|
+
const defaults = () => ({
|
|
441
|
+
authorizationEndpoint: undefined,
|
|
442
|
+
clientSecret: undefined,
|
|
443
|
+
profile: undefined,
|
|
444
|
+
scopes: [],
|
|
445
|
+
grant: undefined,
|
|
446
|
+
cacheDir: undefined,
|
|
447
|
+
storage: undefined,
|
|
448
|
+
fileLayout: undefined,
|
|
449
|
+
auth: undefined
|
|
450
|
+
});
|
|
451
|
+
const create = (() => {
|
|
452
|
+
return uniffiCreateRecord<ProviderOptions, ReturnType<typeof defaults>>(defaults);
|
|
453
|
+
})();
|
|
454
|
+
return Object.freeze({
|
|
455
|
+
create,
|
|
456
|
+
new: create,
|
|
457
|
+
defaults: () => Object.freeze(defaults()) as Partial<ProviderOptions>,
|
|
458
|
+
});
|
|
459
|
+
})();
|
|
460
|
+
|
|
461
|
+
const FfiConverterTypeProviderOptions = (() => {
|
|
462
|
+
type TypeName = ProviderOptions;
|
|
463
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
464
|
+
readFromCursor(c: Cursor): TypeName {
|
|
465
|
+
return {
|
|
466
|
+
provider: FfiConverterString.readFromCursor(c),
|
|
467
|
+
clientId: FfiConverterString.readFromCursor(c),
|
|
468
|
+
tokenEndpoint: FfiConverterString.readFromCursor(c),
|
|
469
|
+
authorizationEndpoint: FfiConverterOptionalString.readFromCursor(c),
|
|
470
|
+
clientSecret: FfiConverterOptionalString.readFromCursor(c),
|
|
471
|
+
profile: FfiConverterOptionalString.readFromCursor(c),
|
|
472
|
+
scopes: FfiConverterSequenceString.readFromCursor(c),
|
|
473
|
+
grant: FfiConverterOptionalTypeOAuthGrant.readFromCursor(c),
|
|
474
|
+
cacheDir: FfiConverterOptionalString.readFromCursor(c),
|
|
475
|
+
storage: FfiConverterOptionalTypeStorage.readFromCursor(c),
|
|
476
|
+
fileLayout: FfiConverterOptionalTypeFileLayout.readFromCursor(c),
|
|
477
|
+
auth: FfiConverterOptionalTypeAuthOptions.readFromCursor(c)
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
481
|
+
FfiConverterString.writeIntoCursor(value.provider, c);
|
|
482
|
+
FfiConverterString.writeIntoCursor(value.clientId, c);
|
|
483
|
+
FfiConverterString.writeIntoCursor(value.tokenEndpoint, c);
|
|
484
|
+
FfiConverterOptionalString.writeIntoCursor(value.authorizationEndpoint, c);
|
|
485
|
+
FfiConverterOptionalString.writeIntoCursor(value.clientSecret, c);
|
|
486
|
+
FfiConverterOptionalString.writeIntoCursor(value.profile, c);
|
|
487
|
+
FfiConverterSequenceString.writeIntoCursor(value.scopes, c);
|
|
488
|
+
FfiConverterOptionalTypeOAuthGrant.writeIntoCursor(value.grant, c);
|
|
489
|
+
FfiConverterOptionalString.writeIntoCursor(value.cacheDir, c);
|
|
490
|
+
FfiConverterOptionalTypeStorage.writeIntoCursor(value.storage, c);
|
|
491
|
+
FfiConverterOptionalTypeFileLayout.writeIntoCursor(value.fileLayout, c);
|
|
492
|
+
FfiConverterOptionalTypeAuthOptions.writeIntoCursor(value.auth, c);
|
|
493
|
+
}
|
|
494
|
+
allocationSize(value: TypeName): number {
|
|
495
|
+
return FfiConverterString.allocationSize(value.provider) +
|
|
496
|
+
FfiConverterString.allocationSize(value.clientId) +
|
|
497
|
+
FfiConverterString.allocationSize(value.tokenEndpoint) +
|
|
498
|
+
FfiConverterOptionalString.allocationSize(value.authorizationEndpoint) +
|
|
499
|
+
FfiConverterOptionalString.allocationSize(value.clientSecret) +
|
|
500
|
+
FfiConverterOptionalString.allocationSize(value.profile) +
|
|
501
|
+
FfiConverterSequenceString.allocationSize(value.scopes) +
|
|
502
|
+
FfiConverterOptionalTypeOAuthGrant.allocationSize(value.grant) +
|
|
503
|
+
FfiConverterOptionalString.allocationSize(value.cacheDir) +
|
|
504
|
+
FfiConverterOptionalTypeStorage.allocationSize(value.storage) +
|
|
505
|
+
FfiConverterOptionalTypeFileLayout.allocationSize(value.fileLayout) +
|
|
506
|
+
FfiConverterOptionalTypeAuthOptions.allocationSize(value.auth);
|
|
507
|
+
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
return new FFIConverter();
|
|
511
|
+
})();
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
// Error type: AuthError
|
|
515
|
+
export enum AuthError_Tags {
|
|
516
|
+
Failure = "Failure"
|
|
517
|
+
}
|
|
518
|
+
export const AuthError = (() => {
|
|
519
|
+
|
|
520
|
+
type Failure__interface = {
|
|
521
|
+
tag: AuthError_Tags.Failure;
|
|
522
|
+
inner:
|
|
523
|
+
Readonly<{message: string}>
|
|
524
|
+
};
|
|
525
|
+
class Failure_ extends UniffiError implements Failure__interface {
|
|
526
|
+
/**
|
|
527
|
+
* @private
|
|
528
|
+
* This field is private and should not be used, use `tag` instead.
|
|
529
|
+
*/
|
|
530
|
+
readonly [uniffiTypeNameSymbol] = "AuthError";
|
|
531
|
+
readonly tag = AuthError_Tags.Failure;
|
|
532
|
+
readonly inner:
|
|
533
|
+
Readonly<{message: string}>;
|
|
534
|
+
constructor(
|
|
535
|
+
inner: {message: string }) {
|
|
536
|
+
super("AuthError", "Failure");
|
|
537
|
+
|
|
538
|
+
this.inner = Object.freeze(inner);
|
|
539
|
+
}
|
|
540
|
+
static new(
|
|
541
|
+
inner: {message: string }): Failure_ {
|
|
542
|
+
return new Failure_(inner);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
static instanceOf(obj: any): obj is Failure_ {
|
|
546
|
+
return obj.tag === AuthError_Tags.Failure;
|
|
547
|
+
}
|
|
548
|
+
static hasInner(obj: any): obj is Failure_ {
|
|
549
|
+
return Failure_.instanceOf(obj);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
static getInner(obj: Failure_):
|
|
553
|
+
Readonly<{message: string}> {
|
|
554
|
+
return obj.inner;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function instanceOf(obj: any): obj is AuthError {
|
|
560
|
+
return obj[uniffiTypeNameSymbol] === "AuthError";
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return Object.freeze({
|
|
564
|
+
instanceOf,
|
|
565
|
+
Failure: Failure_
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
})();
|
|
569
|
+
export type AuthError = InstanceType<
|
|
570
|
+
typeof AuthError['Failure']
|
|
571
|
+
>;
|
|
572
|
+
|
|
573
|
+
// FfiConverter for enum AuthError
|
|
574
|
+
const FfiConverterTypeAuthError = (() => {
|
|
575
|
+
type TypeName = AuthError;
|
|
576
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
577
|
+
readFromCursor(c: Cursor): TypeName {
|
|
578
|
+
switch (c.readI32()) {
|
|
579
|
+
case 1: return new AuthError.Failure({message: FfiConverterString.readFromCursor(c) });
|
|
580
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
writeIntoCursor(value: TypeName, c: Cursor): void {
|
|
584
|
+
switch (value.tag) {
|
|
585
|
+
case AuthError_Tags.Failure: {
|
|
586
|
+
c.writeI32(1);
|
|
587
|
+
const inner = value.inner;
|
|
588
|
+
FfiConverterString.writeIntoCursor(inner.message, c);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
default:
|
|
592
|
+
// Throwing from here means that AuthError_Tags hasn't matched an ordinal.
|
|
593
|
+
throw new UniffiInternalError.UnexpectedEnumCase();
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
allocationSize(value: TypeName): number {
|
|
597
|
+
switch (value.tag) {
|
|
598
|
+
case AuthError_Tags.Failure: {
|
|
599
|
+
const inner = value.inner;
|
|
600
|
+
let size = 4;
|
|
601
|
+
size += FfiConverterString.allocationSize(inner.message);
|
|
602
|
+
return size;
|
|
603
|
+
}
|
|
604
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return new FFIConverter();
|
|
609
|
+
})();
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Generic OAuth provider using the shared persistent credential lifecycle.
|
|
613
|
+
*/
|
|
614
|
+
export interface ProviderAuthLike {
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Renew the credential even if it has not entered its refresh window.
|
|
618
|
+
*/
|
|
619
|
+
forceRefreshToken(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
|
|
620
|
+
/**
|
|
621
|
+
* Delete the stored credential while holding its refresh lock.
|
|
622
|
+
*/
|
|
623
|
+
logout(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
|
|
624
|
+
/**
|
|
625
|
+
* Reuse a concurrent replacement or renew the rejected access token.
|
|
626
|
+
*/
|
|
627
|
+
refreshRejectedToken(staleAccessToken: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
|
|
628
|
+
/**
|
|
629
|
+
* True forces login, false forbids interactive login, and omission permits missing-token login.
|
|
630
|
+
*/
|
|
631
|
+
token(login?: boolean | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<AccessToken>;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* @deprecated Use `ProviderAuthLike` instead.
|
|
635
|
+
*/
|
|
636
|
+
export type ProviderAuthInterface = ProviderAuthLike;
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Generic OAuth provider using the shared persistent credential lifecycle.
|
|
641
|
+
*/
|
|
642
|
+
export class ProviderAuth extends UniffiAbstractObject implements ProviderAuthLike {
|
|
643
|
+
|
|
644
|
+
readonly [uniffiTypeNameSymbol] = "ProviderAuth";
|
|
645
|
+
readonly [destructorGuardSymbol]: UniffiGcObject;
|
|
646
|
+
readonly [pointerLiteralSymbol]: UniffiHandle;
|
|
647
|
+
// No primary constructor declared for this class.
|
|
648
|
+
private constructor(pointer: UniffiHandle) {
|
|
649
|
+
super();
|
|
650
|
+
this[pointerLiteralSymbol] = pointer;
|
|
651
|
+
this[destructorGuardSymbol] = uniffiTypeProviderAuthObjectFactory.bless(pointer);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Renew the credential even if it has not entered its refresh window.
|
|
659
|
+
*/
|
|
660
|
+
async forceRefreshToken(asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
|
|
661
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
662
|
+
try {
|
|
663
|
+
return await uniffiRustCallAsync(
|
|
664
|
+
/*rustCaller:*/ uniffiCaller,
|
|
665
|
+
/*rustFutureFunc:*/ () => {
|
|
666
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_providerauth_force_refresh_token(
|
|
667
|
+
uniffiTypeProviderAuthObjectFactory.clonePointer(this)
|
|
668
|
+
);
|
|
669
|
+
},
|
|
670
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_rust_buffer,
|
|
671
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_rust_buffer,
|
|
672
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_rust_buffer,
|
|
673
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_rust_buffer,
|
|
674
|
+
// Async returns always go through the JS-side converter: the
|
|
675
|
+
// FFI symbol returns the future handle (u64), and the user-level
|
|
676
|
+
// RustBuffer comes back via the shared `rust_future_complete_*`
|
|
677
|
+
// export. The bytes the runtime hands back must be deserialized
|
|
678
|
+
// here using the per-callable return-type converter.
|
|
679
|
+
// Borrowed view over foreign memory: the call site owns the free,
|
|
680
|
+
// as on the sync paths. Unconditional — a no-op where buffers are
|
|
681
|
+
// already JS-owned.
|
|
682
|
+
/*liftFunc:*/ (__rb) => {
|
|
683
|
+
try {
|
|
684
|
+
return FfiConverterTypeAccessToken.lift(__rb);
|
|
685
|
+
} finally {
|
|
686
|
+
nativeModule().rustbuffer_free(__rb);
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
690
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
691
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
692
|
+
);
|
|
693
|
+
} catch (__error: any) {
|
|
694
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
695
|
+
__error.stack = __stack;
|
|
696
|
+
}
|
|
697
|
+
throw __error;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Delete the stored credential while holding its refresh lock.
|
|
703
|
+
*/
|
|
704
|
+
async logout(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
|
|
705
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
706
|
+
try {
|
|
707
|
+
return await uniffiRustCallAsync(
|
|
708
|
+
/*rustCaller:*/ uniffiCaller,
|
|
709
|
+
/*rustFutureFunc:*/ () => {
|
|
710
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_providerauth_logout(
|
|
711
|
+
uniffiTypeProviderAuthObjectFactory.clonePointer(this)
|
|
712
|
+
);
|
|
713
|
+
},
|
|
714
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_void,
|
|
715
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_void,
|
|
716
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_void,
|
|
717
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_void,
|
|
718
|
+
/*liftFunc:*/ (_v) => {},
|
|
719
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
720
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
721
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
722
|
+
);
|
|
723
|
+
} catch (__error: any) {
|
|
724
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
725
|
+
__error.stack = __stack;
|
|
726
|
+
}
|
|
727
|
+
throw __error;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Reuse a concurrent replacement or renew the rejected access token.
|
|
733
|
+
*/
|
|
734
|
+
async refreshRejectedToken(staleAccessToken: string, asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
|
|
735
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
736
|
+
try {
|
|
737
|
+
return await uniffiRustCallAsync(
|
|
738
|
+
/*rustCaller:*/ uniffiCaller,
|
|
739
|
+
/*rustFutureFunc:*/ () => {
|
|
740
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_providerauth_refresh_rejected_token(
|
|
741
|
+
uniffiTypeProviderAuthObjectFactory.clonePointer(this),FfiConverterString.lower(staleAccessToken, nativeModule().rustbuffer_alloc)
|
|
742
|
+
);
|
|
743
|
+
},
|
|
744
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_rust_buffer,
|
|
745
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_rust_buffer,
|
|
746
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_rust_buffer,
|
|
747
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_rust_buffer,
|
|
748
|
+
// Async returns always go through the JS-side converter: the
|
|
749
|
+
// FFI symbol returns the future handle (u64), and the user-level
|
|
750
|
+
// RustBuffer comes back via the shared `rust_future_complete_*`
|
|
751
|
+
// export. The bytes the runtime hands back must be deserialized
|
|
752
|
+
// here using the per-callable return-type converter.
|
|
753
|
+
// Borrowed view over foreign memory: the call site owns the free,
|
|
754
|
+
// as on the sync paths. Unconditional — a no-op where buffers are
|
|
755
|
+
// already JS-owned.
|
|
756
|
+
/*liftFunc:*/ (__rb) => {
|
|
757
|
+
try {
|
|
758
|
+
return FfiConverterTypeAccessToken.lift(__rb);
|
|
759
|
+
} finally {
|
|
760
|
+
nativeModule().rustbuffer_free(__rb);
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
764
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
765
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
766
|
+
);
|
|
767
|
+
} catch (__error: any) {
|
|
768
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
769
|
+
__error.stack = __stack;
|
|
770
|
+
}
|
|
771
|
+
throw __error;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* True forces login, false forbids interactive login, and omission permits missing-token login.
|
|
777
|
+
*/
|
|
778
|
+
async token(login: boolean | undefined = undefined, asyncOpts_?: { signal: AbortSignal }): Promise<AccessToken> /*throws*/ {
|
|
779
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
780
|
+
try {
|
|
781
|
+
return await uniffiRustCallAsync(
|
|
782
|
+
/*rustCaller:*/ uniffiCaller,
|
|
783
|
+
/*rustFutureFunc:*/ () => {
|
|
784
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_providerauth_token(
|
|
785
|
+
uniffiTypeProviderAuthObjectFactory.clonePointer(this),FfiConverterOptionalBoolean.lower(login, nativeModule().rustbuffer_alloc)
|
|
786
|
+
);
|
|
787
|
+
},
|
|
788
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_rust_buffer,
|
|
789
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_rust_buffer,
|
|
790
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_rust_buffer,
|
|
791
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_rust_buffer,
|
|
792
|
+
// Async returns always go through the JS-side converter: the
|
|
793
|
+
// FFI symbol returns the future handle (u64), and the user-level
|
|
794
|
+
// RustBuffer comes back via the shared `rust_future_complete_*`
|
|
795
|
+
// export. The bytes the runtime hands back must be deserialized
|
|
796
|
+
// here using the per-callable return-type converter.
|
|
797
|
+
// Borrowed view over foreign memory: the call site owns the free,
|
|
798
|
+
// as on the sync paths. Unconditional — a no-op where buffers are
|
|
799
|
+
// already JS-owned.
|
|
800
|
+
/*liftFunc:*/ (__rb) => {
|
|
801
|
+
try {
|
|
802
|
+
return FfiConverterTypeAccessToken.lift(__rb);
|
|
803
|
+
} finally {
|
|
804
|
+
nativeModule().rustbuffer_free(__rb);
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
808
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
809
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
810
|
+
);
|
|
811
|
+
} catch (__error: any) {
|
|
812
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
813
|
+
__error.stack = __stack;
|
|
814
|
+
}
|
|
815
|
+
throw __error;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
uniffiDestroy(): void {
|
|
821
|
+
const ptr = (this as any)[destructorGuardSymbol];
|
|
822
|
+
if (ptr !== undefined) {
|
|
823
|
+
const pointer = uniffiTypeProviderAuthObjectFactory.pointer(this);
|
|
824
|
+
uniffiTypeProviderAuthObjectFactory.freePointer(pointer);
|
|
825
|
+
uniffiTypeProviderAuthObjectFactory.unbless(ptr);
|
|
826
|
+
delete (this as any)[destructorGuardSymbol];
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
static instanceOf(obj_: any): obj_ is ProviderAuth {
|
|
831
|
+
return uniffiTypeProviderAuthObjectFactory.isConcreteType(obj_);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
const uniffiTypeProviderAuthObjectFactory: UniffiObjectFactory<ProviderAuthLike> = (() => {
|
|
838
|
+
|
|
839
|
+
/// <reference lib="es2021" />
|
|
840
|
+
const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
|
|
841
|
+
uniffiTypeProviderAuthObjectFactory.freePointer(heldValue);
|
|
842
|
+
}) : null;
|
|
843
|
+
|
|
844
|
+
return {
|
|
845
|
+
create(pointer: UniffiHandle): ProviderAuthLike {
|
|
846
|
+
const instance = Object.create(ProviderAuth.prototype);
|
|
847
|
+
instance[pointerLiteralSymbol] = pointer;
|
|
848
|
+
instance[destructorGuardSymbol] = this.bless(pointer);
|
|
849
|
+
instance[uniffiTypeNameSymbol] = "ProviderAuth";
|
|
850
|
+
return instance;
|
|
851
|
+
},
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
bless(p: UniffiHandle): UniffiGcObject {
|
|
855
|
+
const ptr = {
|
|
856
|
+
p, // make sure this object doesn't get optimized away.
|
|
857
|
+
markDestroyed: () => undefined,
|
|
858
|
+
};
|
|
859
|
+
if (registry) {
|
|
860
|
+
registry.register(ptr, p, ptr);
|
|
861
|
+
}
|
|
862
|
+
return ptr;
|
|
863
|
+
},
|
|
864
|
+
|
|
865
|
+
unbless(ptr_: UniffiGcObject) {
|
|
866
|
+
if (registry) {
|
|
867
|
+
registry.unregister(ptr_);
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
|
|
871
|
+
pointer(obj_: ProviderAuthLike): UniffiHandle {
|
|
872
|
+
if ((obj_ as any)[destructorGuardSymbol] === undefined) {
|
|
873
|
+
throw new UniffiInternalError.UnexpectedNullPointer();
|
|
874
|
+
}
|
|
875
|
+
return (obj_ as any)[pointerLiteralSymbol];
|
|
876
|
+
},
|
|
877
|
+
|
|
878
|
+
clonePointer(obj_: ProviderAuthLike): UniffiHandle {
|
|
879
|
+
const pointer = this.pointer(obj_);
|
|
880
|
+
return uniffiCaller.rustCall(
|
|
881
|
+
/*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_auth_fn_clone_providerauth(pointer, callStatus),
|
|
882
|
+
/*liftString:*/ FfiConverterString.lift
|
|
883
|
+
);
|
|
884
|
+
},
|
|
885
|
+
|
|
886
|
+
freePointer(pointer: UniffiHandle): void {
|
|
887
|
+
uniffiCaller.rustCall(
|
|
888
|
+
/*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_auth_fn_free_providerauth(pointer, callStatus),
|
|
889
|
+
/*liftString:*/ FfiConverterString.lift
|
|
890
|
+
);
|
|
891
|
+
},
|
|
892
|
+
|
|
893
|
+
isConcreteType(obj_: any): obj_ is ProviderAuthLike {
|
|
894
|
+
return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "ProviderAuth";
|
|
895
|
+
},
|
|
896
|
+
}})();
|
|
897
|
+
const FfiConverterTypeProviderAuth = new FfiConverterObject(uniffiTypeProviderAuthObjectFactory);
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Foreign-language persistence contract; implement every method in Node or Python.
|
|
901
|
+
*
|
|
902
|
+
* UniFFI callback interfaces do not inherit Rust default method bodies. A store
|
|
903
|
+
* must explicitly implement locking and may implement `prepare_write` as a no-op
|
|
904
|
+
* when writes need no preflight. Credential JSON can contain refresh tokens.
|
|
905
|
+
*/
|
|
906
|
+
export interface StorageAdapter {
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Load credential JSON, returning None when the key does not exist.
|
|
910
|
+
*/
|
|
911
|
+
load(profile: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string | undefined>;
|
|
912
|
+
/**
|
|
913
|
+
* Check write readiness before a provider rotates a refresh token.
|
|
914
|
+
*/
|
|
915
|
+
prepareWrite(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
|
|
916
|
+
/**
|
|
917
|
+
* Persist credential JSON without discarding unrelated keys.
|
|
918
|
+
*/
|
|
919
|
+
save(profile: string, token: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
|
|
920
|
+
/**
|
|
921
|
+
* Delete only the specified credential.
|
|
922
|
+
*/
|
|
923
|
+
remove(profile: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
|
|
924
|
+
/**
|
|
925
|
+
* Acquire an exclusive refresh lease or fail within the timeout.
|
|
926
|
+
*/
|
|
927
|
+
acquireLock(profile: string, timeoutMillis: bigint, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
|
|
928
|
+
/**
|
|
929
|
+
* Release the lease returned by `acquire_lock`.
|
|
930
|
+
*/
|
|
931
|
+
releaseLock(lease: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
|
|
932
|
+
/**
|
|
933
|
+
* Return a human-readable backend identifier.
|
|
934
|
+
*/
|
|
935
|
+
name(): string;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Foreign-language persistence contract; implement every method in Node or Python.
|
|
941
|
+
*
|
|
942
|
+
* UniFFI callback interfaces do not inherit Rust default method bodies. A store
|
|
943
|
+
* must explicitly implement locking and may implement `prepare_write` as a no-op
|
|
944
|
+
* when writes need no preflight. Credential JSON can contain refresh tokens.
|
|
945
|
+
*/
|
|
946
|
+
export class StorageAdapterImpl extends UniffiAbstractObject implements StorageAdapter {
|
|
947
|
+
|
|
948
|
+
readonly [uniffiTypeNameSymbol] = "StorageAdapterImpl";
|
|
949
|
+
readonly [destructorGuardSymbol]: UniffiGcObject;
|
|
950
|
+
readonly [pointerLiteralSymbol]: UniffiHandle;
|
|
951
|
+
// No primary constructor declared for this class.
|
|
952
|
+
private constructor(pointer: UniffiHandle) {
|
|
953
|
+
super();
|
|
954
|
+
this[pointerLiteralSymbol] = pointer;
|
|
955
|
+
this[destructorGuardSymbol] = uniffiTypeStorageAdapterImplObjectFactory.bless(pointer);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Load credential JSON, returning None when the key does not exist.
|
|
963
|
+
*/
|
|
964
|
+
async load(profile: string, asyncOpts_?: { signal: AbortSignal }): Promise<string | undefined> /*throws*/ {
|
|
965
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
966
|
+
try {
|
|
967
|
+
return await uniffiRustCallAsync(
|
|
968
|
+
/*rustCaller:*/ uniffiCaller,
|
|
969
|
+
/*rustFutureFunc:*/ () => {
|
|
970
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_storageadapter_load(
|
|
971
|
+
uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc)
|
|
972
|
+
);
|
|
973
|
+
},
|
|
974
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_rust_buffer,
|
|
975
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_rust_buffer,
|
|
976
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_rust_buffer,
|
|
977
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_rust_buffer,
|
|
978
|
+
// Async returns always go through the JS-side converter: the
|
|
979
|
+
// FFI symbol returns the future handle (u64), and the user-level
|
|
980
|
+
// RustBuffer comes back via the shared `rust_future_complete_*`
|
|
981
|
+
// export. The bytes the runtime hands back must be deserialized
|
|
982
|
+
// here using the per-callable return-type converter.
|
|
983
|
+
// Borrowed view over foreign memory: the call site owns the free,
|
|
984
|
+
// as on the sync paths. Unconditional — a no-op where buffers are
|
|
985
|
+
// already JS-owned.
|
|
986
|
+
/*liftFunc:*/ (__rb) => {
|
|
987
|
+
try {
|
|
988
|
+
return FfiConverterOptionalString.lift(__rb);
|
|
989
|
+
} finally {
|
|
990
|
+
nativeModule().rustbuffer_free(__rb);
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
994
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
995
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
996
|
+
);
|
|
997
|
+
} catch (__error: any) {
|
|
998
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
999
|
+
__error.stack = __stack;
|
|
1000
|
+
}
|
|
1001
|
+
throw __error;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* Check write readiness before a provider rotates a refresh token.
|
|
1007
|
+
*/
|
|
1008
|
+
async prepareWrite(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
|
|
1009
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
1010
|
+
try {
|
|
1011
|
+
return await uniffiRustCallAsync(
|
|
1012
|
+
/*rustCaller:*/ uniffiCaller,
|
|
1013
|
+
/*rustFutureFunc:*/ () => {
|
|
1014
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_storageadapter_prepare_write(
|
|
1015
|
+
uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this)
|
|
1016
|
+
);
|
|
1017
|
+
},
|
|
1018
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_void,
|
|
1019
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_void,
|
|
1020
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_void,
|
|
1021
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_void,
|
|
1022
|
+
/*liftFunc:*/ (_v) => {},
|
|
1023
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
1024
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
1025
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
1026
|
+
);
|
|
1027
|
+
} catch (__error: any) {
|
|
1028
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
1029
|
+
__error.stack = __stack;
|
|
1030
|
+
}
|
|
1031
|
+
throw __error;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Persist credential JSON without discarding unrelated keys.
|
|
1037
|
+
*/
|
|
1038
|
+
async save(profile: string, token: string, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
|
|
1039
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
1040
|
+
try {
|
|
1041
|
+
return await uniffiRustCallAsync(
|
|
1042
|
+
/*rustCaller:*/ uniffiCaller,
|
|
1043
|
+
/*rustFutureFunc:*/ () => {
|
|
1044
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_storageadapter_save(
|
|
1045
|
+
uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc),FfiConverterString.lower(token, nativeModule().rustbuffer_alloc)
|
|
1046
|
+
);
|
|
1047
|
+
},
|
|
1048
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_void,
|
|
1049
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_void,
|
|
1050
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_void,
|
|
1051
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_void,
|
|
1052
|
+
/*liftFunc:*/ (_v) => {},
|
|
1053
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
1054
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
1055
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
1056
|
+
);
|
|
1057
|
+
} catch (__error: any) {
|
|
1058
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
1059
|
+
__error.stack = __stack;
|
|
1060
|
+
}
|
|
1061
|
+
throw __error;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Delete only the specified credential.
|
|
1067
|
+
*/
|
|
1068
|
+
async remove(profile: string, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
|
|
1069
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
1070
|
+
try {
|
|
1071
|
+
return await uniffiRustCallAsync(
|
|
1072
|
+
/*rustCaller:*/ uniffiCaller,
|
|
1073
|
+
/*rustFutureFunc:*/ () => {
|
|
1074
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_storageadapter_remove(
|
|
1075
|
+
uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc)
|
|
1076
|
+
);
|
|
1077
|
+
},
|
|
1078
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_void,
|
|
1079
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_void,
|
|
1080
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_void,
|
|
1081
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_void,
|
|
1082
|
+
/*liftFunc:*/ (_v) => {},
|
|
1083
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
1084
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
1085
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
1086
|
+
);
|
|
1087
|
+
} catch (__error: any) {
|
|
1088
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
1089
|
+
__error.stack = __stack;
|
|
1090
|
+
}
|
|
1091
|
+
throw __error;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* Acquire an exclusive refresh lease or fail within the timeout.
|
|
1097
|
+
*/
|
|
1098
|
+
async acquireLock(profile: string, timeoutMillis: bigint, asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
|
|
1099
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
1100
|
+
try {
|
|
1101
|
+
return await uniffiRustCallAsync(
|
|
1102
|
+
/*rustCaller:*/ uniffiCaller,
|
|
1103
|
+
/*rustFutureFunc:*/ () => {
|
|
1104
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_storageadapter_acquire_lock(
|
|
1105
|
+
uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(profile, nativeModule().rustbuffer_alloc),FfiConverterUInt64.lower(timeoutMillis, nativeModule().rustbuffer_alloc)
|
|
1106
|
+
);
|
|
1107
|
+
},
|
|
1108
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_rust_buffer,
|
|
1109
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_rust_buffer,
|
|
1110
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_rust_buffer,
|
|
1111
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_rust_buffer,
|
|
1112
|
+
// Async returns always go through the JS-side converter: the
|
|
1113
|
+
// FFI symbol returns the future handle (u64), and the user-level
|
|
1114
|
+
// RustBuffer comes back via the shared `rust_future_complete_*`
|
|
1115
|
+
// export. The bytes the runtime hands back must be deserialized
|
|
1116
|
+
// here using the per-callable return-type converter.
|
|
1117
|
+
// Borrowed view over foreign memory: the call site owns the free,
|
|
1118
|
+
// as on the sync paths. Unconditional — a no-op where buffers are
|
|
1119
|
+
// already JS-owned.
|
|
1120
|
+
/*liftFunc:*/ (__rb) => {
|
|
1121
|
+
try {
|
|
1122
|
+
return FfiConverterString.lift(__rb);
|
|
1123
|
+
} finally {
|
|
1124
|
+
nativeModule().rustbuffer_free(__rb);
|
|
1125
|
+
}
|
|
1126
|
+
},
|
|
1127
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
1128
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
1129
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
1130
|
+
);
|
|
1131
|
+
} catch (__error: any) {
|
|
1132
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
1133
|
+
__error.stack = __stack;
|
|
1134
|
+
}
|
|
1135
|
+
throw __error;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* Release the lease returned by `acquire_lock`.
|
|
1141
|
+
*/
|
|
1142
|
+
async releaseLock(lease: string, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
|
|
1143
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
1144
|
+
try {
|
|
1145
|
+
return await uniffiRustCallAsync(
|
|
1146
|
+
/*rustCaller:*/ uniffiCaller,
|
|
1147
|
+
/*rustFutureFunc:*/ () => {
|
|
1148
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_storageadapter_release_lock(
|
|
1149
|
+
uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),FfiConverterString.lower(lease, nativeModule().rustbuffer_alloc)
|
|
1150
|
+
);
|
|
1151
|
+
},
|
|
1152
|
+
/*pollFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_poll_void,
|
|
1153
|
+
/*cancelFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_cancel_void,
|
|
1154
|
+
/*completeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_complete_void,
|
|
1155
|
+
/*freeFunc:*/ nativeModule().ffi_dbx_tools_auth_rust_future_free_void,
|
|
1156
|
+
/*liftFunc:*/ (_v) => {},
|
|
1157
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
1158
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
1159
|
+
/*errorHandler:*/ FfiConverterTypeAuthError.lift.bind(FfiConverterTypeAuthError)
|
|
1160
|
+
);
|
|
1161
|
+
} catch (__error: any) {
|
|
1162
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
1163
|
+
__error.stack = __stack;
|
|
1164
|
+
}
|
|
1165
|
+
throw __error;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* Return a human-readable backend identifier.
|
|
1171
|
+
*/
|
|
1172
|
+
name(): string {
|
|
1173
|
+
const __rb: Uint8Array = uniffiCaller.rustCall(
|
|
1174
|
+
/*caller:*/ (callStatus) => {
|
|
1175
|
+
return nativeModule().uniffi_dbx_tools_auth_fn_method_storageadapter_name(
|
|
1176
|
+
uniffiTypeStorageAdapterImplObjectFactory.clonePointer(this),
|
|
1177
|
+
callStatus);
|
|
1178
|
+
},
|
|
1179
|
+
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
|
|
1180
|
+
);
|
|
1181
|
+
try {
|
|
1182
|
+
return FfiConverterString.lift(__rb);
|
|
1183
|
+
} finally {
|
|
1184
|
+
nativeModule().rustbuffer_free(__rb);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
uniffiDestroy(): void {
|
|
1190
|
+
const ptr = (this as any)[destructorGuardSymbol];
|
|
1191
|
+
if (ptr !== undefined) {
|
|
1192
|
+
const pointer = uniffiTypeStorageAdapterImplObjectFactory.pointer(this);
|
|
1193
|
+
uniffiTypeStorageAdapterImplObjectFactory.freePointer(pointer);
|
|
1194
|
+
uniffiTypeStorageAdapterImplObjectFactory.unbless(ptr);
|
|
1195
|
+
delete (this as any)[destructorGuardSymbol];
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
static instanceOf(obj_: any): obj_ is StorageAdapterImpl {
|
|
1200
|
+
return uniffiTypeStorageAdapterImplObjectFactory.isConcreteType(obj_);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
const uniffiTypeStorageAdapterImplObjectFactory: UniffiObjectFactory<StorageAdapter> = (() => {
|
|
1207
|
+
|
|
1208
|
+
/// <reference lib="es2021" />
|
|
1209
|
+
const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
|
|
1210
|
+
uniffiTypeStorageAdapterImplObjectFactory.freePointer(heldValue);
|
|
1211
|
+
}) : null;
|
|
1212
|
+
|
|
1213
|
+
return {
|
|
1214
|
+
create(pointer: UniffiHandle): StorageAdapter {
|
|
1215
|
+
const instance = Object.create(StorageAdapterImpl.prototype);
|
|
1216
|
+
instance[pointerLiteralSymbol] = pointer;
|
|
1217
|
+
instance[destructorGuardSymbol] = this.bless(pointer);
|
|
1218
|
+
instance[uniffiTypeNameSymbol] = "StorageAdapterImpl";
|
|
1219
|
+
return instance;
|
|
1220
|
+
},
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
bless(p: UniffiHandle): UniffiGcObject {
|
|
1224
|
+
const ptr = {
|
|
1225
|
+
p, // make sure this object doesn't get optimized away.
|
|
1226
|
+
markDestroyed: () => undefined,
|
|
1227
|
+
};
|
|
1228
|
+
if (registry) {
|
|
1229
|
+
registry.register(ptr, p, ptr);
|
|
1230
|
+
}
|
|
1231
|
+
return ptr;
|
|
1232
|
+
},
|
|
1233
|
+
|
|
1234
|
+
unbless(ptr_: UniffiGcObject) {
|
|
1235
|
+
if (registry) {
|
|
1236
|
+
registry.unregister(ptr_);
|
|
1237
|
+
}
|
|
1238
|
+
},
|
|
1239
|
+
|
|
1240
|
+
pointer(obj_: StorageAdapter): UniffiHandle {
|
|
1241
|
+
if ((obj_ as any)[destructorGuardSymbol] === undefined) {
|
|
1242
|
+
throw new UniffiInternalError.UnexpectedNullPointer();
|
|
1243
|
+
}
|
|
1244
|
+
return (obj_ as any)[pointerLiteralSymbol];
|
|
1245
|
+
},
|
|
1246
|
+
|
|
1247
|
+
clonePointer(obj_: StorageAdapter): UniffiHandle {
|
|
1248
|
+
const pointer = this.pointer(obj_);
|
|
1249
|
+
return uniffiCaller.rustCall(
|
|
1250
|
+
/*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_auth_fn_clone_storageadapter(pointer, callStatus),
|
|
1251
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1252
|
+
);
|
|
1253
|
+
},
|
|
1254
|
+
|
|
1255
|
+
freePointer(pointer: UniffiHandle): void {
|
|
1256
|
+
uniffiCaller.rustCall(
|
|
1257
|
+
/*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_auth_fn_free_storageadapter(pointer, callStatus),
|
|
1258
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1259
|
+
);
|
|
1260
|
+
},
|
|
1261
|
+
|
|
1262
|
+
isConcreteType(obj_: any): obj_ is StorageAdapter {
|
|
1263
|
+
return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "StorageAdapterImpl";
|
|
1264
|
+
},
|
|
1265
|
+
}})();
|
|
1266
|
+
const FfiConverterTypeStorageAdapter = new FfiConverterObjectWithCallbacks(uniffiTypeStorageAdapterImplObjectFactory);
|
|
1267
|
+
|
|
1268
|
+
// Add a vtable for the callbacks that go in StorageAdapter.
|
|
1269
|
+
|
|
1270
|
+
// Put the implementation in a struct so we don't pollute the top-level namespace
|
|
1271
|
+
const uniffiCallbackInterfaceStorageAdapter: { vtable: any; register: () => void; } = {
|
|
1272
|
+
// Create the VTable using a series of closures.
|
|
1273
|
+
// ts automatically converts these into C callback functions.
|
|
1274
|
+
vtable: {
|
|
1275
|
+
load: (
|
|
1276
|
+
uniffiHandle: bigint,
|
|
1277
|
+
profile: Uint8Array,
|
|
1278
|
+
uniffiFutureCallback: UniffiForeignFutureCompleterustBuffer,
|
|
1279
|
+
uniffiCallbackData: bigint) => {
|
|
1280
|
+
const uniffiMakeCall =
|
|
1281
|
+
async (signal: AbortSignal)
|
|
1282
|
+
: Promise<string | undefined> => {
|
|
1283
|
+
const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
|
|
1284
|
+
return await jsCallback.load(
|
|
1285
|
+
FfiConverterString.lift(profile), { signal }
|
|
1286
|
+
)
|
|
1287
|
+
};
|
|
1288
|
+
const uniffiHandleSuccess = (returnValue: string | undefined) => {
|
|
1289
|
+
uniffiFutureCallback.call(
|
|
1290
|
+
uniffiFutureCallback,
|
|
1291
|
+
uniffiCallbackData,
|
|
1292
|
+
/* UniffiForeignFutureResultRustBuffer */{
|
|
1293
|
+
return_value: FfiConverterOptionalString.lower(returnValue, nativeModule().rustbuffer_alloc),
|
|
1294
|
+
call_status: uniffiCaller.createCallStatus()
|
|
1295
|
+
}
|
|
1296
|
+
);
|
|
1297
|
+
};
|
|
1298
|
+
const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
|
|
1299
|
+
uniffiFutureCallback.call(
|
|
1300
|
+
uniffiFutureCallback,
|
|
1301
|
+
uniffiCallbackData,
|
|
1302
|
+
/* UniffiForeignFutureResultRustBuffer */{
|
|
1303
|
+
return_value: /*empty*/ new Uint8Array(0),
|
|
1304
|
+
// TODO create callstatus with error.
|
|
1305
|
+
call_status: uniffiCaller.createErrorStatus(code, errorBuf),
|
|
1306
|
+
}
|
|
1307
|
+
);
|
|
1308
|
+
};
|
|
1309
|
+
const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
|
|
1310
|
+
/*makeCall:*/ uniffiMakeCall,
|
|
1311
|
+
/*handleSuccess:*/ uniffiHandleSuccess,
|
|
1312
|
+
/*handleError:*/ uniffiHandleError,
|
|
1313
|
+
/*isErrorType:*/ AuthError.instanceOf,
|
|
1314
|
+
/*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
|
|
1315
|
+
/*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
|
|
1316
|
+
/*alloc:*/ nativeModule().rustbuffer_alloc,
|
|
1317
|
+
);
|
|
1318
|
+
return uniffiForeignFuture;
|
|
1319
|
+
},
|
|
1320
|
+
prepare_write: (
|
|
1321
|
+
uniffiHandle: bigint,
|
|
1322
|
+
uniffiFutureCallback: UniffiForeignFutureCompletevoid,
|
|
1323
|
+
uniffiCallbackData: bigint) => {
|
|
1324
|
+
const uniffiMakeCall =
|
|
1325
|
+
async (signal: AbortSignal)
|
|
1326
|
+
: Promise<void> => {
|
|
1327
|
+
const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
|
|
1328
|
+
return await jsCallback.prepareWrite({ signal }
|
|
1329
|
+
)
|
|
1330
|
+
};
|
|
1331
|
+
const uniffiHandleSuccess = (returnValue: void) => {
|
|
1332
|
+
uniffiFutureCallback.call(
|
|
1333
|
+
uniffiFutureCallback,
|
|
1334
|
+
uniffiCallbackData,
|
|
1335
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1336
|
+
call_status: uniffiCaller.createCallStatus()
|
|
1337
|
+
}
|
|
1338
|
+
);
|
|
1339
|
+
};
|
|
1340
|
+
const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
|
|
1341
|
+
uniffiFutureCallback.call(
|
|
1342
|
+
uniffiFutureCallback,
|
|
1343
|
+
uniffiCallbackData,
|
|
1344
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1345
|
+
// TODO create callstatus with error.
|
|
1346
|
+
call_status: uniffiCaller.createErrorStatus(code, errorBuf),
|
|
1347
|
+
}
|
|
1348
|
+
);
|
|
1349
|
+
};
|
|
1350
|
+
const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
|
|
1351
|
+
/*makeCall:*/ uniffiMakeCall,
|
|
1352
|
+
/*handleSuccess:*/ uniffiHandleSuccess,
|
|
1353
|
+
/*handleError:*/ uniffiHandleError,
|
|
1354
|
+
/*isErrorType:*/ AuthError.instanceOf,
|
|
1355
|
+
/*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
|
|
1356
|
+
/*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
|
|
1357
|
+
/*alloc:*/ nativeModule().rustbuffer_alloc,
|
|
1358
|
+
);
|
|
1359
|
+
return uniffiForeignFuture;
|
|
1360
|
+
},
|
|
1361
|
+
save: (
|
|
1362
|
+
uniffiHandle: bigint,
|
|
1363
|
+
profile: Uint8Array,
|
|
1364
|
+
token: Uint8Array,
|
|
1365
|
+
uniffiFutureCallback: UniffiForeignFutureCompletevoid,
|
|
1366
|
+
uniffiCallbackData: bigint) => {
|
|
1367
|
+
const uniffiMakeCall =
|
|
1368
|
+
async (signal: AbortSignal)
|
|
1369
|
+
: Promise<void> => {
|
|
1370
|
+
const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
|
|
1371
|
+
return await jsCallback.save(
|
|
1372
|
+
FfiConverterString.lift(profile),
|
|
1373
|
+
FfiConverterString.lift(token), { signal }
|
|
1374
|
+
)
|
|
1375
|
+
};
|
|
1376
|
+
const uniffiHandleSuccess = (returnValue: void) => {
|
|
1377
|
+
uniffiFutureCallback.call(
|
|
1378
|
+
uniffiFutureCallback,
|
|
1379
|
+
uniffiCallbackData,
|
|
1380
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1381
|
+
call_status: uniffiCaller.createCallStatus()
|
|
1382
|
+
}
|
|
1383
|
+
);
|
|
1384
|
+
};
|
|
1385
|
+
const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
|
|
1386
|
+
uniffiFutureCallback.call(
|
|
1387
|
+
uniffiFutureCallback,
|
|
1388
|
+
uniffiCallbackData,
|
|
1389
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1390
|
+
// TODO create callstatus with error.
|
|
1391
|
+
call_status: uniffiCaller.createErrorStatus(code, errorBuf),
|
|
1392
|
+
}
|
|
1393
|
+
);
|
|
1394
|
+
};
|
|
1395
|
+
const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
|
|
1396
|
+
/*makeCall:*/ uniffiMakeCall,
|
|
1397
|
+
/*handleSuccess:*/ uniffiHandleSuccess,
|
|
1398
|
+
/*handleError:*/ uniffiHandleError,
|
|
1399
|
+
/*isErrorType:*/ AuthError.instanceOf,
|
|
1400
|
+
/*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
|
|
1401
|
+
/*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
|
|
1402
|
+
/*alloc:*/ nativeModule().rustbuffer_alloc,
|
|
1403
|
+
);
|
|
1404
|
+
return uniffiForeignFuture;
|
|
1405
|
+
},
|
|
1406
|
+
remove: (
|
|
1407
|
+
uniffiHandle: bigint,
|
|
1408
|
+
profile: Uint8Array,
|
|
1409
|
+
uniffiFutureCallback: UniffiForeignFutureCompletevoid,
|
|
1410
|
+
uniffiCallbackData: bigint) => {
|
|
1411
|
+
const uniffiMakeCall =
|
|
1412
|
+
async (signal: AbortSignal)
|
|
1413
|
+
: Promise<void> => {
|
|
1414
|
+
const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
|
|
1415
|
+
return await jsCallback.remove(
|
|
1416
|
+
FfiConverterString.lift(profile), { signal }
|
|
1417
|
+
)
|
|
1418
|
+
};
|
|
1419
|
+
const uniffiHandleSuccess = (returnValue: void) => {
|
|
1420
|
+
uniffiFutureCallback.call(
|
|
1421
|
+
uniffiFutureCallback,
|
|
1422
|
+
uniffiCallbackData,
|
|
1423
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1424
|
+
call_status: uniffiCaller.createCallStatus()
|
|
1425
|
+
}
|
|
1426
|
+
);
|
|
1427
|
+
};
|
|
1428
|
+
const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
|
|
1429
|
+
uniffiFutureCallback.call(
|
|
1430
|
+
uniffiFutureCallback,
|
|
1431
|
+
uniffiCallbackData,
|
|
1432
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1433
|
+
// TODO create callstatus with error.
|
|
1434
|
+
call_status: uniffiCaller.createErrorStatus(code, errorBuf),
|
|
1435
|
+
}
|
|
1436
|
+
);
|
|
1437
|
+
};
|
|
1438
|
+
const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
|
|
1439
|
+
/*makeCall:*/ uniffiMakeCall,
|
|
1440
|
+
/*handleSuccess:*/ uniffiHandleSuccess,
|
|
1441
|
+
/*handleError:*/ uniffiHandleError,
|
|
1442
|
+
/*isErrorType:*/ AuthError.instanceOf,
|
|
1443
|
+
/*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
|
|
1444
|
+
/*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
|
|
1445
|
+
/*alloc:*/ nativeModule().rustbuffer_alloc,
|
|
1446
|
+
);
|
|
1447
|
+
return uniffiForeignFuture;
|
|
1448
|
+
},
|
|
1449
|
+
acquire_lock: (
|
|
1450
|
+
uniffiHandle: bigint,
|
|
1451
|
+
profile: Uint8Array,
|
|
1452
|
+
timeoutMillis: bigint,
|
|
1453
|
+
uniffiFutureCallback: UniffiForeignFutureCompleterustBuffer,
|
|
1454
|
+
uniffiCallbackData: bigint) => {
|
|
1455
|
+
const uniffiMakeCall =
|
|
1456
|
+
async (signal: AbortSignal)
|
|
1457
|
+
: Promise<string> => {
|
|
1458
|
+
const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
|
|
1459
|
+
return await jsCallback.acquireLock(
|
|
1460
|
+
FfiConverterString.lift(profile),
|
|
1461
|
+
FfiConverterUInt64.lift(timeoutMillis), { signal }
|
|
1462
|
+
)
|
|
1463
|
+
};
|
|
1464
|
+
const uniffiHandleSuccess = (returnValue: string) => {
|
|
1465
|
+
uniffiFutureCallback.call(
|
|
1466
|
+
uniffiFutureCallback,
|
|
1467
|
+
uniffiCallbackData,
|
|
1468
|
+
/* UniffiForeignFutureResultRustBuffer */{
|
|
1469
|
+
return_value: FfiConverterString.lower(returnValue, nativeModule().rustbuffer_alloc),
|
|
1470
|
+
call_status: uniffiCaller.createCallStatus()
|
|
1471
|
+
}
|
|
1472
|
+
);
|
|
1473
|
+
};
|
|
1474
|
+
const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
|
|
1475
|
+
uniffiFutureCallback.call(
|
|
1476
|
+
uniffiFutureCallback,
|
|
1477
|
+
uniffiCallbackData,
|
|
1478
|
+
/* UniffiForeignFutureResultRustBuffer */{
|
|
1479
|
+
return_value: /*empty*/ new Uint8Array(0),
|
|
1480
|
+
// TODO create callstatus with error.
|
|
1481
|
+
call_status: uniffiCaller.createErrorStatus(code, errorBuf),
|
|
1482
|
+
}
|
|
1483
|
+
);
|
|
1484
|
+
};
|
|
1485
|
+
const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
|
|
1486
|
+
/*makeCall:*/ uniffiMakeCall,
|
|
1487
|
+
/*handleSuccess:*/ uniffiHandleSuccess,
|
|
1488
|
+
/*handleError:*/ uniffiHandleError,
|
|
1489
|
+
/*isErrorType:*/ AuthError.instanceOf,
|
|
1490
|
+
/*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
|
|
1491
|
+
/*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
|
|
1492
|
+
/*alloc:*/ nativeModule().rustbuffer_alloc,
|
|
1493
|
+
);
|
|
1494
|
+
return uniffiForeignFuture;
|
|
1495
|
+
},
|
|
1496
|
+
release_lock: (
|
|
1497
|
+
uniffiHandle: bigint,
|
|
1498
|
+
lease: Uint8Array,
|
|
1499
|
+
uniffiFutureCallback: UniffiForeignFutureCompletevoid,
|
|
1500
|
+
uniffiCallbackData: bigint) => {
|
|
1501
|
+
const uniffiMakeCall =
|
|
1502
|
+
async (signal: AbortSignal)
|
|
1503
|
+
: Promise<void> => {
|
|
1504
|
+
const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
|
|
1505
|
+
return await jsCallback.releaseLock(
|
|
1506
|
+
FfiConverterString.lift(lease), { signal }
|
|
1507
|
+
)
|
|
1508
|
+
};
|
|
1509
|
+
const uniffiHandleSuccess = (returnValue: void) => {
|
|
1510
|
+
uniffiFutureCallback.call(
|
|
1511
|
+
uniffiFutureCallback,
|
|
1512
|
+
uniffiCallbackData,
|
|
1513
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1514
|
+
call_status: uniffiCaller.createCallStatus()
|
|
1515
|
+
}
|
|
1516
|
+
);
|
|
1517
|
+
};
|
|
1518
|
+
const uniffiHandleError = (code: number, errorBuf: UniffiByteArray) => {
|
|
1519
|
+
uniffiFutureCallback.call(
|
|
1520
|
+
uniffiFutureCallback,
|
|
1521
|
+
uniffiCallbackData,
|
|
1522
|
+
/* UniffiForeignFutureResultVoid */{
|
|
1523
|
+
// TODO create callstatus with error.
|
|
1524
|
+
call_status: uniffiCaller.createErrorStatus(code, errorBuf),
|
|
1525
|
+
}
|
|
1526
|
+
);
|
|
1527
|
+
};
|
|
1528
|
+
const uniffiForeignFuture = uniffiTraitInterfaceCallAsyncWithError(
|
|
1529
|
+
/*makeCall:*/ uniffiMakeCall,
|
|
1530
|
+
/*handleSuccess:*/ uniffiHandleSuccess,
|
|
1531
|
+
/*handleError:*/ uniffiHandleError,
|
|
1532
|
+
/*isErrorType:*/ AuthError.instanceOf,
|
|
1533
|
+
/*lowerError:*/ FfiConverterTypeAuthError.lower.bind(FfiConverterTypeAuthError),
|
|
1534
|
+
/*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
|
|
1535
|
+
/*alloc:*/ nativeModule().rustbuffer_alloc,
|
|
1536
|
+
);
|
|
1537
|
+
return uniffiForeignFuture;
|
|
1538
|
+
},
|
|
1539
|
+
name: (
|
|
1540
|
+
uniffiHandle: bigint,) => {
|
|
1541
|
+
const uniffiMakeCall =
|
|
1542
|
+
()
|
|
1543
|
+
: string => {
|
|
1544
|
+
const jsCallback = FfiConverterTypeStorageAdapter.lift(uniffiHandle);
|
|
1545
|
+
return jsCallback.name(
|
|
1546
|
+
)
|
|
1547
|
+
};
|
|
1548
|
+
const uniffiResult = UniffiResult.ready<Uint8Array>();
|
|
1549
|
+
const uniffiHandleSuccess = (obj: any) => {
|
|
1550
|
+
UniffiResult.writeSuccess(uniffiResult, FfiConverterString.lower(obj, nativeModule().rustbuffer_alloc));
|
|
1551
|
+
};
|
|
1552
|
+
const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => {
|
|
1553
|
+
UniffiResult.writeError(uniffiResult, code, errBuf);
|
|
1554
|
+
};
|
|
1555
|
+
uniffiTraitInterfaceCall(
|
|
1556
|
+
/*makeCall:*/ uniffiMakeCall,
|
|
1557
|
+
/*handleSuccess:*/ uniffiHandleSuccess,
|
|
1558
|
+
/*handleError:*/ uniffiHandleError,
|
|
1559
|
+
/*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
|
|
1560
|
+
/*alloc:*/ nativeModule().rustbuffer_alloc,
|
|
1561
|
+
)
|
|
1562
|
+
return uniffiResult;
|
|
1563
|
+
},
|
|
1564
|
+
uniffi_free: (uniffiHandle: UniffiHandle): void => {
|
|
1565
|
+
// this will throw a stale handle error if the handle isn't found.
|
|
1566
|
+
FfiConverterTypeStorageAdapter.drop(uniffiHandle);
|
|
1567
|
+
},
|
|
1568
|
+
uniffi_clone: (uniffiHandle: UniffiHandle): UniffiHandle => {
|
|
1569
|
+
return FfiConverterTypeStorageAdapter.clone(uniffiHandle);
|
|
1570
|
+
}
|
|
1571
|
+
},
|
|
1572
|
+
register: () => {nativeModule().uniffi_dbx_tools_auth_fn_init_callback_vtable_storageadapter(
|
|
1573
|
+
uniffiCallbackInterfaceStorageAdapter.vtable
|
|
1574
|
+
);
|
|
1575
|
+
},
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Keeps storage callbacks in the native library that owns their converters.
|
|
1580
|
+
*/
|
|
1581
|
+
export interface StorageHandleLike {
|
|
1582
|
+
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* @deprecated Use `StorageHandleLike` instead.
|
|
1586
|
+
*/
|
|
1587
|
+
export type StorageHandleInterface = StorageHandleLike;
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Keeps storage callbacks in the native library that owns their converters.
|
|
1592
|
+
*/
|
|
1593
|
+
export class StorageHandle extends UniffiAbstractObject implements StorageHandleLike {
|
|
1594
|
+
|
|
1595
|
+
readonly [uniffiTypeNameSymbol] = "StorageHandle";
|
|
1596
|
+
readonly [destructorGuardSymbol]: UniffiGcObject;
|
|
1597
|
+
readonly [pointerLiteralSymbol]: UniffiHandle;
|
|
1598
|
+
// No primary constructor declared for this class.
|
|
1599
|
+
private constructor(pointer: UniffiHandle) {
|
|
1600
|
+
super();
|
|
1601
|
+
this[pointerLiteralSymbol] = pointer;
|
|
1602
|
+
this[destructorGuardSymbol] = uniffiTypeStorageHandleObjectFactory.bless(pointer);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
uniffiDestroy(): void {
|
|
1610
|
+
const ptr = (this as any)[destructorGuardSymbol];
|
|
1611
|
+
if (ptr !== undefined) {
|
|
1612
|
+
const pointer = uniffiTypeStorageHandleObjectFactory.pointer(this);
|
|
1613
|
+
uniffiTypeStorageHandleObjectFactory.freePointer(pointer);
|
|
1614
|
+
uniffiTypeStorageHandleObjectFactory.unbless(ptr);
|
|
1615
|
+
delete (this as any)[destructorGuardSymbol];
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
static instanceOf(obj_: any): obj_ is StorageHandle {
|
|
1620
|
+
return uniffiTypeStorageHandleObjectFactory.isConcreteType(obj_);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
const uniffiTypeStorageHandleObjectFactory: UniffiObjectFactory<StorageHandleLike> = (() => {
|
|
1627
|
+
|
|
1628
|
+
/// <reference lib="es2021" />
|
|
1629
|
+
const registry = typeof FinalizationRegistry !== 'undefined' ? new FinalizationRegistry<UniffiHandle>((heldValue: UniffiHandle) => {
|
|
1630
|
+
uniffiTypeStorageHandleObjectFactory.freePointer(heldValue);
|
|
1631
|
+
}) : null;
|
|
1632
|
+
|
|
1633
|
+
return {
|
|
1634
|
+
create(pointer: UniffiHandle): StorageHandleLike {
|
|
1635
|
+
const instance = Object.create(StorageHandle.prototype);
|
|
1636
|
+
instance[pointerLiteralSymbol] = pointer;
|
|
1637
|
+
instance[destructorGuardSymbol] = this.bless(pointer);
|
|
1638
|
+
instance[uniffiTypeNameSymbol] = "StorageHandle";
|
|
1639
|
+
return instance;
|
|
1640
|
+
},
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
bless(p: UniffiHandle): UniffiGcObject {
|
|
1644
|
+
const ptr = {
|
|
1645
|
+
p, // make sure this object doesn't get optimized away.
|
|
1646
|
+
markDestroyed: () => undefined,
|
|
1647
|
+
};
|
|
1648
|
+
if (registry) {
|
|
1649
|
+
registry.register(ptr, p, ptr);
|
|
1650
|
+
}
|
|
1651
|
+
return ptr;
|
|
1652
|
+
},
|
|
1653
|
+
|
|
1654
|
+
unbless(ptr_: UniffiGcObject) {
|
|
1655
|
+
if (registry) {
|
|
1656
|
+
registry.unregister(ptr_);
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1659
|
+
|
|
1660
|
+
pointer(obj_: StorageHandleLike): UniffiHandle {
|
|
1661
|
+
if ((obj_ as any)[destructorGuardSymbol] === undefined) {
|
|
1662
|
+
throw new UniffiInternalError.UnexpectedNullPointer();
|
|
1663
|
+
}
|
|
1664
|
+
return (obj_ as any)[pointerLiteralSymbol];
|
|
1665
|
+
},
|
|
1666
|
+
|
|
1667
|
+
clonePointer(obj_: StorageHandleLike): UniffiHandle {
|
|
1668
|
+
const pointer = this.pointer(obj_);
|
|
1669
|
+
return uniffiCaller.rustCall(
|
|
1670
|
+
/*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_auth_fn_clone_storagehandle(pointer, callStatus),
|
|
1671
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1672
|
+
);
|
|
1673
|
+
},
|
|
1674
|
+
|
|
1675
|
+
freePointer(pointer: UniffiHandle): void {
|
|
1676
|
+
uniffiCaller.rustCall(
|
|
1677
|
+
/*caller:*/ (callStatus) => nativeModule().uniffi_dbx_tools_auth_fn_free_storagehandle(pointer, callStatus),
|
|
1678
|
+
/*liftString:*/ FfiConverterString.lift
|
|
1679
|
+
);
|
|
1680
|
+
},
|
|
1681
|
+
|
|
1682
|
+
isConcreteType(obj_: any): obj_ is StorageHandleLike {
|
|
1683
|
+
return obj_[destructorGuardSymbol] && obj_[uniffiTypeNameSymbol] === "StorageHandle";
|
|
1684
|
+
},
|
|
1685
|
+
}})();
|
|
1686
|
+
const FfiConverterTypeStorageHandle = new FfiConverterObject(uniffiTypeStorageHandleObjectFactory);
|
|
1687
|
+
|
|
1688
|
+
// FfiConverter for string | undefined
|
|
1689
|
+
const FfiConverterOptionalString = new FfiConverterOptional(FfiConverterString);
|
|
1690
|
+
|
|
1691
|
+
// FfiConverter for Array<string>
|
|
1692
|
+
const FfiConverterSequenceString = new FfiConverterArray(FfiConverterString);
|
|
1693
|
+
|
|
1694
|
+
// FfiConverter for OAuthGrant | undefined
|
|
1695
|
+
const FfiConverterOptionalTypeOAuthGrant = new FfiConverterOptional(FfiConverterTypeOAuthGrant);
|
|
1696
|
+
|
|
1697
|
+
// FfiConverter for Storage | undefined
|
|
1698
|
+
const FfiConverterOptionalTypeStorage = new FfiConverterOptional(FfiConverterTypeStorage);
|
|
1699
|
+
|
|
1700
|
+
// FfiConverter for FileLayout | undefined
|
|
1701
|
+
const FfiConverterOptionalTypeFileLayout = new FfiConverterOptional(FfiConverterTypeFileLayout);
|
|
1702
|
+
|
|
1703
|
+
// FfiConverter for AuthOptions | undefined
|
|
1704
|
+
const FfiConverterOptionalTypeAuthOptions = new FfiConverterOptional(FfiConverterTypeAuthOptions);
|
|
1705
|
+
|
|
1706
|
+
// FfiConverter for boolean | undefined
|
|
1707
|
+
const FfiConverterOptionalBoolean = new FfiConverterOptional(FfiConverterBool);
|
|
1708
|
+
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* This should be called before anything else.
|
|
1712
|
+
*
|
|
1713
|
+
* It is likely that this is being done for you by the library's `index.ts`.
|
|
1714
|
+
*
|
|
1715
|
+
* It checks versions of uniffi between when the Rust scaffolding was generated
|
|
1716
|
+
* and when the bindings were generated.
|
|
1717
|
+
*
|
|
1718
|
+
* It also initializes the machinery to enable Rust to talk back to Javascript.
|
|
1719
|
+
*/
|
|
1720
|
+
function uniffiEnsureInitialized() {
|
|
1721
|
+
// Get the bindings contract version from our ComponentInterface
|
|
1722
|
+
const bindingsContractVersion = 30;
|
|
1723
|
+
// Get the scaffolding contract version by calling the into the dylib
|
|
1724
|
+
const scaffoldingContractVersion = nativeModule().ffi_dbx_tools_auth_uniffi_contract_version();
|
|
1725
|
+
if (bindingsContractVersion !== scaffoldingContractVersion) {
|
|
1726
|
+
throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
|
|
1727
|
+
}
|
|
1728
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_func_canonical_scopes() !== 18689) {
|
|
1729
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_func_canonical_scopes");
|
|
1730
|
+
}
|
|
1731
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_func_create_provider_auth() !== 20751) {
|
|
1732
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_func_create_provider_auth");
|
|
1733
|
+
}
|
|
1734
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_func_create_provider_auth_with_storage() !== 25852) {
|
|
1735
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_func_create_provider_auth_with_storage");
|
|
1736
|
+
}
|
|
1737
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_func_create_storage_handle() !== 15844) {
|
|
1738
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_func_create_storage_handle");
|
|
1739
|
+
}
|
|
1740
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_func_credential_key() !== 22562) {
|
|
1741
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_func_credential_key");
|
|
1742
|
+
}
|
|
1743
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_providerauth_force_refresh_token() !== 35205) {
|
|
1744
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_providerauth_force_refresh_token");
|
|
1745
|
+
}
|
|
1746
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_providerauth_logout() !== 58116) {
|
|
1747
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_providerauth_logout");
|
|
1748
|
+
}
|
|
1749
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_providerauth_refresh_rejected_token() !== 40032) {
|
|
1750
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_providerauth_refresh_rejected_token");
|
|
1751
|
+
}
|
|
1752
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_providerauth_token() !== 54952) {
|
|
1753
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_providerauth_token");
|
|
1754
|
+
}
|
|
1755
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_storageadapter_load() !== 2549) {
|
|
1756
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_storageadapter_load");
|
|
1757
|
+
}
|
|
1758
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_storageadapter_prepare_write() !== 1371) {
|
|
1759
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_storageadapter_prepare_write");
|
|
1760
|
+
}
|
|
1761
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_storageadapter_save() !== 50464) {
|
|
1762
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_storageadapter_save");
|
|
1763
|
+
}
|
|
1764
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_storageadapter_remove() !== 46592) {
|
|
1765
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_storageadapter_remove");
|
|
1766
|
+
}
|
|
1767
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_storageadapter_acquire_lock() !== 13715) {
|
|
1768
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_storageadapter_acquire_lock");
|
|
1769
|
+
}
|
|
1770
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_storageadapter_release_lock() !== 42072) {
|
|
1771
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_storageadapter_release_lock");
|
|
1772
|
+
}
|
|
1773
|
+
if (nativeModule().uniffi_dbx_tools_auth_checksum_method_storageadapter_name() !== 674) {
|
|
1774
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_dbx_tools_auth_checksum_method_storageadapter_name");
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
uniffiCallbackInterfaceStorageAdapter.register();
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
export default Object.freeze({
|
|
1781
|
+
initialize: uniffiEnsureInitialized,
|
|
1782
|
+
converters: {
|
|
1783
|
+
FfiConverterTypeAccessToken,
|
|
1784
|
+
FfiConverterTypeAuthError,
|
|
1785
|
+
FfiConverterTypeAuthOptions,
|
|
1786
|
+
FfiConverterTypeFileLayout,
|
|
1787
|
+
FfiConverterTypeOAuthGrant,
|
|
1788
|
+
FfiConverterTypeProviderAuth,
|
|
1789
|
+
FfiConverterTypeProviderOptions,
|
|
1790
|
+
FfiConverterTypeStorage,
|
|
1791
|
+
FfiConverterTypeStorageAdapter,
|
|
1792
|
+
FfiConverterTypeStorageHandle,
|
|
1793
|
+
}
|
|
1794
|
+
});
|