Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
935bb64306 | |||
24e8a2d97a | |||
571efa201f | |||
a50e4df4ed | |||
c6b75f9236 | |||
9157d51471 | |||
0dc496d22a | |||
5f2350a9e7 | |||
e18fd0178d | |||
ebd7ccc171 |
1497
package-lock.json
generated
1497
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@consentsoftware/webclient",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.12",
|
||||
"private": false,
|
||||
"description": "a webclient for using consent.software in your website. Works with vanilla js, angular, react, you name it.",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -13,17 +13,17 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^14.11.2",
|
||||
"@types/node": "^14.14.0",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest": "^1.0.43",
|
||||
"@consentsoftware/interfaces": "^1.0.7",
|
||||
"@pushrocks/smarttime": "^3.0.35",
|
||||
"@pushrocks/webstore": "^1.0.14"
|
||||
"@apiglobal/typedrequest": "^1.0.54",
|
||||
"@consentsoftware/interfaces": "^1.0.10",
|
||||
"@pushrocks/smarttime": "^3.0.37",
|
||||
"@pushrocks/webstore": "^1.0.16"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
|
11
ts/index.ts
11
ts/index.ts
@ -29,7 +29,7 @@ export class CsWebclient {
|
||||
plugins.csInterfaces.IWebclientSettings['acceptedCookieLevels']
|
||||
> {
|
||||
const result = await this.webstore.get('acceptedCookieLevels');
|
||||
return result.acceptedCookieLevels;
|
||||
return result?.acceptedCookieLevels;
|
||||
}
|
||||
|
||||
public async isCookieLevelStillValid(): Promise<boolean> {
|
||||
@ -46,7 +46,7 @@ export class CsWebclient {
|
||||
return true;
|
||||
}
|
||||
|
||||
public async getAndRunConsentTuples() {
|
||||
public async getAndRunConsentTuples(domainArg?: string) {
|
||||
const acceptedCookieLevels = await this.getCookieLevels();
|
||||
if (!acceptedCookieLevels) {
|
||||
console.log('You need to set accepted cookielevels first');
|
||||
@ -55,15 +55,16 @@ export class CsWebclient {
|
||||
const csGetDomainSettingsRequest = new plugins.typedrequest.TypedRequest<
|
||||
plugins.csInterfaces.IRequest_Client_ConsentSoftwareServer_GetDomainSettings
|
||||
>('https://connect.api.global/consentsoftware', 'getDomainSettings');
|
||||
const domainToRequest = domainArg || window.location.hostname;
|
||||
const response = await csGetDomainSettingsRequest.fire({
|
||||
domain: window.location.hostname
|
||||
domain: domainToRequest
|
||||
});
|
||||
for (const consentTuple of response.consentTuples) {
|
||||
if (consentTuple.level === 'functional' || acceptedCookieLevels.includes(consentTuple.level)) {
|
||||
const scriptString = consentTuple.script as string;
|
||||
// tslint:disable-next-line: function-constructor
|
||||
const tupleFunction = new Function(scriptString);
|
||||
await tupleFunction();
|
||||
const tupleFunction = new Function(`return (${scriptString})()`);
|
||||
await tupleFunction(consentTuple.scriptExecutionDataArg);
|
||||
console.log (`Successfully executed ConsentTuple >>${consentTuple.name}<< -> ${consentTuple.description}`);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user