Skip to content

Commit e65725a

Browse files
authored
Official Discord app id (905987126099836938) (#73)
1 parent 090b295 commit e65725a

File tree

18 files changed

+54
-25
lines changed

18 files changed

+54
-25
lines changed

apps/desktop/components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
},
1212
"aliases": {
1313
"components": "@/components",
14-
"utils": "@/lib/utils"
14+
"utils": "@/utils/tw"
1515
}
1616
}

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition = "2021"
1313
tauri-build = { version = "1.5", features = [] }
1414

1515
[dependencies]
16-
tauri = { version = "1.5", features = [ "notification-all", "global-shortcut-all", "process-relaunch", "updater", "process-exit", "os-all",
16+
tauri = { version = "1.5", features = [ "fs-create-dir", "notification-all", "global-shortcut-all", "process-relaunch", "updater", "process-exit", "os-all",
1717
"window-set-position",
1818
"shell-open",
1919
"path-all",

apps/desktop/src-tauri/tauri.conf.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@
3636
"open": ".*"
3737
},
3838
"fs": {
39-
"scope": ["$APPDATA/*"],
39+
"scope": ["$APPCONFIG/**", "$APPDATA/**"],
4040
"readFile": true,
4141
"writeFile": true,
42+
"createDir": true,
4243
"exists": true
4344
},
4445
"http": {
4546
"all": true,
4647
"request": true,
47-
"scope": ["https://streamkit.discord.com/overlay/token"]
48+
"scope": ["https://api.overlayed.dev/token"]
4849
},
4950
"path": {
5051
"all": true

apps/desktop/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function App() {
3434
const { horizontal, setHorizontalDirection } = useAlign();
3535

3636
const visibleClass = visible ? "opacity-100" : "opacity-0";
37+
3738
return (
3839
<div className={`text-white h-screen select-none rounded-lg ${visibleClass}`}>
3940
{!clickthrough && (

apps/desktop/src/components/ui/avatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import * as AvatarPrimitive from "@radix-ui/react-avatar";
33

4-
import { cn } from "@/lib/utils";
4+
import { cn } from "@/utils/tw";
55

66
const Avatar = React.forwardRef<
77
React.ElementRef<typeof AvatarPrimitive.Root>,

apps/desktop/src/components/ui/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import { Slot } from "@radix-ui/react-slot";
33
import { cva, type VariantProps } from "class-variance-authority";
44

5-
import { cn } from "@/lib/utils";
5+
import { cn } from "@/utils/tw";
66

77
const buttonVariants = cva(
88
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",

apps/desktop/src/components/ui/checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
33
import { Check } from "lucide-react";
44

5-
import { cn } from "@/lib/utils";
5+
import { cn } from "@/utils/tw";
66

77
const Checkbox = React.forwardRef<
88
React.ElementRef<typeof CheckboxPrimitive.Root>,

apps/desktop/src/components/ui/dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import * as DialogPrimitive from "@radix-ui/react-dialog";
33
import { X } from "lucide-react";
44

5-
import { cn } from "@/lib/utils";
5+
import { cn } from "@/utils/tw";
66

77
const Dialog = DialogPrimitive.Root;
88

apps/desktop/src/components/ui/input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from "react";
22

3-
import { cn } from "@/lib/utils";
3+
import { cn } from "@/utils/tw";
44

55
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
66
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}

apps/desktop/src/components/ui/label.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import * as LabelPrimitive from "@radix-ui/react-label";
33
import { cva, type VariantProps } from "class-variance-authority";
44

5-
import { cn } from "@/lib/utils";
5+
import { cn } from "@/utils/tw";
66

77
const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
88

apps/desktop/src/components/ui/tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import * as TabsPrimitive from "@radix-ui/react-tabs";
33

4-
import { cn } from "@/lib/utils";
4+
import { cn } from "@/utils/tw";
55

66
const Tabs = TabsPrimitive.Root;
77

apps/desktop/src/components/ui/toast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as ToastPrimitives from "@radix-ui/react-toast";
33
import { cva, type VariantProps } from "class-variance-authority";
44
import { X } from "lucide-react";
55

6-
import { cn } from "@/lib/utils";
6+
import { cn } from "@/utils/tw";
77

88
const ToastProvider = ToastPrimitives.Provider;
99

apps/desktop/src/components/ui/tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react";
22
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
33

4-
import { cn } from "@/lib/utils";
4+
import { cn } from "@/utils/tw";
55

66
const TooltipProvider = TooltipPrimitive.Provider;
77

apps/desktop/src/rpc/manager.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ const SUBSCRIBABLE_EVENTS = [
6161
RPCEvent.VOICE_STATE_UPDATE,
6262
];
6363

64-
const STREAM_KIT_APP_ID = "207646673902501888";
64+
export const APP_ID = "905987126099836938";
6565
const WEBSOCKET_URL = "ws://127.0.0.1:6463";
66-
const STREAMKIT_URL = "https://streamkit.discord.com";
66+
const API_URL = "https://api.overlayed.dev";
6767

6868
interface DiscordPayload {
6969
cmd: `${RPCCommand}`;
@@ -101,12 +101,11 @@ class SocketManager {
101101

102102
this._navigate = navigate;
103103

104-
const connectionUrl = `${WEBSOCKET_URL}/?v=1&client_id=${STREAM_KIT_APP_ID}`;
104+
const connectionUrl = `${WEBSOCKET_URL}/?v=1&client_id=${APP_ID}`;
105105
try {
106106
this.socket = await WebSocket.connect(connectionUrl, {
107107
headers: {
108-
// we need to set the origin header to the discord streamkit domain
109-
origin: STREAMKIT_URL,
108+
origin: API_URL,
110109
},
111110
});
112111

@@ -143,7 +142,7 @@ class SocketManager {
143142
private authenticate() {
144143
this.send({
145144
args: {
146-
client_id: STREAM_KIT_APP_ID,
145+
client_id: APP_ID,
147146
scopes: ["rpc", "identify"],
148147
},
149148
cmd: RPCCommand.AUTHORIZE,
@@ -177,10 +176,10 @@ class SocketManager {
177176

178177
const payload: DiscordPayload = JSON.parse(event.data);
179178

180-
// console.log(payload);
181179
// either the token is good and valid and we can login otherwise prompt them approve
182180
if (payload.evt === RPCEvent.READY) {
183181
const acessToken = this.userdataStore.accessToken;
182+
184183
if (acessToken) {
185184
this.login(acessToken);
186185
} else {
@@ -250,7 +249,7 @@ class SocketManager {
250249
// we got a token back from discord let's fetch an access token
251250
if (payload.cmd === RPCCommand.AUTHORIZE) {
252251
const { code } = payload.data;
253-
const res = await fetch<TokenResponse>(`${STREAMKIT_URL}/overlay/token`, {
252+
const res = await fetch<TokenResponse>(`${API_URL}/token`, {
254253
method: "POST",
255254
body: Body.json({ code }),
256255
});
@@ -278,9 +277,13 @@ class SocketManager {
278277
// console.log(payload);
279278
// we are ready to do things cause we are fully authed
280279
if (payload.cmd === RPCCommand.AUTHENTICATE && payload.evt === RPCEvent.ERROR) {
281-
// if they have an invalid we remove it and make them auth again
280+
// they have a token from the old client id
281+
if (payload.data.code === RPCErrors.INVALID_CLIENTID) {
282+
this.userdataStore.removeAccessToken();
283+
}
284+
285+
// they have an invalid token
282286
if (payload.data.code === RPCErrors.INVALID_TOKEN) {
283-
this.store.pushError(payload.data.message);
284287
this.userdataStore.removeAccessToken();
285288
}
286289

apps/desktop/src/utils/migration.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { BaseDirectory, createDir, exists, readTextFile, writeFile } from "@tauri-apps/api/fs";
2+
3+
export async function completeMigration(name: string) {
4+
try {
5+
if (!(await exists("migrations", { dir: BaseDirectory.AppConfig }))) {
6+
await createDir("migrations", { dir: BaseDirectory.AppConfig });
7+
}
8+
9+
await writeFile(`migrations/${name}.json`, JSON.stringify({ completed: true }), { dir: BaseDirectory.AppConfig });
10+
} catch (e) {
11+
console.error(e);
12+
}
13+
}
14+
15+
export async function isMigrationComplete(name: string): Promise<boolean> {
16+
try {
17+
const contents = await readTextFile(`migrations/${name}.json`, {
18+
dir: BaseDirectory.AppConfig,
19+
});
20+
21+
return JSON.parse(contents).completed;
22+
} catch (e) {
23+
return false;
24+
}
25+
}
File renamed without changes.

apps/desktop/src/views/settings/join-history.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Button } from "@/components/ui/button";
22
import { Trash, PhoneOff, PhoneIncoming } from "lucide-react";
3-
import { cn } from "@/lib/utils";
3+
import { cn } from "@/utils/tw";
44
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
55
import { useEffect, useRef, useState } from "react";
66
import { listen } from "@tauri-apps/api/event";

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"clean": "turbo run clean && rm -rf node_modules .turbo",
99
"lint": "turbo run lint",
1010
"format": "turbo run format",
11-
"ui:add": "pnpm --filter ui ui:add",
1211
"dl-contrib": "tsx scripts/generate-contributors.ts"
1312
},
1413
"type": "module",

0 commit comments

Comments
 (0)