Skip to content

Instantly share code, notes, and snippets.

@hhrhhr
Created January 19, 2023 22:36
Show Gist options
  • Save hhrhhr/5653ce285fe1dc6d5e09b842a9cc68e3 to your computer and use it in GitHub Desktop.
Save hhrhhr/5653ce285fe1dc6d5e09b842a9cc68e3 to your computer and use it in GitHub Desktop.
fix for "Rename namespace in protobuf files" (428d7c8)
diff --git a/src/lib/common/apiFunctions.svelte b/src/lib/common/apiFunctions.svelte
index c6a9630..26f71e4 100644
--- a/src/lib/common/apiFunctions.svelte
+++ b/src/lib/common/apiFunctions.svelte
@@ -10,7 +10,7 @@
let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || '';
// endpoint url for getting users
- let endpointURL = '/api/v1/namespace';
+ let endpointURL = '/api/v1/user';
//returning variables
let headscaleUsers = [new User()];
@@ -40,7 +40,7 @@
});
await headscaleUsersResponse.json().then((data) => {
- headscaleUsers = data.namespaces
+ headscaleUsers = data.users
// sort the users
headscaleUsers = sortUsers(headscaleUsers);
});
@@ -57,7 +57,7 @@
let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || '';
// endpoint url for editing users
- let endpointURL = '/api/v1/namespace/' + currentUsername + '/rename/' + newUsername;
+ let endpointURL = '/api/v1/user/' + currentUsername + '/rename/' + newUsername;
await fetch(headscaleURL + endpointURL, {
method: 'POST',
@@ -189,7 +189,7 @@
let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || '';
// endpoint url for editing users
- let endpointURL = '/api/v1/namespace/' + currentUsername;
+ let endpointURL = '/api/v1/user/' + currentUsername;
await fetch(headscaleURL + endpointURL, {
method: 'DELETE',
@@ -218,7 +218,7 @@
let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || '';
// endpoint url for editing users
- let endpointURL = '/api/v1/namespace';
+ let endpointURL = '/api/v1/user';
await fetch(headscaleURL + endpointURL, {
method: 'POST',
@@ -341,7 +341,7 @@
let headscalePreAuthKey = [new PreAuthKey()];
let headscalePreAuthKeyResponse: Response = new Response();
- await fetch(headscaleURL + endpointURL + '?namespace=' + userName, {
+ await fetch(headscaleURL + endpointURL + '?user=' + userName, {
method: 'GET',
headers: {
Accept: 'application/json',
@@ -381,7 +381,7 @@
Authorization: `Bearer ${headscaleAPIKey}`
},
body: JSON.stringify({
- namespace: userName,
+ user: userName,
expiration: expiry,
reusable: reusable,
ephemeral: ephemeral
@@ -416,7 +416,7 @@
Authorization: `Bearer ${headscaleAPIKey}`
},
body: JSON.stringify({
- namespace: userName,
+ user: userName,
key: preAuthKey
})
})
@@ -442,7 +442,7 @@
// endpoint url for editing users
let endpointURL = '/api/v1/machine/register';
- await fetch(headscaleURL + endpointURL + '?namespace=' + userName + '&key=' + key, {
+ await fetch(headscaleURL + endpointURL + '?user=' + userName + '&key=' + key, {
method: 'POST',
headers: {
Accept: 'application/json',
@@ -469,7 +469,7 @@
let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || '';
// endpoint url for editing users
- let endpointURL = '/api/v1/machine/' + deviceID + '/namespace?namespace=' + user;
+ let endpointURL = '/api/v1/machine/' + deviceID + '/user?user=' + user;
await fetch(headscaleURL + endpointURL, {
method: 'POST',
diff --git a/src/lib/common/classes.ts b/src/lib/common/classes.ts
index e12a6b6..c4742b3 100644
--- a/src/lib/common/classes.ts
+++ b/src/lib/common/classes.ts
@@ -7,7 +7,7 @@ export class Device {
public forcedTags: string[] = []
public validTags: string[] = []
public invalidTags: string[] = []
- public namespace: { name: string } = { name: '' }
+ public user: { name: string } = { name: '' }
public constructor(init?: Partial<Device>) {
Object.assign(this, init);
@@ -47,7 +47,7 @@ export class APIKey {
}
export class PreAuthKey {
- public namespace: string = '';
+ public user: string = '';
public id: string = '';
public key: string = '';
public createdAt: string = '';
diff --git a/src/lib/common/searching.svelte b/src/lib/common/searching.svelte
index 344a2f5..d48e80a 100644
--- a/src/lib/common/searching.svelte
+++ b/src/lib/common/searching.svelte
@@ -24,7 +24,7 @@
// only run if we have search contents set
if (get(deviceSearchStore)) {
let options: Fuse.IFuseOptions<Device> = {
- keys: ['id', 'givenName', 'name', 'forcedTags', 'validTags', 'namespace.name']
+ keys: ['id', 'givenName', 'name', 'forcedTags', 'validTags', 'user.name']
};
let searcher = new Fuse(get(deviceStore), options);
diff --git a/src/lib/devices/DeviceCard/MoveDevice.svelte b/src/lib/devices/DeviceCard/MoveDevice.svelte
index bbc5763..0353ebf 100644
--- a/src/lib/devices/DeviceCard/MoveDevice.svelte
+++ b/src/lib/devices/DeviceCard/MoveDevice.svelte
@@ -6,7 +6,7 @@
export let device = new Device();
let deviceMoving = false;
- let selectedUser = device.namespace.name;
+ let selectedUser = device.user.name;
function moveDeviceAction() {
moveDevice(device.id, selectedUser)
@@ -23,7 +23,7 @@
<td>
{#if !deviceMoving}
- {device.namespace.name}
+ {device.user.name}
<!-- edit symbol -->
<button
on:click={() => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment