mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-22 01:43:29 +01:00
Changing AuthToken to be complex type so can have a version, rather than just a string
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export type AuthToken = {
|
||||
value: string,
|
||||
version: string
|
||||
}
|
||||
|
||||
export type Association = {
|
||||
authToken: string
|
||||
authToken: AuthToken
|
||||
userId: string
|
||||
nickname: string
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios from "axios";
|
||||
import { Md5 } from "ts-md5/dist/md5";
|
||||
import { AuthToken } from "./link_codes";
|
||||
|
||||
const s = "foobar100";
|
||||
const navidrome = process.env["BONOB_NAVIDROME_URL"];
|
||||
@@ -13,7 +14,7 @@ export function isSuccess(authResult: AuthSuccess | AuthFailure): authResult is
|
||||
}
|
||||
|
||||
export type AuthSuccess = {
|
||||
authToken: string
|
||||
authToken: AuthToken
|
||||
userId: string
|
||||
nickname: string
|
||||
}
|
||||
@@ -28,7 +29,7 @@ export interface MusicService {
|
||||
|
||||
export class Navidrome implements MusicService {
|
||||
login({ username }: Credentials) {
|
||||
return { authToken: `${username}`, userId: username, nickname: username }
|
||||
return { authToken: { value: `${username}`, version: "1" }, userId: username, nickname: username }
|
||||
}
|
||||
|
||||
ping = (): Promise<boolean> =>
|
||||
|
||||
@@ -129,8 +129,8 @@ function server(
|
||||
if (association) {
|
||||
return {
|
||||
getDeviceAuthTokenResult: {
|
||||
authToken: association.authToken,
|
||||
privateKey: "v1",
|
||||
authToken: association.authToken.value,
|
||||
privateKey: association.authToken.version,
|
||||
userInfo: {
|
||||
nickname: association.nickname,
|
||||
userIdHashCode: crypto
|
||||
|
||||
Reference in New Issue
Block a user