@rio.js/enterprise 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
- import { n as db } from "./db-Bd2Dgk3D.mjs";
1
+ import { $ as teamRole, A as oauthAccessTokenRelations, B as organizationRoleRelations, C as memberAssetRoleRelations, D as memberTeamRole, E as memberRelations, F as object, G as schemaDefinition, H as platformRole, I as objectRelations, J as sessionRelations, K as schemaDefinitionRelations, L as organization$1, M as oauthApplicationRelations, N as oauthConsent, O as memberTeamRoleRelations, P as oauthConsentRelations, Q as teamRelations, R as organizationRelations, S as memberAssetRole, T as memberOrganizationRoleRelations, U as relationship, V as person, W as relationshipRelations, X as teamMember, Y as team, Z as teamMemberRelations, _ as assetType, a as agent, at as verification, b as invitationRelations, c as apikeyRelations, d as assetRole, et as teamRoleRelations, f as assetRoleRelations, g as assetShareRelations, h as assetShareLinkRelations, i as accountRelations, it as userRelations, j as oauthApplication, k as oauthAccessToken, l as asset, m as assetShareLink, n as db, nt as twoFactorRelations, o as agentRelations, ot as enterpriseSchema, p as assetShare, q as session, r as account, rt as user, s as apikey, st as __export, tt as twoFactor$1, u as assetRelations, v as assetTypeRelations, w as memberOrganizationRole, x as member, y as invitation, z as organizationRole } from "./db-Bd2Dgk3D.mjs";
2
2
  import { G as getCurrentTransactionAdapter, W as getCurrentGraphContext } from "./json-oFuWgANh-CZSe35mm.mjs";
3
3
  import { f as logger, g as BetterAuthError, v as invariant } from "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
4
4
  import { A as apiKey, E as admin, K as graph, R as lastLoginMethod, U as organization, a as openAPI, it as APIError$1, j as assets, k as agents, rt as twoFactor, z as mcp } from "./plugins-C_-kHHzW.mjs";
5
- import { n as betterAuth, t as db_schema_final_exports } from "./db-schema.final-U_UYOH47.mjs";
5
+ import { t as betterAuth } from "./dist-DGeBMuXr.mjs";
6
6
  import { t as createAdapterFactory } from "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
7
7
  import { and, asc, count, desc, eq, gt, gte, inArray, like, lt, lte, ne, notInArray, or, sql } from "drizzle-orm";
8
8
  import cuid from "cuid";
@@ -295,6 +295,69 @@ const drizzleAdapter = (db$1, config) => {
295
295
  };
296
296
  };
297
297
 
298
+ //#endregion
299
+ //#region src/db-schema.final.ts
300
+ var db_schema_final_exports = /* @__PURE__ */ __export({
301
+ account: () => account,
302
+ accountRelations: () => accountRelations,
303
+ agent: () => agent,
304
+ agentRelations: () => agentRelations,
305
+ apikey: () => apikey,
306
+ apikeyRelations: () => apikeyRelations,
307
+ asset: () => asset,
308
+ assetRelations: () => assetRelations,
309
+ assetRole: () => assetRole,
310
+ assetRoleRelations: () => assetRoleRelations,
311
+ assetShare: () => assetShare,
312
+ assetShareLink: () => assetShareLink,
313
+ assetShareLinkRelations: () => assetShareLinkRelations,
314
+ assetShareRelations: () => assetShareRelations,
315
+ assetType: () => assetType,
316
+ assetTypeRelations: () => assetTypeRelations,
317
+ enterpriseSchema: () => enterpriseSchema,
318
+ invitation: () => invitation,
319
+ invitationRelations: () => invitationRelations,
320
+ member: () => member,
321
+ memberAssetRole: () => memberAssetRole,
322
+ memberAssetRoleRelations: () => memberAssetRoleRelations,
323
+ memberOrganizationRole: () => memberOrganizationRole,
324
+ memberOrganizationRoleRelations: () => memberOrganizationRoleRelations,
325
+ memberRelations: () => memberRelations,
326
+ memberTeamRole: () => memberTeamRole,
327
+ memberTeamRoleRelations: () => memberTeamRoleRelations,
328
+ oauthAccessToken: () => oauthAccessToken,
329
+ oauthAccessTokenRelations: () => oauthAccessTokenRelations,
330
+ oauthApplication: () => oauthApplication,
331
+ oauthApplicationRelations: () => oauthApplicationRelations,
332
+ oauthConsent: () => oauthConsent,
333
+ oauthConsentRelations: () => oauthConsentRelations,
334
+ object: () => object,
335
+ objectRelations: () => objectRelations,
336
+ organization: () => organization$1,
337
+ organizationRelations: () => organizationRelations,
338
+ organizationRole: () => organizationRole,
339
+ organizationRoleRelations: () => organizationRoleRelations,
340
+ person: () => person,
341
+ platformRole: () => platformRole,
342
+ relationship: () => relationship,
343
+ relationshipRelations: () => relationshipRelations,
344
+ schemaDefinition: () => schemaDefinition,
345
+ schemaDefinitionRelations: () => schemaDefinitionRelations,
346
+ session: () => session,
347
+ sessionRelations: () => sessionRelations,
348
+ team: () => team,
349
+ teamMember: () => teamMember,
350
+ teamMemberRelations: () => teamMemberRelations,
351
+ teamRelations: () => teamRelations,
352
+ teamRole: () => teamRole,
353
+ teamRoleRelations: () => teamRoleRelations,
354
+ twoFactor: () => twoFactor$1,
355
+ twoFactorRelations: () => twoFactorRelations,
356
+ user: () => user,
357
+ userRelations: () => userRelations,
358
+ verification: () => verification
359
+ });
360
+
298
361
  //#endregion
299
362
  //#region src/utils/email.ts
300
363
  /**
@@ -365,11 +428,11 @@ async function getOrCreatePersonalOrganization(userId, userName) {
365
428
  value: userId
366
429
  }]
367
430
  });
368
- for (const member of existingMembers) if (await adapter.findOne({
431
+ for (const member$1 of existingMembers) if (await adapter.findOne({
369
432
  model: "organization",
370
433
  where: [{
371
434
  field: "id",
372
- value: member.organizationId
435
+ value: member$1.organizationId
373
436
  }, {
374
437
  field: "slug",
375
438
  value: `user-${userId}`
@@ -480,13 +543,18 @@ function createAuthSystem(options) {
480
543
  ...options.plugins ?? []
481
544
  ],
482
545
  account: { accountLinking: { enabled: true } },
546
+ session: { cookieCache: {
547
+ enabled: true,
548
+ maxAge: 300,
549
+ refreshCache: { updateAge: 60 }
550
+ } },
483
551
  trustedOrigins: ["http://localhost:3000"],
484
552
  emailAndPassword: {
485
553
  enabled: true,
486
554
  requireEmailVerification: true,
487
- sendResetPassword: async ({ user, url, token }, request) => {
555
+ sendResetPassword: async ({ user: user$1, url, token }, request) => {
488
556
  await sendEmail({
489
- to: user.email,
557
+ to: user$1.email,
490
558
  subject: "Reset your password",
491
559
  text: `Click the link to reset your password: ${url}`
492
560
  });
@@ -494,32 +562,32 @@ function createAuthSystem(options) {
494
562
  },
495
563
  hooks: {},
496
564
  databaseHooks: { user: { create: {
497
- async before(user, options$1) {
498
- if (user.actorType === "agent") {} else {
565
+ async before(user$1, options$1) {
566
+ if (user$1.actorType === "agent") {} else {
499
567
  invariant(!!options$1?.context.adapter, "Adapter is required");
500
- if (!user.id) user.id = generatePrefixedId("user");
568
+ if (!user$1.id) user$1.id = generatePrefixedId("user");
501
569
  const adapter = await getCurrentTransactionAdapter();
502
570
  const graphAdapter = await getCurrentGraphContext();
503
- const person = await adapter.create({
571
+ const person$1 = await adapter.create({
504
572
  model: "person",
505
- data: { name: user.name },
573
+ data: { name: user$1.name },
506
574
  select: ["id"]
507
575
  });
508
576
  await graphAdapter.addRelationship({
509
- subjectId: person.id,
577
+ subjectId: person$1.id,
510
578
  subjectType: "person",
511
- objectId: user.id,
579
+ objectId: user$1.id,
512
580
  objectType: "user",
513
581
  relationshipType: "person_profile"
514
582
  });
515
- if (!person) throw new Error("Failed to create person");
516
- user.actorType = "person";
517
- user.actorId = person.id;
583
+ if (!person$1) throw new Error("Failed to create person");
584
+ user$1.actorType = "person";
585
+ user$1.actorId = person$1.id;
518
586
  }
519
- return { data: user };
587
+ return { data: user$1 };
520
588
  },
521
- async after(user, context) {
522
- if (user.actorType === "person" && user.id) await getOrCreatePersonalOrganization(user.id, user.name || "User");
589
+ async after(user$1, context) {
590
+ if (user$1.actorType === "person" && user$1.id) await getOrCreatePersonalOrganization(user$1.id, user$1.name || "User");
523
591
  }
524
592
  } } },
525
593
  user: { additionalFields: {
@@ -542,7 +610,7 @@ function createAuthSystem(options) {
542
610
  });
543
611
  }
544
612
  },
545
- database: drizzleAdapter(db, {
613
+ database: drizzleAdapter(options.db ?? db, {
546
614
  provider: "pg",
547
615
  schema: db_schema_final_exports,
548
616
  usePlural: false,
@@ -1,9 +1,11 @@
1
+ import { n as db } from "./db-D5eWeSOf.mjs";
1
2
  import * as better_auth0 from "better-auth";
2
3
  import { BetterAuthPlugin, betterAuth } from "better-auth";
3
4
 
4
5
  //#region src/better-auth.d.ts
5
6
  declare function createAuthSystem(options: {
6
7
  plugins?: BetterAuthPlugin[];
8
+ db?: typeof db;
7
9
  }): ReturnType<typeof betterAuth>;
8
10
  declare const auth: better_auth0.Auth<better_auth0.BetterAuthOptions>;
9
11
  //#endregion
@@ -1,2 +1,3 @@
1
- import { n as createAuthSystem, t as auth } from "./better-auth-D2WGpedB.mjs";
1
+ import "./db-D5eWeSOf.mjs";
2
+ import { n as createAuthSystem, t as auth } from "./better-auth-RunrSBmw.mjs";
2
3
  export { auth, createAuthSystem };
@@ -10,8 +10,8 @@ import "./dist-BidhxJQx.mjs";
10
10
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
11
11
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
12
12
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
13
- import "./db-schema.final-U_UYOH47.mjs";
13
+ import "./dist-DGeBMuXr.mjs";
14
14
  import "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
15
- import { n as createAuthSystem, t as auth } from "./better-auth-BZO6QkDT.mjs";
15
+ import { n as createAuthSystem, t as auth } from "./better-auth-C0GYWCr8.mjs";
16
16
 
17
17
  export { auth, createAuthSystem };
package/dist/db.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as db, t as databaseSchema } from "./db-DCIm6th7.mjs";
1
+ import { n as db, t as databaseSchema } from "./db-D5eWeSOf.mjs";
2
2
  export { databaseSchema, db };
@@ -1,4 +1,3 @@
1
- import { $ as teamRole, A as oauthAccessTokenRelations, B as organizationRoleRelations, C as memberAssetRoleRelations, D as memberTeamRole, E as memberRelations, F as object, G as schemaDefinition, H as platformRole, I as objectRelations, J as sessionRelations, K as schemaDefinitionRelations, L as organization, M as oauthApplicationRelations, N as oauthConsent, O as memberTeamRoleRelations, P as oauthConsentRelations, Q as teamRelations, R as organizationRelations, S as memberAssetRole, T as memberOrganizationRoleRelations, U as relationship, V as person, W as relationshipRelations, X as teamMember, Y as team, Z as teamMemberRelations, _ as assetType, a as agent, at as verification, b as invitationRelations, c as apikeyRelations, d as assetRole, et as teamRoleRelations, f as assetRoleRelations, g as assetShareRelations, h as assetShareLinkRelations, i as accountRelations, it as userRelations, j as oauthApplication, k as oauthAccessToken, l as asset, m as assetShareLink, nt as twoFactorRelations, o as agentRelations, ot as enterpriseSchema, p as assetShare, q as session, r as account, rt as user, s as apikey, st as __export, tt as twoFactor, u as assetRelations, v as assetTypeRelations, w as memberOrganizationRole, x as member, y as invitation, z as organizationRole } from "./db-Bd2Dgk3D.mjs";
2
1
  import { c as generateId, f as createHash, h as hashPassword, n as getAuthTables, p as createRandomStringGenerator, q as runWithAdapter, v as verifyPassword } from "./json-oFuWgANh-CZSe35mm.mjs";
3
2
  import { a as getBooleanEnvVar, f as logger, g as BetterAuthError, h as BASE_ERROR_CODES, i as env, l as isProduction, r as createLogger, s as getEnvVar, t as ENV, u as isTest } from "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
4
3
  import { H as base64 } from "./verify-BmFXks5a.mjs";
@@ -636,8 +635,8 @@ async function createAuthContext(adapter, options, getDatabaseType) {
636
635
  },
637
636
  checkPassword
638
637
  },
639
- setNewSession(session$1) {
640
- this.newSession = session$1;
638
+ setNewSession(session) {
639
+ this.newSession = session;
641
640
  },
642
641
  newSession: null,
643
642
  adapter,
@@ -719,67 +718,4 @@ const betterAuth = (options) => {
719
718
  };
720
719
 
721
720
  //#endregion
722
- //#region src/db-schema.final.ts
723
- var db_schema_final_exports = /* @__PURE__ */ __export({
724
- account: () => account,
725
- accountRelations: () => accountRelations,
726
- agent: () => agent,
727
- agentRelations: () => agentRelations,
728
- apikey: () => apikey,
729
- apikeyRelations: () => apikeyRelations,
730
- asset: () => asset,
731
- assetRelations: () => assetRelations,
732
- assetRole: () => assetRole,
733
- assetRoleRelations: () => assetRoleRelations,
734
- assetShare: () => assetShare,
735
- assetShareLink: () => assetShareLink,
736
- assetShareLinkRelations: () => assetShareLinkRelations,
737
- assetShareRelations: () => assetShareRelations,
738
- assetType: () => assetType,
739
- assetTypeRelations: () => assetTypeRelations,
740
- enterpriseSchema: () => enterpriseSchema,
741
- invitation: () => invitation,
742
- invitationRelations: () => invitationRelations,
743
- member: () => member,
744
- memberAssetRole: () => memberAssetRole,
745
- memberAssetRoleRelations: () => memberAssetRoleRelations,
746
- memberOrganizationRole: () => memberOrganizationRole,
747
- memberOrganizationRoleRelations: () => memberOrganizationRoleRelations,
748
- memberRelations: () => memberRelations,
749
- memberTeamRole: () => memberTeamRole,
750
- memberTeamRoleRelations: () => memberTeamRoleRelations,
751
- oauthAccessToken: () => oauthAccessToken,
752
- oauthAccessTokenRelations: () => oauthAccessTokenRelations,
753
- oauthApplication: () => oauthApplication,
754
- oauthApplicationRelations: () => oauthApplicationRelations,
755
- oauthConsent: () => oauthConsent,
756
- oauthConsentRelations: () => oauthConsentRelations,
757
- object: () => object,
758
- objectRelations: () => objectRelations,
759
- organization: () => organization,
760
- organizationRelations: () => organizationRelations,
761
- organizationRole: () => organizationRole,
762
- organizationRoleRelations: () => organizationRoleRelations,
763
- person: () => person,
764
- platformRole: () => platformRole,
765
- relationship: () => relationship,
766
- relationshipRelations: () => relationshipRelations,
767
- schemaDefinition: () => schemaDefinition,
768
- schemaDefinitionRelations: () => schemaDefinitionRelations,
769
- session: () => session,
770
- sessionRelations: () => sessionRelations,
771
- team: () => team,
772
- teamMember: () => teamMember,
773
- teamMemberRelations: () => teamMemberRelations,
774
- teamRelations: () => teamRelations,
775
- teamRole: () => teamRole,
776
- teamRoleRelations: () => teamRoleRelations,
777
- twoFactor: () => twoFactor,
778
- twoFactorRelations: () => twoFactorRelations,
779
- user: () => user,
780
- userRelations: () => userRelations,
781
- verification: () => verification
782
- });
783
-
784
- //#endregion
785
- export { getTelemetryAuthConfig as i, betterAuth as n, createTelemetry as r, db_schema_final_exports as t };
721
+ export { createTelemetry as n, getTelemetryAuthConfig as r, betterAuth as t };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as createAuthSystem } from "./better-auth-D2WGpedB.mjs";
2
- import { n as db } from "./db-DCIm6th7.mjs";
1
+ import { n as db } from "./db-D5eWeSOf.mjs";
2
+ import { n as createAuthSystem } from "./better-auth-RunrSBmw.mjs";
3
3
  import { parseSetCookieHeader } from "better-auth/cookies";
4
4
  export * from "better-auth";
5
5
  export * from "better-auth/crypto";
package/dist/index.mjs CHANGED
@@ -10,8 +10,8 @@ import "./dist-BidhxJQx.mjs";
10
10
  import { t as capitalizeFirstLetter } from "./misc-CbURQDlR-Dpe-5X_i.mjs";
11
11
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
12
12
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
13
- import { i as getTelemetryAuthConfig, n as betterAuth, r as createTelemetry } from "./db-schema.final-U_UYOH47.mjs";
13
+ import { n as createTelemetry, r as getTelemetryAuthConfig, t as betterAuth } from "./dist-DGeBMuXr.mjs";
14
14
  import "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
15
- import { n as createAuthSystem } from "./better-auth-BZO6QkDT.mjs";
15
+ import { n as createAuthSystem } from "./better-auth-C0GYWCr8.mjs";
16
16
 
17
17
  export { APIError$1 as APIError, BASE_ERROR_CODES, BetterAuthError, ENV, HIDE_METADATA, TTY_COLORS, accountSchema, betterAuth, capitalizeFirstLetter, clientCredentialsToken, constantTimeEqual, coreSchema, createAuthSystem, createAuthorizationCodeRequest, createAuthorizationURL, createClientCredentialsTokenRequest, createLogger, createRefreshAccessTokenRequest, createTelemetry, defineErrorCodes, db as enterpriseDB, env, generateCodeChallenge, generateId, generateRandomString, generateState, getBooleanEnvVar, getColorDepth, getCurrentAdapter, getCurrentGraphContext, getCurrentTransactionAdapter, getEnvVar, getOAuth2Tokens, getTelemetryAuthConfig, hashPassword, initializeGraph, invariant, isDevelopment, isProduction, isTest, levels, logger, nodeENV, parseSetCookieHeader, parseState, rateLimitSchema, refreshAccessToken, sessionSchema, shouldPublishLog, signJWT, symmetricDecodeJWT, symmetricDecrypt, symmetricEncodeJWT, symmetricEncrypt, userSchema, validateAuthorizationCode, validateToken, verificationSchema, verifyJWT, verifyPassword };
package/dist/init.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import "./db-Bd2Dgk3D.mjs";
2
1
  import "./json-oFuWgANh-CZSe35mm.mjs";
3
2
  import "./env-DwlNAN_D-C1zHd0cf-DcFsKQM_.mjs";
4
3
  import "./verify-BmFXks5a.mjs";
@@ -10,8 +9,7 @@ import "./dist-BidhxJQx.mjs";
10
9
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
11
10
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
12
11
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
13
- import "./db-schema.final-U_UYOH47.mjs";
14
- import { eq } from "drizzle-orm";
12
+ import "./dist-DGeBMuXr.mjs";
15
13
  import { readFile } from "fs/promises";
16
14
 
17
15
  //#region src/init.ts
package/dist/server.mjs CHANGED
@@ -10,9 +10,9 @@ import "./dist-BidhxJQx.mjs";
10
10
  import "./misc-CbURQDlR-Dpe-5X_i.mjs";
11
11
  import "./parser-bL7W2mQ0-JPVS1FmJ.mjs";
12
12
  import "./client--1_AEBPu-Dl2Y0Yen.mjs";
13
- import "./db-schema.final-U_UYOH47.mjs";
13
+ import "./dist-DGeBMuXr.mjs";
14
14
  import "./adapter-factory-BTRALCLD-Bv_0fQx-.mjs";
15
- import { t as auth } from "./better-auth-BZO6QkDT.mjs";
15
+ import { t as auth } from "./better-auth-C0GYWCr8.mjs";
16
16
  import "dotenv/config";
17
17
  import { cors } from "@elysiajs/cors";
18
18
  import { jwt } from "@elysiajs/jwt";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rio.js/enterprise",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "srvx --import=jiti/register --port 3001",
File without changes