pryv 2.1.8 → 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 +12 -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 +833 -0
  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 +164 -162
  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 -723
  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 -92
  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 -71
@@ -1,6 +1,8 @@
1
- const expect = chai.expect;
2
-
3
- const testData = require('./test-data.js');
1
+ /**
2
+ * @license
3
+ * [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4
+ */
5
+ /* global describe, it, before, after, expect, Browser, pryv, testData */
4
6
 
5
7
  describe('ServiceAssets', function () {
6
8
  let removeZombie = false;
@@ -9,7 +11,7 @@ describe('ServiceAssets', function () {
9
11
  this.timeout(5000);
10
12
  await testData.prepare();
11
13
  });
12
-
14
+
13
15
  before(async () => {
14
16
  if (typeof document !== 'undefined') return; // in browser
15
17
  removeZombie = true;
@@ -21,59 +23,51 @@ describe('ServiceAssets', function () {
21
23
  });
22
24
 
23
25
  after(async () => {
24
- if (! removeZombie) return; // in browser
26
+ if (!removeZombie) return; // in browser
25
27
  delete global.document;
26
- delete global.window;
27
- delete global.location;
28
+ delete global.window;
29
+ delete global.location;
28
30
  });
29
31
 
30
32
  it('relativeURL()', async () => {
31
-
32
- const pryvService = new Pryv.Service(null, testData.serviceInfo);
33
+ const pryvService = new pryv.Service(null, testData.serviceInfo);
33
34
  const assets = await pryvService.assets();
34
35
  expect(assets.relativeURL('./toto')).to.eql(testData.serviceInfo.assets.definitions.replace('index.json', 'toto'));
35
-
36
36
  });
37
37
 
38
38
  it('setAllDefaults()', async () => {
39
- const pryvService = new Pryv.Service(null, testData.serviceInfo);
39
+ const pryvService = new pryv.Service(null, testData.serviceInfo);
40
40
  const assets = await pryvService.assets();
41
41
  await assets.setAllDefaults();
42
-
43
42
  });
44
43
 
45
44
  it('Load all external elements', async () => {
46
- const pryvService = new Pryv.Service(null, testData.serviceInfo);
45
+ const pryvService = new pryv.Service(null, testData.serviceInfo);
47
46
  const assets = await pryvService.assets();
48
-
49
-
47
+
50
48
  await assets.loginButtonLoadCSS();
51
49
  await assets.loginButtonGetHTML();
52
50
  await assets.loginButtonGetMessages();
53
-
54
51
  });
55
52
 
56
53
  it('.get() returns all assets', async () => {
57
- const pryvService = new Pryv.Service(null, testData.serviceInfo);
54
+ const pryvService = new pryv.Service(null, testData.serviceInfo);
58
55
  const assets = await pryvService.assets();
59
56
  const allAssets = await assets.get();
60
57
  expect(allAssets.favicon.default.url).to.eql('favicon.ico');
61
58
  });
62
59
 
63
60
  it('.get(keyPath) ', async () => {
64
- const pryvService = new Pryv.Service(null, testData.serviceInfo);
61
+ const pryvService = new pryv.Service(null, testData.serviceInfo);
65
62
  const assets = await pryvService.assets();
66
63
  const faviconUrl = await assets.get('favicon:default:url');
67
64
  expect(faviconUrl).to.eql('favicon.ico');
68
65
  });
69
66
 
70
67
  it('.getUrl(keyPath) ', async () => {
71
- const pryvService = new Pryv.Service(null, testData.serviceInfo);
68
+ const pryvService = new pryv.Service(null, testData.serviceInfo);
72
69
  const assets = await pryvService.assets();
73
70
  const faviconUrl = await assets.getUrl('favicon:default:url');
74
71
  expect(faviconUrl).to.eql(testData.serviceInfo.assets.definitions.replace('index.json', 'favicon.ico'));
75
72
  });
76
-
77
73
  });
78
-
79
-
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Pryv JS lib browser tests</title>
5
+ <link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
6
+ </head>
7
+
8
+ <body>
9
+ <div id="mocha"></div>
10
+ <script src="https://unpkg.com/chai/chai.js"></script>
11
+ <script src="https://unpkg.com/mocha/mocha.js"></script>
12
+
13
+ <script class="mocha-init">
14
+ mocha.setup('bdd');
15
+ mocha.setup({ignoreLeaks: true});
16
+ </script>
17
+
18
+ <!-- Files cf. webpack config -->
19
+ <script src="pryv.js"></script>
20
+ <script src="tests.js"></script>
21
+
22
+ <script>
23
+ mocha.run();
24
+ </script>
25
+ </body>
26
+ </html>
@@ -1,68 +1,63 @@
1
-
2
- const should = chai.should();
3
- const expect = chai.expect;
4
-
5
- const testData = require('./test-data.js');
1
+ /**
2
+ * @license
3
+ * [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4
+ */
5
+ /* global describe, it, before, expect, pryv, testData */
6
+ /* eslint-disable no-unused-expressions */
6
7
 
7
8
  describe('utils', function () {
8
-
9
9
  before(async function () {
10
10
  this.timeout(5000);
11
11
  await testData.prepare();
12
12
  });
13
13
 
14
- it('extractTokenAndApiEndpoint', function (done) {
15
- const tokenAndAPI = Pryv.utils
16
- .extractTokenAndApiEndpoint(testData.apiEndpointWithToken);
17
- testData.token.should.equals(tokenAndAPI.token);
18
-
19
- (testData.apiEndpoint).should.equals(tokenAndAPI.endpoint);
14
+ it('extractTokenAndAPIEndpoint', function (done) {
15
+ const tokenAndAPI = pryv.utils
16
+ .extractTokenAndAPIEndpoint(testData.apiEndpointWithToken);
17
+ expect(testData.token).to.equal(tokenAndAPI.token);
18
+
19
+ expect(testData.apiEndpoint).to.equal(tokenAndAPI.endpoint);
20
20
  done();
21
21
  });
22
22
 
23
- it('extractTokenAndApiEndpoint should work without token', function (done) {
24
- const tokenAndAPI = Pryv.utils
25
- .extractTokenAndApiEndpoint(testData.apiEndpoint);
26
-
27
- should.not.exist(tokenAndAPI.token);
23
+ it('extractTokenAndAPIEndpoint should work without token', function (done) {
24
+ const tokenAndAPI = pryv.utils
25
+ .extractTokenAndAPIEndpoint(testData.apiEndpoint);
26
+
27
+ expect(tokenAndAPI.token).to.not.exist;
28
28
 
29
- (testData.apiEndpoint).should.equals(tokenAndAPI.endpoint);
29
+ expect(testData.apiEndpoint).to.equal(tokenAndAPI.endpoint);
30
30
  done();
31
31
  });
32
32
 
33
- it('extractTokenAndApiEndpoint should fail on invalid url', function (done) {
33
+ it('extractTokenAndAPIEndpoint should fail on invalid url', function (done) {
34
34
  let error = null;
35
35
  try {
36
- const tokenAndAPI = Pryv.utils
37
- .extractTokenAndApiEndpoint('blip');
36
+ pryv.utils.extractTokenAndAPIEndpoint('blip');
38
37
  } catch (e) {
39
38
  error = e;
40
-
41
39
  return done();
42
40
  }
43
- should.exist(error);
44
-
41
+ expect(error).to.exist;
45
42
  });
46
43
 
47
44
  it('buildAPIEndpoint with token', function (done) {
48
- const apiEndpoint = Pryv.utils
49
- .buildPryvApiEndpoint({
50
- token: testData.token,
51
- endpoint: testData.apiEndpoint});
52
- apiEndpoint.should.equals(testData.apiEndpointWithToken);
45
+ const apiEndpoint = pryv.utils
46
+ .buildAPIEndpoint({
47
+ token: testData.token,
48
+ endpoint: testData.apiEndpoint
49
+ });
50
+ expect(apiEndpoint).to.equal(testData.apiEndpointWithToken);
53
51
  done();
54
52
  });
55
53
 
56
54
  it('buildAPIEndpoint without token', function (done) {
57
- const apiEndpoint = Pryv.utils
58
- .buildPryvApiEndpoint({
55
+ const apiEndpoint = pryv.utils
56
+ .buildAPIEndpoint({
59
57
  token: null,
60
58
  endpoint: testData.apiEndpoint
61
59
  });
62
- apiEndpoint.should.equals(testData.apiEndpoint);
60
+ expect(apiEndpoint).to.equal(testData.apiEndpoint);
63
61
  done();
64
62
  });
65
-
66
63
  });
67
-
68
-
package/.jsdoc-conf.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "plugins": [
3
- "plugins/markdown"
4
- ],
5
- "recurseDepth": 10,
6
- "source": {
7
- "include": ["./src"],
8
- "includePattern": ".+\\.js(doc|x)?$",
9
- "excludePattern": "(^|\\/|\\\\)_"
10
- },
11
- "sourceType": "module",
12
- "tags": {
13
- "allowUnknownTags": true,
14
- "dictionaries": [
15
- "jsdoc",
16
- "closure"
17
- ]
18
- },
19
- "templates": {
20
- "cleverLinks": false,
21
- "monospaceLinks": false
22
- },
23
- "opts": {
24
- "encoding": "utf8",
25
- "destination": "./dist/docs",
26
- "recurse": true,
27
- "readme": "./README.md"
28
- }
29
- }
package/.mocharc.js DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- diff: true,
3
- extension: ['js'],
4
- opts: false,
5
- package: './package.json',
6
- reporter: 'spec',
7
- slow: 75,
8
- timeout: 2000,
9
- require: 'test/helpers.js',
10
- ui: 'bdd',
11
- 'watch-files': ['lib/**/*.js', 'test/**/*.js'],
12
- 'watch-ignore': ['lib/vendor']
13
- };
package/LICENSE.md DELETED
@@ -1,27 +0,0 @@
1
- Copyright (c) 2020-2021, Pryv S.A.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification,
5
- are permitted provided that the following conditions are met:
6
-
7
- - Redistributions of source code must retain the above copyright notice, this
8
- list of conditions and the following disclaimer.
9
-
10
- - Redistributions in binary form must reproduce the above copyright notice, this
11
- list of conditions and the following disclaimer in the documentation and/or
12
- other materials provided with the distribution.
13
-
14
- - Neither the name of Pryv nor the names of its
15
- contributors may be used to endorse or promote products derived from
16
- this software without specific prior written permission.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.