diff --git a/Makefile b/Makefile index 316d67e18..1759554a3 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ gen-web: --additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=@goauthentik/api,npmVersion=${NPM_VERSION} mkdir -p web/node_modules/@goauthentik/api python -m scripts.web_api_esm + \cp -fv scripts/web_api_readme.md web-api/README.md cd web-api && npm i \cp -rfv web-api/* web/node_modules/@goauthentik/api diff --git a/scripts/web_api_readme.md b/scripts/web_api_readme.md new file mode 100644 index 000000000..cbf730782 --- /dev/null +++ b/scripts/web_api_readme.md @@ -0,0 +1,38 @@ +## @goauthentik/api + +This package provides a generated API Client for [authentik](https://goauthentik.io). + +### Building + +See https://goauthentik.io/developer-docs/making-schema-changes + +### Consuming + +``` +npm install @goauthentik/api --save +``` + +Create a configuration: + +```typescript +import { Configuration } from "@goauthentik/api"; + +export const DEFAULT_CONFIG = new Configuration({ + // Configure where the API is located + // Can be a full host, ensure CORS is configured + basePath: "", + // Required for POST/PUT/DELETE requests + // getCookie function must return the cookie's contents + headers: { + "X-CSRFToken": getCookie("authentik_csrf"), + }, +}); +``` + +Then use the API: + +```typescript +import { CoreApi } from "@goauthentik/api"; + +const user = await new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve(); +``` diff --git a/web/package-lock.json b/web/package-lock.json index fb0382c0c..b4c7dc002 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -15,7 +15,7 @@ "@babel/preset-env": "^7.15.0", "@babel/preset-typescript": "^7.15.0", "@fortawesome/fontawesome-free": "^5.15.4", - "@goauthentik/api": "^2021.8.1-rc1-1629709535", + "@goauthentik/api": "^2021.8.1-rc1-1629712721", "@lingui/cli": "^3.10.2", "@lingui/core": "^3.10.4", "@lingui/macro": "^3.10.2", @@ -1690,9 +1690,9 @@ } }, "node_modules/@goauthentik/api": { - "version": "2021.8.1-rc1-1629709535", - "resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629709535.tgz", - "integrity": "sha512-rlOt63gF3ALGuRIn8RiWRT5cZ4JhKu9koCtdFA7FDOYYU9jWBJ3e/YlFLLOLQrL8Cyl2g553We98t0n8AyDOBQ==" + "version": "2021.8.1-rc1-1629712721", + "resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629712721.tgz", + "integrity": "sha512-YC/txo36I6/dnOlj0nSXcxFV2fuwMkO/lQRIj5LGwNz85Jru1fwJzAuB8UFs8Floqw9yPI/DyWaUObFlatEe6A==" }, "node_modules/@humanwhocodes/config-array": { "version": "0.5.0", @@ -9567,9 +9567,9 @@ "integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg==" }, "@goauthentik/api": { - "version": "2021.8.1-rc1-1629709535", - "resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629709535.tgz", - "integrity": "sha512-rlOt63gF3ALGuRIn8RiWRT5cZ4JhKu9koCtdFA7FDOYYU9jWBJ3e/YlFLLOLQrL8Cyl2g553We98t0n8AyDOBQ==" + "version": "2021.8.1-rc1-1629712721", + "resolved": "https://registry.npmjs.org/@goauthentik/api/-/api-2021.8.1-rc1-1629712721.tgz", + "integrity": "sha512-YC/txo36I6/dnOlj0nSXcxFV2fuwMkO/lQRIj5LGwNz85Jru1fwJzAuB8UFs8Floqw9yPI/DyWaUObFlatEe6A==" }, "@humanwhocodes/config-array": { "version": "0.5.0", diff --git a/web/package.json b/web/package.json index 27ace2e48..de6421f25 100644 --- a/web/package.json +++ b/web/package.json @@ -46,7 +46,7 @@ "@babel/preset-env": "^7.15.0", "@babel/preset-typescript": "^7.15.0", "@fortawesome/fontawesome-free": "^5.15.4", - "@goauthentik/api": "^2021.8.1-rc1-1629709535", + "@goauthentik/api": "^2021.8.1-rc1-1629712721", "@lingui/cli": "^3.10.2", "@lingui/core": "^3.10.4", "@lingui/macro": "^3.10.2",