Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev' into michael/IR-3593_image_prefab
Browse files Browse the repository at this point in the history
  • Loading branch information
MbfloydIR authored Aug 16, 2024
2 parents 30a9604 + 1cedafc commit 2b7c836
Show file tree
Hide file tree
Showing 42 changed files with 450 additions and 241 deletions.
1 change: 1 addition & 0 deletions packages/client-core/i18n/en/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@
"subtitle": "Edit Metabase Settings",
"siteUrl": "Site Url",
"secretKey": "Secret Key",
"environment": "Environment",
"expiration": "Expiration",
"crashDashboardId": "Crash Dashboard Id"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/client-core/i18n/en/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"unknownStatus": "Unknown Status",
"CORS": "Possibly a CORS error",
"urlFetchError": "Failed to fetch \"{{url}}\"",
"invalidSceneName": "Scene name must be 4-64 characters long, using only alphanumeric characters, hyphens, and underscores."
"invalidSceneName": "Scene name must be 4-64 characters long, using only alphanumeric characters and hyphens, and begin and end with an alphanumeric."
},
"viewport": {
"title": "Viewport",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
const id = useHookstate<string | undefined>(undefined)
const siteUrl = useHookstate('')
const secretKey = useHookstate('')
const environment = useHookstate('')
const expiration = useHookstate(10)
const crashDashboardId = useHookstate('')
const metabaseSettingMutation = useMutation(metabaseSettingPath)
Expand All @@ -55,6 +56,7 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
id.set(data[0].id)
siteUrl.set(data[0].siteUrl)
secretKey.set(data[0].secretKey)
environment.set(data[0].environment)
expiration.set(data[0].expiration)
crashDashboardId.set(data[0].crashDashboardId || '')
}
Expand All @@ -63,13 +65,14 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
const handleSubmit = (event) => {
event.preventDefault()

if (!siteUrl.value || !secretKey.value) return
if (!siteUrl.value || !secretKey.value || !environment.value) return

state.loading.set(true)

const setting = {
siteUrl: siteUrl.value,
secretKey: secretKey.value,
environment: environment.value,
crashDashboardId: crashDashboardId.value
}

Expand All @@ -90,6 +93,7 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
id.set(data[0].id)
siteUrl.set(data[0].siteUrl)
secretKey.set(data[0].secretKey)
environment.set(data[0].environment)
expiration.set(data[0].expiration)
crashDashboardId.set(data[0].crashDashboardId || '')
}
Expand All @@ -112,6 +116,13 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
onChange={(e) => siteUrl.set(e.target.value)}
/>

<Input
className="col-span-1"
label={t('admin:components.setting.metabase.environment')}
value={environment?.value || ''}
onChange={(e) => environment.set(e.target.value)}
/>

<PasswordInput
className="col-span-1"
label={t('admin:components.setting.metabase.secretKey')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ export const FileThumbnailJobState = defineState({
if (seenResources.has(resource.key)) continue
seenResources.add(resource.key)

if (resource.type === 'thumbnail') {
//set thumbnail's thumbnail as itself
Engine.instance.api.service(staticResourcePath).patch(resource.id, { thumbnailKey: resource.key })
continue
}

if (resource.thumbnailKey != null || !extensionCanHaveThumbnail(resource.key.split('.').pop() ?? '')) continue

getMutableState(FileThumbnailJobState).merge([
Expand Down
18 changes: 9 additions & 9 deletions packages/client-core/src/hooks/useZendesk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { AuthState } from '../user/services/AuthService'

declare global {
interface Window {
zE: (...args: any) => void
zE?: (...args: any) => void
}
}

Expand All @@ -49,7 +49,7 @@ export const useZendesk = () => {
const authenticateUser = () => {
if (authenticated.value || config.client.zendesk.authenticationEnabled !== 'true') return

window.zE('messenger', 'loginUser', function (callback: any) {
window.zE?.('messenger', 'loginUser', function (callback: any) {
zendeskMutation.create().then(async (token) => {
authenticated.set(true)
await callback(token)
Expand All @@ -71,10 +71,10 @@ export const useZendesk = () => {
hideWidget()
authenticateUser()
}
window.zE('messenger:on', 'close', () => {
window.zE?.('messenger:on', 'close', () => {
hideWidget()
})
window.zE('messenger:on', 'open', function () {
window.zE?.('messenger:on', 'open', function () {
showWidget()
})
})
Expand All @@ -89,28 +89,28 @@ export const useZendesk = () => {
authenticateUser()
} else if (user.isGuest.value && initialized.value) {
closeChat()
window.zE('messenger', 'logoutUser')
window.zE?.('messenger', 'logoutUser')
}
}, [user.value])

const hideWidget = () => {
if (!initialized.value) return
window.zE('messenger', 'hide')
window.zE?.('messenger', 'hide')
isWidgetVisible.set(false)
}
const showWidget = () => {
if (!initialized.value) return
window.zE('messenger', 'show')
window.zE?.('messenger', 'show')
isWidgetVisible.set(true)
}
const openChat = () => {
if (!initialized.value) return
window.zE('messenger', 'open')
window.zE?.('messenger', 'open')
}

const closeChat = () => {
if (!initialized.value) return
window.zE('messenger', 'close')
window.zE?.('messenger', 'close')
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { useTranslation } from 'react-i18next'
import { Link, useLocation } from 'react-router-dom'

import Avatar from '@etherealengine/client-core/src/common/components/Avatar'
import Button from '@etherealengine/client-core/src/common/components/Button'
import commonStyles from '@etherealengine/client-core/src/common/components/common.module.scss'
import ConfirmDialog from '@etherealengine/client-core/src/common/components/ConfirmDialog'
import { AppleIcon } from '@etherealengine/client-core/src/common/components/Icons/AppleIcon'
Expand Down Expand Up @@ -322,51 +321,51 @@ const ProfileMenu = ({ hideLogin, onClose, isPopover }: Props): JSX.Element => {
// console.log('VC Request query result:', result)
}

async function handleWalletLoginClick() {
const domain = window.location.origin
const challenge = '99612b24-63d9-11ea-b99f-4f66f3e4f81a' // TODO: generate

console.log('Sending DIDAuth query...')

const didAuthQuery: any = {
web: {
VerifiablePresentation: {
query: [
{
type: 'DIDAuth' // request the controller's DID
},
{
type: 'QueryByExample',
credentialQuery: [
{
example: {
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/xr/v1'],
// contains username and avatar icon
type: 'LoginDisplayCredential'
}
},
{
example: {
'@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/xr/v1'],
// various Ethereal Engine user preferences
type: 'UserPreferencesCredential'
}
}
]
}
],
challenge,
domain // e.g.: requestingparty.example.com
}
}
}
// async function handleWalletLoginClick() {
// const domain = window.location.origin
// const challenge = '99612b24-63d9-11ea-b99f-4f66f3e4f81a' // TODO: generate

// console.log('Sending DIDAuth query...')

// const didAuthQuery: any = {
// web: {
// VerifiablePresentation: {
// query: [
// {
// type: 'DIDAuth' // request the controller's DID
// },
// {
// type: 'QueryByExample',
// credentialQuery: [
// {
// example: {
// '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/xr/v1'],
// // contains username and avatar icon
// type: 'LoginDisplayCredential'
// }
// },
// {
// example: {
// '@context': ['https://www.w3.org/2018/credentials/v1', 'https://w3id.org/xr/v1'],
// // various Ethereal Engine user preferences
// type: 'UserPreferencesCredential'
// }
// }
// ]
// }
// ],
// challenge,
// domain // e.g.: requestingparty.example.com
// }
// }
// }

// Use Credential Handler API to authenticate and receive basic login display credentials
const vprResult: any = await navigator.credentials.get(didAuthQuery)
console.log(vprResult)
// // Use Credential Handler API to authenticate and receive basic login display credentials
// const vprResult: any = await navigator.credentials.get(didAuthQuery)
// console.log(vprResult)

AuthService.loginUserByXRWallet(vprResult)
}
// AuthService.loginUserByXRWallet(vprResult)
// }

const refreshApiKey = () => {
AuthService.updateApiKey()
Expand Down Expand Up @@ -752,7 +751,7 @@ const ProfileMenu = ({ hideLogin, onClose, isPopover }: Props): JSX.Element => {
</>
)}

{isGuest && enableWalletLogin && (
{/* {isGuest && enableWalletLogin && (
<>
<Text align="center" variant="body2" mb={1} mt={2}>
{t('user:usermenu.profile.or')}
Expand All @@ -776,7 +775,7 @@ const ProfileMenu = ({ hideLogin, onClose, isPopover }: Props): JSX.Element => {
</Box>
)}
</>
)}
)} */}

{enableSocial && (
<>
Expand Down
108 changes: 54 additions & 54 deletions packages/client-core/src/user/services/AuthService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,41 +317,41 @@ export const AuthService = {
*
* @param vprResult {object} - VPR Query result from a user's wallet.
*/
async loginUserByXRWallet(vprResult: any) {
const authState = getMutableState(AuthState)
try {
authState.merge({ isProcessing: true, error: '' })

const credentials: any = parseUserWalletCredentials(vprResult)
console.log(credentials)

const walletUser = resolveWalletUser(credentials)
const authUser = {
accessToken: '',
authentication: { strategy: 'did-auth' },
identityProvider: {
id: '',
token: '',
type: 'didWallet',
userId: walletUser.id,
createdAt: '',
updatedAt: ''
}
}

// TODO: This is temp until we move completely to XR wallet #6453
const oldId = authState.user.id.value
walletUser.id = oldId

// loadXRAvatarForUpdatedUser(walletUser)
authState.merge({ isLoggedIn: true, user: walletUser, authUser })
} catch (err) {
authState.merge({ error: i18n.t('common:error.login-error') })
NotificationService.dispatchNotify(err.message, { variant: 'error' })
} finally {
authState.merge({ isProcessing: false, error: '' })
}
},
// async loginUserByXRWallet(vprResult: any) {
// const authState = getMutableState(AuthState)
// try {
// authState.merge({ isProcessing: true, error: '' })

// const credentials: any = parseUserWalletCredentials(vprResult)
// console.log(credentials)

// const walletUser = resolveWalletUser(credentials)
// const authUser = {
// accessToken: '',
// authentication: { strategy: 'did-auth' },
// identityProvider: {
// id: '',
// token: '',
// type: 'didWallet',
// userId: walletUser.id,
// createdAt: '',
// updatedAt: ''
// }
// }

// // TODO: This is temp until we move completely to XR wallet #6453
// const oldId = authState.user.id.value
// walletUser.id = oldId

// // loadXRAvatarForUpdatedUser(walletUser)
// authState.merge({ isLoggedIn: true, user: walletUser, authUser })
// } catch (err) {
// authState.merge({ error: i18n.t('common:error.login-error') })
// NotificationService.dispatchNotify(err.message, { variant: 'error' })
// } finally {
// authState.merge({ isProcessing: false, error: '' })
// }
// },

/**
* Logs in the current user based on an OAuth response.
Expand Down Expand Up @@ -725,25 +725,25 @@ export const AuthService = {
/**
* @param vprResult {any} See `loginUserByXRWallet()`'s docstring.
*/
function parseUserWalletCredentials(vprResult: any) {
console.log('PARSING:', vprResult)

const {
data: { presentation: vp }
} = vprResult
const credentials = Array.isArray(vp.verifiableCredential) ? vp.verifiableCredential : [vp.verifiableCredential]

const { displayName, displayIcon } = parseLoginDisplayCredential(credentials)

return {
user: {
id: vp.holder,
displayName,
icon: displayIcon
// session // this will contain the access token and helper methods
}
}
}
// function parseUserWalletCredentials(vprResult: any) {
// console.log('PARSING:', vprResult)

// const {
// data: { presentation: vp }
// } = vprResult
// const credentials = Array.isArray(vp.verifiableCredential) ? vp.verifiableCredential : [vp.verifiableCredential]

// const { displayName, displayIcon } = parseLoginDisplayCredential(credentials)

// return {
// user: {
// id: vp.holder,
// displayName,
// icon: displayIcon
// // session // this will contain the access token and helper methods
// }
// }
// }

/**
* Parses the user's preferred display name (username) and avatar icon from the
Expand Down
Loading

0 comments on commit 2b7c836

Please sign in to comment.