briven-engine-signup-smoke.mjs70 lines · main
| 1 | /** |
| 2 | * Local-only: init supertokens-node against briven-engine and sign up one user. |
| 3 | * No production deploy. Proves engine + SDK path. |
| 4 | * |
| 5 | * BRIVEN_ENGINE_CONNECTION_URI=http://127.0.0.1:3567 bun scripts/briven-engine-signup-smoke.mjs |
| 6 | */ |
| 7 | |
| 8 | import SuperTokens from 'supertokens-node'; |
| 9 | import EmailPassword from 'supertokens-node/recipe/emailpassword'; |
| 10 | import Session from 'supertokens-node/recipe/session'; |
| 11 | import Multitenancy from 'supertokens-node/recipe/multitenancy'; |
| 12 | |
| 13 | const connectionURI = ( |
| 14 | process.env.BRIVEN_ENGINE_CONNECTION_URI || 'http://127.0.0.1:3567' |
| 15 | ).replace(/\/$/, ''); |
| 16 | |
| 17 | const email = `e2e_${Date.now()}@example.com`; |
| 18 | const password = 'E2eTest!Pass99'; |
| 19 | const tenantId = 'proj_p_e2e_local'; |
| 20 | |
| 21 | console.log('engine', connectionURI); |
| 22 | console.log('tenant', tenantId); |
| 23 | console.log('email', email); |
| 24 | |
| 25 | // Probe Core first |
| 26 | const hello = await fetch(`${connectionURI}/hello`); |
| 27 | const helloText = await hello.text(); |
| 28 | if (!hello.ok || !/hello/i.test(helloText)) { |
| 29 | console.error('FAIL core hello', hello.status, helloText); |
| 30 | process.exit(1); |
| 31 | } |
| 32 | console.log('✔ core hello', helloText.trim()); |
| 33 | |
| 34 | SuperTokens.init({ |
| 35 | supertokens: { connectionURI }, |
| 36 | appInfo: { |
| 37 | appName: 'Briven Auth e2e', |
| 38 | apiDomain: 'http://localhost:3001', |
| 39 | websiteDomain: 'http://localhost:3000', |
| 40 | apiBasePath: '/v1/auth-core/fdi', |
| 41 | websiteBasePath: '/auth', |
| 42 | }, |
| 43 | recipeList: [ |
| 44 | Session.init(), |
| 45 | EmailPassword.init(), |
| 46 | Multitenancy.init(), |
| 47 | ], |
| 48 | }); |
| 49 | |
| 50 | // Ensure tenant |
| 51 | try { |
| 52 | const t = await Multitenancy.createOrUpdateTenant(tenantId, { |
| 53 | emailPasswordEnabled: true, |
| 54 | }); |
| 55 | console.log('✔ tenant', t.status, 'createdNew=', t.createdNew); |
| 56 | } catch (err) { |
| 57 | console.warn('tenant ensure', err instanceof Error ? err.message : err); |
| 58 | } |
| 59 | |
| 60 | const signup = await EmailPassword.signUp(tenantId, email, password); |
| 61 | console.log('signup status', signup.status); |
| 62 | |
| 63 | if (signup.status !== 'OK') { |
| 64 | console.error('FAIL signup', signup); |
| 65 | process.exit(1); |
| 66 | } |
| 67 | |
| 68 | console.log('✔ userId', signup.user.id); |
| 69 | console.log('✔ briven-engine local sign-up proof OK'); |
| 70 | process.exit(0); |