Coder Social home page Coder Social logo

alexanderwe / the-traveler Goto Github PK

View Code? Open in Web Editor NEW
56.0 6.0 10.0 7.62 MB

The Traveler is a small npm package which wraps around the Destiny 2 API.

Home Page: https://alexanderwe.github.io/the-traveler/

License: MIT License

TypeScript 99.96% JavaScript 0.04%
destiny2 destiny-api node-module api-wrapper npm-package nodejs bungie-api bungie api destiny

the-traveler's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

the-traveler's Issues

Failing to compile

I'm a front end web developer (mostly html/css/js/php) and I decided to dive into Node.js/Angular, so I'm definitely doing something wrong, there's no doubt about it. I'm just hoping somebody can help.

Any time I add this to app.component.ts:
`import Traveler from 'the-traveler';
import { ComponentType } from 'the-traveler/build/enums';

const traveler = new Traveler({
apikey: 'pasteYourAPIkey',
userAgent: 'yourUserAgent', //used to identify your request to the API
});`

It fails to compile, and I get this in cmd:
`ERROR in ./node_modules/aws-sign2/index.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\aws-sign2'
ERROR in ./node_modules/aws4/aws4.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\aws4'
ERROR in ./node_modules/ecc-jsbn/index.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\ecc-jsbn'
ERROR in ./node_modules/http-signature/lib/signer.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\http-signature\lib'
ERROR in ./node_modules/http-signature/lib/verify.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\http-signature\lib'
ERROR in ./node_modules/oauth-sign/index.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\oauth-sign'
ERROR in ./node_modules/request/lib/helpers.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\request\lib'
ERROR in ./node_modules/request/lib/hawk.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\request\lib'
ERROR in ./node_modules/request/lib/oauth.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\request\lib'
ERROR in ./node_modules/sshpk/lib/key.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/dhe.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/certificate.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/signature.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/fingerprint.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/identity.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/utils.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/private-key.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/sshpk/lib/formats/pem.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib\formats'
ERROR in ./node_modules/sshpk/lib/formats/ssh-private.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib\formats'
ERROR in ./node_modules/sshpk/lib/formats/openssh-cert.js
Module not found: Error: Can't resolve 'crypto' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib\formats'
ERROR in ./node_modules/node-stream-zip/node_stream_zip.js
Module not found: Error: Can't resolve 'fs' in 'D:\Coding\BitBucket\testiny\node_modules\node-stream-zip'
ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in 'D:\Coding\BitBucket\testiny\node_modules\request\lib'
ERROR in ./node_modules/the-traveler/build/Traveler.js
Module not found: Error: Can't resolve 'fs' in 'D:\Coding\BitBucket\testiny\node_modules\the-traveler\build'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'http' in 'D:\Coding\BitBucket\testiny\node_modules\forever-agent'
ERROR in ./node_modules/http-signature/lib/signer.js
Module not found: Error: Can't resolve 'http' in 'D:\Coding\BitBucket\testiny\node_modules\http-signature\lib'
ERROR in ./node_modules/request/request.js
Module not found: Error: Can't resolve 'http' in 'D:\Coding\BitBucket\testiny\node_modules\request'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'http' in 'D:\Coding\BitBucket\testiny\node_modules\tunnel-agent'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'https' in 'D:\Coding\BitBucket\testiny\node_modules\forever-agent'
ERROR in ./node_modules/request/request.js
Module not found: Error: Can't resolve 'https' in 'D:\Coding\BitBucket\testiny\node_modules\request'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'https' in 'D:\Coding\BitBucket\testiny\node_modules\tunnel-agent'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in 'D:\Coding\BitBucket\testiny\node_modules\forever-agent'
ERROR in ./node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in 'D:\Coding\BitBucket\testiny\node_modules\tough-cookie\lib'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in 'D:\Coding\BitBucket\testiny\node_modules\tunnel-agent'
ERROR in ./node_modules/mime-types/index.js
Module not found: Error: Can't resolve 'path' in 'D:\Coding\BitBucket\testiny\node_modules\mime-types'
ERROR in ./node_modules/node-stream-zip/node_stream_zip.js
Module not found: Error: Can't resolve 'path' in 'D:\Coding\BitBucket\testiny\node_modules\node-stream-zip'
ERROR in ./node_modules/assert-plus/assert.js
Module not found: Error: Can't resolve 'stream' in 'D:\Coding\BitBucket\testiny\node_modules\assert-plus'
ERROR in ./node_modules/combined-stream/lib/combined_stream.js
Module not found: Error: Can't resolve 'stream' in 'D:\Coding\BitBucket\testiny\node_modules\combined-stream\lib'
ERROR in ./node_modules/delayed-stream/lib/delayed_stream.js
Module not found: Error: Can't resolve 'stream' in 'D:\Coding\BitBucket\testiny\node_modules\delayed-stream\lib'
ERROR in ./node_modules/isstream/isstream.js
Module not found: Error: Can't resolve 'stream' in 'D:\Coding\BitBucket\testiny\node_modules\isstream'
ERROR in ./node_modules/node-stream-zip/node_stream_zip.js
Module not found: Error: Can't resolve 'stream' in 'D:\Coding\BitBucket\testiny\node_modules\node-stream-zip'
ERROR in ./node_modules/request/request.js
Module not found: Error: Can't resolve 'stream' in 'D:\Coding\BitBucket\testiny\node_modules\request'
ERROR in ./node_modules/sshpk/lib/ed-compat.js
Module not found: Error: Can't resolve 'stream' in 'D:\Coding\BitBucket\testiny\node_modules\sshpk\lib'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'D:\Coding\BitBucket\testiny\node_modules\forever-agent'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'D:\Coding\BitBucket\testiny\node_modules\tunnel-agent'
ERROR in ./node_modules/node-stream-zip/node_stream_zip.js
Module not found: Error: Can't resolve 'zlib' in 'D:\Coding\BitBucket\testiny\node_modules\node-stream-zip'
ERROR in ./node_modules/request/request.js
Module not found: Error: Can't resolve 'zlib' in 'D:\Coding\BitBucket\testiny\node_modules\request'
i 「wdm」: Failed to compile.

ERROR in src/app/app.component.ts(3,1): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try npm i @types/node.
src/app/app.component.ts(4,19): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try npm i @types/node.`

Now if I'm putting it in the wrong place, let me know. I'm pretty new at this. And yes, I do have an API key.

Any help would be very appreciated.

Some enums updated

Some of the enums have updated with the new release of the OpenAPI spec files.

For example the ActivityModeType now includes Raid and TrialsOfTheNine; however, these updates are not reflected in enums.ts.

TypeError: Right-hand side of 'instanceof' is not an object

Question

Your Environment

| Software | Version(s) |
| OSX | Catalina |
| the-traveler -> 1.0.1 |
| Node 13 |
| Operating System |
OSX

Question

Hey, not sure if this is bug, or i have somethign wrong in my code. But iam getting this error when i am calling getAccessToken()

TypeError: Right-hand side of 'instanceof' is not an object at normalize (normalize-arguments.js:153) at got (create.js:32) at Function.got.<computed> [as post] (create.js:64) at HttpService.js:44 at new Promise (<anonymous>) at HTTPService.post (HttpService.js:43) at OAuthResource.js:87 at new Promise (<anonymous>) at OAuthResource.getAccessToken (OAuthResource.js:86) at Module../src/components/Auth/OAuthReturn.js (OAuthReturn.js:13) at __webpack_require__ (bootstrap:785) at fn (bootstrap:150) at Module../src/index.js (index.css?e32c:37) at __webpack_require__ (bootstrap:785) at fn (bootstrap:150) at Object.1 (travelerClient.js:10) at __webpack_require__ (bootstrap:785) at checkDeferredModules (bootstrap:45) at Array.webpackJsonpCallback [as push] (bootstrap:32) at main.chunk.js:1

Context

Iam trying just authorize my account on bungie. Iam used "create-react-app"to boostrap the basic project and then just import traveler..

I also can provide whole git with this project in case if it will be needed

Manifest Issue

Can download the manifest fine, but then when I then try to download the manifest again I get

Error: EPERM: operation not permitted, open 'mylongfilepath\world_sql_content_d122ea6e6d07e448d34868985f7a9cb9.content.zip'

IDestinyCharacterComponent#emblemBackgroundPath is misspelled

Bug Report

Your Environment

Software Version(s)
the-traveler 0.7.2
Node 8.9.0
Operating System Windows 10

Expected Behavior

The property emblemBackgroundPath of IDestinyCharacterComponent should be spelled correctly.

Current Behavior

The property emblemBackgroundPath is currently spelled emplemBackgroundPath.

Code Sample

N/A

Importing enums?

The docs say:

If you want to use this package inside a ES5 project you can import it like so:

var Traveler = require('the-traveler').default;
const Enums = require('the-traveler/build/enums')

const traveler = new Traveler({
    apikey: 'yourAPIkey',
    userAgent: 'yourUserAgent' //used to identify your request to the API
});

//Access the enums (example componentType profiles)
var profilesType = Enums.ComponentType.Profiles;

But at least when I npm install the-traveler, my node_modules/the-traveler/build directory does not contains any "enums".

Finish tests

Finish writing tests for each method of Traveler.ts and HTTPService.ts.

Why does the-traveler require you to set the oAuth token instead of taking it as a parameter when oAuth API calls are made?

Question

Your Environment

Software Version(s)
the-traveler 0.7.4
Node 8.9.1
Operating System Ubuntu Server 16.04 LTS

Question

Do you create a new traveler instance for each connected client?

I am, because you have to set traveler_instance.oauth to the oAuth token that you get from Bungie. Wouldn't it make more sense to pass your oAuth key to any oAuth API calls that you make so that we only need a single instance of the-traveler?

Context

Each one of my websocket clients has their own instance of the-traveler, plus the web-socket server has it's own instance for manafest management. It would be ideal if the-traveler did not rely on having the oAuth token set, but instead took it as a parameter when making oAuth API calls.

Implement OAuth

Implement OAuth to have access to endpoints which require it

Manifest is not a function

Bug Report

Your Environment

Software Version(s)
the-traveler 0.7.4
Node 8.9.1
Operating System Ubuntu Server 16.04 LTS

Expected Behavior

Creating an instance of manifest using the path to the manifest.content file should create an sqlite3 database handle to the manifest database as specified in the documentation

Current Behavior

Process fails with the error
(node:31520) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Manifest is not a constructor

Code Sample

const Manifest = require( 'the-traveler/build/Manifest' );
const manifest = new Manifest( __dirname + '/../destiny-2/manifest.content' );
const queryResult = await manifest.queryManifest( 'SELECT name FROM sqlite_master WHERE type="table"' );
		
console.log( queryResult );

Other Notes

due to issue #39 I manually unzipped the manifest, renamed it manifest.content, and placed it in the appropriate directory.

API-Key not sending.

I'm trying to write a basic script to use getProfile to return my Destiny profile data. Here's my code.

const traveler = require('the-traveler'); const d2 = new traveler.default({ apikey: '67b5059f0dd947928a6af***********', userAgent: "Agent-Name", debug:true }) d2.destiny2.getProfile(3,"[My Destiny ID]",[100]).then(res => { console.log(res); })

It's spitting out this error.

{"ErrorCode":2102,"ThrottleSeconds":0,"ErrorStatus":"ApiKeyMissingFromRequest","Message":"Please add valid X-API-Key header to request. Visit https://www.bungie.net/developer for details.","MessageData":{}}

Any help is welcome.

Manifest JSON

Bungie-net/api#785

The manifest now comes in a JSON format, tried to get this working but guessing it's only currently supported with .ZIP to extract the .content file.

Maybe needs to have two different ways of handling it depending on the file type, so both work 👍

Error with getAccessToken()

Bug Report

Your Environment

Software Version(s)
the-traveler 1.0.1
Node 10.16.0
Operating System Windows 10

Expected Behavior

obtain the OAuth Access token with the getAccessToken() method

Current Behavior

image

Code Sample

Using the sample given in the documentation
traveler.oauth.getAccessToken(hereComesTheCode).then(oauth => { // Provide your traveler object with the oauth object. This is later used for making authenticated calls traveler.oauth = oauth; }).catch(err => { console.log(err) })

Just changed hereComesTheCode to my own variable which has the code stored.

Implement POST methods

Implement the following POST mehtods:

  • Destiny2.TransferItem

  • Destiny2.EquipItem

  • Destiny2.EquipItems

  • Destiny2.SetItemLockState 

  • Destiny2.InsertSocketPlug  (implemented but not released from API side)

  • Destiny2.ActivateTalentNode (implemented but not released from API side)

  • Add OAuth to methods which require it

Fails to unzip manifest file

Bug Report

Your Environment

Software Version(s)
the-traveler 0.7.4
Node 8.9.1
Operating System Ubuntu Server 16.04 LTS

Expected Behavior

Expected the downloadManifest method to unzip the manifest file in the directory specified as stated in the documentation

Current Behavior

an error results stating the unzipping the file failed.

(node:28670) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error extracting zip
(node:28670) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Code Sample

const result = await self.Destiny2.Api.getDestinyManifest();
const filepath = await self.Destiny2.Api.downloadManifest(result.Response.mobileWorldContentPaths.en, '../destiny-2/manifest.content' );
const manifest = new Manifest( filepath );
const queryResult = await manifest.queryManifest( 'SELECT name FROM sqlite_master WHERE type="table"' );
		
console.log( queryResult );

Delete Manifest ZIP when Finished

Suggestion: Can you make it delete the world_sql_content_version.content.zip after manifest.content has been made/updated? Would help clean up 👍

Adapt v2.1.2

Implement new features mentioned in the changelog of the API

  • Check new docs
  • Add new endpoints (some endpoints seem not be accessible due not achievable scopes)
  • Add interfaces and enums
  • Change existing endpoints to reflect changes
  • Test everything

es6-promise is listed as a dev-dependency but should be a regular dependency

Attempting to use the-traveler without es6-promise results in

'Error: Cannot find module 'es6-promise'
Call stack places the error at HttpService.js:3:1 and from looking at HttpService.ts there's an import for 'es6-promise'

I'm not entirely familiar with your project so I can't tell if the package.json should be updated so that it is no longer listed as a devdependency or if it is being included unnecessarily.

Destiny2.ReportOffensivePostGameCarnageReportPlayer

I saw your recent update and I wanted to give you a heads up on the ReportOffensivePostGameCarnageReportPlayer endpoint.

In the docs it lists the OAuth scope needed as BnetWrite. Our Applications can't get this scope so I created an Issue to ask about it.

Bungie-net/api#332

Basically we can't use this endpoint. Details in the issue linked above.

Are all endpoints wrapped?

Question

Your Environment

Software Version(s)
the-traveler 0.7.4
Node 8.9.1
Operating System Ubuntu server 16.04 LTS

Question

Is there a method to getMembershipDataById? It seems like several endpoints are not yet implemented

Context

I play on PC and using the searchDestinyPlayer( Enums.BungieMembershipType.All ) does not return my PC account, only my XBox account. This is evidently by design, as I'm not the only one who has noticed this behavior in the destiny 2 api. Even using Enums.BungieMembershipType.PC returns an empty array. I have read that using the getMembershipDataById endpoint will pull the PC account info.

Broken enums?

I'm poking at the enums for the first time and I currently have:

const Enums = require('the-traveler/build/type-definitions');
console.log(Enums);

and the output is:

{
  "App": {},
  "User": {},
  "Content": {},
  "Forum": {},
  "GroupV2": {},
  "Destiny2": {},
  "CommunityContent": {},
  "Trending": {},
  "Fireteam": {}
}

Naturally that seems wrong, so I dug into the package and it looks like there are interfaces.d.ts files (https://github.com/alexanderwe/the-traveler/blob/master/src/type-definitions/destiny2/interfaces.ts for example) that are full of definitions sitting next to empty interfaces.js files, which are the ones that actually get used. These are meant to be the generated files right? I'm not familiar with TypeScript but this is wrong yeah?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.