@agntcy/slim-bindings 3.3.8 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { type UniffiByteArray, type UniffiGcObject, type UniffiHandle, FfiConverterObject, RustBuffer, UniffiAbstractObject, destructorGuardSymbol, pointerLiteralSymbol, uniffiTypeNameSymbol } from "@ubjs/core";
1
+ import { type UniffiByteArray, type UniffiGcObject, type UniffiHandle, FfiConverterObject, FfiConverterObjectWithCallbacks, RustBuffer, UniffiAbstractObject, destructorGuardSymbol, pointerLiteralSymbol, uniffiTypeNameSymbol } from "@ubjs/core";
2
2
  /**
3
3
  * Create a new Service with builder pattern (native only)
4
4
  */
@@ -7,6 +7,27 @@ export declare function createService(name: string): ServiceLike;
7
7
  * Create a new Service with configuration (native only)
8
8
  */
9
9
  export declare function createServiceWithConfig(name: string, config: ServiceConfig): ServiceLike;
10
+ /**
11
+ * The `did:key` of an Ed25519 private key, a PKCS#8 PEM document
12
+ * (`-----BEGIN PRIVATE KEY-----`).
13
+ *
14
+ * An app created with `create_app_with_did_key` has this identity; peers list the
15
+ * matching public key in their trust anchor.
16
+ */
17
+ export declare function didKeyOfPrivateKey(privateKeyPem: string): string;
18
+ /**
19
+ * Generate a fresh signature key pair, in the format described on [`SignatureKeys`],
20
+ * for the ciphersuite this library was built with.
21
+ *
22
+ * An [`IdentityProvider`] needs a key pair from the start (see
23
+ * [`IdentityProvider::get_signature_keys`]), so a provider with no key of its own can
24
+ * create one here instead of implementing the crypto itself.
25
+ *
26
+ * ```python
27
+ * keys = slim_bindings.generate_signature_keys()
28
+ * ```
29
+ */
30
+ export declare function generateSignatureKeys(): SignatureKeys;
10
31
  /**
11
32
  * Get detailed build information
12
33
  */
@@ -2054,6 +2075,38 @@ export declare const DataplaneConfig: Readonly<{
2054
2075
  new: (partial: Partial<DataplaneConfig> & Required<Omit<DataplaneConfig, "servers" | "clients">>) => DataplaneConfig;
2055
2076
  defaults: () => Partial<DataplaneConfig>;
2056
2077
  }>;
2078
+ /**
2079
+ * A provider's persistable identity, saved so the app can be restored verbatim
2080
+ * after a restart. `credential` is sensitive: it ends up in the persisted store
2081
+ * (encrypted with the persistence passphrase), so treat it as a secret.
2082
+ */
2083
+ export type IdentityExport = {
2084
+ /**
2085
+ * Stable identity string.
2086
+ */
2087
+ id: string;
2088
+ /**
2089
+ * Provider credential material (e.g. a shared secret). Sensitive.
2090
+ */
2091
+ credential: ArrayBuffer;
2092
+ /**
2093
+ * MLS signature secret key bytes, exactly as in [`SignatureKeys::secret_key`]
2094
+ * (raw bytes, not PKCS#8 or base64). Sensitive.
2095
+ */
2096
+ signatureSecretKey: ArrayBuffer;
2097
+ /**
2098
+ * MLS signature public key bytes, exactly as in [`SignatureKeys::public_key`].
2099
+ */
2100
+ signaturePublicKey: ArrayBuffer;
2101
+ };
2102
+ /**
2103
+ * Generated factory for {@link IdentityExport} record objects.
2104
+ */
2105
+ export declare const IdentityExport: Readonly<{
2106
+ create: (partial: Partial<IdentityExport> & Required<Omit<IdentityExport, "id" | "credential" | "signatureSecretKey" | "signaturePublicKey">>) => IdentityExport;
2107
+ new: (partial: Partial<IdentityExport> & Required<Omit<IdentityExport, "id" | "credential" | "signatureSecretKey" | "signaturePublicKey">>) => IdentityExport;
2108
+ defaults: () => Partial<IdentityExport>;
2109
+ }>;
2057
2110
  /**
2058
2111
  * Name type for SLIM (Secure Low-Latency Interactive Messaging)
2059
2112
  */
@@ -3952,6 +4005,53 @@ export declare const SessionWithCompletion: Readonly<{
3952
4005
  new: (partial: Partial<SessionWithCompletion> & Required<Omit<SessionWithCompletion, "session" | "completion">>) => SessionWithCompletion;
3953
4006
  defaults: () => Partial<SessionWithCompletion>;
3954
4007
  }>;
4008
+ /**
4009
+ * The MLS signature key pair of an identity.
4010
+ *
4011
+ * # Key format
4012
+ *
4013
+ * The keys are opaque bytes in the encoding of the MLS crypto provider (AWS-LC),
4014
+ * which depends on the ciphersuite the library was built with. The default is P-256;
4015
+ * building with the `curve25519` feature switches the whole build to Ed25519, so do not assume one format without knowing how your
4016
+ * SLIM library was built:
4017
+ *
4018
+ * | Build | `secret_key` | `public_key` |
4019
+ * |-------|--------------|--------------|
4020
+ * | default (P-256, ECDSA) | at most 32 bytes: the raw big-endian private scalar, see below | 65 bytes: uncompressed SEC1 point: the byte `0x04`, then X, then Y |
4021
+ * | `curve25519` (Ed25519) | 64 bytes: the 32-byte seed followed by the 32-byte public key | 32 bytes: the raw Ed25519 public key |
4022
+ *
4023
+ * A P-256 secret key is the 32-byte scalar with leading zero bytes removed, so about one
4024
+ * key in 256 is shorter than 32 bytes. Do not check for an exact length or store it in a
4025
+ * fixed-size slot; SLIM also accepts the scalar left-padded to 32 bytes.
4026
+ *
4027
+ * Neither key is PKCS#8, PEM, DER or base64 encoded, and the public key carries no
4028
+ * DER wrapper. SLIM generates the pair and hands it to
4029
+ * [`IdentityProvider::set_signature_keys`]; store and return those exact bytes
4030
+ * from [`IdentityProvider::get_signature_keys`] and [`IdentityProvider::export_identity`].
4031
+ * A provider that supplies its own keys must produce them in the format above.
4032
+ *
4033
+ * How a token carries the public key, for [`IdentityVerifier::get_public_key`] and
4034
+ * [`IdentityVerifier::verify_key_binding`], is up to the scheme. If you put it in a claim
4035
+ * as text, use standard base64 (RFC 4648 section 4, with `=` padding).
4036
+ */
4037
+ export type SignatureKeys = {
4038
+ /**
4039
+ * Private signing key, in the format described on [`SignatureKeys`].
4040
+ */
4041
+ secretKey: ArrayBuffer;
4042
+ /**
4043
+ * Public key, in the format described on [`SignatureKeys`].
4044
+ */
4045
+ publicKey: ArrayBuffer;
4046
+ };
4047
+ /**
4048
+ * Generated factory for {@link SignatureKeys} record objects.
4049
+ */
4050
+ export declare const SignatureKeys: Readonly<{
4051
+ create: (partial: Partial<SignatureKeys> & Required<Omit<SignatureKeys, "secretKey" | "publicKey">>) => SignatureKeys;
4052
+ new: (partial: Partial<SignatureKeys> & Required<Omit<SignatureKeys, "secretKey" | "publicKey">>) => SignatureKeys;
4053
+ defaults: () => Partial<SignatureKeys>;
4054
+ }>;
3955
4055
  /**
3956
4056
  * Tracing/logging configuration for the SLIM bindings
3957
4057
  *
@@ -3993,6 +4093,264 @@ export declare enum Direction {
3993
4093
  Bidirectional = 2,
3994
4094
  None = 3
3995
4095
  }
4096
+ export declare enum IdentityCallbackError_Tags {
4097
+ Failed = "Failed",
4098
+ PublicKeyMismatch = "PublicKeyMismatch",
4099
+ IdentityMismatch = "IdentityMismatch"
4100
+ }
4101
+ /**
4102
+ * Error returned by foreign [`IdentityProvider`] / [`IdentityVerifier`] implementations.
4103
+ */
4104
+ export declare const IdentityCallbackError: Readonly<{
4105
+ instanceOf: (obj: any) => obj is IdentityCallbackError;
4106
+ Failed: {
4107
+ new (inner: {
4108
+ message: string;
4109
+ }): {
4110
+ readonly tag: IdentityCallbackError_Tags.Failed;
4111
+ readonly inner: Readonly<{
4112
+ message: string;
4113
+ }>;
4114
+ /**
4115
+ * @private
4116
+ * This field is private and should not be used, use `tag` instead.
4117
+ */
4118
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4119
+ name: string;
4120
+ message: string;
4121
+ stack?: string;
4122
+ };
4123
+ "new"(inner: {
4124
+ message: string;
4125
+ }): {
4126
+ readonly tag: IdentityCallbackError_Tags.Failed;
4127
+ readonly inner: Readonly<{
4128
+ message: string;
4129
+ }>;
4130
+ /**
4131
+ * @private
4132
+ * This field is private and should not be used, use `tag` instead.
4133
+ */
4134
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4135
+ name: string;
4136
+ message: string;
4137
+ stack?: string;
4138
+ };
4139
+ instanceOf(obj: any): obj is {
4140
+ readonly tag: IdentityCallbackError_Tags.Failed;
4141
+ readonly inner: Readonly<{
4142
+ message: string;
4143
+ }>;
4144
+ /**
4145
+ * @private
4146
+ * This field is private and should not be used, use `tag` instead.
4147
+ */
4148
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4149
+ name: string;
4150
+ message: string;
4151
+ stack?: string;
4152
+ };
4153
+ hasInner(obj: any): obj is {
4154
+ readonly tag: IdentityCallbackError_Tags.Failed;
4155
+ readonly inner: Readonly<{
4156
+ message: string;
4157
+ }>;
4158
+ /**
4159
+ * @private
4160
+ * This field is private and should not be used, use `tag` instead.
4161
+ */
4162
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4163
+ name: string;
4164
+ message: string;
4165
+ stack?: string;
4166
+ };
4167
+ getInner(obj: {
4168
+ readonly tag: IdentityCallbackError_Tags.Failed;
4169
+ readonly inner: Readonly<{
4170
+ message: string;
4171
+ }>;
4172
+ /**
4173
+ * @private
4174
+ * This field is private and should not be used, use `tag` instead.
4175
+ */
4176
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4177
+ name: string;
4178
+ message: string;
4179
+ stack?: string;
4180
+ }): Readonly<{
4181
+ message: string;
4182
+ }>;
4183
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
4184
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
4185
+ stackTraceLimit: number;
4186
+ };
4187
+ PublicKeyMismatch: {
4188
+ new (inner: {
4189
+ message: string;
4190
+ }): {
4191
+ readonly tag: IdentityCallbackError_Tags.PublicKeyMismatch;
4192
+ readonly inner: Readonly<{
4193
+ message: string;
4194
+ }>;
4195
+ /**
4196
+ * @private
4197
+ * This field is private and should not be used, use `tag` instead.
4198
+ */
4199
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4200
+ name: string;
4201
+ message: string;
4202
+ stack?: string;
4203
+ };
4204
+ "new"(inner: {
4205
+ message: string;
4206
+ }): {
4207
+ readonly tag: IdentityCallbackError_Tags.PublicKeyMismatch;
4208
+ readonly inner: Readonly<{
4209
+ message: string;
4210
+ }>;
4211
+ /**
4212
+ * @private
4213
+ * This field is private and should not be used, use `tag` instead.
4214
+ */
4215
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4216
+ name: string;
4217
+ message: string;
4218
+ stack?: string;
4219
+ };
4220
+ instanceOf(obj: any): obj is {
4221
+ readonly tag: IdentityCallbackError_Tags.PublicKeyMismatch;
4222
+ readonly inner: Readonly<{
4223
+ message: string;
4224
+ }>;
4225
+ /**
4226
+ * @private
4227
+ * This field is private and should not be used, use `tag` instead.
4228
+ */
4229
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4230
+ name: string;
4231
+ message: string;
4232
+ stack?: string;
4233
+ };
4234
+ hasInner(obj: any): obj is {
4235
+ readonly tag: IdentityCallbackError_Tags.PublicKeyMismatch;
4236
+ readonly inner: Readonly<{
4237
+ message: string;
4238
+ }>;
4239
+ /**
4240
+ * @private
4241
+ * This field is private and should not be used, use `tag` instead.
4242
+ */
4243
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4244
+ name: string;
4245
+ message: string;
4246
+ stack?: string;
4247
+ };
4248
+ getInner(obj: {
4249
+ readonly tag: IdentityCallbackError_Tags.PublicKeyMismatch;
4250
+ readonly inner: Readonly<{
4251
+ message: string;
4252
+ }>;
4253
+ /**
4254
+ * @private
4255
+ * This field is private and should not be used, use `tag` instead.
4256
+ */
4257
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4258
+ name: string;
4259
+ message: string;
4260
+ stack?: string;
4261
+ }): Readonly<{
4262
+ message: string;
4263
+ }>;
4264
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
4265
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
4266
+ stackTraceLimit: number;
4267
+ };
4268
+ IdentityMismatch: {
4269
+ new (inner: {
4270
+ message: string;
4271
+ }): {
4272
+ readonly tag: IdentityCallbackError_Tags.IdentityMismatch;
4273
+ readonly inner: Readonly<{
4274
+ message: string;
4275
+ }>;
4276
+ /**
4277
+ * @private
4278
+ * This field is private and should not be used, use `tag` instead.
4279
+ */
4280
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4281
+ name: string;
4282
+ message: string;
4283
+ stack?: string;
4284
+ };
4285
+ "new"(inner: {
4286
+ message: string;
4287
+ }): {
4288
+ readonly tag: IdentityCallbackError_Tags.IdentityMismatch;
4289
+ readonly inner: Readonly<{
4290
+ message: string;
4291
+ }>;
4292
+ /**
4293
+ * @private
4294
+ * This field is private and should not be used, use `tag` instead.
4295
+ */
4296
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4297
+ name: string;
4298
+ message: string;
4299
+ stack?: string;
4300
+ };
4301
+ instanceOf(obj: any): obj is {
4302
+ readonly tag: IdentityCallbackError_Tags.IdentityMismatch;
4303
+ readonly inner: Readonly<{
4304
+ message: string;
4305
+ }>;
4306
+ /**
4307
+ * @private
4308
+ * This field is private and should not be used, use `tag` instead.
4309
+ */
4310
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4311
+ name: string;
4312
+ message: string;
4313
+ stack?: string;
4314
+ };
4315
+ hasInner(obj: any): obj is {
4316
+ readonly tag: IdentityCallbackError_Tags.IdentityMismatch;
4317
+ readonly inner: Readonly<{
4318
+ message: string;
4319
+ }>;
4320
+ /**
4321
+ * @private
4322
+ * This field is private and should not be used, use `tag` instead.
4323
+ */
4324
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4325
+ name: string;
4326
+ message: string;
4327
+ stack?: string;
4328
+ };
4329
+ getInner(obj: {
4330
+ readonly tag: IdentityCallbackError_Tags.IdentityMismatch;
4331
+ readonly inner: Readonly<{
4332
+ message: string;
4333
+ }>;
4334
+ /**
4335
+ * @private
4336
+ * This field is private and should not be used, use `tag` instead.
4337
+ */
4338
+ readonly [uniffiTypeNameSymbol]: "IdentityCallbackError";
4339
+ name: string;
4340
+ message: string;
4341
+ stack?: string;
4342
+ }): Readonly<{
4343
+ message: string;
4344
+ }>;
4345
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
4346
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
4347
+ stackTraceLimit: number;
4348
+ };
4349
+ }>;
4350
+ /**
4351
+ * Error returned by foreign [`IdentityProvider`] / [`IdentityVerifier`] implementations.
4352
+ */
4353
+ export type IdentityCallbackError = InstanceType<typeof IdentityCallbackError['Failed' | 'PublicKeyMismatch' | 'IdentityMismatch']>;
3996
4354
  export declare enum IdentityProviderConfig_Tags {
3997
4355
  SharedSecret = "SharedSecret",
3998
4356
  StaticJwt = "StaticJwt",
@@ -4579,6 +4937,66 @@ export declare class App extends UniffiAbstractObject implements AppLike {
4579
4937
  * - StaticJWT: Static JWT loaded from file with auto-reload
4580
4938
  */
4581
4939
  constructor(baseName: NameLike, identityProviderConfig: IdentityProviderConfig, identityVerifierConfig: IdentityVerifierConfig);
4940
+ /**
4941
+ * Create a new App whose identity is implemented in the foreign language
4942
+ *
4943
+ * Unlike [`App::new`], which selects a built-in mechanism through a config enum,
4944
+ * this takes the provider and verifier objects directly.
4945
+ *
4946
+ * # Arguments
4947
+ * * `base_name` - The base name for the app (without ID)
4948
+ * * `identity_provider` - Proves this app's identity to others
4949
+ * * `identity_verifier` - Verifies the identity of others
4950
+ * * `direction` - Traffic direction for sessions
4951
+ *
4952
+ * # Example
4953
+ *
4954
+ * ```rust,no_run
4955
+ * # use std::sync::Arc;
4956
+ * # use slim_bindings::*;
4957
+ * # fn demo(
4958
+ * # name: Arc<Name>,
4959
+ * # provider: Arc<dyn IdentityProvider>,
4960
+ * # verifier: Arc<dyn IdentityVerifier>,
4961
+ * # ) -> Result<(), SlimError> {
4962
+ * let app = App::new_with_custom_identity(name, provider, verifier, Direction::Bidirectional)?;
4963
+ * # Ok(()) }
4964
+ * ```
4965
+ *
4966
+ * # Blocking
4967
+ *
4968
+ * This constructor blocks the calling thread while the provider's and verifier's
4969
+ * async `initialize` run. Do not call it from inside an event loop of a language
4970
+ * whose callbacks need that loop (e.g. Python asyncio): it deadlocks. Use
4971
+ * [`App::new_with_custom_identity_async`] there.
4972
+ */
4973
+ static newWithCustomIdentity(baseName: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction): AppLike;
4974
+ /**
4975
+ * Create a new App whose identity is implemented in the foreign language (async version)
4976
+ *
4977
+ * Same as [`App::new_with_custom_identity`], but awaits the provider's and
4978
+ * verifier's `initialize` instead of blocking. Prefer it from async code.
4979
+ */
4980
+ static newWithCustomIdentityAsync(baseName: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction, asyncOpts_?: {
4981
+ signal: AbortSignal;
4982
+ }): Promise<AppLike>;
4983
+ /**
4984
+ * Create a new App whose identity is a `did:key` (blocking version)
4985
+ *
4986
+ * The app signs with an Ed25519 key and accepts the peers that a trust anchor lists.
4987
+ * It uses the global service. See [`crate::Service::create_app_with_did_key_async`]
4988
+ * for the arguments.
4989
+ */
4990
+ static newWithDidKey(name: NameLike, privateKeyPem: string, trustedKeys: string, direction: Direction): AppLike;
4991
+ /**
4992
+ * Create a new App whose identity is a `did:key` (async version)
4993
+ *
4994
+ * Same as [`App::new_with_did_key`], without blocking the caller. Prefer it from
4995
+ * async code.
4996
+ */
4997
+ static newWithDidKeyAsync(name: NameLike, privateKeyPem: string, trustedKeys: string, direction: Direction, asyncOpts_?: {
4998
+ signal: AbortSignal;
4999
+ }): Promise<AppLike>;
4582
5000
  /**
4583
5001
  * Create a new App with traffic direction (blocking version)
4584
5002
  *
@@ -4770,6 +5188,444 @@ export declare class App extends UniffiAbstractObject implements AppLike {
4770
5188
  uniffiDestroy(): void;
4771
5189
  static instanceOf(obj_: any): obj_ is App;
4772
5190
  }
5191
+ /**
5192
+ * Proves this app's identity to its peers. Implemented in the foreign language.
5193
+ *
5194
+ * `initialize` is async. The other methods are called synchronously from SLIM worker
5195
+ * threads (including from MLS), so they must not block for long and must be safe to
5196
+ * call concurrently; prefetch and cache anything that needs I/O.
5197
+ *
5198
+ * # Keys and tokens
5199
+ *
5200
+ * SLIM signs the control messages of every session with the provider's signature
5201
+ * key pair, with or without MLS, and the peer checks that signature with the key its
5202
+ * [`IdentityVerifier::get_public_key`] returns. A provider therefore must:
5203
+ *
5204
+ * 1. hold a signature key pair from the start (create one with
5205
+ * [`generate_signature_keys`] if you have none) and return it from
5206
+ * [`IdentityProvider::get_signature_keys`];
5207
+ * 2. return tokens that let the paired verifier recover its current public key and check
5208
+ * that the token is bound to it;
5209
+ * 3. replace the pair when [`IdentityProvider::set_signature_keys`] is called (MLS
5210
+ * does this) and carry the new public key in the next tokens.
5211
+ *
5212
+ * If the verifier cannot return the signer's key, new sessions fail with "identity
5213
+ * verification failed".
5214
+ *
5215
+ * # One provider object per app
5216
+ *
5217
+ * SLIM clones its handle to the provider for every session of an app, and all clones
5218
+ * call the same object, so the app and its sessions share one key pair. That is intended,
5219
+ * but it also means two apps given the same object share one key slot: rotating the keys
5220
+ * in one changes the other's. Give each app its own provider object. (Built-in identities
5221
+ * created from a config differ: a shared-secret identity shares its keys across clones
5222
+ * like this, while a JWT signer keeps a key pair per clone.)
5223
+ */
5224
+ export interface IdentityProvider {
5225
+ /**
5226
+ * One-time asynchronous setup (e.g. loading credentials, contacting an identity
5227
+ * service), awaited while an app is created, before any other method. SLIM calls it
5228
+ * once per app creation, so it runs again if you reuse the object for another app:
5229
+ * make it idempotent. Use one provider object per app anyway (see below).
5230
+ */
5231
+ initialize(asyncOpts_?: {
5232
+ signal: AbortSignal;
5233
+ }): Promise<void>;
5234
+ /**
5235
+ * Return a token proving this app's identity. Called every time a token is
5236
+ * needed, so implementations should cache and refresh as appropriate.
5237
+ */
5238
+ getToken(): string;
5239
+ /**
5240
+ * Return the identity (subject) the token carries.
5241
+ */
5242
+ getId(): string;
5243
+ /**
5244
+ * The signature key pair currently in use. SLIM signs session control messages
5245
+ * with it, so it must always be available.
5246
+ *
5247
+ * Return the bytes you were given, unchanged (see [`SignatureKeys`] for the format).
5248
+ *
5249
+ * ```python
5250
+ * def get_signature_keys(self):
5251
+ * if self._keys is None:
5252
+ * raise slim_bindings.IdentityCallbackError.Failed("no keys installed yet")
5253
+ * return slim_bindings.SignatureKeys(self._keys.secret, self._keys.public)
5254
+ * ```
5255
+ */
5256
+ getSignatureKeys(): SignatureKeys;
5257
+ /**
5258
+ * Whether SLIM's keys were installed through
5259
+ * [`IdentityProvider::set_signature_keys`] or [`IdentityProvider::restore_identity`].
5260
+ * Return false until then, even if you created a pair yourself: when MLS is used,
5261
+ * SLIM generates and installs a pair only while this is false. If this fails, SLIM
5262
+ * does not treat it as "not installed", which would replace the keys every session of
5263
+ * the app shares: MLS setup for that session fails instead.
5264
+ */
5265
+ mlsSignatureKeysInstalled(): boolean;
5266
+ /**
5267
+ * Called when MLS is used, with the MLS signature key pair generated by SLIM.
5268
+ * Both keys are raw bytes in the format described on [`SignatureKeys`]: keep them
5269
+ * byte-for-byte and return them unchanged from `get_signature_keys`.
5270
+ * Subsequent tokens should carry `public_key` (e.g. as a `pubkey` or `cnf` claim) so
5271
+ * peers can recover it with [`IdentityVerifier::get_public_key`] and check the binding
5272
+ * with [`IdentityVerifier::verify_key_binding`]. Replace your current pair with these.
5273
+ *
5274
+ * ```python
5275
+ * def set_signature_keys(self, private_key, public_key):
5276
+ * self._keys = Keys(private_key, public_key)
5277
+ * self._token = self._mint_token(claims={"pubkey": base64.b64encode(public_key)})
5278
+ * ```
5279
+ */
5280
+ setSignatureKeys(privateKey: ArrayBuffer, publicKey: ArrayBuffer): void;
5281
+ /**
5282
+ * The persistable identity, or `None` if this provider does not support
5283
+ * persistence. Used when the app is created with persistence enabled. If this fails,
5284
+ * SLIM logs the error and does not update the session record, rather than saving it next
5285
+ * to a stale identity. Make `export_identity` reliable: MLS group state is still saved.
5286
+ *
5287
+ * ```python
5288
+ * def export_identity(self):
5289
+ * return slim_bindings.IdentityExport(
5290
+ * id=self._id,
5291
+ * credential=self._secret, # sensitive: stored encrypted
5292
+ * signature_secret_key=self._keys.secret,
5293
+ * signature_public_key=self._keys.public,
5294
+ * )
5295
+ *
5296
+ * def restore_identity(self, identity):
5297
+ * self._id, self._secret = identity.id, identity.credential
5298
+ * self._keys = Keys(identity.signature_secret_key, identity.signature_public_key)
5299
+ * self._installed = True
5300
+ * ```
5301
+ */
5302
+ exportIdentity(): IdentityExport | undefined;
5303
+ /**
5304
+ * Whether the MLS signing key is long-term, so persisted group state would
5305
+ * expose it. When true, persistence requires a passphrase. If this fails, SLIM
5306
+ * assumes it does when opening a persistent store, and fails to restore a persisted
5307
+ * MLS group.
5308
+ */
5309
+ holdsLongTermSigningKey(): boolean;
5310
+ /**
5311
+ * Adopt an identity returned earlier by [`IdentityProvider::export_identity`],
5312
+ * so the provider presents the same id and MLS keys as before a restart. The
5313
+ * keys count as installed afterwards.
5314
+ *
5315
+ * Be all-or-nothing: on failure leave the provider as it was. SLIM keeps using the
5316
+ * same object when the restore fails, so a half-applied restore would leak into it.
5317
+ * Any failure turns persistence off and leaves the stored identity alone: with a
5318
+ * fresh identity, SLIM would install new MLS keys, and the persisted groups were
5319
+ * created with the old ones. [`IdentityCallbackError::IdentityMismatch`] says the
5320
+ * persisted identity is not yours, which is logged as such.
5321
+ */
5322
+ restoreIdentity(identity: IdentityExport): void;
5323
+ }
5324
+ /**
5325
+ * Proves this app's identity to its peers. Implemented in the foreign language.
5326
+ *
5327
+ * `initialize` is async. The other methods are called synchronously from SLIM worker
5328
+ * threads (including from MLS), so they must not block for long and must be safe to
5329
+ * call concurrently; prefetch and cache anything that needs I/O.
5330
+ *
5331
+ * # Keys and tokens
5332
+ *
5333
+ * SLIM signs the control messages of every session with the provider's signature
5334
+ * key pair, with or without MLS, and the peer checks that signature with the key its
5335
+ * [`IdentityVerifier::get_public_key`] returns. A provider therefore must:
5336
+ *
5337
+ * 1. hold a signature key pair from the start (create one with
5338
+ * [`generate_signature_keys`] if you have none) and return it from
5339
+ * [`IdentityProvider::get_signature_keys`];
5340
+ * 2. return tokens that let the paired verifier recover its current public key and check
5341
+ * that the token is bound to it;
5342
+ * 3. replace the pair when [`IdentityProvider::set_signature_keys`] is called (MLS
5343
+ * does this) and carry the new public key in the next tokens.
5344
+ *
5345
+ * If the verifier cannot return the signer's key, new sessions fail with "identity
5346
+ * verification failed".
5347
+ *
5348
+ * # One provider object per app
5349
+ *
5350
+ * SLIM clones its handle to the provider for every session of an app, and all clones
5351
+ * call the same object, so the app and its sessions share one key pair. That is intended,
5352
+ * but it also means two apps given the same object share one key slot: rotating the keys
5353
+ * in one changes the other's. Give each app its own provider object. (Built-in identities
5354
+ * created from a config differ: a shared-secret identity shares its keys across clones
5355
+ * like this, while a JWT signer keeps a key pair per clone.)
5356
+ */
5357
+ export declare class IdentityProviderImpl extends UniffiAbstractObject implements IdentityProvider {
5358
+ readonly [uniffiTypeNameSymbol] = "IdentityProviderImpl";
5359
+ readonly [destructorGuardSymbol]: UniffiGcObject;
5360
+ readonly [pointerLiteralSymbol]: UniffiHandle;
5361
+ private constructor();
5362
+ /**
5363
+ * One-time asynchronous setup (e.g. loading credentials, contacting an identity
5364
+ * service), awaited while an app is created, before any other method. SLIM calls it
5365
+ * once per app creation, so it runs again if you reuse the object for another app:
5366
+ * make it idempotent. Use one provider object per app anyway (see below).
5367
+ */
5368
+ initialize(asyncOpts_?: {
5369
+ signal: AbortSignal;
5370
+ }): Promise<void>;
5371
+ /**
5372
+ * Return a token proving this app's identity. Called every time a token is
5373
+ * needed, so implementations should cache and refresh as appropriate.
5374
+ */
5375
+ getToken(): string;
5376
+ /**
5377
+ * Return the identity (subject) the token carries.
5378
+ */
5379
+ getId(): string;
5380
+ /**
5381
+ * The signature key pair currently in use. SLIM signs session control messages
5382
+ * with it, so it must always be available.
5383
+ *
5384
+ * Return the bytes you were given, unchanged (see [`SignatureKeys`] for the format).
5385
+ *
5386
+ * ```python
5387
+ * def get_signature_keys(self):
5388
+ * if self._keys is None:
5389
+ * raise slim_bindings.IdentityCallbackError.Failed("no keys installed yet")
5390
+ * return slim_bindings.SignatureKeys(self._keys.secret, self._keys.public)
5391
+ * ```
5392
+ */
5393
+ getSignatureKeys(): SignatureKeys;
5394
+ /**
5395
+ * Whether SLIM's keys were installed through
5396
+ * [`IdentityProvider::set_signature_keys`] or [`IdentityProvider::restore_identity`].
5397
+ * Return false until then, even if you created a pair yourself: when MLS is used,
5398
+ * SLIM generates and installs a pair only while this is false. If this fails, SLIM
5399
+ * does not treat it as "not installed", which would replace the keys every session of
5400
+ * the app shares: MLS setup for that session fails instead.
5401
+ */
5402
+ mlsSignatureKeysInstalled(): boolean;
5403
+ /**
5404
+ * Called when MLS is used, with the MLS signature key pair generated by SLIM.
5405
+ * Both keys are raw bytes in the format described on [`SignatureKeys`]: keep them
5406
+ * byte-for-byte and return them unchanged from `get_signature_keys`.
5407
+ * Subsequent tokens should carry `public_key` (e.g. as a `pubkey` or `cnf` claim) so
5408
+ * peers can recover it with [`IdentityVerifier::get_public_key`] and check the binding
5409
+ * with [`IdentityVerifier::verify_key_binding`]. Replace your current pair with these.
5410
+ *
5411
+ * ```python
5412
+ * def set_signature_keys(self, private_key, public_key):
5413
+ * self._keys = Keys(private_key, public_key)
5414
+ * self._token = self._mint_token(claims={"pubkey": base64.b64encode(public_key)})
5415
+ * ```
5416
+ */
5417
+ setSignatureKeys(privateKey: ArrayBuffer, publicKey: ArrayBuffer): void;
5418
+ /**
5419
+ * The persistable identity, or `None` if this provider does not support
5420
+ * persistence. Used when the app is created with persistence enabled. If this fails,
5421
+ * SLIM logs the error and does not update the session record, rather than saving it next
5422
+ * to a stale identity. Make `export_identity` reliable: MLS group state is still saved.
5423
+ *
5424
+ * ```python
5425
+ * def export_identity(self):
5426
+ * return slim_bindings.IdentityExport(
5427
+ * id=self._id,
5428
+ * credential=self._secret, # sensitive: stored encrypted
5429
+ * signature_secret_key=self._keys.secret,
5430
+ * signature_public_key=self._keys.public,
5431
+ * )
5432
+ *
5433
+ * def restore_identity(self, identity):
5434
+ * self._id, self._secret = identity.id, identity.credential
5435
+ * self._keys = Keys(identity.signature_secret_key, identity.signature_public_key)
5436
+ * self._installed = True
5437
+ * ```
5438
+ */
5439
+ exportIdentity(): IdentityExport | undefined;
5440
+ /**
5441
+ * Whether the MLS signing key is long-term, so persisted group state would
5442
+ * expose it. When true, persistence requires a passphrase. If this fails, SLIM
5443
+ * assumes it does when opening a persistent store, and fails to restore a persisted
5444
+ * MLS group.
5445
+ */
5446
+ holdsLongTermSigningKey(): boolean;
5447
+ /**
5448
+ * Adopt an identity returned earlier by [`IdentityProvider::export_identity`],
5449
+ * so the provider presents the same id and MLS keys as before a restart. The
5450
+ * keys count as installed afterwards.
5451
+ *
5452
+ * Be all-or-nothing: on failure leave the provider as it was. SLIM keeps using the
5453
+ * same object when the restore fails, so a half-applied restore would leak into it.
5454
+ * Any failure turns persistence off and leaves the stored identity alone: with a
5455
+ * fresh identity, SLIM would install new MLS keys, and the persisted groups were
5456
+ * created with the old ones. [`IdentityCallbackError::IdentityMismatch`] says the
5457
+ * persisted identity is not yours, which is logged as such.
5458
+ */
5459
+ restoreIdentity(identity: IdentityExport): void;
5460
+ uniffiDestroy(): void;
5461
+ static instanceOf(obj_: any): obj_ is IdentityProviderImpl;
5462
+ }
5463
+ /**
5464
+ * Verifies the identity of peers. Implemented in the foreign language.
5465
+ *
5466
+ * `initialize` is async, so it may do I/O: fetch trust bundles or keys there, once.
5467
+ * Every other method is called synchronously from SLIM worker threads (including from
5468
+ * MLS), so it must not block for long and must be safe to call concurrently; verify
5469
+ * against what `initialize` fetched and what you refresh in the background.
5470
+ *
5471
+ * `verify_async` is no longer called: SLIM verifies tokens through the synchronous
5472
+ * methods only. It stays in the interface so existing implementations keep working,
5473
+ * and can be implemented by delegating to the synchronous `verify`.
5474
+ */
5475
+ export interface IdentityVerifier {
5476
+ /**
5477
+ * One-time asynchronous setup (e.g. fetching trust bundles or keys), awaited
5478
+ * once while the app is being created, before any other method.
5479
+ */
5480
+ initialize(asyncOpts_?: {
5481
+ signal: AbortSignal;
5482
+ }): Promise<void>;
5483
+ /**
5484
+ * Not called any more: SLIM uses [`IdentityVerifier::verify`]. Implement it by
5485
+ * delegating to `verify`.
5486
+ */
5487
+ verifyAsync(token: string, asyncOpts_?: {
5488
+ signal: AbortSignal;
5489
+ }): Promise<void>;
5490
+ /**
5491
+ * Verify the token from a synchronous context. Fail if it is invalid or expired.
5492
+ */
5493
+ verify(token: string): void;
5494
+ /**
5495
+ * Verify the token and return its claims as a JSON object.
5496
+ *
5497
+ * Include a `sub` claim with the subject the token identifies. SLIM binds the name id of
5498
+ * a peer to its subject, and with `SLIM_IDENTITY_BINDING=enforce` it drops a message
5499
+ * whose id does not derive from it. Without a `sub` (or `id`) claim there is no
5500
+ * subject to bind to, so none of those checks run for the peer.
5501
+ */
5502
+ getClaims(token: string): string;
5503
+ /**
5504
+ * Verify the token and return the subject it identifies.
5505
+ */
5506
+ getSubject(token: string): string;
5507
+ /**
5508
+ * Verify the token and return the public key its holder signs session control messages
5509
+ * with, as raw bytes in the format described on [`SignatureKeys`]. SLIM checks the
5510
+ * signature of a control message with this key, so it must be the key the sender's
5511
+ * [`IdentityProvider::get_signature_keys`] returns. Where the token carries the key is
5512
+ * up to your scheme.
5513
+ *
5514
+ * ```python
5515
+ * def get_public_key(self, token):
5516
+ * claims = self._decode_and_verify(token)
5517
+ * return base64.b64decode(claims["pubkey"])
5518
+ * ```
5519
+ */
5520
+ getPublicKey(token: string): ArrayBuffer;
5521
+ /**
5522
+ * Verify the token and check that it is bound to `public_key`, the MLS
5523
+ * signature public key of the peer, as raw bytes in the format described on
5524
+ * [`SignatureKeys`]. What "bound" means is up to your scheme (a claim holding the key,
5525
+ * a DPoP `cnf`/`jkt` thumbprint, ...). If the token carries the key as a base64
5526
+ * string, compare after decoding it, not the other way round. Fail with
5527
+ * [`IdentityCallbackError::PublicKeyMismatch`] if bound to a different key.
5528
+ *
5529
+ * Only MLS calls this. If your scheme has no MLS support, fail with
5530
+ * [`IdentityCallbackError::Failed`]; MLS then reports the error, and sessions without
5531
+ * MLS are unaffected. [`IdentityVerifier::get_public_key`] is different: sessions need
5532
+ * it, with or without MLS.
5533
+ *
5534
+ * ```python
5535
+ * def verify_key_binding(self, token, public_key):
5536
+ * claims = self._decode_and_verify(token)
5537
+ * if base64.b64decode(claims["pubkey"]) != public_key:
5538
+ * raise slim_bindings.IdentityCallbackError.PublicKeyMismatch("token bound to another key")
5539
+ * ```
5540
+ */
5541
+ verifyKeyBinding(token: string, publicKey: ArrayBuffer): void;
5542
+ }
5543
+ /**
5544
+ * Verifies the identity of peers. Implemented in the foreign language.
5545
+ *
5546
+ * `initialize` is async, so it may do I/O: fetch trust bundles or keys there, once.
5547
+ * Every other method is called synchronously from SLIM worker threads (including from
5548
+ * MLS), so it must not block for long and must be safe to call concurrently; verify
5549
+ * against what `initialize` fetched and what you refresh in the background.
5550
+ *
5551
+ * `verify_async` is no longer called: SLIM verifies tokens through the synchronous
5552
+ * methods only. It stays in the interface so existing implementations keep working,
5553
+ * and can be implemented by delegating to the synchronous `verify`.
5554
+ */
5555
+ export declare class IdentityVerifierImpl extends UniffiAbstractObject implements IdentityVerifier {
5556
+ readonly [uniffiTypeNameSymbol] = "IdentityVerifierImpl";
5557
+ readonly [destructorGuardSymbol]: UniffiGcObject;
5558
+ readonly [pointerLiteralSymbol]: UniffiHandle;
5559
+ private constructor();
5560
+ /**
5561
+ * One-time asynchronous setup (e.g. fetching trust bundles or keys), awaited
5562
+ * once while the app is being created, before any other method.
5563
+ */
5564
+ initialize(asyncOpts_?: {
5565
+ signal: AbortSignal;
5566
+ }): Promise<void>;
5567
+ /**
5568
+ * Not called any more: SLIM uses [`IdentityVerifier::verify`]. Implement it by
5569
+ * delegating to `verify`.
5570
+ */
5571
+ verifyAsync(token: string, asyncOpts_?: {
5572
+ signal: AbortSignal;
5573
+ }): Promise<void>;
5574
+ /**
5575
+ * Verify the token from a synchronous context. Fail if it is invalid or expired.
5576
+ */
5577
+ verify(token: string): void;
5578
+ /**
5579
+ * Verify the token and return its claims as a JSON object.
5580
+ *
5581
+ * Include a `sub` claim with the subject the token identifies. SLIM binds the name id of
5582
+ * a peer to its subject, and with `SLIM_IDENTITY_BINDING=enforce` it drops a message
5583
+ * whose id does not derive from it. Without a `sub` (or `id`) claim there is no
5584
+ * subject to bind to, so none of those checks run for the peer.
5585
+ */
5586
+ getClaims(token: string): string;
5587
+ /**
5588
+ * Verify the token and return the subject it identifies.
5589
+ */
5590
+ getSubject(token: string): string;
5591
+ /**
5592
+ * Verify the token and return the public key its holder signs session control messages
5593
+ * with, as raw bytes in the format described on [`SignatureKeys`]. SLIM checks the
5594
+ * signature of a control message with this key, so it must be the key the sender's
5595
+ * [`IdentityProvider::get_signature_keys`] returns. Where the token carries the key is
5596
+ * up to your scheme.
5597
+ *
5598
+ * ```python
5599
+ * def get_public_key(self, token):
5600
+ * claims = self._decode_and_verify(token)
5601
+ * return base64.b64decode(claims["pubkey"])
5602
+ * ```
5603
+ */
5604
+ getPublicKey(token: string): ArrayBuffer;
5605
+ /**
5606
+ * Verify the token and check that it is bound to `public_key`, the MLS
5607
+ * signature public key of the peer, as raw bytes in the format described on
5608
+ * [`SignatureKeys`]. What "bound" means is up to your scheme (a claim holding the key,
5609
+ * a DPoP `cnf`/`jkt` thumbprint, ...). If the token carries the key as a base64
5610
+ * string, compare after decoding it, not the other way round. Fail with
5611
+ * [`IdentityCallbackError::PublicKeyMismatch`] if bound to a different key.
5612
+ *
5613
+ * Only MLS calls this. If your scheme has no MLS support, fail with
5614
+ * [`IdentityCallbackError::Failed`]; MLS then reports the error, and sessions without
5615
+ * MLS are unaffected. [`IdentityVerifier::get_public_key`] is different: sessions need
5616
+ * it, with or without MLS.
5617
+ *
5618
+ * ```python
5619
+ * def verify_key_binding(self, token, public_key):
5620
+ * claims = self._decode_and_verify(token)
5621
+ * if base64.b64decode(claims["pubkey"]) != public_key:
5622
+ * raise slim_bindings.IdentityCallbackError.PublicKeyMismatch("token bound to another key")
5623
+ * ```
5624
+ */
5625
+ verifyKeyBinding(token: string, publicKey: ArrayBuffer): void;
5626
+ uniffiDestroy(): void;
5627
+ static instanceOf(obj_: any): obj_ is IdentityVerifierImpl;
5628
+ }
4773
5629
  /**
4774
5630
  * Service wrapper for uniffi bindings
4775
5631
  */
@@ -4822,6 +5678,97 @@ export interface ServiceLike {
4822
5678
  createAppAsync(baseName: NameLike, identityProviderConfig: IdentityProviderConfig, identityVerifierConfig: IdentityVerifierConfig, asyncOpts_?: {
4823
5679
  signal: AbortSignal;
4824
5680
  }): Promise<AppLike>;
5681
+ /**
5682
+ * Create a new App whose identity is provided by foreign-language objects - blocking version
5683
+ *
5684
+ * Blocks while the objects' async `initialize` run; see
5685
+ * [`crate::App::new_with_custom_identity`] for when not to use it.
5686
+ */
5687
+ createAppWithCustomIdentity(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction): AppLike;
5688
+ /**
5689
+ * Blocking wrapper around
5690
+ * [`Service::create_app_with_custom_identity_and_persistence_async`].
5691
+ */
5692
+ createAppWithCustomIdentityAndPersistence(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction, persistence: PersistenceConfig): AppLike;
5693
+ /**
5694
+ * Create an app whose identity is provided by objects (foreign-language
5695
+ * implementations), with restorable MLS/session
5696
+ * state persisted under `persistence.path` (async).
5697
+ *
5698
+ * Persistence uses the provider's `export_identity` / `restore_identity`
5699
+ * hooks; a provider whose `export_identity` returns `None` persists no identity, and
5700
+ * one whose `export_identity` fails stops its session records from being updated.
5701
+ * Restore the app's sessions after a restart with [`App::restore_sessions`].
5702
+ *
5703
+ * # Example
5704
+ *
5705
+ * ```rust,no_run
5706
+ * # use std::sync::Arc;
5707
+ * # use slim_bindings::*;
5708
+ * # async fn demo(
5709
+ * # service: Arc<Service>,
5710
+ * # name: Arc<Name>,
5711
+ * # provider: Arc<dyn IdentityProvider>,
5712
+ * # verifier: Arc<dyn IdentityVerifier>,
5713
+ * # ) -> Result<(), SlimError> {
5714
+ * let app = service
5715
+ * .create_app_with_custom_identity_and_persistence_async(
5716
+ * name,
5717
+ * provider,
5718
+ * verifier,
5719
+ * Direction::Bidirectional,
5720
+ * PersistenceConfig {
5721
+ * path: "/var/lib/myapp/slim".into(),
5722
+ * passphrase: Some("a-strong-passphrase".into()),
5723
+ * },
5724
+ * )
5725
+ * .await?;
5726
+ * # Ok(()) }
5727
+ * ```
5728
+ */
5729
+ createAppWithCustomIdentityAndPersistenceAsync(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction, persistence: PersistenceConfig, asyncOpts_?: {
5730
+ signal: AbortSignal;
5731
+ }): Promise<AppLike>;
5732
+ /**
5733
+ * Create a new App whose identity is provided by foreign-language objects (async version)
5734
+ *
5735
+ * `identity_provider` proves this app's identity; `identity_verifier` verifies peers.
5736
+ */
5737
+ createAppWithCustomIdentityAsync(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction, asyncOpts_?: {
5738
+ signal: AbortSignal;
5739
+ }): Promise<AppLike>;
5740
+ /**
5741
+ * Create a new App whose identity is a `did:key` (blocking version)
5742
+ *
5743
+ * See [`Service::create_app_with_did_key_async`] for the arguments.
5744
+ */
5745
+ createAppWithDidKey(name: NameLike, privateKeyPem: string, trustedKeys: string, direction: Direction): AppLike;
5746
+ /**
5747
+ * Create a new App whose identity is a `did:key` (async version)
5748
+ *
5749
+ * The app signs with an Ed25519 key and accepts the peers whose public keys it
5750
+ * trusts. The provider and the verifier are built from the two arguments and
5751
+ * initialized before the app is created.
5752
+ *
5753
+ * # Arguments
5754
+ * * `name` - The base name for the app (without ID)
5755
+ * * `private_key_pem` - The app's Ed25519 private key, a PKCS#8 PEM document
5756
+ * (`-----BEGIN PRIVATE KEY-----`, as `openssl genpkey -algorithm ed25519` writes).
5757
+ * The app's identity is the `did:key` of that key (see
5758
+ * [`crate::did_key_of_private_key`]).
5759
+ * * `trusted_keys` - The JWKS (JSON) of the trust anchor: the public keys of the peers
5760
+ * the app accepts, as `OKP` `Ed25519` JWKs. A token's subject must be the `did:key`
5761
+ * of the key that signed it. It has to list the app's own key too, since MLS
5762
+ * verifies the app's own token against it.
5763
+ * * `direction` - Traffic direction: Send, Recv, Bidirectional, or None
5764
+ *
5765
+ * # Returns
5766
+ * * `Ok(Arc<App>)` - Successfully created app
5767
+ * * `Err(SlimError)` - If a key is invalid, or the app cannot be created
5768
+ */
5769
+ createAppWithDidKeyAsync(name: NameLike, privateKeyPem: string, trustedKeys: string, direction: Direction, asyncOpts_?: {
5770
+ signal: AbortSignal;
5771
+ }): Promise<AppLike>;
4825
5772
  /**
4826
5773
  * Create a new App with authentication configuration and traffic direction (blocking version)
4827
5774
  *
@@ -5021,6 +5968,97 @@ export declare class Service extends UniffiAbstractObject implements ServiceLike
5021
5968
  createAppAsync(baseName: NameLike, identityProviderConfig: IdentityProviderConfig, identityVerifierConfig: IdentityVerifierConfig, asyncOpts_?: {
5022
5969
  signal: AbortSignal;
5023
5970
  }): Promise<AppLike>;
5971
+ /**
5972
+ * Create a new App whose identity is provided by foreign-language objects - blocking version
5973
+ *
5974
+ * Blocks while the objects' async `initialize` run; see
5975
+ * [`crate::App::new_with_custom_identity`] for when not to use it.
5976
+ */
5977
+ createAppWithCustomIdentity(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction): AppLike;
5978
+ /**
5979
+ * Blocking wrapper around
5980
+ * [`Service::create_app_with_custom_identity_and_persistence_async`].
5981
+ */
5982
+ createAppWithCustomIdentityAndPersistence(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction, persistence: PersistenceConfig): AppLike;
5983
+ /**
5984
+ * Create an app whose identity is provided by objects (foreign-language
5985
+ * implementations), with restorable MLS/session
5986
+ * state persisted under `persistence.path` (async).
5987
+ *
5988
+ * Persistence uses the provider's `export_identity` / `restore_identity`
5989
+ * hooks; a provider whose `export_identity` returns `None` persists no identity, and
5990
+ * one whose `export_identity` fails stops its session records from being updated.
5991
+ * Restore the app's sessions after a restart with [`App::restore_sessions`].
5992
+ *
5993
+ * # Example
5994
+ *
5995
+ * ```rust,no_run
5996
+ * # use std::sync::Arc;
5997
+ * # use slim_bindings::*;
5998
+ * # async fn demo(
5999
+ * # service: Arc<Service>,
6000
+ * # name: Arc<Name>,
6001
+ * # provider: Arc<dyn IdentityProvider>,
6002
+ * # verifier: Arc<dyn IdentityVerifier>,
6003
+ * # ) -> Result<(), SlimError> {
6004
+ * let app = service
6005
+ * .create_app_with_custom_identity_and_persistence_async(
6006
+ * name,
6007
+ * provider,
6008
+ * verifier,
6009
+ * Direction::Bidirectional,
6010
+ * PersistenceConfig {
6011
+ * path: "/var/lib/myapp/slim".into(),
6012
+ * passphrase: Some("a-strong-passphrase".into()),
6013
+ * },
6014
+ * )
6015
+ * .await?;
6016
+ * # Ok(()) }
6017
+ * ```
6018
+ */
6019
+ createAppWithCustomIdentityAndPersistenceAsync(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction, persistence: PersistenceConfig, asyncOpts_?: {
6020
+ signal: AbortSignal;
6021
+ }): Promise<AppLike>;
6022
+ /**
6023
+ * Create a new App whose identity is provided by foreign-language objects (async version)
6024
+ *
6025
+ * `identity_provider` proves this app's identity; `identity_verifier` verifies peers.
6026
+ */
6027
+ createAppWithCustomIdentityAsync(name: NameLike, identityProvider: IdentityProvider, identityVerifier: IdentityVerifier, direction: Direction, asyncOpts_?: {
6028
+ signal: AbortSignal;
6029
+ }): Promise<AppLike>;
6030
+ /**
6031
+ * Create a new App whose identity is a `did:key` (blocking version)
6032
+ *
6033
+ * See [`Service::create_app_with_did_key_async`] for the arguments.
6034
+ */
6035
+ createAppWithDidKey(name: NameLike, privateKeyPem: string, trustedKeys: string, direction: Direction): AppLike;
6036
+ /**
6037
+ * Create a new App whose identity is a `did:key` (async version)
6038
+ *
6039
+ * The app signs with an Ed25519 key and accepts the peers whose public keys it
6040
+ * trusts. The provider and the verifier are built from the two arguments and
6041
+ * initialized before the app is created.
6042
+ *
6043
+ * # Arguments
6044
+ * * `name` - The base name for the app (without ID)
6045
+ * * `private_key_pem` - The app's Ed25519 private key, a PKCS#8 PEM document
6046
+ * (`-----BEGIN PRIVATE KEY-----`, as `openssl genpkey -algorithm ed25519` writes).
6047
+ * The app's identity is the `did:key` of that key (see
6048
+ * [`crate::did_key_of_private_key`]).
6049
+ * * `trusted_keys` - The JWKS (JSON) of the trust anchor: the public keys of the peers
6050
+ * the app accepts, as `OKP` `Ed25519` JWKs. A token's subject must be the `did:key`
6051
+ * of the key that signed it. It has to list the app's own key too, since MLS
6052
+ * verifies the app's own token against it.
6053
+ * * `direction` - Traffic direction: Send, Recv, Bidirectional, or None
6054
+ *
6055
+ * # Returns
6056
+ * * `Ok(Arc<App>)` - Successfully created app
6057
+ * * `Err(SlimError)` - If a key is invalid, or the app cannot be created
6058
+ */
6059
+ createAppWithDidKeyAsync(name: NameLike, privateKeyPem: string, trustedKeys: string, direction: Direction, asyncOpts_?: {
6060
+ signal: AbortSignal;
6061
+ }): Promise<AppLike>;
5024
6062
  /**
5025
6063
  * Create a new App with authentication configuration and traffic direction (blocking version)
5026
6064
  *
@@ -5262,6 +6300,21 @@ declare const _default: Readonly<{
5262
6300
  lift(value: UniffiByteArray): FixedIntervalBackoff;
5263
6301
  lower(value: FixedIntervalBackoff, alloc: import("@ubjs/core").RustBufferAllocator): UniffiByteArray;
5264
6302
  };
6303
+ FfiConverterTypeIdentityCallbackError: {
6304
+ read(from: RustBuffer): IdentityCallbackError;
6305
+ write(value: IdentityCallbackError, into: RustBuffer): void;
6306
+ allocationSize(value: IdentityCallbackError): number;
6307
+ lift(value: UniffiByteArray): IdentityCallbackError;
6308
+ lower(value: IdentityCallbackError, alloc: import("@ubjs/core").RustBufferAllocator): UniffiByteArray;
6309
+ };
6310
+ FfiConverterTypeIdentityExport: {
6311
+ read(from: RustBuffer): IdentityExport;
6312
+ write(value: IdentityExport, into: RustBuffer): void;
6313
+ allocationSize(value: IdentityExport): number;
6314
+ lift(value: UniffiByteArray): IdentityExport;
6315
+ lower(value: IdentityExport, alloc: import("@ubjs/core").RustBufferAllocator): UniffiByteArray;
6316
+ };
6317
+ FfiConverterTypeIdentityProvider: FfiConverterObjectWithCallbacks<IdentityProvider>;
5265
6318
  FfiConverterTypeIdentityProviderConfig: {
5266
6319
  read(from: RustBuffer): IdentityProviderConfig;
5267
6320
  write(value: IdentityProviderConfig, into: RustBuffer): void;
@@ -5269,6 +6322,7 @@ declare const _default: Readonly<{
5269
6322
  lift(value: UniffiByteArray): IdentityProviderConfig;
5270
6323
  lower(value: IdentityProviderConfig, alloc: import("@ubjs/core").RustBufferAllocator): UniffiByteArray;
5271
6324
  };
6325
+ FfiConverterTypeIdentityVerifier: FfiConverterObjectWithCallbacks<IdentityVerifier>;
5272
6326
  FfiConverterTypeIdentityVerifierConfig: {
5273
6327
  read(from: RustBuffer): IdentityVerifierConfig;
5274
6328
  write(value: IdentityVerifierConfig, into: RustBuffer): void;
@@ -5447,6 +6501,13 @@ declare const _default: Readonly<{
5447
6501
  lift(value: UniffiByteArray): SessionWithCompletion;
5448
6502
  lower(value: SessionWithCompletion, alloc: import("@ubjs/core").RustBufferAllocator): UniffiByteArray;
5449
6503
  };
6504
+ FfiConverterTypeSignatureKeys: {
6505
+ read(from: RustBuffer): SignatureKeys;
6506
+ write(value: SignatureKeys, into: RustBuffer): void;
6507
+ allocationSize(value: SignatureKeys): number;
6508
+ lift(value: UniffiByteArray): SignatureKeys;
6509
+ lower(value: SignatureKeys, alloc: import("@ubjs/core").RustBufferAllocator): UniffiByteArray;
6510
+ };
5450
6511
  FfiConverterTypeSlimError: {
5451
6512
  read(from: RustBuffer): SlimError;
5452
6513
  write(value: SlimError, into: RustBuffer): void;