New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.7.4 to 1.0.0

build/Logger.d.ts

25

build/HttpService.d.ts

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

import * as rp from 'request-promise-native';
import * as got from 'got';
/**

@@ -7,17 +7,14 @@ * Wrapper class for the request package. Used to make HTTP calls.

private debug?;
constructor(debug?: boolean);
private options;
constructor(options: got.GotJSONOptions, debug?: boolean);
/**
* Base function for GET requests
* @async
* @param options Options for the request package to use
* @return {Promise.any} When fulfilled returns an object containing the response from the request
* Base method for GET requests
*
* @param {string} url Url to GET from
* @param {string} [authenticationToken] optional authentication token
* @returns {Promise<object>}
* @memberof HTTPService
*/
get(options: rp.OptionsWithUri): Promise<object>;
/**
* Base function for POST requests
* @async
* @param options Options for the request package to use
* @return {Promise.any} When fulfilled returns an object containing the response from the request
*/
post(options: rp.OptionsWithUri): Promise<object>;
get(url: string, authenticationToken?: string): Promise<object>;
post(url: string, data: got.GotJSONOptions): Promise<object>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rp = require("request-promise-native");
var got = require("got");
var Logger_1 = require("./Logger");
/**

@@ -8,29 +9,26 @@ * Wrapper class for the request package. Used to make HTTP calls.

var HTTPService = /** @class */ (function () {
function HTTPService(debug) {
function HTTPService(options, debug) {
this.debug = debug;
this.options = options;
}
/**
* Base function for GET requests
* @async
* @param options Options for the request package to use
* @return {Promise.any} When fulfilled returns an object containing the response from the request
* Base method for GET requests
*
* @param {string} url Url to GET from
* @param {string} [authenticationToken] optional authentication token
* @returns {Promise<object>}
* @memberof HTTPService
*/
HTTPService.prototype.get = function (options) {
options.method = 'GET';
HTTPService.prototype.get = function (url, authenticationToken) {
var _this = this;
if (this.debug) {
console.log('\x1b[33m%s\x1b[0m', 'Debug url:' + options.uri);
Logger_1.default.debug("GET - " + url + (authenticationToken ? ' - OAUTH request' : ''));
}
//Deep copy
var authOptions = JSON.parse(JSON.stringify(this.options));
authOptions.headers['Authorization'] = "Bearer " + authenticationToken;
return new Promise(function (resolve, reject) {
rp(options)
got(url, authenticationToken ? authOptions : _this.options)
.then(function (response) {
if (response.access_token) {
// this is a oauth reponse
resolve(response);
}
else if (response.ErrorCode !== 1) {
reject(response);
}
else {
resolve(response);
}
resolve(response.body);
})

@@ -42,24 +40,11 @@ .catch(function (err) {

};
/**
* Base function for POST requests
* @async
* @param options Options for the request package to use
* @return {Promise.any} When fulfilled returns an object containing the response from the request
*/
HTTPService.prototype.post = function (options) {
options.method = 'POST';
HTTPService.prototype.post = function (url, data) {
if (this.debug) {
console.log('\x1b[33m%s\x1b[0m', 'Debug url:' + options.uri);
Logger_1.default.debug("POST - " + url);
}
return new Promise(function (resolve, reject) {
rp(options)
got
.post(url, data)
.then(function (response) {
if (response.access_token) {
// this is a oauth reponse
resolve(response);
}
else if (response.ErrorCode !== 1) {
reject(response);
}
resolve(response);
resolve(response.body);
})

@@ -66,0 +51,0 @@ .catch(function (err) {

@@ -1,3 +0,6 @@

import { BungieMembershipType, SocketResponseCodes, TypeDefinition } from './enums';
import { IAPIResponse, IConfig, IDestinyActivityHistoryResults, IDestinyAggregateActivityResults, IDestinyCharacterResponse, IDestinyClanAggregateStat, IDestinyCollectibleNodeDetailResponse, IDestinyDefinition, IDestinyEntitySearchResult, IDestinyEquipItemResults, IGlobalAlert, IDestinyHistoricalStatsAccountResult, IDestinyHistoricalStatsByPeriod, IDestinyHistoricalStatsDefinition, IDestinyHistoricalWeaponStatsData, IDestinyItemActionRequest, IDestinyItemResponse, IDestinyItemSetActionRequest, IDestinyItemStateRequest, IDestinyItemTransferRequest, IDestinyLinkedProfilesResponse, IDestinyManifest, IDestinyMilestone, IDestinyMilestoneContent, IDestinyPostGameCarnageReportData, IDestinyPostMasterTransferRequest, IDestinyProfileResponse, IDestinyPublicMilestone, IDestinyVendorResponse, IDestinyVendorsResponse, IOAuthResponse, IQueryStringParameters, IUserInfoCard, IUserMembershipData } from './interfaces';
import GlobalResource from './resources/GlobalResource';
import Destiny2Resource from './resources/Destiny2Resource';
import UserResource from './resources/UserResource';
import { ITravelerConfig } from './type-definitions/additions';
import OAuthResource from './resources/OAuthResource';
/**

@@ -9,497 +12,8 @@ * Entry class for accessing the Destiny 2 API

private userAgent;
private oauthConfig;
private _oauth;
private apibaseDestiny2;
private apibaseUser;
private apibase;
private httpService;
private options;
private oauthOptions;
constructor(config: IConfig);
/**
* Gets any active global alert for display in the forum banners, help pages, etc. Usually used for DOC alerts.
* @async
* @return {Promise.IAPIResponse<IDestinyManifest>} When fulfilled returns an object containing the current Global Alerts
*/
getGlobalAlerts(): Promise<IAPIResponse<IGlobalAlert[]>>;
/**
* Gets the current manifest in a JSON document
* @async
* @return {Promise.IAPIResponse<IDestinyManifest>} When fulfilled returns an object containing the current Destiny 2 manifest
*/
getDestinyManifest(): Promise<IAPIResponse<IDestinyManifest>>;
/**
* Returns the static definition of an entity of the given Type and hash identifier. Examine the API Documentation for the Type Names of entities that have their own definitions.
* Note that the return type will always *inherit from* DestinyDefinition, but the specific type returned will be the requested entity type if it can be found.
* Please don't use this as a chatty alternative to the Manifest database if you require large sets of data, but for simple and one-off accesses this should be handy.
* @param entityType
* @param hashIdentifier
* @return {Promise.IAPIResponse<IDestinyDefinition>} When fulfilled returns an object containing the static definition of an entity.
*/
getDestinyEntityDefinition(typeDefinition: TypeDefinition, hashIdentifier: string): Promise<IAPIResponse<IDestinyDefinition>>;
/**
* Search for a Destiny 2 player by name
* @async
* @param displayName The full gamertag or PSN id of the player. Spaces and case are ignored
* @param membershipType A valid non-BungieNet membership type, or All <ul>
* <li>-1: ALL</li>
* <li>1: Xbox</li>
* <li>2: PSN</li>
* <li>4: PC (Blizzard)</li>
* <li>254: Bungie</li>
* </ul>
* Keep in mind that `-1` or `MembershipType.All` is only applicable on this endpoint.
* @return {Promise.IAPIResponse<IUserInfoCard[]>} When fulfilled returns an object containing information about the found user
*/
searchDestinyPlayer(membershipType: BungieMembershipType, displayName: string): Promise<IAPIResponse<IUserInfoCard[]>>;
/**
* Returns a summary information about all profiles linked to the requesting membership type/membership ID that have valid Destiny information.
* The passed-in Membership Type/Membership ID may be a Bungie.Net membership or a Destiny membership.
* It only returns the minimal amount of data to begin making more substantive requests, but will hopefully serve as a useful alternative to UserServices for people who just care about Destiny data.
* Note that it will only return linked accounts whose linkages you are allowed to view.
* @async
* @param membershipType
* @param destinyMembershipId
*/
getLinkedProfiles(membershipType: BungieMembershipType, destinyMembershipId: string): Promise<IAPIResponse<IDestinyLinkedProfilesResponse>>;
/**
* Retrieve information about the Destiny Profile
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint..
* @param destinyMembershipId The Destiny ID (Account ID)
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>components: See {@link https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType|DestinyComponentType} for the different enum types.</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyProfileResponse>} When fulfilled returns an object containing information about the user profile
*/
getProfile(membershipType: BungieMembershipType, destinyMembershipId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyProfileResponse>>;
/**
* Retrieve information about the Bungie.net profile of the currently authenticated user
* @async
* @return {Promise.IAPIResponse<IUserMembershipData>} When fulfilled returns an object containing information about the membership data of the current logged in user.
*/
getMembershipDataForCurrentUser(): Promise<IAPIResponse<IUserMembershipData>>;
/**
* Retrieve aggregrated details about a Destiny Characters
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param characterId ID of the character
* @param destinyMembershipId The Destiny ID (Account ID)
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>components {string[]}: See {@link https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType|DestinyComponentType} for the different enum types.</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyCharacterResponse>} When fulfilled returns an object containing stats about the specified character
*/
getCharacter(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyCharacterResponse>>;
/**
* Returns information on the weekly clan rewards and if the clan has earned them or not. Note that this will always report rewards as not redeemed
* @async
* @param groupId Group ID of the clan whose stats you wish to fetch
* @return {Promise.IAPIResponse} When fulfilled returns an object containing information about the weekly clan results
*/
getClanWeeklyRewardState(groupId: string): Promise<IAPIResponse<IDestinyMilestone>>;
/**
* Get the details of an instanced Destiny Item. Materials and other non-instanced items can not be queried with this endpoint.
* The items are coupled with an specific Destiny Account
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param itemInstanceId: ID of the Destiny Item
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>components {string[]}: See {@link https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType|DestinyComponentType} for the different enum types.</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyItemResponse>} When fulfilled returns an object containing stats about the queried item
*/
getItem(membershipType: BungieMembershipType, destinyMembershipId: string, itemInstanceId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyItemResponse>>;
/**
* Retrieve all currently available vendors for a specific character
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param characterId ID of the character for whom to get the vendor info
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>components {string[]}: See {@link https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType|DestinyComponentType} for the different enum types.</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyVendorsResponse>} When fulfilled returns an object containing all available vendors
*/
getVendors(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyVendorsResponse>>;
/**
* Retrieve all currently available vendors for a specific character
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param characterId ID of the character for whom to get the vendor info
* @param vendorHash Hash identifier of the vendor to retreieve
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>components {string[]}: See {@link https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType|DestinyComponentType} for the different enum types.</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyVendorResponse>} When fulfilled returns an object containing all available vendors
*/
getVendor(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string, vendorHash: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyVendorResponse>>;
/**
* Given a Presentation Node that has Collectibles as direct descendants, this will return item details about those descendants in the context of the requesting character.
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId Destiny membership ID of another user. You may be denied.
* @param characterId The Destiny Character ID of the character for whom we're getting collectible detail info.
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>components {string[]}: See {@link https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType|DestinyComponentType} for the different enum types.</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyCollectibleNodeDetailResponse>} When fulfilled returns the detailed information about a Collectible Presentation Node and any Collectibles that are direct descendants.
*/
getCollectibleNodeDetails(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string, collectiblePresentationNodeHash: number, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyCollectibleNodeDetailResponse>>;
/**
* Ge the post carnage report for a specific activity ID
* @async
* @param activityId The activity ID for getting the carnage report
* @return {Promise.IAPIResponse<IDestinyPostGameCarnageReportData>} When fulfilled returns an object containing the carnage report for the specified activity
*/
getPostGameCarnageReport(activityId: string): Promise<IAPIResponse<IDestinyPostGameCarnageReportData>>;
/**
* Get historical stats definitions. This contains the values for the key.
* @async
*/
getHistoricalStatsDefinition(): Promise<IAPIResponse<{
[key: string]: IDestinyHistoricalStatsDefinition;
}>>;
/**
* Get the leaderboard of a clan
* @async
* @param groupId Group ID of the clan whose leaderboards you wish to fetch
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>modes {strings[]} Different gameMode IDs for which to get the stats <br />
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType.html#schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType|DestinyActivityModeType} for the different game mode IDs
* </li>
* <li>maxtop {number}: Maximum number of top players to return. Use a large number to get entire leaderboard
* <li><statId {string}: ID of stat to return rather than returning all Leaderboard stats. <br />
* {@link https://alexanderwe.github.io/the-traveler/enums/statid.html|StatIds} for available ids</li>
* </ul>
* @return {Promise.IAPIResponse<object>} When fulfilled returns an object containing leaderboards for a clan
*/
getClanLeaderboards(groupId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<{
[key: string]: object;
}>>;
/**
* Gets aggregated stats for a clan using the same categories as the clan leaderboards
* @async
* @param groupId Group ID of the clan whose stats you wish to fetch
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>modes {string[]}: Array of game modes for which to get stats <br />
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType.html#schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType|DestinyActivityModeType} for the different game mode IDs</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyClanAggregateStat[]>} When fulfilled returns an object containing aggregated stats for a clan
*/
getClanAggregateStats(groupId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyClanAggregateStat[]>>;
/**
* Gets leaderboards with the signed in user's friends and the supplied destinyMembershipId as the focus.
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>modes {strings[]} Different gameMode IDs for which to get the stats <br />
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType.html#schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType|DestinyActivityModeType} for the different game mode IDs
* </li>
* <li>maxtop {number}: Maximum number of top players to return. Use a large number to get entire leaderboard
* <li><statId {string}: ID of stat to return rather than returning all Leaderboard stats. <br />
* See {@link https://alexanderwe.github.io/the-traveler/enums/statid.html|StatIds} for available ids</li>
* </ul>
* @return {Promise.IAPIResponse<object>} When fulfilled returns an object containing the leaderboard
*/
getLeaderboards(membershipType: BungieMembershipType, destinyMembershipId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<{
[key: string]: object;
}>>;
/**
* Gets leaderboards for the specified character and friend's
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param characterId ID of the character
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>modes {strings[]} Different gameMode IDs for which to get the stats <br />
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType.html#schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType|DestinyActivityModeType} for the different game mode IDs
* </li>
* <li>maxtop {number}: Maximum number of top players to return. Use a large number to get entire leaderboard
* <li><statId {string}: ID of stat to return rather than returning all Leaderboard stats. <br />
* See {@link https://github.com/alexanderwe/the-traveler/blob/master/docs/globals.html|<brs} for available ids</li>
* </ul>
* @return {Promise.IAPIResponse} When fulfilled returns an object containing the leaderboard
*/
getLeaderboardsForCharacter(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<{
[key: string]: object;
}>>;
/**
* Gets a page list of Destiny items
* @async
* @param searchTerm The string to use when searching for Destiny entities
* @param typeDefinition The type of entity for which you want to search
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>page {number} Page number to return, starting with 0</li>
* @return {Promise.IAPIResponse<IDestinyEntitySearchResult>} The entities search result
*/
searchDestinyEntities(searchTerm: string, typeDefinition: TypeDefinition, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyEntitySearchResult>>;
/**
* Gets activity history stats for indicated character
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param characterId ID of the character
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>dayend {string}: Last day to return when daily stats are requested. Use the format YYYY-MM-DD</li>
* <li>daystart {string}: First day to return when daily stats are requested. Use the format YYYY-MM-DD</li>
* <li>groups {string[]}: Group of stats to include, otherwise only general stats are returned. Use the numbers.<br >/
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyStatsGroupType.html#schema_Destiny-HistoricalStats-Definitions-DestinyStatsGroupType|DestinyStatsGroupType} for the different IDs
* </li>
* <li>modes {strings[]} Different gameMode IDs for which to get the stats.<br >/
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType.html#schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType|DestinyActivityModeType} for the different game mode IDs
* </li>
* <li>periodType {number}: Indicates a specific period type to return. <br >/
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-PeriodType.html#schema_Destiny-HistoricalStats-Definitions-PeriodType|PeriodType} for the different period type numbers
* </li>
* </ul>
* @return {Promise.IAPIResponse} When fulfilled returns an object containing stats about the characters historical stats
*/
getHistoricalStats(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<{
[key: string]: IDestinyHistoricalStatsByPeriod;
}>>;
/**
* Retrieve aggregrated details about a Destiny account's characters
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li> groups {string[]}: Group of stats to include, otherwise only general stats are returned. Use the numbers. <br >/
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyStatsGroupType.html#schema_Destiny-HistoricalStats-Definitions-DestinyStatsGroupType|DestinyStatsGroupType} for the different IDs
* </ul>
* @return {Promise.IAPIResponse<IDestinyHistoricalStatsAccountResult>} When fulfilled returns an object containing stats about the found user's account
*/
getHistoricalStatsForAccount(membershipType: BungieMembershipType, destinyMembershipId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyHistoricalStatsAccountResult>>;
/**
* Gets activity history stats for indicated character
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param characterId ID of the character
* @param queryStringParameters An object containing key/value query parameters for this endpoint. Following keys are valid:
* <ul>
* <li>count {number}: Number of rows to return</li>
* <li>mode {number} A single game mode to get the history for the specified character. <br />
* See {@link https://bungie-net.github.io/multi/schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType.html#schema_Destiny-HistoricalStats-Definitions-DestinyActivityModeType|DestinyActivityModeType} for the different game mode IDs
* </li>
* <li>page {number}: Page number to return, starting with 0</li>
* </ul>
* @return {Promise.IAPIResponse<IDestinyActivityHistoryResults>} When fulfilled returns an object containing stats for activities for the specified character
*/
getActivityHistory(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string, queryStringParameters: IQueryStringParameters): Promise<IAPIResponse<IDestinyActivityHistoryResults>>;
/**
* Gets details about unique weapon usage, including all exotic weapons
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param characterId ID of the character
* @return {Promise.IAPIResponse<IDestinyHistoricalWeaponStatsData>} When fulfilled returns an object containing information about the weapon usage for the indiciated character
*/
getUniqueWeaponHistory(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string): Promise<IAPIResponse<IDestinyHistoricalWeaponStatsData>>;
/**
* Gets all activities the character has participated in together with aggregate statistics for those activities
* @async
* @param membershipType A valid non-BungieNet membership type. It has to match the type which the `destinyMembershipId` is belonging to. <br />
* Keep in mind that `-1 / MembershipType.All` is <strong> not applicable here </strong> <br/>
* Ex: If the `destinyMembershipId` is a PSN account then use `'2'` or `MembershipType.PSN` for this endpoint.
* @param destinyMembershipId The Destiny ID (Account ID)
* @param characterId ID of the character
* @return {Promise.IAPIResponse<IDestinyAggregateActivityResults>} When fulfilled returns an object containing aggregated information about recent activities
*/
getAggregateActivityStats(membershipType: BungieMembershipType, destinyMembershipId: string, characterId: string): Promise<IAPIResponse<IDestinyAggregateActivityResults>>;
/**
* Gets custom localized content for the milestone of the given hash, if it exists.
* @async
* @param milestoneHash The identifier for the milestone to be returned
* @return {Promise.IAPIResponse<IDestinyMilestoneContent>} When fulfilled returns an object containing aggregated information about recent activities
*/
getPublicMilestoneContent(milestoneHash: string): Promise<IAPIResponse<IDestinyMilestoneContent>>;
/**
* Gets public information about currently available Milestones
* @async
*/
getPublicMilestones(): Promise<IAPIResponse<{
[key: string]: IDestinyPublicMilestone;
}>>;
/**
* Equip an item from the inventory. You must have a valid Destiny Account, and either be in a social space, in orbit, or offline.
* @async
* @param itemActionRequest An object containing following keys: <br />
* <ul>
* <li>itemId {string} - The itemInstanceId (**not hash**) of the item you want to equipt</li>
* <li>charcterId {string} The character ID of the character who gets the item</li>
* <li>membershipType {number} The BungieMemberschipType</li>
* </ul>
*/
equipItem(itemActionRequest: IDestinyItemActionRequest): Promise<IAPIResponse<number>>;
/**
* Equip multiple items from the inventory. You must have a valid Destiny Account, and either be in a social space, in orbit, or offline.
* @async
* @param itemActionRequest An object containing following keys: <br />
* <ul>
* <li>itemIds {string[]} - Multiple itemInstanceIds (**not hasesh**) of the items you want to equipt</li>
* <li>charcterId {string} The character ID of the character who gets the item</li>
* <li>membershipType {number} The BungieMemberschipType</li>
* </ul>
*/
equipItems(itemActionRequest: IDestinyItemSetActionRequest): Promise<IAPIResponse<IDestinyEquipItemResults>>;
/**
* Set the Lock State for an instanced item in your inventory. You must have a valid Destiny Account.
* @async
* @param stateRequest An object containing following keys: <br />
* <ul>
* <li>state {boolean}: Set lock state = true, remove lock state = false</li>
* <li>itemId {string}: Multiple itemInstanceId (**not hash**) of the item which you want to change the lock state on</li>
* <li>charcterId {string}: The character ID of the character who owns the item</li>
* <li>membershipType {number}: The BungieMemberschipType</li>
* </ul>
*/
setItemLockState(stateRequest: IDestinyItemStateRequest): Promise<IAPIResponse<number>>;
/**
* Extract an item from the Postmaster, with whatever implications that may entail. You must have a valid Destiny account. You must also pass BOTH a reference AND an instance ID if it's an instanced item.
* @async
* @param postMasterTransferRequest
*/
pullFromPostmaster(postMasterTransferRequest: IDestinyPostMasterTransferRequest): Promise<IAPIResponse<number>>;
/**
* Transfer an item to/from your vault. You must have a valid Destiny account. You must also pass BOTH a reference AND an instance ID if it's an instanced item (in your inventory).
* @async
* @param transferRequest An object containing following keys: <br />
* <ul>
* <li>itemReferenceHash {string}: hash of the item</li>
* <li>stackSize{number}: How many of the item</li>
* <li>transferToVault {boolean} Transfer to vault - true, from vault - false</li>
* <li>itemId {string}: itemInstanceId (**not hash**) of the item which you want to transfer/li>
* <li>charcterId {string}: The character ID of the character who owns the item</li>
* <li>membershipType {umber}: The BungieMemberschipType</li>
* </ul>
*/
transferItem(transferRequest: IDestinyItemTransferRequest): Promise<IAPIResponse<number>>;
/**
* Insert a plug into a socketed item. <strong>NOT RELEASED</strong>
* @async
* @not-released
* @param itemActionRequest An object containing following keys: <br />
* <ul>
* <li>itemId {string} - The itemInstanceId (**not hash**) of the item you want to equipt</li>
* <li>charcterId {string} The character ID of the character who gets the item</li>
* <li>membershipType {number} The BungieMemberschipType</li>
* </ul>
*/
insertSocketPlug(itemActionRequest: IDestinyItemActionRequest): Promise<IAPIResponse<SocketResponseCodes>>;
/**
* Generates the OAuthURL where your users need to sign up to give your application access to
* authorized endpoints.
*/
generateOAuthURL(): string;
/**
* Retreive the Oauth access token from the authorization code
* @async
* @param code The authorization code from the oauth redirect url
*/
getAccessToken(code: string): Promise<IOAuthResponse>;
/**
* Use the refreshToken to retrieve a new valid access_token.
* Please keep the expiration durations in mind.
* <strong>This is only possible with a confidential app, as only this will get a refresh token to use</strong>
* @async
* @param refreshToken
*/
refreshToken(refreshToken: string): Promise<IOAuthResponse>;
/**
* Download the specified manifest file, extract the zip and also deleting the zip afterwards
* @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
* @async
* @param queryStringParameters: Object which contains the query keys and values
* @return The query string to add to the endpoint url
*/
private resolveQueryStringParameters;
/**
* Initialize a request to perform an advanced write action.
* @async
* @notuseable
* @param awaPermissionRequest An object containing following keys: <br />
* <ul>
* <li>type {DestinyAdvancedAwaType} - Type of advanced write action.</li>
* <li>charcterId {number} - Item instance ID the action shall be applied to. This is optional for all but a new AwaType values. Rule of thumb is to provide the item instance ID if one is available.</li>
* <li>membershipType {number} - The BungieMemberschipType</li>
* <li>affectedItemId {number} Id of the item being affected.</li>
* </ul>
*
*/
/**
* Provide the result of the user interaction. Called by the Bungie Destiny App to approve or reject a request.
* @async
* @notusable
* @param awaUserResponse An object containing following keys: <br />
* <ul>
* <li>selection {DestinyAdvancedAwaUserSelection} - Indication of the selection the user has made (Approving or rejecting the action).</li>
* <li>correlationId {number} - Correlation ID of the request.</li>
* <li>nonce {any} - Secret nonce received via the PUSH notification</li>
* </ul>
* @return {Promise.number} When fulfilled returns a number
*/
/**
* Returns the action token if user approves the request.
* @async
* @notusable
* @param correlationId The identifier for the advanced write action request.
* @return {Promise.IDestinyAdvancedAwaAuthorizationResult} When fulfilled returns a IDestinyAdvancedAwaAuthorizationResult
*/
/**
* Report a player that you met in an activity that was engaging in ToSviolating activities. Both you and the offending player must have played in the activityId passed in.
* Please use this judiciously and only when you have strong suspicions of violation, pretty please.
* @async
* @notuseable
* @param activityId The ID of the activity where you ran into the brigand that you're reporting.
* @return {Promise.IAPIResponse<IDestinyPostGameCarnageReportData>} When fulfilled returns an object containing the carnage report for the specified activity
*/
oauth: IOAuthResponse;
oauth: OAuthResource;
global: GlobalResource;
user: UserResource;
destiny2: Destiny2Resource;
constructor(config: ITravelerConfig);
}
{
"name": "the-traveler",
"version": "0.7.4",
"version": "1.0.0",
"description": "A Node.js API wrapper for the Destiny 2 API",

@@ -20,20 +20,26 @@ "keywords": [

"files": [
"build/*.js",
"build/*.d.ts"
"build/**.js",
"build/**.d.ts",
"build/resources",
"build/resources/**.js",
"build/resources/**.d.ts",
"build/type-definitions",
"build/type-definitions/**.js",
"build/type-definitions/**.d.ts"
],
"scripts": {
"testing": "ts-node ./src/test.ts --files",
"start": "babel-node ./src/index.js --presets env",
"debug": "babel-node ./src/index.js --presets env",
"build": "tsc --p tsconfig.json --declaration --target es5",
"build": "rm -rf ./build && tsc --p tsconfig.json --declaration --target es5",
"watch": "tsc --watch --p tsconfig.json --declaration --target es5",
"test": "jest --coverage",
"posttest": "codecov",
"doc": "typedoc --target ES5 --readme ./README.md --name 'The Traveler' --mode file --out ./docs/ --hideGenerator --exclude **/node_modules/** ./src/*.ts --ignoreCompilerErrors && touch ./docs/.nojekyll",
"doc": "typedoc --target ES5 --readme ./README.md --name 'The Traveler' --mode file --out ./docs/ --hideGenerator --exclude **/node_modules/** ./src/**/**.ts --ignoreCompilerErrors && touch ./docs/.nojekyll",
"package": "npm pack"
},
"dependencies": {
"@types/request-promise-native": "^1.0.6",
"form-data": "^2.3.3",
"got": "^9.4.0",
"node-stream-zip": "^1.3.7",
"request": "^2.83.0",
"request-promise-native": "^1.0.4",
"sqlite3": "^4.0.2"

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

"@types/dotenv": "^4.0.3",
"@types/got": "^9.2.1",
"@types/jest": "23.1.0",

@@ -46,0 +53,0 @@ "@types/sqlite3": "^3.1.1",

@@ -13,24 +13,28 @@ # the-traveler

* [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)
- [Installation](#installation)
- [NPM](#npm)
- [Yarn](#yarn)
- [Prerequisites](#prerequisites)
- [General remark](#general-remark)
- [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)
- [Async await approach (pseudo-code)](#async-await-approach-pseudo-code)
- [Manifest](#manifest)
- [Progress](#progress)
- [Built With](#built-with)
- [Thanks](#thanks)
- [Versioning](#versioning)
- [Issues](#issues)
- [License](#license)
- [Acknowledgments](#acknowledgments)

@@ -95,2 +99,19 @@ ## Getting Started

## General remark
With version `v1.0.0` the structure of the library changed quite a bit. Not in terms of functionality but in terms of how the different methods are called. The `Traveler` object contains different attributes indicating the different resource endpoints. For example if you want to use endpoints from Destiny 2 you call them by:
```js
traveler.destiny2.<method>
```
If you want to access OAuth related methods, they are located under:
```js
traveler.oauth.<method>
```
This decision was made to better seperate the calls according to their destination.
You can find the different resource endpoints in the [documentation](https://alexanderwe.github.io/the-traveler/).
## OAuth

@@ -115,3 +136,3 @@

```js
const authUrl = traveler.generateOAuthURL(); // The URL your users have to visit to give your application access
const authUrl = traveler.oauth.generateOAuthURL(); // The URL your users have to visit to give your application access
```

@@ -124,3 +145,3 @@

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

@@ -160,3 +181,4 @@ traveler.oauth = oauth;

```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
traveler.oauth.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

@@ -221,2 +243,4 @@ traveler.oauth = oauth;

Here are some examples on how to use the library. You can find exhaustive examples in the [ documentation](https://alexanderwe.github.io/the-traveler/)
### Search for an Destiny Account on PSN

@@ -228,2 +252,3 @@

traveler
.destiny2
.searchDestinyPlayer('2', 'playername')

@@ -266,3 +291,5 @@ .then(player => {

traveler.getCharacter('2', '4611686018452033461', '2305843009265042115', { components: ['200', '201', '202', '203', '204', '205'] }).then(result => {
traveler
.destiny2
.getCharacter('2', '4611686018452033461', '2305843009265042115', { components: ['200', '201', '202', '203', '204', '205'] }).then(result => {
console.log(result);

@@ -275,17 +302,19 @@ }).catch(err => {

traveler.getCharacter('2', '4611686018452033461', '2305843009265042115', {
components:
[
ComponentType.Characters,
ComponentType.CharacterInventories,
ComponentType.CharacterProgressions,
ComponentType.CharacterRenderData,
ComponentType.CharacterActivities,
ComponentType.CharacterEquipment
]
}).then(result => {
console.log(result);
}).catch(err => {
console.log(err);
});
traveler
.destiny2
.getCharacter('2', '4611686018452033461', '2305843009265042115', {
components:
[
ComponentType.Characters,
ComponentType.CharacterInventories,
ComponentType.CharacterProgressions,
ComponentType.CharacterRenderData,
ComponentType.CharacterActivities,
ComponentType.CharacterEquipment
]
}).then(result => {
console.log(result);
}).catch(err => {
console.log(err);
});

@@ -312,24 +341,4 @@ ```

### Transfer item from vault to character (needs OAuth)
`traveler.oauth` has to be set before calling this method
```js
traveler
.transferItem({
itemReferenceHash: '2907129556',
stackSize: 1,
transferToVault: false,
itemId: '6917529033189743362',
characterId: 'yourCharacterId',
membershipType: BungieMembershipType.PSN // BungieMembershipType.PSN in ES5
})
.then(result => {
console.log(result);
})
.catch(err => {
console.log(err);
});
```
### Async await approach (pseudo-code)

@@ -371,4 +380,4 @@

traveler.getDestinyManifest().then(result => {
traveler.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content').then(filepath => {
traveler.destiny2.getDestinyManifest().then(result => {
traveler.destiny2.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content').then(filepath => {
const manifest = new Manifest(filepath);

@@ -385,3 +394,2 @@ manifest.queryManifest('SELECT name FROM sqlite_master WHERE type="table"').then(queryResult => {

```

@@ -396,4 +404,4 @@

async ()=> {
const result = await traveler.getDestinyManifest();
const filepath = await traveler.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content');
const result = await traveler.destiny2.getDestinyManifest();
const filepath = await traveler.destiny2.downloadManifest(result.Response.mobileWorldContentPaths.en, './manifest.content');
const manifest = new Manifest(filepath);

@@ -408,36 +416,2 @@ const queryResult = await manifest.queryManifest('SELECT name FROM sqlite_master WHERE type="table"')

| Endpoint | Implemented | Unlocked in API |
|-----------------------------------------------------|-------------|----------------------|
| Destiny2.GetDestinyManifest | ✅ | ✅ |
| Destiny2.GetDestinyEntityDefinition | ✅ | ✅ |
| Destiny2.SearchDestinyPlayer | ✅ | ✅ |
| Destiny2.GetLinkedProfiles | ✅ | ✅ |
| Destiny2.GetProfile | ✅ | ✅ |
| Destiny2.GetCharacter | ✅ | ✅ |
| Destiny2.GetClanWeeklyRewardState | ✅ | ✅ |
| Destiny2.GetItem | ✅ | ✅ |
| Destiny2.GetVendors | ✅ | ✅ |
| Destiny2.GetVendor | ✅ | ✅ |
| Destiny2.TransferItem | ✅ | ✅ |
| Destiny2.PullFromPostmaster | ✅ | ✅ |
| Destiny2.EquipItem | ✅ | ✅ |
| Destiny2.EquipItems | ✅ | ✅ |
| Destiny2.SetItemLockState | ✅ | ✅ |
| Destiny2.InsertSocketPlug | ✅ | ![alt text][preview] |
| Destiny2.GetPostGameCarnageReport | ✅ | ✅ |
| Destiny2.ReportOffensivePostGameCarnageReportPlayer | ✅ | ✅ |
| Destiny2.GetHistoricalStatsDefinition | ✅ | ✅ |
| Destiny2.GetClanLeaderboards | ✅ | ![alt text][preview] |
| Destiny2.GetClanAggregateStats | ✅ | ![alt text][preview] |
| Destiny2.GetLeaderboards | ✅ | ![alt text][preview] |
| Destiny2.GetLeaderboardsForCharacter | ✅ | ![alt text][preview] |
| Destiny2.SearchDestinyEntities | ✅ | ✅ |
| Destiny2.GetHistoricalStats | ✅ | ✅ |
| Destiny2.GetHistoricalStatsForAccount | ✅ | ✅ |
| Destiny2.GetActivityHistory | ✅ | ✅ |
| Destiny2.GetUniqueWeaponHistory | ✅ | ✅ |
| Destiny2.GetDestinyAggregateActivityStats | ✅ | ✅ |
| Destiny2.GetPublicMilestoneContent | ✅ | ✅ |
| Destiny2.GetPublicMilestones | ✅ | ✅ |
## Built With

@@ -450,2 +424,6 @@

## Thanks
Huge thanks to [@BenHollis](https://github.com/bhollis) and [bungie-api-ts](https://github.com/DestinyItemManager/bungie-api-ts) to provide the type definitions for the library, all credits for those are going to him/them
## Versioning

@@ -457,3 +435,3 @@

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).

@@ -460,0 +438,0 @@ ## License

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

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