![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@forgerock/javascript-sdk
Advanced tools
The ForgeRock JavaScript SDK is a toolkit that allows web developers to easily integrate intelligent authentication using ForgeRock OpenAM and/or ForgeRock Identity Cloud.
npm install @forgerock/javascript-sdk
In most real-world scenarios, you will want to have full control over the UI. In these cases, you can use FRAuth
to obtain typed callback instances from authentication trees and render the UI in whatever way makes sense for your application.
In the following example, a simple React app iteratively calls FRAuth.next()
until either an error occurs or a session token is obtained. The custom React component <UsernamePassword />
is defined to handle an authentication step named "UsernamePassword".
import { FRAuth, Config } from '@forgerock/javascript-sdk';
import React from 'react';
class App extends React.Component {
constructor(props) {
super(props);
// Initialize application state
this.state = {
error: undefined,
ssoToken: undefined,
step: undefined,
};
}
componentDidMount() {
// Set configuration defaults
Config.set({
clientId: 'my_client_id',
redirectUri: 'https://myapp.domain.com/callback',
scope: 'openid profile me.read',
serverConfig: { baseUrl: 'https://mytenant.forgeblocks.local/am/' },
tree: 'UsernamePassword',
});
// Start the authentication flow
this.nextStep();
}
nextStep = async (step) => {
// Get the next step in this authentication tree
step = await FRAuth.next(step).catch(this.onError);
// Update application state based on the response
let ssoToken, error;
if (step.type === 'LoginSuccess') {
ssoToken = step.getSessionToken();
} else if (step.type === 'LoginFailure') {
error = step.getCode();
}
this.setState({ step, ssoToken, error });
};
onError = (error) => {
this.setState({ error });
};
render() {
// Handle init/success/failure states
if (!this.state.step) {
return <p>Loading...</p>;
} else if (this.state.ssoToken) {
return <p>Authenticated!</p>;
} else if (this.state.error) {
return <p>Error: {this.state.error}</p>;
}
// Otherwise, select the correct component for this step
const stage = this.state.step.getStage();
return (
<>
<h1>Sign In</h1>
{stage === 'UsernamePassword' && (
<UsernamePassword step={this.state.step} onSubmit={this.nextStep} />
)}
{/* Create similar components for other stages */}
</>
);
}
}
// Custom UI for rendering the "UsernamePassword" step
function UsernamePassword(props) {
const setUsername = (e) => {
const cb = props.step.getCallbackOfType('NameCallback');
cb.setName(e.target.value);
};
const setPassword = (e) => {
const cb = props.step.getCallbackOfType('PasswordCallback');
cb.setPassword(e.target.value);
};
const onSubmit = () => {
props.onSubmit(props.step);
};
return (
<>
<input type="text" placeholder="Username" onChange={setUsername} />
<input type="password" placeholder="Password" onChange={setPassword} />
<button onClick={onSubmit}>Submit</button>
</>
);
}
export default App;
Prerequisites:
# Add host
echo '127.0.0.1 forgerock-sdk-samples.com' | sudo tee -a /etc/hosts
# Install dependencies
npm i
# Generate CA and self-signed certificate
# (Pick any passphrase and use it whenever prompted)
npm run make_certs
# Build the SDK and watch for changes
npm start
# Start the sample webserver
npm run samples
# Follow the next section to trust certificate
Access the samples at https://forgerock-sdk-samples.com:3000
Trusting the certificate is required to avoid browser warnings and for WebAuthn to work correctly.
Add the certificate to your keychain:
# MacOS
sudo npm run trust_certs
You must restart Chrome for the change to take effect.
Import the certificate to Firefox:
certs/ca.crt
and enable option to "Trust this CA to identify websites"Preliminary E2E tests are implemented with Puppeteer. They utilize an HTML page that allows configuration of the SDK via querystring parameters at the beginning of each test scenario.
# Start the test web server
npm run e2e_server
# Run test scenarios
npm run e2e_tests
FAQs
ForgeRock JavaScript SDK
The npm package @forgerock/javascript-sdk receives a total of 1,780 weekly downloads. As such, @forgerock/javascript-sdk popularity was classified as popular.
We found that @forgerock/javascript-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.