Skip to content

Commit ca7a8be

Browse files
committed
chore: clean up
1 parent 05d6c8e commit ca7a8be

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

packages/backend/src/api/endpoints/MachineTokensApi.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,37 @@ type RevokeMachineTokenParams = WithMachineTokenSecret<{
2929
}>;
3030

3131
export class MachineTokensApi extends AbstractAPI {
32-
/**
33-
* Attaches the machine token secret as an Authorization header if present.
34-
*/
35-
#withMachineTokenSecretHeader<T extends WithMachineTokenSecret<unknown>>(
32+
#withMachineTokenSecretHeader(
3633
options: ClerkBackendApiRequestOptions,
37-
params: T,
34+
machineTokenSecret?: string | null,
3835
): ClerkBackendApiRequestOptions {
39-
if (params.machineTokenSecret) {
36+
if (machineTokenSecret) {
4037
return {
4138
...options,
4239
headerParams: {
43-
Authorization: `Bearer ${params.machineTokenSecret}`,
40+
Authorization: `Bearer ${machineTokenSecret}`,
4441
},
4542
};
4643
}
4744
return options;
4845
}
4946

5047
async create(params: CreateMachineTokenParams) {
48+
const { machineTokenSecret, ...bodyParams } = params;
5149
return this.request<MachineToken>(
5250
this.#withMachineTokenSecretHeader(
5351
{
5452
method: 'POST',
5553
path: basePath,
56-
bodyParams: params,
54+
bodyParams,
5755
},
58-
params,
56+
machineTokenSecret,
5957
),
6058
);
6159
}
6260

6361
async update(params: UpdateMachineTokenParams) {
64-
const { m2mTokenId, ...bodyParams } = params;
62+
const { m2mTokenId, machineTokenSecret, ...bodyParams } = params;
6563
this.requireId(m2mTokenId);
6664
return this.request<MachineToken>(
6765
this.#withMachineTokenSecretHeader(
@@ -70,13 +68,13 @@ export class MachineTokensApi extends AbstractAPI {
7068
path: joinPaths(basePath, m2mTokenId),
7169
bodyParams,
7270
},
73-
params,
71+
machineTokenSecret,
7472
),
7573
);
7674
}
7775

7876
async revoke(params: RevokeMachineTokenParams) {
79-
const { m2mTokenId, ...bodyParams } = params;
77+
const { m2mTokenId, machineTokenSecret, ...bodyParams } = params;
8078
this.requireId(m2mTokenId);
8179
return this.request<MachineToken>(
8280
this.#withMachineTokenSecretHeader(
@@ -85,7 +83,7 @@ export class MachineTokensApi extends AbstractAPI {
8583
path: joinPaths(basePath, m2mTokenId, 'revoke'),
8684
bodyParams,
8785
},
88-
params,
86+
machineTokenSecret,
8987
),
9088
);
9189
}

0 commit comments

Comments
 (0)