@squidcloud/client 1.0.414 → 1.0.415
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/dist/cjs/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/internal-common/src/public-types/external-auth/external-auth.public-types.d.ts +39 -0
- package/dist/typescript-client/src/external-auth-client.d.ts +36 -0
- package/dist/typescript-client/src/index.d.ts +1 -0
- package/dist/typescript-client/src/public-types.d.ts +1 -0
- package/dist/typescript-client/src/squid.d.ts +10 -0
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IntegrationId } from '../communication.public-types';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for identifying a user's external auth connection.
|
|
4
|
+
* @category ExternalAuth
|
|
5
|
+
*/
|
|
6
|
+
export interface ExternalAuthConfig {
|
|
7
|
+
/** The integration ID (e.g., 'google-calendar', 'microsoft-teams'). */
|
|
8
|
+
integrationId: IntegrationId;
|
|
9
|
+
/** User-specific identifier to distinguish between different users' tokens. */
|
|
10
|
+
identifier: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Request to save an authorization code and exchange it for tokens.
|
|
14
|
+
* @category ExternalAuth
|
|
15
|
+
*/
|
|
16
|
+
export interface SaveAuthCodeRequest {
|
|
17
|
+
/** The authorization code from the auth provider. */
|
|
18
|
+
authCode: string;
|
|
19
|
+
/** Configuration identifying the user and integration. */
|
|
20
|
+
externalAuthConfig: ExternalAuthConfig;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Request to get a valid access token for an integration.
|
|
24
|
+
* @category ExternalAuth
|
|
25
|
+
*/
|
|
26
|
+
export interface GetAccessTokenRequest {
|
|
27
|
+
/** Configuration identifying the user and integration. */
|
|
28
|
+
externalAuthConfig: ExternalAuthConfig;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Response containing a valid access token and expiration time.
|
|
32
|
+
* @category ExternalAuth
|
|
33
|
+
*/
|
|
34
|
+
export interface GetAccessTokenResponse {
|
|
35
|
+
/** Valid access token for making API calls. */
|
|
36
|
+
accessToken: string;
|
|
37
|
+
/** When the access token expires. */
|
|
38
|
+
expirationTime: Date;
|
|
39
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GetAccessTokenResponse } from '../../internal-common/src/public-types/external-auth/external-auth.public-types';
|
|
2
|
+
/**
|
|
3
|
+
* Client for managing authentication tokens for external integrations.
|
|
4
|
+
*
|
|
5
|
+
* Provides methods for saving and retrieving auth tokens for external services.
|
|
6
|
+
* @category ExternalAuth
|
|
7
|
+
*/
|
|
8
|
+
export declare class ExternalAuthClient {
|
|
9
|
+
private readonly integrationId;
|
|
10
|
+
private readonly rpcManager;
|
|
11
|
+
/**
|
|
12
|
+
* Takes an auth token, potentially exchanges the auth token with an external api depending on the external auth,
|
|
13
|
+
* and stores the result in Squid's secure storage.
|
|
14
|
+
*
|
|
15
|
+
* This function requires Squid to be initialized with an API key
|
|
16
|
+
*
|
|
17
|
+
* @param authCode - The authorization code obtained from the auth provider's callback.
|
|
18
|
+
* @param identifier - A user-specific identifier (usually a user ID) to associate with the tokens.
|
|
19
|
+
* This allows multiple users to connect their own accounts to the same integration.
|
|
20
|
+
* @returns A promise that resolves with the access token and its expiration time.
|
|
21
|
+
*/
|
|
22
|
+
saveAuthCode(authCode: string, identifier: string): Promise<GetAccessTokenResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves a valid access token for the integration.
|
|
25
|
+
* Automatically refreshes the token if it has expired or is about to expire.
|
|
26
|
+
*
|
|
27
|
+
* This function requires Squid to be initialized with an API key
|
|
28
|
+
*
|
|
29
|
+
* @param identifier - The user-specific identifier that was used when saving the auth code.
|
|
30
|
+
* @returns A promise that resolves with a valid access token and its expiration time.
|
|
31
|
+
*
|
|
32
|
+
* @throws Error if no tokens are found for the given integration and identifier.
|
|
33
|
+
* The user must first complete the auth flow by calling `saveAuthCode()`.
|
|
34
|
+
*/
|
|
35
|
+
getAccessToken(identifier: string): Promise<GetAccessTokenResponse>;
|
|
36
|
+
}
|
|
@@ -26,6 +26,7 @@ export * from './document-reference';
|
|
|
26
26
|
export * from './document-reference.factory';
|
|
27
27
|
export * from './document-store';
|
|
28
28
|
export * from './execute-function-options';
|
|
29
|
+
export * from './external-auth-client';
|
|
29
30
|
export * from './extraction-client';
|
|
30
31
|
export * from './file-args-transformer';
|
|
31
32
|
export * from './file-utils';
|
|
@@ -12,6 +12,7 @@ export * from '../../internal-common/src/public-types/code-executor.public-types
|
|
|
12
12
|
export * from '../../internal-common/src/public-types/communication.public-types';
|
|
13
13
|
export * from '../../internal-common/src/public-types/context.public-types';
|
|
14
14
|
export * from '../../internal-common/src/public-types/document.public-types';
|
|
15
|
+
export * from '../../internal-common/src/public-types/external-auth/external-auth.public-types';
|
|
15
16
|
export * from '../../internal-common/src/public-types/extraction.public-types';
|
|
16
17
|
export * from '../../internal-common/src/public-types/http-status.public-types';
|
|
17
18
|
export * from '../../internal-common/src/public-types/integration.public-types';
|
|
@@ -5,6 +5,7 @@ import { CollectionReference } from './collection-reference';
|
|
|
5
5
|
import { ConnectionDetails } from './connection-details';
|
|
6
6
|
import { DistributedLock } from './distributed-lock.manager';
|
|
7
7
|
import { ExecuteFunctionOptions } from './execute-function-options';
|
|
8
|
+
import { ExternalAuthClient } from './external-auth-client';
|
|
8
9
|
import { ExtractionClient } from './extraction-client';
|
|
9
10
|
import { JobClient } from './job-client';
|
|
10
11
|
import { NotificationClient } from './notification-client';
|
|
@@ -330,6 +331,15 @@ export declare class Squid {
|
|
|
330
331
|
* @param integrationId The storage integration ID to use.
|
|
331
332
|
*/
|
|
332
333
|
personalStorage(integrationId: IntegrationId): PersonalStorageClient;
|
|
334
|
+
/**
|
|
335
|
+
* Returns a client for managing external oauth tokens for integrations.
|
|
336
|
+
* Use this to save authorization codes and retrieve access tokens.
|
|
337
|
+
* Squid automatically handles token refresh when tokens expire.
|
|
338
|
+
*
|
|
339
|
+
* @param integrationId The integration ID
|
|
340
|
+
* @returns An ExternalAuthClient instance for the specified integration
|
|
341
|
+
*/
|
|
342
|
+
externalAuth(integrationId: IntegrationId): ExternalAuthClient;
|
|
333
343
|
/**
|
|
334
344
|
* Returns a client for working with structured data extraction tools.
|
|
335
345
|
*/
|