@ianlucas/remix-auth-steam 3.0.0 → 4.1.0-beta.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/dist/index.d.ts +3 -2
- package/dist/index.js +36 -16
- package/package.json +17 -16
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { SessionStorage } from "@remix-run/server-runtime";
|
|
|
2
2
|
import { AuthenticateOptions, Strategy, StrategyVerifyCallback } from "remix-auth";
|
|
3
3
|
import { UserSummary } from "steamapi";
|
|
4
4
|
export interface SteamStrategyOptions {
|
|
5
|
-
returnURL: string;
|
|
6
|
-
realm?: string;
|
|
7
5
|
apiKey: string;
|
|
6
|
+
onError?: (error: unknown) => void;
|
|
7
|
+
realm?: string;
|
|
8
|
+
returnURL: string;
|
|
8
9
|
}
|
|
9
10
|
export type SteamStrategyVerifyParams = {
|
|
10
11
|
request: Request;
|
package/dist/index.js
CHANGED
|
@@ -40,26 +40,46 @@ export class SteamStrategy extends Strategy {
|
|
|
40
40
|
this.options = options;
|
|
41
41
|
}
|
|
42
42
|
async authenticate(request, sessionStorage, options) {
|
|
43
|
-
const { apiKey, returnURL, realm } = typeof this.options === "function" ? await this.options(request) : this.options;
|
|
44
|
-
const
|
|
45
|
-
|
|
43
|
+
const { apiKey, onError, returnURL, realm } = typeof this.options === "function" ? await this.options(request) : this.options;
|
|
44
|
+
const notifyError = (error) => {
|
|
45
|
+
if (!(error instanceof Response)) {
|
|
46
|
+
onError?.(error);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
46
49
|
try {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const relyingParty = new OpenID.RelyingParty(returnURL, realm ?? null, true, false, []);
|
|
51
|
+
const steamApi = new SteamAPI(apiKey);
|
|
52
|
+
const url = new URL(request.url);
|
|
53
|
+
const callbackUrl = new URL(returnURL);
|
|
54
|
+
if (url.pathname === callbackUrl.pathname) {
|
|
55
|
+
const result = await verifySteamAssertion(relyingParty, request);
|
|
56
|
+
if (!result.authenticated || !result.claimedIdentifier)
|
|
57
|
+
return this.failure(`Not authenticated from result`, request, sessionStorage, options);
|
|
58
|
+
try {
|
|
59
|
+
const userSteamID = result.claimedIdentifier.toString().split("/").at(-1);
|
|
60
|
+
const steamUserSummary = (await steamApi.getUserSummary(userSteamID));
|
|
61
|
+
const user = await this.verify({ user: steamUserSummary, request });
|
|
62
|
+
return this.success(user, request, sessionStorage, options);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
notifyError(error);
|
|
66
|
+
let message = error.message;
|
|
67
|
+
return this.failure(message, request, sessionStorage, options);
|
|
68
|
+
}
|
|
55
69
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
else {
|
|
71
|
+
try {
|
|
72
|
+
throw redirect(await authenticateToSteam(relyingParty));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
notifyError(error);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
59
78
|
}
|
|
60
79
|
}
|
|
61
|
-
catch {
|
|
62
|
-
|
|
80
|
+
catch (error) {
|
|
81
|
+
notifyError(error);
|
|
82
|
+
throw error;
|
|
63
83
|
}
|
|
64
84
|
}
|
|
65
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ianlucas/remix-auth-steam",
|
|
3
|
-
"version": "3.0.0",
|
|
4
3
|
"description": "Remix authentication strategy for Steam",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"author": "Ian Lucas",
|
|
@@ -19,29 +18,31 @@
|
|
|
19
18
|
"scripts": {
|
|
20
19
|
"prepack": "([ -d dist ] && rm -rf dist); tsc",
|
|
21
20
|
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
22
|
-
"format": "prettier . --write"
|
|
21
|
+
"format": "prettier . --write",
|
|
22
|
+
"upgrade": "npx npm-check-updates@latest --target minor -u"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@remix-run/server-runtime": "^2.8.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
-
"@babel/preset-env": "^7.
|
|
30
|
-
"@babel/preset-react": "^7.24.
|
|
31
|
-
"@babel/preset-typescript": "^7.24.
|
|
32
|
-
"@remix-run/node": "^2.
|
|
33
|
-
"@remix-run/react": "^2.
|
|
34
|
-
"@remix-run/server-runtime": "^2.
|
|
35
|
-
"@types/node": "^20.
|
|
28
|
+
"@babel/core": "^7.25.2",
|
|
29
|
+
"@babel/preset-env": "^7.25.4",
|
|
30
|
+
"@babel/preset-react": "^7.24.7",
|
|
31
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
32
|
+
"@remix-run/node": "^2.11.2",
|
|
33
|
+
"@remix-run/react": "^2.11.2",
|
|
34
|
+
"@remix-run/server-runtime": "^2.11.2",
|
|
35
|
+
"@types/node": "^20.16.1",
|
|
36
36
|
"@types/openid": "^2.0.5",
|
|
37
|
-
"prettier": "^3.
|
|
38
|
-
"react": "^18.
|
|
39
|
-
"typescript": "^5.4
|
|
37
|
+
"prettier": "^3.3.3",
|
|
38
|
+
"react": "^18.3.1",
|
|
39
|
+
"typescript": "^5.5.4"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@types/steamapi": "^2.2.5",
|
|
43
43
|
"openid": "^2.0.12",
|
|
44
|
-
"remix-auth": "^3.
|
|
45
|
-
"steamapi": "^3.0.
|
|
46
|
-
}
|
|
44
|
+
"remix-auth": "^3.7.0",
|
|
45
|
+
"steamapi": "^3.0.12"
|
|
46
|
+
},
|
|
47
|
+
"version": "4.1.0-beta.1"
|
|
47
48
|
}
|