@digipair/skill-keycloak 0.10.7 → 0.10.9

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/index.cjs.js CHANGED
@@ -23522,14 +23522,14 @@ function indent(str, spaces) {
23522
23522
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23523
23523
  // match is required
23524
23524
  if (!match) {
23525
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
23525
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23526
23526
  v: nextMatch1
23527
23527
  };
23528
23528
  }
23529
23529
  var token = match.token, offset = match.offset;
23530
23530
  i1 += offset;
23531
23531
  if (token === " ") {
23532
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23532
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23533
23533
  }
23534
23534
  tokens1 = _to_consumable_array$3(tokens1).concat([
23535
23535
  token
@@ -23548,7 +23548,7 @@ function indent(str, spaces) {
23548
23548
  if (contextKeys.some(function(el) {
23549
23549
  return el.startsWith(name);
23550
23550
  })) {
23551
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23551
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23552
23552
  }
23553
23553
  if (dateTimeIdentifiers.some(function(el) {
23554
23554
  return el === name;
@@ -23567,9 +23567,9 @@ function indent(str, spaces) {
23567
23567
  if (dateTimeIdentifiers.some(function(el) {
23568
23568
  return el.startsWith(name);
23569
23569
  })) {
23570
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23570
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23571
23571
  }
23572
- return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
23572
+ return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23573
23573
  v: nextMatch1
23574
23574
  };
23575
23575
  };
@@ -34019,6 +34019,31 @@ let KeycloakService = class KeycloakService {
34019
34019
  }
34020
34020
  return await executePinsList(execute, context);
34021
34021
  }
34022
+ async boost(params, _pinsSettingsList, context) {
34023
+ var _context_request_headers_authorization;
34024
+ if (context.request.method !== 'POST') {
34025
+ return {
34026
+ error: 'Method not allowed'
34027
+ };
34028
+ }
34029
+ const { execute, secured = true, url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM } = params;
34030
+ const token = /^Bearer /g.test(context.request.headers.authorization) && ((_context_request_headers_authorization = context.request.headers.authorization) == null ? void 0 : _context_request_headers_authorization.replace(/^Bearer /g, ''));
34031
+ if (token) {
34032
+ context.keycloak = {
34033
+ isLogged: true,
34034
+ decodedToken: await this.decodedToken(url, realm, context.request.headers.authorization.replace(/^Bearer /, ''))
34035
+ };
34036
+ } else {
34037
+ context.keycloak = {
34038
+ isLogged: false
34039
+ };
34040
+ }
34041
+ if (secured && !context.keycloak.decodedToken) {
34042
+ throw new Error('Unauthorized');
34043
+ }
34044
+ const result = await executePinsList(execute, context);
34045
+ return result;
34046
+ }
34022
34047
  constructor(){
34023
34048
  this.skillKeycloak = `(() => {
34024
34049
  class KeycloakService {
@@ -34078,6 +34103,8 @@ let KeycloakService = class KeycloakService {
34078
34103
  };
34079
34104
  const page = (params, pinsSettingsList, context)=>new KeycloakService().page(params, pinsSettingsList, context);
34080
34105
  const service = (params, pinsSettingsList, context)=>new KeycloakService().service(params, pinsSettingsList, context);
34106
+ const boost = (params, pinsSettingsList, context)=>new KeycloakService().boost(params, pinsSettingsList, context);
34081
34107
 
34108
+ exports.boost = boost;
34082
34109
  exports.page = page;
34083
34110
  exports.service = service;
package/index.esm.js CHANGED
@@ -23493,14 +23493,14 @@ function indent(str, spaces) {
23493
23493
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23494
23494
  // match is required
23495
23495
  if (!match) {
23496
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23496
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
23497
23497
  v: nextMatch1
23498
23498
  };
23499
23499
  }
23500
23500
  var token = match.token, offset = match.offset;
23501
23501
  i1 += offset;
23502
23502
  if (token === " ") {
23503
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23503
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23504
23504
  }
23505
23505
  tokens1 = _to_consumable_array$3(tokens1).concat([
23506
23506
  token
@@ -23519,7 +23519,7 @@ function indent(str, spaces) {
23519
23519
  if (contextKeys.some(function(el) {
23520
23520
  return el.startsWith(name);
23521
23521
  })) {
23522
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23522
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23523
23523
  }
23524
23524
  if (dateTimeIdentifiers.some(function(el) {
23525
23525
  return el === name;
@@ -23538,9 +23538,9 @@ function indent(str, spaces) {
23538
23538
  if (dateTimeIdentifiers.some(function(el) {
23539
23539
  return el.startsWith(name);
23540
23540
  })) {
23541
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23541
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, "continue";
23542
23542
  }
23543
- return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23543
+ return i = i1, nextMatch = nextMatch1, tokens = tokens1, {
23544
23544
  v: nextMatch1
23545
23545
  };
23546
23546
  };
@@ -33990,6 +33990,31 @@ let KeycloakService = class KeycloakService {
33990
33990
  }
33991
33991
  return await executePinsList(execute, context);
33992
33992
  }
33993
+ async boost(params, _pinsSettingsList, context) {
33994
+ var _context_request_headers_authorization;
33995
+ if (context.request.method !== 'POST') {
33996
+ return {
33997
+ error: 'Method not allowed'
33998
+ };
33999
+ }
34000
+ const { execute, secured = true, url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM } = params;
34001
+ const token = /^Bearer /g.test(context.request.headers.authorization) && ((_context_request_headers_authorization = context.request.headers.authorization) == null ? void 0 : _context_request_headers_authorization.replace(/^Bearer /g, ''));
34002
+ if (token) {
34003
+ context.keycloak = {
34004
+ isLogged: true,
34005
+ decodedToken: await this.decodedToken(url, realm, context.request.headers.authorization.replace(/^Bearer /, ''))
34006
+ };
34007
+ } else {
34008
+ context.keycloak = {
34009
+ isLogged: false
34010
+ };
34011
+ }
34012
+ if (secured && !context.keycloak.decodedToken) {
34013
+ throw new Error('Unauthorized');
34014
+ }
34015
+ const result = await executePinsList(execute, context);
34016
+ return result;
34017
+ }
33993
34018
  constructor(){
33994
34019
  this.skillKeycloak = `(() => {
33995
34020
  class KeycloakService {
@@ -34049,5 +34074,6 @@ let KeycloakService = class KeycloakService {
34049
34074
  };
34050
34075
  const page = (params, pinsSettingsList, context)=>new KeycloakService().page(params, pinsSettingsList, context);
34051
34076
  const service = (params, pinsSettingsList, context)=>new KeycloakService().service(params, pinsSettingsList, context);
34077
+ const boost = (params, pinsSettingsList, context)=>new KeycloakService().boost(params, pinsSettingsList, context);
34052
34078
 
34053
- export { page, service };
34079
+ export { boost, page, service };
@@ -1,3 +1,4 @@
1
1
  import { PinsSettings } from '@digipair/engine';
2
2
  export declare const page: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
3
3
  export declare const service: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
4
+ export declare const boost: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-keycloak",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
package/schema.json CHANGED
@@ -251,6 +251,52 @@
251
251
  }
252
252
  }
253
253
  ]
254
+ },
255
+ "/boost": {
256
+ "summary": "Boost sécurisé",
257
+ "description": "Boost proposé par le Digipair sécurisé par Keycloak",
258
+ "tags": ["boost", "service"],
259
+ "metadata": [
260
+ {
261
+ "name": "boosts",
262
+ "summary": "Liste des déclencheurs",
263
+ "required": true,
264
+ "description": "Liste des déclencheurs du boost",
265
+ "schema": {
266
+ "type": "array",
267
+ "items": {
268
+ "$ref": "#/components/schemas/Boost"
269
+ }
270
+ }
271
+ },
272
+ {
273
+ "name": "secured",
274
+ "summary": "Sécurisé",
275
+ "required": false,
276
+ "description": "Accès autorisé seulement si un token Keycloak est fourni",
277
+ "schema": {
278
+ "type": "string"
279
+ }
280
+ },
281
+ {
282
+ "name": "url",
283
+ "summary": "Adresse du Keycloak",
284
+ "required": false,
285
+ "description": "Adresse du serveur Keycloak",
286
+ "schema": {
287
+ "type": "string"
288
+ }
289
+ },
290
+ {
291
+ "name": "realm",
292
+ "summary": "Realm",
293
+ "required": false,
294
+ "description": "Realm du serveur Keycloak",
295
+ "schema": {
296
+ "type": "string"
297
+ }
298
+ }
299
+ ]
254
300
  }
255
301
  }
256
302
  }