diff --git a/.vitepress/sidebars/concepts.ts b/.vitepress/sidebars/concepts.ts index de0639b..30485bf 100644 --- a/.vitepress/sidebars/concepts.ts +++ b/.vitepress/sidebars/concepts.ts @@ -56,6 +56,10 @@ export const conceptsSidebar: DefaultTheme.SidebarItem[] = [ text: "Files", link: "/concepts/internals/files", }, + { + text: "GraphQL", + link: "/concepts/internals/graphql", + }, { text: "Cloud", link: "/concepts/internals/cloud", diff --git a/src/_images/graphql_explorer.png b/src/_images/graphql_explorer.png new file mode 100644 index 0000000..25da5e8 Binary files /dev/null and b/src/_images/graphql_explorer.png differ diff --git a/src/_images/graphql_playground.png b/src/_images/graphql_playground.png new file mode 100644 index 0000000..12fdcf0 Binary files /dev/null and b/src/_images/graphql_playground.png differ diff --git a/src/concepts/internals/graphql.md b/src/concepts/internals/graphql.md new file mode 100644 index 0000000..c1cd1bf --- /dev/null +++ b/src/concepts/internals/graphql.md @@ -0,0 +1,62 @@ +# GraphQL + +Caido mainly uses [Graphql](https://graphql.org/) for the `client/server` communication. +We make this API very public on purpose to allow you to build third party tools using it. + +::: warning +We make no guarantee on the stability of that API and it **will** change with each release +::: + +Client/server architecture. + +## Authentication + +Except for a few exceptions, the GraphQL API requires authentication via a `Bearer` access token. + +```http +Authorization: Bearer +``` + +The easiest way to get a working token is to get it from the Caido `client` itself! +If you are authenticated, open the developper tools and paste the following in the console: + +```javascript +JSON.parse(localStorage.CAIDO_AUTHENTICATION).accessToken; +``` + +::: info +This token will last 7 days. If you need a more permanent token, we suggest doing the [OAuth authentication flow](http://localhost:5173/concepts/internals/authentication.html). + +We are currently working on libraries to abstract that process. In the meantime, look at the mutation `startAuthenticationFlow` and the subscription `createdAuthenticationToken`. +::: + +Once you have your token, you can send a simple request to verify that your credentials are working: + +```graphql +query Viewer { + viewer { + id + profile { + identity { + email + } + } + } +} +``` + +## Playground + +To simplify your life, we included a playground (based on [Graphiql](https://github.com/graphql/graphiql)) inside of Caido at `http://:/graphql` + +It will even setup the authentication for you if you used the same browser for the Caido `client` :sunglasses: + +Client/server architecture. + +## Explorer + +The schema of Caido is quite large and so exploring it can be hard. For that purpose, we offer a GraphQL explorer (based on [GraphQL Voyager](https://github.com/graphql-kit/graphql-voyager)). + +Open Graphql Explorer + +Client/server architecture.