gitoriaLog in with ident

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit98226b4198226b41antcolony#40: mission references point to the moved missionsmre98226b41/tests/oldstore-009.hl

3.8 KB

  1. // tests/oldstore-009.hl — THE MIGRATION FIXTURE (tests/migration.mjs): an ident store in the
  2. // OLD format (before mission 009: `*id` tables `<prefix>-<table>.*`, public ids = id + 1),
  3. // with known keys, secret hashes and per-app ids. OLD_PREFIX=/abs/dir/ident
  4. // The ids are EXPLICIT (id = 0, 1, …) since hybriel 5bb08628 (#4): a fresh `*id` table counts from 1
  5. // now, the old tables counted from 0 (mission 048).
  6. import { MPackDB } from 'hl:mpackdb'
  7. import { env } from 'hl:proc'
  8. import { now } from 'hl:time'
  9. import { sha256 } from 'hl:crypto'
  10. let p = env('OLD_PREFIX')
  11. let accounts = new MPackDB(file = p + '-accounts.db', primaryKey = '*id', indexes = ['!email'])
  12. let identities = new MPackDB(file = p + '-identities.db', primaryKey = '*id', indexes = ['account'])
  13. let otp = new MPackDB(file = p + '-otp.db', primaryKey = '*id', indexes = ['email'])
  14. let sends = new MPackDB(file = p + '-sends.db', primaryKey = '*id', indexes = ['email'])
  15. let apps = new MPackDB(file = p + '-apps.db', primaryKey = '*id', indexes = ['owner' '!apiKey'])
  16. let conns = new MPackDB(file = p + '-connections.db', primaryKey = '*id', indexes = ['!pair' 'app' '!appIdentity'])
  17. let requests = new MPackDB(file = p + '-requests.db', primaryKey = '*id', indexes = ['!rid'])
  18. let grants = new MPackDB(file = p + '-grants.db', primaryKey = '*id', indexes = ['!hash'])
  19. let t = now()
  20. let x = (c, n) => {
  21. let s = ''
  22. while (s.length < n) { s = s + c }
  23. return s
  24. }
  25. accounts.put({ id = 0 email = '[email protected]' timeZone = 'Europe/Vienna' created = t - 90000 }) // public 1
  26. accounts.put({ id = 1 email = '[email protected]' timeZone = 'Asia/Tokyo' created = t - 80000 }) // public 2
  27. identities.put({ id = 0 account = 1 identityName = 'Default' nickname = 'Al' firstname = 'Alice' lastname = 'Example' created = t - 89000 updated = t - 1000 }) // 1
  28. identities.put({ id = 1 account = 1 identityName = 'Work' nickname = '' firstname = '' lastname = '' created = t - 70000 updated = t - 70000 }) // 2
  29. identities.put({ id = 2 account = 2 identityName = 'Default' nickname = '' firstname = '' lastname = '' created = t - 79000 updated = t - 79000 }) // 3
  30. let gone = identities.put({ id = 3 account = 1 identityName = 'Old' nickname = '' firstname = '' lastname = '' created = t - 60000 updated = t - 60000 }) // 4, deleted below
  31. apps.put({ id = 0 owner = 1 name = 'Fixture app' origins = 'http://127.0.0.1:8396' apiKey = 'pk_' + x('1', 32) secretHash = sha256('sk_' + x('2', 48)) created = t - 50000 updated = t - 50000 }) // 1
  32. apps.put({ id = 1 owner = 2 name = 'Bob app' origins = 'http://127.0.0.1:8397' apiKey = 'pk_' + x('3', 32) secretHash = sha256('sk_' + x('4', 48)) created = t - 40000 updated = t - 40000 }) // 2
  33. conns.put({ id = 0 pair = '1:1' app = 1 identity = 1 appIdentity = x('a', 32) created = t - 49000 })
  34. conns.put({ id = 1 pair = '1:2' app = 1 identity = 2 appIdentity = x('b', 32) created = t - 48000 })
  35. conns.put({ id = 2 pair = '1:4' app = 1 identity = 4 appIdentity = x('c', 32) created = t - 47000 })
  36. conns.put({ id = 3 pair = '2:3' app = 2 identity = 3 appIdentity = x('d', 32) created = t - 39000 })
  37. identities.delete(gone)
  38. sends.put({ id = 0 email = '[email protected]' at = t - 1000 })
  39. otp.put({ id = 0 email = '[email protected]' hash = sha256('[email protected]:123456') expires = t + 600000 tries = 0 })
  40. requests.put({ id = 0 rid = x('f', 32) app = 1 returnUrl = 'http://127.0.0.1:8396/callback' expires = t + 1800000 })
  41. grants.put({ id = 0 hash = sha256(x('e', 48)) app = 1 identity = 2 appIdentity = x('b', 32) expires = t + 3600000 })
  42. console.log('oldstore: accounts ' + accounts.count() + ' identities ' + identities.count() + ' apps ' + apps.count() + ' connections ' + conns.count() + ' otp ' + otp.count() + ' sends ' + sends.count() + ' requests ' + requests.count() + ' grants ' + grants.count())

Branches

Latest commits

  • 98226b41antcolony#40: mission references point to the moved missionsmre
  • ff805b9aantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
  • 51a7bcdfident: Hybriel master 73267707 (#122); /code uses the new page() signature; pending address passed as parameter; once-checksmre
  • 836f644fident#24: installable app (manifest, service worker, data-free offline /start), own iconmre
  • 8bebbbf2deploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • cc063ea2deploy.sh: never send .git or .gitignore to Byrodinmre
  • 81b15b7bState of 2026-09-27, before the move to gitoriamre