getstream
Advanced tools
Comparing version 4.0.4 to 4.0.5
@@ -384,3 +384,3 @@ var _extends = require("@babel/runtime/helpers/extends"); | ||
token = signing.JWTScopeToken(this.apiSecret, '*', '*', { | ||
feedId: userId | ||
feedId: '' + feedSlug + userId | ||
}); | ||
@@ -387,0 +387,0 @@ } else { |
@@ -14,3 +14,3 @@ { | ||
"license": "BSD-3-Clause", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"scripts": { | ||
@@ -17,0 +17,0 @@ "build": "babel src --out-dir lib", |
@@ -43,2 +43,4 @@ Stream-JS | ||
### API client setup Node | ||
```javascript | ||
@@ -50,15 +52,38 @@ var stream = require('getstream'); | ||
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', 'APP_ID', { location: 'us-west' }); | ||
// Instantiate a new client (client side) | ||
client = stream.connect('YOUR_API_KEY'); | ||
// Find your API keys here https://getstream.io/dashboard/ | ||
``` | ||
### API client setup Node + Browser | ||
If you want to use the API client directly on your web/mobile app you need to generate a user token server-side and pass it. | ||
#### Server-side token generation | ||
```javascript | ||
var stream = require('getstream'); | ||
// Instantiate a new client (server side) | ||
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET'); | ||
// Optionally supply the app identifier and an object specifying the data center to use | ||
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', 'APP_ID', { location: 'us-west' }); | ||
// Create a token for user with id "the-user-id" | ||
const userToken = client.createUserToken('the-user-id'); | ||
``` | ||
#### Client API init | ||
```javascript | ||
var stream = require('getstream'); | ||
// Instantiate new client with a user token | ||
client = stream.connect('apikey', userToken, 'appid'); | ||
``` | ||
#### Examples | ||
```javascript | ||
// Instantiate a feed object server side | ||
user1 = client.feed('user', '1'); | ||
// Instantiate a feed object client side | ||
// Generate a feed's token using server side signing (see below for stream-js or https://getstream.io/docs/ for other languages) | ||
user1 = client.feed('user', '1', 'FEED_TOKEN'); | ||
// Get activities from 5 to 10 (slow pagination) | ||
user1.get({limit:5, offset:5}, callback); | ||
// (Recommended & faster) Filter on an id less than a given UUID | ||
// Filter on an id less than a given UUID | ||
user1.get({limit:5, id_lt:"e561de8f-00f1-11e4-b400-0cc47a024be0"}); | ||
@@ -138,2 +163,3 @@ | ||
// ⚠️ server-side only! | ||
client.addToMany(activity, feeds); | ||
@@ -148,2 +174,3 @@ | ||
// ⚠️ server-side only! | ||
client.followMany(follows); | ||
@@ -177,12 +204,3 @@ | ||
// creating a feed token server side | ||
token = user1.token; | ||
// passed to client via template or api and initialized as such | ||
user1 = client.feed('user', '1', token); | ||
// creating a read-only feed token server side | ||
readonlyToken = client.feed('user', '1').getReadOnlyToken(); | ||
// passed to client via template or api and initialized as such | ||
user1 = client.feed('user', '1', readonlyToken); | ||
// ⚠️ server-side only! | ||
// Create redirect urls | ||
@@ -225,9 +243,7 @@ var impression = { | ||
var stream = require('getstream'); | ||
// NOTE: the site id is needed for subscribing | ||
// server side example: | ||
client = stream.connect('YOUR_API_KEY', 'API_KEY_SECRET', 'APP_ID'); | ||
// ⚠️ userToken is generated server-side (see previous section) | ||
client = stream.connect('YOUR_API_KEY', userToken, 'APP_ID'); | ||
user1 = client.feed('user', '1'); | ||
// same two lines but client side (generate the feed token server side) | ||
client = stream.connect('YOUR_API_KEY', null, 'APP_ID'); | ||
user1 = client.feed('user', '1', 'feedtoken'); | ||
// subscribe to the changes | ||
@@ -234,0 +250,0 @@ var subscription = user1.subscribe(function (data) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
67811338
288