@verdocs/web-sdk 1.1.0 → 1.2.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.
- package/dist/cjs/Auth-0ba9a04b.js +68 -0
- package/dist/cjs/{Transport-68c8b1f4.js → Token-1ea6d834.js} +81 -19
- package/dist/cjs/{index-6fc067b7.js → index-01e27102.js} +5 -357
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/verdocs-auth.cjs.entry.js +9 -70
- package/dist/cjs/verdocs-button_2.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-document-status.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-dropdown_12.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-initial-dialog.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-loader.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-ok-dialog.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-organization-card.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-quick-functions.cjs.entry.js +31 -0
- package/dist/cjs/verdocs-search-activity_2.cjs.entry.js +210 -0
- package/dist/cjs/verdocs-search-tabs.cjs.entry.js +20 -0
- package/dist/cjs/verdocs-search.cjs.entry.js +2 -2
- package/dist/cjs/verdocs-sign.cjs.entry.js +11 -12
- package/dist/cjs/verdocs-signature-dialog.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-template-card.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-template-tags.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-toggle.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-upload-dialog.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-web-sdk.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +4 -6
- package/dist/collection/components/elements/{search-quick-functions → verdocs-quick-functions}/document-icon.svg +0 -0
- package/dist/collection/components/elements/{search-quick-functions → verdocs-quick-functions}/template-icon.svg +0 -0
- package/dist/collection/components/elements/{search-quick-functions/search-quick-functions.css → verdocs-quick-functions/verdocs-quick-functions.css} +5 -5
- package/dist/collection/components/elements/{search-quick-functions/search-quick-functions.js → verdocs-quick-functions/verdocs-quick-functions.js} +9 -10
- package/dist/collection/components/elements/{search-quick-functions/search-quick-functions.stories.js → verdocs-quick-functions/verdocs-quick-functions.stories.js} +2 -2
- package/dist/collection/components/elements/{search-starred → verdocs-search-activity}/document-icon.svg +0 -0
- package/dist/collection/components/elements/{search-starred/search-starred.css → verdocs-search-activity/verdocs-search-activity.css} +12 -12
- package/dist/collection/components/elements/verdocs-search-activity/verdocs-search-activity.js +168 -0
- package/dist/collection/components/elements/verdocs-search-activity/verdocs-search-activity.stories.js +14 -0
- package/dist/collection/components/elements/{search-box → verdocs-search-box}/close.svg +0 -0
- package/dist/collection/components/elements/{search-box → verdocs-search-box}/search.svg +0 -0
- package/dist/collection/components/elements/{search-box/search-box.css → verdocs-search-box/verdocs-search-box.css} +9 -9
- package/dist/collection/components/elements/{search-box/search-box.js → verdocs-search-box/verdocs-search-box.js} +14 -15
- package/dist/collection/components/elements/{search-box/search-box.stories.js → verdocs-search-box/verdocs-search-box.stories.js} +2 -2
- package/dist/collection/components/elements/verdocs-search-tabs/verdocs-search-tabs.css +3 -0
- package/dist/collection/components/elements/verdocs-search-tabs/verdocs-search-tabs.js +19 -0
- package/dist/collection/components/elements/{search-tabs/search-tabs.stories.js → verdocs-search-tabs/verdocs-search-tabs.stories.js} +2 -2
- package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js +2 -2
- package/dist/collection/components/embeds/verdocs-search/verdocs-search.js +4 -4
- package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +1 -1
- package/dist/custom-elements/index.d.ts +24 -36
- package/dist/custom-elements/index.js +271 -331
- package/dist/docs.json +254 -344
- package/dist/esm/Auth-16761ea6.js +64 -0
- package/dist/esm/{Transport-797d3c59.js → Token-b82a8ea3.js} +81 -20
- package/dist/esm/{index-80d1b936.js → index-ade0ef1e.js} +5 -357
- package/dist/esm/loader.js +2 -2
- package/dist/esm/verdocs-auth.entry.js +4 -65
- package/dist/esm/verdocs-button_2.entry.js +1 -1
- package/dist/esm/verdocs-document-status.entry.js +1 -1
- package/dist/esm/verdocs-dropdown_12.entry.js +1 -1
- package/dist/esm/verdocs-initial-dialog.entry.js +1 -1
- package/dist/esm/verdocs-loader.entry.js +1 -1
- package/dist/esm/verdocs-ok-dialog.entry.js +1 -1
- package/dist/esm/verdocs-organization-card.entry.js +1 -1
- package/dist/esm/verdocs-quick-functions.entry.js +27 -0
- package/dist/esm/verdocs-search-activity_2.entry.js +205 -0
- package/dist/esm/verdocs-search-tabs.entry.js +16 -0
- package/dist/esm/verdocs-search.entry.js +2 -2
- package/dist/esm/verdocs-sign.entry.js +3 -4
- package/dist/esm/verdocs-signature-dialog.entry.js +1 -1
- package/dist/esm/verdocs-template-card.entry.js +1 -1
- package/dist/esm/verdocs-template-tags.entry.js +1 -1
- package/dist/esm/verdocs-toggle.entry.js +1 -1
- package/dist/esm/verdocs-upload-dialog.entry.js +1 -1
- package/dist/esm/verdocs-web-sdk.js +2 -2
- package/dist/esm-es5/Auth-16761ea6.js +1 -0
- package/dist/esm-es5/{Transport-797d3c59.js → Token-b82a8ea3.js} +1 -1
- package/dist/esm-es5/index-ade0ef1e.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/verdocs-auth.entry.js +1 -1
- package/dist/esm-es5/verdocs-button_2.entry.js +1 -1
- package/dist/esm-es5/verdocs-document-status.entry.js +1 -1
- package/dist/esm-es5/verdocs-dropdown_12.entry.js +1 -1
- package/dist/esm-es5/verdocs-initial-dialog.entry.js +1 -1
- package/dist/esm-es5/verdocs-loader.entry.js +1 -1
- package/dist/esm-es5/verdocs-ok-dialog.entry.js +1 -1
- package/dist/esm-es5/verdocs-organization-card.entry.js +1 -1
- package/dist/esm-es5/verdocs-quick-functions.entry.js +1 -0
- package/dist/esm-es5/verdocs-search-activity_2.entry.js +1 -0
- package/dist/esm-es5/verdocs-search-tabs.entry.js +1 -0
- package/dist/esm-es5/verdocs-search.entry.js +1 -1
- package/dist/esm-es5/verdocs-sign.entry.js +1 -1
- package/dist/esm-es5/verdocs-signature-dialog.entry.js +1 -1
- package/dist/esm-es5/verdocs-template-card.entry.js +1 -1
- package/dist/esm-es5/verdocs-template-tags.entry.js +1 -1
- package/dist/esm-es5/verdocs-toggle.entry.js +1 -1
- package/dist/esm-es5/verdocs-upload-dialog.entry.js +1 -1
- package/dist/esm-es5/verdocs-web-sdk.js +1 -1
- package/dist/types/components/elements/{search-quick-functions/search-quick-functions.d.ts → verdocs-quick-functions/verdocs-quick-functions.d.ts} +1 -1
- package/dist/types/components/elements/{search-quick-functions/search-quick-functions.stories.d.ts → verdocs-quick-functions/verdocs-quick-functions.stories.d.ts} +0 -0
- package/dist/types/components/elements/{search-starred/search-starred.d.ts → verdocs-search-activity/verdocs-search-activity.d.ts} +10 -3
- package/dist/types/components/elements/{search-starred/search-starred.stories.d.ts → verdocs-search-activity/verdocs-search-activity.stories.d.ts} +2 -2
- package/dist/types/components/elements/{search-box/search-box.d.ts → verdocs-search-box/verdocs-search-box.d.ts} +1 -1
- package/dist/types/components/elements/{search-box/search-box.stories.d.ts → verdocs-search-box/verdocs-search-box.stories.d.ts} +0 -0
- package/dist/types/components/elements/{search-tabs/search-tabs.d.ts → verdocs-search-tabs/verdocs-search-tabs.d.ts} +1 -1
- package/dist/types/components/elements/{search-tabs/search-tabs.stories.d.ts → verdocs-search-tabs/verdocs-search-tabs.stories.d.ts} +0 -0
- package/dist/types/components.d.ts +106 -154
- package/dist/verdocs-web-sdk/{p-b07ae79f.entry.js → p-063c4c71.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-94d6f88f.system.entry.js → p-10e7c953.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-5a6041c0.entry.js → p-183c7338.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-d03d748c.entry.js → p-25a138c4.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-2ded0974.entry.js → p-28b3017f.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-2ec1d8d8.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-3ced6e3a.system.js +1 -0
- package/dist/verdocs-web-sdk/{p-a415926b.system.entry.js → p-41383ebc.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-44b75396.system.js +1 -0
- package/dist/verdocs-web-sdk/p-48b73707.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-4bfe13e6.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-556f577f.system.js +1 -0
- package/dist/verdocs-web-sdk/p-6e95da9d.js +1 -0
- package/dist/verdocs-web-sdk/p-6ef8ca10.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-72ebb6e3.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-cdae8dba.entry.js → p-817302a8.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-8a1b9ad0.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-ba8a7e2d.system.entry.js → p-91f87fa8.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-95880bac.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-9e0a07a7.js +1 -0
- package/dist/verdocs-web-sdk/{p-d299cd16.system.entry.js → p-a0fcbe6e.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-3a102b59.entry.js → p-ae37b970.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-b3c30059.system.js +1 -0
- package/dist/verdocs-web-sdk/{p-b13ee3be.entry.js → p-b567001f.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-fae1351f.system.entry.js → p-b8f5af91.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-f4786f62.entry.js → p-bc61d0ce.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-c4add613.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-80c7bc0c.system.entry.js → p-ccad2089.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-993a0a23.system.entry.js → p-cfb1cad1.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-82f4cb67.system.entry.js → p-d3a4e22e.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-d3ae5318.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-dc1f3572.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-bdfa7db9.system.entry.js → p-dcf25d2c.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-89f5fc2b.entry.js → p-df4ae522.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-3b2cd409.system.entry.js → p-e0091c19.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-0956a3bc.system.entry.js → p-e1887a75.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-e9f5d6a6.js +1 -0
- package/dist/verdocs-web-sdk/{p-853e30f2.system.entry.js → p-efffddab.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-6327fd83.entry.js → p-f0d20c75.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-fcfe34db.entry.js → p-f35c796c.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-24236b87.entry.js → p-f5109d69.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-7f9a96d5.system.entry.js → p-f6938563.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-fa8ae849.entry.js +1 -0
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/dist/verdocs-web-sdk/verdocs-web-sdk.js +1 -1
- package/package.json +10 -13
- package/dist/cjs/Token-65a1dc17.js +0 -71
- package/dist/cjs/search-box_5.cjs.entry.js +0 -283
- package/dist/cjs/search-tabs.cjs.entry.js +0 -20
- package/dist/collection/components/elements/search-recent/search-icon.svg +0 -1
- package/dist/collection/components/elements/search-recent/search-recent.css +0 -65
- package/dist/collection/components/elements/search-recent/search-recent.js +0 -98
- package/dist/collection/components/elements/search-recent/search-recent.stories.js +0 -12
- package/dist/collection/components/elements/search-saved/search-icon.svg +0 -1
- package/dist/collection/components/elements/search-saved/search-saved.css +0 -56
- package/dist/collection/components/elements/search-saved/search-saved.js +0 -98
- package/dist/collection/components/elements/search-saved/search-saved.stories.js +0 -12
- package/dist/collection/components/elements/search-starred/search-starred.js +0 -114
- package/dist/collection/components/elements/search-starred/search-starred.stories.js +0 -35
- package/dist/collection/components/elements/search-tabs/search-tabs.css +0 -3
- package/dist/collection/components/elements/search-tabs/search-tabs.js +0 -20
- package/dist/custom-elements.json +0 -727
- package/dist/esm/Token-a058076d.js +0 -69
- package/dist/esm/search-box_5.entry.js +0 -275
- package/dist/esm/search-tabs.entry.js +0 -16
- package/dist/esm-es5/Token-a058076d.js +0 -1
- package/dist/esm-es5/index-80d1b936.js +0 -1
- package/dist/esm-es5/search-box_5.entry.js +0 -1
- package/dist/esm-es5/search-tabs.entry.js +0 -1
- package/dist/types/components/elements/search-recent/search-recent.d.ts +0 -25
- package/dist/types/components/elements/search-recent/search-recent.stories.d.ts +0 -7
- package/dist/types/components/elements/search-saved/search-saved.d.ts +0 -25
- package/dist/types/components/elements/search-saved/search-saved.stories.d.ts +0 -7
- package/dist/verdocs-web-sdk/p-30d908ea.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-37b07203.system.js +0 -1
- package/dist/verdocs-web-sdk/p-3c70c740.system.js +0 -1
- package/dist/verdocs-web-sdk/p-403cb7cf.js +0 -1
- package/dist/verdocs-web-sdk/p-4a538cbc.js +0 -1
- package/dist/verdocs-web-sdk/p-62ec194f.js +0 -1
- package/dist/verdocs-web-sdk/p-81b15287.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-83dbc583.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-8739595c.system.js +0 -1
- package/dist/verdocs-web-sdk/p-9a896baf.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-a4fc6ad9.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-a73a1ff8.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-aec93cc9.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-d82dc646.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-eaffa4b1.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-fc3d921f.system.js +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Token = require('./Token-1ea6d834.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Authenticate to Verdocs via user/password authentication
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {Auth} from '@verdocs/js-sdk/Auth';
|
|
10
|
+
* import {Transport} from '@verdocs/js-sdk/HTTP';
|
|
11
|
+
*
|
|
12
|
+
* const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
|
|
13
|
+
* Transport.setAuthToken(accessToken);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
var authenticateUser = function (params) {
|
|
17
|
+
return Token.getEndpoint()
|
|
18
|
+
.api.post('/authentication/login', params)
|
|
19
|
+
.then(function (r) { return r.data; });
|
|
20
|
+
};
|
|
21
|
+
var clearSession = function (source, persist) {
|
|
22
|
+
Token.getEndpoint().setAuthorization(null);
|
|
23
|
+
if (persist) {
|
|
24
|
+
localStorage.removeItem(source);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Parses and sets the active session, optionally persisting (brower-only, persists to localStorage).
|
|
30
|
+
*/
|
|
31
|
+
var setSession = function (source, token, persist) {
|
|
32
|
+
if (persist === void 0) { persist = false; }
|
|
33
|
+
if (token === null) {
|
|
34
|
+
return clearSession(source, persist);
|
|
35
|
+
}
|
|
36
|
+
var session = Token.decodeAccessTokenBody(token || '');
|
|
37
|
+
if (session === null || (session.exp && session.exp * 1000 < new Date().getTime())) {
|
|
38
|
+
return clearSession(source, persist);
|
|
39
|
+
}
|
|
40
|
+
if (persist) {
|
|
41
|
+
localStorage.setItem(source, token);
|
|
42
|
+
}
|
|
43
|
+
Token.getEndpoint().setAuthorization(token);
|
|
44
|
+
return session;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Load a session from localStorage
|
|
48
|
+
*/
|
|
49
|
+
var loadSession = function (source) {
|
|
50
|
+
var token = localStorage.getItem(source);
|
|
51
|
+
if (!token) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
var session = Token.decodeAccessTokenBody(token);
|
|
55
|
+
if (!session) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (session.exp && session.exp * 1000 < new Date().getTime()) {
|
|
59
|
+
localStorage.removeItem(source);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
Token.getEndpoint().setAuthorization(token);
|
|
63
|
+
return session;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.authenticateUser = authenticateUser;
|
|
67
|
+
exports.loadSession = loadSession;
|
|
68
|
+
exports.setSession = setSession;
|
|
@@ -1805,9 +1805,14 @@ axios_1.default = _default;
|
|
|
1805
1805
|
|
|
1806
1806
|
var axios = axios_1;
|
|
1807
1807
|
|
|
1808
|
+
var requestLogger = function (r) {
|
|
1809
|
+
// tslint:disable-next-line
|
|
1810
|
+
console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
|
|
1811
|
+
return r;
|
|
1812
|
+
};
|
|
1808
1813
|
/**
|
|
1809
|
-
*
|
|
1810
|
-
*
|
|
1814
|
+
* VerdocsEndpoint is a class wrapper for a specific connection and authorization context for calling the Verdocs APIs.
|
|
1815
|
+
* Endpoints can be used for isolated session tasks.
|
|
1811
1816
|
* For instance, ephemeral signing sessions may be created independently of a caller's status as an authenticated user.
|
|
1812
1817
|
* In that case, an Endpoint can be created and authenticated, used for calls related to signing operations, then
|
|
1813
1818
|
* discarded once signing is complete.
|
|
@@ -1823,31 +1828,19 @@ var axios = axios_1;
|
|
|
1823
1828
|
* .setClientID('1234)
|
|
1824
1829
|
* .setTimeout(5000);
|
|
1825
1830
|
* ```
|
|
1826
|
-
*
|
|
1827
|
-
* @module
|
|
1828
1831
|
*/
|
|
1829
|
-
var requestLogger = function (r) {
|
|
1830
|
-
// tslint:disable-next-line
|
|
1831
|
-
console.debug("[JS-SDK] ".concat(r.method.toUpperCase(), " ").concat(r.baseURL).concat(r.url), r.data ? JSON.stringify(r.data) : '');
|
|
1832
|
-
return r;
|
|
1833
|
-
};
|
|
1834
1832
|
var VerdocsEndpoint = /** @class */ (function () {
|
|
1835
1833
|
/**
|
|
1836
|
-
* Create a new
|
|
1834
|
+
* Create a new VerdocsEndpoint to call Verdocs platform services.
|
|
1837
1835
|
*
|
|
1838
1836
|
* ```typescript
|
|
1839
1837
|
* import {VerdocsEndpoint} from '@verdocs/js-sdk/HTTP';
|
|
1840
|
-
*
|
|
1841
|
-
* console.log('Current timeout', Transport.getEndpoint().defaults.timeout);
|
|
1838
|
+
* const endpoint = new VerdocsEndpoint();
|
|
1842
1839
|
* ```
|
|
1843
1840
|
*/
|
|
1844
|
-
function VerdocsEndpoint(
|
|
1845
|
-
var _b = _a === void 0 ? {} : _a, baseURL = _b.baseURL, timeout = _b.timeout;
|
|
1841
|
+
function VerdocsEndpoint() {
|
|
1846
1842
|
this.requestLoggerId = null;
|
|
1847
|
-
this.api = axios.create({
|
|
1848
|
-
baseURL: baseURL || 'https://api.verdocs.com',
|
|
1849
|
-
timeout: timeout || 6000,
|
|
1850
|
-
});
|
|
1843
|
+
this.api = axios.create({ baseURL: 'https://api.verdocs.com', timeout: 3000 });
|
|
1851
1844
|
}
|
|
1852
1845
|
/**
|
|
1853
1846
|
* Set the timeout for API calls in milliseconds. 2000-4000ms is recommended for most purposes. 3000ms is the default.
|
|
@@ -1963,7 +1956,7 @@ var VerdocsEndpoint = /** @class */ (function () {
|
|
|
1963
1956
|
// Also see globalThis for comments about why we're doing this in the first place.
|
|
1964
1957
|
var ENDPOINT_KEY = Symbol.for('verdocs-api-endpoint');
|
|
1965
1958
|
if (!globalThis_1[ENDPOINT_KEY]) {
|
|
1966
|
-
globalThis_1[ENDPOINT_KEY] = new VerdocsEndpoint(
|
|
1959
|
+
globalThis_1[ENDPOINT_KEY] = new VerdocsEndpoint();
|
|
1967
1960
|
}
|
|
1968
1961
|
var globalEndpoint = globalThis_1[ENDPOINT_KEY];
|
|
1969
1962
|
var activeEndpoint = globalEndpoint;
|
|
@@ -1998,6 +1991,75 @@ var setActiveEndpoint = function (e) {
|
|
|
1998
1991
|
activeEndpoint = e || globalEndpoint;
|
|
1999
1992
|
};
|
|
2000
1993
|
|
|
1994
|
+
/* tslint:disable:no-bitwise */
|
|
1995
|
+
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
1996
|
+
// Regular expression to check formal correctness of base64 encoded strings
|
|
1997
|
+
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
1998
|
+
/**
|
|
1999
|
+
* Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
|
|
2000
|
+
* Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
|
|
2001
|
+
*/
|
|
2002
|
+
var AtoB = function (str) {
|
|
2003
|
+
// atob can work with strings with whitespaces, even inside the encoded part,
|
|
2004
|
+
// but only \t, \n, \f, \r and ' ', which can be stripped.
|
|
2005
|
+
str = String(str).replace(/[\t\n\f\r ]+/g, '');
|
|
2006
|
+
if (!b64re.test(str))
|
|
2007
|
+
throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
|
2008
|
+
// Adding the padding if missing, for semplicity
|
|
2009
|
+
str += '=='.slice(2 - (str.length & 3));
|
|
2010
|
+
var bitmap;
|
|
2011
|
+
var result = '';
|
|
2012
|
+
var r1;
|
|
2013
|
+
var r2;
|
|
2014
|
+
var i = 0;
|
|
2015
|
+
for (; i < str.length;) {
|
|
2016
|
+
bitmap =
|
|
2017
|
+
(b64.indexOf(str.charAt(i++)) << 18) |
|
|
2018
|
+
(b64.indexOf(str.charAt(i++)) << 12) |
|
|
2019
|
+
((r1 = b64.indexOf(str.charAt(i++))) << 6) |
|
|
2020
|
+
(r2 = b64.indexOf(str.charAt(i++)));
|
|
2021
|
+
result +=
|
|
2022
|
+
r1 === 64
|
|
2023
|
+
? String.fromCharCode((bitmap >> 16) & 255)
|
|
2024
|
+
: r2 === 64
|
|
2025
|
+
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
|
|
2026
|
+
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
|
|
2027
|
+
}
|
|
2028
|
+
return result;
|
|
2029
|
+
};
|
|
2030
|
+
/**
|
|
2031
|
+
* Decode the body of a JWT. This helper may allow front-end applications to avoid a dependency on `jsonwebtoken` in
|
|
2032
|
+
* many cases. Note that this should only be used for true JWTs. Opaque tokens will cause this to throw.
|
|
2033
|
+
*/
|
|
2034
|
+
var decodeTokenBody = function (token) { return JSON.parse(AtoB((token || '').split('.')[1] || '')); };
|
|
2035
|
+
/**
|
|
2036
|
+
* Decode the body of an Verdocs access token. Note that raw tokens contain namespaced fields, e.g.
|
|
2037
|
+
* `https://verdocs.com/profile_id`. To make these tokens easier to use in front-end code, this name-spacing
|
|
2038
|
+
* will be removed. Note that user and signing sessions have different access token formats. The calling
|
|
2039
|
+
* application should distinguish between the two based on the context of the authenticated session, or by
|
|
2040
|
+
* the presence of the `document_id` field, which will only be present for signing sessions.
|
|
2041
|
+
*/
|
|
2042
|
+
var decodeAccessTokenBody = function (token) {
|
|
2043
|
+
var decoded;
|
|
2044
|
+
try {
|
|
2045
|
+
decoded = decodeTokenBody(token);
|
|
2046
|
+
if (decoded === null) {
|
|
2047
|
+
return null;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
catch (e) {
|
|
2051
|
+
return null;
|
|
2052
|
+
}
|
|
2053
|
+
Object.keys(decoded).forEach(function (key) {
|
|
2054
|
+
if (typeof key === 'string' && key.startsWith('https://verdocs.com/')) {
|
|
2055
|
+
decoded[key.replace('https://verdocs.com/', '')] = decoded[key];
|
|
2056
|
+
delete decoded[key];
|
|
2057
|
+
}
|
|
2058
|
+
});
|
|
2059
|
+
return decoded;
|
|
2060
|
+
};
|
|
2061
|
+
|
|
2001
2062
|
exports.VerdocsEndpoint = VerdocsEndpoint;
|
|
2063
|
+
exports.decodeAccessTokenBody = decodeAccessTokenBody;
|
|
2002
2064
|
exports.getEndpoint = getEndpoint;
|
|
2003
2065
|
exports.setActiveEndpoint = setActiveEndpoint;
|