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

the-traveler

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

the-traveler - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0

build/Manifest.d.ts

3

build/HttpService.js

@@ -20,3 +20,2 @@ "use strict";

options.method = 'GET';
options.json = true;
if (this.debug) {

@@ -35,3 +34,3 @@ console.log('\x1b[33m%s\x1b[0m', 'Debug url:' + options.uri);

else {
resolve(JSON.parse(JSON.stringify(response)));
resolve(response);
}

@@ -38,0 +37,0 @@ })

@@ -466,3 +466,5 @@ import { BungieMembershipType, ComponentPrivacySetting, ComponentType, DamageType, DestinyActivityDifficultyTier, DestinyActivityModeType, DestinyClass, DestinyGameVersion, DestinyGender, DestinyRace, DestinyStatsGroupType, DestinyTalentNodeState, EquipFailureReason, ItemBindStatus, ItemLocation, ItemState, PeriodType, PlatformErrorCodes, StatsCategoryType, TransferStatus, UnitType, VendorItemRefundPolicy, VendorItemStatus } from './enums';

mobileGearAssetDataBases: IGearAssetDataBaseDefinition[];
mobileWorldContentPaths: object;
mobileWorldContentPaths: {
[key: string]: string;
};
mobileClanBannerDatabasePath: string;

@@ -651,45 +653,2 @@ mobileGearCDN: object;

/**
* Interface for the response of getMembershipDataByCurrentUser
* @interface
*/
export interface IUserMembershipData {
destinyMemberships: IUserInfoCard[];
bungieNetUser: IGeneralUser;
}
/**
* Interface for Bungie.net user info
* @interface
*/
export interface IGeneralUser {
membershipId: String;
uniqueName: String;
normalizedName: String;
displayName: String;
profilePicture: String;
profileTheme: String;
userTitle: String;
successMessageFlags: String;
isDeleted: Boolean;
about: String;
firstAccess?: String;
lastUpdate?: Date;
legacyPortalUID?: String;
psnDisplayName: String;
xboxDisplayName: String;
fbDisplayName: String;
showActivity?: Boolean;
locale: String;
localeInheritDefault: Boolean;
lastBanReportId?: String;
showGroupMessaging: Boolean;
profilePicturePath: String;
profilePictureWidePath: String;
profileThemeName: String;
userTitleDisplay: String;
statusText: String;
statusDate: Date;
profileBanExpire?: Date;
blizzardDisplayName: String;
}
/**
* Interface for a single character progress component

@@ -872,2 +831,37 @@ * @interface

/**
* Interface for Bungie.net user info
* @interface
*/
export interface IGeneralUser {
membershipId: string;
uniqueName: string;
normalizedName: string;
displayName: string;
profilePicture: string;
profileTheme: string;
userTitle: string;
successMessageFlags: string;
isDeleted: boolean;
about: string;
firstAccess?: string;
lastUpdate?: Date;
legacyPortalUID?: string;
psnDisplayName: string;
xboxDisplayName: string;
fbDisplayName: string;
showActivity?: boolean;
locale: string;
localeInheritDefault: boolean;
lastBanReportId?: string;
showGroupMessaging: boolean;
profilePicturePath: string;
profilePictureWidePath: string;
profileThemeName: string;
userTitleDisplay: string;
statusText: string;
statusDate: Date;
profileBanExpire?: Date;
blizzardDisplayName: string;
}
/**
* Interface for defining an object for the OAuth process

@@ -942,1 +936,9 @@ * @interface

}
/**
* Interface for the response of getMembershipDataByCurrentUser
* @interface
*/
export interface IUserMembershipData {
destinyMemberships: IUserInfoCard[];
bungieNetUser: IGeneralUser;
}

@@ -415,2 +415,10 @@ import { BungieMembershipType, TypeDefinition } from './enums';

/**
* Download the specified manifest file
* @async
* @param manifestUrl The url of the manifest you want to download
* @param filename The filename of the final unzipped file. This is used for the constructor of [[Manifest]]
* @return {Promise.string} When fulfilled returns the path of the saved manifest file
*/
downloadManifest(manifestUrl: string, filename?: string): Promise<string>;
/**
* Generates the query string parameters out of the specified object which contains the parameters

@@ -417,0 +425,0 @@ * @async

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var SZIP = require("node-stream-zip");
var querystring = require("querystring");
var request = require("request");
var HttpService_1 = require("./HttpService");

@@ -947,2 +950,37 @@ var OAuthError_1 = require("./OAuthError");

/**
* Download the specified manifest file
* @async
* @param manifestUrl The url of the manifest you want to download
* @param filename The filename of the final unzipped file. This is used for the constructor of [[Manifest]]
* @return {Promise.string} When fulfilled returns the path of the saved manifest file
*/
Traveler.prototype.downloadManifest = function (manifestUrl, filename) {
var _this = this;
this.options.uri = "https://www.bungie.net/" + manifestUrl;
var outStream = fs.createWriteStream(manifestUrl.substring(manifestUrl.lastIndexOf('/') + 1) + ".zip");
return new Promise(function (resolve, reject) {
request(_this.options)
.on('response', function (res, body) {
// do nothing
}).pipe(outStream)
.on('finish', function () {
var zip = new SZIP({
file: manifestUrl.substring(manifestUrl.lastIndexOf('/') + 1) + ".zip",
storeEntries: true,
});
var fileName = manifestUrl.substring(manifestUrl.lastIndexOf('/') + 1);
zip.on('ready', function () {
zip.extract(manifestUrl.substring(manifestUrl.lastIndexOf('/') + 1), filename, function (err, count) {
if (err) {
reject(new Error('Error extracting zip'));
}
else {
resolve(filename);
}
});
});
});
});
};
/**
* Generates the query string parameters out of the specified object which contains the parameters

@@ -949,0 +987,0 @@ * @async

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

@@ -35,3 +35,4 @@ "keywords": [

"es6-promise": "^4.1.1",
"request": "^2.81.0",
"node-stream-zip": "^1.3.7",
"request": "^2.83.0",
"request-promise-native": "^1.0.4"

@@ -43,2 +44,3 @@ },

"@types/mocha": "^2.2.43",
"@types/sqlite3": "^3.1.1",
"babel-cli": "^6.26.0",

@@ -62,3 +64,6 @@ "babel-core": "^6.26.0",

"typescript": "^2.5.2"
},
"peerDependencies": {
"sqlite3": "^3.1.13"
}
}
# the-traveler
[![npm](https://img.shields.io/npm/v/the-traveler.svg)](https://www.npmjs.com/package/the-traveler)
[![npm](https://img.shields.io/npm/dt/the-traveler.svg)](https://www.npmjs.com/package/the-traveler)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/alexanderwe/the-traveler/blob/master/LICENSE.md)
[![GitHub issues](https://img.shields.io/github/issues/alexanderwe/the-traveler.svg)](https://github.com/alexanderwe/the-traveler/issues)
[![Build Status](https://travis-ci.org/alexanderwe/the-traveler.svg?branch=master)](https://travis-ci.org/alexanderwe/the-traveler)
[![codecov](https://codecov.io/gh/alexanderwe/the-traveler/branch/master/graph/badge.svg)](https://codecov.io/gh/alexanderwe/the-traveler)
[![dependencies Status](https://david-dm.org/alexanderwe/the-traveler/status.svg)](https://david-dm.org/alexanderwe/the-traveler)
[![Known Vulnerabilities](https://snyk.io/test/github/alexanderwe/the-traveler/badge.svg)](https://snyk.io/test/github/alexanderwe/the-traveler/badge.svg)

@@ -20,3 +20,3 @@ the-traveler is a small npm package which wraps around the Destiny 2 API. It uses Promises for a modern workflow in your application.

* [Notices](#notices)
* [Typescript Support](#typescript-support)
* [Typescript Support](#typescript-support)
* [Typical Response](#typical-response)

@@ -30,2 +30,3 @@ * [Privacy](#privacy)

* [Async await approach (pseudo-code)](#async-await-approach-pseudo-code)
* [Manifest](#manifest)
* [Progress](#progress)

@@ -40,2 +41,3 @@ * [Built With](#built-with)

## Getting Started

@@ -341,2 +343,47 @@

### Manifest
To use the manifest you first have to download it via 'traveler.downloadManifest(manifestUrl, filename)'. **Be aware that you have to install [node-sqlite3](https://github.com/mapbox/node-sqlite3) to use the manifest class**
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_
```
import Traveler from 'the-traveler';
import Manifest from 'the-traveler/build/Manifest'
traveler.getDestinyManifest().then(result => {
traveler.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content').then(filepath => {
const manifest = new Manifest(filepath);
manifest.queryManifest('SELECT name FROM sqlite_master WHERE type="table"').then(queryResult => {
console.log(queryResult);
}).catch(err => {
console.log(err);
});
}).catch(err => {
console.log(err);
})
})
```
_async way_
```
import Traveler from 'the-traveler';
import Manifest from 'the-traveler/build/Manifest'
async ()=> {
const result = await traveler.getDestinyManifest();
const filepath = await traveler.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content');
const manifest = new Manifest(filepath);
const queryResult = await manifest.queryManifest('SELECT name FROM sqlite_master WHERE type="table"')
}
```
## Progress

@@ -381,2 +428,4 @@

* [Typescript](https://github.com/Microsoft/TypeScript) - Programming Language
* [node-stream-zip](https://github.com/antelle/node-stream-zip) - Unzipping files in node (for Manifest interaction)
* [node-sqlite3](https://github.com/mapbox/node-sqlite3) - Use sqlite 3 in node (for Manifest interaction as a peer dependency)

@@ -383,0 +432,0 @@ ## Versioning

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc