@digipair/skill-keycloak 0.7.3 → 0.8.1

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
@@ -33879,7 +33879,7 @@ let KeycloakService = class KeycloakService {
33879
33879
  }
33880
33880
  async page(params, _pinsSettingsList, context) {
33881
33881
  var _context_request_body;
33882
- const { body, title = 'Digipair', favicon = 'https://www.digipair.ai/assets/images/favicon.ico', styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', url = context.variables.KEYCLOAK_URL, realm = context.variables.KEYCLOAK_REALM, clientId = context.variables.KEYCLOAK_CLIENTID, libraries = {}, factoryInitialize = [], browserInitialize = [], browserLoad = [], logged = [], unlogged = [] } = params;
33882
+ const { body, title = 'Digipair', favicon = 'https://www.digipair.ai/assets/images/favicon.ico', styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM, clientId = context.privates.KEYCLOAK_CLIENTID, libraries = {}, factoryInitialize = [], browserInitialize = [], browserLoad = [], logged = [], unlogged = [] } = params;
33883
33883
  const engineVersion = libraries['@digipair/engine'] || 'latest';
33884
33884
  const preparedData = {};
33885
33885
  if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
@@ -33981,6 +33981,25 @@ let KeycloakService = class KeycloakService {
33981
33981
  `;
33982
33982
  return html;
33983
33983
  }
33984
+ async service(params, _pinsSettingsList, context) {
33985
+ var _context_request_headers_authorization;
33986
+ const { execute, secured = true, url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM } = params;
33987
+ 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, ''));
33988
+ if (token) {
33989
+ context.keycloak = {
33990
+ isLogged: true,
33991
+ decodedToken: await this.decodedToken(url, realm, context.request.headers.authorization.replace(/^Bearer /, ''))
33992
+ };
33993
+ } else {
33994
+ context.keycloak = {
33995
+ isLogged: false
33996
+ };
33997
+ }
33998
+ if (secured && !context.keycloak.decodedToken) {
33999
+ throw new Error('Unauthorized');
34000
+ }
34001
+ return await executePinsList(execute, context);
34002
+ }
33984
34003
  constructor(){
33985
34004
  this.skillKeycloak = `(() => {
33986
34005
  class KeycloakService {
@@ -34039,5 +34058,7 @@ let KeycloakService = class KeycloakService {
34039
34058
  }
34040
34059
  };
34041
34060
  const page = (params, pinsSettingsList, context)=>new KeycloakService().page(params, pinsSettingsList, context);
34061
+ const service = (params, pinsSettingsList, context)=>new KeycloakService().service(params, pinsSettingsList, context);
34042
34062
 
34043
34063
  exports.page = page;
34064
+ 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 i = i1, tokens = tokens1, nextMatch = nextMatch1, {
23496
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
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 i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23503
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "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 i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23522
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "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 i = i1, tokens = tokens1, nextMatch = nextMatch1, "continue";
23541
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, "continue";
23542
23542
  }
23543
- return i = i1, tokens = tokens1, nextMatch = nextMatch1, {
23543
+ return tokens = tokens1, i = i1, nextMatch = nextMatch1, {
23544
23544
  v: nextMatch1
23545
23545
  };
23546
23546
  };
@@ -33850,7 +33850,7 @@ let KeycloakService = class KeycloakService {
33850
33850
  }
33851
33851
  async page(params, _pinsSettingsList, context) {
33852
33852
  var _context_request_body;
33853
- const { body, title = 'Digipair', favicon = 'https://www.digipair.ai/assets/images/favicon.ico', styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', url = context.variables.KEYCLOAK_URL, realm = context.variables.KEYCLOAK_REALM, clientId = context.variables.KEYCLOAK_CLIENTID, libraries = {}, factoryInitialize = [], browserInitialize = [], browserLoad = [], logged = [], unlogged = [] } = params;
33853
+ const { body, title = 'Digipair', favicon = 'https://www.digipair.ai/assets/images/favicon.ico', styleHtml = '', styleBody = '', baseUrl = 'https://cdn.jsdelivr.net/npm', url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM, clientId = context.privates.KEYCLOAK_CLIENTID, libraries = {}, factoryInitialize = [], browserInitialize = [], browserLoad = [], logged = [], unlogged = [] } = params;
33854
33854
  const engineVersion = libraries['@digipair/engine'] || 'latest';
33855
33855
  const preparedData = {};
33856
33856
  if (context.request.method === 'POST' && ((_context_request_body = context.request.body) == null ? void 0 : _context_request_body.type) === 'DIGIPAIR_EXECUTE_FACTORY') {
@@ -33952,6 +33952,25 @@ let KeycloakService = class KeycloakService {
33952
33952
  `;
33953
33953
  return html;
33954
33954
  }
33955
+ async service(params, _pinsSettingsList, context) {
33956
+ var _context_request_headers_authorization;
33957
+ const { execute, secured = true, url = context.privates.KEYCLOAK_URL, realm = context.privates.KEYCLOAK_REALM } = params;
33958
+ 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, ''));
33959
+ if (token) {
33960
+ context.keycloak = {
33961
+ isLogged: true,
33962
+ decodedToken: await this.decodedToken(url, realm, context.request.headers.authorization.replace(/^Bearer /, ''))
33963
+ };
33964
+ } else {
33965
+ context.keycloak = {
33966
+ isLogged: false
33967
+ };
33968
+ }
33969
+ if (secured && !context.keycloak.decodedToken) {
33970
+ throw new Error('Unauthorized');
33971
+ }
33972
+ return await executePinsList(execute, context);
33973
+ }
33955
33974
  constructor(){
33956
33975
  this.skillKeycloak = `(() => {
33957
33976
  class KeycloakService {
@@ -34010,5 +34029,6 @@ let KeycloakService = class KeycloakService {
34010
34029
  }
34011
34030
  };
34012
34031
  const page = (params, pinsSettingsList, context)=>new KeycloakService().page(params, pinsSettingsList, context);
34032
+ const service = (params, pinsSettingsList, context)=>new KeycloakService().service(params, pinsSettingsList, context);
34013
34033
 
34014
- export { page };
34034
+ export { page, service };
@@ -1,2 +1,3 @@
1
1
  import { PinsSettings } from '@digipair/engine';
2
2
  export declare const page: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
3
+ export declare const service: (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.7.3",
3
+ "version": "0.8.1",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"
package/schema.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "schema": {
24
24
  "type": "array",
25
25
  "items": {
26
- "$ref": "https://www.pinser.world/schemas/pinsSettings"
26
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
27
27
  }
28
28
  }
29
29
  },
@@ -56,6 +56,53 @@
56
56
  "metadata": [],
57
57
  "parameters": []
58
58
  }
59
+ },
60
+ "/service": {
61
+ "summary": "Web service",
62
+ "description": "Réponse à un appel http.",
63
+ "tags": ["service"],
64
+ "metadata": [],
65
+ "parameters": [
66
+ {
67
+ "name": "execute",
68
+ "summary": "Exécute",
69
+ "required": true,
70
+ "description": "Commandes à exécuter",
71
+ "schema": {
72
+ "type": "array",
73
+ "items": {
74
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
75
+ }
76
+ }
77
+ },
78
+ {
79
+ "name": "secured",
80
+ "summary": "Sécurisé",
81
+ "required": false,
82
+ "description": "Accès autorisé seulement si un token Keycloak est fourni",
83
+ "schema": {
84
+ "type": "string"
85
+ }
86
+ },
87
+ {
88
+ "name": "url",
89
+ "summary": "Adresse du Keycloak",
90
+ "required": false,
91
+ "description": "Adresse du serveur Keycloak",
92
+ "schema": {
93
+ "type": "string"
94
+ }
95
+ },
96
+ {
97
+ "name": "realm",
98
+ "summary": "Realm",
99
+ "required": false,
100
+ "description": "Realm du serveur Keycloak",
101
+ "schema": {
102
+ "type": "string"
103
+ }
104
+ }
105
+ ]
59
106
  }
60
107
  },
61
108
  "components": {
@@ -76,7 +123,7 @@
76
123
  "schema": {
77
124
  "type": "array",
78
125
  "items": {
79
- "$ref": "https://www.pinser.world/schemas/pinsSettings"
126
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
80
127
  }
81
128
  }
82
129
  },
@@ -151,7 +198,7 @@
151
198
  "schema": {
152
199
  "type": "array",
153
200
  "items": {
154
- "$ref": "https://www.pinser.world/schemas/pinsSettings"
201
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
155
202
  }
156
203
  }
157
204
  },
@@ -163,7 +210,7 @@
163
210
  "schema": {
164
211
  "type": "array",
165
212
  "items": {
166
- "$ref": "https://www.pinser.world/schemas/pinsSettings"
213
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
167
214
  }
168
215
  }
169
216
  },
@@ -175,7 +222,7 @@
175
222
  "schema": {
176
223
  "type": "array",
177
224
  "items": {
178
- "$ref": "https://www.pinser.world/schemas/pinsSettings"
225
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
179
226
  }
180
227
  }
181
228
  },
@@ -187,7 +234,7 @@
187
234
  "schema": {
188
235
  "type": "array",
189
236
  "items": {
190
- "$ref": "https://www.pinser.world/schemas/pinsSettings"
237
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
191
238
  }
192
239
  }
193
240
  },
@@ -199,7 +246,7 @@
199
246
  "schema": {
200
247
  "type": "array",
201
248
  "items": {
202
- "$ref": "https://www.pinser.world/schemas/pinsSettings"
249
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
203
250
  }
204
251
  }
205
252
  }