pryv 2.2.0 → 2.3.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 (46) hide show
  1. package/package.json +11 -45
  2. package/src/Auth/AuthController.js +43 -50
  3. package/src/Auth/AuthStates.js +12 -12
  4. package/src/Auth/LoginMessages.js +17 -14
  5. package/src/Auth/index.js +18 -15
  6. package/src/Browser/CookieUtils.js +37 -27
  7. package/src/Browser/LoginButton.js +42 -37
  8. package/src/Browser/index.js +16 -42
  9. package/src/Connection.js +102 -95
  10. package/src/Service.js +47 -45
  11. package/src/ServiceAssets.js +42 -34
  12. package/src/browser-index-bundle.js +8 -0
  13. package/src/browser-index.js +7 -0
  14. package/src/index.d.ts +36 -48
  15. package/src/index.js +20 -3
  16. package/src/lib/browser-getEventStreamed.js +21 -19
  17. package/src/lib/json-parser.js +23 -24
  18. package/src/utils.js +55 -43
  19. package/test/Browser.AuthController.test.js +19 -21
  20. package/test/Browser.test.js +23 -26
  21. package/test/Connection.test.js +135 -151
  22. package/test/Service.test.js +30 -44
  23. package/test/ServiceAssets.test.js +16 -22
  24. package/test/browser-index.html +26 -0
  25. package/test/utils.test.js +30 -35
  26. package/.jsdoc-conf.json +0 -29
  27. package/.mocharc.js +0 -13
  28. package/LICENSE.md +0 -27
  29. package/README.md +0 -742
  30. package/scripts/setup-environment-dev.sh +0 -28
  31. package/scripts/upload.sh +0 -15
  32. package/src/Pryv.js +0 -19
  33. package/src/index-socket.io-monitor.js +0 -4
  34. package/src/index.html +0 -17
  35. package/test/browser-index.js +0 -11
  36. package/test/browser-tests.html +0 -31
  37. package/test/helpers.js +0 -8
  38. package/test/load-test-account.js +0 -108
  39. package/test/test-data.js +0 -95
  40. package/web-demos/auth-with-redirection.html +0 -72
  41. package/web-demos/auth.html +0 -77
  42. package/web-demos/custom-login-button.html +0 -158
  43. package/web-demos/index.html +0 -186
  44. package/web-demos/service-info.json +0 -13
  45. package/web-demos/stream-examples.html +0 -80
  46. package/webpack.config.js +0 -83
package/src/Service.js CHANGED
@@ -1,25 +1,27 @@
1
-
1
+ /**
2
+ * @license
3
+ * [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4
+ */
2
5
  const utils = require('./utils.js');
3
6
  // Connection is required at the end of this file to allow circular requires.
4
7
  const Assets = require('./ServiceAssets.js');
5
8
 
6
-
7
9
  /**
8
- * @class Pryv.Service
10
+ * @class pryv.Service
9
11
  * A Pryv.io deployment is a unique "Service", as an example **Pryv Lab** is a service, deployed with the domain name **pryv.me**.
10
- *
11
- * `Pryv.Service` exposes tools to interact with Pryv.io at a "Platform" level.
12
+ *
13
+ * `pryv.Service` exposes tools to interact with Pryv.io at a "Platform" level.
12
14
  *
13
15
  * ##### Initizalization with a service info URL
14
- ```javascript
15
- const service = new Pryv.Service('https://reg.pryv.me/service/info');
16
+ ```js
17
+ const service = new pryv.Service('https://reg.pryv.me/service/info');
16
18
  ```
17
19
 
18
20
  - With the content of a serviceInfo configuration
19
21
 
20
22
  Service information properties can be overriden with specific values. This might be usefull to test new designs on production platforms.
21
23
 
22
- ```javascript
24
+ ```js
23
25
  const serviceInfoUrl = 'https://reg.pryv.me/service/info';
24
26
  const serviceCustomizations = {
25
27
  name: 'Pryv Lab 2',
@@ -27,68 +29,67 @@ const serviceCustomizations = {
27
29
  definitions: 'https://pryv.github.io/assets-pryv.me/index.json'
28
30
  }
29
31
  }
30
- const service = new Pryv.Service(serviceInfoUrl, serviceCustomizations);
31
- ```
32
+ const service = new pryv.Service(serviceInfoUrl, serviceCustomizations);
33
+ ```
32
34
 
33
- * @memberof Pryv
34
- *
35
+ * @memberof pryv
36
+ *
35
37
  * @constructor
36
38
  * @param {string} serviceInfoUrl Url point to /service/info of a Pryv platform see: {@link https://api.pryv.com/reference/#service-info}
37
39
  */
38
40
  class Service {
39
-
40
41
  constructor (serviceInfoUrl, serviceCustomizations) {
41
- this._pryvServiceInfo = null;
42
+ this._serviceInfo = null;
42
43
  this._assets = null;
43
44
  this._polling = false;
44
- this._pryvServiceInfoUrl = serviceInfoUrl;
45
+ this._serviceInfoUrl = serviceInfoUrl;
45
46
  this._pryvServiceCustomizations = serviceCustomizations;
46
47
  }
47
48
 
48
49
  /**
49
50
  * Return service info parameters info known of fetch it if needed.
50
- * Example
51
- * - name of a platform
52
- * `const serviceName = await service.info().name`
53
- * @see PryvServiceInfo For details on available properties.
51
+ * Example
52
+ * - name of a platform
53
+ * `const serviceName = await service.info().name`
54
+ * @see ServiceInfo For details on available properties.
54
55
  * @param {boolean?} forceFetch If true, will force fetching service info.
55
- * @returns {Promise<PryvServiceInfo>} Promise to Service info Object
56
+ * @returns {Promise<ServiceInfo>} Promise to Service info Object
56
57
  */
57
58
  async info (forceFetch) {
58
- if (forceFetch || !this._pryvServiceInfo) {
59
+ if (forceFetch || !this._serviceInfo) {
59
60
  let baseServiceInfo = {};
60
- if (this._pryvServiceInfoUrl) {
61
- const res = await utils.superagent.get(this._pryvServiceInfoUrl).set('Access-Control-Allow-Origin', '*').set('accept', 'json');
61
+ if (this._serviceInfoUrl) {
62
+ const res = await utils.superagent.get(this._serviceInfoUrl).set('Access-Control-Allow-Origin', '*').set('accept', 'json');
62
63
  baseServiceInfo = res.body;
63
64
  }
64
65
  Object.assign(baseServiceInfo, this._pryvServiceCustomizations);
65
66
  this.setServiceInfo(baseServiceInfo);
66
67
  }
67
- return this._pryvServiceInfo;
68
+ return this._serviceInfo;
68
69
  }
69
70
 
70
71
  /**
71
72
  * @private
72
- * @param {PryvServiceInfo} serviceInfo
73
+ * @param {ServiceInfo} serviceInfo
73
74
  */
74
75
  setServiceInfo (serviceInfo) {
75
76
  if (!serviceInfo.name) {
76
77
  throw new Error('Invalid data from service/info');
77
78
  }
78
- // cleanup serviceInfo for eventual url not finishing by "/"
79
+ // cleanup serviceInfo for eventual url not finishing by "/"
79
80
  // code will be obsolete with next version of register
80
81
  ['access', 'api', 'register'].forEach((key) => {
81
82
  if (serviceInfo[key].slice(-1) !== '/') {
82
83
  serviceInfo[key] += '/';
83
84
  }
84
85
  });
85
- this._pryvServiceInfo = serviceInfo;
86
+ this._serviceInfo = serviceInfo;
86
87
  }
87
88
 
88
89
  /**
89
90
  * Return assets property content
90
91
  * @param {boolean?} forceFetch If true, will force fetching service info.
91
- * @returns {Promise<ServiceAssets>} Promise to ServiceAssets
92
+ * @returns {Promise<ServiceAssets>} Promise to ServiceAssets
92
93
  */
93
94
  async assets (forceFetch) {
94
95
  if (!forceFetch && this._assets) {
@@ -106,17 +107,17 @@ class Service {
106
107
 
107
108
  /**
108
109
  * Return service info parameters info known or null if not yet loaded
109
- * @returns {PryvServiceInfo} Service Info definition
110
+ * @returns {ServiceInfo} Service Info definition
110
111
  */
111
112
  infoSync () {
112
- return this._pryvServiceInfo;
113
+ return this._serviceInfo;
113
114
  }
114
115
 
115
116
  /**
116
117
  * Return an API Endpoint from a username and token
117
118
  * @param {string} username
118
119
  * @param {string} [token]
119
- * @return {PryvApiEndpoint}
120
+ * @return {APIEndpoint}
120
121
  */
121
122
  async apiEndpointFor (username, token) {
122
123
  const serviceInfo = await this.info();
@@ -124,25 +125,25 @@ class Service {
124
125
  }
125
126
 
126
127
  /**
127
- * Return an API Endpoint from a username and token and a PryvServiceInfo.
128
+ * Return an API Endpoint from a username and token and a ServiceInfo.
128
129
  * This is method is rarely used. See **apiEndpointFor** as an alternative.
129
- * @param {PryvServiceInfo} serviceInfo
130
+ * @param {ServiceInfo} serviceInfo
130
131
  * @param {string} username
131
132
  * @param {string} [token]
132
- * @return {PryvApiEndpoint}
133
+ * @return {APIEndpoint}
133
134
  */
134
135
  static buildAPIEndpoint (serviceInfo, username, token) {
135
136
  const endpoint = serviceInfo.api.replace('{username}', username);
136
- return utils.buildPryvApiEndpoint({ endpoint: endpoint, token: token });
137
+ return utils.buildAPIEndpoint({ endpoint: endpoint, token: token });
137
138
  }
138
139
 
139
140
  /**
140
- * Issue a "login call on the Service" return a Connection on success
141
+ * Issue a "login call on the Service" return a Connection on success
141
142
  * **! Warning**: the token of the connection will be a "Personal" token that expires
142
143
  * @see https://api.pryv.com/reference-full/#login-user
143
- * @param {string} username
144
- * @param {string} password
145
- * @param {string} appId
144
+ * @param {string} username
145
+ * @param {string} password
146
+ * @param {string} appId
146
147
  * @param {string} [originHeader=service-info.register] Only for Node.js. If not set will use the register value of service info. In browsers this will overridden by current page location.
147
148
  * @throws {Error} on invalid login
148
149
  */
@@ -167,10 +168,11 @@ class Service {
167
168
  this // Pre load Connection with service
168
169
  );
169
170
  } catch (e) {
170
- if (e.response && e.response.body
171
- && e.response.body.error
172
- && e.response.body.error.message) {
173
- throw new Error(e.response.body.error.message)
171
+ if (e.response &&
172
+ e.response.body &&
173
+ e.response.body.error &&
174
+ e.response.body.error.message) {
175
+ throw new Error(e.response.body.error.message);
174
176
  }
175
177
  }
176
178
  }
@@ -183,7 +185,7 @@ const Connection = require('./Connection');
183
185
 
184
186
  /**
185
187
  * Object to handle Pryv Service Informations https://api.pryv.com/reference/#service-info
186
- * @typedef {Object} PryvServiceInfo
188
+ * @typedef {Object} ServiceInfo
187
189
  * @property {string} register The URL of the register service.
188
190
  * @property {string} access The URL of the access page.
189
191
  * @property {string} api The API endpoint format.
@@ -191,7 +193,7 @@ const Connection = require('./Connection');
191
193
  * @property {string} home The URL of the platform's home page.
192
194
  * @property {string} support The email or URL of the support page.
193
195
  * @property {string} terms The terms and conditions, in plain text or the URL displaying them.
194
- * @property {string} eventTypes The URL of the list of validated event types.
196
+ * @property {string} eventTypes The URL of the list of validated event types.
195
197
  * @property {Object} [assets] Holder for service specific Assets (icons, css, ...)
196
198
  * @property {String} [assets.definitions] URL to json object with assets definitions
197
199
  */
@@ -1,10 +1,17 @@
1
+ /**
2
+ * @license
3
+ * [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4
+ */
1
5
  const utils = require('./utils.js');
6
+
7
+ /* global location */
8
+
2
9
  /**
3
10
  * Holds Pryv Service informations.
4
- *
11
+ *
5
12
  * It's returned by `service.assets()`
6
13
  *
7
- * @memberof Pryv
14
+ * @memberof pryv
8
15
  **/
9
16
  class ServiceAssets {
10
17
  /**
@@ -12,7 +19,7 @@ class ServiceAssets {
12
19
  * @param { object} assets The content of service/info.assets properties.
13
20
  * @param { string } pryvServiceAssetsSourceUrl Url point to assets of the service of a Pryv platform: https://api.pryv.com/reference/#service-info property `assets.src`
14
21
  */
15
- constructor(assets, assetsURL) {
22
+ constructor (assets, assetsURL) {
16
23
  this._assets = assets;
17
24
  this._assetsURL = assetsURL;
18
25
  }
@@ -22,7 +29,7 @@ class ServiceAssets {
22
29
  * @param {string} pryvServiceAssetsSourceUrl
23
30
  * @returns {ServiceAssets}
24
31
  */
25
- static async setup(pryvServiceAssetsSourceUrl) {
32
+ static async setup (pryvServiceAssetsSourceUrl) {
26
33
  const res = await utils.superagent.get(pryvServiceAssetsSourceUrl).set('accept', 'json');
27
34
  return new ServiceAssets(res.body, pryvServiceAssetsSourceUrl);
28
35
  }
@@ -30,9 +37,9 @@ class ServiceAssets {
30
37
  /**
31
38
  * get a value from path separated by `:`
32
39
  * exemple of key `lib-js:buttonSignIn`
33
- * @param {string} [keyPath] if null, will return the all assets
40
+ * @param {string} [keyPath] if null, will return the all assets
34
41
  */
35
- get(keyPath) {
42
+ get (keyPath) {
36
43
  let result = Object.assign({}, this._assets);
37
44
  if (keyPath) {
38
45
  keyPath.split(':').forEach((key) => {
@@ -47,12 +54,12 @@ class ServiceAssets {
47
54
  * get an Url from path separated by `:`
48
55
  * identical to doing assets.relativeURL(assets.get(keyPath))
49
56
  * exemple of key `lib-js:buttonSignIn`
50
- * @param {string} [keyPath] if null, will return the all assets
57
+ * @param {string} [keyPath] if null, will return the all assets
51
58
  */
52
- getUrl(keyPath) {
59
+ getUrl (keyPath) {
53
60
  const url = this.get(keyPath);
54
61
  if (typeof url !== 'string') {
55
- throw new Error(url + ' returned ' + value);
62
+ throw new Error(`Unexpected value for ${keyPath}: ${url}`);
56
63
  }
57
64
  return this.relativeURL(url);
58
65
  }
@@ -60,16 +67,16 @@ class ServiceAssets {
60
67
  /**
61
68
  * get relativeUrl
62
69
  */
63
- relativeURL(url) {
70
+ relativeURL (url) {
64
71
  return relPathToAbs(this._assets.baseUrl || this._assetsURL, url);
65
72
  }
66
73
 
67
- //---------------- Default service ressources
68
-
74
+ // ---------------- Default service resources
75
+
69
76
  /**
70
77
  * Set all defaults Favicon, CSS
71
78
  */
72
- async setAllDefaults() {
79
+ async setAllDefaults () {
73
80
  this.setFavicon();
74
81
  await this.loadCSS();
75
82
  }
@@ -77,8 +84,8 @@ class ServiceAssets {
77
84
  /**
78
85
  * Set service Favicon to Web Page
79
86
  */
80
- setFavicon() {
81
- var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
87
+ setFavicon () {
88
+ const link = document.querySelector("link[rel*='icon']") || document.createElement('link');
82
89
  link.type = 'image/x-icon';
83
90
  link.rel = 'shortcut icon';
84
91
  link.href = this.relativeURL(this._assets.favicon.default.url);
@@ -88,40 +95,41 @@ class ServiceAssets {
88
95
  /**
89
96
  * Set default service CSS
90
97
  */
91
- async loadCSS() {
98
+ async loadCSS () {
92
99
  loadCSS(this.relativeURL(this._assets.css.default.url));
93
100
  }
94
101
 
95
102
  // ---- Login
96
103
 
97
104
  /**
98
- * Load CSS for Login button
99
- */
105
+ * Load CSS for Login button
106
+ */
100
107
  async loginButtonLoadCSS () {
101
108
  loadCSS(this.relativeURL(this._assets['lib-js'].buttonSignIn.css));
102
109
  }
103
110
 
104
111
  /**
105
- * Get HTML for Login Button
106
- */
107
- async loginButtonGetHTML() {
112
+ * Get HTML for Login Button
113
+ */
114
+ async loginButtonGetHTML () {
108
115
  const res = await utils.superagent.get(this.relativeURL(this._assets['lib-js'].buttonSignIn.html)).set('accept', 'html');
109
116
  return res.text;
110
117
  }
111
118
 
112
- /**
113
- * Get Messages strings for Login Button
114
- */
115
- async loginButtonGetMessages() {
119
+ /**
120
+ * Get Messages strings for Login Button
121
+ */
122
+ async loginButtonGetMessages () {
116
123
  const res = await utils.superagent.get(this.relativeURL(this._assets['lib-js'].buttonSignIn.messages)).set('accept', 'json');
117
124
  return res.body;
118
125
  }
119
-
120
126
  }
121
127
 
122
- function loadCSS(url) {
123
- var head = document.getElementsByTagName('head')[0];
124
- var link = document.createElement('link');
128
+ module.exports = ServiceAssets;
129
+
130
+ function loadCSS (url) {
131
+ const head = document.getElementsByTagName('head')[0];
132
+ const link = document.createElement('link');
125
133
  link.id = url;
126
134
  link.rel = 'stylesheet';
127
135
  link.type = 'text/css';
@@ -130,8 +138,11 @@ function loadCSS(url) {
130
138
  head.appendChild(link);
131
139
  }
132
140
 
141
+ /* HACK: disabling linting until code is cleaned up */
142
+ /* eslint-disable */
143
+
133
144
  /*\
134
- |*| Modified version of
145
+ |*| Modified version of
135
146
  |*| :: translate relative paths to absolute paths ::
136
147
  |*|
137
148
  |*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
@@ -154,9 +165,6 @@ function relPathToAbs (baseUrlString, sRelPath) {
154
165
  sDir = (sDir + sPath.substring(nStart, nEnd)).replace(new RegExp("(?:\\\/+[^\\\/]*){0," + ((nUpLn - 1) / 3) + "}$"),
155
166
  "/");
156
167
  }
157
- let portStr = baseLocation.port ? ':' + baseLocation.port : '';
168
+ const portStr = baseLocation.port ? ':' + baseLocation.port : '';
158
169
  return baseLocation.protocol + '//' + baseLocation.hostname + portStr + sDir + sPath.substr(nStart);
159
170
  }
160
-
161
-
162
- module.exports = ServiceAssets;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4
+ */
5
+ const pryv = require('./browser-index');
6
+ require('@pryv/socket.io')(pryv);
7
+ require('@pryv/monitor')(pryv);
8
+ module.exports = pryv;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4
+ */
5
+ // make lib available as `Pryv` (with capital P, deprecated) for backward-compatibility with apps importing via <script>
6
+ // TODO: remove deprecated alias with next major version
7
+ module.exports = global.Pryv = require('./index');
package/src/index.d.ts CHANGED
@@ -168,7 +168,7 @@ declare module 'pryv' {
168
168
 
169
169
  type EditMetadata = 'created' | 'createdBy' | 'modified' | 'modifiedBy';
170
170
 
171
- export type ApiCallMethods = {
171
+ export type APICallMethods = {
172
172
  // mfa
173
173
  'mfa.challenge': {
174
174
  params: null;
@@ -516,20 +516,20 @@ declare module 'pryv' {
516
516
  ) extends (k: infer I) => any
517
517
  ? I
518
518
  : never;
519
- type ApiCallResultUnion = ApiCallMethods[keyof ApiCallMethods]['res'];
520
- type ApiCallResultTypes = UnionToIntersection<
521
- NonNullable<ApiCallResultUnion>
519
+ type APICallResultUnion = APICallMethods[keyof APICallMethods]['res'];
520
+ type APICallResultTypes = UnionToIntersection<
521
+ NonNullable<APICallResultUnion>
522
522
  >;
523
523
 
524
524
  type PossibleError = {
525
525
  error?: Error;
526
526
  };
527
527
 
528
- type ApiCallResult<K extends keyof ApiCallMethods> =
529
- ApiCallMethods[K]['res'] & PossibleError;
528
+ type APICallResult<K extends keyof APICallMethods> =
529
+ APICallMethods[K]['res'] & PossibleError;
530
530
 
531
- export type ApiCallResultHandler<K extends keyof ApiCallMethods> = (
532
- result: ApiCallResult<K>,
531
+ export type APICallResultHandler<K extends keyof APICallMethods> = (
532
+ result: APICallResult<K>,
533
533
  ) => Promise<any>;
534
534
  export type StreamedEventsHandler = (event: Event) => void;
535
535
 
@@ -546,36 +546,36 @@ declare module 'pryv' {
546
546
  export type EventFileCreationParams = Partial<
547
547
  Omit<Event, 'attachments' | EditMetadata>
548
548
  >;
549
- export type ApiCall<K extends keyof ApiCallMethods = keyof ApiCallMethods> =
550
- K extends keyof ApiCallMethods
549
+ export type APICall<K extends keyof APICallMethods = keyof APICallMethods> =
550
+ K extends keyof APICallMethods
551
551
  ? {
552
552
  method: K;
553
- params: ApiCallMethods[K]['params'];
554
- handleResult?: ApiCallResultHandler<K>;
553
+ params: APICallMethods[K]['params'];
554
+ handleResult?: APICallResultHandler<K>;
555
555
  }
556
556
  : never;
557
557
 
558
- export type TypedApiCallResult = ApiCallResultTypes & PossibleError;
558
+ export type TypedAPICallResult = APICallResultTypes & PossibleError;
559
559
 
560
- export type ApiCallProgressHandler = (percentage: number) => void;
560
+ export type APICallProgressHandler = (percentage: number) => void;
561
561
 
562
562
  interface AccessInfo extends Access {
563
563
  calls: KeyValue;
564
564
  user: KeyValue;
565
565
  }
566
566
 
567
- type EventApiCallRes = {
567
+ type EventAPICallRes = {
568
568
  event?: Event;
569
569
  } & PossibleError;
570
570
 
571
571
  export interface Connection {
572
- new (pryvApiEndpoint: string, service?: Service): Connection;
572
+ new (apiEndpoint: string, service?: Service): Connection;
573
573
  get service(): Service;
574
574
  username(): Promise<string>;
575
- api<Calls extends ApiCall[] = ApiCall[]>(
575
+ api<Calls extends APICall[] = APICall[]>(
576
576
  apiCalls: Calls,
577
- res?: ApiCallProgressHandler[],
578
- ): Promise<Array<TypedApiCallResult>>;
577
+ res?: APICallProgressHandler[],
578
+ ): Promise<Array<TypedAPICallResult>>;
579
579
  getEventsStreamed(
580
580
  queryParams: Partial<EventQueryParamsStreamQuery>,
581
581
  forEachEvent: StreamedEventsHandler,
@@ -583,16 +583,16 @@ declare module 'pryv' {
583
583
  createEventWithFile(
584
584
  params: EventFileCreationParams,
585
585
  filePath: string | Buffer | Blob,
586
- ): Promise<EventApiCallRes>;
586
+ ): Promise<EventAPICallRes>;
587
587
  createEventWithFormData(
588
588
  params: EventFileCreationParams,
589
589
  formData: FormData,
590
- ): Promise<EventApiCallRes>;
590
+ ): Promise<EventAPICallRes>;
591
591
  createEventWithFileFromBuffer(
592
592
  params: EventFileCreationParams,
593
- bufferData: string | Buffer,
593
+ bufferData: string | Buffer | Blob,
594
594
  filename: string,
595
- ): Promise<EventApiCallRes>;
595
+ ): Promise<EventAPICallRes>;
596
596
  addPointsToHFEvent(
597
597
  id: Identifier,
598
598
  fields: string[],
@@ -615,7 +615,7 @@ declare module 'pryv' {
615
615
  };
616
616
  };
617
617
 
618
- export type PryvServiceInfo = {
618
+ export type ServiceInfo = {
619
619
  register: string;
620
620
  access: string;
621
621
  api: string;
@@ -625,6 +625,10 @@ declare module 'pryv' {
625
625
  terms: string;
626
626
  eventTypes: string;
627
627
  version: string;
628
+ assets: {
629
+ definitions: string;
630
+ };
631
+ serial: string;
628
632
  };
629
633
 
630
634
  export type AssetsConfig = {
@@ -650,10 +654,10 @@ declare module 'pryv' {
650
654
  serviceInfoUrl: string,
651
655
  serviceCustomizations?: serviceCustomizations,
652
656
  ): Service;
653
- info(forceFetch?: boolean): Promise<PryvServiceInfo>;
654
- setServiceInfo(serviceInfo: Partial<PryvServiceInfo>): Promise<void>;
657
+ info(forceFetch?: boolean): Promise<ServiceInfo>;
658
+ setServiceInfo(serviceInfo: Partial<ServiceInfo>): Promise<void>;
655
659
  assets(forceFetch?: boolean): Promise<AssetsConfig>;
656
- infoSync(): PryvServiceInfo | null;
660
+ infoSync(): ServiceInfo | null;
657
661
  apiEndpointFor(username: string, token: string): Promise<string>;
658
662
  login(
659
663
  username: string,
@@ -676,22 +680,6 @@ declare module 'pryv' {
676
680
  | 'ACCEPTED'
677
681
  | 'SIGNOUT';
678
682
 
679
- type ServiceInfo = {
680
- access: string;
681
- api: string;
682
- assets: {
683
- definitions: string;
684
- };
685
- eventTypes: string;
686
- home: string;
687
- name: string;
688
- register: string;
689
- serial: string;
690
- support: string;
691
- terms: string;
692
- version: string;
693
- };
694
-
695
683
  type StateChangeTypes = {
696
684
  LOADING: {};
697
685
  INITIALIZED: {
@@ -816,15 +804,15 @@ declare module 'pryv' {
816
804
  serviceInfoFromUrl: getServiceInfoFromURL;
817
805
  }
818
806
 
819
- type TokenAndApiEndpoint = {
807
+ type TokenAndAPIEndpoint = {
820
808
  endpoint: string;
821
809
  token: string;
822
810
  };
823
811
 
824
812
  export interface utils {
825
813
  isBrowser(): boolean;
826
- extractTokenAndApiEndpoint(pryvApiEndpoint: string): TokenAndApiEndpoint;
827
- buildPryvApiEndpoint(tokenAndApi: TokenAndApiEndpoint): string;
814
+ extractTokenAndAPIEndpoint(apiEndpoint: string): TokenAndAPIEndpoint;
815
+ buildAPIEndpoint(tokenAndAPI: TokenAndAPIEndpoint): string;
828
816
  browserIsMobileOrTablet(navigator: string): boolean;
829
817
  cleanURLFromPrYvParams(url: string): string;
830
818
  getQueryParamsFromURL(url: string): KeyValue;
@@ -832,7 +820,7 @@ declare module 'pryv' {
832
820
 
833
821
  type version = string;
834
822
 
835
- let Pryv: {
823
+ let pryv: {
836
824
  Service: Service;
837
825
  Connection: Connection;
838
826
  Auth: Auth;
@@ -841,5 +829,5 @@ declare module 'pryv' {
841
829
  version: version;
842
830
  };
843
831
 
844
- export default Pryv;
832
+ export default pryv;
845
833
  }
package/src/index.js CHANGED
@@ -1,3 +1,20 @@
1
- const Pryv = require('./Pryv');
2
-
3
- module.exports = Pryv;
1
+ /**
2
+ * @license
3
+ * [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4
+ */
5
+ /**
6
+ * `pryv` library
7
+ * @exports pryv
8
+ * @property {pryv.Service} Service - To interact with Pryv.io at a "Platform level"
9
+ * @property {pryv.Connection} Connection - To interact with an individual's (user) data set
10
+ * @property {pryv.Browser} Browser - Browser Tools - Access request helpers and visuals (button)
11
+ * @property {pryv.utils} utils - Exposes **superagent** for HTTP calls and tools to manipulate Pryv's API Endpoints
12
+ */
13
+ module.exports = {
14
+ Service: require('./Service'),
15
+ Connection: require('./Connection'),
16
+ Auth: require('./Auth'),
17
+ Browser: require('./Browser'),
18
+ utils: require('./utils'),
19
+ version: require('../package.json').version
20
+ };