sharetribe-flex-sdk 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/.circleci/config.yml +22 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +19 -0
  4. package/CHANGELOG.md +231 -0
  5. package/LICENSE +201 -0
  6. package/README.md +76 -0
  7. package/build/sharetribe-flex-sdk-node.js +13592 -0
  8. package/build/sharetribe-flex-sdk-web.js +1 -0
  9. package/docs/README.md +20 -0
  10. package/docs/authentication.md +179 -0
  11. package/docs/calling-the-api.md +217 -0
  12. package/docs/configurations.md +95 -0
  13. package/docs/developing-sdk.md +131 -0
  14. package/docs/docpress.json +14 -0
  15. package/docs/features.md +14 -0
  16. package/docs/keep-alive.md +48 -0
  17. package/docs/object-query-parameters.md +36 -0
  18. package/docs/scripts.js +41 -0
  19. package/docs/serializing-types-to-json.md +40 -0
  20. package/docs/sharing-session-between-client-and-server.md +19 -0
  21. package/docs/styles.css +95 -0
  22. package/docs/token-store.md +114 -0
  23. package/docs/try-it-in-browser.md +32 -0
  24. package/docs/try-it-in-the-playground.md +153 -0
  25. package/docs/types.md +27 -0
  26. package/docs/writing-your-own-token-store.md +29 -0
  27. package/docs/your-own-types.md +61 -0
  28. package/examples/README.md +5 -0
  29. package/examples/getting-started-browser/README.md +22 -0
  30. package/examples/getting-started-browser/index.html +89 -0
  31. package/examples/getting-started-browser/index.js +156 -0
  32. package/examples/getting-started-browser/screenshots/screenshot1.png +0 -0
  33. package/examples/getting-started-browser/screenshots/screenshot2.png +0 -0
  34. package/examples/getting-started-node/README.md +23 -0
  35. package/examples/getting-started-node/index.js +139 -0
  36. package/examples/getting-started-node/screenshots/screenshot.png +0 -0
  37. package/package.json +83 -0
  38. package/playground.js +295 -0
  39. package/src/browser_cookie_store.js +26 -0
  40. package/src/context_runner.js +151 -0
  41. package/src/context_runner.test.js +185 -0
  42. package/src/detect.js +11 -0
  43. package/src/express_cookie_store.js +57 -0
  44. package/src/fake/adapter.js +130 -0
  45. package/src/fake/api.js +137 -0
  46. package/src/fake/auth.js +84 -0
  47. package/src/fake/token_store.js +231 -0
  48. package/src/index.js +25 -0
  49. package/src/interceptors/.eslintrc.js +5 -0
  50. package/src/interceptors/add_auth_header.js +32 -0
  51. package/src/interceptors/add_auth_header.test.js +50 -0
  52. package/src/interceptors/add_auth_token_response.js +16 -0
  53. package/src/interceptors/add_client_id_to_params.js +12 -0
  54. package/src/interceptors/add_client_secret_to_params.js +15 -0
  55. package/src/interceptors/add_grant_type_to_params.js +23 -0
  56. package/src/interceptors/add_idp_client_id_to_params.js +17 -0
  57. package/src/interceptors/add_idp_id_to_params.js +17 -0
  58. package/src/interceptors/add_idp_token_to_params.js +17 -0
  59. package/src/interceptors/add_scope_to_params.js +18 -0
  60. package/src/interceptors/add_subject_token_to_params.js +18 -0
  61. package/src/interceptors/add_token_exchange_grant_type_to_params.js +12 -0
  62. package/src/interceptors/auth_info.js +50 -0
  63. package/src/interceptors/clear_token_after_revoke.js +45 -0
  64. package/src/interceptors/default_params.js +12 -0
  65. package/src/interceptors/fetch_auth_token_from_api.js +33 -0
  66. package/src/interceptors/fetch_auth_token_from_store.js +27 -0
  67. package/src/interceptors/fetch_refresh_token_for_revoke.js +24 -0
  68. package/src/interceptors/multipart_request.js +35 -0
  69. package/src/interceptors/retry_with_anon_token.js +58 -0
  70. package/src/interceptors/retry_with_refresh_token.js +70 -0
  71. package/src/interceptors/save_token.js +20 -0
  72. package/src/interceptors/transit_request.js +27 -0
  73. package/src/interceptors/transit_request.test.js +58 -0
  74. package/src/interceptors/transit_response.js +27 -0
  75. package/src/memory_store.js +19 -0
  76. package/src/params_serializer.js +65 -0
  77. package/src/params_serializer.test.js +58 -0
  78. package/src/sdk.js +894 -0
  79. package/src/sdk.test.js +908 -0
  80. package/src/serializer.js +279 -0
  81. package/src/serializer.test.js +229 -0
  82. package/src/token_store.js +15 -0
  83. package/src/types.js +108 -0
  84. package/src/types.test.js +75 -0
  85. package/src/utils.js +68 -0
  86. package/src/utils.test.js +85 -0
  87. package/webpack.config.babel.js +47 -0
package/docs/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # Documentation
2
+
3
+ * [Sharetribe Flex SDK for JavaScript](../README.md)
4
+ * [Features](./features.md)
5
+ * [Try it in browser!](./try-it-in-browser.md)
6
+ * [Try it in the API Playground!](./try-it-in-the-playground.md)
7
+ * Getting started
8
+ * [Authentication](./authentication.md)
9
+ * [Calling the API](./calling-the-api.md)
10
+ * [Types](./types.md)
11
+ * Advanced
12
+ * [Configurations](./configurations.md)
13
+ * [Your own types](./your-own-types.md)
14
+ * [Serializing types to JSON](./serializing-types-to-json.md)
15
+ * [Object query parameters](./object-query-parameters.md)
16
+ * [Token store](./token-store.md)
17
+ * [Sharing session between client and server](sharing-session-between-client-and-server.md)
18
+ * [Keep-Alive](./keep-alive.md)
19
+ * [Writing your own token store](./writing-your-own-token-store.md)
20
+ * [Developing SDK](./developing-sdk.md)
@@ -0,0 +1,179 @@
1
+ # Authentication
2
+
3
+ The SDK provides methods to log the user in and out and determine if
4
+ the user is already logged in or not.
5
+
6
+ ## Login
7
+
8
+ **`sdk.login({ username: string, password: string }) : Promise`**
9
+
10
+ Logs in the user and returns a Promise.
11
+
12
+ The session information will be saved to the SDK instance when the
13
+ Promise is resolved. Subsequent requests will be made as the logged in
14
+ user.
15
+
16
+ ## Logout
17
+
18
+ **`sdk.logout() : Promise`**
19
+
20
+ Logs out the user and returns a Promise.
21
+
22
+ **Trobleshooting:** In case you're testing locally from `file:///`,
23
+ the session information may not be saved after successful login. In
24
+ this case, you should configure the SDK to use [memory-based token
25
+ store](./token-store.md#memory-store).
26
+
27
+ ## Login with IdP
28
+
29
+ **`sdk.loginWithIdp({ idpId: string, idpClientId: string, idpToken: string }) : Promise`**
30
+
31
+ Logs in the user with information from an identity provider (e.g. Facebook) and
32
+ returns a Promise. User can be authenticated if the `idpToken` can be verified
33
+ and an identity provider account resolved from the token is associated with a
34
+ Flex account or if an email address resolved from the token matches a verified
35
+ email of a Flex account.
36
+
37
+ `sdk.loginWithIdp` requires that the SDK instance is initialized with a
38
+ `clientSecret` attribute.
39
+
40
+ The session information will be saved to the SDK instance when the
41
+ Promise is resolved. Subsequent requests will be made as the logged in
42
+ user.
43
+
44
+ ## Determine if user is logged in
45
+
46
+ **`sdk.authInfo() : Promise(Object)`**
47
+
48
+ Returns a Promise with an Object as a value. The object may contain two fields:
49
+
50
+ - `scopes`: an array containing the scopes associated with the currently stored token
51
+ - `isAnonymous`: a boolean denoting if the currently stored token only allows public read access
52
+
53
+ To determine if the user is logged in, check if `isAnonymous` equals
54
+ `false`.
55
+
56
+ **Example:**
57
+
58
+ ```js
59
+ sdk.authInfo().then(authInfo => {
60
+ if (authInfo && authInfo.isAnonymous === false) {
61
+ console.log("User is logged in.");
62
+ } else {
63
+ console.log("User is NOT logged in.")
64
+ }
65
+ };
66
+ ```
67
+
68
+ **Please note:** Even thought the `authInfo` method returns a Promise,
69
+ the method does not call the API. The authentication information is
70
+ saved locally in the [token store](./token-store.md).
71
+
72
+ **Please note:** The token store does not store any other user
73
+ information in addition to the authentication token. If you need, for
74
+ example, to know the name of the logged in user, you need to call
75
+ `sdk.current_user.show()`, which calls the corresponding API endpoint.
76
+
77
+ ## Authentication example
78
+
79
+ Here's a full example how to log user in and out and determine the
80
+ current authentication status.
81
+
82
+ **Example:**
83
+
84
+ ```js
85
+ const isLoggedIn = (authInfo) => authInfo && authInfo.isAnonymous === false;
86
+
87
+ sdk
88
+ .authInfo()
89
+ .then((authInfo) => {
90
+ console.log(`Logged in: ${isLoggedIn(authInfo)}`);
91
+ // prints: "Logged in: false"
92
+
93
+ return sdk.login({
94
+ username: "test-user@example.com",
95
+ password: "test-secret",
96
+ });
97
+ })
98
+ .then((loginRes) => {
99
+ console.log("Login successful!");
100
+
101
+ return sdk.authInfo();
102
+ })
103
+ .then((authInfo) => {
104
+ console.log(`Logged in: ${isLoggedIn(authInfo)}`);
105
+ // prints: "Logged in: true"
106
+
107
+ return sdk.currentUser.show();
108
+ })
109
+ .then((userRes) => {
110
+ const profile = userRes.data.data.attributes.profile;
111
+ console.log(`Current user: ${profile.firstName} ${profile.lastName}`);
112
+
113
+ return sdk.logout();
114
+ })
115
+ .then((logoutRes) => {
116
+ console.log("Logged out!");
117
+
118
+ return sdk.authInfo();
119
+ })
120
+ .then((authInfo) => {
121
+ console.log(`Logged in: ${isLoggedIn(authInfo)}`);
122
+ // prints: "Logged in: false"
123
+ })
124
+ .catch((res) => {
125
+ // An error occurred
126
+ console.log(`Request failed with status: ${res.status} ${res.statusText}`);
127
+ });
128
+ ```
129
+
130
+ ## Exchange token
131
+
132
+ **`sdk.exchangeToken() : Promise`**
133
+
134
+ A valid access token can be exchanged to a trusted token when combined with a client
135
+ secret. A trusted token is required by the Flex APIs for certain requests, for
136
+ example, [privileged
137
+ transitions](https://www.sharetribe.com/docs/background/privileged-transitions/).
138
+
139
+ In order to exchange an access token, a valid access token needs to be stored in
140
+ the SDK's token store. This can be achieved by logging in or by initializing the
141
+ SDK with a token store that holds an access token.
142
+
143
+ **Example:**
144
+
145
+ ```js
146
+ const sdk = sharetribeSdk.createInstance({
147
+ clientId: "a client ID",
148
+ clientSecret: "a client secret",
149
+ tokenStore: sharetribeSdk.tokenStore.memoryStore(),
150
+ });
151
+
152
+ sdk.login({ username: "test-user@example.com", password: "test-secret" });
153
+
154
+ sdk.exchangeToken().then((res) => {
155
+ console.log("Trusted token: ", res.data);
156
+ });
157
+ ```
158
+
159
+ ## Seeing occasional 401 errors?
160
+
161
+ Are you seeing occasional 401 errors in the browser's Web Console?
162
+ Don't worry! That's part of the normal operations.
163
+
164
+ Flex API uses two authentication tokens for each session:
165
+
166
+ - _Access token_ that is used to authenticate the user. Valid only a
167
+ short amount of time.
168
+ - _Refresh token_ that is used to issue a fresh authentication
169
+ token. Long lived.
170
+
171
+ When _access token_ expires, you will see a 401 error in browser's Web
172
+ Console. The SDK will handle this and automatically issue new fresh
173
+ authentication token and retry the request. This all happens under the
174
+ hood and you don't need to worry about it. SDK will do the heavy
175
+ lifting.
176
+
177
+ See [Authentication API reference
178
+ document](https://www.sharetribe.com/api-reference/authentication.html)
179
+ for more information.
@@ -0,0 +1,217 @@
1
+ # Calling the API
2
+
3
+ ## API Endpoints
4
+
5
+ The SDK provides direct mapping from API endpoints to SDK methods.
6
+
7
+ For example:
8
+
9
+ `GET /api/marketplace/show` maps to `sdk.marketplace.show(...)`
10
+
11
+ `GET /api/listings/query` maps to `sdk.listings.query(...)`
12
+
13
+ `POST /api/own_listings/create` maps to `sdk.ownListings.create(...)`
14
+
15
+ ## Parameters
16
+
17
+ You can pass a set of parameters to the SDK method you call. The
18
+ *query* endpoints take one parameter, where as the *command* endpoints
19
+ take three parameters.
20
+
21
+ **Please note:** The SDK does not validate the parameters. The
22
+ parameter validation is only done in the client side. In case of
23
+ invalid parameters, the request fill fail.
24
+
25
+ ### Query method parameters
26
+
27
+ The *query* (GET) methods take only one parameter:
28
+
29
+ * `queryParams`: Object of query parameters
30
+
31
+ **Example:**
32
+
33
+ ```js
34
+ sdk.listings.query({perPage: 5})
35
+
36
+ // Calls GET /api/listings/query?perPage=5
37
+ ```
38
+
39
+ The `queryParams` is optional. If the endpoint doesn't require any
40
+ query parameters, you can call the SDK method without any parameters.
41
+
42
+ ### Command method parameters
43
+
44
+ The *command* (POST) methods take three parameters:
45
+
46
+ * `bodyParams`: Object of body parameters
47
+ * `queryParams`: Object of query parameters
48
+ * `opts`: Additional options
49
+
50
+ **Example:**
51
+
52
+ ```js
53
+ sdk.ownListings.create({title: 'New listings', price: new Money(5000, 'USD')}, {expand: true});
54
+
55
+ // Calls POST /api/own_listings/create?expand=true
56
+ // with title and price serialized in the request body
57
+ ```
58
+
59
+ All parameters are optional. If the endpoint doesn't require any body
60
+ parameters, query parameters or options, you can call the SDK method
61
+ without any parameters.
62
+
63
+ If you wonder what the `new Money(...)` is, have a look at [Types](./types.md).
64
+
65
+ ### Command method options
66
+
67
+ The third parameter for *command* methods is `opts`.
68
+
69
+ Here's a list of available `opts`:
70
+
71
+ * `onUploadProcess`: Takes a callback function that is called with [ProgressEvent](https://developer.mozilla.org/en-US/docs/Web/API/ProgressEvent).
72
+
73
+ **Example:**
74
+
75
+ ```js
76
+ const logProgress = (progressEvent) => {
77
+ const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
78
+ console.log(percentCompleted + '% completed');
79
+ }
80
+
81
+ sdk.listings.uploadImage({ image: file }, {}, { onUploadProgress: logProgress })
82
+ ```
83
+
84
+ ## Response
85
+
86
+ Calling any SDK method will always return a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). The value of the Promise differs whether the request was successful or error. In case of successful request the Promise will be *fulfilled* where as in case of error the Promise will be *rejected*.
87
+
88
+ **Example:**
89
+
90
+ ```js
91
+ const promise = sdk.listings.query();
92
+
93
+ // Handle success response
94
+ promise.then(response => { console.log(response)} );
95
+
96
+ // Handle error response
97
+ promise.catch(response => { console.log(response)} );
98
+ ```
99
+
100
+ ### Success response
101
+
102
+ A successful response will have the following format:
103
+
104
+ ```
105
+ {
106
+ status: 200,
107
+ statusText: 'OK',
108
+ data: // The data returned by the API. Object.
109
+ }
110
+ ```
111
+
112
+ The API returns the data always in the following format:
113
+
114
+ ```
115
+ {
116
+ data: // Either an array of resources or just a single resource
117
+ meta: {} // Object containing metadata, such as pagination information
118
+ included: [] // Array of included responses
119
+ }
120
+ ```
121
+
122
+ **Example:** Response from query that returns multiple listings.
123
+
124
+ ```
125
+ {
126
+ status: 200,
127
+ statusText: 'OK',
128
+ data: {
129
+ data: [
130
+ {
131
+ id: '5a8d820f-8cb9-4855-96bf-5a6e1db31362',
132
+ type: 'listing',
133
+ attributes: {
134
+ title: '...'
135
+ description: '...',
136
+
137
+ // other attributes here ...
138
+ },
139
+ relationships: {
140
+ author: {
141
+ data: {
142
+ id: '...',
143
+ type: 'user'
144
+ }
145
+ },
146
+ images: {
147
+ data: [
148
+ {
149
+ id: '...',
150
+ type: 'image'
151
+ }
152
+
153
+ // other listing images here ...
154
+ ]
155
+ }
156
+ }
157
+ }
158
+ ],
159
+ meta: {
160
+ totalItems: 210,
161
+ totalPages: 210,
162
+ page: 1,
163
+ perPage: 1
164
+ },
165
+ included: [
166
+ {
167
+ id: '...',
168
+ type: 'image',
169
+ attributes: { ... }
170
+ },
171
+ {
172
+ id: '...' ,
173
+ type: 'user',
174
+ attributes: { ... }
175
+ }
176
+
177
+ // other included resources here ...
178
+ ]
179
+ }
180
+ }
181
+ ```
182
+
183
+ ### Error response
184
+
185
+ An error response will have the following format:
186
+
187
+ ```
188
+ {
189
+ status: <HTTP Status code, 4xx or 5xx>,
190
+ statusText: <HTTP Status text>,
191
+ data: // The data returned by the API, for example:
192
+ {
193
+ errors: [
194
+ {
195
+ status: <HTTP Status code, 4xx or 5xx>,
196
+ code: // error code
197
+ title: <HTTP Status text>,
198
+ details: {
199
+ // Additional details, not part of the public API.
200
+ }
201
+ }
202
+ ]
203
+ }
204
+ }
205
+ ```
206
+
207
+ The error value is always an `instanceof` [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error).
208
+
209
+ **Please note** that the content of the `details` is not part of the public API. This means that:
210
+
211
+ - You can use `details` for debugging and error tracking.
212
+ - You SHOULD NOT write production code that depends on the content of `details`.
213
+ - The content of `details` is not well specified and will change in the future.
214
+
215
+ ## API documentation
216
+
217
+ Please see the [API documentation](https://flex-api-docs-preview.sharetribe.com/), for more information about the available endpoints, parameters and the response format.
@@ -0,0 +1,95 @@
1
+ # Configurations
2
+
3
+ There are a few configuration options that can given to the
4
+ `createInstance` method:
5
+
6
+ ``` js
7
+ const sharetribeSdk = require('sharetribe-flex-sdk');
8
+
9
+ var sdk = sharetribeSdk.createInstance({
10
+
11
+ // An API application client ID (mandatory)
12
+ clientId: "08ec69f6-d37e-414d-83eb-324e94afddf0",
13
+
14
+ // An API application client secret. Only to be used in a server
15
+ // environment and not to be exposed to a client/browser.
16
+ clientSecret: "8af2bf99c380b3a303ab90ae4012c8cd8f69d309",
17
+
18
+ // Token store
19
+ //
20
+ // Token store instance to use. Token store is where the SDK
21
+ // saves the session information.
22
+ //
23
+ // Built-in token stores:
24
+ //
25
+ // - sharetribeSdk.tokenStore.browserCookieStore
26
+ // - sharetribeSdk.tokenStore.expressCookieStore
27
+ // - sharetribeSdk.tokenStore.memoryStore
28
+ //
29
+ // Default: sharetribeSdk.tokenStore.browserCookieStore()
30
+ //
31
+ tokenStore: sharetribeSdk.tokenStore.browserCookieStore(),
32
+
33
+ // List of custom type handlers
34
+ typeHandlers: [
35
+ {
36
+ sdkType: UUID,
37
+ // "type" was renamed to "sdkType" on v1.4.0
38
+ appType: MyUuidType,
39
+ // "customType" was renamed to "appType" on v1.4.0
40
+
41
+ // Writer fn type signature must be:
42
+ // appType -> sdkType
43
+ //
44
+ // E.g.
45
+ // MyUuidType -> UUID
46
+ writer: v => new UUID(v.myUuid),
47
+
48
+ // Reader fn type signature must be:
49
+ // sdkType -> appType
50
+ //
51
+ // E.g.
52
+ // UUID -> MyUuidType
53
+ reader: v => new MyUuidType(v.uuid),
54
+ }
55
+ ],
56
+
57
+ // Node.js only.
58
+ // HTTP and HTTPS agents to be used when performing
59
+ // http and https request. This allows defining non-default
60
+ // options for agent, such as `{ keepAlive: true }`.
61
+ //
62
+ httpAgent: httpAgent,
63
+ httpsAgent: httpsAgent,
64
+
65
+ // If true and default browser token store is used,
66
+ // the cookie is never transferred without HTTPS connection.
67
+ // Default: false
68
+ secure: false,
69
+
70
+ // SDK uses Transit format to communicate with the API.
71
+ // If this configuration is `true` a verbose Transit mode is enabled.
72
+ // Useful for development.
73
+ // Default: false
74
+ transitVerbose: false,
75
+
76
+ // The API base URL (optional)
77
+ // Defaults to Sharetribe production (https://flex-api.sharetribe.com)
78
+ // Change this if you want to point the SDK to somewhere else (like localhost).
79
+ // Useful mainly for Sharetribe's internal development
80
+ baseUrl: "https://the-api-base-url.example.sharetribe.com/",
81
+
82
+ // Allow use of Client Secret in browser (optional, defaults to false)
83
+ //
84
+ // Privileged Marketplace API calls that use Client Secret are meant to be done
85
+ // from a secure context, e.g. from a private Node.js server. Using Client Secret
86
+ // in an open website exposes the it to the public.
87
+ //
88
+ // By default, the SDK will display a warning if Client Secret is used in browser
89
+ // but if you know what you are doing, and you have secured the website properly so
90
+ // that Client Secret is not leaked, you can suppress the warning by setting this
91
+ // to `true`.
92
+ dangerouslyAllowClientSecretInBrowser: false
93
+
94
+ });
95
+ ```
@@ -0,0 +1,131 @@
1
+ # Developing SDK
2
+
3
+ Here are the commands you need when developing the SDK:
4
+
5
+ #### Install dependencies:
6
+
7
+ ```sh
8
+ $ yarn install
9
+ ```
10
+
11
+ #### Build the package:
12
+
13
+ ```sh
14
+ $ yarn run build
15
+ ```
16
+
17
+ #### Run tests:
18
+
19
+ ```sh
20
+ $ yarn test
21
+ ```
22
+
23
+ #### Run linter:
24
+
25
+ ```sh
26
+ $ yarn run lint
27
+ ```
28
+
29
+ #### Format code (run Prettier):
30
+
31
+ ```sh
32
+ $ yarn run format
33
+ ```
34
+
35
+ #### Move the built files to `/docs` folder
36
+
37
+ Docpress only looks for files in the project root and `/docs` folder.
38
+
39
+ ```sh
40
+ $ cp build/sharetribe-flex-sdk-web.js docs/sharetribe-flex-sdk-web.js
41
+ ```
42
+
43
+ #### Serve the docpress docs
44
+
45
+ ```sh
46
+ $ yarn run serve-docs
47
+ ```
48
+
49
+ #### Build the docpress docs
50
+
51
+ ```sh
52
+ $ yarn run build-docs
53
+ ```
54
+
55
+ #### Update the Github Pages
56
+
57
+ ```sh
58
+ $ yarn run build
59
+ $ cp build/sharetribe-flex-sdk-web.js docs/sharetribe-flex-sdk-web.js
60
+ $ yarn run build-docs
61
+ $ mv _docpress ../
62
+ $ git checkout gh-pages
63
+ $ cp -r ../_docpress/* ./
64
+ $ rm -r ../_docpress
65
+ $ // git add, commit, push
66
+ ```
67
+
68
+ #### Release a new version to NPM
69
+
70
+ 1. Update version in `package.json`
71
+
72
+ 1. Update CHANGELOG.md
73
+ - Move everything in Unreleased to the corresponding version section
74
+
75
+ 1. Login as `sharetribe` with `npm login`
76
+ - check credentials from password manager
77
+
78
+ 1. Publish with `npm publish`
79
+
80
+ 1. Add a new tag
81
+
82
+ ```bash
83
+ git tag -a v1.2.3 -m v1.2.3
84
+ ```
85
+
86
+ 1. Update `latest` tag
87
+
88
+ ```bash
89
+ git push origin :refs/tags/latest
90
+ git tag -f -a latest -m latest
91
+ ```
92
+
93
+ 1. Push the tag
94
+
95
+ ```bash
96
+ git push --tags
97
+ ```
98
+
99
+ 1. Go to [Github releases and draft a new release](https://github.com/sharetribe/flex-sdk-js/releases/new)
100
+
101
+ Use the following content:
102
+
103
+ **Tag version:** \<the newly created tag\>
104
+
105
+ **Release title:** \<version number\>
106
+
107
+ **Describe this release:**
108
+
109
+ ```markdown
110
+ <copy the content from the [CHANGELOG.md](CHANGELOG.md)>
111
+ ```
112
+
113
+ Here's a full example:
114
+
115
+ **Tag version:** v1.2.3
116
+
117
+ **Release title:** v1.2.3
118
+
119
+ **Describe this release:**
120
+
121
+ ```markdown
122
+ ### Added
123
+
124
+ - Added many things
125
+
126
+ ### Changed
127
+
128
+ - Changed this and that
129
+ ```
130
+
131
+ 1. Announce the new version in Slack
@@ -0,0 +1,14 @@
1
+ {
2
+ "github": "sharetribe/flex-sdk-js",
3
+ "scripts": [
4
+ "scripts.js",
5
+ "sharetribe-flex-sdk-web.js"
6
+ ],
7
+ "css": [
8
+ "styles.css"
9
+ ],
10
+ "googleAnalytics": {
11
+ "id": "UA-10178914-13",
12
+ "domain": "sharetribe.github.io"
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ # Features
2
+
3
+ The SDK handles **groundwork** such as authentication, renewing
4
+ authentication tokens and serializing and deserializing data to and
5
+ from JavaScript data structures, so that you don't need to worry about
6
+ it.
7
+
8
+ The main SDK features are:
9
+
10
+ - [Promise-based](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) asynchronous API.
11
+ - Universal: Runs in any JavaScript environment, including [Node.js](https://nodejs.org/), browser and [React Native](https://facebook.github.io/react-native/) (experimental).
12
+ - Predictable mapping from SDK methods to API endpoints.
13
+ - [Types](./types.md) to represent UUID, money, geolocation, etc. with automatic serialization and deserialization.
14
+ - [Easy authentication](./authentication.md).