Skip to content

Commit 01963a0

Browse files
authored
feat(api): project and personal scoped access tokens (#7206)
1 parent 2d74620 commit 01963a0

File tree

69 files changed

+6347
-696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+6347
-696
lines changed

.changeset/five-hoops-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-hive/cli': minor
3+
---
4+
5+
Improve output of the `hive whoami` command. It now also handles the new access token format.

.changeset/long-impalas-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': minor
3+
---
4+
5+
Introduce personal access tokens (PAT) and project scoped access tokens.

integration-tests/testkit/seed.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import {
6060
import { execute } from './graphql';
6161
import { UpdateSchemaPolicyForOrganization, UpdateSchemaPolicyForProject } from './schema-policy';
6262
import { collect, CollectedOperation, legacyCollect } from './usage';
63-
import { generateUnique } from './utils';
63+
import { generateUnique, getServiceHost } from './utils';
6464

6565
export function initSeed() {
6666
function createConnectionPool() {
@@ -89,6 +89,15 @@ export function initSeed() {
8989
},
9090
authenticate,
9191
generateEmail: () => userEmail(generateUnique()),
92+
async purgeOrganizationAccessTokenById(id: string) {
93+
const registryAddress = await getServiceHost('server', 8082);
94+
await fetch(
95+
'http://' + registryAddress + '/cache/organization-access-token-cache/delete/' + id,
96+
{
97+
method: 'POST',
98+
},
99+
).then(res => res.json());
100+
},
92101
async createOwner() {
93102
const ownerEmail = userEmail(generateUnique());
94103
const auth = await authenticate(ownerEmail);
@@ -120,7 +129,7 @@ export function initSeed() {
120129
) {
121130
const result = await createOrganizationAccessToken(
122131
{
123-
title: 'A Access Token',
132+
title: 'an access token',
124133
description: 'access token',
125134
organization: {
126135
byId: organization.id,
@@ -488,7 +497,7 @@ export function initSeed() {
488497
return result.addAlertChannel;
489498
},
490499
/**
491-
* Create a access token for a given target.
500+
* Create an access token for a given target.
492501
* This token can be used for usage reporting and all actions that would be performed by the CLI.
493502
*/
494503
async createTargetAccessToken({

integration-tests/testkit/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,12 @@ export function assertNonNull<T>(
111111
throw new Error(message);
112112
}
113113
}
114+
115+
export function assertNonNullish<T>(
116+
value: T | null | undefined,
117+
message = 'Expected non-null value.',
118+
): asserts value is T {
119+
if (value === null) {
120+
throw new Error(message);
121+
}
122+
}

0 commit comments

Comments
 (0)