@ianlucas/remix-auth-steam 2.1.1 → 4.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.
@@ -0,0 +1,30 @@
1
+ name: Publish Release (npm)
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish-npm:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ id-token: write
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: actions/setup-node@v4
15
+ with:
16
+ node-version: 22.x
17
+ registry-url: "https://registry.npmjs.org"
18
+ cache: "npm"
19
+ - run: npm ci
20
+ - run: npm version ${TAG_NAME} --git-tag-version=false
21
+ env:
22
+ TAG_NAME: ${{ github.ref_name }}
23
+ - run: npm publish --provenance --access public --tag next
24
+ if: "github.event.release.prerelease"
25
+ env:
26
+ NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
27
+ - run: npm publish --provenance --access public
28
+ if: "!github.event.release.prerelease"
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
package/dist/index.d.ts CHANGED
@@ -2,11 +2,15 @@ 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
- export type SteamStrategyVerifyParams = UserSummary;
10
+ export type SteamStrategyVerifyParams = {
11
+ request: Request;
12
+ user: UserSummary;
13
+ };
10
14
  export declare class SteamStrategy<User> extends Strategy<User, SteamStrategyVerifyParams> {
11
15
  private options;
12
16
  name: string;
package/dist/index.js CHANGED
@@ -40,7 +40,12 @@ 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;
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
+ };
44
49
  const relyingParty = new OpenID.RelyingParty(returnURL, realm ?? null, true, false, []);
45
50
  const steamApi = new SteamAPI(apiKey);
46
51
  try {
@@ -50,16 +55,24 @@ export class SteamStrategy extends Strategy {
50
55
  try {
51
56
  const userSteamID = result.claimedIdentifier.toString().split("/").at(-1);
52
57
  const steamUserSummary = (await steamApi.getUserSummary(userSteamID));
53
- const user = await this.verify(steamUserSummary);
58
+ const user = await this.verify({ user: steamUserSummary, request });
54
59
  return this.success(user, request, sessionStorage, options);
55
60
  }
56
61
  catch (error) {
62
+ notifyError(error);
57
63
  let message = error.message;
58
64
  return this.failure(message, request, sessionStorage, options);
59
65
  }
60
66
  }
61
- catch {
62
- throw redirect(await authenticateToSteam(relyingParty));
67
+ catch (error) {
68
+ notifyError(error);
69
+ try {
70
+ throw redirect(await authenticateToSteam(relyingParty));
71
+ }
72
+ catch (error) {
73
+ notifyError(error);
74
+ throw error;
75
+ }
63
76
  }
64
77
  }
65
78
  }
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@ianlucas/remix-auth-steam",
3
- "version": "2.1.1",
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.24.1",
29
- "@babel/preset-env": "^7.24.1",
30
- "@babel/preset-react": "^7.24.1",
31
- "@babel/preset-typescript": "^7.24.1",
32
- "@remix-run/node": "^2.8.1",
33
- "@remix-run/react": "^2.8.1",
34
- "@remix-run/server-runtime": "^2.8.1",
35
- "@types/node": "^20.11.30",
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.2.5",
38
- "react": "^18.2.0",
39
- "typescript": "^5.4.2"
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.6.0",
45
- "steamapi": "^3.0.8"
46
- }
44
+ "remix-auth": "^3.7.0",
45
+ "steamapi": "^3.0.12"
46
+ },
47
+ "version": "4.0.0"
47
48
  }