@ley0x/better-auth-lastfm 1.1.6 → 1.2.1

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.
package/README.md CHANGED
@@ -44,7 +44,12 @@ export const auth = betterAuth({
44
44
  // Optional: set base URL (usually auto-detected)
45
45
  baseUrl: process.env.BETTER_AUTH_URL
46
46
  })
47
- ]
47
+ ],
48
+ // Optional: customize session expiration (default: 7 days)
49
+ session: {
50
+ expiresIn: 60 * 60 * 24 * 30, // 30 days
51
+ updateAge: 60 * 60 * 24 // Update session every day
52
+ }
48
53
  })
49
54
  ```
50
55
 
@@ -147,6 +152,48 @@ BETTER_AUTH_SECRET=your_secret_here # BetterAuth secret
147
152
 
148
153
  The plugin uses BetterAuth's standard user and account tables. Last.fm session keys are stored in the `accessToken` field of the account record.
149
154
 
155
+ ## Session Configuration
156
+
157
+ By default, BetterAuth sessions expire after 7 days. You can customize the session expiration by adding a `session` configuration object to your `betterAuth` configuration:
158
+
159
+ ```typescript
160
+ export const auth = betterAuth({
161
+ plugins: [lastfmPlugin({ /* ... */ })],
162
+ session: {
163
+ expiresIn: 60 * 60 * 24 * 30, // 30 days (default: 7 days)
164
+ updateAge: 60 * 60 * 24 // Update session every day (default: 1 day)
165
+ }
166
+ })
167
+ ```
168
+
169
+ ### Important: Session Persistence Fix
170
+
171
+ **Note**: A recent fix ensures sessions persist across browser restarts. The plugin now properly respects cookie `maxAge` settings. See [SESSION_PERSISTENCE_SOLUTION.md](SESSION_PERSISTENCE_SOLUTION.md) for details.
172
+
173
+ ### Recommended Configuration for Persistence
174
+
175
+ ```typescript
176
+ export const auth = betterAuth({
177
+ plugins: [lastfmPlugin({ /* ... */ })],
178
+ session: {
179
+ expiresIn: 60 * 60 * 24 * 30, // 30 days
180
+ updateAge: 60 * 60 * 24,
181
+ cookieCache: {
182
+ enabled: true,
183
+ maxAge: 60 * 60 * 24,
184
+ strategy: 'compact'
185
+ }
186
+ },
187
+ cookies: {
188
+ sessionToken: {
189
+ attributes: {
190
+ maxAge: 60 * 60 * 24 * 30 // Persistent cookie
191
+ }
192
+ }
193
+ }
194
+ })
195
+ ```
196
+
150
197
  ## API Reference
151
198
 
152
199
  ### `lastfmPlugin(options)`
package/dist/index.cjs CHANGED
@@ -147,16 +147,16 @@ function lastfmPlugin(options) {
147
147
  }
148
148
  });
149
149
  }
150
- const session = await ctx.context.internalAdapter.createSession(user.id, ctx);
150
+ const session = await ctx.context.internalAdapter.createSession(user.id);
151
151
  const cookieName = ctx.context.authCookies.sessionToken.name;
152
- const cookieOptions = ctx.context.authCookies.sessionToken.options;
152
+ const cookieOptions = ctx.context.authCookies.sessionToken.attributes;
153
153
  await ctx.setSignedCookie(
154
154
  cookieName,
155
155
  session.token,
156
156
  ctx.context.secret,
157
157
  {
158
158
  ...cookieOptions,
159
- maxAge: void 0
159
+ maxAge: cookieOptions.maxAge || void 0
160
160
  }
161
161
  );
162
162
  return ctx.redirect(redirectTo);
package/dist/index.js CHANGED
@@ -120,16 +120,16 @@ function lastfmPlugin(options) {
120
120
  }
121
121
  });
122
122
  }
123
- const session = await ctx.context.internalAdapter.createSession(user.id, ctx);
123
+ const session = await ctx.context.internalAdapter.createSession(user.id);
124
124
  const cookieName = ctx.context.authCookies.sessionToken.name;
125
- const cookieOptions = ctx.context.authCookies.sessionToken.options;
125
+ const cookieOptions = ctx.context.authCookies.sessionToken.attributes;
126
126
  await ctx.setSignedCookie(
127
127
  cookieName,
128
128
  session.token,
129
129
  ctx.context.secret,
130
130
  {
131
131
  ...cookieOptions,
132
- maxAge: void 0
132
+ maxAge: cookieOptions.maxAge || void 0
133
133
  }
134
134
  );
135
135
  return ctx.redirect(redirectTo);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ley0x/better-auth-lastfm",
3
- "version": "1.1.6",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "description": "Last.fm authentication plugin for BetterAuth",
6
6
  "main": "dist/index.cjs",
@@ -44,16 +44,16 @@
44
44
  "better-auth": "^1.x.x"
45
45
  },
46
46
  "dependencies": {
47
- "zod": "^3.25.76"
47
+ "zod": "^4.3.6"
48
48
  },
49
49
  "devDependencies": {
50
- "@eslint/js": "^9.33.0",
51
- "@types/node": "^20.19.10",
50
+ "@eslint/js": "^10.0.1",
51
+ "@types/node": "^25.5.0",
52
52
  "better-auth": "latest",
53
- "eslint": "^9.33.0",
54
- "tsup": "^8.5.0",
55
- "typescript": "^5.9.2",
56
- "typescript-eslint": "^8.39.1",
53
+ "eslint": "^10.1.0",
54
+ "tsup": "^8.5.1",
55
+ "typescript": "^5.9.3",
56
+ "typescript-eslint": "^8.57.2",
57
57
  "vitest": "^1.6.1"
58
58
  },
59
59
  "engines": {