Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit c8975b0

Browse files
committed
#59 add csrf token for activiti #47 add ts for addNode
1 parent b75d171 commit c8975b0

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

dist/alfresco-js-api.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72670,6 +72670,8 @@ var AlfrescoApiClient = function (_ApiClient) {
7267072670
// set header parameters
7267172671
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
7267272672

72673+
this.setCsrfToken(request);
72674+
7267372675
// set request timeout
7267472676
request.timeout(this.timeout);
7267572677

@@ -72771,6 +72773,20 @@ var AlfrescoApiClient = function (_ApiClient) {
7277172773

7277272774
return this.promise;
7277372775
}
72776+
}, {
72777+
key: 'setCsrfToken',
72778+
value: function setCsrfToken(request) {
72779+
var token = this.token();
72780+
request.set('X-CSRF-TOKEN', token);
72781+
try {
72782+
document.cookie = 'CSRF-TOKEN=' + token + ';path=/';
72783+
} catch (err) {}
72784+
}
72785+
}, {
72786+
key: 'token',
72787+
value: function token(a) {
72788+
return a ? (a ^ Math.random() * 16 >> a / 4).toString(16) : ([1e16] + 1e16).replace(/[01]/g, this.token);
72789+
}
7277472790
}, {
7277572791
key: 'progress',
7277672792
value: function progress(event, eventEmitter) {

dist/alfresco-js-api.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/alfrescoApiClient.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class AlfrescoApiClient extends ApiClient {
5858
// set header parameters
5959
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
6060

61+
this.setCsrfToken(request);
62+
6163
// set request timeout
6264
request.timeout(this.timeout);
6365

@@ -159,6 +161,19 @@ class AlfrescoApiClient extends ApiClient {
159161
return this.promise;
160162
}
161163

164+
setCsrfToken(request) {
165+
var token = this.token();
166+
request.set('X-CSRF-TOKEN', token);
167+
try {
168+
document.cookie = 'CSRF-TOKEN=' + token + ';path=/';
169+
} catch (err) {
170+
}
171+
}
172+
173+
token(a) {
174+
return a ? (a ^ Math.random() * 16 >> a / 4).toString(16) : ([1e16] + 1e16).replace(/[01]/g, this.token);
175+
}
176+
162177
progress(event, eventEmitter) {
163178
if (event.lengthComputable && this.promise) {
164179
var percent = Math.round(event.loaded / event.total * 100);

typescript/alfresco-js-api.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ interface NodesApi {
272272
purgeDeletedNode(nodeId: string): Promise<any>;
273273
getDeletedNode(nodeId: string, opts: any): Promise<DeletedNodeEntity>;
274274
restoreNode(nodeId: string): Promise<MinimalNodeEntity>;
275+
addNode(nodeId: string, nodeBody: any, opts: any);
275276
}
276277

277278
interface ApiClient {

0 commit comments

Comments
 (0)