Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

the-traveler

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

the-traveler - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

@@ -22,2 +22,3 @@ /**

ProfileCurrencies = 103,
ProfileProgression = 104,
Characters = 200,

@@ -41,3 +42,7 @@ CharacterInventories = 201,

VendorSales = 402,
Kiosks = 500
Kiosks = 500,
CurrencyLookups = 600,
PresentationNodes = 700,
Collectibles = 800,
Records = 900
}

@@ -189,2 +194,19 @@ /**

/**
* The possible states of Destiny Profile Records. IMPORTANT: Any given item can theoretically have many of these states simultaneously: as a result, this was altered to be a flags enumeration for v3.2.0.
* @enum
*/
export declare enum DestinyVendorItemState {
None = 0,
Incomplete = 1,
RewardAvailable = 2,
Complete = 4,
New = 8,
Featured = 16,
Ending = 32,
OnSale = 64,
Owned = 128,
WideView = 256,
NexusAttention = 512
}
/**
* Enum for races in Destiny

@@ -274,3 +296,4 @@ * @enum

Locked = 1,
Tracked = 2
Tracked = 2,
Masterwork = 4
}

@@ -329,3 +352,3 @@ export declare enum MergeMethod {

ThrottleLimitExceeded = 31,
ValidationTagError = 31,
ValidationTagError = 32,
ValidationProfanityError = 33,

@@ -829,2 +852,3 @@ ValidationUrlFormatError = 34,

DestinyCharacterLoggedInNotAllowed = 1681,
DestinyPublicAccountNotAccessible = 1682,
FbInvalidRequest = 1800,

@@ -898,2 +922,6 @@ FbRedirectMismatch = 1801,

OfferRequired = 2046,
UnknownEververseHistoryError = 2047,
MissingEververseHistoryError = 2048,
BungieRewardEmailStateInvalid = 2049,
BungieRewardNotYetClaimable = 2050,
ApiExceededMaxKeys = 2100,

@@ -963,3 +991,5 @@ ApiInvalidOrExpiredKey = 2101,

ClanFireteamPublicCreationRestriction = 3022,
ClanFireteamAlreadyJoined = 3023
ClanFireteamAlreadyJoined = 3023,
ClanFireteamScheduledFireteamsRange = 3024,
ClanFireteamPublicCreationRestrictionExtended = 3025
}

@@ -966,0 +996,0 @@ export declare enum SocketResponseCodes {

@@ -1,2 +0,2 @@

import { BungieMembershipType, ComponentPrivacySetting, ComponentType, DamageType, DestinyActivityDifficultyTier, DestinyActivityModeType, DestinyAdvancedAwaResponseReason, DestinyAdvancedAwaType, DestinyAdvancedAwaUserSelection, DestinyClass, DestinyGameVersion, DestinyGender, DestinyRace, DestinyStatsGroupType, DestinyTalentNodeState, EquipFailureReason, ItemBindStatus, ItemLocation, ItemState, PeriodType, PlatformErrorCodes, StatsCategoryType, TransferStatus, UnitType, VendorItemRefundPolicy, VendorItemStatus, MergeMethod } from './enums';
import { BungieMembershipType, ComponentPrivacySetting, ComponentType, DamageType, DestinyActivityDifficultyTier, DestinyActivityModeType, DestinyAdvancedAwaResponseReason, DestinyAdvancedAwaType, DestinyAdvancedAwaUserSelection, DestinyClass, DestinyVendorItemState, DestinyGameVersion, DestinyGender, DestinyRace, DestinyStatsGroupType, DestinyTalentNodeState, EquipFailureReason, ItemBindStatus, ItemLocation, ItemState, PeriodType, PlatformErrorCodes, StatsCategoryType, TransferStatus, UnitType, VendorItemRefundPolicy, VendorItemStatus, MergeMethod } from './enums';
/**

@@ -134,3 +134,3 @@ * Interface for the common API response object

emblemPath: string;
emplemBackgroundPath: string;
emblemBackgroundPath: string;
emblemHash: number;

@@ -371,3 +371,3 @@ levelProgression: IDestinyProgression;

itemHash: number;
itemInstanceId: string;
itemInstanceId: number;
quantity: number;

@@ -403,3 +403,3 @@ bindStatus: ItemBindStatus;

canEquip: boolean;
equiRequiredLevel: number;
equipRequiredLevel: number;
unlockHashesRequiredToEquip: string[];

@@ -413,2 +413,4 @@ cannEquipReason: EquipFailureReason;

objectives: IDestinyObjectiveProgress[];
flavorObject: IDestinyObjectiveProgress;
dateCompleted?: Date;
}

@@ -485,4 +487,7 @@ /**

isEnabled: boolean;
isVisible: boolean;
enableFailIndexes: number[];
reusablePlugHashes: string[];
reusablePlugHashes: number[];
plugObjectives: IDestinyObjectiveProgress[];
reusablePlugs: IDestinyItemPlug[];
}

@@ -653,3 +658,5 @@ export interface IDestinyItemSocketsComponent {

progress?: number;
completionValue: number;
complete: boolean;
visible: boolean;
}

@@ -680,2 +687,10 @@ /**

}
export interface IDestinyItemPlug {
plugItemHash: number;
plugObjectives: IDestinyObjectiveProgress[];
canInsert: boolean;
enabled: boolean;
insertFailIndexes: number[];
enableFailIndexes: number[];
}
/**

@@ -870,12 +885,12 @@ * Interface for the post game carnage report data

vendors?: ISingleComponentResponse<{
[key: string]: IDestinyVendorComponent;
[key: number]: IDestinyVendorComponent;
}>;
categories?: ISingleComponentResponse<{
[key: string]: IDestinyVendorCategoriesComponent;
[key: number]: IDestinyVendorCategoriesComponent;
}>;
sales?: ISingleComponentResponse<{
[key: string]: IDestinyVendorSaleItemComponent;
[key: number]: IDestinyVendorSaleItemSetComponent;
}>;
itemComponents?: ISingleComponentResponse<{
[key: string]: IDestinyItemComponent;
[key: number]: IDestinyItemComponent;
}>;

@@ -898,6 +913,8 @@ currencyLookups: ISingleComponentResponse<IDestinyCurrenciesComponent>;

progression: IDestinyProgression;
vendorLocationIndex: number;
seasonalRank?: number;
}
export interface IDestinyVendorGroup {
vendorGroupHash: string;
vendorHashes: string[];
vendorGroupHash: number;
vendorHashes: number[];
}

@@ -939,10 +956,17 @@ export interface IDestinyVendorGroupComponent {

}
export interface IDestinyVendorSaleItemSetComponent {
saleItems: IDestinyVendorSaleItemComponent[];
}
export interface IDestinyVendorSaleItemComponent {
vendorItemIndex: number;
itemHash: number;
overrideStyleItemHash: number;
quantity: number;
saleStatus: VendorItemStatus;
costs: IDestinyItemQuantity[];
requiredUnlocks: string[];
requiredUnlocks: number[];
unlockStatuses: IDestinyUnlockStatus[];
failureIndexes: number[];
augments: DestinyVendorItemState;
overrideNextRefreshDate: Date;
}

@@ -955,3 +979,3 @@ /**

data: {
[key: string]: IComponent;
[key: number]: IComponent;
};

@@ -958,0 +982,0 @@ privacy: ComponentPrivacySetting;

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

{
"name": "the-traveler",
"version": "0.7.2",
"version": "0.7.3",
"description": "A Node.js API wrapper for the Destiny 2 API",

@@ -24,4 +24,4 @@ "keywords": [

"scripts": {
"start": "babel-node ./src/index.js --presets es2015,stage-2",
"debug": "babel-node ./src/index.js --presets es2015,stage-2",
"start": "babel-node ./src/index.js --presets env",
"debug": "babel-node ./src/index.js --presets env",
"build": "tsc --p tsconfig.json --declaration --target es5",

@@ -35,28 +35,28 @@ "watch": "tsc --watch --p tsconfig.json --declaration --target es5",

"@types/request-promise-native": "^1.0.6",
"es6-promise": "^4.1.1",
"node-stream-zip": "^1.3.7",
"request": "^2.83.0",
"request-promise-native": "^1.0.4"
"request-promise-native": "^1.0.4",
"sqlite3": "^4.0.2"
},
"devDependencies": {
"@types/jest": "^23.1.0",
"@babel/core": "^7.1.0",
"@types/dotenv": "^4.0.3",
"@types/jest": "23.1.0",
"@types/sqlite3": "^3.1.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"codecov": "^2.3.0",
"babel-preset-env": "^1.7.0",
"codecov": "^3.1.0",
"dotenv": "^6.0.0",
"es6-promise": "^4.1.1",
"es6-promise": "^4.2.5",
"es6-shim": "^0.35.3",
"jest": "^23.1.0",
"jest": "23.1.0",
"minami": "^1.2.3",
"source-map-support": "^0.4.18",
"ts-jest": "^22.4.6",
"ts-node": "^6.1.1",
"source-map-support": "^0.5.9",
"ts-jest": "23.1.0",
"ts-node": "^7.0.1",
"tslint": "^5.10.0",
"typedoc": "^0.11.1",
"typedoc": "^0.12.0",
"typedoc-clarity-theme": "^1.1.0",
"typescript": "^2.9.2"
"typescript": "^3.0.3"
},

@@ -63,0 +63,0 @@ "peerDependencies": {

@@ -1,2 +0,3 @@

# the-traveler
# the-traveler
[![npm](https://img.shields.io/npm/v/the-traveler.svg)](https://www.npmjs.com/package/the-traveler)

@@ -11,37 +12,40 @@ [![npm](https://img.shields.io/npm/dt/the-traveler.svg)](https://www.npmjs.com/package/the-traveler)

Table of Contents
=================
## Table of Contents
* [the-traveler](#the-traveler)
* [Table of Contents](#table-of-contents)
* [Getting Started](#getting-started)
* [Prerequisites](#prerequisites)
* [OAuth](#oauth)
* [Notices](#notices)
* [Typescript Support](#typescript-support)
* [Typical Response](#typical-response)
* [Privacy](#privacy)
* [Documentation](#documentation)
* [Examples](#examples)
* [Search for an Destiny Account on PSN](#search-for-an-destiny-account-on-psn)
* [Get a character for an PSN Account](#get-a-character-for-an-psn-account)
* [Transfer item from vault to character (needs OAuth)](#transfer-item-from-vault-to-character-needs-oauth)
* [Async await approach (pseudo-code)](#async-await-approach-pseudo-code)
* [Manifest](#manifest)
* [Progress](#progress)
* [Built With](#built-with)
* [Versioning](#versioning)
* [Issues](#issues)
* [License](#license)
* [Acknowledgments](#acknowledgments)
* [the-traveler](#the-traveler)
* [Table of Contents](#table-of-contents)
* [Getting Started](#getting-started)
* [Prerequisites](#prerequisites)
* [OAuth](#oauth)
* [Notices](#notices)
* [Typescript Support](#typescript-support)
* [Typical Response](#typical-response)
* [Privacy](#privacy)
* [Documentation](#documentation)
* [Examples](#examples)
* [Search for an Destiny Account on PSN](#search-for-an-destiny-account-on-psn)
* [Get a character for an PSN Account](#get-a-character-for-an-psn-account)
* [Transfer item from vault to character (needs OAuth)](#transfer-item-from-vault-to-character-needs-oauth)
* [Async await approach (pseudo-code)](#async-await-approach-pseudo-code)
* [Manifest](#manifest)
* [Progress](#progress)
* [Built With](#built-with)
* [Versioning](#versioning)
* [Issues](#issues)
* [License](#license)
* [Acknowledgments](#acknowledgments)
## Getting Started
### Installation
#### NPM
## Getting Started
```bash
npm install the-traveler
```
#### Yarn
```
npm install the-traveler
# or
```bash
yarn add the-traveler

@@ -56,3 +60,3 @@ ```

```
```js
import Traveler from 'the-traveler';

@@ -69,3 +73,3 @@ import { ComponentType } from 'the-traveler/build/enums';

```
```js
var Traveler = require('the-traveler').default;

@@ -84,8 +88,9 @@ const Enums = require('the-traveler/build/enums')

_If you want to show the URLs the API wrapper is requesting, just add `debug: true` to the configuration array when instantiate a `Traveler` object_
```
*If you want to show the URLs the API wrapper is requesting, just add `debug: true` to the configuration array when instantiate a `Traveler` object*
```js
const traveler = new Traveler({
apikey: 'pasteYourAPIkey',
userAgent: 'yourUserAgent', //used to identify your request to the API
debug: true
debug: true
});

@@ -98,3 +103,3 @@ ```

```
```js
import Traveler from 'the-traveler';

@@ -110,11 +115,9 @@

Please ensure that you specified a `redirectURL` in your application settings on [https://www.bungie.net/en/Application](https://www.bungie.net/en/Application).
After you have done that, you can generate the authentication URL which has to be visited by your users to approve your application. The URL is constructed with the following schema: `https://www.bungie.net/en/OAuth/Authorize?client_id={yourClientID}&response_type=code`.
After you have done that, you can generate the authentication URL which has to be visited by your users to approve your application. The URL is constructed with the following schema: `https://www.bungie.net/en/OAuth/Authorize?client_id={yourClientID}&response_type=code`.
```
```js
const authUrl = traveler.generateOAuthURL(); // The URL your users have to visit to give your application access
```
If a user visit this site and approve your application he/she will be redirected to the `redirectURL` you specified. This URL is expaned with query parameter called `code`: `https://www.example.com/?code=hereComesTheCode`

@@ -124,6 +127,6 @@

```
```js
traveler.getAccessToken(hereComesTheCode).then(oauth => {
// Provide your traveler object with the oauth object. This is later used for making authenticated calls
traveler.oauth = oauth;
traveler.oauth = oauth;
}).catch(err => {

@@ -136,9 +139,9 @@ console.log(err)

_Response_:
_Response_:
```
```js
{ access_token: '',
token_type: 'Bearer',
expires_in: 3600,
membership_id: ''}
membership_id: '' }
```

@@ -149,16 +152,18 @@

_Response_:
```
```js
{ access_token: '',
token_type: 'Bearer',
expires_in: 3600,
refresh_token: ',
refresh_token: '',
refresh_expires_in: 7776000,
membership_id: '' }
```
```
_Use refresh_:
```
```js
traveler.refreshToken(traveler.oauth.refresh_token).then(oauth => { // take the refresh token from the oauth object you provided when initialize the oauth to the traveler
// Provide your traveler object with the oauth object. This is later used for making authenticated calls
traveler.oauth = oauth;
traveler.oauth = oauth;
}).catch(err => {

@@ -168,2 +173,3 @@ console.log(err)

```
So the refresh procedure has to be initiated manually, there is no automatic refresh implemented.

@@ -180,3 +186,3 @@

* After the oauth object is set on the traveler object you can query the endpoints which require authentiation
* You can try to use this approach with `async` and `await` to overcome the `callback hell`, see [Async await approach (pseudo-code)](#async-await-approach-pseudo-code)
* You can try to use this approach with `async` and `await` to overcome the `callback hell`, see [Async await approach (pseudo-code)](#async-await-approach-pseudo-code)
* Keep in mind that it would be very useful to store the tokens for your users _**securely**_!

@@ -186,11 +192,8 @@

### Typescript Support
The npm package comes with `d.ts` files to allow autocompletion and type checking if you are using `the-traveler` within Typescript.
The npm package comes with `d.ts` files to allow autocompletion and type checking if you are using `the-traveler` within Typescript.
![TypeScript example](https://raw.githubusercontent.com/alexanderwe/the-traveler/master/output.gif)
![](https://raw.githubusercontent.com/alexanderwe/the-traveler/master/output.gif)
There are some other noteworthy information which could help to resolve some issues with the Destiny 2 API.

@@ -200,5 +203,5 @@

The response object from the API is always constructed like the following snippet indicates. The `Response` will contain the actual request data, while `ErrorCode`, `ThrottleSeconds`, `ErrorStatus`, `Message` and `MessageData` will hold additional data about the sucess of our request.
The response object from the API is always constructed like the following snippet indicates. The `Response` will contain the actual request data, while `ErrorCode`, `ThrottleSeconds`, `ErrorStatus`, `Message` and `MessageData` will hold additional data about the sucess of our request.
```
```js
{ Response: Array or Object,

@@ -211,2 +214,3 @@ ErrorCode: 1,

```
### Privacy

@@ -225,3 +229,2 @@

## Examples

@@ -232,3 +235,4 @@

_Query:_
```
```js
traveler

@@ -243,4 +247,5 @@ .searchDestinyPlayer('2', 'playername')

_Response_
```
_Response:_
```js
{ Response:

@@ -262,5 +267,6 @@ [ { iconPath: '/img/theme/destiny/icons/icon_psn.png',

_Query:_
```
```js
import Traveler from 'the-traveler';
import {ComponentType} from 'the-traveler/build/enums'
import {ComponentType} from 'the-traveler/build/enums'

@@ -297,4 +303,6 @@ const traveler = new Traveler({

```
_Response (First level):_
```
```js
{ Response:

@@ -315,3 +323,2 @@ { inventory: { privacy: 2 },

### Transfer item from vault to character (needs OAuth)

@@ -321,3 +328,3 @@

```
```js
traveler

@@ -344,3 +351,3 @@ .transferItem({

```
```js
async () => {

@@ -355,3 +362,3 @@ const traveler = new Traveler({

traveler.oauth = await traveler.getAccessToken(accessCode);
// OR
// OR
traveler.oauth = await traveler.refreshToken(refreshToken);

@@ -368,9 +375,10 @@

The `manifestUrl` can be every URL contained in the response of `traveler.getManifest()`
This method will download the specified manifest, unzip it and save it as `filename`. Afterwards you are able to create a new instance of the `Manifest` class. With this it is possible to query the saved file with valid sqlite queries. A good hint for querying is noted in the [Gist](https://gist.github.com/vpzed/efb7b29f5dfda49633d62801ac30566c) from [@vpzed](https://github.com/vpzed). The result is retrieved asynchronously which makes it possible to integrate it with the `async` `await` flow.
_common way_
```
This method will download the specified manifest, unzip it and save it as `filename`. Afterwards you are able to create a new instance of the `Manifest` class. With this it is possible to query the saved file with valid sqlite queries. A good hint for querying is noted in the [Gist](https://gist.github.com/vpzed/efb7b29f5dfda49633d62801ac30566c) from [@vpzed](https://github.com/vpzed). The result is retrieved asynchronously which makes it possible to integrate it with the `async` `await` flow.
_common way:_
```js
import Traveler from 'the-traveler';
import Manifest from 'the-traveler/build/Manifest'
import Manifest from 'the-traveler/build/Manifest'

@@ -394,7 +402,7 @@

*async way:*
_async way_
```
```js
import Traveler from 'the-traveler';
import Manifest from 'the-traveler/build/Manifest'
import Manifest from 'the-traveler/build/Manifest'

@@ -409,3 +417,2 @@ async ()=> {

## Progress

@@ -416,3 +423,3 @@

| Endpoint | Implemented | Unlocked in API |
| --------------------------------------------------- | ----------- | -------------------- |
|-----------------------------------------------------|-------------|----------------------|
| Destiny2.GetDestinyManifest | ✅ | ✅ |

@@ -455,14 +462,12 @@ | Destiny2.GetDestinyEntityDefinition | ✅ | ✅ |

* [node-stream-zip](https://github.com/antelle/node-stream-zip) - Unzipping files in node (for Manifest interaction) _Note: Maybe this will end up in a peer depdendency in a future release since it adds overhead to the package if you do not want to use the Manifest flow_
* [node-sqlite3](https://github.com/mapbox/node-sqlite3) - Use sqlite 3 in node (for Manifest interaction as a peer dependency)
* [node-sqlite3](https://github.com/mapbox/node-sqlite3) - Use sqlite 3 in node (for Manifest interaction as a peer dependency)
## Versioning
the-traveler uses [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/alexanderwe/the-traveler/tags).
the-traveler uses [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/alexanderwe/the-traveler/tags).
## Issues
Do you have any issues or recommendations for this package ? Feel free to open an issue in the [issue section](https://github.com/alexanderwe/the-traveler/issues) :)
Do you have any issues or recommendations for this package ? Feel free to open an issue in the [issue section](https://github.com/alexanderwe/the-traveler/issues) :)
## License

@@ -476,6 +481,5 @@

[yes]: https://img.shields.io/badge/implemented-yes-green.svg "Implemented:yes"
[no]: https://img.shields.io/badge/implemented-no-red.svg "Implemented:no"
[preview]: https://img.shields.io/badge/-preview-blue.svg "Preview"
[unlocked]: https://img.shields.io/badge/-unlocked-green.svg "Unlocked"
[unlocked]: https://img.shields.io/badge/-unlocked-green.svg "Unlocked"

Sorry, the diff of this file is too big to display