next-auth-dynamodb
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -34,3 +34,3 @@ "use strict"; | ||
accessToken: joi_1.default.string().required(), | ||
accessTokenExpires: joi_1.default.number().required(), | ||
accessTokenExpires: joi_1.default.number(), | ||
}, | ||
@@ -109,3 +109,3 @@ }); | ||
}); | ||
await AccountStore.create({ | ||
const account = { | ||
userId, | ||
@@ -117,4 +117,7 @@ providerId, | ||
accessToken, | ||
accessTokenExpires, | ||
}); | ||
}; | ||
if (accessTokenExpires) { | ||
account.accessTokenExpires = accessTokenExpires; | ||
} | ||
await AccountStore.create(account); | ||
}, | ||
@@ -121,0 +124,0 @@ // Session |
{ | ||
"name": "next-auth-dynamodb", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"contributors": [ | ||
@@ -5,0 +5,0 @@ "Tom Andrews <git@tomandrews.co.uk>" |
@@ -78,2 +78,32 @@ import Omanyd from "omanyd"; | ||
it("should not fail to link when there is no access token expiry date", async () => { | ||
const adapter = await nextAuthDynamodb.getAdapter(opts); | ||
const savedUser = await adapter.createUser({ | ||
email: "foo@bar.com", | ||
emailVerified: false, | ||
name: "Foo Bar", | ||
image: "foo.png", | ||
}); | ||
const providerId = `providerId-${Date.now()}`; | ||
const providerAccountId = `providerAccountId-${Date.now()}`; | ||
await adapter.linkAccount( | ||
savedUser.id, | ||
providerId, | ||
"providerType", | ||
providerAccountId, | ||
"refreshToken", | ||
"accessToken", | ||
null | ||
); | ||
const readUser = await adapter.getUserByProviderAccountId( | ||
providerId, | ||
providerAccountId | ||
); | ||
expect(readUser).toStrictEqual(savedUser); | ||
}); | ||
it("should not blow up if a provider uses numeric account ids", async () => { | ||
@@ -80,0 +110,0 @@ const adapter = await nextAuthDynamodb.getAdapter(opts); |
@@ -37,3 +37,3 @@ import type { Adapter } from "next-auth/adapters"; | ||
accessToken: string; | ||
accessTokenExpires: number; | ||
accessTokenExpires?: number; | ||
} | ||
@@ -52,3 +52,3 @@ | ||
accessToken: Joi.string().required(), | ||
accessTokenExpires: Joi.number().required(), | ||
accessTokenExpires: Joi.number(), | ||
}, | ||
@@ -154,3 +154,3 @@ }); | ||
accessToken: string, | ||
accessTokenExpires: number | ||
accessTokenExpires: number | null | ||
) { | ||
@@ -166,3 +166,3 @@ log("linkAccount", { | ||
}); | ||
await AccountStore.create({ | ||
const account: Omit<Account, "id"> = { | ||
userId, | ||
@@ -174,4 +174,7 @@ providerId, | ||
accessToken, | ||
accessTokenExpires, | ||
}); | ||
}; | ||
if (accessTokenExpires) { | ||
account.accessTokenExpires = accessTokenExpires; | ||
} | ||
await AccountStore.create(account); | ||
}, | ||
@@ -178,0 +181,0 @@ |
27539
625