Skip to content

Commit afb709e

Browse files
committed
fix merge conflict typo
1 parent 95871e8 commit afb709e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

packages/blob/src/client.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const put = createPutMethod<ClientPutCommandOptions>({
2222
extraChecks(options: ClientPutCommandOptions) {
2323
if (typeof window === 'undefined') {
2424
throw new BlobError(
25-
'client/`put` must be called from a client environment',
25+
'client/`put` must be called from a client environment'
2626
);
2727
}
2828

@@ -37,7 +37,7 @@ export const put = createPutMethod<ClientPutCommandOptions>({
3737
options.cacheControlMaxAge !== undefined
3838
) {
3939
throw new BlobError(
40-
'addRandomSuffix and cacheControlMaxAge are not supported in client uploads. Configure these options at the server side when generating client tokens.',
40+
'addRandomSuffix and cacheControlMaxAge are not supported in client uploads. Configure these options at the server side when generating client tokens.'
4141
);
4242
}
4343
},
@@ -79,7 +79,7 @@ export const upload = createPutMethod<UploadOptions>({
7979
extraChecks(options: UploadOptions) {
8080
if (typeof window === 'undefined') {
8181
throw new BlobError(
82-
'client/`upload` must be called from a client environment',
82+
'client/`upload` must be called from a client environment'
8383
);
8484
}
8585

@@ -95,7 +95,7 @@ export const upload = createPutMethod<UploadOptions>({
9595
options.cacheControlMaxAge !== undefined
9696
) {
9797
throw new BlobError(
98-
'addRandomSuffix and cacheControlMaxAge are not supported in client uploads. Configure these options at the server side when generating client tokens.',
98+
'addRandomSuffix and cacheControlMaxAge are not supported in client uploads. Configure these options at the server side when generating client tokens.'
9999
);
100100
}
101101
},
@@ -115,13 +115,13 @@ async function importKey(token: string): Promise<CryptoKey> {
115115
new TextEncoder().encode(token),
116116
{ name: 'HMAC', hash: 'SHA-256' },
117117
false,
118-
['sign', 'verify'],
118+
['sign', 'verify']
119119
);
120120
}
121121

122122
async function signPayload(
123123
payload: string,
124-
token: string,
124+
token: string
125125
): Promise<string | undefined> {
126126
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Node.js < 20: globalThis.crypto is undefined (in a real script.js, because the REPL has it linked to the crypto module). Node.js >= 20, Browsers and Cloudflare workers: globalThis.crypto is defined and is the Web Crypto API.
127127
if (!globalThis.crypto) {
@@ -131,7 +131,7 @@ async function signPayload(
131131
const signature = await globalThis.crypto.subtle.sign(
132132
'HMAC',
133133
await importKey(token),
134-
new TextEncoder().encode(payload),
134+
new TextEncoder().encode(payload)
135135
);
136136
return Buffer.from(new Uint8Array(signature)).toString('hex');
137137
}
@@ -168,7 +168,7 @@ async function verifyCallbackSignature({
168168
'HMAC',
169169
await importKey(token),
170170
hexToArrayByte(signature),
171-
new TextEncoder().encode(body),
171+
new TextEncoder().encode(body)
172172
);
173173
return verified;
174174
}
@@ -194,7 +194,7 @@ export type DecodedClientTokenPayload = Omit<
194194
};
195195

196196
export function getPayloadFromClientToken(
197-
clientToken: string,
197+
clientToken: string
198198
): DecodedClientTokenPayload {
199199
const [, , , , encodedToken] = clientToken.split('_');
200200
const encodedPayload = Buffer.from(encodedToken ?? '', 'base64')
@@ -229,7 +229,7 @@ export interface HandleUploadOptions {
229229
body: HandleUploadBody;
230230
onBeforeGenerateToken: (
231231
pathname: string,
232-
clientPayload?: string,
232+
clientPayload?: string
233233
) => Promise<
234234
Pick<
235235
GenerateClientTokenOptions,
@@ -350,6 +350,7 @@ async function tryGetErrorMessageFromResponse(res: Response) {
350350
if ('error' in jsonBody && typeof jsonBody.error === 'string') {
351351
return jsonBody.error;
352352
}
353+
}
353354

354355
function toAbsoluteUrl(url: string): string {
355356
return new URL(url, window.location.href).href;
@@ -369,7 +370,7 @@ export async function generateClientTokenFromReadWriteToken({
369370
}: GenerateClientTokenOptions): Promise<string> {
370371
if (typeof window !== 'undefined') {
371372
throw new BlobError(
372-
'"generateClientTokenFromReadWriteToken" must be called from a server environment',
373+
'"generateClientTokenFromReadWriteToken" must be called from a server environment'
373374
);
374375
}
375376

@@ -381,15 +382,15 @@ export async function generateClientTokenFromReadWriteToken({
381382

382383
if (!storeId) {
383384
throw new BlobError(
384-
token ? 'Invalid `token` parameter' : 'Invalid `BLOB_READ_WRITE_TOKEN`',
385+
token ? 'Invalid `token` parameter' : 'Invalid `BLOB_READ_WRITE_TOKEN`'
385386
);
386387
}
387388

388389
const payload = Buffer.from(
389390
JSON.stringify({
390391
...argsWithoutToken,
391392
validUntil: argsWithoutToken.validUntil ?? timestamp.getTime(),
392-
}),
393+
})
393394
).toString('base64');
394395

395396
const securedKey = await signPayload(payload, readWriteToken);
@@ -398,7 +399,7 @@ export async function generateClientTokenFromReadWriteToken({
398399
throw new BlobError('Unable to sign client token');
399400
}
400401
return `vercel_blob_client_${storeId}_${Buffer.from(
401-
`${securedKey}.${payload}`,
402+
`${securedKey}.${payload}`
402403
).toString('base64')}`;
403404
}
404405

0 commit comments

Comments
 (0)