steamutils 1.4.27 → 1.4.29
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/utils.js +30 -0
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { EAuthTokenPlatformType, LoginApprover, LoginSession } from "steam-session";
|
2
|
+
|
1
3
|
const isBrowser = typeof window !== "undefined";
|
2
4
|
|
3
5
|
export const sleep = (ms) => {
|
@@ -206,3 +208,31 @@ export async function renewRefreshToken({ refreshToken, accessToken }) {
|
|
206
208
|
console.error("renewRefreshToken Error", e);
|
207
209
|
}
|
208
210
|
}
|
211
|
+
|
212
|
+
export async function approveLogin({ steamId, url, sharedSecret, accessToken, shouldApprove }) {
|
213
|
+
try {
|
214
|
+
const approver = new LoginApprover(accessToken, sharedSecret, {});
|
215
|
+
const sessionInfo = await approver.getAuthSessionInfo(url);
|
216
|
+
sessionInfo.steamId = steamId;
|
217
|
+
|
218
|
+
if (typeof shouldApprove === "function" && !shouldApprove(sessionInfo)) {
|
219
|
+
return;
|
220
|
+
}
|
221
|
+
|
222
|
+
await approver.approveAuthSession({
|
223
|
+
qrChallengeUrl: url,
|
224
|
+
approve: true,
|
225
|
+
});
|
226
|
+
|
227
|
+
return {
|
228
|
+
steamId,
|
229
|
+
sessionInfo,
|
230
|
+
};
|
231
|
+
} catch (error) {
|
232
|
+
console.error("approveLogin Error", error);
|
233
|
+
return {
|
234
|
+
steamId,
|
235
|
+
error,
|
236
|
+
};
|
237
|
+
}
|
238
|
+
}
|