Skip to content

Commit 94b79a2

Browse files
feat(api): add per endpoint security
1 parent 3e7b8f0 commit 94b79a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+328
-54
lines changed

.github/workflows/release-doctor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ jobs:
1919
bash ./bin/check-release-environment
2020
env:
2121
NPM_TOKEN: ${{ secrets.FINCH_NPM_TOKEN || secrets.NPM_TOKEN }}
22-

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 46
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-46f433f34d440aa1dfcc48cc8d822c598571b68be2f723ec99e1b4fba6c13b1e.yml
33
openapi_spec_hash: 5b5cd728776723ac773900f7e8a32c05
4-
config_hash: 0892e2e0eeb0343a022afa62e9080dd1
4+
config_hash: 83522e0e335cf983f8d2119c1f2bba18

src/client.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,14 @@ export class Finch {
302302
);
303303
}
304304

305-
protected async authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
306-
return buildHeaders([await this.bearerAuth(opts), await this.basicAuth(opts)]);
305+
protected async authHeaders(
306+
opts: FinalRequestOptions,
307+
schemes: { bearerAuth?: boolean; basicAuth?: boolean },
308+
): Promise<NullableHeaders | undefined> {
309+
return buildHeaders([
310+
schemes.bearerAuth ? await this.bearerAuth(opts) : null,
311+
schemes.basicAuth ? await this.basicAuth(opts) : null,
312+
]);
307313
}
308314

309315
protected async bearerAuth(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
@@ -768,7 +774,7 @@ export class Finch {
768774
...getPlatformHeaders(),
769775
'Finch-API-Version': '2020-09-17',
770776
},
771-
await this.authHeaders(options),
777+
await this.authHeaders(options, options.__security ?? { bearerAuth: true, basicAuth: true }),
772778
this._options.defaultHeaders,
773779
bodyHeaders,
774780
options.headers,

src/internal/request-options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export type RequestOptions = {
7575
*/
7676
defaultBaseURL?: string | undefined;
7777

78+
__security?: { bearerAuth?: boolean; basicAuth?: boolean };
79+
7880
__binaryResponse?: boolean | undefined;
7981
};
8082

src/resources/access-tokens.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class AccessTokens extends APIResource {
3232
body: bodyWithReplacements,
3333
...options,
3434
headers: headersWithReplacements,
35+
__security: {},
3536
});
3637
}
3738
}

src/resources/account.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export class Account extends APIResource {
1010
* Disconnect one or more `access_token`s from your application.
1111
*/
1212
disconnect(options?: RequestOptions): APIPromise<DisconnectResponse> {
13-
return this._client.post('/disconnect', options);
13+
return this._client.post('/disconnect', { ...options, __security: { bearerAuth: true } });
1414
}
1515

1616
/**
1717
* Read account information associated with an `access_token`
1818
*/
1919
introspect(options?: RequestOptions): APIPromise<Introspection> {
20-
return this._client.get('/introspect', options);
20+
return this._client.get('/introspect', { ...options, __security: { bearerAuth: true } });
2121
}
2222
}
2323

src/resources/connect/sessions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class Sessions extends APIResource {
99
* Create a new connect session for an employer
1010
*/
1111
new(body: SessionNewParams, options?: RequestOptions): APIPromise<SessionNewResponse> {
12-
return this._client.post('/connect/sessions', { body, ...options });
12+
return this._client.post('/connect/sessions', { body, ...options, __security: { basicAuth: true } });
1313
}
1414

1515
/**
@@ -19,7 +19,11 @@ export class Sessions extends APIResource {
1919
body: SessionReauthenticateParams,
2020
options?: RequestOptions,
2121
): APIPromise<SessionReauthenticateResponse> {
22-
return this._client.post('/connect/sessions/reauthenticate', { body, ...options });
22+
return this._client.post('/connect/sessions/reauthenticate', {
23+
body,
24+
...options,
25+
__security: { basicAuth: true },
26+
});
2327
}
2428
}
2529

src/resources/hris/benefits/benefits.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ export class Benefits extends APIResource {
3838
options?: RequestOptions,
3939
): APIPromise<CreateCompanyBenefitsResponse> {
4040
const { entity_ids, ...body } = params ?? {};
41-
return this._client.post('/employer/benefits', { query: { entity_ids }, body, ...options });
41+
return this._client.post('/employer/benefits', {
42+
query: { entity_ids },
43+
body,
44+
...options,
45+
__security: { bearerAuth: true },
46+
});
4247
}
4348

4449
/**
@@ -56,7 +61,11 @@ export class Benefits extends APIResource {
5661
query: BenefitRetrieveParams | null | undefined = {},
5762
options?: RequestOptions,
5863
): APIPromise<CompanyBenefit> {
59-
return this._client.get(path`/employer/benefits/${benefitID}`, { query, ...options });
64+
return this._client.get(path`/employer/benefits/${benefitID}`, {
65+
query,
66+
...options,
67+
__security: { bearerAuth: true },
68+
});
6069
}
6170

6271
/**
@@ -78,6 +87,7 @@ export class Benefits extends APIResource {
7887
query: { entity_ids },
7988
body,
8089
...options,
90+
__security: { bearerAuth: true },
8191
});
8292
}
8393

@@ -96,7 +106,11 @@ export class Benefits extends APIResource {
96106
query: BenefitListParams | null | undefined = {},
97107
options?: RequestOptions,
98108
): PagePromise<CompanyBenefitsSinglePage, CompanyBenefit> {
99-
return this._client.getAPIList('/employer/benefits', SinglePage<CompanyBenefit>, { query, ...options });
109+
return this._client.getAPIList('/employer/benefits', SinglePage<CompanyBenefit>, {
110+
query,
111+
...options,
112+
__security: { bearerAuth: true },
113+
});
100114
}
101115

102116
/**
@@ -117,6 +131,7 @@ export class Benefits extends APIResource {
117131
return this._client.getAPIList('/employer/benefits/meta', SinglePage<SupportedBenefit>, {
118132
query,
119133
...options,
134+
__security: { bearerAuth: true },
120135
});
121136
}
122137
}

src/resources/hris/benefits/individuals.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class Individuals extends APIResource {
3131
query: { entity_ids },
3232
body: individuals,
3333
...options,
34+
__security: { bearerAuth: true },
3435
});
3536
}
3637

@@ -50,7 +51,11 @@ export class Individuals extends APIResource {
5051
query: IndividualEnrolledIDsParams | null | undefined = {},
5152
options?: RequestOptions,
5253
): APIPromise<IndividualEnrolledIDsResponse> {
53-
return this._client.get(path`/employer/benefits/${benefitID}/enrolled`, { query, ...options });
54+
return this._client.get(path`/employer/benefits/${benefitID}/enrolled`, {
55+
query,
56+
...options,
57+
__security: { bearerAuth: true },
58+
});
5459
}
5560

5661
/**
@@ -74,7 +79,7 @@ export class Individuals extends APIResource {
7479
return this._client.getAPIList(
7580
path`/employer/benefits/${benefitID}/individuals`,
7681
SinglePage<IndividualBenefit>,
77-
{ query, ...options },
82+
{ query, ...options, __security: { bearerAuth: true } },
7883
);
7984
}
8085

@@ -99,6 +104,7 @@ export class Individuals extends APIResource {
99104
query: { entity_ids },
100105
body,
101106
...options,
107+
__security: { bearerAuth: true },
102108
});
103109
}
104110
}

src/resources/hris/company/company.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CompanyResource extends APIResource {
2929
query: CompanyRetrieveParams | null | undefined = {},
3030
options?: RequestOptions,
3131
): APIPromise<Company> {
32-
return this._client.get('/employer/company', { query, ...options });
32+
return this._client.get('/employer/company', { query, ...options, __security: { bearerAuth: true } });
3333
}
3434
}
3535

0 commit comments

Comments
 (0)