@cobaltio/cobalt-js 9.1.0 → 9.2.0-beta.1

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/cobalt.d.ts CHANGED
@@ -34,6 +34,8 @@ export interface Application {
34
34
  };
35
35
  /** The list of connected accounts for this application */
36
36
  connected_accounts?: {
37
+ /** The connection identifier of the auth config. */
38
+ connection_id: string;
37
39
  /** The identifier (username, email, etc.) of the connected account. */
38
40
  identifier: unknown;
39
41
  /** The auth type used to connect the account. */
@@ -86,6 +88,22 @@ export interface InputField {
86
88
  value: string;
87
89
  }[];
88
90
  }
91
+ export interface OAuthParams {
92
+ /** The application slug. */
93
+ slug: string;
94
+ /** The connection identifier. */
95
+ connection?: string;
96
+ /** The key value pairs of auth data. */
97
+ payload?: Record<string, string>;
98
+ }
99
+ export interface KeyBasedParams {
100
+ /** The application slug. */
101
+ slug: string;
102
+ /** The connection identifier. */
103
+ connection?: string;
104
+ /** The key value pairs of auth data. */
105
+ payload?: Record<string, string>;
106
+ }
89
107
  /** The payload object for config. */
90
108
  export interface ConfigPayload {
91
109
  /** The application slug. */
@@ -336,23 +354,20 @@ declare class Cobalt {
336
354
  * Returns the auth URL that users can use to authenticate themselves to the
337
355
  * specified application.
338
356
  * @private
339
- * @param {String} slug The application slug.
340
- * @param {Object.<string, string>} [params] The key value pairs of auth data.
357
+ * @param {OAuthParams} params The OAuth parameters.
341
358
  * @returns {Promise<String>} The auth URL where users can authenticate themselves.
342
359
  */
343
360
  private getOAuthUrl;
344
361
  /**
345
362
  * Handle OAuth for the specified application.
346
363
  * @private
347
- * @param {String} slug The application slug.
348
- * @param {Object.<string, string>} [params] The key value pairs of auth data.
364
+ * @param {OAuthParams} params The OAuth parameters.
349
365
  * @returns {Promise<Boolean>} Whether the user authenticated.
350
366
  */
351
367
  private oauth;
352
368
  /**
353
369
  * Save auth data for the specified keybased application.
354
- * @param {String} slug The application slug.
355
- * @param {Object.<string, string>} [payload] The key value pairs of auth data.
370
+ * @param {KeyBasedParams} params The key based parameters.
356
371
  * @returns {Promise<Boolean>} Whether the auth data was saved successfully.
357
372
  */
358
373
  private keybased;
@@ -360,13 +375,15 @@ declare class Cobalt {
360
375
  * Connects the specified application using the provided authentication type and optional auth data.
361
376
  * @param params - The parameters for connecting the application.
362
377
  * @param params.slug - The application slug.
378
+ * @param params.connection - The connection identifier of the auth config.
363
379
  * @param params.type - The authentication type to use. If not provided, it defaults to `keybased` if payload is provided, otherwise `oauth2`.
364
380
  * @param params.payload - key-value pairs of authentication data required for the specified auth type.
365
381
  * @returns A promise that resolves to true if the connection was successful, otherwise false.
366
382
  * @throws Throws an error if the authentication type is invalid or the connection fails.
367
383
  */
368
- connect({ slug, type, payload, }: {
384
+ connect({ slug, connection, type, payload, }: {
369
385
  slug: string;
386
+ connection?: string;
370
387
  type?: AuthType;
371
388
  payload?: Record<string, string>;
372
389
  }): Promise<boolean>;
@@ -374,9 +391,10 @@ declare class Cobalt {
374
391
  * Disconnect the specified application and remove any associated data from Cobalt.
375
392
  * @param {String} slug The application slug.
376
393
  * @param {AuthType} [type] The authentication type to use. If not provided, it'll remove all the connected accounts.
394
+ * @param {String} [connection] The connection identifier of the auth config.
377
395
  * @returns {Promise<unknown>}
378
396
  */
379
- disconnect(slug: string, type?: AuthType): Promise<unknown>;
397
+ disconnect(slug: string, type?: AuthType, connection?: string): Promise<unknown>;
380
398
  /**
381
399
  * Returns the specified config, or creates one if it doesn't exist.
382
400
  * @param {ConfigPayload} payload The payload object for config.