Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 #230

Draft
wants to merge 75 commits into
base: master
Choose a base branch
from
Draft

v4 #230

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
80dbf9d
Start v4
DoctorMcKay Feb 14, 2019
729f078
Removed deprecated confirmation checker
DoctorMcKay Feb 14, 2019
5a85531
Removed inventoryhistory.js
DoctorMcKay Feb 14, 2019
f99d86a
Removed async dependency
DoctorMcKay Feb 14, 2019
103e941
Updated dependencies
DoctorMcKay Feb 14, 2019
0cb0d22
Cleaned up imports
DoctorMcKay Feb 14, 2019
8a7d6f5
Merge branch 'master' into v4
DoctorMcKay Feb 14, 2019
6b0f958
Merge branch 'master' into v4
DoctorMcKay Sep 24, 2019
8e9e372
Code cleanup for chat.js
DoctorMcKay Sep 24, 2019
ac8e4a6
Code cleanup for confirmations.js
DoctorMcKay Sep 24, 2019
d7cfc39
Code cleanup for groups.js
DoctorMcKay Sep 24, 2019
30ebf33
Code cleanup for helpers.js
DoctorMcKay Sep 24, 2019
fa25392
Code cleanup for http.js
DoctorMcKay Sep 24, 2019
dfd0ccb
Merge branch 'master' into v4
DoctorMcKay Jul 22, 2021
247d804
Cleaned up market.js
DoctorMcKay Jul 22, 2021
c550b38
Cleaned up profile.js
DoctorMcKay Jul 22, 2021
9a4be45
Cleaned up twofactor.js
DoctorMcKay Jul 22, 2021
c69a545
Cleaned up webapi.js
DoctorMcKay Jul 22, 2021
d093466
Removed getWebApiOauthToken
DoctorMcKay Jul 22, 2021
8ffa0b5
Cleaned up help.js
DoctorMcKay Jul 22, 2021
2b678be
Some more cleanup
DoctorMcKay Jul 22, 2021
63b0b82
Cleaned up users.js
DoctorMcKay Jul 22, 2021
5b40683
Merge branch 'master' into v4
DoctorMcKay Jul 23, 2021
2adc23f
Added eslint config
DoctorMcKay Jul 29, 2021
4c59309
Refactor index.js
DoctorMcKay Jul 29, 2021
600a411
Refactor all files
DoctorMcKay Jul 29, 2021
9ec3295
Added eslint action
DoctorMcKay Jul 29, 2021
8c0994c
Fixed eslint action
DoctorMcKay Jul 29, 2021
ca887c4
Use npx for eslint
DoctorMcKay Jul 29, 2021
59df4de
eslint requires node 10
DoctorMcKay Jul 29, 2021
a4de664
Disable eslint on generated files
DoctorMcKay Jul 29, 2021
e252efc
Change all eslint rules to errors so they'll hit on CI
DoctorMcKay Jul 29, 2021
40ee35a
Fixed last eslint error
DoctorMcKay Jul 29, 2021
9d47d28
Some more refactoring
DoctorMcKay Jul 29, 2021
89d058f
Update EResult.js
DoctorMcKay Jul 29, 2021
605fb62
Skip eslint workflow for internal pull requests
DoctorMcKay Jul 29, 2021
3def387
Updated @doctormckay/stdlib
DoctorMcKay Jul 29, 2021
485529e
Use npm run lint in workflow
DoctorMcKay Jul 29, 2021
dfda22c
Rename ConfirmationType to EConfirmationType for consistency
DoctorMcKay Jul 29, 2021
e9d3221
Start replacing request with got
DoctorMcKay Jul 29, 2021
ac19e08
Start adding callback promises
DoctorMcKay Jul 29, 2021
7c6e531
Added rationale for not using eqeqeq
DoctorMcKay Jul 30, 2021
565132d
Enforce dot-notation
DoctorMcKay Jul 30, 2021
e49c5c1
Fix dot-notation violation
DoctorMcKay Jul 30, 2021
e2ef03c
Disallow spaces before anonymous/named function parens
DoctorMcKay Jul 30, 2021
fd5ed31
Ignore unused vars starting with underscore
DoctorMcKay Jul 30, 2021
c7a8c67
Simplify isSteamID
DoctorMcKay Jul 30, 2021
d09f18f
Compare against PrivacyState rather than using a magic number
DoctorMcKay Jul 30, 2021
ad09560
Clean up comment parsing code a little
DoctorMcKay Jul 30, 2021
48f0637
Use [email protected]
DoctorMcKay Jul 30, 2021
43c0504
Require node 12 or later
DoctorMcKay Jul 30, 2021
7ebbd58
Merge branch 'master' into v4
DoctorMcKay Feb 2, 2022
b98997a
Merge branch 'master' into v4
DoctorMcKay Apr 24, 2023
d28c2cd
Require node 14
DoctorMcKay Apr 24, 2023
9218ec6
Use stdlib 2.1.0
DoctorMcKay Apr 25, 2023
711ab8a
Update stdlib version
DoctorMcKay Apr 26, 2023
86e87e8
Merge branch 'master' into v4
DoctorMcKay Jun 27, 2023
f776d9f
Removed getWebApiOauthToken
DoctorMcKay Jun 27, 2023
2bfaecd
Removed oAuthLogin method
DoctorMcKay Jun 27, 2023
b48e8fa
Promote steam-session to a full dependency
DoctorMcKay Jun 27, 2023
2094f05
Update xml2js dependency
DoctorMcKay Jun 27, 2023
078e395
Remove got dependency
DoctorMcKay Jun 27, 2023
ccf16b6
Updated httpRequest to use StdLib HttpClient
DoctorMcKay Jun 27, 2023
0ba889e
Fixed merge conflict remnant
DoctorMcKay Jun 27, 2023
028ee43
Updated index.js methods to use new http interface
DoctorMcKay Jun 27, 2023
c1901d5
Updated confirmations.js methods to use new http interface
DoctorMcKay Jun 27, 2023
e9bc778
Removed request dependency
DoctorMcKay Jun 27, 2023
96e3e7e
Updated help.js methods to use new http interface
DoctorMcKay Jun 27, 2023
3a65768
Updated sharedfiles.js methods to use new http interface
DoctorMcKay Jun 27, 2023
e65d50b
Updated twofactor.js methods to use new http interface
DoctorMcKay Jun 27, 2023
38d3fb3
Updated webapi.js methods to use new http interface
DoctorMcKay Jun 27, 2023
8e1f214
Log into steam using steam-session
DoctorMcKay Jun 27, 2023
c006526
Pass httpProxy down to steam-session
DoctorMcKay Jun 27, 2023
25dfa2c
Rename uri to url everywhere
DoctorMcKay Jun 27, 2023
4ec372b
Added packageName and packageVersion properties
DoctorMcKay Jul 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
env: {
commonjs: true,
es2021: true,
node: true
},
extends: 'eslint:recommended',
parserOptions: {
ecmaVersion: 12
},
rules: {
DoctorMcKay marked this conversation as resolved.
Show resolved Hide resolved
// Use tabs for indentation and require 'case' in switch to be indented 1 level (default 0)
indent: ['error', 'tab', {SwitchCase: 1}],
// Single quotes for strings
quotes: ['error', 'single'],
// Always require semicolons
semi: ['error', 'always'],
// Don't use 'var'
'no-var': 'error',
// Only use quotes in object literal keys as needed
'quote-props': ['error', 'as-needed'],
// Don't allow trailing spaces after a line
'no-trailing-spaces': 'error',
// Require spaces before and after keywords (like "if")
'keyword-spacing': 'error',
// Don't allow unused variables, but allow unused function args (e.g. in callbacks) and global vars
'no-unused-vars': ['error', {vars: 'local', args: 'none', varsIgnorePattern: '^_'}],
// Require using dot notation (obj.prop instead of obj['prop']) where possible
'dot-notation': 'error',
// Don't use spaces before parens in anonymous or named functions
'space-before-function-paren': ['error', {anonymous: 'never', named: 'never', asyncArrow: 'always'}]

// We will NOT be using eqeqeq for a few reasons:
// 1. I would have to go through and check every single `==` to make sure that it's not depending on loose equality checks.
// 2. I'm only using ESLint to enforce style, not actual differences in functionality. ==/=== is not merely a style choice.
// Yes, I know that 'no-var' is actually enforcing a difference in functionality, but in practice nobody uses
// (or even knows about) var's hoisting functionality, so at this point it's effectively a style choice.
// 3. A lot of the time, you actually *want* loose equality checks, especially when interacting with a web server
// (as HTTP as no concept of anything but strings). Yes, most of our interaction is JSON, but not all. And even then,
// not all JSON actually serializes numbers as numbers.
// 4. `==` is really nowhere near as dangerous as memes would lead you to believe, if you know what you're doing.
// 5. If the idea behind enforcing `===` is to prevent inexperienced developers from unwittingly introducing bugs
// via loose quality checks, in my opinion it could be just as harmful to instruct a code quality tool to
// naively demand that all `==` become `===`. If a developer were to build code that works, but upon opening
// a pull request they see that ESLint demands they use `===` instead, they might just click "fix" and resubmit,
// expecting the code quality tool to know what it's doing. But it *doesn't* know what it's doing, since it's
// just blindly alerting when it sees `==`. The change in functionality from `==` to `===` could very well
// introduce a bug by itself.
}
};
31 changes: 31 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ESLint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest

# Run for external PRs, but not on our own internal PRs as they'll be run by the push to the branch.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'DoctorMcKay/node-steamcommunity'

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: npm install
working-directory: .
run: npm install --ignore-scripts

- name: Run ESLint
run: npm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/*
test.js
dev/

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down
32 changes: 31 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 26 additions & 11 deletions classes/CConfirmation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var SteamCommunity = require('../index.js');
const StdLib = require('@doctormckay/stdlib');

const SteamCommunity = require('../index.js');

module.exports = CConfirmation;

Expand All @@ -18,20 +20,33 @@ function CConfirmation(community, data) {
this.offerID = this.type == SteamCommunity.ConfirmationType.Trade ? this.creator : null;
}

/**
* @param {number} time
* @param {string} key
* @param {function} [callback]
* @return Promise<{offerID: number}>
*/
CConfirmation.prototype.getOfferID = function(time, key, callback) {
if (this.type && this.creator) {
if (this.type != SteamCommunity.ConfirmationType.Trade) {
callback(new Error('Not a trade confirmation'));
return;
}
return StdLib.Promises.callbackPromise(['offerID'], null, false, async (resolve, reject) => {
if (this.type && this.creator) {
if (this.type != SteamCommunity.ConfirmationType.Trade) {
return reject(new Error('Not a trade confirmation'));
}

callback(null, this.creator);
return;
}
return resolve({offerID: this.creator});
}

this._community.getConfirmationOfferID(this.id, time, key, callback);
return await this._community.getConfirmationOfferID(this.id, time, key, callback);
});
};

/**
* @param {number} time
* @param {string} key
* @param {boolean} accept
* @param {function} [callback]
* @return Promise<void>
*/
CConfirmation.prototype.respond = function(time, key, accept, callback) {
this._community.respondToConfirmation(this.id, this.key, time, key, accept, callback);
return this._community.respondToConfirmation(this.id, this.key, time, key, accept, callback);
};
45 changes: 19 additions & 26 deletions classes/CEconItem.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
module.exports = CEconItem;

function CEconItem(item, description, contextID) {
var thing;
for (thing in item) {
if (item.hasOwnProperty(thing)) {
this[thing] = item[thing];
}
for (let thing in item) {
this[thing] = item[thing];
}

var isCurrency = !!(this.is_currency || this.currency) || typeof this.currencyid !== 'undefined'; // I don't want to put this on the object yet; it's nice to have the ids at the top of printed output
let isCurrency = !!(this.is_currency || this.currency) || typeof this.currencyid !== 'undefined'; // I don't want to put this on the object yet; it's nice to have the ids at the top of printed output

if (isCurrency) {
this.currencyid = this.id = (this.id || this.currencyid);
Expand All @@ -27,10 +24,8 @@ function CEconItem(item, description, contextID) {
description = description[this.classid + '_' + this.instanceid];
}

for (thing in description) {
if (description.hasOwnProperty(thing)) {
this[thing] = description[thing];
}
for (let thing in description) {
this[thing] = description[thing];
}
}

Expand All @@ -49,20 +44,18 @@ function CEconItem(item, description, contextID) {

// Restore old property names of tags
if (this.tags) {
this.tags = this.tags.map(function(tag) {
return {
"internal_name": tag.internal_name,
"name": tag.localized_tag_name || tag.name,
"category": tag.category,
"color": tag.color || "",
"category_name": tag.localized_category_name || tag.category_name
};
});
this.tags = this.tags.map((tag) => ({
internal_name: tag.internal_name,
name: tag.localized_tag_name || tag.name,
category: tag.category,
color: tag.color || '',
category_name: tag.localized_category_name || tag.category_name
}));
}

// Restore market_fee_app, if applicable
var match;
if (this.appid == 753 && this.contextid == 6 && this.market_hash_name && (match = this.market_hash_name.match(/^(\d+)\-/))) {
let match;
if (this.appid == 753 && this.contextid == 6 && this.market_hash_name && (match = this.market_hash_name.match(/^(\d+)-/))) {
this.market_fee_app = parseInt(match[1], 10);
}

Expand All @@ -82,7 +75,7 @@ function CEconItem(item, description, contextID) {
this.cache_expiration = this.item_expiration;
}

if (this.actions === "") {
if (this.actions === '') {
this.actions = [];
}

Expand All @@ -94,23 +87,23 @@ function CEconItem(item, description, contextID) {
}

CEconItem.prototype.getImageURL = function() {
return "https://steamcommunity-a.akamaihd.net/economy/image/" + this.icon_url + "/";
return 'https://steamcommunity-a.akamaihd.net/economy/image/' + this.icon_url + '/';
};

CEconItem.prototype.getLargeImageURL = function() {
if(!this.icon_url_large) {
if (!this.icon_url_large) {
return this.getImageURL();
}

return "https://steamcommunity-a.akamaihd.net/economy/image/" + this.icon_url_large + "/";
return 'https://steamcommunity-a.akamaihd.net/economy/image/' + this.icon_url_large + '/';
};

CEconItem.prototype.getTag = function(category) {
if (!this.tags) {
return null;
}

for (var i = 0; i < this.tags.length; i++) {
for (let i = 0; i < this.tags.length; i++) {
if (this.tags[i].category == category) {
return this.tags[i];
}
Expand Down
Loading