briven-engine-signup-smoke.mjs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Local-only: sign up one user on briven-engine (public tenant).
  3. *
  4. * Multitenancy createTenant needs SuperTokens LICENSE_KEY (free key available
  5. * from SuperTokens). Until set, isolation can use public + project metadata,
  6. * or set BRIVEN_ENGINE_LICENSE_KEY on the engine container.
  7. *
  8. * cd apps/api
  9. * BRIVEN_ENGINE_CONNECTION_URI=http://127.0.0.1:3567 bun scripts/briven-engine-signup-smoke.mjs
  10. */
  11. import SuperTokens from 'supertokens-node';
  12. import EmailPassword from 'supertokens-node/recipe/emailpassword';
  13. import Session from 'supertokens-node/recipe/session';
  14. const connectionURI = (
  15. process.env.BRIVEN_ENGINE_CONNECTION_URI || 'http://127.0.0.1:3567'
  16. ).replace(/\/$/, '');
  17. const email = `e2e_${Date.now()}@example.com`;
  18. const password = 'E2eTest!Pass99';
  19. const tenantId = 'public';
  20. console.log('engine', connectionURI);
  21. console.log('tenant', tenantId);
  22. console.log('email', email);
  23. const hello = await fetch(`${connectionURI}/hello`);
  24. const helloText = await hello.text();
  25. if (!hello.ok || !/hello/i.test(helloText)) {
  26. console.error('FAIL core hello', hello.status, helloText);
  27. process.exit(1);
  28. }
  29. console.log('✔ core hello', helloText.trim());
  30. SuperTokens.init({
  31. supertokens: { connectionURI },
  32. appInfo: {
  33. appName: 'Briven Auth e2e',
  34. apiDomain: 'http://localhost:3001',
  35. websiteDomain: 'http://localhost:3000',
  36. apiBasePath: '/v1/auth-core/fdi',
  37. websiteBasePath: '/auth',
  38. },
  39. recipeList: [Session.init(), EmailPassword.init()],
  40. });
  41. const signup = await EmailPassword.signUp(tenantId, email, password);
  42. console.log('signup status', signup.status);
  43. if (signup.status !== 'OK') {
  44. console.error('FAIL signup', signup);
  45. process.exit(1);
  46. }
  47. console.log('✔ userId', signup.user.id);
  48. console.log('✔ briven-engine local sign-up proof OK');
  49. process.exit(0);