destiny-client
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -1,1 +0,1 @@ | ||
module.exports = require('./lib/destiny'); | ||
module.exports = require('./build/main'); |
{ | ||
"name": "destiny-client", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "A client for Bungie's Destiny API.", | ||
@@ -17,3 +17,3 @@ "main": "index.js", | ||
"author": "@waltfy", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -23,12 +23,11 @@ "url": "https://github.com/waltfy/destiny/issues" | ||
"homepage": "https://github.com/waltfy/destiny", | ||
"dependencies": { | ||
"lodash": "^2.4.1", | ||
"promise": "^6.0.1", | ||
"superagent": "^0.21.0", | ||
"superagent-promise": "^0.2.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^6.3.2", | ||
"uglify-js": "^2.4.15" | ||
"babel": "^5.4.7", | ||
"babel-eslint": "^3.1.8", | ||
"eslint": "^0.21.2", | ||
"isomorphic-fetch": "^2.1.0", | ||
"lodash": "^3.9.1", | ||
"uglify-loader": "^1.2.0", | ||
"webpack": "^1.9.9" | ||
} | ||
} |
@@ -27,3 +27,4 @@ #!/usr/env/bin node | ||
http.createServer(function(req, res) { | ||
http.createServer(function (req, res) { | ||
var outboundData = { | ||
@@ -37,2 +38,4 @@ method: req.method, | ||
console.log('req.headers.cookie:', req.headers.cookie); | ||
outboundData.headers.host = BUNGIE.host; | ||
@@ -63,4 +66,4 @@ | ||
}).listen(process.argv[2], function() { | ||
console.log('Bungie Proxy Server up at http://%s:%s', this.address().address, this.address().port); | ||
}).listen(process.argv[2], function () { | ||
console.log('Bungie Proxy Server running on port %s', this.address().port); | ||
}); |
443
README.md
@@ -1,2 +0,2 @@ | ||
Destiny-Client | ||
Destiny-Client [![npm version](https://badge.fury.io/js/destiny-client.svg)](http://badge.fury.io/js/destiny-client) [![Gitter](https://badges.gitter.im/Destiny-Client.svg)](https://gitter.im/waltfy/destiny?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
==== | ||
@@ -6,18 +6,6 @@ | ||
[![npm version](https://badge.fury.io/js/destiny-client.svg)](http://badge.fury.io/js/destiny-client) [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/waltfy/destiny?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
The intent is to implement [more and more end-points](https://gist.github.com/waltfy/3f707a1ea7454997e484) as time allows. | ||
Please feel free submit issues and requests. | ||
Please feel free submit issues and requests, or [get in touch](//www.twitter.com/waltfy). | ||
## Usage | ||
```js | ||
Destiny | ||
.search({ type: 1, name: 'waltercarvalho' }) | ||
.end(function (err, res) { | ||
// do stuff | ||
}); | ||
``` | ||
## Getting Started | ||
@@ -27,3 +15,3 @@ | ||
Unfortunately you cannot hit `https://bungie.net` directly. So if you plan to use this library in client-side code, due to `CORS` you'll have to run your own proxy server to handle your requests to Bungie for you. I have added an example proxy server ([`proxy.js`](https://github.com/waltfy/destiny/blob/develop/proxy.js)). Simply run `node proxy.js`. Credit to [@phuu](https://github.com/phuu). | ||
Unfortunately you cannot "hit" `https://bungie.net` directly. So if you plan to use this library in client-side code, due to `CORS` you'll have to run your own proxy server to handle your requests to Bungie for you. I have added an example proxy server ([`proxy.js`](https://github.com/waltfy/destiny/blob/develop/proxy.js)). Simply run `node proxy.js`. Credit to [@phuu](https://github.com/phuu). | ||
@@ -37,3 +25,12 @@ ### Node | ||
```js | ||
var Destiny = require('destiny-client')(/* { host: 'http://localhost:9000' } */); | ||
var destiny = require('destiny-client')(); | ||
destiny | ||
.Search({ | ||
memebershipType: 1, | ||
name: 'waltercarvalho' | ||
}) | ||
.then(users => { | ||
console.debug('users', users); | ||
}); | ||
``` | ||
@@ -43,17 +40,28 @@ | ||
Simply include [`desiny.js`](https://raw.githubusercontent.com/waltfy/destiny/develop/destiny.js) or [`destiny.min.js`](https://raw.githubusercontent.com/waltfy/destiny/develop/destiny.min.js) on your page. You will most likely need a proxy server due to `CORS`. See [proxy-server](#proxy-server) instructions above. | ||
Simply include [`destiny.js`](https://raw.githubusercontent.com/waltfy/destiny/develop/destiny.js) on your page. You will most likely need a proxy server due to `CORS`. See [proxy-server](#proxy-server) instructions above. | ||
```html | ||
<script src='destiny.min.js' type='text/javascript'></script> | ||
<script src='destiny.js' type='text/javascript'></script> | ||
<script type="text/javascript"> | ||
var client = Destiny(/* { host: 'http://localhost:9000' } */); | ||
client | ||
.search({ type: 2, name: 'yourusername' }) | ||
.end(function (err, res) { /* do stuff */ }); | ||
var destiny = Destiny('http://{{ host }}:{{ yourport }}/platform/Destiny/'); // this is your proxy server | ||
destiny | ||
.Search({ | ||
memebershipType: 1, | ||
name: 'waltercarvalho' | ||
}) | ||
.then(users => { | ||
console.debug('users', users); | ||
}); | ||
</script> | ||
``` | ||
### Acquiring Cookies | ||
**TODO:** Working on automating this, for now simply inspect your resources to find cookies. Guides can be found online. | ||
## API Overview | ||
In all requests `type` is a `Number` representing the account type, or what network you are in. The network types are: | ||
**NOTE:** In all requests `membershipType` is a `Number` representing the account type, or what network you are in. The network types are: | ||
* `1`: XBox Live. | ||
@@ -64,44 +72,367 @@ * `2`: PlayStation Network (PSN). | ||
### Search Player | ||
* **`Destiny.search({ type: Number, name: String[, query: Object] })`** | ||
* `type`: Network type. | ||
* `name`: Your Bungie name. | ||
* `query`: An object used to create a query string. | ||
### `Destiny::Search(params)` | ||
### Account | ||
> Returns an `Array` of accounts. | ||
* **`Destiny.account({ type: Number, id: String[, query: Object] })`** | ||
* `type`: Network type. | ||
* `id`: Your Bungie membership id. If you don't know this use `Destiny.search`. | ||
* `query`: An object used to create a query string. | ||
`params` (`Object`) | ||
### Main (Character Overview) | ||
* **`Destiny.main({ type: Number, membership: String, id: String[, query: Object] })`** | ||
* `type`: Network type. | ||
* `membership`: Your Bungie membership id. If you don't know this use `Destiny.search`. | ||
* `id`: A destiny Character id. | ||
* `query`: An object used to create a query string. | ||
- `membershipType` - `Number` | ||
- `name` - `String`, the name of your account. | ||
### Character (Inventory, Activities, Progression) | ||
#### Sample Usage: | ||
```js | ||
var destiny = require('./index')(); | ||
* **`Destiny.character.inventory({ type: Number, membership: String, id: String[, query: Object] })`** | ||
* `type`: Network type. | ||
* `membership`: Your Bungie membership id. If you don't know this use `Destiny.search`. | ||
* `id`: A destiny Character id. | ||
* `query`: An object used to create a query string. | ||
destiny | ||
.Search({ | ||
membershipType: 1, | ||
name: 'waltercarvalho' | ||
}) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
``` | ||
* **`Destiny.character.activities({ type: Number, membership: String, id: String[, query: Object] })`** | ||
* `type`: Network type. | ||
* `membership`: Your Bungie membership id. If you don't know this use `Destiny.search`. | ||
* `id`: A destiny Character id. | ||
* `query`: An object used to create a query string. | ||
#### Sample Response: | ||
```js | ||
[ | ||
{ | ||
iconPath: '/img/theme/destiny/icons/icon_xbl.png', | ||
membershipType: 1, | ||
membershipId: '4611686018439937004', | ||
displayName: 'waltercarvalho' | ||
} | ||
] | ||
``` | ||
* **`Destiny.character.progression({ type: Number, membership: String, id: String[, query: Object] })`** | ||
* `type`: Network type. | ||
* `membership`: Your Bungie membership id. If you don't know this use `Destiny.search`. | ||
* `id`: A destiny Character id. | ||
* `query`: An object used to create a query string. | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'Search', url: 'SearchDestinyPlayer/${ membershipType }/${ name }/', required: ['membershipType', 'name'] }` | ||
* * * | ||
### `Destiny::Account(params)` | ||
> Returns an `Object` with details about an account. | ||
`params` (`Object`) | ||
- `membershipType` - `Number` | ||
- `membershipId` - `String`, your membership id. | ||
#### Sample Usage: | ||
var destiny = require('./index')(); | ||
destiny | ||
.Account({ | ||
membershipType: 1, | ||
membershipId: '4611686018439937004' | ||
}) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
#### Sample Response: | ||
```js | ||
{ membershipId: '4611686018439937000', | ||
membershipType: 1, | ||
characters: | ||
[ { characterBase: [Object], | ||
levelProgression: [Object], | ||
emblemPath: '/common/destiny_content/icons/117285c72a9c89626cd7b3fa3d7226ee.jpg', | ||
backgroundPath: '/common/destiny_content/icons/2c73bcd2e874e640f158197bb9f2c55d.jpg', | ||
emblemHash: 776529032, | ||
characterLevel: 2, | ||
baseCharacterLevel: 2, | ||
isPrestigeLevel: false, | ||
percentToNextLevel: 50.1219521 } ], | ||
inventory: | ||
{ buckets: { Invisible: [], Item: [], Currency: [] }, | ||
currencies: [ [Object] ] }, | ||
grimoireScore: 85 } | ||
``` | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'Account', url: '${ membershipType }/Account/${ membershipId }', required: ['membershipType', 'membershipId'] },` | ||
* * * | ||
### `Destiny::Character(params)` | ||
> Returns an `Object` with details about a character. | ||
`params` (`Object`) | ||
- `membershipType` - `Number` | ||
- `membershipId` - `String`, your membership id. | ||
- `characterId` - `String`, your character id. | ||
#### Sample Usage: | ||
```js | ||
var destiny = require('./index')(); | ||
destiny | ||
.Character({ | ||
membershipType: 1, | ||
membershipId: '4611686018439937004', | ||
characterId: '2305843009244228629' | ||
}) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
``` | ||
#### Sample Response: | ||
```js | ||
{ characterBase: | ||
{ membershipId: '4611686018439937004', | ||
membershipType: 1, | ||
characterId: '2305843009244228629', | ||
dateLastPlayed: '2015-05-24T14:31:37Z', | ||
minutesPlayedThisSession: '87', | ||
minutesPlayedTotal: '6130', | ||
powerLevel: 32, | ||
raceHash: 2803282938, | ||
genderHash: 3111576190, | ||
classHash: 2271682572, | ||
currentActivityHash: 0, | ||
lastCompletedStoryHash: 0, | ||
stats: | ||
{ STAT_DEFENSE: [Object], | ||
STAT_INTELLECT: [Object], | ||
STAT_DISCIPLINE: [Object], | ||
STAT_STRENGTH: [Object], | ||
STAT_LIGHT: [Object], | ||
STAT_ARMOR: [Object], | ||
STAT_AGILITY: [Object], | ||
STAT_RECOVERY: [Object], | ||
STAT_OPTICS: [Object] }, | ||
customization: | ||
{ personality: 2166136261, | ||
face: 820889531, | ||
skinColor: 2542514575, | ||
lipColor: 1328348389, | ||
eyeColor: 1511637748, | ||
hairColor: 2001723931, | ||
featureColor: 2166136261, | ||
decalColor: 233897108, | ||
wearHelmet: false, | ||
hairIndex: 10, | ||
featureIndex: 0, | ||
decalIndex: 0 }, | ||
grimoireScore: 2100, | ||
peerView: { equipment: [Object] }, | ||
genderType: 0, | ||
classType: 2, | ||
buildStatGroupHash: 1997970403 }, | ||
levelProgression: | ||
{ dailyProgress: 4032, | ||
weeklyProgress: 196282, | ||
currentProgress: 1091453, | ||
level: 13, | ||
step: 0, | ||
progressToNextLevel: 51453, | ||
nextLevelAt: 80000, | ||
progressionHash: 2030054750 }, | ||
emblemPath: '/common/destiny_content/icons/a9ac444de02308d1410af8a0c201d177.jpg', | ||
backgroundPath: '/common/destiny_content/icons/ee90656ee23ceabf4fe6c4b34234d3ca.jpg', | ||
emblemHash: 3656150982, | ||
characterLevel: 32, | ||
baseCharacterLevel: 20, | ||
isPrestigeLevel: true, | ||
percentToNextLevel: 25 } | ||
``` | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'Character', url: '${ membershipType }/Account/${ membershipId }/Character/${ characterId }/', required: ['membershipType', 'membershipId', 'characterId'] }` | ||
### `Destiny::Activities(params)` | ||
> Returns an `Object` with details about a character's activities. | ||
`params` (`Object`) | ||
- `membershipType` - `Number` | ||
- `membershipId` - `String`, your membership id. | ||
- `characterId` - `String`, your character id. | ||
#### Sample Usage: | ||
```js | ||
var destiny = require('./index')(); | ||
destiny | ||
.Character({ | ||
membershipType: 1, | ||
membershipId: '4611686018439937004', | ||
characterId: '2305843009244228629' | ||
}) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
``` | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'Activities', url: '${ membershipType }/Account/${ membershipId }/Character/${ characterId }/Activities', required: ['membershipType', 'membershipId', 'characterId'] }` | ||
* * * | ||
### `Destiny::Inventory(params)` | ||
> Returns an `Object` with details about character's inventory. | ||
`params` (`Object`) | ||
- `membershipType` - `Number` | ||
- `membershipId` - `String`, your membership id. | ||
- `characterId` - `String`, your character id. | ||
#### Sample Usage: | ||
```js | ||
var destiny = require('./index')(); | ||
destiny | ||
.Inventory({ | ||
membershipType: 1, | ||
membershipId: '4611686018439937004', | ||
characterId: '2305843009244228629' | ||
}) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
``` | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'Inventory', url: '${ membershipType }/Account/${ membershipId }/Character/${ characterId }/Inventory', required: ['membershipType', 'membershipId', 'characterId'] }` | ||
* * * | ||
### `Destiny::Progression(params)` | ||
> Returns an `Object` with details about character's progression. | ||
`params` (`Object`) | ||
- `membershipType` - `Number` | ||
- `membershipId` - `String`, your membership id. | ||
- `characterId` - `String`, your character id. | ||
#### Sample Usage: | ||
```js | ||
var destiny = require('./index')(); | ||
destiny | ||
.Inventory({ | ||
membershipType: 1, | ||
membershipId: '4611686018439937004', | ||
characterId: '2305843009244228629' | ||
}) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
``` | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'Progression', url: '${ membershipType }/Account/${ membershipId }/Character/${ characterId }/Progression', required: ['membershipType', 'membershipId', 'characterId'] }` | ||
* * * | ||
### `Destiny::Equip(params, headers)` – **COOKIES REQUIRED** | ||
> Equips an item onto a character | ||
- `params` (`Object`) | ||
- `membershipType` - `Number` | ||
- `characterId` - `String`, your character id. | ||
- `itemId` - `String`, id of item to be equipped. | ||
- `headers` - `Object`, used for authentication. | ||
- `'Cookie'` - `String`, provided by Bungie. | ||
- `'x-api-key'` - `String`, provided by Bungie. | ||
- `'x-csrf'` - `String`, provided by Bungie. | ||
#### Sample Usage: | ||
```js | ||
var destiny = require('./index')(); | ||
var AUTH = { | ||
'Cookie': '{{ cookie }}', | ||
'x-api-key': '{{ your api key}}', | ||
'x-csrf': '{{ your csrf token }}' | ||
}; | ||
destiny | ||
.Equip({ | ||
characterId: '2305843009244228629', | ||
itemId: '6917529049882199897', | ||
membershipType: 1 | ||
}, AUTH) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
``` | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'Equip', url: 'EquipItem', required: ['characterId', 'itemId', 'membershipType'] }` | ||
* * * | ||
### `Destiny::TransferItem(params, headers)` | ||
> Transfers an item from a char's inventory to the vault. | ||
- `params` (`Object`) | ||
- `membershipType` - `Number` | ||
- `characterId` - `String`, your character id. | ||
- `itemId` - `String`, id of item to be equipped. | ||
- `itemReferenceHash` - `Number` | ||
- `stackSize` - `Number`, number of items to move, 1 for weapons and armour. | ||
- `transferToVault` - `Boolean`, `true` to send to the vault, and `false` to pull from it. | ||
- `headers` - `Object`, used for authentication. | ||
- `'Cookie'` - `String`, provided by Bungie. | ||
- `'x-api-key'` - `String`, provided by Bungie. | ||
- `'x-csrf'` - `String`, provided by Bungie. | ||
#### Sample Usage: | ||
```js | ||
var destiny = require('./index')(); | ||
var AUTH = { | ||
'Cookie': '{{ cookie }}', | ||
'x-api-key': '{{ your api key}}', | ||
'x-csrf': '{{ your csrf token }}' | ||
}; | ||
destiny | ||
.TransferItem({ | ||
characterId: '2305843009244228629', | ||
itemId: '6917529037157880001', | ||
itemReferenceHash: 1683638659, | ||
membershipType: 1, | ||
stackSize: 1, | ||
transferToVault: true | ||
}, AUTH) | ||
.then(res => { /* deal with response */ }) | ||
.catch(err => { /* handle error */ }); | ||
``` | ||
#### Spec | ||
As per defined in [`endpoints.js`](https://github.com/waltfy/destiny/blob/develop/src/endpoints.js). | ||
`{ name: 'TransferItem', url: 'TransferItem', required: ['characterId', 'itemId', 'itemReferenceHash', 'membershipType'] }` | ||
## Change Log | ||
- `v.0.4.0` - Breaking changes. | ||
- `v.0.3.2` | ||
## License | ||
@@ -111,3 +442,3 @@ | ||
Copyright (c) 2014 Walter Carvalho | ||
Copyright (c) 2014-2015 Walter Carvalho | ||
@@ -114,0 +445,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
18
1
456
0
143357
7
687
- Removedlodash@^2.4.1
- Removedpromise@^6.0.1
- Removedsuperagent@^0.21.0
- Removedsuperagent-promise@^0.2.0
- Removedasap@1.0.0(transitive)
- Removedasync@0.9.2(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcomponent-emitter@1.1.2(transitive)
- Removedcookiejar@2.0.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedextend@1.2.1(transitive)
- Removedform-data@0.1.3(transitive)
- Removedformidable@1.0.14(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedlodash@2.4.2(transitive)
- Removedmethods@1.0.1(transitive)
- Removedmime@1.2.11(transitive)
- Removedms@2.0.0(transitive)
- Removedpromise@6.1.0(transitive)
- Removedqs@1.2.0(transitive)
- Removedreadable-stream@1.0.27-1(transitive)
- Removedreduce-component@1.0.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedsuperagent@0.21.0(transitive)
- Removedsuperagent-promise@0.2.0(transitive)