Grabbed dndbeyond's source code

```
~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js
```
This commit is contained in:
2025-05-28 11:50:03 -07:00
commit 8df9031d27
3592 changed files with 319051 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import AuthUtils from "@dndbeyond/authentication-lib-js";
import { getStt } from "./tokenUtils";
export const getAuthHeaders = AuthUtils.makeGetAuthorizationHeaders({
madeGetShortTermToken: getStt,
});
/**
* A wrapper around fetch that adds the Authorization header and anything else
* that may need to be included in every request. If withCookies is true, the
* request will add the credentials: "include" option. Otherwise, this function
* should work exactly like the native fetch function.
*
* See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
*/
export const summon = async (
input: RequestInfo | URL,
init?: RequestInit,
withCookies?: boolean
) => {
// Get the Authorization headers from the auth token
const authHeaders = await getAuthHeaders();
// If withCookies is true, set the credentials to include
const credentials = withCookies && { credentials: "include" };
// If there is a body, set the Content-Type to application/json
const contentType = init?.body && { "Content-Type": "application/json" };
return window.fetch(input, {
...(credentials as { credentials: RequestCredentials } | undefined),
...init,
headers: {
...authHeaders,
...init?.headers,
...contentType,
Accept: "application/json",
},
});
};