Skip to content

Commit 8ba5076

Browse files
author
chxx
committed
fixed token expired
1 parent e85536b commit 8ba5076

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

tests/smapi_auth.test.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ describe("auth", () => {
6363

6464
const expiresIn = "1h";
6565
const secret = `secret-${uuid()}`;
66-
const key = uuid();
67-
const smapiLoginTokens = new JWTSmapiLoginTokens(clock, secret, expiresIn, () => key);
66+
const smapiLoginTokens = new JWTSmapiLoginTokens(clock, secret, expiresIn);
6867

6968
describe("issuing a new token", () => {
7069
it("should issue a token that can then be verified", () => {
@@ -77,7 +76,7 @@ describe("auth", () => {
7776
serviceToken,
7877
iat: clock.now().unix(),
7978
},
80-
secret + SMAPI_TOKEN_VERSION + key,
79+
secret + "." + SMAPI_TOKEN_VERSION,
8180
{ expiresIn }
8281
);
8382

@@ -100,16 +99,13 @@ describe("auth", () => {
10099
const vXSmapiTokens = new JWTSmapiLoginTokens(
101100
clock,
102101
secret,
103-
expiresIn,
104-
uuid,
105-
SMAPI_TOKEN_VERSION
102+
expiresIn
106103
);
107104

108105
const vXPlus1SmapiTokens = new JWTSmapiLoginTokens(
109106
clock,
110107
secret,
111108
expiresIn,
112-
() => uuid(),
113109
SMAPI_TOKEN_VERSION + 1
114110
);
115111

@@ -146,10 +142,7 @@ describe("auth", () => {
146142

147143
const smapiToken = smapiLoginTokens.issue(authToken);
148144

149-
const result = smapiLoginTokens.verify({
150-
...smapiToken,
151-
key: "some other key",
152-
});
145+
const result = new JWTSmapiLoginTokens(clock, "different-secret", expiresIn).verify(smapiToken);
153146
expect(result).toEqual(
154147
E.left(new InvalidTokenError("invalid signature"))
155148
);

0 commit comments

Comments
 (0)