interface DigimeSDK {
    createProvisionalStorage: (
        props: CreateProvisionalStorageOptions,
    ) => Promise<CreateProvisionalStorageResponse>;
    deleteAccount: (
        props: DeleteAccountOptions,
    ) => Promise<DeleteAccountResponse>;
    deleteStorageFiles: (
        props: DeleteStorageFilesOptions,
    ) => Promise<DeleteStorageFilesResponse>;
    deleteUser: (props: DeleteUserOptions) => Promise<DeleteUserResponse>;
    downloadStorageFile: (
        props: DownloadStorageFileOptions,
    ) => Promise<DownloadStorageFileResponse>;
    exchangeCodeForToken: (
        props: ExchangeCodeForTokenOptions,
    ) => Promise<UserAccessToken>;
    getAuthorizeUrl: (
        props: GetAuthorizeUrlOptions,
    ) => Promise<GetAuthorizeUrlResponse>;
    getOnboardServiceUrl: (
        props: GetOnboardServiceUrlOptions,
    ) => Promise<GetOnboardServiceUrlResponse>;
    getPortabilityReport: (
        props: GetPortabilityReportOptions,
    ) => Promise<GetPortabilityReportResponse>;
    getReauthorizeAccountUrl: (
        props: GetReauthorizeAccountUrlOptions,
    ) => Promise<GetReauthorizeAccountUrlResponse>;
    getReauthorizeUrl: (
        props: GetReauthorizeUrlOptions,
    ) => Promise<GetReauthorizeUrlResponse>;
    getRevokeAccountPermissionUrl: (
        props: GetRevokeAccountPermissionUrlOptions,
    ) => Promise<GetRevokeAccountPermissionUrlResponse>;
    getServiceSampleDataSets: (
        props: GetServiceSampleDataSetsOptions,
    ) => Promise<GetServiceSampleDataSetsResponse>;
    getUserStorage: (
        props: GetUserStorageOptions,
    ) => Promise<GetUserStorageResponse>;
    listStorageFiles: (
        props: ListStorageFilesOptions,
    ) => Promise<ListStorageFilesResponse>;
    pushData: (props: PushDataOptions) => Promise<void>;
    queryCategories: (
        props: QueryCategoriesOptions,
    ) => Promise<QueryCategoriesResponse>;
    queryCountries: (
        props: QueryCountriesOptions,
    ) => Promise<QueryCountriesResponse>;
    queryPlatforms: (
        props: QueryPlatformsOptions,
    ) => Promise<QueryPlatformsResponse>;
    querySources: (props: QuerySourcesOptions) => Promise<QuerySourcesResponse>;
    readAccounts: (props: ReadAccountsOptions) => Promise<ReadAccountsResponse>;
    readAllFiles: (props: ReadAllFilesOptions) => ReadAllFilesResponse;
    readFile: (props: ReadFileOptions) => Promise<ReadFileResponse>;
    readFileList: (props: ReadFileListOptions) => Promise<ReadFileListResponse>;
    readFileMetadata: (
        props: ReadFileMetadataOptions,
    ) => Promise<ReadFileMetadataResponse>;
    readSession: (props: ReadSessionOptions) => Promise<ReadSessionResponse>;
    refreshToken: (props: RefreshTokenOptions) => Promise<UserAccessToken>;
    uploadFileToStorage: (
        props: UploadFileToStorageOptions,
    ) => Promise<UploadFileToStorageResponse>;
}

Authorization

exchangeCodeForToken: (
    props: ExchangeCodeForTokenOptions,
) => Promise<UserAccessToken>

This is called when authorization flow successfully completed, and you have been given an authorization code. We can then use this function to exchange for an access token.

getAuthorizeUrl: (
    props: GetAuthorizeUrlOptions,
) => Promise<GetAuthorizeUrlResponse>

In order to push or read data from digi.me, we first need to create an access token. Access tokens are linked to a contract, and it is possible to create multiple access tokens that access to the same digi.me libary. This function is called when:

  • Authorize a new user. You have the option to also onboard a service during this process.
  • An existing user authorizing a new contract.
  • Existing user’s refresh token has expired and we need to extend it.
// run typedoc --help for a list of supported languages
const instance = new MyClass();
getOnboardServiceUrl: (
    props: GetOnboardServiceUrlOptions,
) => Promise<GetOnboardServiceUrlResponse>

This is called when we already have a valid user access token for this user and we want to add more services to this user’s library.

getReauthorizeAccountUrl: (
    props: GetReauthorizeAccountUrlOptions,
) => Promise<GetReauthorizeAccountUrlResponse>

This is called when we need to reauthorize specific account due to Service authorization required error

getReauthorizeUrl: (
    props: GetReauthorizeUrlOptions,
) => Promise<GetReauthorizeUrlResponse>

This is called when user receives InvalidToken error (401 - The token (refresh_token) is invalid). We can use this method to get new AT/RT pair.

getRevokeAccountPermissionUrl: (
    props: GetRevokeAccountPermissionUrlOptions,
) => Promise<GetRevokeAccountPermissionUrlResponse>

Revoke account permission

refreshToken: (props: RefreshTokenOptions) => Promise<UserAccessToken>

This is called if you want to issue new token

Delete

deleteAccount: (props: DeleteAccountOptions) => Promise<DeleteAccountResponse>

Deletes account on digi.me

deleteUser: (props: DeleteUserOptions) => Promise<DeleteUserResponse>

Deletes user data on digi.me

Other

getPortabilityReport: (
    props: GetPortabilityReportOptions,
) => Promise<GetPortabilityReportResponse>

Get Portability Report.

Push

pushData: (props: PushDataOptions) => Promise<void>

Push something to the user's digi.me library or to provider

Read

getServiceSampleDataSets: (
    props: GetServiceSampleDataSetsOptions,
) => Promise<GetServiceSampleDataSetsResponse>

Get a list of datasets for given sourceId.

queryCategories: (
    props: QueryCategoriesOptions,
) => Promise<QueryCategoriesResponse>

Get a list of possible categories

queryCountries: (
    props: QueryCountriesOptions,
) => Promise<QueryCountriesResponse>

Get a list of possible countries

queryPlatforms: (
    props: QueryPlatformsOptions,
) => Promise<QueryPlatformsResponse>

Get a list of possible platforms

querySources: (props: QuerySourcesOptions) => Promise<QuerySourcesResponse>

Get a list of possible sources a user can onboard

readAccounts: (props: ReadAccountsOptions) => Promise<ReadAccountsResponse>

Get a list of accounts that exist of current user's library.

readAllFiles: (props: ReadAllFilesOptions) => ReadAllFilesResponse

Handy util function to download all available user files.

readFile: (props: ReadFileOptions) => Promise<ReadFileResponse>

Download a file.

readFileList: (props: ReadFileListOptions) => Promise<ReadFileListResponse>

Get a list of files that are ready to be downloaded.

readFileMetadata: (
    props: ReadFileMetadataOptions,
) => Promise<ReadFileMetadataResponse>

Download a file metadata.

readSession: (props: ReadSessionOptions) => Promise<ReadSessionResponse>

Start a new read session. When we already have an user access token.

Storage

createProvisionalStorage: (
    props: CreateProvisionalStorageOptions,
) => Promise<CreateProvisionalStorageResponse>

Create provisional storage

deleteStorageFiles: (
    props: DeleteStorageFilesOptions,
) => Promise<DeleteStorageFilesResponse>

Download file from storage by path

downloadStorageFile: (
    props: DownloadStorageFileOptions,
) => Promise<DownloadStorageFileResponse>

Download file from storage by path

getUserStorage: (
    props: GetUserStorageOptions,
) => Promise<GetUserStorageResponse>

Get storage for existing user

listStorageFiles: (
    props: ListStorageFilesOptions,
) => Promise<ListStorageFilesResponse>

List storage files

uploadFileToStorage: (
    props: UploadFileToStorageOptions,
) => Promise<UploadFileToStorageResponse>

Upload file to storage by path