MCPcopy Create free account
hub / github.com/ProtonDriveApps/sdk / initApi

Function initApi

cli/src/api/index.ts:16–54  ·  view source on GitHub ↗
(
    config: Config,
    credentials: Credentials,
    logger: Logger,
    cryptoProxy: CryptoApiInterface,
)

Source from the content-addressed store, hash-verified

14
15/** Wires proton-drive-sdk-account with Drive SDK-specific HTTP and requirement header handling. */
16export async function initApi(
17 config: Config,
18 credentials: Credentials,
19 logger: Logger,
20 cryptoProxy: CryptoApiInterface,
21) {
22 const apiClient = new ApiClient({
23 baseUrl: config.baseUrl,
24 appVersion: config.appVersion,
25 credentials,
26 logger,
27 headers: {
28 'x-pm-drive-sdk-version': config.sdkVersion,
29 },
30 afterResponseHooks: [createDriveRequirementAfterResponseHook(config, logger)],
31 });
32 const {
33 auth,
34 srp,
35 addresses: accountAddresses,
36 } = await initAccount({
37 authClientId: config.authClientId,
38 apiClient,
39 credentials,
40 cryptoProxy,
41 logger,
42 accountUrl: config.accountUrl,
43 });
44 const addresses = new DriveAccountAdapter(accountAddresses);
45 const httpClient = new HTTPClient(apiClient);
46
47 return {
48 credentials,
49 addresses,
50 auth,
51 srp,
52 apiClient,
53 httpClient,
54 };
55}

Callers 1

initFunction · 0.90

Calls 2

initAccountFunction · 0.85

Tested by

no test coverage detected