This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use common API client utils from graphql-client library
- Loading branch information
1 parent
f74d883
commit 7efc764
Showing
8 changed files
with
78 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
packages/storefront-api-client/src/utilities/api-versions.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
packages/storefront-api-client/src/utilities/validations.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ERROR_PREFIX } from "./constants"; | ||
|
||
export function validatePrivateAccessTokenUsage( | ||
privateAccessToken: string | undefined | ||
) { | ||
if (privateAccessToken && window) { | ||
throw new Error( | ||
`${ERROR_PREFIX} private access tokens and headers should only be used in a server-to-server implementation. Use the API public access token in nonserver environments.` | ||
); | ||
} | ||
} | ||
|
||
export function validateRequiredAccessTokens( | ||
publicAccessToken: string | undefined, | ||
privateAccessToken: string | undefined | ||
) { | ||
if (!publicAccessToken && !privateAccessToken) { | ||
throw new Error( | ||
`${ERROR_PREFIX} a public or private access token must be provided` | ||
); | ||
} | ||
|
||
if (publicAccessToken && privateAccessToken) { | ||
throw new Error( | ||
`${ERROR_PREFIX} only provide either a public or private access token` | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters