scimgateway 5.1.2 → 5.1.3

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/README.md CHANGED
@@ -7,7 +7,7 @@ Author: Jarle Elshaug
7
7
 
8
8
  Validated through IdP's:
9
9
 
10
- - Symantec/Broadcom/CA Identity Manager
10
+ - Symantec/Broadcom Identity Manager
11
11
  - Microsoft Entra ID
12
12
  - One Identity Manager/OneLogin
13
13
  - Okta
@@ -78,7 +78,7 @@ Demonstrates SAP HANA specific user provisioning
78
78
  Entra ID user provisioning including license management (App Service plans) e.g. Office 365
79
79
  Using Microsoft Graph API through HelperRest
80
80
  Using customized SCIM attributes according to Microsoft Graph API
81
- Includes Symantec/Broadcom/CA ConnectorXpress metafile for creating provisioning "Azure - ScimGateway" endpoint type
81
+ Includes Symantec/Broadcom ConnectorXpress metafile for creating provisioning "Azure - ScimGateway" endpoint type
82
82
 
83
83
  * **LDAP** (Directory)
84
84
  Fully functional LDAP plugin
@@ -122,8 +122,6 @@ If internet connection is blocked, we could install on another machine and copy
122
122
  #### Startup and verify default Loki plugin
123
123
 
124
124
  bun c:\my-scimgateway
125
-
126
- If using Node.js instead of Bun, scimgateway must be downloaded from github and startup: node --experimental-strip-types c:\my-scimgateway\index.ts
127
125
 
128
126
  Start a browser (note, Edge do not pop-up logon dialog box when using http)
129
127
 
@@ -152,6 +150,8 @@ If internet connection is blocked, we could install on another machine and copy
152
150
 
153
151
  >Tip, take a look at bun test scripts located in `node_modules\scimgateway\test\lib`
154
152
 
153
+ > If using Node.js instead of Bun, scimgateway must be downloaded from github and startup:
154
+ node --experimental-strip-types c:\my-scimgateway\index.ts
155
155
 
156
156
  #### Upgrade SCIM Gateway
157
157
 
@@ -413,13 +413,11 @@ Definitions in `endpoint` object are customized according to our plugin code. Pl
413
413
  "ca": null
414
414
  }
415
415
 
416
- Example of how to make a self signed certificate:
417
-
418
- openssl req -nodes -newkey rsa:2048 -x509 -sha256 -days 3650 -keyout key.pem -out cert.pem -subj "/O=Testing/OU=SCIM Gateway/CN=<FQDN>" -config "<path>\openssl.cnf"
416
+ Example of how to make a self signed certificate:
419
417
 
420
- `<FQDN>` is Fully Qualified Domain Name of the host having SCIM Gateway installed
418
+ openssl.exe req -nodes -newkey rsa:2048 -x509 -sha256 -days 3650 -keyout key.pem -out cert.pem -subj "/O=My Company/OU=Application/CN=SCIM Gateway" -addext "subjectAltName=DNS:localhost,DNS:127.0.0.1,DNS:*.mycompany.com" -addext "extendedKeyUsage=serverAuth" -addext "keyUsage=digitalSignature"
421
419
 
422
- Note, when using Symantec/Broadcom/CA Provisioning, the "certificate authority - CA" also have to be imported on the Connector Server. For self-signed certificate CA and the certificate (public key) is the same.
420
+ Note, when using Symantec/Broadcom Provisioning, the "certificate authority - CA" also must be imported on the Connector Server. For self-signed certificate, CA and the certificate (public key) is the same.
423
421
 
424
422
  PFX / PKCS#12 bundle can be used instead of key/cert/ca e.g:
425
423
 
@@ -428,7 +426,7 @@ Definitions in `endpoint` object are customized according to our plugin code. Pl
428
426
  "password": "password"
429
427
  }
430
428
 
431
- Note, we should normally use certificate (https) for communicating with SCIM Gateway unless we install ScimGatway locally on the manager (e.g. on the CA Connector Server). When installed on the manager, we could use `http://localhost:port` or `http://127.0.0.1:port` which will not be passed down to the data link layer for transmission. We could then also set {"localhostonly": true}
429
+ Note, we should normally use certificate (https) for communicating with SCIM Gateway unless we install gateway locally on the manager (e.g. on the provisioning Connector Server). When installed on the manager, we could use `http://localhost:port` or `http://127.0.0.1:port` which will not be passed down to the data link layer for transmission. We could then also set {"localhostonly": true}
432
430
 
433
431
  - **ipAllowList** - Array of one or more IPv4/IPv6 subnets (CIDR) allowed for incoming traffic. E.g. using Entra ID as IdP, we would like to restrict access to IP addresses used by Azure. Azure IP-range can be downloaded from: [https://azureipranges.azurewebsites.net](https://azureipranges.azurewebsites.net), enter **AzureActiveDirectory** in the search list and select JSON download. Copy the "addressPrefixes" array content and paste into ipAllowList array. CIDR single IP-host syntax is a.b.c.d/32. Note, front-end HTTP proxy or a load balancer must include client IP-address in the **X-Forwarded-For** header. Configuration example:
434
432
 
@@ -606,8 +604,6 @@ Definitions in `endpoint` object are customized according to our plugin code. Pl
606
604
 
607
605
  Using `scimgateway.authPassThroughAllowed = true` and `plugin-<name>.json` configuration `scimgateway.auth.passThrough=true` enables Authentication PassTrhough
608
606
 
609
-
610
-
611
607
  ## Manual startup
612
608
 
613
609
  Gateway can be started from a command window running in administrative mode
@@ -795,16 +791,11 @@ Some notes related to Entra ID:
795
791
  - Deleting a user in Entra ID sends a modify user `{"active":"False"}` which means user should be disabled. This logic is default set in attribute mappings expression rule `Switch([IsSoftDeleted], , "False", "True", "True", "False")`. Standard SCIM "DELETE" method seems not to be used.
796
792
 
797
793
 
798
- ## CA Identity Manager as IdP using SCIM Gateway
799
-
800
- Using Symantec/Broadcom/CA Identity Manger, plugin configuration might have to use **SCIM Version "1.1"** (scimgateway.scim.version).
801
-
802
- In the Provisioning Manager we have to use
794
+ ## Symantec Identity Manager as IdP using SCIM Gateway
803
795
 
796
+ Using Symantec/Broadcom Identity Manger, plugin configuration must use **SCIM Version "1.1"** (scimgateway.scim.version).
804
797
 
805
- `Endpoint type = SCIM (DYN Endpoint)`
806
-
807
- or create our own custom endpoint type based on this one
798
+ In the Provisioning Manager we could use `Endpoint type = SCIM (DYN Endpoint)` or create our own custom endpoint type based on this one
808
799
 
809
800
  SCIM endpoint configuration example for Loki plugin (plugin-loki)
810
801
 
@@ -829,13 +820,10 @@ http://localhost:8880/client-b
829
820
 
830
821
  Each baseEntity should then be defined in the plugin configuration file with custom attributes needed. Please see examples in plugin-soap.json
831
822
 
832
- IM 12.6 SP7 (and above) also supports pagination for SCIM endpoint (data transferred in bulks - endpoint explore of users). Loki plugin supports pagination. Other plugin may ignore this setting.
833
-
834
-
835
823
  ## Entra ID provisioning
836
824
  Using plugin-entra-id we could do user provisioning towards Entra ID
837
825
 
838
- For testing purposes we could get an Azure free account
826
+ For testing purposes we could get an Azure free account
839
827
 
840
828
  ### Entra ID configuration
841
829
 
@@ -861,25 +849,30 @@ For testing purposes we could get an Azure free account
861
849
  - Application permissions
862
850
  - Directory - Directory.ReadWriteAll
863
851
  - Organization - Organization.ReadWrite.All
864
- - Click "Add permissions"
865
- Note, we also have to go to Enterprise application to grant these consents
866
- - Microsoft Entra ID - Enterprise applications - SCIM Gateway Inbound
867
- - Permissions:
868
- - Click "Grant admin consent for [tenant name]"
869
- - In the logon dialog, logon as global administrator
870
- - In permissions request dialog, click "Accept"
871
- - Click "Refresh", directory and organization permissions are now listed and OK
852
+ - Click "Add permissions"
853
+ - API permissions: - Grant Admin consent
854
+ Or we could go to Enterprise application to grant these consents:
855
+ - Microsoft Entra ID - Enterprise applications - SCIM Gateway Inbound
856
+ - Permissions:
857
+ - Click "Grant admin consent for [tenant name]"
858
+ - In the logon dialog, logon as global administrator
859
+ - In permissions request dialog, click "Accept"
860
+ - Click "Refresh", directory and organization permissions are now listed and OK
872
861
 
873
862
 
874
- **For some odd reasons Application needs to be member of "User administrator" for having privileges to manage office/mobile phone on users that is member of any administrator roles**
863
+ **Seems Application needs to be member of "User administrator" for having privileges to manage office/mobile phone on users that is member of any administrator roles**
875
864
 
876
865
  Also note, enable/disable user (accountEnabled - through Graph API) will fail if user have an "Administrator" role other than above mentioned "User Administrator" e.g. "Group Administrator"/"Application Administrator". To be sure we can enable/disable all users, application needs to be member of **"Global administrator"** - 62e90394-69f5-4237-9190-012177145e10.
877
866
 
878
- - Microsoft Entra ID - Roles and administration
879
- - Click on role **"User administrator"**
867
+ - Microsoft Entra ID - Manage - Roles and administrators
868
+ - Search: User administrator
869
+ - Click on role **User administrator**
880
870
  - Click "Add assignments"
881
- - Search: SCIM Gateway Inbound (application name)
882
- - Select the application that shows up and click "Add"
871
+ - Click "No member selected" to add members
872
+ - Search: SCIM Gateway Inbound (name of the application we have created)
873
+ - Select the application name that shows up and click "Add"
874
+ - Click Next
875
+ - Assignment type=Active and enable "Permanent assigned", add some justification text and click "Assign"
883
876
 
884
877
  ### SCIM Gateway configuration
885
878
 
@@ -890,7 +883,7 @@ Set plugin to be started to `entra-id`
890
883
 
891
884
  **Edit plugin-entra-id.json**
892
885
 
893
- Note, for Symantec/Broadcom/CA Provisioning we must use SCIM version 1.1
886
+ Note, for Symantec/Broadcom Provisioning we must use SCIM version 1.1
894
887
 
895
888
  scimgateway: {
896
889
  "scim": {
@@ -964,7 +957,7 @@ For additional details, see baseEntity description.
964
957
 
965
958
  Note, we should normally use certificate (https) for communicating with SCIM Gateway unless we install gateway locally on the manager (e.g. on the CA Connector Server). When installed on the manager, we could use `http://localhost:port` or `http://127.0.0.1:port` which will not be passed down to the data link layer for transmission. We could then also set {"localhostonly": true}
966
959
 
967
- ### Using Symantec/Broadcom/CA Provisioning
960
+ ### Using Symantec/Broadcom Provisioning
968
961
  Create a new endpoint type "Azure - ScimGateway"
969
962
 
970
963
  - Start SCIM Gateway
@@ -1182,6 +1175,39 @@ MIT © [Jarle Elshaug](https://www.elshaug.xyz)
1182
1175
 
1183
1176
  ## Change log
1184
1177
 
1178
+ ### v5.1.3
1179
+
1180
+ [Fixed]
1181
+
1182
+ - HelperRest, auth.type=`oauthJwtBearer` and auth.options=`tenantIdGUID`
1183
+
1184
+ Configuration example using Entra ID application having uploaded cert.pem as certificate secret:
1185
+
1186
+ "endpoint": {
1187
+ "entity": {
1188
+ "undefined": {
1189
+ "connection": {
1190
+ "baseUrls": [],
1191
+ "auth": {
1192
+ "type": "oauthJwtBearer",
1193
+ "options": {
1194
+ "tenantIdGUID": "Entra ID Tenant ID (GUID)",
1195
+ "clientId": "<application clientId>",
1196
+ "certificate": { // files located in ./config/certs
1197
+ "key": "key.pem",
1198
+ "cert": "cert.pem"
1199
+ }
1200
+ }
1201
+ }
1202
+ }
1203
+ }
1204
+ }
1205
+ }
1206
+
1207
+ Please see code editor method HelperRest doRequest() IntelliSense for details
1208
+
1209
+ Note, this fix may break `plugin-entra-id` if baseUrls configuration not empty. If baseUrl not empty, it will be used. If empty, baseUrl will automatically be set according to graph api when using tenantIdGUID definition
1210
+
1185
1211
  ### v5.1.2
1186
1212
 
1187
1213
  [Improved]
@@ -132,16 +132,13 @@
132
132
  "entity": {
133
133
  "undefined": {
134
134
  "connection": {
135
- "baseUrls": [
136
- "not in use for Entra ID when tenantIdGUID is defined"
137
- ],
135
+ "baseUrls": [],
138
136
  "auth": {
139
137
  "type": "oauth",
140
138
  "options": {
141
- "tokenUrl": "oauth token_url - not in use when tenantIdGUID is defined",
142
- "tenantIdGUID": "Entra ID Tenant ID (GUID) or Primary domain name - only used by plugin-entra-id",
143
- "clientId": "oauth client_id - Entra ID: Application ID",
144
- "clientSecret": "oauth client_secret - Entra ID: generated application secret value"
139
+ "tenantIdGUID": "Entra ID Tenant ID (GUID)",
140
+ "clientId": "Entra ID Application ID",
141
+ "clientSecret": "Entra ID Application secret value"
145
142
  }
146
143
  },
147
144
  "proxy": {
@@ -40,17 +40,24 @@ export class HelperRest {
40
40
  for (const baseEntity in this.config_entity) {
41
41
  entityFound = true
42
42
  if (this.config_entity[baseEntity]?.connection) {
43
- if (this.config_entity[baseEntity]?.connection?.auth?.options?.tenantIdGUID) { // Entra ID, setting baseUrls to graph
44
- if (this.config_entity[baseEntity]?.connection?.auth?.type === 'oauth') {
45
- this.config_entity[baseEntity].connection.baseUrls = [this.graphUrl]
46
- }
47
- } else if (this.config_entity[baseEntity]?.connection?.auth?.options?.serviceAccountKeyFile) { // Google, setting baseUrls to googleapis
48
- const type = this.config_entity[baseEntity]?.connection?.auth?.type
49
- if (type === 'oauthJwtBearer' || type === 'oauth') { // includes oauth because of email.auth.type
50
- this.config_entity[baseEntity].connection.baseUrls = [this.googleUrl]
43
+ connectionFound = true
44
+ const type = this.config_entity[baseEntity].connection?.auth?.type
45
+ if (type === 'oauthJwtBearer' || type === 'oauth') { // includes oauth because of email.auth.type
46
+ // set default baseUrls for Entra ID and Google if not already defined
47
+ if (this.config_entity[baseEntity]?.connection?.auth?.options?.tenantIdGUID) { // Entra ID, setting baseUrls to graph
48
+ if (!this.config_entity[baseEntity].connection.baseUrls) {
49
+ this.config_entity[baseEntity].connection.baseUrls = [this.graphUrl]
50
+ } else if (this.config_entity[baseEntity].connection.baseUrls?.length < 1) {
51
+ this.config_entity[baseEntity].connection.baseUrls = [this.graphUrl]
52
+ }
53
+ } else if (this.config_entity[baseEntity]?.connection?.auth?.options?.serviceAccountKeyFile) { // Google, setting baseUrls to googleapis
54
+ if (!this.config_entity[baseEntity].connection.baseUrls) {
55
+ this.config_entity[baseEntity].connection.baseUrls = [this.googleUrl]
56
+ } else if (this.config_entity[baseEntity].connection.baseUrls?.length < 1) {
57
+ this.config_entity[baseEntity].connection.baseUrls = [this.googleUrl]
58
+ }
51
59
  }
52
60
  }
53
- connectionFound = true
54
61
  }
55
62
  }
56
63
  let errMsg = ''
@@ -80,123 +87,232 @@ export class HelperRest {
80
87
  let form: object
81
88
  let resource = ''
82
89
 
83
- switch (this.config_entity[baseEntity]?.connection?.auth?.type) {
84
- case 'oauth':
85
- try {
86
- const urlObj = new URL(this.config_entity[baseEntity].connection.baseUrls[0])
87
- resource = urlObj.origin
88
- } catch (err) { void 0 }
89
- if (this.config_entity[baseEntity].connection.auth?.options?.tenantIdGUID) { // Azure
90
- tokenUrl = `https://login.microsoftonline.com/${this.config_entity[baseEntity].connection.auth.options.tenantIdGUID}/oauth2/token`
91
- } else {
90
+ try {
91
+ switch (this.config_entity[baseEntity]?.connection?.auth?.type) {
92
+ case 'oauth':
93
+ try {
94
+ const urlObj = new URL(this.config_entity[baseEntity].connection.baseUrls[0])
95
+ resource = urlObj.origin
96
+ } catch (err) { void 0 }
97
+ if (this.config_entity[baseEntity].connection.auth?.options?.tenantIdGUID) { // Azure
98
+ tokenUrl = `https://login.microsoftonline.com/${this.config_entity[baseEntity].connection.auth.options.tenantIdGUID}/oauth2/token`
99
+ } else {
100
+ tokenUrl = this.config_entity[baseEntity].connection.auth.options.tokenUrl
101
+ }
102
+ form = {
103
+ grant_type: 'client_credentials',
104
+ client_id: this.config_entity[baseEntity].connection.auth.options.clientId,
105
+ client_secret: this.config_entity[baseEntity].connection.auth.options.clientSecret,
106
+ scope: this.config_entity[baseEntity].connection.auth.options.scope || null,
107
+ resource: resource || null, // "https://graph.microsoft.com"
108
+ }
109
+ break
110
+
111
+ case 'token':
92
112
  tokenUrl = this.config_entity[baseEntity].connection.auth.options.tokenUrl
93
- }
94
- form = {
95
- grant_type: 'client_credentials',
96
- client_id: this.config_entity[baseEntity].connection.auth.options.clientId,
97
- client_secret: this.config_entity[baseEntity].connection.auth.options.clientSecret,
98
- scope: this.config_entity[baseEntity].connection.auth.options.scope || null,
99
- resource: resource || null, // "https://graph.microsoft.com"
100
- }
101
- break
113
+ form = { // example username/password in body
114
+ username: this.config_entity[baseEntity].connection.auth.options.username,
115
+ password: this.config_entity[baseEntity].connection.auth.options.password,
116
+ }
117
+ break
102
118
 
103
- case 'token':
104
- tokenUrl = this.config_entity[baseEntity].connection.auth.options.tokenUrl
105
- form = { // example username/password in body
106
- username: this.config_entity[baseEntity].connection.auth.options.username,
107
- password: this.config_entity[baseEntity].connection.auth.options.password,
108
- }
109
- break
110
-
111
- case 'oauthSamlBearer':
112
- tokenUrl = this.config_entity[baseEntity].connection.auth.options.tokenUrl
113
- const context = null
114
- const cert = fs.readFileSync(this.config_entity[baseEntity].connection.auth.options.certificate.cert).toString()
115
- const key = fs.readFileSync(this.config_entity[baseEntity].connection.auth.options.certificate.key).toString()
116
-
117
- const issuer = `scimgateway/${this.scimgateway.pluginName}`
118
- const lifetime = 3600
119
- const clientId = this.config_entity[baseEntity].connection.auth.options.clientId
120
- const nameId = this.config_entity[baseEntity].connection.auth.options.userId
121
- const userIdentifierFormat = 'userName'
122
- const tokenEndpoint = tokenUrl
123
- const audience = `scimgateway/${this.scimgateway.pluginName}`
124
- const delay = 1
125
-
126
- form = {
127
- token_url: tokenUrl,
128
- grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer',
129
- client_id: clientId,
130
- company_id: this.config_entity[baseEntity].connection.auth.options.companyId,
131
- assertion: await samlAssertion.run(context, cert, key, issuer, lifetime, clientId, nameId, userIdentifierFormat, tokenEndpoint, audience, delay),
132
- }
133
- break
119
+ case 'oauthSamlBearer':
120
+ tokenUrl = this.config_entity[baseEntity].connection.auth.options.tokenUrl
121
+ const context = null
122
+ const cert = fs.readFileSync(this.config_entity[baseEntity].connection.auth.options.certificate.cert).toString()
123
+ const key = fs.readFileSync(this.config_entity[baseEntity].connection.auth.options.certificate.key).toString()
124
+
125
+ const issuer = `scimgateway/${this.scimgateway.pluginName}`
126
+ const lifetime = 3600
127
+ const clientId = this.config_entity[baseEntity].connection.auth.options.clientId
128
+ const nameId = this.config_entity[baseEntity].connection.auth.options.userId
129
+ const userIdentifierFormat = 'userName'
130
+ const tokenEndpoint = tokenUrl
131
+ const audience = `scimgateway/${this.scimgateway.pluginName}`
132
+ const delay = 1
133
+
134
+ form = {
135
+ token_url: tokenUrl,
136
+ grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer',
137
+ client_id: clientId,
138
+ company_id: this.config_entity[baseEntity].connection.auth.options.companyId,
139
+ assertion: await samlAssertion.run(context, cert, key, issuer, lifetime, clientId, nameId, userIdentifierFormat, tokenEndpoint, audience, delay),
140
+ }
141
+ break
142
+
143
+ case 'oauthJwtBearer':
144
+ let jwtClaims: jsonwebtoken.JwtPayload | Record<string, any> = {}
145
+ let jwtOpts: jsonwebtoken.SignOptions = {}
146
+ const serviceAccountKeyFile = this.config_entity[baseEntity]?.connection?.auth?.options?.serviceAccountKeyFile
147
+ const tenantIdGUID = this.config_entity[baseEntity]?.connection?.auth?.options?.tenantIdGUID
148
+
149
+ if (tenantIdGUID) {
150
+ // Microsoft Entra ID
151
+ if (!this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?.key || !this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?.cert) {
152
+ throw new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' - missing options.certificate.key/cert configuration`)
153
+ }
154
+ tokenUrl = `https://login.microsoftonline.com/${tenantIdGUID}/oauth2/v2.0/token` // `https://login.microsoftonline.com/${tenantIdGUID}/oauth2/token`
155
+ let privateKey = this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?._key || ''
156
+ let cert = this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?._cert || ''
157
+ if (!privateKey || !cert) {
158
+ privateKey = fs.readFileSync(this.config_entity[baseEntity].connection.auth.options.certificate.key, 'utf-8') || ''
159
+ cert = fs.readFileSync(this.config_entity[baseEntity].connection.auth.options.certificate.cert, 'utf-8') || ''
160
+ if (privateKey) this.config_entity[baseEntity].connection.auth.options.certificate._key = privateKey
161
+ if (cert) this.config_entity[baseEntity].connection.auth.options.certificate._cert = cert
162
+ }
163
+ if (!privateKey || !cert) {
164
+ throw new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' - missing options.certificate.key/cert file content`)
165
+ }
166
+
167
+ const jwtPayload: jsonwebtoken.JwtPayload = {
168
+ sub: this.config_entity[baseEntity]?.connection?.auth?.options?.clientId,
169
+ iss: this.config_entity[baseEntity]?.connection?.auth?.options?.clientId,
170
+ aud: `https://login.microsoftonline.com/${tenantIdGUID}/v2.0`,
171
+ iat: Math.floor(Date.now() / 1000) - 60,
172
+ exp: Math.floor(Date.now() / 1000) + 3600,
173
+ jti: crypto.randomUUID(),
174
+ nbf: Math.floor(Date.now() / 1000) - 60,
175
+ }
176
+ jwtClaims = {
177
+ ...jwtPayload,
178
+ }
179
+
180
+ const base64Thumbprint = utils.getBase64CertificateThumbprint(cert, 'sha1') // xt5=>sha1, x5t#S256=>sha256
181
+ jwtOpts = {
182
+ algorithm: 'RS256',
183
+ header: {
184
+ typ: 'JWT',
185
+ alg: 'RS256',
186
+ x5t: base64Thumbprint,
187
+ },
188
+ }
134
189
 
135
- case 'oauthJwtBearer':
136
- let privateKey = ''
137
- let jwtAttr: Record<string, any> = {}
138
- const serviceAccountKeyFile = this.config_entity[baseEntity]?.connection?.auth?.options?.serviceAccountKeyFile
190
+ /* Microsoft recommended modern x5t#S256 does not work using self-signed certificate
191
+ const base64Thumbprint = utils.getBase64CertificateThumbprint(cert, 'sha256')
192
+ jwtOpts = {
193
+ algorithm: 'PS256',
194
+ header: {
195
+ 'typ': 'JWT',
196
+ 'alg': 'PS256',
197
+ 'x5t#S256': base64Thumbprint,
198
+ },
199
+ }
200
+ */
139
201
 
140
- if (serviceAccountKeyFile) { // Google Service Account key json-file
141
- const gkey: Record<string, any> = await (async () => {
202
+ let scope = 'https://graph.microsoft.com/.default'
142
203
  try {
143
- const jsonObject = await import(serviceAccountKeyFile, { assert: { type: 'json' } })
144
- return jsonObject.default // access the object via the `default` property
145
- } catch (err: any) {
146
- throw new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' - serviceAccountKeyFile error: ${err.message}`)
204
+ const urlObj = new URL(this.config_entity[baseEntity].connection.baseUrls[0])
205
+ scope = urlObj.origin + '/.default' // for application exposed api's and included permissions use: api://${this.config_entity[baseEntity]?.connection?.auth?.options?.clientId}/.default
206
+ } catch (err) { void 0 }
207
+
208
+ form = {
209
+ scope,
210
+ grant_type: 'client_credentials',
211
+ client_id: this.config_entity[baseEntity]?.connection?.auth?.options?.clientId,
212
+ client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
213
+ client_assertion: jsonwebtoken.sign(jwtClaims, privateKey, jwtOpts),
214
+ }
215
+ } else if (serviceAccountKeyFile) {
216
+ // Google - using Service Account key json-file
217
+ if (!this.config_entity[baseEntity]?.connection?.auth?.options?.scope || !this.config_entity[baseEntity]?.connection?.auth?.options?.subject) {
218
+ const err = new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' - using auth.options 'serviceAccountKeyFile' requires mandatory configuration entity.${baseEntity}.connection.auth.options.scope/subject`)
219
+ throw err
220
+ }
221
+ let gkey: Record<string, any> = this.config_entity[baseEntity]?.connection?.auth?.options?._gkey
222
+ if (!gkey) {
223
+ gkey = await (async () => {
224
+ try {
225
+ const jsonObject = await import(serviceAccountKeyFile, { assert: { type: 'json' } })
226
+ return jsonObject.default // access the object via the `default` property
227
+ } catch (err: any) {
228
+ throw new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' - serviceAccountKeyFile error: ${err.message}`)
229
+ }
230
+ })()
231
+ this.config_entity[baseEntity].connection.auth.options._gkey = gkey
232
+ }
233
+
234
+ tokenUrl = gkey.token_uri // https://oauth2.googleapis.com/token
235
+ const privateKey = gkey.private_key
236
+ const jwtPayload: jsonwebtoken.JwtPayload = {
237
+ sub: this.config_entity[baseEntity]?.connection?.auth?.options?.subject, // firstname.lastname@mycompany.com
238
+ iss: gkey.client_email, // service account email/user
239
+ aud: gkey.token_uri,
240
+ iat: Math.floor(Date.now() / 1000) - 60, // issued at
241
+ exp: Math.floor(Date.now() / 1000) + 3600, // expiration time
242
+ }
243
+ jwtClaims = {
244
+ ...jwtPayload,
245
+ scope: this.config_entity[baseEntity]?.connection?.auth?.options?.scope, // https://www.googleapis.com/auth/gmail.send
246
+ }
247
+ jwtOpts = {
248
+ algorithm: 'RS256',
249
+ header: {
250
+ typ: 'JWT',
251
+ alg: 'RS256',
252
+ kid: gkey.client_id,
253
+ },
254
+ }
255
+ form = {
256
+ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
257
+ assertion: jsonwebtoken.sign(jwtClaims, privateKey, jwtOpts),
258
+ }
259
+ } else {
260
+ // standard JWT - requires all configuation: tokenUrl, rawJwtPayload and certificate.key
261
+ if (!this.config_entity[baseEntity]?.connection?.auth?.options?.tokenUrl
262
+ || !this.config_entity[baseEntity]?.connection?.auth?.options?.rawJwtPayload
263
+ || typeof this.config_entity[baseEntity]?.connection?.auth?.options?.rawJwtPayload !== 'object') {
264
+ throw new Error(`auth.type '${this.config_entity[baseEntity]?.connection?.auth?.type}' (no tenantIdGUID/serviceAccountKeyFile using raw) - missing configuration entity.${baseEntity}.connection.auth.options.tokenUrl/rawJwtPayload`)
265
+ }
266
+ if (!this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?.key) {
267
+ throw new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' (no tenantIdGUID/serviceAccountKeyFile using raw) - missing options.certificate.key configuration`)
268
+ }
269
+ tokenUrl = this.config_entity[baseEntity].connection.auth.options.tokenUrl
270
+ let privateKey = this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?._key || ''
271
+ if (!privateKey) {
272
+ privateKey = fs.readFileSync(this.config_entity[baseEntity].connection.auth.options.certificate.key, 'utf-8') || ''
273
+ if (privateKey) this.config_entity[baseEntity].connection.auth.options.certificate._key = privateKey
274
+ }
275
+
276
+ let jwtPayload = this.config_entity[baseEntity].connection.auth.options.rawJwtPayload
277
+ if (!jwtPayload.iat) jwtPayload.iat = Math.floor(Date.now() / 1000) - 60
278
+ if (!jwtPayload.exp) jwtPayload.exp = Math.floor(Date.now() / 1000) + 3600
279
+
280
+ jwtClaims = {
281
+ ...jwtPayload,
282
+ }
283
+ jwtOpts = {
284
+ algorithm: 'RS256',
285
+ header: {
286
+ typ: 'JWT',
287
+ alg: 'RS256',
288
+ },
289
+ }
290
+
291
+ form = {
292
+ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
293
+ assertion: jsonwebtoken.sign(jwtClaims, privateKey, jwtOpts),
147
294
  }
148
- })()
149
-
150
- tokenUrl = gkey.token_uri // https://oauth2.googleapis.com/token
151
- privateKey = gkey.private_key
152
- jwtAttr = {
153
- scope: this.config_entity[baseEntity]?.connection?.auth?.options?.scope, // https://www.googleapis.com/auth/gmail.send
154
- sub: this.config_entity[baseEntity]?.connection?.auth?.options?.subject, // firstname.lastname@mycompany.com
155
- iss: gkey.client_email, // service account email/user
156
- aud: gkey.token_uri,
157
- iat: Math.floor(Date.now() / 1000), // issued at
158
- exp: Math.floor(Date.now() / 1000) + (60 * 60), // expiration time
159
- }
160
- } else { // standard JWT requires all configuation set
161
- tokenUrl = this.config_entity[baseEntity]?.connection?.auth?.options?.tokenUrl
162
- const privateKeyFile = this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?.key
163
- if (privateKeyFile) privateKey = fs.readFileSync(privateKeyFile).toString()
164
- jwtAttr = {
165
- scope: this.config_entity[baseEntity]?.connection?.auth?.options?.scope,
166
- sub: this.config_entity[baseEntity]?.connection?.auth?.options?.subject,
167
- iss: this.config_entity[baseEntity]?.connection?.auth?.options?.issuer,
168
- aud: this.config_entity[baseEntity]?.connection?.auth?.options?.audience,
169
- iat: Math.floor(Date.now() / 1000),
170
- exp: Math.floor(Date.now() / 1000) + (60 * 60),
171
295
  }
172
- }
173
296
 
174
- form = {
175
- grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
176
- assertion: jsonwebtoken.sign(jwtAttr, privateKey, { algorithm: 'RS256' }),
177
- }
178
- break
297
+ break
179
298
 
180
- default:
181
- this.lock.release()
182
- throw new Error(`getAccessToken() none supported entity.${baseEntity}.connection.auth.type: '${this.config_entity[baseEntity]?.connection?.auth?.type}'`)
183
- }
299
+ default:
300
+ throw new Error(`getAccessToken() none supported entity.${baseEntity}.connection.auth.type: '${this.config_entity[baseEntity]?.connection?.auth?.type}'`)
301
+ }
184
302
 
185
- if (!tokenUrl) {
186
- this.lock.release()
187
- throw new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' - missing tokenUrl or tenantIdGUID configuration`)
188
- }
303
+ if (!tokenUrl) {
304
+ throw new Error(`auth type '${this.config_entity[baseEntity]?.connection?.auth?.type}' - missing tokenUrl`)
305
+ }
189
306
 
190
- this.scimgateway.logDebug(baseEntity, `${action}: Retrieving accesstoken`)
191
- const method = 'POST'
192
- let connOpt: any = {}
193
- if (this.config_entity[baseEntity].connection.options && typeof this.config_entity[baseEntity].connection.options === 'object') {
194
- connOpt = utils.copyObj(this.config_entity[baseEntity].connection.options)
195
- }
196
- if (!connOpt.headers) connOpt.headers = {}
197
- connOpt.headers['Content-Type'] = 'application/x-www-form-urlencoded' // body must be query string formatted (no JSON)
307
+ this.scimgateway.logDebug(baseEntity, `${action}: Retrieving accesstoken`)
308
+ const method = 'POST'
309
+ let connOpt: any = {}
310
+ if (this.config_entity[baseEntity].connection.options && typeof this.config_entity[baseEntity].connection.options === 'object') {
311
+ connOpt = utils.copyObj(this.config_entity[baseEntity].connection.options)
312
+ }
313
+ if (!connOpt.headers) connOpt.headers = {}
314
+ connOpt.headers['Content-Type'] = 'application/x-www-form-urlencoded' // body must be query string formatted (no JSON)
198
315
 
199
- try {
200
316
  const response = await this.doRequest(baseEntity, method, tokenUrl, form, ctx, connOpt)
201
317
  if (!response.body) {
202
318
  const err = new Error(`[${action}] No data retrieved from: ${method} ${tokenUrl}`)
@@ -344,22 +460,9 @@ export class HelperRest {
344
460
  param.options.headers['Authorization'] = `Bearer ${param.accessToken.access_token}`
345
461
  break
346
462
  case 'oauthJwtBearer':
347
- if (this.config_entity[baseEntity]?.connection?.auth?.options?.serviceAccountKeyFile) { // Google Service Account
348
- if (!this.config_entity[baseEntity]?.connection?.auth?.options?.scope || !this.config_entity[baseEntity]?.connection?.auth?.options?.subject) {
349
- const err = new Error(`auth.type 'oauthJwtBearer' - using auth.options 'serviceAccountKeyFile' also requires mandatory configuration entity.${baseEntity}.connection.auth.options.scope/subject`)
350
- throw err
351
- }
352
- } else if (!this.config_entity[baseEntity]?.connection?.auth?.options?.tokenUrl
353
- || !this.config_entity[baseEntity]?.connection?.auth?.options?.scope
354
- || !this.config_entity[baseEntity]?.connection?.auth?.options?.subject
355
- || !this.config_entity[baseEntity]?.connection?.auth?.options?.issuer
356
- || !this.config_entity[baseEntity]?.connection?.auth?.options?.audience
357
- || !this.config_entity[baseEntity]?.connection?.auth?.options?.certificate?.key
358
- ) {
359
- const err = new Error(`auth.type 'oauthJwtBearer' - when not using auth.options 'serviceAccountKeyFile' which is related to Google, following auth.options is mandatory: tokenUrl, scope, subject, issuer, audience, certificate.key`)
360
- throw err
361
- }
362
-
463
+ // auth.options.tenantIdGUID => Microsoft Entra ID
464
+ // auth.options.serviceAccountKeyFile => Google Service Account
465
+ // also support custom using tokenUrl/rawJwtPayload
363
466
  param.accessToken = await this.getAccessToken(baseEntity, ctx)
364
467
  param.options.headers['Authorization'] = `Bearer ${param.accessToken.access_token}`
365
468
  break
@@ -679,8 +782,8 @@ export class HelperRest {
679
782
  * ```
680
783
  * {
681
784
  * "options": {
682
- * "tenantIdGUID": "<Entra ID tenantIdGUID", // Microsoft Graph API - baseUrls automatically set to [https://graph.microsoft.com/beta]
683
- * "tokenUrl": "<tokenUrl>", // not used when tenantIdGUID defined - baseUrls required
785
+ * "tenantIdGUID": "<Entra ID tenantIdGUID", // Entra ID authentication - if baseUrls not defined, baseUrls automatically set to [https://graph.microsoft.com/beta]
786
+ * "tokenUrl": "<tokenUrl>", // must be set if not using tenantIdGUID
684
787
  * "clientId": "<clientId>",
685
788
  * "clientSecret": "<clientSecret>"
686
789
  * }
@@ -725,26 +828,40 @@ export class HelperRest {
725
828
  *
726
829
  * type=**"oauthJwtBearer"** having auth.options:
727
830
  * ```
728
- * // Google API - baseUrls automatically set to [https://www.googleapis.com]
831
+ * // Microsoft Entra ID
832
+ * {
833
+ * "options": {
834
+ * "tenantIdGUID": "<Entra ID tenantIdGUID", // Entra ID authentication, if baseUrls not defined, baseUrls automatically set to [https://graph.microsoft.com/beta]
835
+ * "clientId": "<clientId>",
836
+ * "certificate": { // files located in ./config/certs
837
+ * "key": "key.pem",
838
+ * "cert": "cert.pem"
839
+ * }
840
+ * }
841
+ * }
842
+ *
843
+ * // Google Cloud Platform - GCP
729
844
  * {
730
845
  * "options": {
731
- * "serviceAccountKeyFile": "<Google Service Account key file name>", // located in ./config/certs
732
- * "scope": "<jwt-scope>"
846
+ * "serviceAccountKeyFile": "<Google Service Account key file name>", // located in ./config/certs. If baseUrls not defined, baseUrls automatically set to [https://www.googleapis.com]
847
+ * "scope": "<jwt-scope>",
733
848
  * "subject": "<jwt-subject>
734
849
  * }
735
850
  * }
736
851
  *
737
- * // General JWT API - baseUrls required
852
+ * // General JWT API
738
853
  * {
739
854
  * "options": {
740
855
  * "tokenUrl": "<tokenUrl",
741
- * "scope": "<jwt-scope>",
742
- * "subject": "<jwt-subject>",
743
- * "issuer": "<jwt-issuer>",
744
- * "audience": "<jwt-audience>",
745
856
  * "certificate": {
746
- * "key": "<signing-key-file-name>"
747
- * }
857
+ * "key": "<signing-key-file-name>" // key.pem file located in ./config/certs
858
+ * },
859
+ * "rawJwtPayload": {
860
+ * "sub": "<subject>",
861
+ * "iss": "<issuer>",
862
+ * "aud": "<audience>",
863
+ * ...
864
+ * }
748
865
  * }
749
866
  * }
750
867
  * ```
package/lib/logger.ts CHANGED
@@ -96,7 +96,7 @@ export class Log {
96
96
  customMaskXml = customMasking.join('"?|')
97
97
  customMaskXml = '|' + customMaskXml + '"?'
98
98
  }
99
- this.reJson = `^.*"(password|access_token|client_secret|assertion${customMaskJson})" ?: ?"([^"]+)".*`
99
+ this.reJson = `^.*"(password|access_token|client_secret|assertion|client_assertion${customMaskJson})" ?: ?"([^"]+)".*`
100
100
  this.reXml = `^.*(credentials"?|PasswordText"?|PasswordDigest"?|password"?${customMaskXml})>([^<]+)</.*`
101
101
 
102
102
  const trans: any = [
@@ -11,4 +11,4 @@
11
11
  // for details see: https://elshaug.xyz/docs/scim-stream
12
12
  //
13
13
  // ================================================================
14
- 'use strict';(function(_0x1bc805,_0x388521){const _0x33ddb4=a0_0x24a2,_0x1e67eb=_0x1bc805();while(!![]){try{const _0x51ec16=-parseInt(_0x33ddb4(0x27a))/0x1+parseInt(_0x33ddb4(0x225))/0x2+parseInt(_0x33ddb4(0x1f8))/0x3+parseInt(_0x33ddb4(0x1d9))/0x4+-parseInt(_0x33ddb4(0x1f4))/0x5*(parseInt(_0x33ddb4(0x252))/0x6)+-parseInt(_0x33ddb4(0x27f))/0x7+parseInt(_0x33ddb4(0x1f0))/0x8;if(_0x51ec16===_0x388521)break;else _0x1e67eb['push'](_0x1e67eb['shift']());}catch(_0x13ba79){_0x1e67eb['push'](_0x1e67eb['shift']());}}}(a0_0x47b0,0x62bea));function a0_0x24a2(_0x2f0a4d,_0x47d9cc){const _0x47b07a=a0_0x47b0();return a0_0x24a2=function(_0x24a29c,_0x1e2dae){_0x24a29c=_0x24a29c-0x1b3;let _0x4348a6=_0x47b07a[_0x24a29c];return _0x4348a6;},a0_0x24a2(_0x2f0a4d,_0x47d9cc);}import{jwtAuthenticator,headers}from'@nats-io/nats-core';import{jetstream,jetstreamManager,DeliverPolicy,AckPolicy}from'@nats-io/jetstream';function a0_0x47b0(){const _0x4de22e=['all','\x20message\x20json\x20parsing\x20error:\x20','close','secret','bearerToken','increment','GET\x20api','drain','\x22,\x22errName\x22:\x22','POST\x20users','onCreate','active','origin','\x20-\x20','streamChaining\x20called\x20but\x20missing\x20chainingBaseUrl','ack','patchApiHandler','getUsers()\x20getObj=','file-not-configured','stringify',']\x20client\x20consumer\x20reinitiated\x20because\x20of\x20','includes','lowercase','UnableConnectingHost','errName',']\x20client\x20is\x20attempting\x20to\x20reconnect\x20','delete','SIGINT','PUT\x20api','foldReplacing','UnableConnectingService','\x20message:\x20user\x20not\x20created\x20because\x20of\x20active=false','modifyOnly','type','subscribe',',\x20obj=','url','indexOf','Resources','debug','name','content-type','37050pZjlnS','postApiHandler',']\x20connect\x20error:\x20','\x20convertedScim20\x20error:\x20','getServer','utf-8','statusCode','HR.','ctx','GET\x20serviceproviderconfig','then','users','path','/Users','application/scim+json;\x20charset=utf-8',']\x20client\x20reconnected\x20','startsWith','normalize','doRequest','join','charAt','convertedScim20','routeObj','##doIncrement','\x20Create\x20User\x20userName=','from','nats',']\x20handling\x20\x22','Msg-Id','split','patchHandler','timeout','putHandler','\x20message:\x20user\x20not\x20deleted\x20because\x20of\x20configuration\x20modifyOnly=true',']\x20onChainingHandler\x20error:\x20configuration\x20scimgateway.chainingBaseUrl\x20must\x20use\x20correct\x20syntax\x20\x27http(s)://host:port\x27\x20error:\x20','Basic\x20','func','reconnectTimeWait','reconnect','parse','352710kdQFjR','getuniquevalue','\x20done',']\x20initialization\x20error:\x20missing\x20certificate\x20configuration','config','491603xQBpTM','true','roles','/certs/','length','certificate','createRandomPassword','chainingBaseUrl','substring','consumers','replaceDomains','POST\x20api','modifyGroup',']\x20error:\x20client\x20have\x20not\x20been\x20initialized','toLowerCase','randomUUID','getHandlerId','ECONNREFUSED','tenant','pluginName',']\x20closed\x20with\x20error:\x20','ENOTFOUND','/approles','push','request','string','constructor',']\x20initialization\x20error:\x20missing\x20configuration\x20stream.baseUrls','\x20-\x20will\x20do\x20auto\x20connect\x20when\x20available\x20-\x20however,\x20please\x20verify\x20stream\x20configuration','PATCH\x20api',']\x20client\x20disconnected\x20','subscriber\x20message\x20error:\x20message\x20not\x20JSON\x20formatted','streamChaining\x20error:\x20','Operations','\x20message\x20handled:\x20',',true','tls','Explicit','publisher[','response','toString',']\x20subscriber[','message','_info','getProcessed','PUT\x20groups','authenticator','createWriteStream','usePutSoftSync','body','configDir','helperRest','call','jwt','maxReconnectAttempts','uppercase','Bearer\x20','publisher\x20error:\x20none\x20JSON\x20formatted\x20response:\x20','publisher\x20not\x20initialized/connected','/Users/','activityOperation',']\x20initialization\x20error:\x20missing\x20configuration\x20nats.tenant','file','gwName','schemas','closed','filter_subject','PUT\x20users','\x20error:\x20missing\x20id}','respond','generateUserPassword','password','copyObj','existsSync','basic','\x20(count=',']\x20subscriber\x20stopped\x20error:\x20','encode','All','operation',']\x20publisher[','SIGTERM','?filter=userName\x20eq\x20\x22','groups','error','newHelperRest','append','\x20Create\x20userName=','getEncrypted','info','Users','reconnecting','add','replace','GW.','isArray','NOT_FOUND','GET\x20groups',']\x20error:\x20','\x20group\x20removal\x20error:\x20','forEach','?attributes=','token','displayName','base64','utf8','publisher\x20response\x20error:\x20','consumer_not_found','\x20processing\x20incoming\x20message','baseUrls','deleteUserOnLastGroupRoleRemoval','subscriber\x20using\x20remote\x20gateway\x20through\x20chainingBaseUrl\x20requires\x20either\x20auth.tokenBearer\x20or\x20auth.basic\x20to\x20be\x20configured',']\x20initialization\x20error:\x20missing\x20configuration\x20nats','deleteHandler','rejectUnauthorized','trim','waitOnFirstConnect','pingInterval','doIncrement',',\x20id=',']\x20connected\x20','status','DELETE\x20groups',']\x20approle\x20uuid\x20file\x20created:\x20','durable_','\x20Delete\x20User\x20id=',']\x20client\x20has\x20a\x20stale\x20connection\x20','userName','get','putApiHandler','31876rWXYDk','deleteUser','display','\x20error:\x20','value','authorization','obj','false','toUpperCase','headers','GET','undefined','staleConnection','write','\x20roles\x20converted\x20to\x20groups:\x20','GET\x20users','baseEntity','passThrough','consume','maxPingOut','operator','getGroups','\x20getUserId()\x20error:\x20','3740632Ixokmg','auth','DELETE\x20api','mkdirSync','295RTBriT',']\x20error:\x20no\x20subscribers/responders\x20to\x20subject\x20','getUsers','scimgateway','274200bSLygP','\x20Replace\x20User\x20id=','_autogenerated.cfg',']\x20initialization\x20certificate\x20error:\x20','GET\x20schemas','transports','getAppRoles','SCIM\x20Stream',']\x20initialization\x20error:\x20missing\x20configuration\x20nats.subject','server_name','servers','set',']\x20client\x20error\x20','update','}\x20message\x20error\x20response:\x20','?filter=externalId\x20eq\x20\x22','replaceAll','logger','getHandlerSchemas','\x20role\x20removal\x20error:\x20','\x20=>\x20subscriber\x20not\x20activated','getUsers()\x20error:\x20unsupported\x20operator\x20for\x20getObj:\x20','user',']\x20error:\x20message\x20must\x20be\x20JSON\x20formatted','publish','typeId','ETIMEDOUT','modifyUser','approles','\x20createUser()\x20obj=','\x20result=','\x20missing\x20user\x20object\x20in\x20message:\x20','attribute','isClosed','method','subject','getHandlerServiceProviderConfig','readFileSync','data','remove','replaceUsrGrp','internal\x20stream\x20policy\x20have\x20been\x20changed\x20-\x20central\x20SCIM\x20Stream\x20must\x20be\x20stopped\x20and\x20corresponding\x20./jetstream\x20folder\x20deleted\x20before\x20startup\x20allowing\x20new\x20policy','DELETE\x20users',']\x20initialization\x20error:\x20nats.subject\x20root\x20topic\x20must\x20be\x20\x27GW\x27,\x20nats.subject\x20example:\x20GW.APP1','createUser','1249548XVGFPE','username','prototype'];a0_0x47b0=function(){return _0x4de22e;};return a0_0x47b0();}import{connect as a0_0x2d222d}from'@nats-io/transport-node';import a0_0x442400 from'fold-to-ascii';import a0_0x42a5b2 from'node:fs';import a0_0x5d9708 from'node:path';import a0_0x385c0f from'node:crypto';import*as a0_0xfd4a34 from'./utils.ts';import*as a0_0x34c478 from'./utils-scim.ts';export class Subscriber{constructor(_0x43b748,_0x5d1d0b){const _0x309557=a0_0x24a2,_0x1c6ff4=_0x43b748,_0x46b9da={},_0x28d126=_0x1c6ff4[_0x309557(0x27e)][_0x309557(0x1f7)]['chainingBaseUrl'];let _0x3184ae='';if(_0x28d126){if(_0x1c6ff4[_0x309557(0x27e)]['scimgateway']?.[_0x309557(0x1f1)]?.[_0x309557(0x22c)]&&Array[_0x309557(0x1b6)](_0x1c6ff4[_0x309557(0x27e)]['scimgateway'][_0x309557(0x1f1)][_0x309557(0x22c)])&&_0x1c6ff4[_0x309557(0x27e)][_0x309557(0x1f7)][_0x309557(0x1f1)][_0x309557(0x22c)]['length']>0x0){const _0xfe26d6=_0x1c6ff4['config'][_0x309557(0x1f7)][_0x309557(0x1f1)][_0x309557(0x22c)];if(_0xfe26d6[0x0]['token']){const _0x2309b0=Buffer[_0x309557(0x26b)](_0xfe26d6[0x0][_0x309557(0x1bd)])[_0x309557(0x2a7)](_0x309557(0x1bf));_0x3184ae=_0x309557(0x2b7)+_0x2309b0;}}if(!_0x3184ae&&_0x1c6ff4[_0x309557(0x27e)][_0x309557(0x1f7)]?.['auth']?.[_0x309557(0x2c9)]&&Array[_0x309557(0x1b6)](_0x1c6ff4[_0x309557(0x27e)][_0x309557(0x1f7)][_0x309557(0x1f1)][_0x309557(0x2c9)])&&_0x1c6ff4[_0x309557(0x27e)][_0x309557(0x1f7)][_0x309557(0x1f1)][_0x309557(0x2c9)][_0x309557(0x283)]>0x0){const _0x256b14=_0x1c6ff4[_0x309557(0x27e)][_0x309557(0x1f7)]['auth'][_0x309557(0x2c9)];if(_0x256b14[0x0][_0x309557(0x226)]&&_0x256b14[0x0]['password']){const _0x2acb04=Buffer[_0x309557(0x26b)](_0x256b14[0x0][_0x309557(0x226)]+':'+_0x256b14[0x0][_0x309557(0x2c6)])[_0x309557(0x2a7)]('base64');_0x3184ae=_0x309557(0x275)+_0x2acb04;}}}let _0x134e4c='';for(let _0x1bf604=0x0;_0x1bf604<_0x1c6ff4['logger']['transports'][_0x309557(0x283)];_0x1bf604++){if(_0x1c6ff4['logger']['transports'][_0x1bf604]['name']===_0x309557(0x2bd)){_0x134e4c=_0x1c6ff4[_0x309557(0x209)][_0x309557(0x1fd)][_0x1bf604]['level'];break;}}const _0x29f29d=''+(_0x134e4c===_0x309557(0x24f)?'\x0a':''),_0x1a80c6=async(_0x2bf9f4,_0x51944c)=>{const _0x1c1576=_0x309557,_0x3b81d8=_0x46b9da[_0x2bf9f4][_0x1c1576(0x27e)]?.['nats']?.[_0x1c1576(0x21b)];let _0x5bdafc;try{_0x5bdafc=await a0_0x2d222d(_0x51944c);if(_0x5bdafc['info'][_0x1c1576(0x201)]!==_0x1c1576(0x1ff)){_0x5bdafc[_0x1c1576(0x22a)]();return;}_0x46b9da[_0x2bf9f4]['nc']=_0x5bdafc,_0x535678(_0x2bf9f4,_0x5bdafc),_0x5b9f53(_0x2bf9f4,_0x5bdafc);}catch(_0x2feafe){_0x1c6ff4[_0x1c1576(0x209)][_0x1c1576(0x2d3)](_0x1c6ff4[_0x1c1576(0x2be)]+'['+_0x1c6ff4[_0x1c1576(0x292)]+']\x20subscriber['+_0x2bf9f4+']['+_0x3b81d8+_0x1c1576(0x254)+_0x2feafe['message']+'\x20-\x20will\x20do\x20auto\x20connect\x20when\x20available\x20-\x20however,\x20please\x20verify\x20stream\x20configuration'),_0x51944c[_0x1c1576(0x1cb)]=!![];try{_0x5bdafc=await a0_0x2d222d(_0x51944c);if(_0x5bdafc[_0x1c1576(0x2d8)][_0x1c1576(0x201)]!=='SCIM\x20Stream'){_0x5bdafc[_0x1c1576(0x22a)]();return;}_0x46b9da[_0x2bf9f4]['nc']=_0x5bdafc,_0x535678(_0x2bf9f4,_0x5bdafc),_0x5b9f53(_0x2bf9f4,_0x5bdafc);}catch(_0x3c6319){_0x1c6ff4['logger']['error'](_0x1c6ff4[_0x1c1576(0x2be)]+'['+_0x1c6ff4[_0x1c1576(0x292)]+_0x1c1576(0x2a8)+_0x2bf9f4+']['+_0x3b81d8+']\x20connect\x20error:\x20'+_0x3c6319[_0x1c1576(0x2a9)]);return;}}_0x1c6ff4[_0x1c1576(0x209)][_0x1c1576(0x24f)](_0x1c6ff4[_0x1c1576(0x2be)]+'['+_0x1c6ff4['pluginName']+_0x1c1576(0x2a8)+_0x2bf9f4+']['+_0x3b81d8+_0x1c1576(0x1cf)+(_0x51944c['tls']['ca']?_0x1c1576(0x2a3):'')+'\x20'+_0x5bdafc[_0x1c1576(0x256)]()),_0x5bdafc[_0x1c1576(0x2c0)]()['then'](_0x1a163c=>{const _0x3de332=_0x1c1576;_0x1a163c&&_0x1c6ff4[_0x3de332(0x209)][_0x3de332(0x2d3)](_0x1c6ff4[_0x3de332(0x2be)]+'['+_0x1c6ff4[_0x3de332(0x292)]+_0x3de332(0x2a8)+_0x2bf9f4+']['+_0x3b81d8+_0x3de332(0x293)+_0x1a163c[_0x3de332(0x2a9)]);});};this['add']=async(_0x4ea94b,_0x5e4d7e)=>{const _0x3f8690=_0x309557;if(!_0x5e4d7e?.[_0x3f8690(0x26c)]){_0x1c6ff4[_0x3f8690(0x209)][_0x3f8690(0x2d3)](_0x1c6ff4[_0x3f8690(0x2be)]+'['+_0x1c6ff4['pluginName']+_0x3f8690(0x2a8)+_0x4ea94b+_0x3f8690(0x1c7));return;}if(!_0x5e4d7e?.[_0x3f8690(0x26c)]?.[_0x3f8690(0x291)]){_0x1c6ff4['logger'][_0x3f8690(0x2d3)](_0x1c6ff4[_0x3f8690(0x2be)]+'['+_0x1c6ff4[_0x3f8690(0x292)]+_0x3f8690(0x2a8)+_0x4ea94b+_0x3f8690(0x2bc));return;}if(!_0x5e4d7e?.[_0x3f8690(0x26c)]?.[_0x3f8690(0x21b)]){_0x1c6ff4[_0x3f8690(0x209)][_0x3f8690(0x2d3)](_0x1c6ff4['gwName']+'['+_0x1c6ff4['pluginName']+_0x3f8690(0x2a8)+_0x4ea94b+_0x3f8690(0x200));return;}if(!_0x5e4d7e?.[_0x3f8690(0x284)]?.['ca']){_0x1c6ff4[_0x3f8690(0x209)][_0x3f8690(0x2d3)](_0x1c6ff4[_0x3f8690(0x2be)]+'['+_0x1c6ff4['pluginName']+_0x3f8690(0x2a8)+_0x4ea94b+_0x3f8690(0x27d));return;}if(!_0x5e4d7e['baseUrls']||!Array[_0x3f8690(0x1b6)](_0x5e4d7e[_0x3f8690(0x1c4)])||_0x5e4d7e[_0x3f8690(0x1c4)][_0x3f8690(0x283)]<0x1){_0x1c6ff4[_0x3f8690(0x209)]['error'](_0x1c6ff4['gwName']+'['+_0x1c6ff4[_0x3f8690(0x292)]+']\x20subscriber['+_0x4ea94b+_0x3f8690(0x29a));return;}if(!_0x5e4d7e[_0x3f8690(0x2af)]){const _0x4fcc45=_0x5e4d7e?.[_0x3f8690(0x26c)]?.[_0x3f8690(0x21b)][_0x3f8690(0x1e1)]();if(_0x4fcc45[_0x3f8690(0x262)](_0x3f8690(0x259)))_0x5e4d7e[_0x3f8690(0x2af)]=!![];}const _0xf07295={};try{let _0x27735f=a0_0x5d9708[_0x3f8690(0x265)](_0x1c6ff4[_0x3f8690(0x2b1)],_0x3f8690(0x282),_0x5e4d7e?.[_0x3f8690(0x284)]?.['ca']||_0x3f8690(0x23a));(_0x5e4d7e?.[_0x3f8690(0x284)]?.['ca']?.[_0x3f8690(0x262)]('/')||_0x5e4d7e?.[_0x3f8690(0x284)]?.['ca']?.[_0x3f8690(0x23d)]('\x5c'))&&(_0x27735f=_0x5e4d7e[_0x3f8690(0x284)]['ca']),_0xf07295['ca']=[a0_0x42a5b2[_0x3f8690(0x21d)](_0x27735f)],_0xf07295[_0x3f8690(0x1c9)]=!![];}catch(_0x41acec){_0x1c6ff4['logger'][_0x3f8690(0x2d3)](_0x1c6ff4[_0x3f8690(0x2be)]+'['+_0x1c6ff4[_0x3f8690(0x292)]+_0x3f8690(0x2a8)+_0x4ea94b+_0x3f8690(0x1fb)+_0x41acec[_0x3f8690(0x2a9)]);return;}const _0x2b36f3={},_0x458208=new TextEncoder()[_0x3f8690(0x2cc)](_0x5e4d7e?.[_0x3f8690(0x26c)]?.[_0x3f8690(0x22b)]),_0x17889b=_0x5e4d7e?.[_0x3f8690(0x26c)]?.['jwt'];_0x2b36f3[_0x3f8690(0x2ad)]=jwtAuthenticator(_0x17889b,_0x458208),_0x2b36f3['servers']=_0x5e4d7e[_0x3f8690(0x1c4)],_0x2b36f3[_0x3f8690(0x2a3)]=_0xf07295,_0x2b36f3['waitOnFirstConnect']=![],_0x2b36f3[_0x3f8690(0x278)]=!![],_0x2b36f3[_0x3f8690(0x277)]=0x3e8*0xa,_0x2b36f3[_0x3f8690(0x2b5)]=-0x1,_0x2b36f3['pingInterval']=0x2*0x3c*0x3e8,_0x2b36f3[_0x3f8690(0x1ec)]=0x5,_0x2b36f3[_0x3f8690(0x24f)]=![],_0x46b9da[_0x4ea94b]={},_0x46b9da[_0x4ea94b]['config']=_0x5e4d7e,_0x46b9da[_0x4ea94b]['nc']=undefined,_0x46b9da[_0x4ea94b]['sub']=undefined,_0x1a80c6(_0x4ea94b,_0x2b36f3);};const _0x5b9f53=async(_0x145816,_0x24cb52)=>{const _0x2e6485=_0x309557,_0x1dd1fa=_0x46b9da[_0x145816]['config'],_0x21440c=_0x1dd1fa?.[_0x2e6485(0x26c)]?.[_0x2e6485(0x21b)];if(!_0x24cb52){_0x1c6ff4[_0x2e6485(0x209)][_0x2e6485(0x2d3)](_0x1c6ff4['gwName']+'['+_0x1c6ff4[_0x2e6485(0x292)]+_0x2e6485(0x2a8)+_0x145816+']['+_0x21440c+_0x2e6485(0x28c));return;}const _0xb01e09=async(_0x216019,_0x32d198)=>{const _0x572eb0=_0x2e6485;try{_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x2d8)](_0x216019+'\x20handling\x20message:\x20'+_0x32d198);let _0x225deb;try{if(_0x1dd1fa[_0x572eb0(0x289)]&&Array[_0x572eb0(0x1b6)](_0x1dd1fa['replaceDomains']))for(let _0x261d0f=0x0;_0x261d0f<_0x1dd1fa[_0x572eb0(0x289)][_0x572eb0(0x283)];_0x261d0f++){const _0x28d152=_0x1dd1fa[_0x572eb0(0x289)][_0x261d0f];if(!_0x28d152[_0x572eb0(0x26b)]||!_0x28d152['from'][_0x572eb0(0x23d)]('.')||!_0x28d152['to']||!_0x28d152['to'][_0x572eb0(0x23d)]('.'))continue;const _0x59fcef=new RegExp('@'+_0x28d152[_0x572eb0(0x26b)]+'\x22','gi');_0x32d198=_0x32d198[_0x572eb0(0x1b4)](_0x59fcef,'@'+_0x28d152['to']+'\x22');}_0x225deb=JSON[_0x572eb0(0x279)](_0x32d198);}catch(_0x1b8edf){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x229)+_0x1b8edf[_0x572eb0(0x2a9)]+'\x20message:\x20'+_0x32d198),_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}const _0x450d76=_0x225deb[_0x572eb0(0x20e)];if(!_0x450d76){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x217)+JSON[_0x572eb0(0x23b)](_0x225deb)),_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}if(!_0x450d76[_0x572eb0(0x1d6)]){_0x1c6ff4['logger']['error'](_0x216019+'\x20missing\x20mandatory\x20user.userName\x20in\x20message:\x20'+JSON[_0x572eb0(0x23b)](_0x225deb)),_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}delete _0x450d76[_0x572eb0(0x2bf)];let _0x19f06f;_0x450d76['id']&&(_0x19f06f=_0x450d76['id'],delete _0x450d76['id']);let _0x31bca4;_0x450d76['onCreate']&&(_0x31bca4=a0_0xfd4a34[_0x572eb0(0x2c7)](_0x450d76['onCreate']),delete _0x450d76[_0x572eb0(0x232)]);await _0xd83f5a(_0x145816,_0x450d76);const _0x42e92a=_0x450d76[_0x572eb0(0x1d6)];let _0x4a36f9,_0x529564;try{_0x4a36f9=await _0x1d3f95(_0x145816,_0x572eb0(0x1d6),_0x42e92a);}catch(_0x5e9089){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x1ef)+_0x5e9089['message']),_0x1c6ff4['logger']['debug'](_0x216019+_0x572eb0(0x27c)+_0x29f29d);const _0xa89f64=[_0x572eb0(0x23f),_0x572eb0(0x246),_0x572eb0(0x290),_0x572eb0(0x294),_0x572eb0(0x212),_0x572eb0(0x271)];for(const _0x1cd5b7 in _0xa89f64){if(_0x5e9089[_0x572eb0(0x2a9)][_0x572eb0(0x23d)](_0x1cd5b7))return!![];}return;}if(!_0x1dd1fa['skipConvertRolesToGroups']){let _0x9fa9a8=![];if(_0x225deb[_0x572eb0(0x2a0)]&&Array[_0x572eb0(0x1b6)](_0x225deb['Operations']))for(let _0x52e939=0x0;_0x52e939<_0x225deb['Operations'][_0x572eb0(0x283)];_0x52e939++){const _0x4671bf=_0x225deb[_0x572eb0(0x2a0)][_0x52e939];_0x4671bf[_0x572eb0(0x25e)][_0x572eb0(0x262)](_0x572eb0(0x281))&&(_0x4671bf[_0x572eb0(0x25e)]=_0x572eb0(0x2d2),Array['isArray'](_0x4671bf[_0x572eb0(0x1dd)])?(_0x4671bf[_0x572eb0(0x1dd)][0x0]['id']=_0x4671bf['value'][0x0][_0x572eb0(0x1dd)],_0x4671bf[_0x572eb0(0x1dd)][0x0][_0x572eb0(0x1db)]=_0x4671bf['value'][0x0][_0x572eb0(0x249)]+_0x572eb0(0x235)+_0x4671bf['value'][0x0][_0x572eb0(0x1dd)],delete _0x4671bf[_0x572eb0(0x1dd)][0x0][_0x572eb0(0x1dd)],delete _0x4671bf[_0x572eb0(0x1dd)][0x0][_0x572eb0(0x249)]):_0x4671bf['value']=[{'id':_0x4671bf[_0x572eb0(0x1dd)],'display':_0x4671bf[_0x572eb0(0x1dd)]}],delete _0x4671bf[_0x572eb0(0x211)],_0x9fa9a8=!![]);}if(_0x450d76[_0x572eb0(0x281)]&&Array[_0x572eb0(0x1b6)](_0x450d76[_0x572eb0(0x281)])&&_0x450d76[_0x572eb0(0x281)][_0x572eb0(0x283)]>0x0){if(!_0x450d76['groups'])_0x450d76[_0x572eb0(0x2d2)]=[];if(!Array['isArray'](_0x450d76[_0x572eb0(0x2d2)]))_0x450d76[_0x572eb0(0x2d2)]=[];for(let _0x342050=0x0;_0x342050<_0x450d76[_0x572eb0(0x281)][_0x572eb0(0x283)];_0x342050++){const _0x298751={},_0x3b4297=_0x450d76[_0x572eb0(0x281)][_0x342050];_0x298751['value']=_0x3b4297[_0x572eb0(0x1dd)],_0x298751[_0x572eb0(0x1db)]=_0x3b4297[_0x572eb0(0x249)]+_0x572eb0(0x235)+_0x3b4297[_0x572eb0(0x1db)],_0x450d76[_0x572eb0(0x2d2)]['push'](_0x298751);}delete _0x450d76[_0x572eb0(0x281)],_0x9fa9a8=!![];}if(_0x9fa9a8)_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x1e7)+JSON[_0x572eb0(0x23b)](_0x225deb));}if(!_0x4a36f9){if(_0x225deb[_0x572eb0(0x2bb)]===_0x572eb0(0x1da)){_0x1c6ff4['logger'][_0x572eb0(0x24f)](_0x216019+'\x20Delete\x20User\x20userName='+_0x42e92a+'\x20message:\x20user\x20does\x20not\x20exist'),_0x1c6ff4['logger'][_0x572eb0(0x24f)](_0x216019+'\x20done'+_0x29f29d);return;}if(_0x1dd1fa[_0x572eb0(0x248)]&&_0x1dd1fa[_0x572eb0(0x248)]===!![]){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x2d6)+_0x42e92a+'\x20message:\x20user\x20not\x20created\x20because\x20of\x20configuration\x20modifyOnly=true'),_0x1c6ff4[_0x572eb0(0x209)]['debug'](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}if(Object[_0x572eb0(0x227)]['hasOwnProperty'][_0x572eb0(0x2b3)](_0x450d76,_0x572eb0(0x233))){if(typeof _0x450d76['active']===_0x572eb0(0x298)){const _0x2b384a=_0x450d76[_0x572eb0(0x233)]['toLowerCase']();if(_0x2b384a===_0x572eb0(0x280))_0x450d76[_0x572eb0(0x233)]=!![];else{if(_0x2b384a===_0x572eb0(0x1e0))_0x450d76[_0x572eb0(0x233)]=![];}}if(_0x450d76[_0x572eb0(0x233)]===![]){_0x1c6ff4[_0x572eb0(0x209)]['debug'](_0x216019+_0x572eb0(0x2d6)+_0x42e92a+_0x572eb0(0x247)),_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}}_0x1c6ff4['logger']['debug'](_0x216019+_0x572eb0(0x26a)+_0x42e92a);const _0x3531f7=a0_0xfd4a34[_0x572eb0(0x2c7)](_0x450d76);try{delete _0x3531f7['groups'];!_0x3531f7['password']&&_0x1dd1fa['generateUserPassword']&&_0x1dd1fa[_0x572eb0(0x2c5)]===!![]&&(_0x3531f7['password']=a0_0xfd4a34[_0x572eb0(0x285)](0xf));if(_0x31bca4||_0x19f06f){if(_0x31bca4)for(const _0x5f2f09 in _0x31bca4){_0x3531f7[_0x5f2f09]=_0x31bca4[_0x5f2f09];}if(_0x19f06f)_0x3531f7['id']=_0x19f06f;await _0xd83f5a(_0x145816,_0x3531f7);}await _0x1283d0(_0x145816,_0x3531f7),_0x450d76[_0x572eb0(0x2d2)]&&Array[_0x572eb0(0x1b6)](_0x450d76[_0x572eb0(0x2d2)])&&_0x450d76[_0x572eb0(0x2d2)][_0x572eb0(0x283)]>0x0&&(_0x529564=await _0x1d3f95(_0x145816,_0x572eb0(0x1d6),_0x42e92a));}catch(_0x520628){_0x1c6ff4['logger'][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x215)+JSON[_0x572eb0(0x23b)](_0x3531f7)+'\x20error:\x20'+_0x520628[_0x572eb0(0x2a9)]+'}'),_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}}if(_0x4a36f9||_0x529564){if(_0x225deb[_0x572eb0(0x2bb)]==='deleteUser'){if(_0x1dd1fa[_0x572eb0(0x248)]&&_0x1dd1fa[_0x572eb0(0x248)]===!![]){_0x1c6ff4[_0x572eb0(0x209)]['debug'](_0x216019+_0x572eb0(0x1d4)+_0x4a36f9+_0x572eb0(0x273)),_0x1c6ff4[_0x572eb0(0x209)]['debug'](_0x216019+'\x20done'+_0x29f29d);return;}_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+'\x20Delete\x20User\x20id='+_0x4a36f9);try{await _0x50fce0(_0x145816,_0x4a36f9);}catch(_0x2d048a){_0x1c6ff4[_0x572eb0(0x209)]['error'](_0x216019+_0x572eb0(0x1d4)+_0x4a36f9+_0x572eb0(0x1dc)+_0x2d048a[_0x572eb0(0x2a9)]+'}'),_0x1c6ff4[_0x572eb0(0x209)]['debug'](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}}else{if(_0x529564)_0x4a36f9=_0x529564;_0x1c6ff4[_0x572eb0(0x209)]['debug'](_0x216019+_0x572eb0(0x1f9)+_0x4a36f9);try{await _0x52d6c3(_0x572eb0(0x2d9),_0x145816,_0x4a36f9,_0x450d76,_0x1dd1fa['usePutSoftSync']);}catch(_0xce6cf2){_0x1c6ff4['logger'][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x1f9)+_0x4a36f9+_0x572eb0(0x1dc)+_0xce6cf2[_0x572eb0(0x2a9)]),_0x1c6ff4[_0x572eb0(0x209)]['debug'](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}if(_0x1dd1fa[_0x572eb0(0x2af)]){const [_0xc9534,_0x3a3cb8]=a0_0x34c478[_0x572eb0(0x267)]({'Operations':_0x225deb[_0x572eb0(0x2a0)]});if(_0x3a3cb8){_0x1c6ff4['logger'][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x1f9)+_0x4a36f9+_0x572eb0(0x255)+_0x3a3cb8['message']),_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+'\x20done'+_0x29f29d);return;}const _0x516dc8=[];if(_0xc9534[_0x572eb0(0x281)]&&Array['isArray'](_0xc9534[_0x572eb0(0x281)]))for(let _0x27a2b6=0x0;_0x27a2b6<_0xc9534[_0x572eb0(0x281)][_0x572eb0(0x283)];_0x27a2b6++){_0xc9534['roles'][_0x27a2b6][_0x572eb0(0x2ce)]&&_0xc9534[_0x572eb0(0x281)][_0x27a2b6]['operation']===_0x572eb0(0x242)&&_0x516dc8[_0x572eb0(0x296)](_0xc9534[_0x572eb0(0x281)][_0x27a2b6]);}if(_0x516dc8[_0x572eb0(0x283)]>0x0)try{await _0x1c6ff4[_0x572eb0(0x213)](_0x145816,_0x4a36f9,{'roles':_0x516dc8});}catch(_0x27cd15){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x1f9)+_0x4a36f9+_0x572eb0(0x20b)+_0x27cd15[_0x572eb0(0x2a9)]);}const _0x567531=[];if(_0xc9534[_0x572eb0(0x2d2)]&&Array[_0x572eb0(0x1b6)](_0xc9534[_0x572eb0(0x2d2)]))for(let _0x1fbe97=0x0;_0x1fbe97<_0xc9534[_0x572eb0(0x2d2)][_0x572eb0(0x283)];_0x1fbe97++){_0xc9534['groups'][_0x1fbe97][_0x572eb0(0x2ce)]&&_0xc9534[_0x572eb0(0x2d2)][_0x1fbe97][_0x572eb0(0x2ce)]===_0x572eb0(0x242)&&_0x567531['push'](_0xc9534['groups'][_0x1fbe97]);}if(_0x567531[_0x572eb0(0x283)]>0x0)for(let _0x2b407c=0x0;_0x2b407c<_0x567531[_0x572eb0(0x283)];_0x2b407c++){try{await _0x1c6ff4[_0x572eb0(0x28b)](_0x145816,_0x567531[_0x2b407c]['id'],{'members':[{'operation':_0x572eb0(0x242),'value':_0x4a36f9}]});}catch(_0x547890){_0x1c6ff4[_0x572eb0(0x209)]['error'](_0x216019+_0x572eb0(0x1f9)+_0x4a36f9+_0x572eb0(0x1ba)+_0x547890[_0x572eb0(0x2a9)]);}}}if(_0x1dd1fa[_0x572eb0(0x1c5)]&&_0x225deb[_0x572eb0(0x2bb)]===_0x572eb0(0x213)){if(_0x450d76[_0x572eb0(0x2d2)]&&Array[_0x572eb0(0x1b6)](_0x450d76[_0x572eb0(0x2d2)])&&_0x450d76[_0x572eb0(0x2d2)][_0x572eb0(0x283)]===0x0){if(_0x450d76[_0x572eb0(0x281)]&&Array[_0x572eb0(0x1b6)](_0x450d76['roles'])&&_0x450d76['roles'][_0x572eb0(0x283)]===0x0){if(_0x225deb[_0x572eb0(0x2a0)]&&Array['isArray'](_0x225deb[_0x572eb0(0x2a0)])&&_0x225deb['Operations'][_0x572eb0(0x283)]>0x0){let _0x40c423=![];for(let _0x47076d=0x0;_0x47076d<_0x225deb['Operations'][_0x572eb0(0x283)];_0x47076d++){const _0x47558a=_0x225deb[_0x572eb0(0x2a0)][_0x47076d];if(_0x47558a['op']===_0x572eb0(0x21f)){if(_0x47558a['path']){if(_0x47558a[_0x572eb0(0x25e)][_0x572eb0(0x262)](_0x572eb0(0x281))&&_0x47558a[_0x572eb0(0x211)]){_0x40c423=!![];break;}else{if(_0x47558a[_0x572eb0(0x25e)]===_0x572eb0(0x2d2)){_0x40c423=!![];break;}}}}}if(_0x40c423){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x1d4)+_0x4a36f9);try{await _0x50fce0(_0x145816,_0x4a36f9);}catch(_0x31b6df){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x2d3)](_0x216019+_0x572eb0(0x1d4)+_0x4a36f9+_0x572eb0(0x1dc)+_0x31b6df[_0x572eb0(0x2a9)]+'}'),_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x27c)+_0x29f29d);return;}}}}}}}}_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x24f)](_0x216019+_0x572eb0(0x27c)+_0x29f29d);}catch(_0x5daea0){_0x1c6ff4[_0x572eb0(0x209)][_0x572eb0(0x2d3)](_0x1c6ff4[_0x572eb0(0x2be)]+'['+_0x1c6ff4[_0x572eb0(0x292)]+']\x20subscriber['+_0x145816+']['+_0x21440c+_0x572eb0(0x1b9)+_0x5daea0[_0x572eb0(0x2a9)]+_0x572eb0(0x20c)+_0x29f29d);}},_0x188f34=jetstream(_0x24cb52),_0xbf3a46=(_0x2e6485(0x1d3)+_0x1c6ff4[_0x2e6485(0x292)]+'_'+_0x145816)[_0x2e6485(0x208)]('*','#')[_0x2e6485(0x208)]('>','##')[_0x2e6485(0x208)]('.','_'),_0x287f45=_0x21440c['split']('.')[0x0][_0x2e6485(0x1e1)]()==='GW',_0x103bd9=async()=>{const _0x55854f=_0x2e6485;try{let _0x4b8f18;const _0x47e399=''+_0x1dd1fa?.['nats']?.[_0x55854f(0x291)],_0x245d95=await jetstreamManager(_0x24cb52),_0x18bf16=async()=>{const _0x36ade5=_0x55854f;let _0x2e5581;try{_0x2e5581=await _0x188f34[_0x36ade5(0x288)][_0x36ade5(0x1d7)](_0x47e399,_0xbf3a46);}catch(_0x588d88){const _0x4437c4={'durable_name':_0xbf3a46,'deliver_policy':DeliverPolicy[_0x36ade5(0x2cd)],'ack_policy':AckPolicy[_0x36ade5(0x2a4)],'filter_subject':_0x21440c};await _0x245d95['consumers'][_0x36ade5(0x1b3)](_0x47e399,_0x4437c4),_0x2e5581=await _0x188f34[_0x36ade5(0x288)][_0x36ade5(0x1d7)](_0x47e399,_0xbf3a46);}if(_0x2e5581?.[_0x36ade5(0x2aa)]?.['config']?.['deliver_policy']!==_0x36ade5(0x228))throw new Error(_0x36ade5(0x221));_0x2e5581?.[_0x36ade5(0x2aa)]?.[_0x36ade5(0x27e)]?.[_0x36ade5(0x2c1)]!==_0x21440c&&(await _0x245d95[_0x36ade5(0x288)][_0x36ade5(0x205)](_0x47e399,_0xbf3a46,{'filter_subject':_0x21440c}),_0x2e5581=await _0x188f34[_0x36ade5(0x288)]['get'](_0x47e399,_0xbf3a46)),_0x4b8f18=await _0x2e5581[_0x36ade5(0x1eb)]({'max_messages':0x64}),_0x46aaac(_0x4b8f18);},_0x46aaac=async _0x161210=>{const _0xbb1a3e=_0x55854f;for await(const _0x6b3615 of await _0x161210[_0xbb1a3e(0x1d0)]()){switch(_0x6b3615[_0xbb1a3e(0x249)]){case _0xbb1a3e(0x1c2):_0x1c6ff4[_0xbb1a3e(0x209)][_0xbb1a3e(0x2d8)](_0x1c6ff4[_0xbb1a3e(0x2be)]+'['+_0x1c6ff4['pluginName']+_0xbb1a3e(0x2a8)+_0x145816+']['+_0x21440c+_0xbb1a3e(0x23c)+_0x6b3615[_0xbb1a3e(0x249)]),_0x18bf16();return;}}};await _0x18bf16();let _0x398517=-0x1;do{for await(const _0x3e1e92 of _0x4b8f18){if(!_0x3e1e92[_0x55854f(0x1e2)]||!_0x3e1e92[_0x55854f(0x1e2)][_0x55854f(0x1d7)](_0x55854f(0x26e))){_0x3e1e92[_0x55854f(0x237)]();continue;}_0x398517=_0x4b8f18[_0x55854f(0x2ab)]();const _0x25a7b2=_0x1c6ff4['gwName']+'['+_0x1c6ff4['pluginName']+_0x55854f(0x2a8)+_0x145816+']['+_0x3e1e92[_0x55854f(0x21b)]+']['+_0x398517+']['+(_0x3e1e92[_0x55854f(0x1e2)]?_0x3e1e92[_0x55854f(0x1e2)][_0x55854f(0x1d7)]('Msg-Id'):'')+']',_0x50108f=_0x3e1e92['string'](),_0x5780ba=await _0xb01e09(_0x25a7b2,_0x50108f);if(!_0x5780ba||_0x5780ba!==!![])_0x3e1e92[_0x55854f(0x237)]();else _0x1c6ff4[_0x55854f(0x209)][_0x55854f(0x2d3)](_0x25a7b2+'\x20subscriber\x20error:\x20scimgateway\x20endpoint\x20connect\x20problem\x20-\x20will\x20do\x20auto\x20retry\x20until\x20connected');if(_0x398517<0x1)break;}}while(_0x398517===0x0);}catch(_0x4ffb40){_0x1c6ff4[_0x55854f(0x209)][_0x55854f(0x2d3)](_0x1c6ff4[_0x55854f(0x2be)]+'['+_0x1c6ff4['pluginName']+_0x55854f(0x2a8)+_0x145816+']['+_0x21440c+_0x55854f(0x2cb)+_0x4ffb40['message']);}},_0x4ca244=async()=>{const _0x293742=_0x2e6485,_0x3df257=_0x24cb52[_0x293742(0x24a)](_0x21440c,{'max':0x64});for await(const _0xa8a8fc of _0x3df257){const _0x31464c=_0xa8a8fc[_0x293742(0x1e2)][_0x293742(0x1d7)](_0x293742(0x26e));if(!_0xa8a8fc[_0x293742(0x1e2)]||!_0x31464c)continue;const _0x55cb4f=_0x1c6ff4['gwName']+'['+_0x1c6ff4[_0x293742(0x292)]+_0x293742(0x2a8)+_0x145816+']['+_0xa8a8fc[_0x293742(0x21b)]+']['+(_0xa8a8fc['headers']?_0x31464c:'')+']';_0x1c6ff4['logger'][_0x293742(0x24f)](_0x55cb4f+_0x293742(0x1c3));const _0x1412c5={'func':'','id':'','obj':''};let _0x4fab57;try{try{_0x4fab57=JSON[_0x293742(0x279)](_0xa8a8fc['string']());}catch(_0x41628c){const _0xebfa63=_0x293742(0x29e);_0x1c6ff4[_0x293742(0x209)][_0x293742(0x2d3)](_0x1c6ff4['gwName']+'['+_0x1c6ff4['pluginName']+_0x293742(0x2a8)+_0x145816+']['+_0x21440c+']\x20'+_0xebfa63+':\x20'+_0xa8a8fc[_0x293742(0x298)]());throw new Error(_0xebfa63);}const _0x525a3a=_0x4fab57[_0x293742(0x25a)];if(_0x525a3a?.[_0x293742(0x268)]?.['id'])_0x1412c5['id']=_0x525a3a[_0x293742(0x268)]['id'];if(_0x525a3a?.[_0x293742(0x297)]?.[_0x293742(0x2b0)])_0x1412c5[_0x293742(0x1df)]=a0_0xfd4a34['copyObj'](_0x525a3a['request'][_0x293742(0x2b0)]);if(_0x525a3a?.[_0x293742(0x297)]?.[_0x293742(0x1e2)]?.['authorization']){const _0x3e9617=_0x525a3a[_0x293742(0x297)]['headers']['authorization'];if(_0x3e9617)_0x525a3a[_0x293742(0x297)][_0x293742(0x1e2)][_0x293742(0x1de)]=a0_0xfd4a34[_0x293742(0x2d7)](_0x3e9617,_0x31464c);}if(_0x525a3a?.[_0x293742(0x1ea)]?.[_0x293742(0x1e2)]?.[_0x293742(0x1de)]){const _0xac0c72=_0x525a3a[_0x293742(0x1ea)][_0x293742(0x1e2)]['authorization'];if(_0xac0c72)_0x525a3a[_0x293742(0x1ea)][_0x293742(0x1e2)][_0x293742(0x1de)]=a0_0xfd4a34['getEncrypted'](_0xac0c72,_0x31464c);}if(_0x1c6ff4[_0x293742(0x27e)][_0x293742(0x1f7)][_0x293742(0x286)])await _0x2739a3(_0x525a3a);else{const _0x5c3063=_0x525a3a?.['routeObj']?.[_0x293742(0x21a)]+'\x20'+_0x525a3a?.[_0x293742(0x268)]?.['handle'];_0x1412c5['func']=_0x5c3063;switch(_0x5c3063){case _0x293742(0x1e8):case _0x293742(0x1b8):case'GET\x20serviceplans':if(_0x525a3a[_0x293742(0x268)]['id'])await _0x5d1d0b[_0x293742(0x28f)](_0x525a3a);else await _0x5d1d0b['getHandler'](_0x525a3a);break;case _0x293742(0x22e):await _0x5d1d0b['getApiHandler'](_0x525a3a);break;case _0x293742(0x1fc):await _0x5d1d0b[_0x293742(0x20a)](_0x525a3a);break;case _0x293742(0x25b):case'GET\x20serviceproviderconfigs':await _0x5d1d0b[_0x293742(0x21c)](_0x525a3a);break;case'PATCH\x20users':case'PATCH\x20groups':await _0x5d1d0b[_0x293742(0x270)](_0x525a3a);break;case _0x293742(0x29c):await _0x5d1d0b[_0x293742(0x238)](_0x525a3a);break;case _0x293742(0x2c2):case _0x293742(0x2ac):await _0x5d1d0b[_0x293742(0x272)](_0x525a3a);break;case _0x293742(0x244):await _0x5d1d0b[_0x293742(0x1d8)](_0x525a3a);break;case _0x293742(0x231):case'POST\x20groups':await _0x5d1d0b['postHandler'](_0x525a3a);break;case _0x293742(0x28a):await _0x5d1d0b[_0x293742(0x253)](_0x525a3a);break;case _0x293742(0x222):case _0x293742(0x1d1):await _0x5d1d0b[_0x293742(0x1c8)](_0x525a3a);break;case _0x293742(0x1f2):await _0x5d1d0b['deleteApiHandler'](_0x525a3a);break;default:_0x525a3a['response']=new Response(_0x293742(0x1b7),{'status':0x194});}}if(!_0x525a3a[_0x293742(0x2a6)])_0x525a3a[_0x293742(0x2a6)]=null;const _0x9de961=JSON[_0x293742(0x23b)](_0x525a3a[_0x293742(0x2a6)]);_0xa8a8fc[_0x293742(0x2c4)](_0x9de961),_0x1c6ff4[_0x293742(0x209)][_0x293742(0x2d8)](_0x55cb4f+'\x20message\x20handled:\x20'+_0x1412c5[_0x293742(0x276)]+_0x293742(0x24b)+(_0x1412c5['obj']?JSON[_0x293742(0x23b)](_0x1412c5['obj']):'')+_0x293742(0x1ce)+(_0x1412c5['id']?_0x1412c5['id']:'')+'}\x20message\x20response:\x20'+_0x9de961+_0x29f29d);}catch(_0x60c984){const _0x45f8fc='{\x22error\x22:\x22'+_0x60c984['message']+_0x293742(0x230)+_0x60c984['name']+'\x22}';_0xa8a8fc[_0x293742(0x2c4)](_0x45f8fc),_0x1c6ff4['logger'][_0x293742(0x2d8)]((_0x55cb4f||'')+_0x293742(0x2a1)+_0x1412c5[_0x293742(0x276)]+',\x20obj='+(_0x1412c5[_0x293742(0x1df)]?JSON[_0x293742(0x23b)](_0x1412c5['obj']):'')+_0x293742(0x1ce)+(_0x1412c5['id']?_0x1412c5['id']:'')+_0x293742(0x206)+_0x45f8fc+_0x29f29d);}}};if(_0x287f45)_0x4ca244();else _0x103bd9();},_0x535678=async(_0x52cda9,_0x1c6dc0)=>{const _0x5f5232=_0x309557,_0x554994=_0x46b9da[_0x52cda9][_0x5f5232(0x27e)]?.['nats']?.[_0x5f5232(0x21b)];let _0x40f989=0x0;for await(const _0x14a8bb of _0x1c6dc0['status']()){switch(_0x14a8bb[_0x5f5232(0x249)]){case'disconnect':_0x1c6ff4[_0x5f5232(0x209)]['error'](_0x1c6ff4[_0x5f5232(0x2be)]+'['+_0x1c6ff4['pluginName']+_0x5f5232(0x2a8)+_0x52cda9+']['+_0x554994+_0x5f5232(0x29d)+_0x14a8bb[_0x5f5232(0x21e)]+'\x20-\x20will\x20do\x20auto\x20reconnect\x20when\x20connection\x20becomes\x20available'),_0x40f989=0x0;break;case _0x5f5232(0x278):_0x1c6ff4[_0x5f5232(0x209)][_0x5f5232(0x2d8)](_0x1c6ff4[_0x5f5232(0x2be)]+'['+_0x1c6ff4[_0x5f5232(0x292)]+']\x20subscriber['+_0x52cda9+']['+_0x554994+_0x5f5232(0x261)+_0x14a8bb['data']);break;case _0x5f5232(0x2d3):_0x1c6ff4[_0x5f5232(0x209)][_0x5f5232(0x2d3)](_0x1c6ff4[_0x5f5232(0x2be)]+'['+_0x1c6ff4[_0x5f5232(0x292)]+_0x5f5232(0x2a8)+_0x52cda9+']['+_0x554994+_0x5f5232(0x204)+_0x14a8bb['data']);break;case _0x5f5232(0x2da):_0x40f989+=0x1;_0x40f989%0x1e===0x0&&_0x1c6ff4['logger']['debug'](_0x1c6ff4[_0x5f5232(0x2be)]+'['+_0x1c6ff4['pluginName']+_0x5f5232(0x2a8)+_0x52cda9+']['+_0x554994+']\x20client\x20is\x20attempting\x20to\x20reconnect\x20'+_0x14a8bb['data']+_0x5f5232(0x2ca)+_0x40f989+')');break;case'staleConnection':_0x1c6ff4[_0x5f5232(0x209)][_0x5f5232(0x24f)](_0x1c6ff4[_0x5f5232(0x2be)]+'['+_0x1c6ff4[_0x5f5232(0x292)]+_0x5f5232(0x2a8)+_0x52cda9+']['+_0x554994+_0x5f5232(0x1d5)+_0x14a8bb[_0x5f5232(0x21e)]);break;}}};process['on'](_0x309557(0x2d0),async()=>{const _0x5d9be3=_0x309557;for(const _0x31abc0 in _0x46b9da){_0x46b9da[_0x31abc0]['nc']&&!_0x46b9da[_0x31abc0]['nc'][_0x5d9be3(0x219)]()&&await _0x46b9da[_0x31abc0]['nc'][_0x5d9be3(0x22f)]();}}),process['on'](_0x309557(0x243),async()=>{const _0x7bee27=_0x309557;for(const _0x4f162c in _0x46b9da){_0x46b9da[_0x4f162c]['nc']&&!_0x46b9da[_0x4f162c]['nc'][_0x7bee27(0x219)]()&&await _0x46b9da[_0x4f162c]['nc'][_0x7bee27(0x22f)]();}});const _0x1d3f95=async(_0x50a596,_0x9b92bd,_0x311e0e)=>{const _0x8c63f6=_0x309557,_0x7bc73b={'attribute':_0x9b92bd,'operator':'eq','value':_0x311e0e,'rawFilter':undefined,'startIndex':undefined,'count':undefined},_0x90e6e8=[_0x9b92bd];if(_0x9b92bd!=='id')_0x90e6e8[_0x8c63f6(0x296)]('id');try{const _0x3b753f=await _0x2626fe(_0x50a596,_0x7bc73b,_0x90e6e8);if(!_0x3b753f||!_0x3b753f[_0x8c63f6(0x24e)]||!Array[_0x8c63f6(0x1b6)](_0x3b753f['Resources']))throw new Error('getUsers()\x20getObj='+JSON['stringify'](_0x7bc73b)+'\x20error:\x20missing\x20result');if(_0x3b753f['Resources']['length']===0x0)return null;else{if(_0x3b753f[_0x8c63f6(0x24e)][_0x8c63f6(0x283)]>0x2)throw new Error('getUsers()\x20getObj='+JSON[_0x8c63f6(0x23b)](_0x7bc73b)+'\x20error:\x20more\x20than\x20one\x20user\x20were\x20found}');else{const _0x66a98f=_0x3b753f['Resources'][0x0];if(!_0x66a98f['id'])throw new Error(_0x8c63f6(0x239)+JSON[_0x8c63f6(0x23b)](_0x7bc73b)+_0x8c63f6(0x216)+JSON[_0x8c63f6(0x23b)](_0x66a98f)+_0x8c63f6(0x2c3));return decodeURIComponent(_0x66a98f['id']);}}}catch(_0x866159){throw new Error(_0x8c63f6(0x239)+JSON[_0x8c63f6(0x23b)](_0x7bc73b)+_0x8c63f6(0x1dc)+_0x866159[_0x8c63f6(0x2a9)]+'}');}},_0x2626fe=async(_0x4526de,_0x24b82d,_0x1b03e3)=>{const _0x5c0885=_0x309557;if(!_0x28d126)return await _0x1c6ff4[_0x5c0885(0x1f6)](_0x4526de,_0x24b82d,_0x1b03e3);if(!_0x24b82d?.[_0x5c0885(0x1ed)]||_0x24b82d['operator']!=='eq')throw new Error(_0x5c0885(0x20d)+JSON['stringify'](_0x24b82d));if(_0x4526de===_0x5c0885(0x1e4))_0x4526de=undefined;let _0x4e0955=_0x4526de?'/'+_0x4526de+'/Users':_0x5c0885(0x25f);if(_0x24b82d['attribute']==='id'){_0x4e0955+='/'+_0x24b82d[_0x5c0885(0x1dd)];if(_0x1b03e3&&_0x1b03e3[_0x5c0885(0x283)]>0x0)_0x4e0955+=_0x5c0885(0x1bc)+_0x1b03e3[_0x5c0885(0x265)](',');}else{if(_0x24b82d[_0x5c0885(0x218)]===_0x5c0885(0x1d6)){_0x4e0955+=_0x5c0885(0x2d1)+_0x24b82d[_0x5c0885(0x1dd)]+'\x22';if(_0x1b03e3&&_0x1b03e3['length']>0x0)_0x4e0955+='&attributes='+_0x1b03e3['join'](',');}else{if(_0x24b82d[_0x5c0885(0x218)]==='externalId'){_0x4e0955+=_0x5c0885(0x207)+_0x24b82d[_0x5c0885(0x1dd)]+'\x22';if(_0x1b03e3&&_0x1b03e3['length']>0x0)_0x4e0955+='&attributes='+_0x1b03e3['join'](',');}else throw new Error(_0x5c0885(0x20d)+JSON[_0x5c0885(0x23b)](_0x24b82d));}}return await _0x2afd4f(_0x4526de,_0x5c0885(0x1e3),_0x4e0955);},_0x1283d0=async(_0x1030f3,_0x93c34c)=>{const _0x1032e3=_0x309557;if(!_0x28d126)return await _0x1c6ff4[_0x1032e3(0x224)](_0x1030f3,_0x93c34c);if(_0x1030f3==='undefined')_0x1030f3=undefined;const _0x4f72f6=_0x1030f3?'/'+_0x1030f3+'/Users':_0x1032e3(0x25f);return await _0x2afd4f(_0x1030f3,'POST',_0x4f72f6,_0x93c34c);},_0x52d6c3=async(_0x230181,_0x4aa24c,_0x189173,_0x2309e6,_0x22a07e)=>{const _0x41d40a=_0x309557;if(!_0x230181||_0x230181['toLowerCase']()!==_0x41d40a(0x25d))throw new Error('replaceUsrGrp()\x20error:\x20stream\x20replaceUsrGrp\x20must\x20be\x20type\x20\x22Users\x22');if(!_0x28d126)return await _0x1c6ff4[_0x41d40a(0x220)](_0x41d40a(0x2d9),_0x4aa24c,_0x189173,_0x2309e6,_0x22a07e);if(_0x4aa24c===_0x41d40a(0x1e4))_0x4aa24c=undefined;const _0x3d1c7c=_0x4aa24c?'/'+_0x4aa24c+'/Users/'+_0x189173:_0x41d40a(0x2ba)+_0x189173;return await _0x2afd4f(_0x4aa24c,'PUT',_0x3d1c7c,_0x2309e6);},_0x50fce0=async(_0x31a4b1,_0x4bef1d)=>{const _0x4cb3f2=_0x309557;!_0x28d126&&await _0x1c6ff4['deleteUser'](_0x31a4b1,_0x4bef1d);if(_0x31a4b1===_0x4cb3f2(0x1e4))_0x31a4b1=undefined;const _0xb82286=_0x31a4b1?'/'+_0x31a4b1+_0x4cb3f2(0x2ba)+_0x4bef1d:_0x4cb3f2(0x2ba)+_0x4bef1d;return await _0x2afd4f(_0x31a4b1,'DELETE',_0xb82286);},_0x3167f6=_0x166fdf=>{const _0x677062=_0x309557;if(!_0x166fdf||typeof _0x166fdf!=='string')return[null,null];_0x166fdf=_0x166fdf[_0x677062(0x1ca)]();const _0x1c95d3=_0x166fdf['indexOf']('(');if(_0x1c95d3<0x1)return[null,null];if(_0x166fdf['substring'](_0x166fdf[_0x677062(0x283)]-0x1)!==')')return[null,null];if(_0x3f2ed6(_0x166fdf,'(')!==_0x3f2ed6(_0x166fdf,')'))return[null,null];const _0x300d05=_0x166fdf[_0x677062(0x287)](0x0,_0x1c95d3),_0x5a9504=_0x166fdf[_0x677062(0x287)](_0x1c95d3+0x1,_0x166fdf['length']-0x1);let _0x270315=[];const _0x13921a=_0x5a9504['split'](',');let _0x3551bb='';for(let _0x34e3b7=0x0;_0x34e3b7<_0x13921a[_0x677062(0x283)];_0x34e3b7++){const _0x4d7c59=_0x3551bb?_0x3551bb+','+_0x13921a[_0x34e3b7]:_0x13921a[_0x34e3b7],_0x4d057e=_0x3f2ed6(_0x4d7c59,'('),_0x175ad6=_0x3f2ed6(_0x4d7c59,')');if(_0x4d057e===_0x175ad6)_0x270315[_0x677062(0x296)](_0x5de116(_0x4d7c59,'\x22')),_0x3551bb='';else{if(_0x3551bb)_0x3551bb+=','+_0x13921a[_0x34e3b7];else _0x3551bb+=_0x13921a[_0x34e3b7];}}if(_0x270315['length']===0x0)_0x270315=null;return[_0x300d05,_0x270315];};function _0x3f2ed6(_0x3a8ddf,_0x5349da){const _0x4b0ffa=_0x309557;let _0x4e459f=0x0;for(let _0x5ad7c6=0x0;_0x5ad7c6<_0x3a8ddf[_0x4b0ffa(0x283)];_0x5ad7c6++){_0x3a8ddf[_0x4b0ffa(0x266)](_0x5ad7c6)===_0x5349da&&(_0x4e459f+=0x1);}return _0x4e459f;}const _0x5de116=(_0x1577d6,_0x4367fe)=>{const _0x291bd2=_0x309557;if(typeof _0x1577d6!==_0x291bd2(0x298)||typeof _0x4367fe!=='string')return _0x1577d6;if(_0x1577d6['length']===0x1)return _0x1577d6;if(_0x4367fe['length']!==0x1)return _0x1577d6;return _0x1577d6=_0x1577d6['trim'](),_0x1577d6[_0x291bd2(0x287)](0x0,0x1)===_0x4367fe&&(_0x1577d6=_0x1577d6['substring'](0x1)),_0x1577d6[_0x291bd2(0x287)](_0x1577d6[_0x291bd2(0x283)]-0x1)===_0x4367fe&&(_0x1577d6=_0x1577d6[_0x291bd2(0x287)](0x0,_0x1577d6[_0x291bd2(0x283)]-0x1)),_0x1577d6;},_0x25a17c=async(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0xd3b695)=>{const _0xe60199=_0x309557;if(!_0x102d9a||!_0x3d5d8c||!_0xd3b695)return null;const [_0x151e07,_0x48fd35]=_0x3167f6(_0xd3b695);if(!_0x151e07||!_0x48fd35){const _0x5dd31e=_0xd3b695[_0xe60199(0x26f)]('(');if(_0x5dd31e[_0xe60199(0x283)]>0x1){const _0x42df9a=[_0xe60199(0x23e),_0xe60199(0x2b6),'firstn','elementnumber','join','replace',_0xe60199(0x263),_0xe60199(0x22d),'getuniquevalue'],_0x4b5746=_0x5dd31e[0x0][_0xe60199(0x28d)]();if(_0x42df9a['includes'](_0x4b5746))return null;}return _0xd3b695;}for(let _0xbcfb99=0x0;_0xbcfb99<_0x48fd35[_0xe60199(0x283)];_0xbcfb99++){if(_0x48fd35[_0xbcfb99][_0xe60199(0x287)](0x0,0x1)==='['){const _0x23010b=_0x48fd35[_0xbcfb99][_0xe60199(0x24d)](']');if(_0x23010b<0x0)return null;const _0x27528d=_0x48fd35[_0xbcfb99][_0xe60199(0x287)](0x1,_0x23010b),_0xa40c16=_0x27528d['split']('.');let _0x38f44b;for(let _0x35a9a6=0x0;_0x35a9a6<_0xa40c16['length'];_0x35a9a6++){if(_0x35a9a6===0x0)_0x38f44b=_0x102d9a[_0xa40c16[_0x35a9a6]];else{if(!_0x38f44b)return null;_0x38f44b=_0x38f44b[_0xa40c16[_0x35a9a6]];}}if(!_0x38f44b)return null;_0x48fd35[_0xbcfb99]=_0x38f44b;}}for(let _0x5ce54d=0x0;_0x5ce54d<_0x48fd35[_0xe60199(0x283)];_0x5ce54d++){const [_0x968f96]=_0x3167f6(_0x48fd35[_0x5ce54d]);_0x968f96&&(_0x48fd35[_0x5ce54d]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x48fd35[_0x5ce54d]));}if(_0x48fd35[0x0]===null)return null;switch(_0x151e07['toLowerCase']()){case _0xe60199(0x23e):{if(_0x48fd35[_0xe60199(0x283)]!==0x1)return null;const [_0x3f9dfb]=_0x3167f6(_0x48fd35[0x0]);if(_0x3f9dfb)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x3f9dfb);if(_0x48fd35[0x0]===null)return null;return _0x48fd35[0x0][_0xe60199(0x28d)]();}case'uppercase':{if(_0x48fd35[_0xe60199(0x283)]!==0x1)return null;const [_0x32bce0]=_0x3167f6(_0x48fd35[0x0]);if(_0x32bce0)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x32bce0);if(_0x48fd35[0x0]===null)return null;return _0x48fd35[0x0][_0xe60199(0x1e1)]();}case'firstn':{if(_0x48fd35[_0xe60199(0x283)]!==0x2)return null;const [_0x28ca69]=_0x3167f6(_0x48fd35[0x0]);if(_0x28ca69)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x28ca69);if(_0x48fd35[0x0]===null)return null;if(isNaN(_0x48fd35[0x1]))return null;return _0x48fd35[0x0][_0xe60199(0x287)](0x0,_0x48fd35[0x1]);}case'elementnumber':{const [_0x278add]=_0x3167f6(_0x48fd35[0x0]);if(_0x48fd35[_0xe60199(0x283)]<0x2)return null;if(_0x278add)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x278add);if(_0x48fd35[0x0]===null)return null;const _0x59dfae=_0x48fd35[0x1];if(isNaN(_0x59dfae))return null;let _0x474b3a;if(_0x48fd35[_0xe60199(0x283)]===0x3)_0x474b3a=_0x48fd35[0x0][_0xe60199(0x26f)](_0x48fd35[0x2]);else _0x474b3a=_0x474b3a=_0x48fd35[0x0][_0xe60199(0x26f)]('\x20');if(_0x59dfae<=_0x474b3a[_0xe60199(0x283)])return _0x474b3a[_0x59dfae-0x1];else return'';}case _0xe60199(0x1b4):{const [_0x347de0]=_0x3167f6(_0x48fd35[0x0]);if(_0x347de0)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x347de0);if(_0x48fd35[0x0]===null)return null;if(_0x48fd35[_0xe60199(0x283)]!==0x3)return null;return _0x48fd35[0x0][_0xe60199(0x208)](_0x48fd35[0x1],_0x48fd35[0x2]);}case _0xe60199(0x263):{if(_0x48fd35[_0xe60199(0x283)]!==0x1)return null;const [_0xc080]=_0x3167f6(_0x48fd35[0x0]);if(_0xc080)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0xc080);if(_0x48fd35[0x0]===null)return null;return a0_0x442400[_0xe60199(0x245)](_0x48fd35[0x0]);}case _0xe60199(0x265):{let _0x53d86b='';for(let _0x21bbbe=0x0;_0x21bbbe<_0x48fd35['length'];_0x21bbbe++){const [_0x1d69fb]=_0x3167f6(_0x48fd35[_0x21bbbe]);if(_0x1d69fb)_0x48fd35[_0x21bbbe]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x1d69fb);if(_0x48fd35[_0x21bbbe]===null)return null;_0x53d86b+=_0x48fd35[_0x21bbbe];}return _0x53d86b;}case _0xe60199(0x22d):{if(_0x48fd35[_0xe60199(0x283)]>0x2)return null;const [_0x25d93f]=_0x3167f6(_0x48fd35[0x0]);if(_0x25d93f)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x25d93f);if(_0x48fd35[0x0]===null)return null;const _0x146ac9=parseInt(_0x48fd35[0x0]);if(isNaN(_0x146ac9))return null;let _0x16fc82=_0xe60199(0x269);_0x16fc82+=','+_0x48fd35[0x0];if(_0x48fd35[_0xe60199(0x283)]===0x2&&_0x48fd35[0x1][_0xe60199(0x28d)]()===_0xe60199(0x280))_0x16fc82+=_0xe60199(0x2a2);else _0x16fc82+=',false';return _0x16fc82+='##',_0x16fc82;}case _0xe60199(0x27b):{if(_0x48fd35['length']!==0x1)return null;const [_0x15e51d]=_0x3167f6(_0x48fd35[0x0]);if(_0x15e51d)_0x48fd35[0x0]=await _0x25a17c(_0x1d8a2e,_0x102d9a,_0x3d5d8c,_0x15e51d);if(_0x48fd35[0x0]===null)return null;let _0x52fea7,_0x880f4f=![],_0x31c95f='';const _0xd90a8d=_0x48fd35[0x0]['split']('##');if(_0xd90a8d[_0xe60199(0x283)]>0x2)for(let _0x1ea8a6=0x0;_0x1ea8a6<_0xd90a8d['length'];_0x1ea8a6++){if(_0xd90a8d[_0x1ea8a6][_0xe60199(0x262)](_0xe60199(0x1cd))){const _0x56d3ba=_0xd90a8d[_0x1ea8a6][_0xe60199(0x26f)](',');if(_0x56d3ba[_0xe60199(0x283)]<0x2)return null;const _0x4e4eb0=parseInt(_0x56d3ba[0x1]);if(isNaN(_0x4e4eb0))return null;_0x31c95f='##'+_0xd90a8d[_0x1ea8a6]+'##',_0x52fea7=_0x56d3ba[0x1],_0x56d3ba['length']>0x2&&(_0x880f4f=_0x56d3ba[0x2]['toLowerCase']()===_0xe60199(0x280));}}let _0x407121,_0x1c43b4=0x0,_0x3860d7=0x0;if(_0x52fea7){_0x3860d7=_0x52fea7[_0xe60199(0x283)],_0x1c43b4=0xa;for(let _0x5a9b85=0x1;_0x5a9b85<_0x3860d7;_0x5a9b85++){_0x1c43b4*=0xa;}_0x1c43b4-=0x1,_0x407121=parseInt(_0x52fea7);if(isNaN(_0x407121))return null;_0x407121-=0x1;}else _0x407121=0x0;do{_0x407121+=0x1;let _0x4f7685=_0x48fd35[0x0];if(_0x52fea7!==undefined&&_0x31c95f){let _0x584301=_0x407121['toString']();while(_0x584301[_0xe60199(0x283)]<_0x3860d7){_0x584301='0'+_0x584301;}_0x880f4f?_0x4f7685=_0x4f7685[_0xe60199(0x1b4)](_0x31c95f,_0x584301):(_0x4f7685=_0x4f7685[_0xe60199(0x1b4)](_0x31c95f,''),_0x880f4f=!![],_0x407121-=0x1);}try{const _0x7fb2c2=await _0x1d3f95(_0x1d8a2e,_0x3d5d8c,_0x4f7685);if(!_0x7fb2c2)return _0x4f7685;}catch(_0x1e7e48){return _0x1c6ff4['logger'][_0xe60199(0x2d3)](_0x1c6ff4[_0xe60199(0x2be)]+'['+_0x1c6ff4[_0xe60199(0x292)]+']\x20'+_0x151e07+_0xe60199(0x1ef)+_0x1e7e48[_0xe60199(0x2a9)]),null;}}while(_0x407121<_0x1c43b4);return null;}default:}return null;},_0xd83f5a=async(_0x5f3d20,_0x1e5851)=>{const _0x2f7771=_0x309557;for(const _0x36ce59 in _0x1e5851){const _0x4eb8d1=_0x1e5851[_0x36ce59],[_0x25b963,_0x5b8839]=_0x3167f6(_0x4eb8d1);if(_0x25b963){const _0x484b9e=''+_0x36ce59,_0x5ad4a7=_0x25b963+'('+_0x5b8839[_0x2f7771(0x265)](',')+')',_0x1b3ebd=await _0x25a17c(_0x5f3d20,_0x1e5851,_0x484b9e,_0x5ad4a7);if(_0x1b3ebd===null)delete _0x1e5851[_0x36ce59];else _0x1e5851[_0x36ce59]=_0x1b3ebd;}for(const _0x427961 in _0x4eb8d1){const _0x1696ad=_0x4eb8d1[_0x427961],[_0x4cb23c,_0x8c0b3f]=_0x3167f6(_0x1696ad);if(_0x4cb23c){const _0x4b06d1=_0x36ce59+'.'+_0x427961,_0x3aab26=_0x4cb23c+'('+_0x8c0b3f['join'](',')+')',_0x2ade5d=await _0x25a17c(_0x5f3d20,_0x1e5851,_0x4b06d1,_0x3aab26);if(_0x2ade5d===null)delete _0x4eb8d1[_0x427961];else _0x4eb8d1[_0x427961]=_0x2ade5d;}}}return _0x1e5851;},_0x2afd4f=async(_0x1571cc,_0xb63a55,_0xb90033,_0x29ba58)=>{const _0x59f453=_0x309557;if(!_0x28d126)throw new Error(_0x59f453(0x236));if(!_0x3184ae)throw new Error(_0x59f453(0x1c6));try{if(!_0x1c6ff4[_0x59f453(0x2b2)])_0x1c6ff4[_0x59f453(0x2b2)]=_0x1c6ff4[_0x59f453(0x2d4)]();const _0x4c55ae={'headers':{'Authorization':_0x3184ae}},_0x7f4dd7=await _0x1c6ff4['helperRest'][_0x59f453(0x264)](undefined,_0xb63a55,_0x28d126+_0xb90033,_0x29ba58,undefined,_0x4c55ae);return _0x7f4dd7[_0x59f453(0x2b0)];}catch(_0x2f27a3){try{const _0x4d8370=JSON[_0x59f453(0x279)](_0x2f27a3[_0x59f453(0x2a9)]);if(_0x4d8370[_0x59f453(0x2b0)])throw new Error(JSON['stringify'](_0x4d8370[_0x59f453(0x2b0)]));throw new Error(_0x2f27a3['message']);}catch(_0x17d9ae){throw new Error(_0x59f453(0x29f)+_0x17d9ae[_0x59f453(0x2a9)]);}}},_0x2739a3=async _0x54ae8a=>{const _0x331388=_0x309557,_0x517aaf=_0x1c6ff4[_0x331388(0x27e)][_0x331388(0x1f7)][_0x331388(0x286)];if(!_0x517aaf){_0x54ae8a[_0x331388(0x2a6)]['status']=0x1f4,_0x1c6ff4[_0x331388(0x209)][_0x331388(0x2d3)](_0x1c6ff4[_0x331388(0x2be)]+'['+_0x1c6ff4['pluginName']+']\x20onChainingHandler\x20error:\x20configuration\x20scimgateway.chainingBaseUrl\x20missing');return;}try{new URL(_0x517aaf);}catch(_0x2666d9){_0x54ae8a[_0x331388(0x2a6)][_0x331388(0x1d0)]=0x1f4,_0x1c6ff4['logger'][_0x331388(0x2d3)](_0x1c6ff4[_0x331388(0x2be)]+'['+_0x1c6ff4['pluginName']+_0x331388(0x274)+_0x2666d9[_0x331388(0x2a9)]);return;}try{if(!_0x1c6ff4[_0x331388(0x2b2)])_0x1c6ff4[_0x331388(0x2b2)]=_0x1c6ff4[_0x331388(0x2d4)]();const _0x237619=new URL(_0x54ae8a[_0x331388(0x297)][_0x331388(0x24c)]),_0x2f39df=_0x54ae8a['request']['method'],_0xd6abe=_0x54ae8a[_0x331388(0x297)][_0x331388(0x24c)][_0x331388(0x1b4)](_0x237619[_0x331388(0x234)],_0x517aaf),_0x2a8719=_0x54ae8a['request'][_0x331388(0x2b0)],_0x1fe70b={'headers':{'Authorization':_0x54ae8a[_0x331388(0x297)][_0x331388(0x1e2)][_0x331388(0x1de)]}},_0xf61b4a=await _0x1c6ff4['helperRest'][_0x331388(0x264)](_0x331388(0x1e4),_0x2f39df,_0xd6abe,_0x2a8719,undefined,_0x1fe70b);_0x54ae8a['response'][_0x331388(0x1d0)]=_0xf61b4a[_0x331388(0x258)];try{_0x54ae8a[_0x331388(0x2a6)][_0x331388(0x2b0)]=JSON[_0x331388(0x23b)](_0xf61b4a[_0x331388(0x2b0)]);}catch(_0x4a116c){_0x54ae8a['response'][_0x331388(0x2b0)]=_0xf61b4a['body'];}}catch(_0x8d355f){try{const _0x7b7cda=JSON[_0x331388(0x279)](_0x8d355f[_0x331388(0x2a9)]);_0x54ae8a[_0x331388(0x2a6)][_0x331388(0x1d0)]=_0x7b7cda?.[_0x331388(0x2b0)]?.['status']||_0x7b7cda?.[_0x331388(0x258)]||0x1f4,_0x54ae8a['response'][_0x331388(0x2b0)]=_0x7b7cda[_0x331388(0x2b0)]?JSON[_0x331388(0x23b)](_0x7b7cda[_0x331388(0x2b0)]):_0x8d355f['message'];}catch(_0xc7055b){_0x54ae8a[_0x331388(0x2a6)]['status']=0x1f4,_0x1c6ff4['logger'][_0x331388(0x2d3)](_0x1c6ff4['gwName']+'['+_0x1c6ff4[_0x331388(0x292)]+']\x20onChainingHandler\x20error:\x20'+_0x8d355f[_0x331388(0x2a9)]);}}};}}export class Publisher{constructor(_0x4e5468){const _0x58d45a=a0_0x24a2,_0x54d38d=_0x4e5468,_0x4b554e={},_0x5314dc=async(_0x15445e,_0x45a2bb)=>{const _0x297aeb=a0_0x24a2,_0x4d1f71=_0x4b554e[_0x15445e][_0x297aeb(0x27e)]?.[_0x297aeb(0x26c)]?.[_0x297aeb(0x21b)];let _0x22e001=0x0;for await(const _0x6cb0c5 of _0x45a2bb[_0x297aeb(0x1d0)]()){switch(_0x6cb0c5[_0x297aeb(0x249)]){case'disconnect':_0x54d38d['logger'][_0x297aeb(0x2d3)](_0x54d38d[_0x297aeb(0x2be)]+'['+_0x54d38d[_0x297aeb(0x292)]+_0x297aeb(0x2cf)+_0x15445e+']['+_0x4d1f71+_0x297aeb(0x29d)+_0x6cb0c5[_0x297aeb(0x21e)]+'\x20-\x20will\x20do\x20auto\x20reconnect\x20when\x20connection\x20becomes\x20available'),_0x22e001=0x0;break;case _0x297aeb(0x278):_0x54d38d[_0x297aeb(0x209)]['info'](_0x54d38d[_0x297aeb(0x2be)]+'['+_0x54d38d[_0x297aeb(0x292)]+_0x297aeb(0x2cf)+_0x15445e+']['+_0x4d1f71+_0x297aeb(0x261)+_0x6cb0c5[_0x297aeb(0x21e)]);break;case _0x297aeb(0x2d3):_0x54d38d['logger']['error'](_0x54d38d['gwName']+'['+_0x54d38d[_0x297aeb(0x292)]+_0x297aeb(0x2cf)+_0x15445e+']['+_0x4d1f71+']\x20client\x20error\x20'+_0x6cb0c5[_0x297aeb(0x21e)]);break;case _0x297aeb(0x2da):_0x22e001+=0x1;_0x22e001%0x1e===0x0&&_0x54d38d[_0x297aeb(0x209)][_0x297aeb(0x24f)](_0x54d38d[_0x297aeb(0x2be)]+'['+_0x54d38d[_0x297aeb(0x292)]+_0x297aeb(0x2cf)+_0x15445e+']['+_0x4d1f71+_0x297aeb(0x241)+_0x6cb0c5[_0x297aeb(0x21e)]+_0x297aeb(0x2ca)+_0x22e001+')');break;case _0x297aeb(0x1e5):_0x54d38d[_0x297aeb(0x209)][_0x297aeb(0x24f)](_0x54d38d[_0x297aeb(0x2be)]+'['+_0x54d38d[_0x297aeb(0x292)]+_0x297aeb(0x2cf)+_0x15445e+']['+_0x4d1f71+_0x297aeb(0x1d5)+_0x6cb0c5[_0x297aeb(0x21e)]);break;}}},_0x42ad67=async(_0x27d3b3,_0x509666)=>{const _0x1312ab=a0_0x24a2,_0x55837c=_0x4b554e[_0x27d3b3]['config']?.[_0x1312ab(0x26c)]?.['subject'];let _0x2b167d;try{_0x2b167d=await a0_0x2d222d(_0x509666);if(_0x2b167d['info']['server_name']!==_0x1312ab(0x1ff)){_0x2b167d[_0x1312ab(0x22a)]();return;}_0x4b554e[_0x27d3b3]['nc']=_0x2b167d,_0x5314dc(_0x27d3b3,_0x2b167d);}catch(_0x2d0464){_0x54d38d[_0x1312ab(0x209)][_0x1312ab(0x2d3)](_0x54d38d[_0x1312ab(0x2be)]+'['+_0x54d38d[_0x1312ab(0x292)]+']\x20publisher['+_0x27d3b3+']['+_0x55837c+_0x1312ab(0x254)+_0x2d0464[_0x1312ab(0x2a9)]+_0x1312ab(0x29b)),_0x509666[_0x1312ab(0x1cb)]=!![];try{_0x2b167d=await a0_0x2d222d(_0x509666);if(_0x2b167d[_0x1312ab(0x2d8)][_0x1312ab(0x201)]!=='SCIM\x20Stream'){_0x2b167d[_0x1312ab(0x22a)]();return;}_0x4b554e[_0x27d3b3]['nc']=_0x2b167d,_0x5314dc(_0x27d3b3,_0x2b167d);}catch(_0x381bea){_0x54d38d[_0x1312ab(0x209)][_0x1312ab(0x2d3)](_0x54d38d[_0x1312ab(0x2be)]+'['+_0x54d38d['pluginName']+_0x1312ab(0x2cf)+_0x27d3b3+']['+_0x55837c+_0x1312ab(0x254)+_0x381bea[_0x1312ab(0x2a9)]);return;}}_0x54d38d[_0x1312ab(0x209)][_0x1312ab(0x24f)](_0x54d38d[_0x1312ab(0x2be)]+'['+_0x54d38d['pluginName']+_0x1312ab(0x2cf)+_0x27d3b3+']['+_0x55837c+_0x1312ab(0x1cf)+(_0x509666['tls']['ca']?_0x1312ab(0x2a3):'')+'\x20'+_0x2b167d['getServer']()),_0x2b167d[_0x1312ab(0x2c0)]()[_0x1312ab(0x25c)](_0x34cb48=>{const _0x34cff2=_0x1312ab;_0x34cb48&&_0x54d38d['logger'][_0x34cff2(0x2d3)](_0x54d38d['gwName']+'['+_0x54d38d[_0x34cff2(0x292)]+']\x20publisher['+_0x27d3b3+']['+_0x55837c+_0x34cff2(0x293)+_0x34cb48[_0x34cff2(0x2a9)]);});};this[_0x58d45a(0x1b3)]=async(_0x377831,_0x41abe7)=>{const _0x467d74=_0x58d45a;if(!_0x41abe7?.[_0x467d74(0x26c)]){_0x54d38d[_0x467d74(0x209)][_0x467d74(0x2d3)](_0x54d38d[_0x467d74(0x2be)]+'['+_0x54d38d[_0x467d74(0x292)]+']\x20publisher['+_0x377831+']\x20initialization\x20error:\x20missing\x20configuration\x20nats');return;}if(!_0x41abe7?.['nats']?.[_0x467d74(0x291)]){_0x54d38d[_0x467d74(0x209)][_0x467d74(0x2d3)](_0x54d38d['gwName']+'['+_0x54d38d['pluginName']+_0x467d74(0x2cf)+_0x377831+_0x467d74(0x2bc));return;}if(!_0x41abe7?.[_0x467d74(0x26c)]?.[_0x467d74(0x21b)]){_0x54d38d[_0x467d74(0x209)]['error'](_0x54d38d['gwName']+'['+_0x54d38d[_0x467d74(0x292)]+']\x20publisher['+_0x377831+_0x467d74(0x200));return;}if(!_0x41abe7?.[_0x467d74(0x26c)]?.[_0x467d74(0x21b)][_0x467d74(0x262)](_0x467d74(0x1b5))){_0x54d38d['logger']['error'](_0x54d38d['gwName']+'['+_0x54d38d['pluginName']+_0x467d74(0x2cf)+_0x377831+_0x467d74(0x223));return;}if(!_0x41abe7['baseUrls']||!Array['isArray'](_0x41abe7[_0x467d74(0x1c4)])||_0x41abe7[_0x467d74(0x1c4)][_0x467d74(0x283)]<0x1){_0x54d38d[_0x467d74(0x209)][_0x467d74(0x2d3)](_0x54d38d[_0x467d74(0x2be)]+'['+_0x54d38d[_0x467d74(0x292)]+_0x467d74(0x2cf)+_0x377831+_0x467d74(0x29a));return;}if(!_0x41abe7?.[_0x467d74(0x284)]?.['ca']){_0x54d38d[_0x467d74(0x209)]['error'](_0x54d38d[_0x467d74(0x2be)]+'['+_0x54d38d['pluginName']+_0x467d74(0x2cf)+_0x377831+_0x467d74(0x27d));return;}const _0xfffed7={};try{let _0x3e4c12=a0_0x5d9708[_0x467d74(0x265)](_0x54d38d['configDir'],_0x467d74(0x282),_0x41abe7?.[_0x467d74(0x284)]?.['ca']||'file-not-configured');(_0x41abe7?.[_0x467d74(0x284)]?.['ca']?.[_0x467d74(0x262)]('/')||_0x41abe7?.[_0x467d74(0x284)]?.['ca']?.[_0x467d74(0x23d)]('\x5c'))&&(_0x3e4c12=_0x41abe7[_0x467d74(0x284)]['ca']),_0xfffed7['ca']=[a0_0x42a5b2[_0x467d74(0x21d)](_0x3e4c12)],_0xfffed7['rejectUnauthorized']=!![];}catch(_0x28ab6b){_0x54d38d[_0x467d74(0x209)][_0x467d74(0x2d3)](_0x54d38d[_0x467d74(0x2be)]+'['+_0x54d38d['pluginName']+_0x467d74(0x2cf)+_0x377831+_0x467d74(0x1fb)+_0x28ab6b[_0x467d74(0x2a9)]);return;}const _0x26e717={},_0x5d4ec1=new TextEncoder()[_0x467d74(0x2cc)](_0x41abe7?.[_0x467d74(0x26c)]?.[_0x467d74(0x22b)]),_0x2596c3=_0x41abe7?.[_0x467d74(0x26c)]?.[_0x467d74(0x2b4)];_0x26e717[_0x467d74(0x2ad)]=jwtAuthenticator(_0x2596c3,_0x5d4ec1),_0x26e717[_0x467d74(0x202)]=_0x41abe7[_0x467d74(0x1c4)],_0x26e717[_0x467d74(0x2a3)]=_0xfffed7,_0x26e717[_0x467d74(0x1cb)]=![],_0x26e717[_0x467d74(0x278)]=!![],_0x26e717['reconnectTimeWait']=0x3e8*0xa,_0x26e717[_0x467d74(0x2b5)]=-0x1,_0x26e717[_0x467d74(0x1cc)]=0x2*0x3c*0x3e8,_0x26e717['maxPingOut']=0x5,_0x26e717[_0x467d74(0x24f)]=![],_0x4b554e[_0x377831]={},_0x4b554e[_0x377831]['config']=_0x41abe7,_0x4b554e[_0x377831]['nc']=undefined,_0x42ad67(_0x377831,_0x26e717);},this[_0x58d45a(0x210)]=async _0x5ed809=>{const _0x5b10c3=_0x58d45a;let _0x4f4614;const _0x34f42e=a0_0x385c0f[_0x5b10c3(0x28e)]();try{if(_0x5ed809[_0x5b10c3(0x299)]===Object){_0x4f4614=_0x5ed809['baseEntity'];if(!_0x4f4614)_0x5ed809[_0x5b10c3(0x1e9)]='undefined';if(_0x5ed809?.[_0x5b10c3(0x25a)]?.[_0x5b10c3(0x297)]?.['headers']){const _0x395fdc=_0x5ed809['ctx'][_0x5b10c3(0x297)]['headers'][_0x5b10c3(0x1d7)](_0x5b10c3(0x1de));if(_0x395fdc)_0x5ed809[_0x5b10c3(0x25a)][_0x5b10c3(0x297)][_0x5b10c3(0x1e2)][_0x5b10c3(0x203)]('authorization',a0_0xfd4a34[_0x5b10c3(0x2d7)](_0x395fdc,_0x34f42e));}if(_0x5ed809?.[_0x5b10c3(0x25a)]?.['passThrough']?.[_0x5b10c3(0x1e2)]){const _0x51aa03=_0x5ed809['ctx']['passThrough'][_0x5b10c3(0x1e2)][_0x5b10c3(0x1d7)]('authorization');if(_0x51aa03)_0x5ed809[_0x5b10c3(0x25a)][_0x5b10c3(0x1ea)][_0x5b10c3(0x1e2)][_0x5b10c3(0x203)](_0x5b10c3(0x1de),a0_0xfd4a34[_0x5b10c3(0x2d7)](_0x51aa03,_0x34f42e));}_0x5ed809=JSON[_0x5b10c3(0x23b)](_0x5ed809);}else{const _0x5d8d6f=JSON[_0x5b10c3(0x279)](_0x5ed809);_0x4f4614=_0x5d8d6f[_0x5b10c3(0x1e9)];}}catch(_0x1cd4cd){throw new Error('publisher['+_0x4f4614+_0x5b10c3(0x20f));}if(!_0x4b554e[_0x4f4614])throw new Error(_0x5b10c3(0x2a5)+_0x4f4614+']\x20error:\x20missing\x20entity\x20configuration\x20for\x20baseEntity='+_0x4f4614);const _0x2362b2=headers();_0x2362b2[_0x5b10c3(0x2d5)](_0x5b10c3(0x26e),_0x34f42e);let _0xd0a5c5;try{if(!_0x4b554e[_0x4f4614]['nc'])throw new Error(_0x5b10c3(0x2b9));_0xd0a5c5=await _0x4b554e[_0x4f4614]['nc'][_0x5b10c3(0x297)](_0x4b554e[_0x4f4614][_0x5b10c3(0x27e)]?.[_0x5b10c3(0x26c)]?.[_0x5b10c3(0x21b)],_0x5ed809,{'headers':_0x2362b2});}catch(_0x10524){if(_0x10524[_0x5b10c3(0x2a9)]==='503')throw new Error(_0x5b10c3(0x2a5)+_0x4f4614+_0x5b10c3(0x1f5)+_0x4b554e[_0x4f4614][_0x5b10c3(0x27e)]?.[_0x5b10c3(0x26c)]?.['subject']);else throw new Error(_0x5b10c3(0x2a5)+_0x4f4614+']\x20error:\x20'+_0x10524[_0x5b10c3(0x2a9)]);}let _0x1d8e4c;try{_0x1d8e4c=JSON[_0x5b10c3(0x279)](_0xd0a5c5[_0x5b10c3(0x298)]());try{JSON[_0x5b10c3(0x279)](_0x1d8e4c[_0x5b10c3(0x2b0)]);if(!_0x1d8e4c[_0x5b10c3(0x1e2)])_0x1d8e4c[_0x5b10c3(0x1e2)]={};if(!_0x1d8e4c[_0x5b10c3(0x1e2)]['content-type'])_0x1d8e4c[_0x5b10c3(0x1e2)][_0x5b10c3(0x251)]=_0x5b10c3(0x260);}catch(_0x487589){void 0x0;}}catch(_0xb87a18){throw new Error(_0x5b10c3(0x2b8)+_0xd0a5c5[_0x5b10c3(0x298)]());}if(_0x1d8e4c?.[_0x5b10c3(0x2d3)]){const _0xc61d6f=new Error(_0x5b10c3(0x1c1)+_0x1d8e4c[_0x5b10c3(0x2d3)]);_0xc61d6f[_0x5b10c3(0x250)]=_0x1d8e4c[_0x5b10c3(0x240)];throw _0xc61d6f;}return _0x1d8e4c;},process['on'](_0x58d45a(0x2d0),async()=>{const _0x47da45=_0x58d45a;for(const _0x1c2cdd in _0x4b554e){_0x4b554e[_0x1c2cdd]['nc']&&!_0x4b554e[_0x1c2cdd]['nc'][_0x47da45(0x219)]()&&await _0x4b554e[_0x1c2cdd]['nc'][_0x47da45(0x22f)]();}}),process['on'](_0x58d45a(0x243),async()=>{const _0x982600=_0x58d45a;for(const _0x1e34ff in _0x4b554e){_0x4b554e[_0x1e34ff]['nc']&&!_0x4b554e[_0x1e34ff]['nc'][_0x982600(0x219)]()&&await _0x4b554e[_0x1e34ff]['nc']['drain']();}});}}export const getAppRoles=async(_0x1be18a,_0x4abbf0)=>{const _0x422a22=a0_0x24a2,_0x2fd574=_0x422a22(0x1fe),_0x44d0d0=_0x1be18a;_0x44d0d0['logger']['debug'](_0x44d0d0[_0x422a22(0x2be)]+'['+_0x44d0d0[_0x422a22(0x292)]+_0x422a22(0x26d)+_0x2fd574+'\x22');try{if(!a0_0x42a5b2[_0x422a22(0x2c8)](_0x44d0d0['configDir']+_0x422a22(0x295)))a0_0x42a5b2[_0x422a22(0x1f3)](_0x44d0d0[_0x422a22(0x2b1)]+'/approles');}catch(_0x246189){void 0x0;}const _0xf5787=a0_0x5d9708[_0x422a22(0x265)](''+_0x44d0d0[_0x422a22(0x2b1)],_0x422a22(0x214),'approles_'+_0x44d0d0[_0x422a22(0x292)]+_0x422a22(0x1fa)),_0x362fb0={};a0_0xfd4a34['fsExistsSync'](_0xf5787)&&a0_0x42a5b2[_0x422a22(0x21d)](_0xf5787,_0x422a22(0x257))[_0x422a22(0x26f)](/\r?\n/)['forEach'](_0xebcbb7=>{const _0x1d3a5c=_0x422a22,_0x119c05=_0xebcbb7['split']('\x20');_0x119c05[_0x1d3a5c(0x283)]===0x2&&(_0x362fb0[_0x119c05[0x0]]=_0x119c05[0x1]);});const _0x4ed0c4=a0_0x42a5b2[_0x422a22(0x2ae)](_0xf5787,{'flags':'w','encoding':_0x422a22(0x1c0),'mode':0x1b6,'autoClose':!![]}),_0x451182=[],_0x2a6230=await _0x44d0d0[_0x422a22(0x1ee)](_0x4abbf0,{'attribute':undefined,'operator':undefined,'value':undefined},['id',_0x422a22(0x1be)]);return _0x2a6230[_0x422a22(0x24e)][_0x422a22(0x1bb)](_0x438484=>{const _0x32810f=_0x422a22;if(_0x438484['id']){let _0x44464d=a0_0x385c0f[_0x32810f(0x28e)]();if(_0x362fb0[_0x438484['id']])_0x44464d=_0x362fb0[_0x438484['id']];const _0x3c7877={'allowedMemberTypes':['User'],'description':'SCIM\x20Stream\x20-\x20Autogenerated','displayName':_0x438484[_0x32810f(0x1be)]||_0x438484['id'],'id':_0x44464d,'isEnabled':!![],'lang':null,'origin':'Application','value':decodeURIComponent(_0x438484['id'])};_0x451182['push'](_0x3c7877),_0x4ed0c4[_0x32810f(0x1e6)](_0x438484['id']+'\x20'+_0x44464d+'\x0a');}}),_0x4ed0c4[_0x422a22(0x22a)](),_0x44d0d0[_0x422a22(0x209)]['debug'](_0x44d0d0[_0x422a22(0x2be)]+'['+_0x44d0d0[_0x422a22(0x292)]+_0x422a22(0x1d2)+_0xf5787),{'Resources':[{'appRoles':_0x451182}]};};
14
+ 'use strict';(function(_0x2f1d51,_0xb9ba5f){const _0x30bfcb=a0_0xecb8,_0x31dc3e=_0x2f1d51();while(!![]){try{const _0xf7db2e=-parseInt(_0x30bfcb(0x26d))/0x1*(parseInt(_0x30bfcb(0x2b1))/0x2)+parseInt(_0x30bfcb(0x2e5))/0x3+-parseInt(_0x30bfcb(0x29a))/0x4+parseInt(_0x30bfcb(0x2a1))/0x5+-parseInt(_0x30bfcb(0x21f))/0x6*(-parseInt(_0x30bfcb(0x245))/0x7)+parseInt(_0x30bfcb(0x27a))/0x8*(-parseInt(_0x30bfcb(0x1f8))/0x9)+parseInt(_0x30bfcb(0x2b0))/0xa;if(_0xf7db2e===_0xb9ba5f)break;else _0x31dc3e['push'](_0x31dc3e['shift']());}catch(_0x1a7897){_0x31dc3e['push'](_0x31dc3e['shift']());}}}(a0_0x1c7f,0xc7188));function a0_0xecb8(_0x984d89,_0x20159b){const _0x1c7f73=a0_0x1c7f();return a0_0xecb8=function(_0xecb83,_0x1d2f7b){_0xecb83=_0xecb83-0x1ce;let _0x3702d0=_0x1c7f73[_0xecb83];return _0x3702d0;},a0_0xecb8(_0x984d89,_0x20159b);}import{jwtAuthenticator,headers}from'@nats-io/nats-core';import{jetstream,jetstreamManager,DeliverPolicy,AckPolicy}from'@nats-io/jetstream';function a0_0x1c7f(){const _0x7f7723=[']\x20initialization\x20error:\x20missing\x20configuration\x20nats','\x20subscriber\x20error:\x20scimgateway\x20endpoint\x20connect\x20problem\x20-\x20will\x20do\x20auto\x20retry\x20until\x20connected','origin','server_name','attribute','hasOwnProperty','doRequest','subscribe','Msg-Id','data','Explicit','63oOMjRa','streamChaining\x20called\x20but\x20missing\x20chainingBaseUrl',']\x20client\x20error\x20','publisher[','lowercase',']\x20closed\x20with\x20error:\x20','\x20processing\x20incoming\x20message',']\x20client\x20is\x20attempting\x20to\x20reconnect\x20','trim','PATCH\x20users','PATCH\x20groups','func','tls','undefined','subscriber\x20using\x20remote\x20gateway\x20through\x20chainingBaseUrl\x20requires\x20either\x20auth.tokenBearer\x20or\x20auth.basic\x20to\x20be\x20configured','Basic\x20','from','getApiHandler','getUsers()\x20error:\x20unsupported\x20operator\x20for\x20getObj:\x20','\x20role\x20removal\x20error:\x20','503','getUsers','body','\x20createUser()\x20obj=','encode','configDir','DELETE','internal\x20stream\x20policy\x20have\x20been\x20changed\x20-\x20central\x20SCIM\x20Stream\x20must\x20be\x20stopped\x20and\x20corresponding\x20./jetstream\x20folder\x20deleted\x20before\x20startup\x20allowing\x20new\x20policy','GET\x20groups','config','path','obj','reconnectTimeWait','level','replaceDomains',']\x20subscriber[','\x20Replace\x20User\x20id=','status','includes','2112UFEbdP','\x20-\x20will\x20do\x20auto\x20reconnect\x20when\x20connection\x20becomes\x20available','pingInterval','&attributes=','Application','SIGTERM','putHandler','_autogenerated.cfg','getUsers()\x20getObj=','logger','remove','stringify',']\x20initialization\x20error:\x20missing\x20configuration\x20stream.baseUrls','GET\x20api',']\x20initialization\x20error:\x20missing\x20configuration\x20nats.subject','getHandlerServiceProviderConfig','\x22,\x22errName\x22:\x22','waitOnFirstConnect','getServer','true','getGroups','readFileSync',',\x20obj=','write','\x20missing\x20user\x20object\x20in\x20message:\x20','respond','fsExistsSync','schemas','\x20message:\x20user\x20not\x20created\x20because\x20of\x20active=false','pluginName','tenant',']\x20client\x20reconnected\x20',']\x20initialization\x20certificate\x20error:\x20','closed','publish','staleConnection','isArray','rejectUnauthorized','14084CLpjfl','headers','{\x22error\x22:\x22','DELETE\x20users','nats','DELETE\x20api','replaceUsrGrp()\x20error:\x20stream\x20replaceUsrGrp\x20must\x20be\x20type\x20\x22Users\x22','file','convertedScim20','error','operation','durable_','bearerToken','ECONNREFUSED','\x20message\x20handled:\x20','\x20error:\x20missing\x20result','PATCH\x20api','join','POST\x20groups','postHandler','transports','roles','createUser','doIncrement','\x20result=','POST\x20users',']\x20initialization\x20error:\x20missing\x20configuration\x20nats.tenant','push','basic','utf8','reconnect','modifyUser','password','parse','utf-8','content-type','length','\x20message:\x20user\x20not\x20created\x20because\x20of\x20configuration\x20modifyOnly=true','\x20getUserId()\x20error:\x20','display','1AkFTzg','GET\x20serviceplans','jwt',']\x20error:\x20','errName','\x20error:\x20more\x20than\x20one\x20user\x20were\x20found}','info','}\x20message\x20response:\x20','update',']\x20approle\x20uuid\x20file\x20created:\x20','statusCode','reconnecting',']\x20initialization\x20error:\x20nats.subject\x20root\x20topic\x20must\x20be\x20\x27GW\x27,\x20nats.subject\x20example:\x20GW.APP1','772976UnLdWY','GET\x20serviceproviderconfigs','/certs/','\x20message\x20json\x20parsing\x20error:\x20','Operations','toString',']\x20error:\x20no\x20subscribers/responders\x20to\x20subject\x20','maxReconnectAttempts','prototype','helperRest','chainingBaseUrl','generateUserPassword','disconnect','UnableConnectingService','SCIM\x20Stream','secret','value','mkdirSync','SCIM\x20Stream\x20-\x20Autogenerated','/Users','foldReplacing','usePutSoftSync','\x20error:\x20missing\x20id}','modifyOnly','NOT_FOUND','maxPingOut','file-not-configured','call','typeId','url','ctx','debug','2738344UhMQVe','Resources','token','getAppRoles',']\x20connected\x20','passThrough','baseEntity','3352575BlYIVE','startsWith','timeout','newHelperRest','publisher\x20error:\x20none\x20JSON\x20formatted\x20response:\x20','copyObj','username',']\x20client\x20has\x20a\x20stale\x20connection\x20','\x20missing\x20mandatory\x20user.userName\x20in\x20message:\x20','PUT\x20users','POST','_info','patchHandler','substring',']\x20onChainingHandler\x20error:\x20configuration\x20scimgateway.chainingBaseUrl\x20must\x20use\x20correct\x20syntax\x20\x27http(s)://host:port\x27\x20error:\x20','19412040yIJquY','3181462RnIdda','getHandler','randomUUID','GET\x20serviceproviderconfig','##doIncrement',']\x20error:\x20missing\x20entity\x20configuration\x20for\x20baseEntity=','split','active','PUT\x20groups','/Users/','\x20message:\x20user\x20does\x20not\x20exist','existsSync','name','\x20error:\x20','toLowerCase','\x20handling\x20message:\x20','uppercase','constructor','ack','append','forEach','sub','string','normalize','\x20roles\x20converted\x20to\x20groups:\x20','close','\x20convertedScim20\x20error:\x20','SIGINT',']\x20initialization\x20error:\x20missing\x20certificate\x20configuration','replaceUsrGrp','scimgateway','false','deleteUser','gwName','increment','replaceAll','drain','displayName','auth','then','postApiHandler',']\x20error:\x20message\x20must\x20be\x20JSON\x20formatted','subject','\x20done',']\x20connect\x20error:\x20','isClosed','firstn',',\x20id=','base64','\x20Delete\x20User\x20id=','getuniquevalue','groups','1341672mqpnUo','publisher\x20response\x20error:\x20','}\x20message\x20error\x20response:\x20','GET\x20users','\x20Create\x20userName=','?attributes=','getProcessed','application/scim+json;\x20charset=utf-8','request','consumers','toUpperCase','ETIMEDOUT','?filter=userName\x20eq\x20\x22','Users','activityOperation','GET','charAt','get','\x20-\x20','baseUrls',']\x20publisher[','routeObj','type','set','servers','PUT','response','authorization','authenticator','replace','all','operator','POST\x20api','createWriteStream','\x20(count=','ENOTFOUND','certificate','message',']\x20client\x20disconnected\x20','getEncrypted','streamChaining\x20error:\x20','\x20message:\x20','\x20-\x20will\x20do\x20auto\x20connect\x20when\x20available\x20-\x20however,\x20please\x20verify\x20stream\x20configuration','userName','putApiHandler','/approles','elementnumber','delete','indexOf','onCreate','method','filter_subject'];a0_0x1c7f=function(){return _0x7f7723;};return a0_0x1c7f();}import{connect as a0_0x378352}from'@nats-io/transport-node';import a0_0x1db494 from'fold-to-ascii';import a0_0x7dda52 from'node:fs';import a0_0x2546bd from'node:path';import a0_0x368ba7 from'node:crypto';import*as a0_0x3465c4 from'./utils.ts';import*as a0_0x1a6d05 from'./utils-scim.ts';export class Subscriber{constructor(_0x7661ea,_0x5a2c6f){const _0x242833=a0_0xecb8,_0x4b0b6b=_0x7661ea,_0x1aa199={},_0x417e52=_0x4b0b6b[_0x242833(0x215)][_0x242833(0x2cf)][_0x242833(0x284)];let _0x4908e9='';if(_0x417e52){if(_0x4b0b6b[_0x242833(0x215)][_0x242833(0x2cf)]?.['auth']?.[_0x242833(0x251)]&&Array['isArray'](_0x4b0b6b[_0x242833(0x215)][_0x242833(0x2cf)][_0x242833(0x2d7)][_0x242833(0x251)])&&_0x4b0b6b[_0x242833(0x215)][_0x242833(0x2cf)]['auth'][_0x242833(0x251)][_0x242833(0x269)]>0x0){const _0x5d5166=_0x4b0b6b['config'][_0x242833(0x2cf)][_0x242833(0x2d7)]['bearerToken'];if(_0x5d5166[0x0]['token']){const _0x192ab3=Buffer['from'](_0x5d5166[0x0][_0x242833(0x29c)])[_0x242833(0x27f)](_0x242833(0x2e1));_0x4908e9='Bearer\x20'+_0x192ab3;}}if(!_0x4908e9&&_0x4b0b6b[_0x242833(0x215)][_0x242833(0x2cf)]?.[_0x242833(0x2d7)]?.[_0x242833(0x261)]&&Array[_0x242833(0x243)](_0x4b0b6b['config'][_0x242833(0x2cf)][_0x242833(0x2d7)][_0x242833(0x261)])&&_0x4b0b6b[_0x242833(0x215)][_0x242833(0x2cf)][_0x242833(0x2d7)][_0x242833(0x261)][_0x242833(0x269)]>0x0){const _0xa0d19=_0x4b0b6b[_0x242833(0x215)]['scimgateway']['auth'][_0x242833(0x261)];if(_0xa0d19[0x0][_0x242833(0x2a7)]&&_0xa0d19[0x0][_0x242833(0x265)]){const _0x4072a1=Buffer[_0x242833(0x208)](_0xa0d19[0x0][_0x242833(0x2a7)]+':'+_0xa0d19[0x0][_0x242833(0x265)])[_0x242833(0x27f)](_0x242833(0x2e1));_0x4908e9=_0x242833(0x207)+_0x4072a1;}}}let _0x2a103d='';for(let _0x5ee0b3=0x0;_0x5ee0b3<_0x4b0b6b['logger'][_0x242833(0x259)][_0x242833(0x269)];_0x5ee0b3++){if(_0x4b0b6b['logger'][_0x242833(0x259)][_0x5ee0b3][_0x242833(0x2bd)]===_0x242833(0x24c)){_0x2a103d=_0x4b0b6b['logger']['transports'][_0x5ee0b3][_0x242833(0x219)];break;}}const _0x36cc26=''+(_0x2a103d===_0x242833(0x299)?'\x0a':''),_0x2d034f=async(_0x4010ec,_0x1d19c1)=>{const _0x392ce4=_0x242833,_0x144397=_0x1aa199[_0x4010ec][_0x392ce4(0x215)]?.[_0x392ce4(0x249)]?.[_0x392ce4(0x2db)];let _0x125a1e;try{_0x125a1e=await a0_0x378352(_0x1d19c1);if(_0x125a1e[_0x392ce4(0x273)][_0x392ce4(0x1f0)]!==_0x392ce4(0x288)){_0x125a1e[_0x392ce4(0x2ca)]();return;}_0x1aa199[_0x4010ec]['nc']=_0x125a1e,_0x34010c(_0x4010ec,_0x125a1e),_0x316ae2(_0x4010ec,_0x125a1e);}catch(_0x43311e){_0x4b0b6b[_0x392ce4(0x228)]['error'](_0x4b0b6b[_0x392ce4(0x2d2)]+'['+_0x4b0b6b['pluginName']+_0x392ce4(0x21b)+_0x4010ec+']['+_0x144397+_0x392ce4(0x2dd)+_0x43311e[_0x392ce4(0x1de)]+'\x20-\x20will\x20do\x20auto\x20connect\x20when\x20available\x20-\x20however,\x20please\x20verify\x20stream\x20configuration'),_0x1d19c1[_0x392ce4(0x230)]=!![];try{_0x125a1e=await a0_0x378352(_0x1d19c1);if(_0x125a1e['info'][_0x392ce4(0x1f0)]!=='SCIM\x20Stream'){_0x125a1e['close']();return;}_0x1aa199[_0x4010ec]['nc']=_0x125a1e,_0x34010c(_0x4010ec,_0x125a1e),_0x316ae2(_0x4010ec,_0x125a1e);}catch(_0x3402ee){_0x4b0b6b[_0x392ce4(0x228)][_0x392ce4(0x24e)](_0x4b0b6b[_0x392ce4(0x2d2)]+'['+_0x4b0b6b[_0x392ce4(0x23c)]+_0x392ce4(0x21b)+_0x4010ec+']['+_0x144397+_0x392ce4(0x2dd)+_0x3402ee[_0x392ce4(0x1de)]);return;}}_0x4b0b6b[_0x392ce4(0x228)][_0x392ce4(0x299)](_0x4b0b6b[_0x392ce4(0x2d2)]+'['+_0x4b0b6b[_0x392ce4(0x23c)]+_0x392ce4(0x21b)+_0x4010ec+']['+_0x144397+_0x392ce4(0x29e)+(_0x1d19c1['tls']['ca']?_0x392ce4(0x204):'')+'\x20'+_0x125a1e[_0x392ce4(0x231)]()),_0x125a1e[_0x392ce4(0x240)]()[_0x392ce4(0x2d8)](_0x16770c=>{const _0x4eea0f=_0x392ce4;_0x16770c&&_0x4b0b6b[_0x4eea0f(0x228)]['error'](_0x4b0b6b[_0x4eea0f(0x2d2)]+'['+_0x4b0b6b[_0x4eea0f(0x23c)]+_0x4eea0f(0x21b)+_0x4010ec+']['+_0x144397+_0x4eea0f(0x1fd)+_0x16770c[_0x4eea0f(0x1de)]);});};this['add']=async(_0x44db75,_0x564c93)=>{const _0x1e56d1=_0x242833;if(!_0x564c93?.[_0x1e56d1(0x249)]){_0x4b0b6b[_0x1e56d1(0x228)][_0x1e56d1(0x24e)](_0x4b0b6b[_0x1e56d1(0x2d2)]+'['+_0x4b0b6b['pluginName']+_0x1e56d1(0x21b)+_0x44db75+']\x20initialization\x20error:\x20missing\x20configuration\x20nats');return;}if(!_0x564c93?.[_0x1e56d1(0x249)]?.[_0x1e56d1(0x23d)]){_0x4b0b6b[_0x1e56d1(0x228)][_0x1e56d1(0x24e)](_0x4b0b6b['gwName']+'['+_0x4b0b6b[_0x1e56d1(0x23c)]+']\x20subscriber['+_0x44db75+_0x1e56d1(0x25f));return;}if(!_0x564c93?.[_0x1e56d1(0x249)]?.[_0x1e56d1(0x2db)]){_0x4b0b6b[_0x1e56d1(0x228)][_0x1e56d1(0x24e)](_0x4b0b6b['gwName']+'['+_0x4b0b6b[_0x1e56d1(0x23c)]+_0x1e56d1(0x21b)+_0x44db75+']\x20initialization\x20error:\x20missing\x20configuration\x20nats.subject');return;}if(!_0x564c93?.[_0x1e56d1(0x1dd)]?.['ca']){_0x4b0b6b[_0x1e56d1(0x228)][_0x1e56d1(0x24e)](_0x4b0b6b[_0x1e56d1(0x2d2)]+'['+_0x4b0b6b[_0x1e56d1(0x23c)]+_0x1e56d1(0x21b)+_0x44db75+_0x1e56d1(0x2cd));return;}if(!_0x564c93[_0x1e56d1(0x2f8)]||!Array[_0x1e56d1(0x243)](_0x564c93[_0x1e56d1(0x2f8)])||_0x564c93[_0x1e56d1(0x2f8)]['length']<0x1){_0x4b0b6b['logger']['error'](_0x4b0b6b[_0x1e56d1(0x2d2)]+'['+_0x4b0b6b['pluginName']+']\x20subscriber['+_0x44db75+']\x20initialization\x20error:\x20missing\x20configuration\x20stream.baseUrls');return;}if(!_0x564c93[_0x1e56d1(0x28f)]){const _0x1d49de=_0x564c93?.['nats']?.[_0x1e56d1(0x2db)]['toUpperCase']();if(_0x1d49de[_0x1e56d1(0x2a2)]('HR.'))_0x564c93[_0x1e56d1(0x28f)]=!![];}const _0x2b7395={};try{let _0x383c29=a0_0x2546bd['join'](_0x4b0b6b[_0x1e56d1(0x211)],_0x1e56d1(0x27c),_0x564c93?.['certificate']?.['ca']||_0x1e56d1(0x294));(_0x564c93?.[_0x1e56d1(0x1dd)]?.['ca']?.[_0x1e56d1(0x2a2)]('/')||_0x564c93?.[_0x1e56d1(0x1dd)]?.['ca']?.[_0x1e56d1(0x21e)]('\x5c'))&&(_0x383c29=_0x564c93[_0x1e56d1(0x1dd)]['ca']),_0x2b7395['ca']=[a0_0x7dda52[_0x1e56d1(0x234)](_0x383c29)],_0x2b7395[_0x1e56d1(0x244)]=!![];}catch(_0x40d7ba){_0x4b0b6b[_0x1e56d1(0x228)][_0x1e56d1(0x24e)](_0x4b0b6b[_0x1e56d1(0x2d2)]+'['+_0x4b0b6b[_0x1e56d1(0x23c)]+']\x20subscriber['+_0x44db75+_0x1e56d1(0x23f)+_0x40d7ba['message']);return;}const _0x18094e={},_0x2048c8=new TextEncoder()[_0x1e56d1(0x210)](_0x564c93?.[_0x1e56d1(0x249)]?.[_0x1e56d1(0x289)]),_0x42c630=_0x564c93?.['nats']?.['jwt'];_0x18094e[_0x1e56d1(0x1d5)]=jwtAuthenticator(_0x42c630,_0x2048c8),_0x18094e[_0x1e56d1(0x1d1)]=_0x564c93[_0x1e56d1(0x2f8)],_0x18094e[_0x1e56d1(0x204)]=_0x2b7395,_0x18094e[_0x1e56d1(0x230)]=![],_0x18094e[_0x1e56d1(0x263)]=!![],_0x18094e[_0x1e56d1(0x218)]=0x3e8*0xa,_0x18094e[_0x1e56d1(0x281)]=-0x1,_0x18094e[_0x1e56d1(0x221)]=0x2*0x3c*0x3e8,_0x18094e[_0x1e56d1(0x293)]=0x5,_0x18094e['debug']=![],_0x1aa199[_0x44db75]={},_0x1aa199[_0x44db75]['config']=_0x564c93,_0x1aa199[_0x44db75]['nc']=undefined,_0x1aa199[_0x44db75][_0x1e56d1(0x2c6)]=undefined,_0x2d034f(_0x44db75,_0x18094e);};const _0x316ae2=async(_0x497188,_0x20aa74)=>{const _0x15feb7=_0x242833,_0xc5bce3=_0x1aa199[_0x497188][_0x15feb7(0x215)],_0x3c800e=_0xc5bce3?.[_0x15feb7(0x249)]?.['subject'];if(!_0x20aa74){_0x4b0b6b['logger'][_0x15feb7(0x24e)](_0x4b0b6b[_0x15feb7(0x2d2)]+'['+_0x4b0b6b['pluginName']+_0x15feb7(0x21b)+_0x497188+']['+_0x3c800e+']\x20error:\x20client\x20have\x20not\x20been\x20initialized');return;}const _0x304a52=async(_0x596cc1,_0x1dd563)=>{const _0x118556=_0x15feb7;try{_0x4b0b6b['logger'][_0x118556(0x273)](_0x596cc1+_0x118556(0x2c0)+_0x1dd563);let _0x53e452;try{if(_0xc5bce3[_0x118556(0x21a)]&&Array[_0x118556(0x243)](_0xc5bce3[_0x118556(0x21a)]))for(let _0x3cddf3=0x0;_0x3cddf3<_0xc5bce3[_0x118556(0x21a)][_0x118556(0x269)];_0x3cddf3++){const _0x32c893=_0xc5bce3[_0x118556(0x21a)][_0x3cddf3];if(!_0x32c893[_0x118556(0x208)]||!_0x32c893[_0x118556(0x208)]['includes']('.')||!_0x32c893['to']||!_0x32c893['to'][_0x118556(0x21e)]('.'))continue;const _0x7ea0ec=new RegExp('@'+_0x32c893[_0x118556(0x208)]+'\x22','gi');_0x1dd563=_0x1dd563['replace'](_0x7ea0ec,'@'+_0x32c893['to']+'\x22');}_0x53e452=JSON[_0x118556(0x266)](_0x1dd563);}catch(_0x506197){_0x4b0b6b[_0x118556(0x228)][_0x118556(0x24e)](_0x596cc1+_0x118556(0x27d)+_0x506197['message']+_0x118556(0x1e2)+_0x1dd563),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}const _0x3c6be9=_0x53e452['user'];if(!_0x3c6be9){_0x4b0b6b[_0x118556(0x228)]['error'](_0x596cc1+_0x118556(0x237)+JSON['stringify'](_0x53e452)),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+'\x20done'+_0x36cc26);return;}if(!_0x3c6be9['userName']){_0x4b0b6b['logger'][_0x118556(0x24e)](_0x596cc1+_0x118556(0x2a9)+JSON[_0x118556(0x22a)](_0x53e452)),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}delete _0x3c6be9[_0x118556(0x23a)];let _0x3d6146;_0x3c6be9['id']&&(_0x3d6146=_0x3c6be9['id'],delete _0x3c6be9['id']);let _0x4c5d94;_0x3c6be9[_0x118556(0x1ea)]&&(_0x4c5d94=a0_0x3465c4['copyObj'](_0x3c6be9['onCreate']),delete _0x3c6be9[_0x118556(0x1ea)]);await _0x5583cc(_0x497188,_0x3c6be9);const _0xfb1fd5=_0x3c6be9[_0x118556(0x1e4)];let _0x379a23,_0x353052;try{_0x379a23=await _0x3f896a(_0x497188,_0x118556(0x1e4),_0xfb1fd5);}catch(_0x42839c){_0x4b0b6b['logger'][_0x118556(0x24e)](_0x596cc1+'\x20getUserId()\x20error:\x20'+_0x42839c[_0x118556(0x1de)]),_0x4b0b6b['logger'][_0x118556(0x299)](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);const _0x52e1eb=['UnableConnectingHost',_0x118556(0x287),_0x118556(0x252),_0x118556(0x1dc),_0x118556(0x2f0),_0x118556(0x2a3)];for(const _0x43b5b9 in _0x52e1eb){if(_0x42839c['message'][_0x118556(0x21e)](_0x43b5b9))return!![];}return;}if(!_0xc5bce3['skipConvertRolesToGroups']){let _0x5b2103=![];if(_0x53e452[_0x118556(0x27e)]&&Array[_0x118556(0x243)](_0x53e452['Operations']))for(let _0x31da7c=0x0;_0x31da7c<_0x53e452['Operations']['length'];_0x31da7c++){const _0x120817=_0x53e452[_0x118556(0x27e)][_0x31da7c];_0x120817[_0x118556(0x216)]['startsWith'](_0x118556(0x25a))&&(_0x120817[_0x118556(0x216)]=_0x118556(0x2e4),Array['isArray'](_0x120817[_0x118556(0x28a)])?(_0x120817[_0x118556(0x28a)][0x0]['id']=_0x120817[_0x118556(0x28a)][0x0][_0x118556(0x28a)],_0x120817['value'][0x0][_0x118556(0x26c)]=_0x120817[_0x118556(0x28a)][0x0][_0x118556(0x1cf)]+'\x20-\x20'+_0x120817[_0x118556(0x28a)][0x0][_0x118556(0x28a)],delete _0x120817['value'][0x0][_0x118556(0x28a)],delete _0x120817[_0x118556(0x28a)][0x0][_0x118556(0x1cf)]):_0x120817[_0x118556(0x28a)]=[{'id':_0x120817['value'],'display':_0x120817[_0x118556(0x28a)]}],delete _0x120817[_0x118556(0x296)],_0x5b2103=!![]);}if(_0x3c6be9['roles']&&Array['isArray'](_0x3c6be9[_0x118556(0x25a)])&&_0x3c6be9['roles'][_0x118556(0x269)]>0x0){if(!_0x3c6be9[_0x118556(0x2e4)])_0x3c6be9[_0x118556(0x2e4)]=[];if(!Array['isArray'](_0x3c6be9[_0x118556(0x2e4)]))_0x3c6be9[_0x118556(0x2e4)]=[];for(let _0x504ac2=0x0;_0x504ac2<_0x3c6be9[_0x118556(0x25a)][_0x118556(0x269)];_0x504ac2++){const _0x36da0d={},_0x48e84a=_0x3c6be9[_0x118556(0x25a)][_0x504ac2];_0x36da0d['value']=_0x48e84a[_0x118556(0x28a)],_0x36da0d['display']=_0x48e84a[_0x118556(0x1cf)]+_0x118556(0x2f7)+_0x48e84a[_0x118556(0x26c)],_0x3c6be9[_0x118556(0x2e4)][_0x118556(0x260)](_0x36da0d);}delete _0x3c6be9[_0x118556(0x25a)],_0x5b2103=!![];}if(_0x5b2103)_0x4b0b6b[_0x118556(0x228)]['debug'](_0x596cc1+_0x118556(0x2c9)+JSON['stringify'](_0x53e452));}if(!_0x379a23){if(_0x53e452[_0x118556(0x2f3)]==='deleteUser'){_0x4b0b6b['logger'][_0x118556(0x299)](_0x596cc1+'\x20Delete\x20User\x20userName='+_0xfb1fd5+_0x118556(0x2bb)),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+'\x20done'+_0x36cc26);return;}if(_0xc5bce3[_0x118556(0x291)]&&_0xc5bce3[_0x118556(0x291)]===!![]){_0x4b0b6b[_0x118556(0x228)]['debug'](_0x596cc1+_0x118556(0x2e9)+_0xfb1fd5+_0x118556(0x26a)),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+'\x20done'+_0x36cc26);return;}if(Object[_0x118556(0x282)][_0x118556(0x1f2)][_0x118556(0x295)](_0x3c6be9,_0x118556(0x2b8))){if(typeof _0x3c6be9[_0x118556(0x2b8)]===_0x118556(0x2c7)){const _0x5d1618=_0x3c6be9[_0x118556(0x2b8)][_0x118556(0x2bf)]();if(_0x5d1618===_0x118556(0x232))_0x3c6be9[_0x118556(0x2b8)]=!![];else{if(_0x5d1618===_0x118556(0x2d0))_0x3c6be9[_0x118556(0x2b8)]=![];}}if(_0x3c6be9[_0x118556(0x2b8)]===![]){_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+'\x20Create\x20userName='+_0xfb1fd5+_0x118556(0x23b)),_0x4b0b6b[_0x118556(0x228)]['debug'](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}}_0x4b0b6b['logger']['debug'](_0x596cc1+'\x20Create\x20User\x20userName='+_0xfb1fd5);const _0x487f60=a0_0x3465c4[_0x118556(0x2a6)](_0x3c6be9);try{delete _0x487f60[_0x118556(0x2e4)];!_0x487f60[_0x118556(0x265)]&&_0xc5bce3['generateUserPassword']&&_0xc5bce3[_0x118556(0x285)]===!![]&&(_0x487f60['password']=a0_0x3465c4['createRandomPassword'](0xf));if(_0x4c5d94||_0x3d6146){if(_0x4c5d94)for(const _0x1fd870 in _0x4c5d94){_0x487f60[_0x1fd870]=_0x4c5d94[_0x1fd870];}if(_0x3d6146)_0x487f60['id']=_0x3d6146;await _0x5583cc(_0x497188,_0x487f60);}await _0x1178d1(_0x497188,_0x487f60),_0x3c6be9[_0x118556(0x2e4)]&&Array[_0x118556(0x243)](_0x3c6be9[_0x118556(0x2e4)])&&_0x3c6be9[_0x118556(0x2e4)][_0x118556(0x269)]>0x0&&(_0x353052=await _0x3f896a(_0x497188,'userName',_0xfb1fd5));}catch(_0x5038b0){_0x4b0b6b[_0x118556(0x228)][_0x118556(0x24e)](_0x596cc1+_0x118556(0x20f)+JSON['stringify'](_0x487f60)+_0x118556(0x2be)+_0x5038b0[_0x118556(0x1de)]+'}'),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}}if(_0x379a23||_0x353052){if(_0x53e452[_0x118556(0x2f3)]===_0x118556(0x2d1)){if(_0xc5bce3['modifyOnly']&&_0xc5bce3[_0x118556(0x291)]===!![]){_0x4b0b6b[_0x118556(0x228)]['debug'](_0x596cc1+'\x20Delete\x20User\x20id='+_0x379a23+'\x20message:\x20user\x20not\x20deleted\x20because\x20of\x20configuration\x20modifyOnly=true'),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+'\x20Delete\x20User\x20id='+_0x379a23);try{await _0x16e7e7(_0x497188,_0x379a23);}catch(_0x301182){_0x4b0b6b['logger']['error'](_0x596cc1+_0x118556(0x2e2)+_0x379a23+_0x118556(0x2be)+_0x301182[_0x118556(0x1de)]+'}'),_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}}else{if(_0x353052)_0x379a23=_0x353052;_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+_0x118556(0x21c)+_0x379a23);try{await _0x56424d(_0x118556(0x2f2),_0x497188,_0x379a23,_0x3c6be9,_0xc5bce3[_0x118556(0x28f)]);}catch(_0x3ff634){_0x4b0b6b[_0x118556(0x228)][_0x118556(0x24e)](_0x596cc1+_0x118556(0x21c)+_0x379a23+'\x20error:\x20'+_0x3ff634[_0x118556(0x1de)]),_0x4b0b6b[_0x118556(0x228)]['debug'](_0x596cc1+'\x20done'+_0x36cc26);return;}if(_0xc5bce3[_0x118556(0x28f)]){const [_0x23e1ca,_0x2a3197]=a0_0x1a6d05[_0x118556(0x24d)]({'Operations':_0x53e452['Operations']});if(_0x2a3197){_0x4b0b6b[_0x118556(0x228)]['error'](_0x596cc1+_0x118556(0x21c)+_0x379a23+_0x118556(0x2cb)+_0x2a3197[_0x118556(0x1de)]),_0x4b0b6b[_0x118556(0x228)]['debug'](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}const _0x4e91e8=[];if(_0x23e1ca[_0x118556(0x25a)]&&Array[_0x118556(0x243)](_0x23e1ca[_0x118556(0x25a)]))for(let _0x40e3a4=0x0;_0x40e3a4<_0x23e1ca[_0x118556(0x25a)]['length'];_0x40e3a4++){_0x23e1ca[_0x118556(0x25a)][_0x40e3a4][_0x118556(0x24f)]&&_0x23e1ca[_0x118556(0x25a)][_0x40e3a4][_0x118556(0x24f)]===_0x118556(0x1e8)&&_0x4e91e8['push'](_0x23e1ca[_0x118556(0x25a)][_0x40e3a4]);}if(_0x4e91e8['length']>0x0)try{await _0x4b0b6b['modifyUser'](_0x497188,_0x379a23,{'roles':_0x4e91e8});}catch(_0xb89656){_0x4b0b6b['logger']['error'](_0x596cc1+_0x118556(0x21c)+_0x379a23+_0x118556(0x20b)+_0xb89656['message']);}const _0x3a5a02=[];if(_0x23e1ca[_0x118556(0x2e4)]&&Array[_0x118556(0x243)](_0x23e1ca[_0x118556(0x2e4)]))for(let _0x1b21c4=0x0;_0x1b21c4<_0x23e1ca[_0x118556(0x2e4)][_0x118556(0x269)];_0x1b21c4++){_0x23e1ca[_0x118556(0x2e4)][_0x1b21c4][_0x118556(0x24f)]&&_0x23e1ca['groups'][_0x1b21c4][_0x118556(0x24f)]===_0x118556(0x1e8)&&_0x3a5a02['push'](_0x23e1ca[_0x118556(0x2e4)][_0x1b21c4]);}if(_0x3a5a02['length']>0x0)for(let _0x3e00e8=0x0;_0x3e00e8<_0x3a5a02['length'];_0x3e00e8++){try{await _0x4b0b6b['modifyGroup'](_0x497188,_0x3a5a02[_0x3e00e8]['id'],{'members':[{'operation':_0x118556(0x1e8),'value':_0x379a23}]});}catch(_0x298807){_0x4b0b6b[_0x118556(0x228)]['error'](_0x596cc1+'\x20Replace\x20User\x20id='+_0x379a23+'\x20group\x20removal\x20error:\x20'+_0x298807[_0x118556(0x1de)]);}}}if(_0xc5bce3['deleteUserOnLastGroupRoleRemoval']&&_0x53e452[_0x118556(0x2f3)]===_0x118556(0x264)){if(_0x3c6be9['groups']&&Array[_0x118556(0x243)](_0x3c6be9['groups'])&&_0x3c6be9[_0x118556(0x2e4)][_0x118556(0x269)]===0x0){if(_0x3c6be9['roles']&&Array[_0x118556(0x243)](_0x3c6be9[_0x118556(0x25a)])&&_0x3c6be9['roles'][_0x118556(0x269)]===0x0){if(_0x53e452[_0x118556(0x27e)]&&Array['isArray'](_0x53e452['Operations'])&&_0x53e452[_0x118556(0x27e)]['length']>0x0){let _0x5185c4=![];for(let _0x3cf7a5=0x0;_0x3cf7a5<_0x53e452[_0x118556(0x27e)]['length'];_0x3cf7a5++){const _0x9b0a13=_0x53e452[_0x118556(0x27e)][_0x3cf7a5];if(_0x9b0a13['op']===_0x118556(0x229)){if(_0x9b0a13[_0x118556(0x216)]){if(_0x9b0a13[_0x118556(0x216)][_0x118556(0x2a2)]('roles')&&_0x9b0a13[_0x118556(0x296)]){_0x5185c4=!![];break;}else{if(_0x9b0a13[_0x118556(0x216)]===_0x118556(0x2e4)){_0x5185c4=!![];break;}}}}}if(_0x5185c4){_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+'\x20Delete\x20User\x20id='+_0x379a23);try{await _0x16e7e7(_0x497188,_0x379a23);}catch(_0x2479df){_0x4b0b6b[_0x118556(0x228)][_0x118556(0x24e)](_0x596cc1+_0x118556(0x2e2)+_0x379a23+_0x118556(0x2be)+_0x2479df[_0x118556(0x1de)]+'}'),_0x4b0b6b['logger']['debug'](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);return;}}}}}}}}_0x4b0b6b[_0x118556(0x228)][_0x118556(0x299)](_0x596cc1+_0x118556(0x2dc)+_0x36cc26);}catch(_0x4a62ea){_0x4b0b6b[_0x118556(0x228)][_0x118556(0x24e)](_0x4b0b6b['gwName']+'['+_0x4b0b6b['pluginName']+_0x118556(0x21b)+_0x497188+']['+_0x3c800e+']\x20error:\x20'+_0x4a62ea[_0x118556(0x1de)]+'\x20=>\x20subscriber\x20not\x20activated'+_0x36cc26);}},_0xed894c=jetstream(_0x20aa74),_0x5384c5=(_0x15feb7(0x250)+_0x4b0b6b[_0x15feb7(0x23c)]+'_'+_0x497188)[_0x15feb7(0x2d4)]('*','#')[_0x15feb7(0x2d4)]('>','##')[_0x15feb7(0x2d4)]('.','_'),_0xcb4bf9=_0x3c800e[_0x15feb7(0x2b7)]('.')[0x0][_0x15feb7(0x2ef)]()==='GW',_0x33c2ea=async()=>{const _0x3896ee=_0x15feb7;try{let _0x30e649;const _0x4af810=''+_0xc5bce3?.['nats']?.['tenant'],_0x4727cf=await jetstreamManager(_0x20aa74),_0x49b6ee=async()=>{const _0x1cda46=a0_0xecb8;let _0x4f0f0b;try{_0x4f0f0b=await _0xed894c[_0x1cda46(0x2ee)][_0x1cda46(0x2f6)](_0x4af810,_0x5384c5);}catch(_0x25c0db){const _0x96a5f8={'durable_name':_0x5384c5,'deliver_policy':DeliverPolicy['All'],'ack_policy':AckPolicy[_0x1cda46(0x1f7)],'filter_subject':_0x3c800e};await _0x4727cf['consumers']['add'](_0x4af810,_0x96a5f8),_0x4f0f0b=await _0xed894c['consumers'][_0x1cda46(0x2f6)](_0x4af810,_0x5384c5);}if(_0x4f0f0b?.[_0x1cda46(0x2ac)]?.['config']?.['deliver_policy']!==_0x1cda46(0x1d7))throw new Error(_0x1cda46(0x213));_0x4f0f0b?.[_0x1cda46(0x2ac)]?.[_0x1cda46(0x215)]?.[_0x1cda46(0x1ec)]!==_0x3c800e&&(await _0x4727cf[_0x1cda46(0x2ee)][_0x1cda46(0x275)](_0x4af810,_0x5384c5,{'filter_subject':_0x3c800e}),_0x4f0f0b=await _0xed894c['consumers'][_0x1cda46(0x2f6)](_0x4af810,_0x5384c5)),_0x30e649=await _0x4f0f0b['consume']({'max_messages':0x64}),_0x5dd8b9(_0x30e649);},_0x5dd8b9=async _0x267856=>{const _0x4ece34=a0_0xecb8;for await(const _0x47455d of await _0x267856['status']()){switch(_0x47455d[_0x4ece34(0x1cf)]){case'consumer_not_found':_0x4b0b6b[_0x4ece34(0x228)][_0x4ece34(0x273)](_0x4b0b6b[_0x4ece34(0x2d2)]+'['+_0x4b0b6b['pluginName']+_0x4ece34(0x21b)+_0x497188+']['+_0x3c800e+']\x20client\x20consumer\x20reinitiated\x20because\x20of\x20'+_0x47455d[_0x4ece34(0x1cf)]),_0x49b6ee();return;}}};await _0x49b6ee();let _0x29e4c3=-0x1;do{for await(const _0xcf9a6a of _0x30e649){if(!_0xcf9a6a['headers']||!_0xcf9a6a[_0x3896ee(0x246)][_0x3896ee(0x2f6)](_0x3896ee(0x1f5))){_0xcf9a6a[_0x3896ee(0x2c3)]();continue;}_0x29e4c3=_0x30e649[_0x3896ee(0x2eb)]();const _0x5e0824=_0x4b0b6b['gwName']+'['+_0x4b0b6b[_0x3896ee(0x23c)]+_0x3896ee(0x21b)+_0x497188+']['+_0xcf9a6a[_0x3896ee(0x2db)]+']['+_0x29e4c3+']['+(_0xcf9a6a[_0x3896ee(0x246)]?_0xcf9a6a[_0x3896ee(0x246)][_0x3896ee(0x2f6)](_0x3896ee(0x1f5)):'')+']',_0x368f72=_0xcf9a6a[_0x3896ee(0x2c7)](),_0x1f3886=await _0x304a52(_0x5e0824,_0x368f72);if(!_0x1f3886||_0x1f3886!==!![])_0xcf9a6a[_0x3896ee(0x2c3)]();else _0x4b0b6b['logger'][_0x3896ee(0x24e)](_0x5e0824+_0x3896ee(0x1ee));if(_0x29e4c3<0x1)break;}}while(_0x29e4c3===0x0);}catch(_0x5669f6){_0x4b0b6b[_0x3896ee(0x228)]['error'](_0x4b0b6b[_0x3896ee(0x2d2)]+'['+_0x4b0b6b[_0x3896ee(0x23c)]+_0x3896ee(0x21b)+_0x497188+']['+_0x3c800e+']\x20subscriber\x20stopped\x20error:\x20'+_0x5669f6['message']);}},_0x344e7d=async()=>{const _0x374cf7=_0x15feb7,_0x6fe2b4=_0x20aa74[_0x374cf7(0x1f4)](_0x3c800e,{'max':0x64});for await(const _0x882998 of _0x6fe2b4){const _0x28461e=_0x882998[_0x374cf7(0x246)][_0x374cf7(0x2f6)]('Msg-Id');if(!_0x882998[_0x374cf7(0x246)]||!_0x28461e)continue;const _0x5a8659=_0x4b0b6b[_0x374cf7(0x2d2)]+'['+_0x4b0b6b[_0x374cf7(0x23c)]+_0x374cf7(0x21b)+_0x497188+']['+_0x882998[_0x374cf7(0x2db)]+']['+(_0x882998[_0x374cf7(0x246)]?_0x28461e:'')+']';_0x4b0b6b[_0x374cf7(0x228)][_0x374cf7(0x299)](_0x5a8659+_0x374cf7(0x1fe));const _0x52be18={'func':'','id':'','obj':''};let _0x372462;try{try{_0x372462=JSON['parse'](_0x882998[_0x374cf7(0x2c7)]());}catch(_0x50a1b8){const _0x5d2a9d='subscriber\x20message\x20error:\x20message\x20not\x20JSON\x20formatted';_0x4b0b6b[_0x374cf7(0x228)]['error'](_0x4b0b6b[_0x374cf7(0x2d2)]+'['+_0x4b0b6b['pluginName']+_0x374cf7(0x21b)+_0x497188+']['+_0x3c800e+']\x20'+_0x5d2a9d+':\x20'+_0x882998['string']());throw new Error(_0x5d2a9d);}const _0x511b06=_0x372462[_0x374cf7(0x298)];if(_0x511b06?.['routeObj']?.['id'])_0x52be18['id']=_0x511b06[_0x374cf7(0x1ce)]['id'];if(_0x511b06?.[_0x374cf7(0x2ed)]?.[_0x374cf7(0x20e)])_0x52be18[_0x374cf7(0x217)]=a0_0x3465c4[_0x374cf7(0x2a6)](_0x511b06[_0x374cf7(0x2ed)][_0x374cf7(0x20e)]);if(_0x511b06?.['request']?.[_0x374cf7(0x246)]?.[_0x374cf7(0x1d4)]){const _0x43e684=_0x511b06[_0x374cf7(0x2ed)][_0x374cf7(0x246)][_0x374cf7(0x1d4)];if(_0x43e684)_0x511b06['request'][_0x374cf7(0x246)][_0x374cf7(0x1d4)]=a0_0x3465c4['getEncrypted'](_0x43e684,_0x28461e);}if(_0x511b06?.[_0x374cf7(0x29f)]?.['headers']?.[_0x374cf7(0x1d4)]){const _0xef6040=_0x511b06[_0x374cf7(0x29f)][_0x374cf7(0x246)][_0x374cf7(0x1d4)];if(_0xef6040)_0x511b06[_0x374cf7(0x29f)][_0x374cf7(0x246)][_0x374cf7(0x1d4)]=a0_0x3465c4[_0x374cf7(0x1e0)](_0xef6040,_0x28461e);}if(_0x4b0b6b['config'][_0x374cf7(0x2cf)][_0x374cf7(0x284)])await _0x170d82(_0x511b06);else{const _0xa7cf29=_0x511b06?.[_0x374cf7(0x1ce)]?.[_0x374cf7(0x1eb)]+'\x20'+_0x511b06?.[_0x374cf7(0x1ce)]?.['handle'];_0x52be18[_0x374cf7(0x203)]=_0xa7cf29;switch(_0xa7cf29){case _0x374cf7(0x2e8):case _0x374cf7(0x214):case _0x374cf7(0x26e):if(_0x511b06['routeObj']['id'])await _0x5a2c6f['getHandlerId'](_0x511b06);else await _0x5a2c6f[_0x374cf7(0x2b2)](_0x511b06);break;case _0x374cf7(0x22c):await _0x5a2c6f[_0x374cf7(0x209)](_0x511b06);break;case'GET\x20schemas':await _0x5a2c6f['getHandlerSchemas'](_0x511b06);break;case _0x374cf7(0x2b4):case _0x374cf7(0x27b):await _0x5a2c6f[_0x374cf7(0x22e)](_0x511b06);break;case _0x374cf7(0x201):case _0x374cf7(0x202):await _0x5a2c6f[_0x374cf7(0x2ad)](_0x511b06);break;case _0x374cf7(0x255):await _0x5a2c6f['patchApiHandler'](_0x511b06);break;case _0x374cf7(0x2aa):case _0x374cf7(0x2b9):await _0x5a2c6f[_0x374cf7(0x225)](_0x511b06);break;case'PUT\x20api':await _0x5a2c6f[_0x374cf7(0x1e5)](_0x511b06);break;case _0x374cf7(0x25e):case _0x374cf7(0x257):await _0x5a2c6f[_0x374cf7(0x258)](_0x511b06);break;case _0x374cf7(0x1d9):await _0x5a2c6f[_0x374cf7(0x2d9)](_0x511b06);break;case _0x374cf7(0x248):case'DELETE\x20groups':await _0x5a2c6f['deleteHandler'](_0x511b06);break;case _0x374cf7(0x24a):await _0x5a2c6f['deleteApiHandler'](_0x511b06);break;default:_0x511b06[_0x374cf7(0x1d3)]=new Response(_0x374cf7(0x292),{'status':0x194});}}if(!_0x511b06[_0x374cf7(0x1d3)])_0x511b06[_0x374cf7(0x1d3)]=null;const _0x1c955e=JSON[_0x374cf7(0x22a)](_0x511b06[_0x374cf7(0x1d3)]);_0x882998[_0x374cf7(0x238)](_0x1c955e),_0x4b0b6b[_0x374cf7(0x228)][_0x374cf7(0x273)](_0x5a8659+_0x374cf7(0x253)+_0x52be18[_0x374cf7(0x203)]+_0x374cf7(0x235)+(_0x52be18['obj']?JSON[_0x374cf7(0x22a)](_0x52be18[_0x374cf7(0x217)]):'')+_0x374cf7(0x2e0)+(_0x52be18['id']?_0x52be18['id']:'')+_0x374cf7(0x274)+_0x1c955e+_0x36cc26);}catch(_0x239fcb){const _0x157214=_0x374cf7(0x247)+_0x239fcb[_0x374cf7(0x1de)]+_0x374cf7(0x22f)+_0x239fcb[_0x374cf7(0x2bd)]+'\x22}';_0x882998[_0x374cf7(0x238)](_0x157214),_0x4b0b6b[_0x374cf7(0x228)][_0x374cf7(0x273)]((_0x5a8659||'')+_0x374cf7(0x253)+_0x52be18[_0x374cf7(0x203)]+',\x20obj='+(_0x52be18[_0x374cf7(0x217)]?JSON[_0x374cf7(0x22a)](_0x52be18['obj']):'')+',\x20id='+(_0x52be18['id']?_0x52be18['id']:'')+_0x374cf7(0x2e7)+_0x157214+_0x36cc26);}}};if(_0xcb4bf9)_0x344e7d();else _0x33c2ea();},_0x34010c=async(_0x8cf3d,_0x5cc98b)=>{const _0x296e21=_0x242833,_0x4ea637=_0x1aa199[_0x8cf3d]['config']?.['nats']?.[_0x296e21(0x2db)];let _0x1b7e09=0x0;for await(const _0x41a8ba of _0x5cc98b[_0x296e21(0x21d)]()){switch(_0x41a8ba['type']){case _0x296e21(0x286):_0x4b0b6b[_0x296e21(0x228)]['error'](_0x4b0b6b[_0x296e21(0x2d2)]+'['+_0x4b0b6b[_0x296e21(0x23c)]+_0x296e21(0x21b)+_0x8cf3d+']['+_0x4ea637+_0x296e21(0x1df)+_0x41a8ba['data']+_0x296e21(0x220)),_0x1b7e09=0x0;break;case'reconnect':_0x4b0b6b[_0x296e21(0x228)][_0x296e21(0x273)](_0x4b0b6b['gwName']+'['+_0x4b0b6b[_0x296e21(0x23c)]+_0x296e21(0x21b)+_0x8cf3d+']['+_0x4ea637+_0x296e21(0x23e)+_0x41a8ba[_0x296e21(0x1f6)]);break;case _0x296e21(0x24e):_0x4b0b6b[_0x296e21(0x228)][_0x296e21(0x24e)](_0x4b0b6b[_0x296e21(0x2d2)]+'['+_0x4b0b6b[_0x296e21(0x23c)]+_0x296e21(0x21b)+_0x8cf3d+']['+_0x4ea637+_0x296e21(0x1fa)+_0x41a8ba[_0x296e21(0x1f6)]);break;case'reconnecting':_0x1b7e09+=0x1;_0x1b7e09%0x1e===0x0&&_0x4b0b6b[_0x296e21(0x228)][_0x296e21(0x299)](_0x4b0b6b[_0x296e21(0x2d2)]+'['+_0x4b0b6b[_0x296e21(0x23c)]+']\x20subscriber['+_0x8cf3d+']['+_0x4ea637+_0x296e21(0x1ff)+_0x41a8ba['data']+_0x296e21(0x1db)+_0x1b7e09+')');break;case _0x296e21(0x242):_0x4b0b6b[_0x296e21(0x228)]['debug'](_0x4b0b6b['gwName']+'['+_0x4b0b6b[_0x296e21(0x23c)]+_0x296e21(0x21b)+_0x8cf3d+']['+_0x4ea637+']\x20client\x20has\x20a\x20stale\x20connection\x20'+_0x41a8ba[_0x296e21(0x1f6)]);break;}}};process['on']('SIGTERM',async()=>{const _0x356cc1=_0x242833;for(const _0x3ea6c1 in _0x1aa199){_0x1aa199[_0x3ea6c1]['nc']&&!_0x1aa199[_0x3ea6c1]['nc']['isClosed']()&&await _0x1aa199[_0x3ea6c1]['nc'][_0x356cc1(0x2d5)]();}}),process['on'](_0x242833(0x2cc),async()=>{const _0x58fc00=_0x242833;for(const _0x2095a0 in _0x1aa199){_0x1aa199[_0x2095a0]['nc']&&!_0x1aa199[_0x2095a0]['nc'][_0x58fc00(0x2de)]()&&await _0x1aa199[_0x2095a0]['nc'][_0x58fc00(0x2d5)]();}});const _0x3f896a=async(_0x2bd130,_0x1ebb15,_0x4f78cf)=>{const _0x46f6ae=_0x242833,_0x538bf4={'attribute':_0x1ebb15,'operator':'eq','value':_0x4f78cf,'rawFilter':undefined,'startIndex':undefined,'count':undefined},_0x365d43=[_0x1ebb15];if(_0x1ebb15!=='id')_0x365d43[_0x46f6ae(0x260)]('id');try{const _0x467ea5=await _0x887639(_0x2bd130,_0x538bf4,_0x365d43);if(!_0x467ea5||!_0x467ea5[_0x46f6ae(0x29b)]||!Array[_0x46f6ae(0x243)](_0x467ea5[_0x46f6ae(0x29b)]))throw new Error(_0x46f6ae(0x227)+JSON[_0x46f6ae(0x22a)](_0x538bf4)+_0x46f6ae(0x254));if(_0x467ea5['Resources'][_0x46f6ae(0x269)]===0x0)return null;else{if(_0x467ea5['Resources']['length']>0x2)throw new Error(_0x46f6ae(0x227)+JSON[_0x46f6ae(0x22a)](_0x538bf4)+_0x46f6ae(0x272));else{const _0x4796d0=_0x467ea5[_0x46f6ae(0x29b)][0x0];if(!_0x4796d0['id'])throw new Error(_0x46f6ae(0x227)+JSON[_0x46f6ae(0x22a)](_0x538bf4)+_0x46f6ae(0x25d)+JSON[_0x46f6ae(0x22a)](_0x4796d0)+_0x46f6ae(0x290));return decodeURIComponent(_0x4796d0['id']);}}}catch(_0x1b6cad){throw new Error(_0x46f6ae(0x227)+JSON['stringify'](_0x538bf4)+'\x20error:\x20'+_0x1b6cad[_0x46f6ae(0x1de)]+'}');}},_0x887639=async(_0x567c53,_0x5d2083,_0x227845)=>{const _0x3baa47=_0x242833;if(!_0x417e52)return await _0x4b0b6b[_0x3baa47(0x20d)](_0x567c53,_0x5d2083,_0x227845);if(!_0x5d2083?.[_0x3baa47(0x1d8)]||_0x5d2083[_0x3baa47(0x1d8)]!=='eq')throw new Error('getUsers()\x20error:\x20unsupported\x20operator\x20for\x20getObj:\x20'+JSON[_0x3baa47(0x22a)](_0x5d2083));if(_0x567c53===_0x3baa47(0x205))_0x567c53=undefined;let _0x2e8912=_0x567c53?'/'+_0x567c53+_0x3baa47(0x28d):'/Users';if(_0x5d2083[_0x3baa47(0x1f1)]==='id'){_0x2e8912+='/'+_0x5d2083[_0x3baa47(0x28a)];if(_0x227845&&_0x227845[_0x3baa47(0x269)]>0x0)_0x2e8912+=_0x3baa47(0x2ea)+_0x227845[_0x3baa47(0x256)](',');}else{if(_0x5d2083[_0x3baa47(0x1f1)]==='userName'){_0x2e8912+=_0x3baa47(0x2f1)+_0x5d2083['value']+'\x22';if(_0x227845&&_0x227845[_0x3baa47(0x269)]>0x0)_0x2e8912+=_0x3baa47(0x222)+_0x227845['join'](',');}else{if(_0x5d2083[_0x3baa47(0x1f1)]==='externalId'){_0x2e8912+='?filter=externalId\x20eq\x20\x22'+_0x5d2083['value']+'\x22';if(_0x227845&&_0x227845[_0x3baa47(0x269)]>0x0)_0x2e8912+='&attributes='+_0x227845[_0x3baa47(0x256)](',');}else throw new Error(_0x3baa47(0x20a)+JSON['stringify'](_0x5d2083));}}return await _0x3a3d7f(_0x567c53,_0x3baa47(0x2f4),_0x2e8912);},_0x1178d1=async(_0x89545d,_0x51fce7)=>{const _0x8c93c1=_0x242833;if(!_0x417e52)return await _0x4b0b6b[_0x8c93c1(0x25b)](_0x89545d,_0x51fce7);if(_0x89545d===_0x8c93c1(0x205))_0x89545d=undefined;const _0x436b3c=_0x89545d?'/'+_0x89545d+'/Users':_0x8c93c1(0x28d);return await _0x3a3d7f(_0x89545d,_0x8c93c1(0x2ab),_0x436b3c,_0x51fce7);},_0x56424d=async(_0x571dc6,_0x1874c5,_0x13b6b7,_0x1dc56f,_0x293bd5)=>{const _0x569e73=_0x242833;if(!_0x571dc6||_0x571dc6['toLowerCase']()!=='users')throw new Error(_0x569e73(0x24b));if(!_0x417e52)return await _0x5a2c6f[_0x569e73(0x2ce)](_0x569e73(0x2f2),_0x1874c5,_0x13b6b7,_0x1dc56f,_0x293bd5);if(_0x1874c5===_0x569e73(0x205))_0x1874c5=undefined;const _0x3c84df=_0x1874c5?'/'+_0x1874c5+_0x569e73(0x2ba)+_0x13b6b7:_0x569e73(0x2ba)+_0x13b6b7;return await _0x3a3d7f(_0x1874c5,_0x569e73(0x1d2),_0x3c84df,_0x1dc56f);},_0x16e7e7=async(_0xc6316f,_0x6c0822)=>{const _0x1a1d51=_0x242833;!_0x417e52&&await _0x4b0b6b[_0x1a1d51(0x2d1)](_0xc6316f,_0x6c0822);if(_0xc6316f==='undefined')_0xc6316f=undefined;const _0x3e6ae7=_0xc6316f?'/'+_0xc6316f+_0x1a1d51(0x2ba)+_0x6c0822:'/Users/'+_0x6c0822;return await _0x3a3d7f(_0xc6316f,_0x1a1d51(0x212),_0x3e6ae7);},_0x30b1b9=_0x52e69b=>{const _0x5dbd7b=_0x242833;if(!_0x52e69b||typeof _0x52e69b!==_0x5dbd7b(0x2c7))return[null,null];_0x52e69b=_0x52e69b[_0x5dbd7b(0x200)]();const _0x310e52=_0x52e69b['indexOf']('(');if(_0x310e52<0x1)return[null,null];if(_0x52e69b[_0x5dbd7b(0x2ae)](_0x52e69b[_0x5dbd7b(0x269)]-0x1)!==')')return[null,null];if(_0xb8da3f(_0x52e69b,'(')!==_0xb8da3f(_0x52e69b,')'))return[null,null];const _0x2d99b7=_0x52e69b[_0x5dbd7b(0x2ae)](0x0,_0x310e52),_0x51c2a1=_0x52e69b[_0x5dbd7b(0x2ae)](_0x310e52+0x1,_0x52e69b[_0x5dbd7b(0x269)]-0x1);let _0x51601c=[];const _0x292da8=_0x51c2a1[_0x5dbd7b(0x2b7)](',');let _0x56cdea='';for(let _0xc9f36b=0x0;_0xc9f36b<_0x292da8['length'];_0xc9f36b++){const _0x4ab97a=_0x56cdea?_0x56cdea+','+_0x292da8[_0xc9f36b]:_0x292da8[_0xc9f36b],_0x284701=_0xb8da3f(_0x4ab97a,'('),_0x516bce=_0xb8da3f(_0x4ab97a,')');if(_0x284701===_0x516bce)_0x51601c[_0x5dbd7b(0x260)](_0x371062(_0x4ab97a,'\x22')),_0x56cdea='';else{if(_0x56cdea)_0x56cdea+=','+_0x292da8[_0xc9f36b];else _0x56cdea+=_0x292da8[_0xc9f36b];}}if(_0x51601c['length']===0x0)_0x51601c=null;return[_0x2d99b7,_0x51601c];};function _0xb8da3f(_0x37bf7c,_0x499b6b){const _0x42bb1c=_0x242833;let _0x64028c=0x0;for(let _0xbccde6=0x0;_0xbccde6<_0x37bf7c[_0x42bb1c(0x269)];_0xbccde6++){_0x37bf7c[_0x42bb1c(0x2f5)](_0xbccde6)===_0x499b6b&&(_0x64028c+=0x1);}return _0x64028c;}const _0x371062=(_0x36cad9,_0x57d269)=>{const _0x290903=_0x242833;if(typeof _0x36cad9!==_0x290903(0x2c7)||typeof _0x57d269!==_0x290903(0x2c7))return _0x36cad9;if(_0x36cad9[_0x290903(0x269)]===0x1)return _0x36cad9;if(_0x57d269['length']!==0x1)return _0x36cad9;return _0x36cad9=_0x36cad9[_0x290903(0x200)](),_0x36cad9[_0x290903(0x2ae)](0x0,0x1)===_0x57d269&&(_0x36cad9=_0x36cad9[_0x290903(0x2ae)](0x1)),_0x36cad9[_0x290903(0x2ae)](_0x36cad9[_0x290903(0x269)]-0x1)===_0x57d269&&(_0x36cad9=_0x36cad9[_0x290903(0x2ae)](0x0,_0x36cad9['length']-0x1)),_0x36cad9;},_0x68548=async(_0x4b8c9b,_0x73e938,_0x59e8db,_0x58286b)=>{const _0x2a82ad=_0x242833;if(!_0x73e938||!_0x59e8db||!_0x58286b)return null;const [_0xe54983,_0x66107a]=_0x30b1b9(_0x58286b);if(!_0xe54983||!_0x66107a){const _0x11526a=_0x58286b[_0x2a82ad(0x2b7)]('(');if(_0x11526a['length']>0x1){const _0x2ff862=[_0x2a82ad(0x1fc),_0x2a82ad(0x2c1),_0x2a82ad(0x2df),'elementnumber','join',_0x2a82ad(0x1d6),_0x2a82ad(0x2c8),'increment',_0x2a82ad(0x2e3)],_0x336924=_0x11526a[0x0][_0x2a82ad(0x2bf)]();if(_0x2ff862[_0x2a82ad(0x21e)](_0x336924))return null;}return _0x58286b;}for(let _0x2f53f2=0x0;_0x2f53f2<_0x66107a[_0x2a82ad(0x269)];_0x2f53f2++){if(_0x66107a[_0x2f53f2][_0x2a82ad(0x2ae)](0x0,0x1)==='['){const _0x590007=_0x66107a[_0x2f53f2][_0x2a82ad(0x1e9)](']');if(_0x590007<0x0)return null;const _0x5984dc=_0x66107a[_0x2f53f2][_0x2a82ad(0x2ae)](0x1,_0x590007),_0x67cab9=_0x5984dc[_0x2a82ad(0x2b7)]('.');let _0x126ebf;for(let _0x2582df=0x0;_0x2582df<_0x67cab9[_0x2a82ad(0x269)];_0x2582df++){if(_0x2582df===0x0)_0x126ebf=_0x73e938[_0x67cab9[_0x2582df]];else{if(!_0x126ebf)return null;_0x126ebf=_0x126ebf[_0x67cab9[_0x2582df]];}}if(!_0x126ebf)return null;_0x66107a[_0x2f53f2]=_0x126ebf;}}for(let _0x5ea7e2=0x0;_0x5ea7e2<_0x66107a[_0x2a82ad(0x269)];_0x5ea7e2++){const [_0xbd4938]=_0x30b1b9(_0x66107a[_0x5ea7e2]);_0xbd4938&&(_0x66107a[_0x5ea7e2]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0x66107a[_0x5ea7e2]));}if(_0x66107a[0x0]===null)return null;switch(_0xe54983['toLowerCase']()){case _0x2a82ad(0x1fc):{if(_0x66107a['length']!==0x1)return null;const [_0xd51cb2]=_0x30b1b9(_0x66107a[0x0]);if(_0xd51cb2)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0xd51cb2);if(_0x66107a[0x0]===null)return null;return _0x66107a[0x0][_0x2a82ad(0x2bf)]();}case _0x2a82ad(0x2c1):{if(_0x66107a[_0x2a82ad(0x269)]!==0x1)return null;const [_0xc3ace7]=_0x30b1b9(_0x66107a[0x0]);if(_0xc3ace7)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0xc3ace7);if(_0x66107a[0x0]===null)return null;return _0x66107a[0x0][_0x2a82ad(0x2ef)]();}case _0x2a82ad(0x2df):{if(_0x66107a[_0x2a82ad(0x269)]!==0x2)return null;const [_0x5740bc]=_0x30b1b9(_0x66107a[0x0]);if(_0x5740bc)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0x5740bc);if(_0x66107a[0x0]===null)return null;if(isNaN(_0x66107a[0x1]))return null;return _0x66107a[0x0]['substring'](0x0,_0x66107a[0x1]);}case _0x2a82ad(0x1e7):{const [_0x57f2e6]=_0x30b1b9(_0x66107a[0x0]);if(_0x66107a['length']<0x2)return null;if(_0x57f2e6)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0x57f2e6);if(_0x66107a[0x0]===null)return null;const _0x9338ff=_0x66107a[0x1];if(isNaN(_0x9338ff))return null;let _0x502ed5;if(_0x66107a['length']===0x3)_0x502ed5=_0x66107a[0x0][_0x2a82ad(0x2b7)](_0x66107a[0x2]);else _0x502ed5=_0x502ed5=_0x66107a[0x0][_0x2a82ad(0x2b7)]('\x20');if(_0x9338ff<=_0x502ed5[_0x2a82ad(0x269)])return _0x502ed5[_0x9338ff-0x1];else return'';}case _0x2a82ad(0x1d6):{const [_0x3073d8]=_0x30b1b9(_0x66107a[0x0]);if(_0x3073d8)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0x3073d8);if(_0x66107a[0x0]===null)return null;if(_0x66107a[_0x2a82ad(0x269)]!==0x3)return null;return _0x66107a[0x0][_0x2a82ad(0x2d4)](_0x66107a[0x1],_0x66107a[0x2]);}case'normalize':{if(_0x66107a[_0x2a82ad(0x269)]!==0x1)return null;const [_0x2b9e28]=_0x30b1b9(_0x66107a[0x0]);if(_0x2b9e28)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0x2b9e28);if(_0x66107a[0x0]===null)return null;return a0_0x1db494[_0x2a82ad(0x28e)](_0x66107a[0x0]);}case _0x2a82ad(0x256):{let _0x11e8db='';for(let _0x2bdfce=0x0;_0x2bdfce<_0x66107a['length'];_0x2bdfce++){const [_0xf59a82]=_0x30b1b9(_0x66107a[_0x2bdfce]);if(_0xf59a82)_0x66107a[_0x2bdfce]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0xf59a82);if(_0x66107a[_0x2bdfce]===null)return null;_0x11e8db+=_0x66107a[_0x2bdfce];}return _0x11e8db;}case _0x2a82ad(0x2d3):{if(_0x66107a[_0x2a82ad(0x269)]>0x2)return null;const [_0x3d8b24]=_0x30b1b9(_0x66107a[0x0]);if(_0x3d8b24)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0x3d8b24);if(_0x66107a[0x0]===null)return null;const _0x4dd0f0=parseInt(_0x66107a[0x0]);if(isNaN(_0x4dd0f0))return null;let _0xacaf04=_0x2a82ad(0x2b5);_0xacaf04+=','+_0x66107a[0x0];if(_0x66107a['length']===0x2&&_0x66107a[0x1]['toLowerCase']()===_0x2a82ad(0x232))_0xacaf04+=',true';else _0xacaf04+=',false';return _0xacaf04+='##',_0xacaf04;}case _0x2a82ad(0x2e3):{if(_0x66107a[_0x2a82ad(0x269)]!==0x1)return null;const [_0x4d5783]=_0x30b1b9(_0x66107a[0x0]);if(_0x4d5783)_0x66107a[0x0]=await _0x68548(_0x4b8c9b,_0x73e938,_0x59e8db,_0x4d5783);if(_0x66107a[0x0]===null)return null;let _0x507a94,_0x2f3297=![],_0x56ddf7='';const _0x5c29eb=_0x66107a[0x0][_0x2a82ad(0x2b7)]('##');if(_0x5c29eb[_0x2a82ad(0x269)]>0x2)for(let _0x5ebf24=0x0;_0x5ebf24<_0x5c29eb['length'];_0x5ebf24++){if(_0x5c29eb[_0x5ebf24][_0x2a82ad(0x2a2)](_0x2a82ad(0x25c))){const _0x5ba582=_0x5c29eb[_0x5ebf24][_0x2a82ad(0x2b7)](',');if(_0x5ba582[_0x2a82ad(0x269)]<0x2)return null;const _0x2f28ac=parseInt(_0x5ba582[0x1]);if(isNaN(_0x2f28ac))return null;_0x56ddf7='##'+_0x5c29eb[_0x5ebf24]+'##',_0x507a94=_0x5ba582[0x1],_0x5ba582[_0x2a82ad(0x269)]>0x2&&(_0x2f3297=_0x5ba582[0x2]['toLowerCase']()===_0x2a82ad(0x232));}}let _0x22f1aa,_0x56d6a4=0x0,_0x227e72=0x0;if(_0x507a94){_0x227e72=_0x507a94['length'],_0x56d6a4=0xa;for(let _0xf702c8=0x1;_0xf702c8<_0x227e72;_0xf702c8++){_0x56d6a4*=0xa;}_0x56d6a4-=0x1,_0x22f1aa=parseInt(_0x507a94);if(isNaN(_0x22f1aa))return null;_0x22f1aa-=0x1;}else _0x22f1aa=0x0;do{_0x22f1aa+=0x1;let _0x492854=_0x66107a[0x0];if(_0x507a94!==undefined&&_0x56ddf7){let _0x17d171=_0x22f1aa[_0x2a82ad(0x27f)]();while(_0x17d171['length']<_0x227e72){_0x17d171='0'+_0x17d171;}_0x2f3297?_0x492854=_0x492854[_0x2a82ad(0x1d6)](_0x56ddf7,_0x17d171):(_0x492854=_0x492854[_0x2a82ad(0x1d6)](_0x56ddf7,''),_0x2f3297=!![],_0x22f1aa-=0x1);}try{const _0x69b797=await _0x3f896a(_0x4b8c9b,_0x59e8db,_0x492854);if(!_0x69b797)return _0x492854;}catch(_0x4c24fe){return _0x4b0b6b[_0x2a82ad(0x228)][_0x2a82ad(0x24e)](_0x4b0b6b[_0x2a82ad(0x2d2)]+'['+_0x4b0b6b['pluginName']+']\x20'+_0xe54983+_0x2a82ad(0x26b)+_0x4c24fe[_0x2a82ad(0x1de)]),null;}}while(_0x22f1aa<_0x56d6a4);return null;}default:}return null;},_0x5583cc=async(_0x2218cb,_0x571a0b)=>{const _0x1b5692=_0x242833;for(const _0x2ea401 in _0x571a0b){const _0x25c9b7=_0x571a0b[_0x2ea401],[_0x1993fd,_0x4a0f67]=_0x30b1b9(_0x25c9b7);if(_0x1993fd){const _0x4e7685=''+_0x2ea401,_0x5022ab=_0x1993fd+'('+_0x4a0f67[_0x1b5692(0x256)](',')+')',_0x22454c=await _0x68548(_0x2218cb,_0x571a0b,_0x4e7685,_0x5022ab);if(_0x22454c===null)delete _0x571a0b[_0x2ea401];else _0x571a0b[_0x2ea401]=_0x22454c;}for(const _0x2edb32 in _0x25c9b7){const _0x12472d=_0x25c9b7[_0x2edb32],[_0xbf543e,_0x1aca6a]=_0x30b1b9(_0x12472d);if(_0xbf543e){const _0xf28ed4=_0x2ea401+'.'+_0x2edb32,_0x19f05c=_0xbf543e+'('+_0x1aca6a['join'](',')+')',_0x2c91dc=await _0x68548(_0x2218cb,_0x571a0b,_0xf28ed4,_0x19f05c);if(_0x2c91dc===null)delete _0x25c9b7[_0x2edb32];else _0x25c9b7[_0x2edb32]=_0x2c91dc;}}}return _0x571a0b;},_0x3a3d7f=async(_0x5e6546,_0x87f5a3,_0x5c939c,_0x247516)=>{const _0x588428=_0x242833;if(!_0x417e52)throw new Error(_0x588428(0x1f9));if(!_0x4908e9)throw new Error(_0x588428(0x206));try{if(!_0x4b0b6b['helperRest'])_0x4b0b6b[_0x588428(0x283)]=_0x4b0b6b[_0x588428(0x2a4)]();const _0x4d0fa8={'headers':{'Authorization':_0x4908e9}},_0xef30ac=await _0x4b0b6b[_0x588428(0x283)][_0x588428(0x1f3)](undefined,_0x87f5a3,_0x417e52+_0x5c939c,_0x247516,undefined,_0x4d0fa8);return _0xef30ac[_0x588428(0x20e)];}catch(_0x389557){try{const _0x440ce2=JSON[_0x588428(0x266)](_0x389557['message']);if(_0x440ce2[_0x588428(0x20e)])throw new Error(JSON[_0x588428(0x22a)](_0x440ce2[_0x588428(0x20e)]));throw new Error(_0x389557[_0x588428(0x1de)]);}catch(_0x3d00af){throw new Error(_0x588428(0x1e1)+_0x3d00af['message']);}}},_0x170d82=async _0x2602ee=>{const _0x135525=_0x242833,_0x4053c8=_0x4b0b6b[_0x135525(0x215)][_0x135525(0x2cf)]['chainingBaseUrl'];if(!_0x4053c8){_0x2602ee[_0x135525(0x1d3)][_0x135525(0x21d)]=0x1f4,_0x4b0b6b[_0x135525(0x228)][_0x135525(0x24e)](_0x4b0b6b[_0x135525(0x2d2)]+'['+_0x4b0b6b[_0x135525(0x23c)]+']\x20onChainingHandler\x20error:\x20configuration\x20scimgateway.chainingBaseUrl\x20missing');return;}try{new URL(_0x4053c8);}catch(_0x551c70){_0x2602ee[_0x135525(0x1d3)][_0x135525(0x21d)]=0x1f4,_0x4b0b6b['logger']['error'](_0x4b0b6b[_0x135525(0x2d2)]+'['+_0x4b0b6b['pluginName']+_0x135525(0x2af)+_0x551c70['message']);return;}try{if(!_0x4b0b6b[_0x135525(0x283)])_0x4b0b6b[_0x135525(0x283)]=_0x4b0b6b[_0x135525(0x2a4)]();const _0x9ffea3=new URL(_0x2602ee['request'][_0x135525(0x297)]),_0x288398=_0x2602ee['request']['method'],_0x133073=_0x2602ee[_0x135525(0x2ed)][_0x135525(0x297)][_0x135525(0x1d6)](_0x9ffea3[_0x135525(0x1ef)],_0x4053c8),_0x5bfaf0=_0x2602ee[_0x135525(0x2ed)][_0x135525(0x20e)],_0xbc5994={'headers':{'Authorization':_0x2602ee[_0x135525(0x2ed)][_0x135525(0x246)][_0x135525(0x1d4)]}},_0x406146=await _0x4b0b6b[_0x135525(0x283)][_0x135525(0x1f3)](_0x135525(0x205),_0x288398,_0x133073,_0x5bfaf0,undefined,_0xbc5994);_0x2602ee[_0x135525(0x1d3)][_0x135525(0x21d)]=_0x406146[_0x135525(0x277)];try{_0x2602ee[_0x135525(0x1d3)][_0x135525(0x20e)]=JSON['stringify'](_0x406146[_0x135525(0x20e)]);}catch(_0x5b51a0){_0x2602ee[_0x135525(0x1d3)][_0x135525(0x20e)]=_0x406146[_0x135525(0x20e)];}}catch(_0x508c6c){try{const _0x7dc66=JSON[_0x135525(0x266)](_0x508c6c[_0x135525(0x1de)]);_0x2602ee['response'][_0x135525(0x21d)]=_0x7dc66?.['body']?.[_0x135525(0x21d)]||_0x7dc66?.[_0x135525(0x277)]||0x1f4,_0x2602ee[_0x135525(0x1d3)][_0x135525(0x20e)]=_0x7dc66[_0x135525(0x20e)]?JSON[_0x135525(0x22a)](_0x7dc66[_0x135525(0x20e)]):_0x508c6c[_0x135525(0x1de)];}catch(_0x5232b5){_0x2602ee[_0x135525(0x1d3)][_0x135525(0x21d)]=0x1f4,_0x4b0b6b[_0x135525(0x228)][_0x135525(0x24e)](_0x4b0b6b['gwName']+'['+_0x4b0b6b[_0x135525(0x23c)]+']\x20onChainingHandler\x20error:\x20'+_0x508c6c[_0x135525(0x1de)]);}}};}}export class Publisher{constructor(_0x282650){const _0x1f62f9=a0_0xecb8,_0x360a2e=_0x282650,_0x2108c4={},_0xd1b037=async(_0x259702,_0x2630c4)=>{const _0xd12941=a0_0xecb8,_0x2b19ee=_0x2108c4[_0x259702]['config']?.[_0xd12941(0x249)]?.['subject'];let _0x438d33=0x0;for await(const _0xc86bee of _0x2630c4[_0xd12941(0x21d)]()){switch(_0xc86bee['type']){case _0xd12941(0x286):_0x360a2e[_0xd12941(0x228)]['error'](_0x360a2e[_0xd12941(0x2d2)]+'['+_0x360a2e['pluginName']+_0xd12941(0x2f9)+_0x259702+']['+_0x2b19ee+_0xd12941(0x1df)+_0xc86bee[_0xd12941(0x1f6)]+'\x20-\x20will\x20do\x20auto\x20reconnect\x20when\x20connection\x20becomes\x20available'),_0x438d33=0x0;break;case'reconnect':_0x360a2e[_0xd12941(0x228)][_0xd12941(0x273)](_0x360a2e[_0xd12941(0x2d2)]+'['+_0x360a2e[_0xd12941(0x23c)]+_0xd12941(0x2f9)+_0x259702+']['+_0x2b19ee+']\x20client\x20reconnected\x20'+_0xc86bee[_0xd12941(0x1f6)]);break;case _0xd12941(0x24e):_0x360a2e[_0xd12941(0x228)][_0xd12941(0x24e)](_0x360a2e[_0xd12941(0x2d2)]+'['+_0x360a2e['pluginName']+_0xd12941(0x2f9)+_0x259702+']['+_0x2b19ee+']\x20client\x20error\x20'+_0xc86bee[_0xd12941(0x1f6)]);break;case _0xd12941(0x278):_0x438d33+=0x1;_0x438d33%0x1e===0x0&&_0x360a2e['logger']['debug'](_0x360a2e[_0xd12941(0x2d2)]+'['+_0x360a2e[_0xd12941(0x23c)]+_0xd12941(0x2f9)+_0x259702+']['+_0x2b19ee+_0xd12941(0x1ff)+_0xc86bee['data']+'\x20(count='+_0x438d33+')');break;case'staleConnection':_0x360a2e[_0xd12941(0x228)][_0xd12941(0x299)](_0x360a2e[_0xd12941(0x2d2)]+'['+_0x360a2e[_0xd12941(0x23c)]+']\x20publisher['+_0x259702+']['+_0x2b19ee+_0xd12941(0x2a8)+_0xc86bee[_0xd12941(0x1f6)]);break;}}},_0x75ee59=async(_0x36170d,_0x2846ca)=>{const _0x23301d=a0_0xecb8,_0x43e123=_0x2108c4[_0x36170d][_0x23301d(0x215)]?.['nats']?.[_0x23301d(0x2db)];let _0x1c94b8;try{_0x1c94b8=await a0_0x378352(_0x2846ca);if(_0x1c94b8['info'][_0x23301d(0x1f0)]!==_0x23301d(0x288)){_0x1c94b8['close']();return;}_0x2108c4[_0x36170d]['nc']=_0x1c94b8,_0xd1b037(_0x36170d,_0x1c94b8);}catch(_0x9710f9){_0x360a2e[_0x23301d(0x228)][_0x23301d(0x24e)](_0x360a2e[_0x23301d(0x2d2)]+'['+_0x360a2e[_0x23301d(0x23c)]+_0x23301d(0x2f9)+_0x36170d+']['+_0x43e123+_0x23301d(0x2dd)+_0x9710f9[_0x23301d(0x1de)]+_0x23301d(0x1e3)),_0x2846ca['waitOnFirstConnect']=!![];try{_0x1c94b8=await a0_0x378352(_0x2846ca);if(_0x1c94b8['info'][_0x23301d(0x1f0)]!==_0x23301d(0x288)){_0x1c94b8['close']();return;}_0x2108c4[_0x36170d]['nc']=_0x1c94b8,_0xd1b037(_0x36170d,_0x1c94b8);}catch(_0x2a65fc){_0x360a2e['logger'][_0x23301d(0x24e)](_0x360a2e[_0x23301d(0x2d2)]+'['+_0x360a2e[_0x23301d(0x23c)]+_0x23301d(0x2f9)+_0x36170d+']['+_0x43e123+_0x23301d(0x2dd)+_0x2a65fc[_0x23301d(0x1de)]);return;}}_0x360a2e['logger'][_0x23301d(0x299)](_0x360a2e[_0x23301d(0x2d2)]+'['+_0x360a2e[_0x23301d(0x23c)]+_0x23301d(0x2f9)+_0x36170d+']['+_0x43e123+']\x20connected\x20'+(_0x2846ca[_0x23301d(0x204)]['ca']?_0x23301d(0x204):'')+'\x20'+_0x1c94b8[_0x23301d(0x231)]()),_0x1c94b8[_0x23301d(0x240)]()[_0x23301d(0x2d8)](_0x3dcd80=>{const _0x2b5f22=_0x23301d;_0x3dcd80&&_0x360a2e['logger'][_0x2b5f22(0x24e)](_0x360a2e[_0x2b5f22(0x2d2)]+'['+_0x360a2e[_0x2b5f22(0x23c)]+_0x2b5f22(0x2f9)+_0x36170d+']['+_0x43e123+_0x2b5f22(0x1fd)+_0x3dcd80[_0x2b5f22(0x1de)]);});};this['add']=async(_0x5c6882,_0xde7e6b)=>{const _0x18c783=a0_0xecb8;if(!_0xde7e6b?.[_0x18c783(0x249)]){_0x360a2e[_0x18c783(0x228)]['error'](_0x360a2e['gwName']+'['+_0x360a2e[_0x18c783(0x23c)]+_0x18c783(0x2f9)+_0x5c6882+_0x18c783(0x1ed));return;}if(!_0xde7e6b?.[_0x18c783(0x249)]?.[_0x18c783(0x23d)]){_0x360a2e[_0x18c783(0x228)][_0x18c783(0x24e)](_0x360a2e[_0x18c783(0x2d2)]+'['+_0x360a2e[_0x18c783(0x23c)]+_0x18c783(0x2f9)+_0x5c6882+']\x20initialization\x20error:\x20missing\x20configuration\x20nats.tenant');return;}if(!_0xde7e6b?.[_0x18c783(0x249)]?.[_0x18c783(0x2db)]){_0x360a2e[_0x18c783(0x228)][_0x18c783(0x24e)](_0x360a2e[_0x18c783(0x2d2)]+'['+_0x360a2e[_0x18c783(0x23c)]+']\x20publisher['+_0x5c6882+_0x18c783(0x22d));return;}if(!_0xde7e6b?.[_0x18c783(0x249)]?.[_0x18c783(0x2db)][_0x18c783(0x2a2)]('GW.')){_0x360a2e['logger'][_0x18c783(0x24e)](_0x360a2e[_0x18c783(0x2d2)]+'['+_0x360a2e[_0x18c783(0x23c)]+_0x18c783(0x2f9)+_0x5c6882+_0x18c783(0x279));return;}if(!_0xde7e6b[_0x18c783(0x2f8)]||!Array['isArray'](_0xde7e6b[_0x18c783(0x2f8)])||_0xde7e6b[_0x18c783(0x2f8)][_0x18c783(0x269)]<0x1){_0x360a2e[_0x18c783(0x228)]['error'](_0x360a2e['gwName']+'['+_0x360a2e['pluginName']+_0x18c783(0x2f9)+_0x5c6882+_0x18c783(0x22b));return;}if(!_0xde7e6b?.['certificate']?.['ca']){_0x360a2e[_0x18c783(0x228)]['error'](_0x360a2e['gwName']+'['+_0x360a2e[_0x18c783(0x23c)]+_0x18c783(0x2f9)+_0x5c6882+']\x20initialization\x20error:\x20missing\x20certificate\x20configuration');return;}const _0x112533={};try{let _0xe40604=a0_0x2546bd[_0x18c783(0x256)](_0x360a2e[_0x18c783(0x211)],_0x18c783(0x27c),_0xde7e6b?.[_0x18c783(0x1dd)]?.['ca']||'file-not-configured');(_0xde7e6b?.[_0x18c783(0x1dd)]?.['ca']?.['startsWith']('/')||_0xde7e6b?.[_0x18c783(0x1dd)]?.['ca']?.['includes']('\x5c'))&&(_0xe40604=_0xde7e6b[_0x18c783(0x1dd)]['ca']),_0x112533['ca']=[a0_0x7dda52[_0x18c783(0x234)](_0xe40604)],_0x112533[_0x18c783(0x244)]=!![];}catch(_0x8965c8){_0x360a2e['logger'][_0x18c783(0x24e)](_0x360a2e[_0x18c783(0x2d2)]+'['+_0x360a2e['pluginName']+']\x20publisher['+_0x5c6882+']\x20initialization\x20certificate\x20error:\x20'+_0x8965c8[_0x18c783(0x1de)]);return;}const _0x490b62={},_0x160b25=new TextEncoder()[_0x18c783(0x210)](_0xde7e6b?.['nats']?.[_0x18c783(0x289)]),_0x23dcf7=_0xde7e6b?.[_0x18c783(0x249)]?.[_0x18c783(0x26f)];_0x490b62[_0x18c783(0x1d5)]=jwtAuthenticator(_0x23dcf7,_0x160b25),_0x490b62[_0x18c783(0x1d1)]=_0xde7e6b['baseUrls'],_0x490b62['tls']=_0x112533,_0x490b62[_0x18c783(0x230)]=![],_0x490b62[_0x18c783(0x263)]=!![],_0x490b62[_0x18c783(0x218)]=0x3e8*0xa,_0x490b62['maxReconnectAttempts']=-0x1,_0x490b62[_0x18c783(0x221)]=0x2*0x3c*0x3e8,_0x490b62[_0x18c783(0x293)]=0x5,_0x490b62[_0x18c783(0x299)]=![],_0x2108c4[_0x5c6882]={},_0x2108c4[_0x5c6882]['config']=_0xde7e6b,_0x2108c4[_0x5c6882]['nc']=undefined,_0x75ee59(_0x5c6882,_0x490b62);},this[_0x1f62f9(0x241)]=async _0x8b9869=>{const _0x542f14=_0x1f62f9;let _0x3e2f2e;const _0x2e9f9b=a0_0x368ba7[_0x542f14(0x2b3)]();try{if(_0x8b9869[_0x542f14(0x2c2)]===Object){_0x3e2f2e=_0x8b9869[_0x542f14(0x2a0)];if(!_0x3e2f2e)_0x8b9869['baseEntity']='undefined';if(_0x8b9869?.[_0x542f14(0x298)]?.[_0x542f14(0x2ed)]?.[_0x542f14(0x246)]){const _0x570f0d=_0x8b9869[_0x542f14(0x298)][_0x542f14(0x2ed)][_0x542f14(0x246)][_0x542f14(0x2f6)](_0x542f14(0x1d4));if(_0x570f0d)_0x8b9869[_0x542f14(0x298)][_0x542f14(0x2ed)][_0x542f14(0x246)][_0x542f14(0x1d0)]('authorization',a0_0x3465c4[_0x542f14(0x1e0)](_0x570f0d,_0x2e9f9b));}if(_0x8b9869?.[_0x542f14(0x298)]?.[_0x542f14(0x29f)]?.['headers']){const _0x59b1b9=_0x8b9869[_0x542f14(0x298)][_0x542f14(0x29f)]['headers'][_0x542f14(0x2f6)](_0x542f14(0x1d4));if(_0x59b1b9)_0x8b9869[_0x542f14(0x298)][_0x542f14(0x29f)]['headers'][_0x542f14(0x1d0)](_0x542f14(0x1d4),a0_0x3465c4[_0x542f14(0x1e0)](_0x59b1b9,_0x2e9f9b));}_0x8b9869=JSON[_0x542f14(0x22a)](_0x8b9869);}else{const _0x1d4b6f=JSON['parse'](_0x8b9869);_0x3e2f2e=_0x1d4b6f['baseEntity'];}}catch(_0x2ba630){throw new Error('publisher['+_0x3e2f2e+_0x542f14(0x2da));}if(!_0x2108c4[_0x3e2f2e])throw new Error(_0x542f14(0x1fb)+_0x3e2f2e+_0x542f14(0x2b6)+_0x3e2f2e);const _0x18bd50=headers();_0x18bd50[_0x542f14(0x2c4)]('Msg-Id',_0x2e9f9b);let _0x39525e;try{if(!_0x2108c4[_0x3e2f2e]['nc'])throw new Error('publisher\x20not\x20initialized/connected');_0x39525e=await _0x2108c4[_0x3e2f2e]['nc'][_0x542f14(0x2ed)](_0x2108c4[_0x3e2f2e][_0x542f14(0x215)]?.[_0x542f14(0x249)]?.['subject'],_0x8b9869,{'headers':_0x18bd50});}catch(_0x21ce1a){if(_0x21ce1a[_0x542f14(0x1de)]===_0x542f14(0x20c))throw new Error(_0x542f14(0x1fb)+_0x3e2f2e+_0x542f14(0x280)+_0x2108c4[_0x3e2f2e][_0x542f14(0x215)]?.[_0x542f14(0x249)]?.[_0x542f14(0x2db)]);else throw new Error(_0x542f14(0x1fb)+_0x3e2f2e+_0x542f14(0x270)+_0x21ce1a[_0x542f14(0x1de)]);}let _0x4411ea;try{_0x4411ea=JSON[_0x542f14(0x266)](_0x39525e[_0x542f14(0x2c7)]());try{JSON[_0x542f14(0x266)](_0x4411ea['body']);if(!_0x4411ea[_0x542f14(0x246)])_0x4411ea[_0x542f14(0x246)]={};if(!_0x4411ea[_0x542f14(0x246)][_0x542f14(0x268)])_0x4411ea[_0x542f14(0x246)][_0x542f14(0x268)]=_0x542f14(0x2ec);}catch(_0x6abcbe){void 0x0;}}catch(_0x224454){throw new Error(_0x542f14(0x2a5)+_0x39525e['string']());}if(_0x4411ea?.['error']){const _0x60fd35=new Error(_0x542f14(0x2e6)+_0x4411ea[_0x542f14(0x24e)]);_0x60fd35[_0x542f14(0x2bd)]=_0x4411ea[_0x542f14(0x271)];throw _0x60fd35;}return _0x4411ea;},process['on'](_0x1f62f9(0x224),async()=>{const _0x298a46=_0x1f62f9;for(const _0x15f8be in _0x2108c4){_0x2108c4[_0x15f8be]['nc']&&!_0x2108c4[_0x15f8be]['nc'][_0x298a46(0x2de)]()&&await _0x2108c4[_0x15f8be]['nc']['drain']();}}),process['on'](_0x1f62f9(0x2cc),async()=>{const _0xbec881=_0x1f62f9;for(const _0x1c2d0a in _0x2108c4){_0x2108c4[_0x1c2d0a]['nc']&&!_0x2108c4[_0x1c2d0a]['nc']['isClosed']()&&await _0x2108c4[_0x1c2d0a]['nc'][_0xbec881(0x2d5)]();}});}}export const getAppRoles=async(_0x2c91c8,_0x2b75c9)=>{const _0x481764=a0_0xecb8,_0x43ce77=_0x481764(0x29d),_0x4706d1=_0x2c91c8;_0x4706d1[_0x481764(0x228)][_0x481764(0x299)](_0x4706d1[_0x481764(0x2d2)]+'['+_0x4706d1[_0x481764(0x23c)]+']\x20handling\x20\x22'+_0x43ce77+'\x22');try{if(!a0_0x7dda52[_0x481764(0x2bc)](_0x4706d1['configDir']+_0x481764(0x1e6)))a0_0x7dda52[_0x481764(0x28b)](_0x4706d1[_0x481764(0x211)]+_0x481764(0x1e6));}catch(_0x380770){void 0x0;}const _0x20d21b=a0_0x2546bd['join'](''+_0x4706d1[_0x481764(0x211)],'approles','approles_'+_0x4706d1['pluginName']+_0x481764(0x226)),_0x56026b={};a0_0x3465c4[_0x481764(0x239)](_0x20d21b)&&a0_0x7dda52[_0x481764(0x234)](_0x20d21b,_0x481764(0x267))[_0x481764(0x2b7)](/\r?\n/)[_0x481764(0x2c5)](_0x5ec679=>{const _0x12cf8c=_0x481764,_0x22e2f6=_0x5ec679['split']('\x20');_0x22e2f6[_0x12cf8c(0x269)]===0x2&&(_0x56026b[_0x22e2f6[0x0]]=_0x22e2f6[0x1]);});const _0x5b5ac8=a0_0x7dda52[_0x481764(0x1da)](_0x20d21b,{'flags':'w','encoding':_0x481764(0x262),'mode':0x1b6,'autoClose':!![]}),_0x2c3a51=[],_0x4f837c=await _0x4706d1[_0x481764(0x233)](_0x2b75c9,{'attribute':undefined,'operator':undefined,'value':undefined},['id',_0x481764(0x2d6)]);return _0x4f837c['Resources']['forEach'](_0x1b1688=>{const _0x51a774=_0x481764;if(_0x1b1688['id']){let _0x2a31a7=a0_0x368ba7[_0x51a774(0x2b3)]();if(_0x56026b[_0x1b1688['id']])_0x2a31a7=_0x56026b[_0x1b1688['id']];const _0x59b5e1={'allowedMemberTypes':['User'],'description':_0x51a774(0x28c),'displayName':_0x1b1688[_0x51a774(0x2d6)]||_0x1b1688['id'],'id':_0x2a31a7,'isEnabled':!![],'lang':null,'origin':_0x51a774(0x223),'value':decodeURIComponent(_0x1b1688['id'])};_0x2c3a51['push'](_0x59b5e1),_0x5b5ac8[_0x51a774(0x236)](_0x1b1688['id']+'\x20'+_0x2a31a7+'\x0a');}}),_0x5b5ac8['close'](),_0x4706d1[_0x481764(0x228)][_0x481764(0x299)](_0x4706d1['gwName']+'['+_0x4706d1[_0x481764(0x23c)]+_0x481764(0x276)+_0x20d21b),{'Resources':[{'appRoles':_0x2c3a51}]};};
@@ -34,7 +34,6 @@ export class ScimGateway {
34
34
  private scimDef: any
35
35
  private countries: any
36
36
  private multiValueTypes: any
37
- private replaceUsrGrp: any
38
37
  private getMemberOf: any
39
38
  private getAppRoles: any
40
39
  private pub: any
@@ -1716,7 +1715,7 @@ export class ScimGateway {
1716
1715
  }
1717
1716
  }
1718
1717
  } // replaceUsrGrp
1719
- this.replaceUsrGrp = replaceUsrGrp
1718
+ funcHandler.replaceUsrGrp = replaceUsrGrp
1720
1719
 
1721
1720
  const putHandler = async (ctx: Context) => {
1722
1721
  const handle = ctx.routeObj.handle // Users/Groups
@@ -2873,7 +2872,9 @@ export class ScimGateway {
2873
2872
 
2874
2873
  const path = `/users/${msgObj.from}/sendMail`
2875
2874
  try {
2876
- await this.helperRest.doRequest('undefined', 'POST', path, emailMessage)
2875
+ if (this.config.scimgateway.email.auth?.options?.certificate?.key && this.config.scimgateway.email.auth?.options?.certificate?.cert) {
2876
+ await this.helperRest.doRequest('undefined', 'POST', path, emailMessage, null, { connection: { auth: { type: 'oauthJwtBearer' } } })
2877
+ } else await this.helperRest.doRequest('undefined', 'POST', path, emailMessage)
2877
2878
  logger.debug(`${gwName}[${pluginName}] sendMail subject '${msgObj.subject}' sent to: ${msgObj.to}${(msgObj.cc) ? ',' + msgObj.cc : ''}`)
2878
2879
  } catch (err: any) {
2879
2880
  logger.error(`${gwName}[${pluginName}] sendMail subject '${msgObj.subject}' sending failed: ${err.message}`)
package/lib/utils.ts CHANGED
@@ -660,3 +660,26 @@ export const formDataMultipartToJSON = function (body?: string, boundary?: strin
660
660
  }
661
661
  return json
662
662
  }
663
+
664
+ /**
665
+ * getBase64CertificateThumbprintconverts return Base64url-encoded SHA thumbprint of the X.509 certificate's DER encoding
666
+ * @param pemCertContent PEM formatted certificate content
667
+ * @param shaVersion sha1 or sha256, default sha1
668
+ * @returns Base64url-encoded SHA thumbprint
669
+ */
670
+ export const getBase64CertificateThumbprint = function (pemCertContent: string, shaVersion: 'sha1' | 'sha256' = 'sha1'): string {
671
+ if (!pemCertContent) return ''
672
+ const certMatch = pemCertContent.match(/-----BEGIN CERTIFICATE-----([\s\S]+?)-----END CERTIFICATE-----/)
673
+ if (!certMatch) return ''
674
+ const certBase64 = certMatch[1].replace(/\s+/g, '') // remove whitespace and newlines
675
+ const certDer = Buffer.from(certBase64, 'base64') // decode the PEM to DER (Base64 decode)
676
+ const hash = crypto.createHash(shaVersion).update(certDer).digest() // compute the SHA-256 hash of the DER
677
+ // thumbprint = hash.toString('hex')
678
+ const base64Url = hash
679
+ .toString('base64') // convert binary hash to standard Base64
680
+ .replace(/\+/g, '-') // replace '+' with '-'
681
+ .replace(/\//g, '_') // replace '/' with '_'
682
+ .replace(/=+$/, '') // remove '=' padding
683
+
684
+ return base64Url
685
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scimgateway",
3
- "version": "5.1.2",
3
+ "version": "5.1.3",
4
4
  "type": "module",
5
5
  "description": "Using SCIM protocol as a gateway for user provisioning to other endpoints",
6
6
  "author": "Jarle Elshaug <jarle.elshaug@gmail.com> (https://elshaug.xyz)",