Client for interacting with the /dataSource API.

Hierarchy

  • DataSourceClient

Constructors

  • Creates an instance of DataSourceClient.

    Example

    const httpClient = new HttpClient();
    const client = new DataSourceClient(httpClient);

    Parameters

    • httpClient: HttpClient

      The HttpClient instance to use for API requests.

    • loggerConfig: LoggerConfig = DEFAULT_LOGGER_CONFIG

    Returns DataSourceClient

Methods

  • Creates a new data source.

    Returns

    • A promise that resolves to the API response containing the created data source.

    Example

    const request: DataSourceRequest = { name: 'New DataSource', url: 'https://mydatasource.com', schemaId: '123', audience: 'myaudience', subject: 'mysubject', nonce: 'uniqueNonce' };
    const response = await client.create(request);

    Parameters

    • dataSourcePayload: DataSourceRequest

    Returns Promise<ApiResponse<DataSourceResponse>>

  • Retrieves a data source by ID.

    Returns

    • A promise that resolves to the API response containing the data source.

    Example

    const id = '123';
    const response = await client.get(id);

    Parameters

    • id: string

      The ID of the data source to retrieve.

    Returns Promise<ApiResponse<DataSourceResponse>>

  • Lists all data sources.

    Returns

    • A promise that resolves to the API response containing the list of data sources.

    Example

    const response = await client.list();
    

    Returns Promise<ApiResponse<DataSourceResponse[]>>

  • Updates a data source by ID.

    Returns

    • A promise that resolves to the API response containing the updated data source.

    Example

    const id = '123';
    const request: DataSourceRequest = { name: 'Updated DataSource', url: 'https://mydatasource.com', schemaId: '123', audience: 'myaudience', subject: 'mysubject', nonce: 'uniqueNonce' };
    const response = await client.update(id, request);

    Parameters

    • id: string

      The ID of the data source to update.

    • dataSourcePayload: DataSourceUpdateRequest

    Returns Promise<ApiResponse<DataSourceResponse>>

  • Deletes a data source by ID.

    Returns

    • A promise that resolves to the API response confirming the deletion.

    Example

    const id = '123';
    const response = await client.delete(id);

    Parameters

    • id: string

      The ID of the data source to delete.

    Returns Promise<ApiResponse<void>>

  • This method refreshes the DataSource token using dataSourceId, tokenLifetimeMinutes & nonceGenerator.

    Returns

    A promise that resolves to an object containing a cancel method that cancels the timer.

    Example

    try {
    const result = await dataSourceClient.scheduleJWSTokenRefresh('myDataSourceId', 'uniqueNonce', 'myTokenLifeTimeMinutes');
    // Use the cancel function if needed!
    result.cancel();
    } catch (error) {
    console.error('Error scheduling JWS refresh for data source:', error);
    }

    Parameters

    • dataSourceId: string

      The id of the data source.

    • tokenLifetimeMinutes: number = 60

      The refresh interval in minutes for the data source. Defaults to 60 mins. Should be an integer.

    • nonceGenerator: (() => string) = crypto.randomUUID

      Accepts an nonceGenerator, developer can provide their own nonceGenerator, defaults to randomUUID.

        • (): string
        • Returns string

    Returns Promise<Cancellable>