Skip to content

Commit

Permalink
feat: use msal for AzureAD; ServiceWorker intercept; XML response han…
Browse files Browse the repository at this point in the history
…dling in XHR (#168)
  • Loading branch information
rentallect authored Jul 9, 2023
1 parent 1da7f71 commit 2220489
Show file tree
Hide file tree
Showing 5 changed files with 508 additions and 59 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@
},
"dependencies": {
"@auth0/auth0-spa-js": "^2.0.4",
"@azure/msal-browser": "^2.38.0",
"@babel/runtime": "^7.17.9",
"@openziti/ziti-browzer-core": "^0.24.1",
"@openziti/ziti-browzer-core": "^0.25.0",
"bowser": "^2.11.0",
"cookie-interceptor": "^1.0.0",
"core-js": "^3.22.8",
Expand Down
37 changes: 37 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright NetFoundry, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/


"use strict";

/**
*
*/
const ZBR_CONSTANTS =
{
AUTH0_IDP: 'AUTH0',
AUTH0_URL_REGEX: /auth0\.com/,

AZURE_AD_IDP: 'AZURE_AD',
AZURE_AD_URL_REGEX: /login\.microsoftonline\.com/,
AZURE_AD_SCOPES: ['User.Read', 'openid', 'email'],

};


export {
ZBR_CONSTANTS
};
8 changes: 8 additions & 0 deletions src/http/ziti-xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ function ZitiXMLHttpRequest () {
// console.log(`XHR: responseBodyText=${self.responseBodyText}`);
self.responseText = self.responseBodyText;
self.response = self.responseBodyText;
self.responseXML = self.responseBodyText;

// create the (potential) XML DOM object
try {
let parser = new DOMParser();
self.responseXML = parser.parseFromString(self.responseBodyText, "text/xml");
} catch (e) { /* NOP */ }

self.responseObject = response;
sendFlag = false;
setState(self.DONE);
Expand Down
Loading

0 comments on commit 2220489

Please sign in to comment.