@adobe/acc-js-sdk 1.0.3 → 1.0.7
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/.github/workflows/codeql-analysis.yml +70 -0
- package/.vscode/launch.json +0 -1
- package/CHANGELOG.md +37 -1
- package/README.md +63 -3
- package/compile.js +2 -0
- package/package-lock.json +2438 -3367
- package/package.json +10 -7
- package/samples/002 - basics - schemas.js +3 -3
- package/samples/020 - encryption.js +5 -5
- package/src/application.js +66 -5
- package/src/cache.js +275 -0
- package/src/campaign.js +35 -22
- package/src/client.js +246 -125
- package/src/crypto.js +5 -2
- package/src/domUtil.js +53 -20
- package/src/entityAccessor.js +4 -2
- package/src/index.js +107 -105
- package/src/methodCache.js +55 -46
- package/src/optionCache.js +40 -28
- package/src/soap.js +53 -23
- package/src/transport.js +11 -7
- package/src/util.js +103 -64
- package/src/xtkCaster.js +66 -11
- package/src/xtkEntityCache.js +42 -24
- package/test/application.test.js +40 -1
- package/test/caches.test.js +214 -14
- package/test/client.test.js +485 -30
- package/test/crypto.test.js +16 -12
- package/test/domUtil.test.js +23 -0
- package/test/mock.js +52 -10
- package/test/soap.test.js +13 -6
- package/test/util.test.js +151 -1
- package/test/xtkCaster.test.js +97 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
|
2
|
+
# to commit it to your repository.
|
|
3
|
+
#
|
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
|
5
|
+
# or to provide custom queries or build logic.
|
|
6
|
+
#
|
|
7
|
+
# ******** NOTE ********
|
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
|
10
|
+
# supported CodeQL languages.
|
|
11
|
+
#
|
|
12
|
+
name: "CodeQL"
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: [ master ]
|
|
17
|
+
pull_request:
|
|
18
|
+
# The branches below must be a subset of the branches above
|
|
19
|
+
branches: [ master ]
|
|
20
|
+
schedule:
|
|
21
|
+
- cron: '34 13 * * 4'
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
analyze:
|
|
25
|
+
name: Analyze
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
permissions:
|
|
28
|
+
actions: read
|
|
29
|
+
contents: read
|
|
30
|
+
security-events: write
|
|
31
|
+
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
language: [ 'javascript' ]
|
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Checkout repository
|
|
41
|
+
uses: actions/checkout@v2
|
|
42
|
+
|
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
|
44
|
+
- name: Initialize CodeQL
|
|
45
|
+
uses: github/codeql-action/init@v1
|
|
46
|
+
with:
|
|
47
|
+
languages: ${{ matrix.language }}
|
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
|
52
|
+
|
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
|
55
|
+
- name: Autobuild
|
|
56
|
+
uses: github/codeql-action/autobuild@v1
|
|
57
|
+
|
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
59
|
+
# 📚 https://git.io/JvXDl
|
|
60
|
+
|
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
|
62
|
+
# and modify them (or add more) to build your code if your project
|
|
63
|
+
# uses a compiled language
|
|
64
|
+
|
|
65
|
+
#- run: |
|
|
66
|
+
# make bootstrap
|
|
67
|
+
# make release
|
|
68
|
+
|
|
69
|
+
- name: Perform CodeQL Analysis
|
|
70
|
+
uses: github/codeql-action/analyze@v1
|
package/.vscode/launch.json
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,43 @@
|
|
|
3
3
|
This is a node.js SDK for Campaign API. It exposes the Campaign API exactly like it is used inside Campaign using the NLWS notation.
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
# Changelog
|
|
6
|
+
# Changelog
|
|
7
|
+
|
|
8
|
+
## Version 1.0.7
|
|
9
|
+
_2022_01_24_
|
|
10
|
+
* Added a hook `refreshClient` on connection parameters. This is a callback called when an authentication token expires. It can be used to implement reconnection logic
|
|
11
|
+
* New attributes on the schema API (application.getSchema)
|
|
12
|
+
* The `enum` attribute of a schema node returns the corresponding enum attribute, i.e. the enumeration name
|
|
13
|
+
* The `target` attribute of a schema node (of type link) returns the target (schema id) of the link
|
|
14
|
+
* The `integrity` attribute of a schema node (of type link) returns the link integrity ("define", "own", etc.)
|
|
15
|
+
* Added a github workflow for code analysis (CodeQL) to detect more potential issues before release
|
|
16
|
+
* Upgrade dependencies to fix some vulnerabilities
|
|
17
|
+
* Add new conversion functions in XtkCaster to support for int, timespan, uuid, html and blob
|
|
18
|
+
|
|
19
|
+
## Version 1.0.6
|
|
20
|
+
_2021/11/03_
|
|
21
|
+
* New ofBearerToken authentication for IMS access token
|
|
22
|
+
* Fix a small issue in the compile script which did not create the dist folder if it was missing
|
|
23
|
+
* Fix an intermittent bug when running the SDK in the browser and when using local storage cache. The schema cache and method cache
|
|
24
|
+
should contain XML representation of Campaign schemas and methods. Before it is put in local storage, data needs to be serialized
|
|
25
|
+
as text. This was only working of JavaScript objects, but DOM elements were not being serialied causing various errors when
|
|
26
|
+
using the cache later
|
|
27
|
+
|
|
28
|
+
## Version 1.0.5
|
|
29
|
+
_2021/10/09_
|
|
30
|
+
* Fix an issue in the logon() function which was not always returning a promise. Some authentication methods such as SessionToken we returning synchronously. Made it so that logon always returns a promise. This should not be a breaking change as logon does not actually return a value
|
|
31
|
+
* Refactor caches (Options cache, Schemas cache, and Methods cache) to use a generic cache class
|
|
32
|
+
* Make sure options parameter of ConnectionParameters constructor is not modified
|
|
33
|
+
* Added a persistent cache for schemas, methods, and options using the browser localStorage by default
|
|
34
|
+
* Make sure X-Security-Token header is hidden as well as session token cookies
|
|
35
|
+
* Added jshint configuration and fixed warnings reported by jshint
|
|
36
|
+
* Fixed vulnerability in ansi-regex; upgrade jest-junit to version 13 to fix
|
|
37
|
+
* Small jsdoc improvements
|
|
38
|
+
|
|
39
|
+
## Version 1.0.4
|
|
40
|
+
_2021/10/07_
|
|
41
|
+
* Fix a bug which caused XML text and cdata elements to be skipped during SimpleJson transformation
|
|
42
|
+
* Make sure passwords are not logged (replace with "***") when activating traces
|
|
7
43
|
|
|
8
44
|
## Version 1.0.3
|
|
9
45
|
_2021/10/06_
|
package/README.md
CHANGED
|
@@ -14,6 +14,11 @@ See the [Change log](./CHANGELOG.md) for more information about the different ve
|
|
|
14
14
|
|
|
15
15
|
The API is fully asynchronous using promises and works as well on the server side than on the client side in the browser.
|
|
16
16
|
|
|
17
|
+
Install
|
|
18
|
+
```js
|
|
19
|
+
npm install --save @adobe/acc-js-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
17
22
|
The SDK entrypoint is the `sdk` object from which everything else can be created.
|
|
18
23
|
|
|
19
24
|
```js
|
|
@@ -115,6 +120,14 @@ Attribute|Default|Description
|
|
|
115
120
|
---|---|---
|
|
116
121
|
representation|"SimpleJson"| See below. Will determine if the SDK works with xml of json object. Default is JSON
|
|
117
122
|
rememberMe|false| The Campaign `rememberMe` attribute which can be used to extend the lifetime of session tokens
|
|
123
|
+
entityCacheTTL|300000| The TTL (in milliseconds) for the xtk entity cache
|
|
124
|
+
methodCacheTTL|300000| The TTL (in milliseconds) for the xtk method cache
|
|
125
|
+
optionCacheTTL|300000| The TTL (in milliseconds) for the xtk option cache
|
|
126
|
+
traceAPICalls|false| Activates tracing of API calls or not
|
|
127
|
+
transport|axios|Overrides the transport layer
|
|
128
|
+
noStorage|false|De-activate using of local storage
|
|
129
|
+
storage|localStorage|Overrides the local storage for caches
|
|
130
|
+
refreshClient|undefined|Async callback to run when the session token is expired
|
|
118
131
|
|
|
119
132
|
```js
|
|
120
133
|
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
@@ -133,6 +146,13 @@ const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
|
133
146
|
"https://myInstance.campaign.adobe.com",
|
|
134
147
|
"admin", "==ims_service_token_here");
|
|
135
148
|
```
|
|
149
|
+
## Login with IMS access token
|
|
150
|
+
The SDK supports IMS access token of an IMS user with the `ofBearerToken` function. Pass it a bearer token.
|
|
151
|
+
```js
|
|
152
|
+
const connectionParameters = sdk.ConnectionParameters.ofBearerToken(
|
|
153
|
+
"https://myInstance.campaign.adobe.com",
|
|
154
|
+
"ims_bearer_token");
|
|
155
|
+
````
|
|
136
156
|
|
|
137
157
|
## Login with Session token
|
|
138
158
|
|
|
@@ -200,6 +220,19 @@ await client.logon();
|
|
|
200
220
|
await client.logoff();
|
|
201
221
|
```
|
|
202
222
|
|
|
223
|
+
## refreshClient callback
|
|
224
|
+
The refreshClient is an async callback function with the SDK client as parameter, it is called when the ACC session is expired.
|
|
225
|
+
The callback must refresh the client session and return it. if a SOAP query fails with session expiration error then it will be retried when the callback is defined.
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
const connectionParameters = sdk.ConnectionParameters.ofUserAndPassword(
|
|
229
|
+
url, "admin", "admin",
|
|
230
|
+
{ refreshClient: async (client) => {
|
|
231
|
+
await client.logon();
|
|
232
|
+
return client;
|
|
233
|
+
}});
|
|
234
|
+
```
|
|
235
|
+
|
|
203
236
|
## IP Whitelisting
|
|
204
237
|
|
|
205
238
|
Campaign includes an IP whitelisting component which prevents connections from unauthorized IP addresses. This is a common source of authentication errors.
|
|
@@ -560,7 +593,7 @@ It's also noteworthy that all the data returned in a CampaignException is trimme
|
|
|
560
593
|
|
|
561
594
|
## Caches
|
|
562
595
|
|
|
563
|
-
The following caches are
|
|
596
|
+
The following caches are managed by the SDK and active by default. They are in-memory caches.
|
|
564
597
|
|
|
565
598
|
* Options cache. Stores typed option values, by option name.
|
|
566
599
|
* Entity cache. Caches schemas and other entities
|
|
@@ -578,6 +611,21 @@ or
|
|
|
578
611
|
client.clearAllCaches();
|
|
579
612
|
```
|
|
580
613
|
|
|
614
|
+
Caches have a TTL of 5 minutes by default. The TTL can be changed at connection time using connection options `entityCacheTTL`, `methodCacheTTL`, and `optionCacheTTL`.
|
|
615
|
+
|
|
616
|
+
Caches can be de-activated by setting a TTL of -1 which will have the effect of making all cached data always invalid.
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
## Persistent caches
|
|
621
|
+
In addition to memory caches, it is possible to use persistent caches as well. This was introduced in version 1.0.5 and is active by default as well when using the SDK in a browser. The browser local storage is used (if allowed).
|
|
622
|
+
|
|
623
|
+
Cached data is stored in local storage with keys prefixed with `acc.js.sdk.{{version}}.{{server}}.cache.` where `version` is the SDK version and `server` is the Campaign server name. This means that the cached data is lost when upgrading the SDK.
|
|
624
|
+
|
|
625
|
+
It's possible to disable persistent caches using the `noStorage` connection option.
|
|
626
|
+
|
|
627
|
+
It is also possible to setup one's own persistent cache, by passing a `storage` object as a connection option. This object should implement 3 methods: `getItem`, `setItem`, and `removeItem` (synchronous)
|
|
628
|
+
|
|
581
629
|
|
|
582
630
|
## Passwords
|
|
583
631
|
|
|
@@ -1412,9 +1460,20 @@ If you need to access entity attributes (or child elements) in a generic way, yo
|
|
|
1412
1460
|
|
|
1413
1461
|
To build this project, you need node and npm
|
|
1414
1462
|
|
|
1415
|
-
|
|
1463
|
+
```sh
|
|
1416
1464
|
npm install
|
|
1417
|
-
|
|
1465
|
+
```
|
|
1466
|
+
|
|
1467
|
+
## Check and resolve any security issues
|
|
1468
|
+
```sh
|
|
1469
|
+
npm audit
|
|
1470
|
+
npm audit fix --force
|
|
1471
|
+
```
|
|
1472
|
+
|
|
1473
|
+
## Check if there are any code warnings
|
|
1474
|
+
```sh
|
|
1475
|
+
node_modules/jshint/bin/jshint src/
|
|
1476
|
+
```
|
|
1418
1477
|
|
|
1419
1478
|
## Run tests
|
|
1420
1479
|
```sh
|
|
@@ -1424,6 +1483,7 @@ npm run unit-tests
|
|
|
1424
1483
|
## Build JavaScript documentation
|
|
1425
1484
|
```sh
|
|
1426
1485
|
npm run jsdoc
|
|
1486
|
+
open ./docs/jsdoc/index.html
|
|
1427
1487
|
```
|
|
1428
1488
|
|
|
1429
1489
|
The HTML doc will be generated in the docs/ folder
|
package/compile.js
CHANGED
|
@@ -31,6 +31,7 @@ var resources = [
|
|
|
31
31
|
{ name: "./transport.js" },
|
|
32
32
|
{ name: "./xtkCaster.js" },
|
|
33
33
|
{ name: "./domUtil.js" },
|
|
34
|
+
{ name: "./cache.js" },
|
|
34
35
|
{ name: "./entityAccessor.js" },
|
|
35
36
|
{ name: "./xtkEntityCache.js" },
|
|
36
37
|
{ name: "./methodCache.js" },
|
|
@@ -44,6 +45,7 @@ var resources = [
|
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
const outFileName = "./dist/bundle.js";
|
|
48
|
+
if (!fs.existsSync("./dist")) fs.mkdirSync("./dist");
|
|
47
49
|
const rootPath = "./src";
|
|
48
50
|
|
|
49
51
|
|