@webex/byods 0.0.0-next.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.
Files changed (36) hide show
  1. package/README.md +66 -0
  2. package/dist/Errors/catalog/ExtendedError.js +24 -0
  3. package/dist/Errors/types.js +32 -0
  4. package/dist/Logger/index.js +202 -0
  5. package/dist/Logger/types.js +31 -0
  6. package/dist/base-client/index.js +182 -0
  7. package/dist/byods/index.js +127 -0
  8. package/dist/constants.js +25 -0
  9. package/dist/data-source-client/constants.js +7 -0
  10. package/dist/data-source-client/index.js +205 -0
  11. package/dist/data-source-client/types.js +5 -0
  12. package/dist/http-client/types.js +5 -0
  13. package/dist/http-utils/index.js +140 -0
  14. package/dist/index.js +48 -0
  15. package/dist/token-manager/index.js +232 -0
  16. package/dist/token-storage-adapter/index.js +80 -0
  17. package/dist/token-storage-adapter/types.js +5 -0
  18. package/dist/types/Errors/catalog/ExtendedError.d.ts +14 -0
  19. package/dist/types/Errors/types.d.ts +32 -0
  20. package/dist/types/Logger/index.d.ts +71 -0
  21. package/dist/types/Logger/types.d.ts +27 -0
  22. package/dist/types/base-client/index.d.ts +91 -0
  23. package/dist/types/byods/index.d.ts +43 -0
  24. package/dist/types/constants.d.ts +17 -0
  25. package/dist/types/data-source-client/constants.d.ts +1 -0
  26. package/dist/types/data-source-client/index.d.ts +87 -0
  27. package/dist/types/data-source-client/types.d.ts +108 -0
  28. package/dist/types/http-client/types.d.ts +53 -0
  29. package/dist/types/http-utils/index.d.ts +70 -0
  30. package/dist/types/index.d.ts +8 -0
  31. package/dist/types/token-manager/index.d.ts +101 -0
  32. package/dist/types/token-storage-adapter/index.d.ts +54 -0
  33. package/dist/types/token-storage-adapter/types.d.ts +46 -0
  34. package/dist/types/types.d.ts +112 -0
  35. package/dist/types.js +5 -0
  36. package/package.json +121 -0
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.InMemoryTokenStorageAdapter = void 0;
7
+ /**
8
+ * An in-memory adapter for storing, listing and retrieving service app authorization tokens.
9
+ *
10
+ * @public
11
+ */
12
+ class InMemoryTokenStorageAdapter {
13
+ /**
14
+ * The local memory cache for the tokens.
15
+ */
16
+
17
+ constructor(tokenCache = {}) {
18
+ this.tokenCache = tokenCache;
19
+ }
20
+
21
+ /**
22
+ * Method to set the token for an organization.
23
+ * @param orgId Organization ID
24
+ * @param token Respective token
25
+ * @example
26
+ * await storageAdapter.setToken('org-id', token);
27
+ */
28
+ async setToken(orgId, token) {
29
+ this.tokenCache[orgId] = token;
30
+ }
31
+
32
+ /**
33
+ * Method to extract a token based on the organization id.
34
+ * @param orgId Organization ID
35
+ * @returns {OrgServiceAppAuthorization} The token object for the organization
36
+ * @example
37
+ * const token = await storageAdapter.getToken('org-id');
38
+ */
39
+ async getToken(orgId) {
40
+ if (this.tokenCache[orgId]) {
41
+ return this.tokenCache[orgId];
42
+ }
43
+ throw new Error(`Service App token not found for org ID: ${orgId}`);
44
+ }
45
+
46
+ /**
47
+ * Method which returns the list of all tokens stored in the InMemoryTokenStorageAdapter.
48
+ * @returns {OrgServiceAppAuthorization[]} List of
49
+ * @example
50
+ * const tokens = await storageAdapter.listTokens();
51
+ */
52
+ async listTokens() {
53
+ return Object.values(this.tokenCache);
54
+ }
55
+
56
+ /**
57
+ * Method to delete a token based on the organization id.
58
+ * @param orgId Organization ID
59
+ * @returns {Promise<void>}
60
+ * @example
61
+ * await storageAdapter.deleteToken('org-id');
62
+ */
63
+ async deleteToken(orgId) {
64
+ if (!this.tokenCache[orgId]) {
65
+ throw new Error(`Service App token not found for org ID: ${orgId}`);
66
+ }
67
+ delete this.tokenCache[orgId];
68
+ }
69
+
70
+ /**
71
+ * Method to remove all tokens stored in the InMemoryTokenStorageAdapter.
72
+ * @returns {Promise<void>}
73
+ * @example
74
+ * await storageAdapter.resetTokens();
75
+ */
76
+ async resetTokens() {
77
+ this.tokenCache = {};
78
+ }
79
+ }
80
+ exports.InMemoryTokenStorageAdapter = InMemoryTokenStorageAdapter;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,14 @@
1
+ import { ErrorMessage, ERROR_TYPE } from '../types';
2
+ /**
3
+ *
4
+ */
5
+ export default class ExtendedError extends Error {
6
+ type: ERROR_TYPE;
7
+ /**
8
+ * Constructs an ExtendedError instance.
9
+ *
10
+ * @param msg - The error message.
11
+ * @param type - The type of the error.
12
+ */
13
+ constructor(msg: ErrorMessage, type?: ERROR_TYPE);
14
+ }
@@ -0,0 +1,32 @@
1
+ import { IMetaContext } from '../Logger/types';
2
+ export type ErrorMessage = string;
3
+ export declare enum ERROR_TYPE {
4
+ DEFAULT = "default_error",
5
+ FORBIDDEN_ERROR = "forbidden",
6
+ NOT_FOUND = "not_found",
7
+ REGISTRATION_ERROR = "registration_error",
8
+ SERVICE_UNAVAILABLE = "service_unavailable",
9
+ TIMEOUT = "timeout",
10
+ TOKEN_ERROR = "token_error",
11
+ SERVER_ERROR = "server_error",
12
+ SCHEDULE_JWS_TOKEN_REFRESH_ERROR = "schedule_jws_token_refresh_error",
13
+ START_AUTO_REFRESH_ERROR = "start_auto_refresh_error"
14
+ }
15
+ export declare enum ERROR_CODE {
16
+ UNAUTHORIZED = 401,
17
+ FORBIDDEN = 403,
18
+ DEVICE_NOT_FOUND = 404,
19
+ INTERNAL_SERVER_ERROR = 500,
20
+ NOT_IMPLEMENTED = 501,
21
+ SERVICE_UNAVAILABLE = 503,
22
+ BAD_REQUEST = 400,
23
+ REQUEST_TIMEOUT = 408,
24
+ TOO_MANY_REQUESTS = 429
25
+ }
26
+ export interface ErrorContext extends IMetaContext {
27
+ }
28
+ export type ErrorObject = {
29
+ message: ErrorMessage;
30
+ type: ERROR_TYPE;
31
+ context: ErrorContext;
32
+ };
@@ -0,0 +1,71 @@
1
+ import ExtendedError from '../Errors/catalog/ExtendedError';
2
+ import { LogContext, LOGGER } from './types';
3
+ declare class Logger {
4
+ private currentLogLevel;
5
+ /**
6
+ * A wrapper around console which prints
7
+ * based on the level defined.
8
+ *
9
+ * @param message - Log Message to print.
10
+ * @param level - Log level.
11
+ */
12
+ private writeToConsole;
13
+ /**
14
+ * Format the Log message as 'timestamp BYODS SDK - [level]: file:example.ts - method:methodName - Actual log message'.
15
+ *
16
+ * @param context - File and method.
17
+ * @param level - Log level.
18
+ * @returns - Formatted string.
19
+ */
20
+ private format;
21
+ /**
22
+ * Used to initialize the logger module
23
+ * with a certain level.
24
+ *
25
+ * @param level - Log Level.
26
+ */
27
+ setLogger(level: string, module: string): void;
28
+ /**
29
+ * To retrieve the current log level.
30
+ *
31
+ * @returns - Log level.
32
+ */
33
+ getLogLevel(): LOGGER;
34
+ /**
35
+ * Can be used to print only useful information.
36
+ *
37
+ * @param message - Caller emitted string.
38
+ * @param context - File and method which called.
39
+ */
40
+ log(message: string, context: LogContext): void;
41
+ /**
42
+ * Can be used to print informational messages.
43
+ *
44
+ * @param message - Caller emitted string.
45
+ * @param context - File and method which called.
46
+ */
47
+ info(message: string, context: LogContext): void;
48
+ /**
49
+ * Can be used to print warning messages.
50
+ *
51
+ * @param message - Caller emitted string.
52
+ * @param context - File and method which called.
53
+ */
54
+ warn(message: string, context: LogContext): void;
55
+ /**
56
+ * Can be used to print the stack trace of the entire call path.
57
+ *
58
+ * @param message - Caller emitted string.
59
+ * @param context - File and method which called.
60
+ */
61
+ trace(message: string, context: LogContext): void;
62
+ /**
63
+ * Can be used to print only errors.
64
+ *
65
+ * @param error - Error string .
66
+ * @param context - File and method which called.
67
+ */
68
+ error(error: ExtendedError, context: LogContext): void;
69
+ }
70
+ declare const log: Logger;
71
+ export default log;
@@ -0,0 +1,27 @@
1
+ export interface IMetaContext {
2
+ file?: string;
3
+ method?: string;
4
+ }
5
+ export type LogContext = IMetaContext;
6
+ export declare enum LOG_PREFIX {
7
+ MAIN = "BYODOS_SDK",
8
+ FILE = "file",
9
+ METHOD = "method",
10
+ EVENT = "event",
11
+ MESSAGE = "message",
12
+ ERROR = "error"
13
+ }
14
+ export declare enum LOGGING_LEVEL {
15
+ error = 1,
16
+ warn = 2,
17
+ log = 3,
18
+ info = 4,
19
+ trace = 5
20
+ }
21
+ export declare enum LOGGER {
22
+ ERROR = "error",
23
+ WARN = "warn",
24
+ INFO = "info",
25
+ LOG = "log",
26
+ TRACE = "trace"
27
+ }
@@ -0,0 +1,91 @@
1
+ import { LoggerConfig } from '../types';
2
+ import TokenManager from '../token-manager';
3
+ import DataSourceClient from '../data-source-client';
4
+ import { HttpClient, ApiResponse } from '../http-client/types';
5
+ import { HttpRequestInit } from '../http-utils';
6
+ export default class BaseClient {
7
+ private baseUrl;
8
+ private headers;
9
+ private tokenManager;
10
+ private orgId;
11
+ private loggerConfig;
12
+ dataSource: DataSourceClient;
13
+ /**
14
+ * Creates an instance of BaseClient.
15
+ * @param {string} baseUrl - The base URL for the API.
16
+ * @param {Record<string, string>} headers - The additional headers to be used in requests.
17
+ * @param {TokenManager} tokenManager - The token manager instance.
18
+ * @param {string} orgId - The organization ID.
19
+ * @example
20
+ * const client = new BaseClient('https://webexapis.com/v1', { 'Your-Custom-Header': 'some value' }, tokenManager, 'org123');
21
+ */
22
+ constructor(baseUrl: string, headers: Record<string, string>, tokenManager: TokenManager, orgId: string, loggerConfig?: LoggerConfig);
23
+ /**
24
+ * Makes an HTTP request.
25
+ * @param {string} endpoint - The API endpoint.
26
+ * @param {HttpRequestInit} [options={}] - The request options.
27
+ * @returns {Promise<ApiResponse<T>>} - The API response.
28
+ * @template T
29
+ * @example
30
+ * const response = await client.request('/endpoint', { method: 'GET', headers: {} });
31
+ */
32
+ request<T>(endpoint: string, options?: HttpRequestInit): Promise<ApiResponse<T>>;
33
+ /**
34
+ * Makes a POST request.
35
+ * @param {string} endpoint - The API endpoint.
36
+ * @param {Record<string, any>} body - The request body.
37
+ * @param {Record<string, string>} [headers={}] - The request headers.
38
+ * @returns {Promise<ApiResponse<T>>} - The API response.
39
+ * @template T
40
+ * @example
41
+ * const response = await client.post('/endpoint', { key: 'value' });
42
+ */
43
+ post<T>(endpoint: string, body: Record<string, any>, headers?: Record<string, string>): Promise<ApiResponse<T>>;
44
+ /**
45
+ * Makes a PUT request.
46
+ * @param {string} endpoint - The API endpoint.
47
+ * @param {Record<string, any>} body - The request body.
48
+ * @returns {Promise<ApiResponse<T>>} - The API response.
49
+ * @template T
50
+ * @example
51
+ * const response = await client.put('/endpoint', { key: 'value' });
52
+ */
53
+ put<T>(endpoint: string, body: Record<string, any>, headers?: Record<string, string>): Promise<ApiResponse<T>>;
54
+ /**
55
+ * Makes a PATCH request.
56
+ * @param {string} endpoint - The API endpoint.
57
+ * @param {Record<string, any>} body - The request body.
58
+ * @returns {Promise<ApiResponse<T>>} - The API response.
59
+ * @template T
60
+ * @example
61
+ * const response = await client.patch('/endpoint', { key: 'value' });
62
+ */
63
+ patch<T>(endpoint: string, body: Record<string, any>, headers?: Record<string, string>): Promise<ApiResponse<T>>;
64
+ /**
65
+ * Makes a GET request.
66
+ * @param {string} endpoint - The API endpoint.
67
+ * @returns {Promise<ApiResponse<T>>} - The API response.
68
+ * @template T
69
+ * @example
70
+ * const response = await client.get('/endpoint');
71
+ */
72
+ get<T>(endpoint: string, headers?: Record<string, string>): Promise<ApiResponse<T>>;
73
+ /**
74
+ * Makes a DELETE request.
75
+ * @param {string} endpoint - The API endpoint.
76
+ * @returns {Promise<ApiResponse<T>>} - The API response.
77
+ * @template T
78
+ * @example
79
+ * const response = await client.delete('/endpoint');
80
+ */
81
+ delete<T>(endpoint: string, headers?: Record<string, string>): Promise<ApiResponse<T>>;
82
+ /**
83
+ * Get an HTTP client for a specific organization.
84
+ * @returns {HttpClient} - An object containing methods for making HTTP requests.
85
+ * @example
86
+ * const httpClient = client.getHttpClientForOrg();
87
+ * const response = await httpClient.get('/endpoint');
88
+ */
89
+ getHttpClientForOrg(): HttpClient;
90
+ private getToken;
91
+ }
@@ -0,0 +1,43 @@
1
+ import BaseClient from '../base-client';
2
+ import { SDKConfig, JWSTokenVerificationResult } from '../types';
3
+ import TokenManager from '../token-manager';
4
+ /**
5
+ * The BYoDS SDK.
6
+ */
7
+ export default class BYODS {
8
+ private headers;
9
+ private jwksCache;
10
+ private jwks;
11
+ private env;
12
+ private config;
13
+ private baseUrl;
14
+ /**
15
+ * The token manager for the SDK.
16
+ */
17
+ tokenManager: TokenManager;
18
+ /**
19
+ * Constructs a new instance of the BYODS SDK.
20
+ *
21
+ * @param {SDKConfig} config - The configuration object containing clientId and clientSecret.
22
+ * @example
23
+ * const sdk = new BYODS({ clientId: 'your-client-id', clientSecret: 'your-client-secret' });
24
+ */
25
+ constructor({ clientId, clientSecret, tokenStorageAdapter, logger, }: SDKConfig);
26
+ /**
27
+ * Verifies a JWS token using the public key.
28
+ * @param {string} jws - The JWS token to verify.
29
+ * @returns {Promise<JWSTokenVerificationResult>} A promise that resolves to an object containing the result of the verification.
30
+ * @example
31
+ * const result = await sdk.verifyJWSToken('jws-token');
32
+ */
33
+ verifyJWSToken(jws: string): Promise<JWSTokenVerificationResult>;
34
+ /**
35
+ * Retrieves a client instance for a specific organization.
36
+ *
37
+ * @param {string} orgId - The unique identifier of the organization.
38
+ * @returns {BaseClient} A new instance of BaseClient configured for the specified organization.
39
+ * @example
40
+ * const client = sdk.getClientForOrg('org-id');
41
+ */
42
+ getClientForOrg(orgId: string): BaseClient;
43
+ }
@@ -0,0 +1,17 @@
1
+ import { LOGGER } from './Logger/types';
2
+ export declare const BYODS_FILE = "BYODS";
3
+ export declare const BYODS_SDK_VERSION = "0.0.1";
4
+ export declare const BYODS_PACKAGE_NAME = "BYoDS NodeJS SDK";
5
+ export declare const USER_AGENT: string;
6
+ export declare const PRODUCTION_BASE_URL = "https://webexapis.com/v1";
7
+ export declare const INTEGRATION_BASE_URL = "https://integration.webexapis.com/v1";
8
+ export declare const PRODUCTION_JWKS_URL = "https://idbroker.webex.com/idb/oauth2/v2/keys/verificationjwk";
9
+ export declare const INTEGRATION_JWKS_URL = "https://idbrokerbts.webex.com/idb/oauth2/v2/keys/verificationjwk";
10
+ export declare const APPLICATION_ID_PREFIX = "ciscospark://us/APPLICATION/";
11
+ export declare const BYODS_BASE_CLIENT_MODULE = "base-client";
12
+ export declare const BYODS_MODULE = "byods";
13
+ export declare const BYODS_TOKEN_MANAGER_MODULE = "token-manager";
14
+ export declare const BYODS_DATA_SOURCE_CLIENT_MODULE = "data-source-client";
15
+ export declare const DEFAULT_LOGGER_CONFIG: {
16
+ level: LOGGER;
17
+ };
@@ -0,0 +1 @@
1
+ export declare const DATASOURCE_ENDPOINT = "/dataSources";
@@ -0,0 +1,87 @@
1
+ import { LoggerConfig } from '../types';
2
+ import { DataSourceRequest, DataSourceResponse, DataSourceUpdateRequest, Cancellable } from './types';
3
+ import { HttpClient, ApiResponse } from '../http-client/types';
4
+ /**
5
+ * Client for interacting with the /dataSource API.
6
+ */
7
+ export default class DataSourceClient {
8
+ private httpClient;
9
+ private loggerConfig;
10
+ /**
11
+ * Creates an instance of DataSourceClient.
12
+ * @param {HttpClient} httpClient - The HttpClient instance to use for API requests.
13
+ * @example
14
+ * const httpClient = new HttpClient();
15
+ * const client = new DataSourceClient(httpClient);
16
+ */
17
+ constructor(httpClient: HttpClient, loggerConfig?: LoggerConfig);
18
+ /**
19
+ * Creates a new data source.
20
+ * @param {DataSourceRequest} createDataSourceRequest - The request object for creating a data source.
21
+ * @returns {Promise<ApiResponse<DataSourceResponse>>} - A promise that resolves to the API response containing the created data source.
22
+ * @example
23
+ * const request: DataSourceRequest = { name: 'New DataSource', url: 'https://mydatasource.com', schemaId: '123', audience: 'myaudience', subject: 'mysubject', nonce: 'uniqueNonce' };
24
+ * const response = await client.create(request);
25
+ */
26
+ create(dataSourcePayload: DataSourceRequest): Promise<ApiResponse<DataSourceResponse>>;
27
+ /**
28
+ * Retrieves a data source by ID.
29
+ * @param {string} id - The ID of the data source to retrieve.
30
+ * @returns {Promise<ApiResponse<DataSourceResponse>>} - A promise that resolves to the API response containing the data source.
31
+ * @example
32
+ * const id = '123';
33
+ * const response = await client.get(id);
34
+ */
35
+ get(id: string): Promise<ApiResponse<DataSourceResponse>>;
36
+ /**
37
+ * Lists all data sources.
38
+ * @returns {Promise<ApiResponse<DataSourceResponse[]>>} - A promise that resolves to the API response containing the list of data sources.
39
+ * @example
40
+ * const response = await client.list();
41
+ */
42
+ list(): Promise<ApiResponse<DataSourceResponse[]>>;
43
+ /**
44
+ * Updates a data source by ID.
45
+ * @param {string} id - The ID of the data source to update.
46
+ * @param {DataSourceRequest} updateDataSourceRequest - The request object for updating a data source.
47
+ * @returns {Promise<ApiResponse<DataSourceResponse>>} - A promise that resolves to the API response containing the updated data source.
48
+ * @example
49
+ * const id = '123';
50
+ * const request: DataSourceRequest = { name: 'Updated DataSource', url: 'https://mydatasource.com', schemaId: '123', audience: 'myaudience', subject: 'mysubject', nonce: 'uniqueNonce' };
51
+ * const response = await client.update(id, request);
52
+ */
53
+ update(id: string, dataSourcePayload: DataSourceUpdateRequest): Promise<ApiResponse<DataSourceResponse>>;
54
+ /**
55
+ * Deletes a data source by ID.
56
+ * @param {string} id - The ID of the data source to delete.
57
+ * @returns {Promise<ApiResponse<void>>} - A promise that resolves to the API response confirming the deletion.
58
+ * @example
59
+ * const id = '123';
60
+ * const response = await client.delete(id);
61
+ */
62
+ delete(id: string): Promise<ApiResponse<void>>;
63
+ /**
64
+ * This method refreshes the DataSource token using dataSourceId, tokenLifetimeMinutes & nonceGenerator.
65
+ * @param {string} dataSourceId The id of the data source.
66
+ * @param {number} tokenLifetimeMinutes The refresh interval in minutes for the data source. Defaults to 60 mins. Should be an integer.
67
+ * @param {string} nonceGenerator Accepts an nonceGenerator, developer can provide their own nonceGenerator, defaults to randomUUID.
68
+ * @returns {Promise<Cancelable>} A promise that resolves to an object containing a cancel method that cancels the timer.
69
+ * @example
70
+ * try {
71
+ const result = await dataSourceClient.scheduleJWSTokenRefresh('myDataSourceId', 'uniqueNonce', 'myTokenLifeTimeMinutes');
72
+ // Use the cancel function if needed!
73
+ result.cancel();
74
+ } catch (error) {
75
+ console.error('Error scheduling JWS refresh for data source:', error);
76
+ }
77
+ */
78
+ scheduleJWSTokenRefresh(dataSourceId: string, tokenLifetimeMinutes?: number, nonceGenerator?: () => string): Promise<Cancellable>;
79
+ /**
80
+ * Sets up a timer that will auto refresh the DataSource JWS token for given intervals
81
+ * @param {string} dataSourceId The id of the data source
82
+ * @param {number} tokenLifetimeMinutes The refresh interval in minutes for the data source. Defaults to 60 mins. Should be <= 1440 & >=1.
83
+ * @param {string} nonceGenerator Accepts an nonceGenerator that will generate nonce for the data source request.
84
+ * @returns {Promise<NodeJS.Timeout>} A promise that resolves to the API response containing NodeJS.Timeout.
85
+ */
86
+ private startAutoRefresh;
87
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Represents the response from a data source.
3
+ *
4
+ * @public
5
+ */
6
+ export interface DataSourceResponse {
7
+ /**
8
+ * The unique identifier for the data source response.
9
+ */
10
+ id: string;
11
+ /**
12
+ * The identifier for the schema associated with the data source.
13
+ */
14
+ schemaId: string;
15
+ /**
16
+ * The identifier for the organization associated with the data source.
17
+ */
18
+ orgId: string;
19
+ /**
20
+ * The plain client identifier (not a Hydra base64 id string).
21
+ */
22
+ applicationId: string;
23
+ /**
24
+ * The status of the data source response. Either "active" or "disabled".
25
+ */
26
+ status: 'active' | 'disabled';
27
+ /**
28
+ * The JSON Web Signature token associated with the data source response.
29
+ */
30
+ jwsToken: string;
31
+ /**
32
+ * The identifier of the user who created the data source response.
33
+ */
34
+ createdBy: string;
35
+ /**
36
+ * The timestamp when the data source response was created.
37
+ */
38
+ createdAt: string;
39
+ /**
40
+ * The identifier of the user who last updated the data source response.
41
+ */
42
+ updatedBy?: string;
43
+ /**
44
+ * The timestamp when the data source response was last updated.
45
+ */
46
+ updatedAt?: string;
47
+ /**
48
+ * The error message associated with the data source response, if any.
49
+ */
50
+ errorMessage?: string;
51
+ }
52
+ /**
53
+ * Represents the request to a data source.
54
+ *
55
+ * @public
56
+ */
57
+ export interface DataSourceRequest {
58
+ /**
59
+ * The identifier for the schema associated with the data source.
60
+ */
61
+ schemaId: string;
62
+ /**
63
+ * The URL of the data source.
64
+ */
65
+ url: string;
66
+ /**
67
+ * The audience for the data source request.
68
+ */
69
+ audience: string;
70
+ /**
71
+ * The subject of the data source request.
72
+ */
73
+ subject: string;
74
+ /**
75
+ * A unique nonce for the data source request.
76
+ */
77
+ nonce: string;
78
+ /**
79
+ * The lifetime of the token in minutes.
80
+ */
81
+ tokenLifetimeMinutes: number;
82
+ }
83
+ /**
84
+ * Represents the request to update a data source.
85
+ *
86
+ * @public
87
+ */
88
+ export interface DataSourceUpdateRequest extends DataSourceRequest {
89
+ /**
90
+ * The status of the data source request. Either "active" or "disabled".
91
+ */
92
+ status: 'active' | 'disabled';
93
+ /**
94
+ * The error message associated with the data source update request. It is optional for "active" but required for "disabled".
95
+ */
96
+ errorMessage?: string;
97
+ }
98
+ /**
99
+ * Represents the response from a list.
100
+ *
101
+ * @public
102
+ */
103
+ export interface ListResponse<T> {
104
+ items: T[];
105
+ }
106
+ export interface Cancellable {
107
+ cancel: () => void;
108
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Represents a generic API response.
3
+ *
4
+ * @public
5
+ */
6
+ export interface ApiResponse<T> {
7
+ /**
8
+ * The response data.
9
+ */
10
+ data: T;
11
+ /**
12
+ * The response status code.
13
+ */
14
+ status: number;
15
+ }
16
+ /**
17
+ * Interface representing an HTTP client.
18
+ */
19
+ export interface HttpClient {
20
+ /**
21
+ * Make a GET request to the specified endpoint.
22
+ * @param {string} endpoint - The endpoint to send the GET request to.
23
+ * @returns {Promise<ApiResponse<T>>} - A promise that resolves to the response data.
24
+ */
25
+ get<T>(endpoint: string): Promise<ApiResponse<T>>;
26
+ /**
27
+ * Make a DELETE request to the specified endpoint.
28
+ * @param {string} endpoint - The endpoint to send the DELETE request to.
29
+ * @returns {Promise<ApiResponse<T>>} - A promise that resolves to the response data.
30
+ */
31
+ delete<T>(endpoint: string): Promise<ApiResponse<T>>;
32
+ /**
33
+ * Make a POST request to the specified endpoint with the given body.
34
+ * @param {string} endpoint - The endpoint to send the POST request to.
35
+ * @param {Record<string, any>} body - The body of the POST request.
36
+ * @returns {Promise<ApiResponse<T>>} - A promise that resolves to the response data.
37
+ */
38
+ post<T>(endpoint: string, body: Record<string, any>): Promise<ApiResponse<T>>;
39
+ /**
40
+ * Make a PUT request to the specified endpoint with the given body.
41
+ * @param {string} endpoint - The endpoint to send the PUT request to.
42
+ * @param {Record<string, any>} body - The body of the PUT request.
43
+ * @returns {Promise<ApiResponse<T>>} - A promise that resolves to the response data.
44
+ */
45
+ put<T>(endpoint: string, body: Record<string, any>): Promise<ApiResponse<T>>;
46
+ /**
47
+ * Make a PATCH request to the specified endpoint with the given body.
48
+ * @param {string} endpoint - The endpoint to send the PATCH request to.
49
+ * @param {Record<string, any>} body - The body of the PATCH request.
50
+ * @returns {Promise<ApiResponse<T>>} - A promise that resolves to the response data.
51
+ */
52
+ patch<T>(endpoint: string, body: Record<string, any>): Promise<ApiResponse<T>>;
53
+ }