profile.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Import modules. */
  2. import { defineStore } from 'pinia'
  3. /**
  4. * Profile Store
  5. */
  6. export const useProfileStore = defineStore('profile', {
  7. state: () => ({
  8. /* Initialize player id. */
  9. _playerid: null,
  10. /* Initialize session. */
  11. _session: null,
  12. /**
  13. * Email
  14. *
  15. * This is a valid email address.
  16. */
  17. _email: null,
  18. /**
  19. * Metadata
  20. *
  21. * Used to store (user-defined) data for:
  22. * 1. Individual accounts
  23. * 2. Individual unspent transaction outputs (UXTOs)
  24. *
  25. * NOTE: Metadata MUST be used sparingly, to avoid data storage bloat;
  26. * and should be deleted when no longer needed.
  27. *
  28. * TODO: Allow this data to be stored on-chain using:
  29. * 1. Bitcoin Files Protocol (BFP) (https://bitcoinfiles.com/)
  30. * 2. Telr Locker (https://locker.telr.io)
  31. */
  32. _meta: null,
  33. /**
  34. * Nickname
  35. *
  36. * This is a public alias.
  37. *
  38. * NOTE: Only alpha-numeric characters are accepted.
  39. * Both upper and lower-case characters are accepted.
  40. */
  41. _nickname: null,
  42. }),
  43. getters: {
  44. playerid(_state) {
  45. // return _state._playerid
  46. return 'nexa:nqtsq5g50uxexshuxtfhg8gava58m99japtehqvy0fgcm2zy' // Anon
  47. },
  48. session(_state) {
  49. return _state._session
  50. },
  51. sessionid(_state) {
  52. return _state._session?.id
  53. },
  54. challenge(_state) {
  55. return _state._session?.challenge
  56. },
  57. },
  58. actions: {
  59. deleteSession() {
  60. /* Reset session. */
  61. this._session = null
  62. },
  63. saveSession(_session) {
  64. console.log('PROFILE SAVING SESSION', _session)
  65. /* Set session. */
  66. this._session = _session
  67. },
  68. },
  69. // persist: true,
  70. })