@ianlucas/remix-auth-steam 2.0.0
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/License.txt +24 -0
- package/README.md +13 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +41 -0
- package/dist/promises.d.ts +6 -0
- package/dist/promises.js +26 -0
- package/package.json +46 -0
package/License.txt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2021 Sergio Xalambrí
|
|
5
|
+
Copyright (c) 2022 Andreychik32
|
|
6
|
+
Copyright (c) 2024 - present Ian Lucas
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# remix-auth-steam
|
|
2
|
+
|
|
3
|
+
This is a [Steam](https://steamcommunity.com/) strategy for [remix-auth](https://github.com/sergiodxa/remix-auth) library.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ianlucas/remix-auth-steam
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Refer to the [original repo](https://github.com/Andreychik32/remix-auth-steam#file-structure) for usage instructions.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SessionStorage } from "@remix-run/server-runtime";
|
|
2
|
+
import { AuthenticateOptions, Strategy, StrategyVerifyCallback } from "remix-auth";
|
|
3
|
+
import { UserSummary } from "steamapi";
|
|
4
|
+
export interface SteamStrategyOptions {
|
|
5
|
+
returnURL: string;
|
|
6
|
+
realm?: string;
|
|
7
|
+
apiKey: string;
|
|
8
|
+
}
|
|
9
|
+
export type SteamStrategyVerifyParams = UserSummary;
|
|
10
|
+
export declare class SteamStrategy<User> extends Strategy<User, SteamStrategyVerifyParams> {
|
|
11
|
+
name: string;
|
|
12
|
+
private options;
|
|
13
|
+
constructor(options: SteamStrategyOptions | (() => Promise<SteamStrategyOptions>), verify: StrategyVerifyCallback<User, SteamStrategyVerifyParams>);
|
|
14
|
+
authenticate(request: Request, sessionStorage: SessionStorage, options: AuthenticateOptions): Promise<User>;
|
|
15
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Ian Lucas. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { redirect } from "@remix-run/server-runtime";
|
|
6
|
+
import { Strategy } from "remix-auth";
|
|
7
|
+
import OpenID from "openid";
|
|
8
|
+
import { PromiseAuthenticate, PromiseVerifyAssertion } from "./promises";
|
|
9
|
+
import SteamAPI from "steamapi";
|
|
10
|
+
export class SteamStrategy extends Strategy {
|
|
11
|
+
name = "steam";
|
|
12
|
+
options;
|
|
13
|
+
constructor(options, verify) {
|
|
14
|
+
super(verify);
|
|
15
|
+
this.options = options;
|
|
16
|
+
}
|
|
17
|
+
async authenticate(request, sessionStorage, options) {
|
|
18
|
+
const { apiKey, returnURL, realm } = typeof this.options === "function" ? await this.options() : this.options;
|
|
19
|
+
const relyingParty = new OpenID.RelyingParty(returnURL, realm ?? null, true, false, []);
|
|
20
|
+
const steamApi = new SteamAPI(apiKey);
|
|
21
|
+
try {
|
|
22
|
+
const result = await PromiseVerifyAssertion(relyingParty, request);
|
|
23
|
+
if (!result.authenticated || !result.claimedIdentifier)
|
|
24
|
+
return this.failure(`Not authenticated from result`, request, sessionStorage, options);
|
|
25
|
+
try {
|
|
26
|
+
const userSteamID = result.claimedIdentifier.toString().split("/").at(-1);
|
|
27
|
+
const steamUserSummary = (await steamApi.getUserSummary(userSteamID));
|
|
28
|
+
const user = await this.verify(steamUserSummary);
|
|
29
|
+
return this.success(user, request, sessionStorage, options);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
let message = error.message;
|
|
33
|
+
return this.failure(message, request, sessionStorage, options);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
const result = await PromiseAuthenticate(relyingParty);
|
|
38
|
+
throw redirect(result);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type OpenID from "openid";
|
|
2
|
+
export declare const PromiseAuthenticate: (relyingParty: OpenID.RelyingParty) => Promise<string>;
|
|
3
|
+
export declare const PromiseVerifyAssertion: (relyingParty: OpenID.RelyingParty, req: Request) => Promise<{
|
|
4
|
+
authenticated: boolean;
|
|
5
|
+
claimedIdentifier?: string | undefined;
|
|
6
|
+
}>;
|
package/dist/promises.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Ian Lucas. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export const PromiseAuthenticate = (relyingParty) => new Promise((resolve, reject) => {
|
|
6
|
+
relyingParty.authenticate("https://steamcommunity.com/openid", false, (err, url) => {
|
|
7
|
+
if (err) {
|
|
8
|
+
return reject(err);
|
|
9
|
+
}
|
|
10
|
+
if (!url) {
|
|
11
|
+
return reject("Got no URL from authenticate method");
|
|
12
|
+
}
|
|
13
|
+
return resolve(url);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
export const PromiseVerifyAssertion = (relyingParty, req) => new Promise((resolve, reject) => {
|
|
17
|
+
relyingParty.verifyAssertion(req, (err, result) => {
|
|
18
|
+
if (err) {
|
|
19
|
+
return reject(err);
|
|
20
|
+
}
|
|
21
|
+
if (!result) {
|
|
22
|
+
return reject(`No result from verifyAssertion`);
|
|
23
|
+
}
|
|
24
|
+
return resolve(result);
|
|
25
|
+
});
|
|
26
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ianlucas/remix-auth-steam",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Remix authentication strategy for Steam",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Ian Lucas",
|
|
7
|
+
"repository": "ianlucas/remix-auth-steam",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"auth",
|
|
11
|
+
"authentication",
|
|
12
|
+
"remix-auth",
|
|
13
|
+
"remix-steam",
|
|
14
|
+
"remix",
|
|
15
|
+
"steam",
|
|
16
|
+
"strategy"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prepack": "([ -d dist ] && rm -rf dist); tsc",
|
|
20
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
21
|
+
"format": "prettier . --write"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@remix-run/server-runtime": "^2.8.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@babel/core": "^7.24.1",
|
|
28
|
+
"@babel/preset-env": "^7.24.1",
|
|
29
|
+
"@babel/preset-react": "^7.24.1",
|
|
30
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
31
|
+
"@remix-run/node": "^2.8.1",
|
|
32
|
+
"@remix-run/react": "^2.8.1",
|
|
33
|
+
"@remix-run/server-runtime": "^2.8.1",
|
|
34
|
+
"@types/node": "^20.11.30",
|
|
35
|
+
"@types/openid": "^2.0.5",
|
|
36
|
+
"prettier": "^3.2.5",
|
|
37
|
+
"react": "^18.2.0",
|
|
38
|
+
"typescript": "^5.4.2"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@types/steamapi": "^2.2.5",
|
|
42
|
+
"openid": "^2.0.12",
|
|
43
|
+
"remix-auth": "^3.6.0",
|
|
44
|
+
"steamapi": "^3.0.8"
|
|
45
|
+
}
|
|
46
|
+
}
|