New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@forgerock/javascript-sdk

Package Overview
Dependencies
Maintainers
10
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forgerock/javascript-sdk - npm Package Compare versions

Comparing version 2.0.0-beta4 to 2.0.0

19

lib-esm/http-client/index.d.ts

@@ -5,2 +5,21 @@ import Dispatcher from '../event';

* HTTP client that includes bearer token injection and refresh.
* This module also supports authorization for policy protected endpoints.
*
* Example:
*
* ```js
* return forgerock.HttpClient.request({
* url: `https://example.com/protected/resource`,
* init: {
* method: 'GET',
* credentials: 'include',
* },
* authorization: {
* handleStep: async (step) => {
* step.getCallbackOfType('PasswordCallback').setPassword(pw);
* return Promise.resolve(step);
* },
* },
* });
* ```
*/

@@ -7,0 +26,0 @@ declare abstract class HttpClient extends Dispatcher {

@@ -63,2 +63,21 @@ var __extends = (this && this.__extends) || (function () {

* HTTP client that includes bearer token injection and refresh.
* This module also supports authorization for policy protected endpoints.
*
* Example:
*
* ```js
* return forgerock.HttpClient.request({
* url: `https://example.com/protected/resource`,
* init: {
* method: 'GET',
* credentials: 'include',
* },
* authorization: {
* handleStep: async (step) => {
* step.getCallbackOfType('PasswordCallback').setPassword(pw);
* return Promise.resolve(step);
* },
* },
* });
* ```
*/

@@ -65,0 +84,0 @@ var HttpClient = /** @class */ (function (_super) {

2

lib-esm/token-storage/index.d.ts
import { Tokens } from '../shared/interfaces';
/**
* Provides access to the token storage API.
* The type of storage (localStorage, sessionStorage, etc) can be configured
* through `tokenStore` object on the SDK configuration.
*/

@@ -5,0 +7,0 @@ declare abstract class TokenStorage {

@@ -43,2 +43,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

* Provides access to the token storage API.
* The type of storage (localStorage, sessionStorage, etc) can be configured
* through `tokenStore` object on the SDK configuration.
*/

@@ -45,0 +47,0 @@ var TokenStorage = /** @class */ (function () {

import { RequestObj } from '../config/interfaces';
import { ActionTypes } from '../config/enums';
/**
* @function middlewareWrapper - A "Node" and "Redux" style middleware that is called just before
* the request is made from the SDK. This allows you access to the request for modification.
* @param request - A request object container the URL and the Request Init object
* @param type - A "Redux" style type that contains the serialized action
* @param payload - The payload of the action that can contain metadata
*/
declare function middlewareWrapper(request: RequestObj, type: ActionTypes, payload?: any): RequestObj;
export default middlewareWrapper;
import Config from '../config';
/**
* @function middlewareWrapper - A "Node" and "Redux" style middleware that is called just before
* the request is made from the SDK. This allows you access to the request for modification.
* @param request - A request object container the URL and the Request Init object
* @param type - A "Redux" style type that contains the serialized action
* @param payload - The payload of the action that can contain metadata
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -3,0 +10,0 @@ function middlewareWrapper(request, type, payload) {

@@ -5,2 +5,21 @@ import Dispatcher from '../event';

* HTTP client that includes bearer token injection and refresh.
* This module also supports authorization for policy protected endpoints.
*
* Example:
*
* ```js
* return forgerock.HttpClient.request({
* url: `https://example.com/protected/resource`,
* init: {
* method: 'GET',
* credentials: 'include',
* },
* authorization: {
* handleStep: async (step) => {
* step.getCallbackOfType('PasswordCallback').setPassword(pw);
* return Promise.resolve(step);
* },
* },
* });
* ```
*/

@@ -7,0 +26,0 @@ declare abstract class HttpClient extends Dispatcher {

@@ -68,2 +68,21 @@ "use strict";

* HTTP client that includes bearer token injection and refresh.
* This module also supports authorization for policy protected endpoints.
*
* Example:
*
* ```js
* return forgerock.HttpClient.request({
* url: `https://example.com/protected/resource`,
* init: {
* method: 'GET',
* credentials: 'include',
* },
* authorization: {
* handleStep: async (step) => {
* step.getCallbackOfType('PasswordCallback').setPassword(pw);
* return Promise.resolve(step);
* },
* },
* });
* ```
*/

@@ -70,0 +89,0 @@ var HttpClient = /** @class */ (function (_super) {

import { Tokens } from '../shared/interfaces';
/**
* Provides access to the token storage API.
* The type of storage (localStorage, sessionStorage, etc) can be configured
* through `tokenStore` object on the SDK configuration.
*/

@@ -5,0 +7,0 @@ declare abstract class TokenStorage {

@@ -48,2 +48,4 @@ "use strict";

* Provides access to the token storage API.
* The type of storage (localStorage, sessionStorage, etc) can be configured
* through `tokenStore` object on the SDK configuration.
*/

@@ -50,0 +52,0 @@ var TokenStorage = /** @class */ (function () {

import { RequestObj } from '../config/interfaces';
import { ActionTypes } from '../config/enums';
/**
* @function middlewareWrapper - A "Node" and "Redux" style middleware that is called just before
* the request is made from the SDK. This allows you access to the request for modification.
* @param request - A request object container the URL and the Request Init object
* @param type - A "Redux" style type that contains the serialized action
* @param payload - The payload of the action that can contain metadata
*/
declare function middlewareWrapper(request: RequestObj, type: ActionTypes, payload?: any): RequestObj;
export default middlewareWrapper;

@@ -7,2 +7,9 @@ "use strict";

var config_1 = __importDefault(require("../config"));
/**
* @function middlewareWrapper - A "Node" and "Redux" style middleware that is called just before
* the request is made from the SDK. This allows you access to the request for modification.
* @param request - A request object container the URL and the Request Init object
* @param type - A "Redux" style type that contains the serialized action
* @param payload - The payload of the action that can contain metadata
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -9,0 +16,0 @@ function middlewareWrapper(request, type, payload) {

14

package.json
{
"name": "@forgerock/javascript-sdk",
"version": "2.0.0-beta4",
"version": "2.0.0",
"description": "ForgeRock JavaScript SDK",

@@ -17,3 +17,3 @@ "main": "./lib/",

"clean": "shx rm -rf bundles docs lib lib-esm coverage",
"clean:all": "npm run clean && shx rm -rf node_modules package-lock.json && git clean -fX --exclude='!.env'",
"clean:all": "npm run clean && shx rm -rf node_modules package-lock.json && git clean -fX",
"certs:make": "sh ./bin/create_certs.sh",

@@ -33,7 +33,7 @@ "certs:trust": "npm run certs:trust:ca && npm run certs:trust:sample",

"test": "npm run test:unit && npm run test:integration && npm run test:e2e",
"test:coverage": "jest --testMatch='<rootDir>/src/**/*.test.ts' --config=./tests/basic.config.js --coverage=true",
"test:e2e": "jest --testMatch='<rootDir>/tests/e2e/**/*.test.ts' --config=./tests/e2e.config.js",
"test:e2e:live": "OAUTH_SERVER=live jest --testMatch='<rootDir>/tests/e2e/**/*.test.ts' --config=./tests/e2e.config.js",
"test:integration": "jest --testMatch='<rootDir>/tests/integration/**/*.test.ts' --config=./tests/basic.config.js",
"test:unit": "jest --testMatch='<rootDir>/src/**/*.test.ts' --config=./tests/basic.config.js --env=./tests/test-env.js",
"test:coverage": "jest --testMatch='<rootDir>/src/**/*.test.ts' --config=./tests/jest.basic.config.js --coverage=true",
"test:e2e": "jest --testMatch='<rootDir>/tests/e2e/**/*.test.ts' --config=./tests/jest.e2e.config.js",
"test:e2e:live": "OAUTH_SERVER=live jest --testMatch='<rootDir>/tests/e2e/**/*.test.ts' --config=./tests/jest.e2e.config.js",
"test:integration": "jest --testMatch='<rootDir>/tests/integration/**/*.test.ts' --config=./tests/jest.basic.config.js",
"test:unit": "jest --testMatch='<rootDir>/src/**/*.test.ts' --config=./tests/jest.basic.config.js --env=./tests/jest.env.config.js",
"watch": "webpack -w --env.DEV=yes"

@@ -40,0 +40,0 @@ },

@@ -117,3 +117,3 @@ # ForgeRock JavaScript SDK

## Samples
## Included Sample App

@@ -123,3 +123,3 @@ Prerequisites:

- [OpenSSL](https://www.openssl.org/) is installed
- **samples/js/config.js** is updated to specify your SDK configuration
- The SDK configuration is updated within **samples/custom-ui/index.html** to specify your AM settings

@@ -133,6 +133,2 @@ ```bash

# Generate CA and self-signed certificate
# (Pick any passphrase and use it whenever prompted)
npm run certs:make
# Build the SDK and watch for changes

@@ -170,3 +166,3 @@ npm run watch

1. On the **Authorities** tab, click **Import...**
1. Select `certs/ca.crt` and enable option to "Trust this CA to identify websites"
1. Select `test/certs/ca.crt` and enable option to "Trust this CA to identify websites"
1. Restart Firefox

@@ -182,14 +178,38 @@

Testing against a live environment requires an OpenAM instance with a public OAuth client configured. Specify your environment details in an `.env` file:
To run the end-to-end tests, you'll need to add a few more domains to your host file:
| Variable | Purpose |
| ----------- | ------------------------------------------------------ |
| `AM_URL` | Full URL to your OpenAM instance |
| `BASE_URL` | Base URL for your application |
| `CLIENT_ID` | Your OAuth client ID |
| `SCOPE` | The scopes to request when getting access tokens |
| `TREE` | The authentication tree name to use for authentication |
| `USERNAME` | The username to use when authenticating |
| `PASSWORD` | The password to use when authenticating |
```bash
# For end-to-end testing this code base, these domains also need to be added
echo '127.0.0.1 auth.example.com api.example.com' | sudo tee -a /etc/hosts
```
### Environment Configuration
| Variable | Purpose |
| ------------ | ------------------------------------------------------ |
| `AM_URL` | Full URL to your OpenAM instance |
| `BASE_URL` | Base URL for your application |
| `CLIENT_ID` | Your OAuth client ID |
| `REALM_PATH` | The realm in which trees, users, OAuth clients reside |
| `SCOPE` | The scopes to request when getting access tokens |
| `TREE` | The authentication tree name to use for authentication |
| `USERNAME` | The username to use when authenticating |
| `PASSWORD` | The password to use when authenticating |
Running E2E tests require a running server (or "backend") for the necessary request/response relationship. Configuration of the server is done within `env.config.ts` file within the `tests/e2e/` directory. The default shown below runs the tests against a mock server:
```js
export const AM_URL = 'https://auth.example.com:9443/am';
export const BASE_URL = 'https://sdkapp.example.com:8443';
export const CLIENT_ID = 'WebOAuthClient';
export const PASSWORD = 'ieH034K&-zlwqh3V_';
export const REALM_PATH = 'root';
export const RESOURCE_URL = 'https://api.example.com:9443/account';
export const SCOPE = 'openid profile me.read';
export const TREE = 'BasicLogin';
export const USERNAME = '57a5b4e4-6999-4b45-bf86-a4f2e5d4b629';
```
If you prefer to test against a live environment, you will need to configure the `.env` file to use your OpenAM instance and its public OAuth client.
### Troubleshooting

@@ -199,3 +219,3 @@

This occurs when OpenAM returns the authorization code, but the `redirect_uri` doesn't match what's configured for the OAuth client. Tests use a path of `/callback`, so your OAuth client should be configured with a `redirect_uri` of `{BASE_URL}/callback` (e.g. https://sdkapp.example.com:8443/callback).
This occurs when OpenAM returns the authorization code, but the `redirect_uri` doesn't match what's configured for the OAuth client. Tests use a path of `/callback`, so your OAuth client should be configured with a `redirect_uri` of `{BASE_URL}/callback` (e.g. https://sdkapp.example.com:8443/_callback).

@@ -202,0 +222,0 @@ ## Version History

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc