@adobe/acc-js-sdk 1.1.37 → 1.1.39
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/docs/_data/navigation.yml +2 -0
- package/docs/anonymous.html +41 -0
- package/docs/changeLog.html +15 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/client.js +43 -5
- package/test/client.test.js +143 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Anonymous SOAP calls
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
The ACC JS SDK uses schemas to dynamically discover available methods and their signature.
|
|
8
|
+
But fetching schemas requires an authenticated user.
|
|
9
|
+
This means it's not directly possible to call anonymous SOAP methods from the SDK.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p>
|
|
13
|
+
Anonymous SOAP methods are declared with the <b>access</b> attribute set to <b>anonymous</b>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<pre class="code">
|
|
17
|
+
<method name="GetServerTime" static="true" access="anonymous">
|
|
18
|
+
<help>Returns the server date and time</help>
|
|
19
|
+
<parameters>
|
|
20
|
+
<param name="serverTime" type="datetime" inout="out"/>
|
|
21
|
+
</parameters>
|
|
22
|
+
</method>
|
|
23
|
+
</pre>
|
|
24
|
+
|
|
25
|
+
<p>
|
|
26
|
+
In order to call anonymous SOAP methods, one therefore needs a different mechanism and the <b>makeSoapCall</b> method can be used
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<pre class="code">
|
|
30
|
+
const sdk = require('@adobe/acc-js-sdk');
|
|
31
|
+
const connectionParameters = sdk.ConnectionParameters.ofAnonymousUser("https://myInstance.campaign.adobe.com");
|
|
32
|
+
var client = await sdk.init(connectionParameters);
|
|
33
|
+
|
|
34
|
+
client.traceAPICalls(true);
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
var inputParams = [];
|
|
38
|
+
var outputParams = [{ name: "serverTime", type: "datetime" }];
|
|
39
|
+
var result = await client.makeSoapCall("xtk:session", "GetServerTime", true, inputParams, outputParams);
|
|
40
|
+
console.log(result);
|
|
41
|
+
</pre>
|
package/docs/changeLog.html
CHANGED
|
@@ -3,6 +3,21 @@ layout: page
|
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
<section class="changelog"><h1>Version 1.1.39</h1>
|
|
7
|
+
<h2>2023/09/20</h2>
|
|
8
|
+
<li>
|
|
9
|
+
Fixed the name of the returned object when querying a temporary schema and when the result of the query is empty.
|
|
10
|
+
</li>
|
|
11
|
+
</section>
|
|
12
|
+
|
|
13
|
+
<section class="changelog"><h1>Version 1.1.38</h1>
|
|
14
|
+
<h2>2023/09/06</h2>
|
|
15
|
+
<li>
|
|
16
|
+
Add support for anonymous SOAP calls. See <a href="https://opensource.adobe.com/acc-js-sdk/anonymous.html"></a> for more information.
|
|
17
|
+
</li>
|
|
18
|
+
</section>
|
|
19
|
+
|
|
20
|
+
|
|
6
21
|
<section class="changelog"><h1>Version 1.1.37</h1>
|
|
7
22
|
<h2>2023/08/07</h2>
|
|
8
23
|
<li>
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/acc-js-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.39",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@adobe/acc-js-sdk",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.39",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.2.1",
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -243,7 +243,7 @@ class Credentials {
|
|
|
243
243
|
* @param {string} securityToken the security token. Will use an empty token if not specified
|
|
244
244
|
*/
|
|
245
245
|
constructor(type, sessionToken, securityToken) {
|
|
246
|
-
if (type != "UserPassword" && type != "ImsServiceToken" && type != "SessionToken" &&
|
|
246
|
+
if (type != "UserPassword" && type != "ImsServiceToken" && type != "SessionToken" && type != "SessionAndSecurityToken" &&
|
|
247
247
|
type != "AnonymousUser" && type != "SecurityToken" && type != "BearerToken" && type != "ImsBearerToken")
|
|
248
248
|
throw CampaignException.INVALID_CREDENTIALS_TYPE(type);
|
|
249
249
|
this._type = type;
|
|
@@ -458,6 +458,21 @@ class ConnectionParameters {
|
|
|
458
458
|
return new ConnectionParameters(endpoint, credentials, options);
|
|
459
459
|
}
|
|
460
460
|
|
|
461
|
+
/**
|
|
462
|
+
* Creates connection parameters for a Campaign instance, using a session token and a security token
|
|
463
|
+
*
|
|
464
|
+
* @static
|
|
465
|
+
* @param {string} endpoint The campaign endpoint (URL)
|
|
466
|
+
* @param {string} sessionToken The session token
|
|
467
|
+
* @param {string} securityToken The security token
|
|
468
|
+
* @param {Campaign.ConnectionOptions} options connection options
|
|
469
|
+
* @returns {ConnectionParameters} a ConnectionParameters object which can be used to create a Client
|
|
470
|
+
*/
|
|
471
|
+
static ofSessionAndSecurityToken(endpoint, sessionToken, securityToken, options) {
|
|
472
|
+
const credentials = new Credentials("SessionAndSecurityToken", sessionToken, securityToken);
|
|
473
|
+
return new ConnectionParameters(endpoint, credentials, options);
|
|
474
|
+
}
|
|
475
|
+
|
|
461
476
|
/**
|
|
462
477
|
* Creates connection parameters for a Campaign instance, using a security token.
|
|
463
478
|
* Typically, called when embedding the SDK in Campaign: the session token will be
|
|
@@ -466,7 +481,7 @@ class ConnectionParameters {
|
|
|
466
481
|
*
|
|
467
482
|
* @static
|
|
468
483
|
* @param {string} endpoint The campaign endpoint (URL)
|
|
469
|
-
* @param {string} securityToken The
|
|
484
|
+
* @param {string} securityToken The security token
|
|
470
485
|
* @param {Campaign.ConnectionOptions} options connection options
|
|
471
486
|
* @returns {ConnectionParameters} a ConnectionParameters object which can be used to create a Client
|
|
472
487
|
*/
|
|
@@ -1330,7 +1345,7 @@ class Client {
|
|
|
1330
1345
|
else if (operation == "select" && emptyResult) {
|
|
1331
1346
|
const querySchemaId = EntityAccessor.getAttributeAsString(object, "schema");
|
|
1332
1347
|
const index = querySchemaId.indexOf(':');
|
|
1333
|
-
const querySchemaName = querySchemaId.substr(index + 1);
|
|
1348
|
+
const querySchemaName = querySchemaId.substr(index + 1).replace(':', '_');
|
|
1334
1349
|
outputParams[1].value[querySchemaName] = [];
|
|
1335
1350
|
}
|
|
1336
1351
|
}
|
|
@@ -1497,11 +1512,11 @@ class Client {
|
|
|
1497
1512
|
if (credentials._type != "SecurityToken" && typeof document != "undefined") {
|
|
1498
1513
|
document.cookie = '__sessiontoken=;path=/;';
|
|
1499
1514
|
}
|
|
1500
|
-
if (credentials._type == "SessionToken" || credentials._type == "AnonymousUser") {
|
|
1515
|
+
if (credentials._type == "SessionToken" || credentials._type == "AnonymousUser" || credentials._type == "SessionAndSecurityToken") {
|
|
1501
1516
|
that._sessionInfo = undefined;
|
|
1502
1517
|
that._installedPackages = {};
|
|
1503
1518
|
that._sessionToken = credentials._sessionToken;
|
|
1504
|
-
that._securityToken = "";
|
|
1519
|
+
that._securityToken = credentials._type == "SessionAndSecurityToken" ? credentials._securityToken : "";
|
|
1505
1520
|
that._bearerToken = undefined;
|
|
1506
1521
|
that._onLogon();
|
|
1507
1522
|
return Promise.resolve();
|
|
@@ -2059,7 +2074,30 @@ class Client {
|
|
|
2059
2074
|
result.push(outputParams[i].value);
|
|
2060
2075
|
}
|
|
2061
2076
|
return result;
|
|
2077
|
+
}
|
|
2062
2078
|
|
|
2079
|
+
/**
|
|
2080
|
+
* Public API to dynamically invoke SOAP calls. This API allows to call any SOAP calls, including anonyous
|
|
2081
|
+
* SOAP calls such as xtk:session#GetServerTime
|
|
2082
|
+
*
|
|
2083
|
+
* @param {string} urn is the schema id, such as "xtk:session"
|
|
2084
|
+
* @param {string} methodName is the name of the method to call, for example "GetServerTime"
|
|
2085
|
+
* @param {boolean} isStatic indicates if the method is static or not
|
|
2086
|
+
* @param {array} inputParams is an array of input parameters. Each element of the array is an object with the following properties: name, type, value
|
|
2087
|
+
* @param {array} outputParams is an array of output parameters. Each element of the array is an object with the following properties: name, type
|
|
2088
|
+
* @param {string} representation the expected representation ('xml', 'BadgerFish', or 'SimpleJson'). If not set, will use the current representation
|
|
2089
|
+
*
|
|
2090
|
+
* @returns {array} the method return values in the same order as was described in the outputParams array.
|
|
2091
|
+
* In addition, the outputParams array will be modified, and the "value" property of each output param will be set
|
|
2092
|
+
*/
|
|
2093
|
+
async makeSoapCall(urn, methodName, isStatic, inputParams, outputParams, representation) {
|
|
2094
|
+
const soapCall = this._prepareSoapCall(urn, methodName, isStatic, false,
|
|
2095
|
+
this._connectionParameters._options.extraHttpHeaders);
|
|
2096
|
+
// To support anonymous SOAP calls, we need to disable the logon check
|
|
2097
|
+
soapCall.requiresLogon = () => false;
|
|
2098
|
+
await this._makeInterceptableSoapCall(urn, null, soapCall, inputParams, outputParams, representation);
|
|
2099
|
+
const results = outputParams.map((o)=> o.value);
|
|
2100
|
+
return results;
|
|
2063
2101
|
}
|
|
2064
2102
|
|
|
2065
2103
|
async _makeHttpCall(request) {
|
package/test/client.test.js
CHANGED
|
@@ -1334,6 +1334,80 @@ describe('ACC Client', function () {
|
|
|
1334
1334
|
expect(extAccount).toEqual({ extAccount: [] });
|
|
1335
1335
|
});
|
|
1336
1336
|
|
|
1337
|
+
it("select with empty result - temporary schema", async () => {
|
|
1338
|
+
const client = await Mock.makeClient();
|
|
1339
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
1340
|
+
await client.NLWS.xtkSession.logon();
|
|
1341
|
+
|
|
1342
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
1343
|
+
|
|
1344
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
1345
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:queryDef' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
1346
|
+
<SOAP-ENV:Body>
|
|
1347
|
+
<ExecuteQueryResponse xmlns='urn:xtk:queryDef' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
1348
|
+
<pdomOutput xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
1349
|
+
<workflow_1047471_query2_result-collection/>
|
|
1350
|
+
</pdomOutput>
|
|
1351
|
+
</ExecuteQueryResponse>
|
|
1352
|
+
</SOAP-ENV:Body></SOAP-ENV:Envelope>`));
|
|
1353
|
+
|
|
1354
|
+
var queryDef = {
|
|
1355
|
+
"schema": "temp:workflow:1047471_query2_result",
|
|
1356
|
+
"operation": "select",
|
|
1357
|
+
"select": {
|
|
1358
|
+
"node": [
|
|
1359
|
+
{ "expr": "@id" },
|
|
1360
|
+
{ "expr": "@name" }
|
|
1361
|
+
]
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
// Select should return empty array
|
|
1366
|
+
var query = client.NLWS.xtkQueryDef.create(queryDef);
|
|
1367
|
+
var temp = await query.executeQuery();
|
|
1368
|
+
expect(temp).toEqual({ 'workflow_1047471_query2_result': [] });
|
|
1369
|
+
});
|
|
1370
|
+
|
|
1371
|
+
it("select with results - temporary schema", async () => {
|
|
1372
|
+
const client = await Mock.makeClient();
|
|
1373
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
1374
|
+
await client.NLWS.xtkSession.logon();
|
|
1375
|
+
|
|
1376
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
1377
|
+
|
|
1378
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
1379
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:queryDef' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
1380
|
+
<SOAP-ENV:Body>
|
|
1381
|
+
<ExecuteQueryResponse xmlns='urn:xtk:queryDef' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
1382
|
+
<pdomOutput xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
1383
|
+
<workflow_1047471_query2_result-collection>
|
|
1384
|
+
<workflow_1047471_query3_result _keyfield0="1195" id="1195">
|
|
1385
|
+
<target _cs="rner20 joewar (joewarner20@fake_domain.com)"></target>
|
|
1386
|
+
</workflow_1047471_query3_result>
|
|
1387
|
+
<workflow_1047471_query3_result _keyfield0="1198" id="1198">
|
|
1388
|
+
<target _cs="aliberte23 troyla (troylaliberte23@fake_domain.com)"></target>
|
|
1389
|
+
</workflow_1047471_query3_result>
|
|
1390
|
+
</workflow_1047471_query2_result-collection>
|
|
1391
|
+
</pdomOutput>
|
|
1392
|
+
</ExecuteQueryResponse>
|
|
1393
|
+
</SOAP-ENV:Body></SOAP-ENV:Envelope>`));
|
|
1394
|
+
|
|
1395
|
+
var queryDef = {
|
|
1396
|
+
"schema": "temp:workflow:1047471_query2_result",
|
|
1397
|
+
"operation": "select",
|
|
1398
|
+
"select": {
|
|
1399
|
+
"node": [
|
|
1400
|
+
{ "expr": "@id" },
|
|
1401
|
+
{ "expr": "target"}
|
|
1402
|
+
]
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
|
|
1406
|
+
var query = client.NLWS.xtkQueryDef.create(queryDef);
|
|
1407
|
+
var temp = await query.executeQuery();
|
|
1408
|
+
expect(temp.workflow_1047471_query3_result.length).toBe(2);
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1337
1411
|
it("getIfExists with a result of exactly one element", async () => {
|
|
1338
1412
|
const client = await Mock.makeClient();
|
|
1339
1413
|
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
@@ -2203,8 +2277,24 @@ describe('ACC Client', function () {
|
|
|
2203
2277
|
expect(client.isLogged()).toBeFalsy();
|
|
2204
2278
|
// Ensure logoff has been called
|
|
2205
2279
|
expect(logoff.mock.calls.length).toBe(1);
|
|
2206
|
-
})
|
|
2207
|
-
})
|
|
2280
|
+
});
|
|
2281
|
+
});
|
|
2282
|
+
|
|
2283
|
+
describe("Session and security tokens authentication", () => {
|
|
2284
|
+
it("Should create logged client", async() => {
|
|
2285
|
+
const connectionParameters = sdk.ConnectionParameters.ofSessionAndSecurityToken("http://acc-sdk:8080", "$session_token$", "$security_token$");
|
|
2286
|
+
const client = await sdk.init(connectionParameters);
|
|
2287
|
+
client._transport = jest.fn();
|
|
2288
|
+
expect(client.isLogged()).toBeFalsy();
|
|
2289
|
+
await client.logon();
|
|
2290
|
+
expect(client.isLogged()).toBeTruthy();
|
|
2291
|
+
const logoff = client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
|
|
2292
|
+
await client.logoff();
|
|
2293
|
+
expect(client.isLogged()).toBeFalsy();
|
|
2294
|
+
// Ensure logoff has been called
|
|
2295
|
+
expect(logoff.mock.calls.length).toBe(1);
|
|
2296
|
+
});
|
|
2297
|
+
});
|
|
2208
2298
|
|
|
2209
2299
|
describe("Bearer token authentication", () => {
|
|
2210
2300
|
// Bearer token authentication is used when embedding IMS for authentication
|
|
@@ -4142,4 +4232,55 @@ describe('ACC Client', function () {
|
|
|
4142
4232
|
await expect(jobs.linkTarget()).rejects.toThrow(/Cannot read (.*getSchema.*of null)|(.*of null.*getSchema)/);
|
|
4143
4233
|
});
|
|
4144
4234
|
});
|
|
4235
|
+
|
|
4236
|
+
describe("Anonymous SOAP calls", () => {
|
|
4237
|
+
it("Should call xtk:session#GetServerTime", async () => {
|
|
4238
|
+
const connectionParameters = sdk.ConnectionParameters.ofAnonymousUser("http://acc-sdk:8080");
|
|
4239
|
+
const client = await sdk.init(connectionParameters);
|
|
4240
|
+
client._transport = jest.fn();
|
|
4241
|
+
|
|
4242
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
4243
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
4244
|
+
<SOAP-ENV:Body>
|
|
4245
|
+
<GetServerTimeResponse xmlns='urn:xtk:session' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
4246
|
+
<ptmServerTime xsi:type='xsd:dateTime'>2023-08-25T13:58:11.477Z</ptmServerTime>
|
|
4247
|
+
</GetServerTimeResponse>
|
|
4248
|
+
</SOAP-ENV:Body>
|
|
4249
|
+
</SOAP-ENV:Envelope>`));
|
|
4250
|
+
|
|
4251
|
+
const inputParams = [];
|
|
4252
|
+
const outputParams = [{ name: "serverTime", type: "datetime" }];
|
|
4253
|
+
const result = await client.makeSoapCall("xtk:session", "GetServerTime", true, inputParams, outputParams);
|
|
4254
|
+
expect(result.length).toBe(1);
|
|
4255
|
+
expect(result[0]).toEqual(new Date("2023-08-25T13:58:11.477Z"));
|
|
4256
|
+
expect(outputParams[0].value).toEqual(new Date("2023-08-25T13:58:11.477Z"));
|
|
4257
|
+
});
|
|
4258
|
+
|
|
4259
|
+
it("Should call xtk:session#Logon", async () => {
|
|
4260
|
+
const connectionParameters = sdk.ConnectionParameters.ofAnonymousUser("http://acc-sdk:8080");
|
|
4261
|
+
const client = await sdk.init(connectionParameters);
|
|
4262
|
+
client._transport = jest.fn();
|
|
4263
|
+
|
|
4264
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
4265
|
+
|
|
4266
|
+
inputParams = [
|
|
4267
|
+
{ name: "login", type: "string", value: "admin" },
|
|
4268
|
+
{ name: "password", type: "string", value: "admin" },
|
|
4269
|
+
{ name: "parameters", type: "DOMElement", value: { rememberMe: true } },
|
|
4270
|
+
|
|
4271
|
+
];
|
|
4272
|
+
outputParams = [
|
|
4273
|
+
{ name: "sessionToken", type: "string" },
|
|
4274
|
+
{ name: "session", type: "DOMElement" },
|
|
4275
|
+
{ name: "securityToken", type: "string" },
|
|
4276
|
+
];
|
|
4277
|
+
const result = await client.makeSoapCall("xtk:session", "Logon", true, inputParams, outputParams);
|
|
4278
|
+
expect(result.length).toBe(3);
|
|
4279
|
+
expect(result[0]).toEqual("___$session_token$");
|
|
4280
|
+
expect(outputParams[0].value).toEqual("___$session_token$");
|
|
4281
|
+
expect(result[2]).toEqual("@$security_token$==");
|
|
4282
|
+
expect(outputParams[2].value).toEqual("@$security_token$==");
|
|
4283
|
+
expect(result[1].serverInfo.buildNumber).toBe("9219");
|
|
4284
|
+
});
|
|
4285
|
+
});
|
|
4145
4286
|
});
|