@verdocs/js-sdk 1.0.28 → 1.1.1
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.js +5 -3
- package/Utils/AtoB.d.ts +1 -0
- package/Utils/AtoB.js +33 -0
- package/Utils/index.d.ts +1 -0
- package/Utils/index.js +1 -0
- package/package.json +3 -1
package/Documents/Documents.js
CHANGED
|
@@ -35,6 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { getEndpoint } from '../HTTP/Transport';
|
|
38
|
+
import { AtoB } from '../Utils';
|
|
38
39
|
/**
|
|
39
40
|
* Get a summary of currently active documents.
|
|
40
41
|
*
|
|
@@ -75,11 +76,12 @@ export var getSigningSession = function (params) { return __awaiter(void 0, void
|
|
|
75
76
|
return [2 /*return*/, getEndpoint()
|
|
76
77
|
.api.get("/documents/".concat(params.documentId, "/recipients/").concat(encodeURIComponent(params.roleId), "/invitation/").concat(params.inviteCode))
|
|
77
78
|
.then(function (r) {
|
|
78
|
-
var _a;
|
|
79
|
+
var _a, _b;
|
|
79
80
|
// Avoiding a jsonwebtoken dependency here - we don't actually need the whole library
|
|
80
81
|
var signerToken = ((_a = r.headers) === null || _a === void 0 ? void 0 : _a.signer_token) || '';
|
|
81
|
-
var session = JSON.parse(
|
|
82
|
-
|
|
82
|
+
var session = JSON.parse(AtoB(signerToken.split('.')[1]));
|
|
83
|
+
getEndpoint().setAuthorization((_b = r.headers) === null || _b === void 0 ? void 0 : _b.signer_token);
|
|
84
|
+
return { recipient: r.data, session: session, signerToken: signerToken };
|
|
83
85
|
})];
|
|
84
86
|
});
|
|
85
87
|
}); };
|
package/Utils/AtoB.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AtoB: (str: string) => string;
|
package/Utils/AtoB.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* tslint:disable:no-bitwise */
|
|
2
|
+
// Modified from https://github.com/MaxArt2501/base64-js/blob/master/base64.js
|
|
3
|
+
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
4
|
+
// Regular expression to check formal correctness of base64 encoded strings
|
|
5
|
+
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
6
|
+
export var AtoB = function (str) {
|
|
7
|
+
// atob can work with strings with whitespaces, even inside the encoded part,
|
|
8
|
+
// but only \t, \n, \f, \r and ' ', which can be stripped.
|
|
9
|
+
str = String(str).replace(/[\t\n\f\r ]+/g, '');
|
|
10
|
+
if (!b64re.test(str))
|
|
11
|
+
throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
|
12
|
+
// Adding the padding if missing, for semplicity
|
|
13
|
+
str += '=='.slice(2 - (str.length & 3));
|
|
14
|
+
var bitmap;
|
|
15
|
+
var result = '';
|
|
16
|
+
var r1;
|
|
17
|
+
var r2;
|
|
18
|
+
var i = 0;
|
|
19
|
+
for (; i < str.length;) {
|
|
20
|
+
bitmap =
|
|
21
|
+
(b64.indexOf(str.charAt(i++)) << 18) |
|
|
22
|
+
(b64.indexOf(str.charAt(i++)) << 12) |
|
|
23
|
+
((r1 = b64.indexOf(str.charAt(i++))) << 6) |
|
|
24
|
+
(r2 = b64.indexOf(str.charAt(i++)));
|
|
25
|
+
result +=
|
|
26
|
+
r1 === 64
|
|
27
|
+
? String.fromCharCode((bitmap >> 16) & 255)
|
|
28
|
+
: r2 === 64
|
|
29
|
+
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
|
|
30
|
+
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
};
|
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.1",
|
|
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": {
|