-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57757e9
commit 4d327b6
Showing
10 changed files
with
154 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
; This is a basic Blender demo | ||
defaultConfigSource = gnnuzabk | ||
; When developing, switching between configs is useful for test and debug | ||
UNSAFE_allowAnyConfigSource = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,53 @@ | ||
import InPlayer from '@inplayer-org/inplayer.js'; | ||
import InPlayer, { Env } from '@inplayer-org/inplayer.js'; | ||
|
||
import type { Login } from '#types/account'; | ||
import type { AuthData, Customer, Login } from '#types/account'; | ||
import { processInplayerAccount, processInPlayerAuth } from '#src/utils/common'; | ||
import type { Config } from '#types/Config'; | ||
|
||
enum InPlayerEnv { | ||
Development = 'development', | ||
Production = 'production', | ||
Daily = 'daily', | ||
} | ||
|
||
export const setEnvironment = (config: Config) => { | ||
const env: string = config.integrations?.inplayer?.useSandbox ? InPlayerEnv.Daily : InPlayerEnv.Production; | ||
InPlayer.setConfig(env as Env); | ||
}; | ||
|
||
export const login: Login = async ({ config, email, password }) => { | ||
const { data } = await InPlayer.Account.signInV2({ | ||
email, | ||
password, | ||
clientId: config.integrations.inplayer?.clientId || '', | ||
referrer: window.location.href, | ||
}); | ||
|
||
return { | ||
auth: processInPlayerAuth(data), | ||
user: processInplayerAccount(data.account), | ||
}; | ||
try { | ||
const { data } = await InPlayer.Account.signInV2({ | ||
email, | ||
password, | ||
clientId: config.integrations.inplayer?.clientId || '', | ||
referrer: window.location.href, | ||
}); | ||
|
||
return { | ||
auth: processInPlayerAuth(data), | ||
user: processInplayerAccount(data.account), | ||
}; | ||
} catch { | ||
throw new Error('Failed to authenticate user.'); | ||
} | ||
}; | ||
|
||
export const logout = async () => { | ||
try { | ||
InPlayer.Account.signOut(); | ||
} catch { | ||
throw new Error('Failed to sign out.'); | ||
} | ||
}; | ||
|
||
export const getUser = async (): Promise<Customer> => { | ||
try { | ||
const { data } = await InPlayer.Account.getAccountInfo(); | ||
return processInplayerAccount(data); | ||
} catch { | ||
throw new Error('Failed to fetch user data.'); | ||
} | ||
}; | ||
|
||
export const getFreshJwtToken = async ({ auth }: { auth: AuthData }) => auth; |
Oops, something went wrong.