@auth/dynamodb-adapter 1.0.12 → 1.0.14

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
@@ -25,4 +25,4 @@
25
25
 
26
26
  ---
27
27
 
28
- Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/dynamodb).
28
+ Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/dynamodb).
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,OAAO,EAKR,MAAM,qBAAqB,CAAA;AAE5B,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsII;AACJ,wBAAgB,eAAe,CAC7B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAyST;AASD,QAAA,MAAM,MAAM;IACV,8EAA8E;eACnE,OAAO,MAAM,EAAE,GAAG,CAAC;IAY9B,sEAAsE;+CAC3B,OAAO,MAAM,EAAE,GAAG,CAAC;CAsB/D,CAAA;AAED,iBAAS,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,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AAM,CAAA;IACxB,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChD,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnD,CAgBA;AAED,OAAO,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAA"}
package/index.js CHANGED
@@ -377,11 +377,14 @@ export function DynamoDBAdapter(client, options) {
377
377
  });
378
378
  if (!data.Items?.length)
379
379
  return null;
380
- const { pk, sk } = data.Items[0];
380
+ const sessionRecord = data.Items[0];
381
381
  const { UpdateExpression, ExpressionAttributeNames, ExpressionAttributeValues, } = generateUpdateExpression(session);
382
382
  const res = await client.update({
383
383
  TableName,
384
- Key: { pk, sk },
384
+ Key: {
385
+ [pk]: sessionRecord[pk],
386
+ [sk]: sessionRecord[sk],
387
+ },
385
388
  UpdateExpression,
386
389
  ExpressionAttributeNames,
387
390
  ExpressionAttributeValues,
@@ -405,10 +408,13 @@ export function DynamoDBAdapter(client, options) {
405
408
  });
406
409
  if (!data?.Items?.length)
407
410
  return null;
408
- const { pk, sk } = data.Items[0];
411
+ const sessionRecord = data.Items[0];
409
412
  const res = await client.delete({
410
413
  TableName,
411
- Key: { pk, sk },
414
+ Key: {
415
+ [pk]: sessionRecord[pk],
416
+ [sk]: sessionRecord[sk],
417
+ },
412
418
  ReturnValues: "ALL_OLD",
413
419
  });
414
420
  return format.from(res.Attributes);
package/jest.config.js CHANGED
@@ -1,9 +1,14 @@
1
+ import config from "utils/adapter/jest-preset.js"
2
+ import path from 'node:path'
3
+
4
+ process.env.JEST_DYNAMODB_CONFIG = path.resolve('./jest-dynamodb-config.cjs');
5
+
1
6
  /*
2
7
  * For a detailed explanation regarding each configuration property and type check, visit:
3
8
  * https://jestjs.io/docs/en/configuration.html
4
9
  */
5
- module.exports = {
6
- ...require("@next-auth/adapter-test/jest/jest-preset"),
10
+ export default {
11
+ ...config,
7
12
  // // Indicates whether the coverage information should be collected while executing the test
8
13
  // collectCoverage: true,
9
14
  // // Indicates which provider should be used to instrument code for coverage
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@auth/dynamodb-adapter",
3
3
  "repository": "https://github.com/nextauthjs/next-auth",
4
- "version": "1.0.12",
4
+ "version": "1.0.14",
5
5
  "description": "AWS DynamoDB adapter for next-auth.",
6
6
  "keywords": [
7
7
  "next-auth",
@@ -42,10 +42,10 @@
42
42
  "devDependencies": {
43
43
  "@aws-sdk/client-dynamodb": "^3.36.1",
44
44
  "@aws-sdk/lib-dynamodb": "^3.36.1",
45
- "@shelf/jest-dynamodb": "^2.1.0"
45
+ "@shelf/jest-dynamodb": "^3.4.2"
46
46
  },
47
47
  "dependencies": {
48
- "@auth/core": "0.19.0"
48
+ "@auth/core": "0.20.0"
49
49
  },
50
50
  "scripts": {
51
51
  "test:default": "jest",
package/src/index.ts CHANGED
@@ -406,7 +406,7 @@ export function DynamoDBAdapter(
406
406
  },
407
407
  })
408
408
  if (!data.Items?.length) return null
409
- const { pk, sk } = data.Items[0] as any
409
+ const sessionRecord = data.Items[0]
410
410
  const {
411
411
  UpdateExpression,
412
412
  ExpressionAttributeNames,
@@ -414,7 +414,10 @@ export function DynamoDBAdapter(
414
414
  } = generateUpdateExpression(session)
415
415
  const res = await client.update({
416
416
  TableName,
417
- Key: { pk, sk },
417
+ Key: {
418
+ [pk]: sessionRecord[pk],
419
+ [sk]: sessionRecord[sk],
420
+ },
418
421
  UpdateExpression,
419
422
  ExpressionAttributeNames,
420
423
  ExpressionAttributeValues,
@@ -438,11 +441,14 @@ export function DynamoDBAdapter(
438
441
  })
439
442
  if (!data?.Items?.length) return null
440
443
 
441
- const { pk, sk } = data.Items[0]
444
+ const sessionRecord = data.Items[0]
442
445
 
443
446
  const res = await client.delete({
444
447
  TableName,
445
- Key: { pk, sk },
448
+ Key: {
449
+ [pk]: sessionRecord[pk],
450
+ [sk]: sessionRecord[sk],
451
+ },
446
452
  ReturnValues: "ALL_OLD",
447
453
  })
448
454
  return format.from<AdapterSession>(res.Attributes)
@@ -1,41 +0,0 @@
1
- module.exports = {
2
- tables: [
3
- {
4
- TableName: `next-auth`,
5
- KeySchema: [
6
- { AttributeName: "pk", KeyType: "HASH" },
7
- { AttributeName: "sk", KeyType: "RANGE" },
8
- ],
9
- AttributeDefinitions: [
10
- { AttributeName: "sk", AttributeType: "S" },
11
- { AttributeName: "pk", AttributeType: "S" },
12
- { AttributeName: "GSI1PK", AttributeType: "S" },
13
- { AttributeName: "GSI1SK", AttributeType: "S" },
14
- ],
15
- GlobalSecondaryIndexes: [
16
- {
17
- IndexName: "GSI1",
18
- KeySchema: [
19
- { AttributeName: "GSI1PK", KeyType: "HASH" },
20
- { AttributeName: "GSI1SK", KeyType: "RANGE" },
21
- ],
22
- Projection: {
23
- ProjectionType: "ALL",
24
- },
25
- ProvisionedThroughput: {
26
- ReadCapacityUnits: 1,
27
- WriteCapacityUnits: 1,
28
- },
29
- },
30
- ],
31
- ProvisionedThroughput: { ReadCapacityUnits: 1, WriteCapacityUnits: 1 },
32
- },
33
- // etc
34
- ],
35
- port: 8000,
36
- installerConfig: {
37
- installPath: "./dynamodblocal-bin",
38
- downloadUrl:
39
- "https://s3.eu-central-1.amazonaws.com/dynamodb-local-frankfurt/dynamodb_local_latest.tar.gz",
40
- },
41
- }