@verdocs/js-sdk 1.0.27 → 1.1.3
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/Documents/Documents.d.ts +14 -3
- package/Documents/Documents.js +27 -2
- package/Documents/Signatures.js +4 -4
- package/Documents/Stars.js +1 -1
- package/Documents/Types.d.ts +20 -0
- package/HTTP/Transport.d.ts +13 -39
- package/HTTP/Transport.js +18 -81
- package/HTTP/{Endpoint.d.ts → VerdocsEndpoint.d.ts} +20 -8
- package/HTTP/{Endpoint.js → VerdocsEndpoint.js} +36 -23
- package/HTTP/index.d.ts +1 -1
- package/HTTP/index.js +1 -1
- package/Organizations/ApiKeys.js +5 -5
- package/Organizations/Groups.js +7 -7
- package/Organizations/Invitations.js +7 -7
- package/Organizations/Members.js +5 -5
- package/Organizations/Organizations.js +6 -6
- package/Organizations/Webhooks.js +2 -2
- package/Organizations/Whitelabel.js +2 -2
- package/Search/Content.js +3 -3
- package/Templates/Documents.js +4 -4
- package/Templates/Fields.js +3 -3
- package/Templates/Pages.js +4 -4
- package/Templates/Reminders.js +4 -4
- package/Templates/Roles.js +7 -7
- package/Templates/Stars.js +2 -2
- package/Templates/Tags.js +6 -6
- package/Templates/Templates.js +6 -6
- package/Templates/Validators.js +2 -2
- package/Users/Auth.d.ts +17 -1
- package/Users/Auth.js +58 -6
- package/Users/Notifications.js +1 -1
- package/Users/Profiles.js +10 -10
- package/Utils/Token.d.ts +20 -0
- package/Utils/Token.js +67 -0
- package/Utils/index.d.ts +1 -0
- package/Utils/index.js +1 -0
- package/package.json +3 -1
package/Utils/Token.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* tslint:disable:no-bitwise */
|
|
2
|
+
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
3
|
+
// Regular expression to check formal correctness of base64 encoded strings
|
|
4
|
+
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
5
|
+
/**
|
|
6
|
+
* Simplified, Node/Browser-safe alternative to atob() for base64 decoding.
|
|
7
|
+
* Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
|
|
8
|
+
*/
|
|
9
|
+
export var AtoB = function (str) {
|
|
10
|
+
// atob can work with strings with whitespaces, even inside the encoded part,
|
|
11
|
+
// but only \t, \n, \f, \r and ' ', which can be stripped.
|
|
12
|
+
str = String(str).replace(/[\t\n\f\r ]+/g, '');
|
|
13
|
+
if (!b64re.test(str))
|
|
14
|
+
throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
|
15
|
+
// Adding the padding if missing, for semplicity
|
|
16
|
+
str += '=='.slice(2 - (str.length & 3));
|
|
17
|
+
var bitmap;
|
|
18
|
+
var result = '';
|
|
19
|
+
var r1;
|
|
20
|
+
var r2;
|
|
21
|
+
var i = 0;
|
|
22
|
+
for (; i < str.length;) {
|
|
23
|
+
bitmap =
|
|
24
|
+
(b64.indexOf(str.charAt(i++)) << 18) |
|
|
25
|
+
(b64.indexOf(str.charAt(i++)) << 12) |
|
|
26
|
+
((r1 = b64.indexOf(str.charAt(i++))) << 6) |
|
|
27
|
+
(r2 = b64.indexOf(str.charAt(i++)));
|
|
28
|
+
result +=
|
|
29
|
+
r1 === 64
|
|
30
|
+
? String.fromCharCode((bitmap >> 16) & 255)
|
|
31
|
+
: r2 === 64
|
|
32
|
+
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
|
|
33
|
+
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Decode the body of a JWT. This helper may allow front-end applications to avoid a dependency on `jsonwebtoken` in
|
|
39
|
+
* many cases. Note that this should only be used for true JWTs. Opaque tokens will cause this to throw.
|
|
40
|
+
*/
|
|
41
|
+
export var decodeTokenBody = function (token) { return JSON.parse(AtoB((token || '').split('.')[1] || '')); };
|
|
42
|
+
/**
|
|
43
|
+
* Decode the body of an Verdocs access token. Note that raw tokens contain namespaced fields, e.g.
|
|
44
|
+
* `https://verdocs.com/profile_id`. To make these tokens easier to use in front-end code, this name-spacing
|
|
45
|
+
* will be removed. Note that user and signing sessions have different access token formats. The calling
|
|
46
|
+
* application should distinguish between the two based on the context of the authenticated session, or by
|
|
47
|
+
* the presence of the `document_id` field, which will only be present for signing sessions.
|
|
48
|
+
*/
|
|
49
|
+
export var decodeAccessTokenBody = function (token) {
|
|
50
|
+
var decoded;
|
|
51
|
+
try {
|
|
52
|
+
decoded = decodeTokenBody(token);
|
|
53
|
+
if (decoded === null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
Object.keys(decoded).forEach(function (key) {
|
|
61
|
+
if (typeof key === 'string' && key.startsWith('https://verdocs.com/')) {
|
|
62
|
+
decoded[key.replace('https://verdocs.com/', '')] = decoded[key];
|
|
63
|
+
delete decoded[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return decoded;
|
|
67
|
+
};
|
package/Utils/index.d.ts
CHANGED
package/Utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdocs/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"homepage": "https://github.com/Verdocs/js-sdk",
|
|
6
6
|
"description": "Verdocs JS SDK",
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
"docs-html": "typedoc --tsconfig ./tsconfig-typedoc.json --plugin none --out docs-html",
|
|
37
37
|
"Xdocs-html": "typedoc --tsconfig ./tsconfig-typedoc.json --plugin ./typedoc-theme.tsx --out docs-html",
|
|
38
38
|
"docs": "rm -rf ../partner-portal/site/static/js-sdk/* && npm run docs-md && npm run docs-html && cp -aR docs-html/* ../partner-portal/site/static/js-sdk/",
|
|
39
|
+
"clear-docs": "aws --profile=verdocs cloudfront create-invalidation --distribution-id E29UFGU4KEH1GQ --paths \"/*\"",
|
|
40
|
+
"deploy-docs": "npm run docs && aws --profile=verdocs s3 sync --acl public-read --delete docs-html s3://verdocs-developers-js-sdk/ && yarn clear-docs",
|
|
39
41
|
"clean": "rm -rf Documents HTTP Organizations Search Templates Users Utils index.js index.d.ts docs docs-html"
|
|
40
42
|
},
|
|
41
43
|
"publishConfig": {
|