@pyramid-embed/embed-react
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -1,2 +0,2 @@ | ||
import { Component, RefObject } from 'react'; | ||
import React, { Component, RefObject } from 'react'; | ||
import { EmbedContentOptions, PyramidEmbedClient } from '@pyramid-embed/embed-js'; | ||
@@ -12,3 +12,3 @@ import { EmbedContainerProps } from '../internal-types'; | ||
componentDidUpdate(): void; | ||
render(): JSX.Element; | ||
render(): React.JSX.Element; | ||
init(): Promise<void>; | ||
@@ -15,0 +15,0 @@ embed(): void; |
@@ -1,43 +0,25 @@ | ||
import { __awaiter, __extends, __generator } from "tslib"; | ||
import React, { Component } from 'react'; | ||
import { initializeAPI } from '../embed-utils'; | ||
var PyramidEmbedContainer = /** @class */ (function (_super) { | ||
__extends(PyramidEmbedContainer, _super); | ||
function PyramidEmbedContainer() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.element = React.createRef(); | ||
return _this; | ||
export class PyramidEmbedContainer extends Component { | ||
constructor() { | ||
super(...arguments); | ||
this.element = React.createRef(); | ||
} | ||
PyramidEmbedContainer.prototype.componentDidMount = function () { | ||
componentDidMount() { | ||
this.init(); | ||
}; | ||
PyramidEmbedContainer.prototype.componentDidUpdate = function () { | ||
} | ||
componentDidUpdate() { | ||
this.embed(); | ||
}; | ||
PyramidEmbedContainer.prototype.render = function () { | ||
} | ||
render() { | ||
return React.createElement("div", { ref: this.element, style: this.props.style, className: this.props.className }); | ||
}; | ||
PyramidEmbedContainer.prototype.init = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var host, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
host = this.props.host; | ||
_a = this; | ||
return [4 /*yield*/, initializeAPI(host, this.props)]; | ||
case 1: | ||
_a.api = _b.sent(); | ||
this.embed(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
PyramidEmbedContainer.prototype.embed = function () { | ||
} | ||
async init() { | ||
const { host } = this.props; | ||
this.api = await initializeAPI(host, this.props); | ||
this.embed(); | ||
} | ||
embed() { | ||
this.api.embed(this.element.current, this.props.options); | ||
}; | ||
return PyramidEmbedContainer; | ||
}(Component)); | ||
export { PyramidEmbedContainer }; | ||
//# sourceMappingURL=pyramid-embed-container.js.map | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Component, RefObject } from 'react'; | ||
import React, { Component, RefObject } from 'react'; | ||
import { EmbedHubOptions, PyramidEmbedClient } from '@pyramid-embed/embed-js'; | ||
@@ -12,3 +12,3 @@ import { EmbedContainerProps } from '../internal-types'; | ||
componentDidUpdate(): void; | ||
render(): JSX.Element; | ||
render(): React.JSX.Element; | ||
init(): Promise<void>; | ||
@@ -15,0 +15,0 @@ embed(): void; |
@@ -1,43 +0,25 @@ | ||
import { __awaiter, __extends, __generator } from "tslib"; | ||
import React, { Component } from 'react'; | ||
import { initializeAPI } from '../embed-utils'; | ||
var PyramidHubEmbedContainer = /** @class */ (function (_super) { | ||
__extends(PyramidHubEmbedContainer, _super); | ||
function PyramidHubEmbedContainer() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.element = React.createRef(); | ||
return _this; | ||
export class PyramidHubEmbedContainer extends Component { | ||
constructor() { | ||
super(...arguments); | ||
this.element = React.createRef(); | ||
} | ||
PyramidHubEmbedContainer.prototype.componentDidMount = function () { | ||
componentDidMount() { | ||
this.init(); | ||
}; | ||
PyramidHubEmbedContainer.prototype.componentDidUpdate = function () { | ||
} | ||
componentDidUpdate() { | ||
this.embed(); | ||
}; | ||
PyramidHubEmbedContainer.prototype.render = function () { | ||
} | ||
render() { | ||
return React.createElement("div", { ref: this.element, style: this.props.style, className: this.props.className }); | ||
}; | ||
PyramidHubEmbedContainer.prototype.init = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var host, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
host = this.props.host; | ||
_a = this; | ||
return [4 /*yield*/, initializeAPI(host, this.props)]; | ||
case 1: | ||
_a.api = _b.sent(); | ||
this.embed(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
PyramidHubEmbedContainer.prototype.embed = function () { | ||
} | ||
async init() { | ||
const { host } = this.props; | ||
this.api = await initializeAPI(host, this.props); | ||
this.embed(); | ||
} | ||
embed() { | ||
this.api.hub(this.element.current, this.props.options); | ||
}; | ||
return PyramidHubEmbedContainer; | ||
}(Component)); | ||
export { PyramidHubEmbedContainer }; | ||
//# sourceMappingURL=pyramid-hub-embed-container.js.map | ||
} | ||
} |
@@ -1,59 +0,40 @@ | ||
import { __assign, __awaiter, __generator } from "tslib"; | ||
import { PyramidEmbedClient } from '@pyramid-embed/embed-js'; | ||
export function initializeAPI(host, loginData) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var api; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
api = new PyramidEmbedClient(host); | ||
if (loginData.authFailureCallback) { | ||
api.setAuthFailureCallback(loginData.authFailureCallback); | ||
} | ||
if (!!api.isLoggedIn) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, authenticate(api, loginData)]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: return [4 /*yield*/, api.init()]; | ||
case 3: | ||
_a.sent(); | ||
return [2 /*return*/, api]; | ||
} | ||
}); | ||
}); | ||
export async function initializeAPI(host, loginData) { | ||
const api = new PyramidEmbedClient(host); | ||
if (loginData.authFailureCallback) { | ||
api.setAuthFailureCallback(loginData.authFailureCallback); | ||
} | ||
if (!api.isLoggedIn) { | ||
await authenticate(api, loginData); | ||
} | ||
await api.init(); | ||
return api; | ||
} | ||
function authenticate(api, loginData) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var preparedLoginData, loginType, userName, password; | ||
return __generator(this, function (_a) { | ||
preparedLoginData = prepareLoginData(loginData); | ||
loginType = preparedLoginData.loginType; | ||
if (loginType === 'forms') { | ||
userName = preparedLoginData.userName, password = preparedLoginData.password; | ||
return [2 /*return*/, api.login(userName, password)]; | ||
} | ||
else if (loginType === 'windows') { | ||
return [2 /*return*/, api.loginWindowsAuth()]; | ||
} | ||
else if (loginType === 'saml') { | ||
return [2 /*return*/, api.loginSamlAuth(preparedLoginData.samlToken)]; | ||
} | ||
else if (loginType === 'openid') { | ||
return [2 /*return*/, api.loginOpenIdAuth(preparedLoginData.openIdToken)]; | ||
} | ||
else if (preparedLoginData.authToken) { | ||
api.setAuthToken(preparedLoginData.authToken); | ||
return [2 /*return*/, preparedLoginData.authToken]; | ||
} | ||
return [2 /*return*/, undefined]; | ||
}); | ||
}); | ||
async function authenticate(api, loginData) { | ||
const preparedLoginData = prepareLoginData(loginData); | ||
const { loginType } = preparedLoginData; | ||
if (loginType === 'forms') { | ||
const { userName, password } = preparedLoginData; | ||
return api.login(userName, password); | ||
} | ||
else if (loginType === 'windows') { | ||
return api.loginWindowsAuth(); | ||
} | ||
else if (loginType === 'saml') { | ||
return api.loginSamlAuth(preparedLoginData.samlToken); | ||
} | ||
else if (loginType === 'openid') { | ||
return api.loginOpenIdAuth(preparedLoginData.openIdToken); | ||
} | ||
else if (preparedLoginData.authToken) { | ||
api.setAuthToken(preparedLoginData.authToken); | ||
return preparedLoginData.authToken; | ||
} | ||
return undefined; | ||
} | ||
function prepareLoginData(loginData) { | ||
if (!loginData.loginType && loginData.userName && loginData.password) { | ||
return __assign(__assign({}, loginData), { loginType: 'forms' }); | ||
return Object.assign(Object.assign({}, loginData), { loginType: 'forms' }); | ||
} | ||
return loginData.loginType ? loginData : __assign(__assign({}, loginData), { loginType: 'none' }); | ||
return loginData.loginType ? loginData : Object.assign(Object.assign({}, loginData), { loginType: 'none' }); | ||
} | ||
//# sourceMappingURL=embed-utils.js.map |
@@ -5,2 +5,1 @@ export * from './types'; | ||
export * from '@pyramid-embed/embed-js'; | ||
//# sourceMappingURL=index.js.map |
export {}; | ||
//# sourceMappingURL=internal-types.js.map |
export {}; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@pyramid-embed/embed-react", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "tsc", | ||
"build:publish": "tsc && npm version patch && npm publish", | ||
"build:publish:prod": "tsc && npm publish", | ||
"postinstall": "npm prune" | ||
"clean" : "rimraf dist/", | ||
"build": "npm run clean && tsc", | ||
"build:publish": "npm run build && npm version patch && npm publish", | ||
"build:publish:prod": "npm run build && npm publish", | ||
"postinstall": "npm prune", | ||
"build:package": "npm run build && npm pack" | ||
}, | ||
@@ -16,16 +17,15 @@ "author": "Pyramid Analytics", | ||
"dependencies": { | ||
"@pyramid-embed/embed-js": "^3.0.0", | ||
"react": "16.12.0", | ||
"react-dom": "16.12.0", | ||
"tslib": "2.5.0", | ||
"typescript": "5.0.4" | ||
"@pyramid-embed/embed-js": "^4.0.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "16.9.19", | ||
"@types/react-dom": "16.9.5", | ||
"remove-files-webpack-plugin": "1.4.3", | ||
"uglifyjs-webpack-plugin": "2.2.0", | ||
"webpack": "4.43.0", | ||
"webpack-cli": "3.3.12" | ||
"@types/react": ">=16.0.0", | ||
"@types/react-dom": ">=16.0.0", | ||
"rimraf": "^5.0.5", | ||
"typescript": "5.4.2" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.0.0", | ||
"react-dom": ">=16.0.0" | ||
}, | ||
"files": [ | ||
@@ -32,0 +32,0 @@ "dist/**/*" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
4
4
1
11990
20
163
+ Added@pyramid-embed/embed-js@4.0.0(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreact-dom@18.3.1(transitive)
+ Addedscheduler@0.23.2(transitive)
+ Addedtslib@2.8.1(transitive)
- Removedreact@16.12.0
- Removedreact-dom@16.12.0
- Removedtypescript@5.0.4
- Removed@pyramid-embed/embed-js@3.0.1(transitive)
- Removedcore-js@3.20.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@16.12.0(transitive)
- Removedreact-dom@16.12.0(transitive)
- Removedreact-is@16.13.1(transitive)
- Removedscheduler@0.18.0(transitive)
- Removedtslib@2.3.12.5.0(transitive)
- Removedtypescript@5.0.4(transitive)
- Removedwhatwg-fetch@3.0.0(transitive)
Updatedtslib@^2.3.0