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.1 to 2.1.0-rc1

lib-esm/fr-auth/callbacks/suspended-text-output-callback.d.ts

24

CHANGELOG.md
# Changelog
## [unreleased]
### Added
- Support for "usernameless" login (storing username on WebAuthn capable tech)
- Support for the recovery code display node and the parsing of the codes from the TextOutputCallback
- Support for user verification property for WebAuthn
- Updated support for new IDM nodes for registration and self-service
- Added SuspendedTextOutputCallback support for the new Email Suspended Node
### Fixed
- Conditionally set user verification, relying party and allow credentials to WebAuthn key options
- Ensure display name and username are correctly parsed and added to WebAuthn key options
- Add authenticator attachment to WebAuthn and other WebAuthn fixes for custom configuration
- Increased entropy for cryptographic functions related to PKCE for both state and verifier
- Improved instructions for cert creation for sample app
### Deprecated
- Name change for `getAuthorizeUrl`: method's name will change to better reflect its behavior in v3
- Removal of `nonce`: this utility is no longer used in the SDK, and therefor will be removed in v3
- Function signature change for `createVerifier`: the parameter will be removed in v3.
## [2.0.0] - 2020-06-22

@@ -4,0 +28,0 @@

2

lib-esm/auth/enums.d.ts

@@ -22,2 +22,3 @@ /**

NameCallback = "NameCallback",
NumberAttributeInputCallback = "NumberAttributeInputCallback",
PasswordCallback = "PasswordCallback",

@@ -27,2 +28,3 @@ PollingWaitCallback = "PollingWaitCallback",

StringAttributeInputCallback = "StringAttributeInputCallback",
SuspendedTextOutputCallback = "SuspendedTextOutputCallback",
TermsAndConditionsCallback = "TermsAndConditionsCallback",

@@ -29,0 +31,0 @@ TextOutputCallback = "TextOutputCallback",

@@ -24,2 +24,3 @@ /**

CallbackType["NameCallback"] = "NameCallback";
CallbackType["NumberAttributeInputCallback"] = "NumberAttributeInputCallback";
CallbackType["PasswordCallback"] = "PasswordCallback";

@@ -29,2 +30,3 @@ CallbackType["PollingWaitCallback"] = "PollingWaitCallback";

CallbackType["StringAttributeInputCallback"] = "StringAttributeInputCallback";
CallbackType["SuspendedTextOutputCallback"] = "SuspendedTextOutputCallback";
CallbackType["TermsAndConditionsCallback"] = "TermsAndConditionsCallback";

@@ -31,0 +33,0 @@ CallbackType["TextOutputCallback"] = "TextOutputCallback";

12

lib-esm/fr-auth/callbacks/attribute-input-callback.d.ts
import FRCallback from '.';
import { Callback, PolicyRequirement } from '../../auth/interfaces';
import { StringDict } from '../../shared/interfaces';
/**
* Represents a callback used to collect attributes.
*
* @typeparam T Maps to StringAttributeInputCallback and BooleanAttributeInputCallback, respectively
* @typeparam T Maps to StringAttributeInputCallback, NumberAttributeInputCallback and
* BooleanAttributeInputCallback, respectively
*/
declare class AttributeInputCallback<T extends string | boolean> extends FRCallback {
declare class AttributeInputCallback<T extends string | number | boolean> extends FRCallback {
payload: Callback;

@@ -33,4 +35,8 @@ /**

*/
getPolicies(): string[];
getPolicies(): StringDict<any>;
/**
* Set if validating value only.
*/
setValidateOnly(value: boolean): void;
/**
* Sets the attribute's value.

@@ -37,0 +43,0 @@ */

@@ -18,3 +18,4 @@ var __extends = (this && this.__extends) || (function () {

*
* @typeparam T Maps to StringAttributeInputCallback and BooleanAttributeInputCallback, respectively
* @typeparam T Maps to StringAttributeInputCallback, NumberAttributeInputCallback and
* BooleanAttributeInputCallback, respectively
*/

@@ -58,6 +59,14 @@ var AttributeInputCallback = /** @class */ (function (_super) {

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
AttributeInputCallback.prototype.getPolicies = function () {
return this.getOutputByName('policies', []);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.getOutputByName('policies', {});
};
/**
* Set if validating value only.
*/
AttributeInputCallback.prototype.setValidateOnly = function (value) {
this.setInputValue(value, /validateOnly/);
};
/**
* Sets the attribute's value.

@@ -64,0 +73,0 @@ */

@@ -14,2 +14,3 @@ import FRCallback from '.';

import ReCaptchaCallback from './recaptcha-callback';
import SuspendedTextOutputCallback from './suspended-text-output-callback';
import TermsAndConditionsCallback from './terms-and-conditions-callback';

@@ -40,2 +41,4 @@ import TextOutputCallback from './text-output-callback';

return new NameCallback(callback);
case CallbackType.NumberAttributeInputCallback:
return new AttributeInputCallback(callback);
case CallbackType.PasswordCallback:

@@ -49,2 +52,4 @@ return new PasswordCallback(callback);

return new AttributeInputCallback(callback);
case CallbackType.SuspendedTextOutputCallback:
return new SuspendedTextOutputCallback(callback);
case CallbackType.TermsAndConditionsCallback:

@@ -51,0 +56,0 @@ return new TermsAndConditionsCallback(callback);

@@ -28,3 +28,3 @@ import { Callback } from '../../auth/interfaces';

*/
setInputValue(value: unknown, selector?: number | string): void;
setInputValue(value: unknown, selector?: number | string | RegExp): void;
/**

@@ -31,0 +31,0 @@ * Gets the value of the specified output element, or the first element if `selector`

@@ -75,2 +75,10 @@ /**

}
// Duck typing for RegEx
if (typeof selector === 'object' && selector.test && selector.exec) {
var input = array.find(function (x) { return selector.test(x.name); });
if (!input) {
throw new Error("Missing callback input entry \"" + selector + "\"");
}
return input;
}
throw new Error('Invalid selector value type');

@@ -77,0 +85,0 @@ };

import FRCallback from '.';
import { Callback, PolicyRequirement } from '../../auth/interfaces';
import { StringDict } from '../../shared/interfaces';
/**

@@ -19,3 +20,3 @@ * Represents a callback used to collect a valid platform password.

*/
getPolicies(): string[];
getPolicies(): StringDict<any>;
/**

@@ -33,3 +34,7 @@ * Gets the callback's prompt.

setPassword(password: string): void;
/**
* Set if validating value only.
*/
setValidateOnly(value: boolean): void;
}
export default ValidatedCreatePasswordCallback;

@@ -37,4 +37,6 @@ var __extends = (this && this.__extends) || (function () {

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ValidatedCreatePasswordCallback.prototype.getPolicies = function () {
return this.getOutputByName('policies', []);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.getOutputByName('policies', {});
};

@@ -59,2 +61,8 @@ /**

};
/**
* Set if validating value only.
*/
ValidatedCreatePasswordCallback.prototype.setValidateOnly = function (value) {
this.setInputValue(value, /validateOnly/);
};
return ValidatedCreatePasswordCallback;

@@ -61,0 +69,0 @@ }(FRCallback));

import FRCallback from '.';
import { Callback, PolicyRequirement } from '../../auth/interfaces';
import { StringDict } from '../../shared/interfaces';
/**

@@ -23,3 +24,3 @@ * Represents a callback used to collect a valid platform username.

*/
getPolicies(): string[];
getPolicies(): StringDict<any>;
/**

@@ -33,3 +34,7 @@ * Gets whether the username is required.

setName(name: string): void;
/**
* Set if validating value only.
*/
setValidateOnly(value: boolean): void;
}
export default ValidatedCreateUsernameCallback;

@@ -43,4 +43,6 @@ var __extends = (this && this.__extends) || (function () {

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ValidatedCreateUsernameCallback.prototype.getPolicies = function () {
return this.getOutputByName('policies', []);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.getOutputByName('policies', {});
};

@@ -59,2 +61,8 @@ /**

};
/**
* Set if validating value only.
*/
ValidatedCreateUsernameCallback.prototype.setValidateOnly = function (value) {
this.setInputValue(value, /validateOnly/);
};
return ValidatedCreateUsernameCallback;

@@ -61,0 +69,0 @@ }(FRCallback));

@@ -37,3 +37,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import Config from '../config';
import OAuth2Client from '../oauth2-client';
import SessionManager from '../session-manager';
import TokenManager from '../token-manager';

@@ -102,27 +104,29 @@ import UserManager from '../user-manager';

return __awaiter(this, void 0, void 0, function () {
var error_2;
var serverConfig, error_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 4, , 5]);
// TODO: Determine if we're using logout() or endSession(). logout() removes
// the cookie, but fails with CORS issues currently.
// await SessionManager.logout();
return [4 /*yield*/, OAuth2Client.endSession(options)];
serverConfig = Config.get(options).serverConfig;
_a.label = 1;
case 1:
// TODO: Determine if we're using logout() or endSession(). logout() removes
// the cookie, but fails with CORS issues currently.
// await SessionManager.logout();
_a.trys.push([1, 7, , 8]);
if (!!serverConfig.baseUrl.includes('forgeblocks.com')) return [3 /*break*/, 3];
return [4 /*yield*/, SessionManager.logout()];
case 2:
_a.sent();
_a.label = 3;
case 3: return [4 /*yield*/, OAuth2Client.endSession(options)];
case 4:
_a.sent();
return [4 /*yield*/, OAuth2Client.revokeToken(options)];
case 2:
case 5:
_a.sent();
return [4 /*yield*/, TokenManager.deleteTokens()];
case 3:
case 6:
_a.sent();
return [3 /*break*/, 5];
case 4:
return [3 /*break*/, 8];
case 7:
error_2 = _a.sent();
throw new Error('Logout failed');
case 5: return [2 /*return*/];
case 8: return [2 /*return*/];
}

@@ -129,0 +133,0 @@ });

@@ -1,4 +0,9 @@

import { ParsedCredential, ResponseCredential } from './interfaces';
/**
* @module
* @ignore
* These are private utility functions for HttpClient
*/
import { ParsedCredential } from './interfaces';
declare function ensureArray(arr: RegExpMatchArray | null): string[];
declare function getClientDataJson(credential: ResponseCredential): string;
declare function arrayBufferToString(arrayBuffer: ArrayBuffer): string;
declare function getIndexOne(arr: RegExpMatchArray | null): string;

@@ -17,2 +22,2 @@ declare function parseCredentials(value: string): ParsedCredential[];

declare function parseRelyingPartyId(relyingPartyId: string): string;
export { ensureArray, getClientDataJson, getIndexOne, parseCredentials, parseNumberArray, parseAllowCredentialsArray, parsePubKeyArray, parseRelyingPartyId, };
export { ensureArray, arrayBufferToString, getIndexOne, parseCredentials, parseNumberArray, parseAllowCredentialsArray, parsePubKeyArray, parseRelyingPartyId, };
function ensureArray(arr) {
return arr || [];
}
function getClientDataJson(credential) {
function arrayBufferToString(arrayBuffer) {
// https://goo.gl/yabPex - To future-proof, we'll pass along whatever the browser
// gives us and let AM disregard randomly-injected properties
var uint8Array = new Uint8Array(credential.response.clientDataJSON);
var uint8Array = new Uint8Array(arrayBuffer);
var txtDecoder = new TextDecoder();

@@ -89,3 +89,3 @@ var json = txtDecoder.decode(uint8Array);

}
export { ensureArray, getClientDataJson, getIndexOne, parseCredentials, parseNumberArray, parseAllowCredentialsArray, parsePubKeyArray, parseRelyingPartyId, };
export { ensureArray, arrayBufferToString, getIndexOne, parseCredentials, parseNumberArray, parseAllowCredentialsArray, parsePubKeyArray, parseRelyingPartyId, };
//# sourceMappingURL=helpers.js.map

@@ -22,2 +22,3 @@ import HiddenValueCallback from '../fr-auth/callbacks/hidden-value-callback';

* }
* ```
*/

@@ -120,5 +121,4 @@ declare abstract class FRWebAuthn {

static createRegistrationPublicKey(metadata: WebAuthnRegistrationMetadata): PublicKeyCredentialCreationOptions;
private static getErrorOutcome;
}
export default FRWebAuthn;
export { RelyingParty, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnOutcome, WebAuthnRegistrationMetadata, WebAuthnStepType, };

@@ -50,3 +50,3 @@ var __assign = (this && this.__assign) || function () {

import { WebAuthnOutcome, WebAuthnStepType } from './enums';
import { getClientDataJson, parseCredentials, parsePubKeyArray, parseRelyingPartyId, } from './helpers';
import { arrayBufferToString, parseCredentials, parsePubKeyArray, parseRelyingPartyId, } from './helpers';
import { parseWebAuthnAuthenticateText, parseWebAuthnRegisterText } from './script-parser';

@@ -68,2 +68,3 @@ /**

* }
* ```
*/

@@ -134,8 +135,7 @@ var FRWebAuthn = /** @class */ (function () {

error_1 = _b.sent();
outcome = this.getErrorOutcome(error_1);
return [3 /*break*/, 4];
throw new Error("WebAuthn: " + error_1.message);
case 4:
hiddenCallback.setInputValue(outcome);
return [2 /*return*/, step];
case 5: throw new Error('Invalid webauthn payload');
case 5: throw new Error('WebAuthn: Invalid payload');
}

@@ -178,8 +178,7 @@ });

error_2 = _b.sent();
outcome = this.getErrorOutcome(error_2);
return [3 /*break*/, 4];
throw new Error("WebAuthn: " + error_2.message);
case 4:
hiddenCallback.setInputValue(outcome);
return [2 /*return*/, step];
case 5: throw new Error('Invalid webauthn payload');
case 5: throw new Error('WebAuthn: Invalid payload');
}

@@ -280,12 +279,21 @@ });

if (credential === null) {
throw new Error('No credential provided');
throw new Error('WebAuthn: No credential provided');
}
var clientDataJSON = getClientDataJson(credential);
var clientDataJSON = arrayBufferToString(credential.response.clientDataJSON);
var assertionResponse = credential.response;
var authenticatorData = new Int8Array(assertionResponse.authenticatorData).toString();
var signature = new Int8Array(assertionResponse.signature).toString();
return clientDataJSON + "::" + authenticatorData + "::" + signature + "::" + credential.id;
// Current native typing for PublicKeyCredential does not include `userHandle`
// eslint-disable-next-line
// @ts-ignore
var userHandle = arrayBufferToString(credential.response.userHandle);
var stringOutput = clientDataJSON + "::" + authenticatorData + "::" + signature + "::" + credential.id;
// Check if Username is stored on device
if (userHandle) {
stringOutput = stringOutput + "::" + userHandle;
}
return stringOutput;
}
catch (error) {
return this.getErrorOutcome(error);
throw new Error(error.message);
}

@@ -301,15 +309,9 @@ };

return __awaiter(this, void 0, void 0, function () {
var credential, error_3;
var credential;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, navigator.credentials.create({ publicKey: options })];
case 0: return [4 /*yield*/, navigator.credentials.create({ publicKey: options })];
case 1:
credential = _a.sent();
return [3 /*break*/, 3];
case 2:
error_3 = _a.sent();
throw new Error(error_3.message);
case 3: return [2 /*return*/, credential];
return [2 /*return*/, credential];
}

@@ -333,3 +335,3 @@ });

}
var clientDataJSON = getClientDataJson(credential);
var clientDataJSON = arrayBufferToString(credential.response.clientDataJSON);
var attestationResponse = credential.response;

@@ -340,3 +342,3 @@ var attestationObject = new Int8Array(attestationResponse.attestationObject).toString();

catch (error) {
return this.getErrorOutcome(error);
throw new Error(error.message);
}

@@ -352,5 +354,6 @@ };

FRWebAuthn.createAuthenticationPublicKey = function (metadata) {
var allowCredentials = metadata.allowCredentials, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, timeout = metadata.timeout;
var allowCredentials = metadata.allowCredentials, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, timeout = metadata.timeout, userVerification = metadata.userVerification;
var rpId = parseRelyingPartyId(relyingPartyId);
return __assign({ allowCredentials: parseCredentials(allowCredentials), challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer, timeout: timeout }, (rpId && { rpId: rpId }));
var allowCredentialsValue = parseCredentials(allowCredentials);
return __assign(__assign(__assign({ challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer, timeout: timeout }, (allowCredentialsValue && { allowCredentials: allowCredentialsValue })), (userVerification && { userVerification: userVerification })), (rpId && { rpId: rpId }));
};

@@ -367,26 +370,17 @@ /**

var pubKeyCredParams = parsePubKeyArray(pubKeyCredParamsString);
if (!pubKeyCredParams) {
if (!pubKeyCredParams || !pubKeyCredParams.length) {
throw new Error('Missing pubKeyCredParams');
}
var attestationPreference = metadata.attestationPreference, authenticatorSelection = metadata.authenticatorSelection, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, relyingPartyName = metadata.relyingPartyName, timeout = metadata.timeout, userId = metadata.userId, userName = metadata.userName;
var excludeCredentials = parseCredentials(metadata.excludeCredentials);
var attestationPreference = metadata.attestationPreference, authenticatorSelection = metadata.authenticatorSelection, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, relyingPartyName = metadata.relyingPartyName, timeout = metadata.timeout, userId = metadata.userId, userName = metadata.userName, displayName = metadata.displayName;
var rpId = parseRelyingPartyId(relyingPartyId);
var rp = __assign({ name: relyingPartyName }, (rpId && { id: rpId }));
return {
attestation: attestationPreference,
authenticatorSelection: JSON.parse(authenticatorSelection),
challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer,
pubKeyCredParams: pubKeyCredParams,
return __assign(__assign({ attestation: attestationPreference, authenticatorSelection: JSON.parse(authenticatorSelection), challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer }, (excludeCredentials.length && { excludeCredentials: excludeCredentials })), { pubKeyCredParams: pubKeyCredParams,
rp: rp,
timeout: timeout,
user: {
displayName: userName,
timeout: timeout, user: {
displayName: displayName,
id: Int8Array.from(userId.split('').map(function (c) { return c.charCodeAt(0); })),
name: userName,
},
};
} });
};
FRWebAuthn.getErrorOutcome = function (error) {
var name = error.name ? error.name + ":" : '';
return WebAuthnOutcome.Error + "::" + name + error.message;
};
return FRWebAuthn;

@@ -393,0 +387,0 @@ }());

@@ -51,2 +51,3 @@ import HiddenValueCallback from '../fr-auth/callbacks/hidden-value-callback';

challenge: string;
excludeCredentials: string;
pubKeyCredParams: string;

@@ -58,2 +59,3 @@ relyingPartyId: string;

userName: string;
displayName: string;
}

@@ -65,2 +67,3 @@ interface WebAuthnAuthenticationMetadata {

timeout: number;
userVerification: UserVerificationType;
}

@@ -67,0 +70,0 @@ interface WebAuthnCallbacks {

@@ -12,17 +12,22 @@ var __assign = (this && this.__assign) || function () {

};
import { ensureArray, getIndexOne, parsePubKeyArray } from './helpers';
import { ensureArray, getIndexOne, parsePubKeyArray, parseCredentials } from './helpers';
function parseWebAuthnRegisterText(text) {
var txtEncoder = new TextEncoder();
// e.g. `attestation: "none"`
var attestation = getIndexOne(text.match(/attestation:\s{0,}"(\w+)"/));
var attestation = getIndexOne(text.match(/attestation"{0,}:\s{0,}"(\w+)"/));
// e.g. `timeout: 60000`
var timeout = Number(getIndexOne(text.match(/timeout:\s{0,}(\d+)/)));
// e.g. `"userVerification":"preferred"`
var userVerification = getIndexOne(text.match(/"userVerification":\s{0,}"(\w+)"/));
var timeout = Number(getIndexOne(text.match(/timeout"{0,}:\s{0,}(\d+)/)));
// e.g. from 7.0: `"userVerification":"preferred"`
// e.g. from 6.5: `userVerification: "preferred"`
var userVerification = getIndexOne(text.match(/userVerification"{0,}:\s{0,}"(\w+)"/));
// e.g. `"requireResidentKey":true`
var requireResidentKey = getIndexOne(text.match(/requireResidentKey"{0,}:\s{0,}(\w+)/));
// e.g. `"authenticatorAttachment":"cross-platform"`
var authenticatorAttachment = getIndexOne(text.match(/authenticatorAttachment"{0,}:\s{0,}"([\w-]+)/));
// e.g. `rp: {\n id: \"https://user.example.com:3002\",\n name: \"ForgeRock\"\n }`
var rp = getIndexOne(text.match(/rp:\s{0,}{([^}]+)}/)).trim();
// e.g. `id: \"https://user.example.com:3002\"
var rpId = getIndexOne(rp.match(/id:\s{0,}"([^"]*)"/));
var rp = getIndexOne(text.match(/rp"{0,}:\s{0,}{([^}]+)}/)).trim();
// e.g. `id: \"example.com\"
var rpId = getIndexOne(rp.match(/id"{0,}:\s{0,}"([^"]*)"/));
// e.g. `name: \"ForgeRock\"`
var rpName = getIndexOne(rp.match(/name:\s{0,}"([^"]*)"/));
var rpName = getIndexOne(rp.match(/name"{0,}:\s{0,}"([^"]*)"/));
// e.g. `user: {\n id: Uint8Array.from(\"NTdhN...RiNjI5\",

@@ -32,13 +37,18 @@ // function (c) { return c.charCodeAt(0) }),\n

// displayName: \"57a5b4e4-...-a4f2e5d4b629\"\n }`
var user = getIndexOne(text.match(/user:\s{0,}{([^]{0,})},/)).trim();
var user = getIndexOne(text.match(/user"{0,}:\s{0,}{([^]{0,})},/)).trim();
// e.g `id: Uint8Array.from(\"NTdhN...RiNjI5\",`
var userId = getIndexOne(user.match(/id:\s{0,}Uint8Array.from\("([^"]+)"/));
var userId = getIndexOne(user.match(/id"{0,}:\s{0,}Uint8Array.from\("([^"]+)"/));
// e.g. `name: \"57a5b4e4-...-a4f2e5d4b629\",`
var userName = getIndexOne(user.match(/name:\s{0,}"([\d\w._-]+)"/));
var userName = getIndexOne(user.match(/name"{0,}:\s{0,}"([\d\w._-]+)"/));
// e.g. `displayName: \"57a5b4e4-...-a4f2e5d4b629\"`
var userDisplayName = getIndexOne(user.match(/displayName:\s{0,}"([\d\w._-]+)"/));
var userDisplayName = getIndexOne(user.match(/displayName"{0,}:\s{0,}"([\d\w\s.@_-]+)"/));
// e.g. `pubKeyCredParams: [
// { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 }
// ]`
var pubKeyCredParamsString = getIndexOne(text.match(/pubKeyCredParams:\s{0,}\[([^]+) ]/)).trim();
var pubKeyCredParamsString = getIndexOne(
// Capture the `pubKeyCredParams` without also matching `excludeCredentials` as well.
// `excludeCredentials` values are very similar to this property, so we need to make sure
// our last value doesn't end with "buffer", so we are only capturing objects that
// end in a digit and possibly a space.
text.match(/pubKeyCredParams"{0,}:\s{0,}\[([^]+\d\s?})\s?]/)).trim();
// e.g. `{ \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 }`

@@ -49,4 +59,11 @@ var pubKeyCredParams = parsePubKeyArray(pubKeyCredParamsString);

}
// e.g. `excludeCredentials: [{
// \"type\": \"public-key\", \"id\": new Int8Array([-18, 69, -99, 82, 38, -66]).buffer },
// { \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, 56, -32, 91]).buffer }],\n`
var excludeCredentialsString = getIndexOne(text.match(/excludeCredentials"{0,}:\s{0,}\[([^]+)\s{0,}]/)).trim();
// e.g. `{ \"type\": \"public-key\", \"id\": new Int8Array([-18, 69, -99, 82, 38, -66]).buffer },
// { \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, 56, -32, 91]).buffer }`
var excludeCredentials = parseCredentials(excludeCredentialsString);
// e.g. `challenge: new Int8Array([87, -95, 18, ... -3, 49, 12, 81]).buffer,`
var challengeArr = ensureArray(text.match(/challenge:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
var challengeArr = ensureArray(text.match(/challenge"{0,}:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[87, -95, 18, ... -3, 49, 12, 81]`

@@ -56,23 +73,10 @@ var challengeJSON = JSON.parse(challengeArr[2]);

var challenge = new Int8Array(challengeJSON).buffer;
return {
attestation: attestation,
authenticatorSelection: {
userVerification: userVerification,
},
challenge: challenge,
excludeCredentials: [],
pubKeyCredParams: pubKeyCredParams,
rp: {
id: rpId,
name: rpName,
},
timeout: timeout,
user: {
return __assign(__assign({ attestation: attestation, authenticatorSelection: __assign(__assign({ userVerification: userVerification }, (authenticatorAttachment && { authenticatorAttachment: authenticatorAttachment })), (requireResidentKey === 'true' && { requireResidentKey: !!requireResidentKey })), challenge: challenge }, (excludeCredentials.length && { excludeCredentials: excludeCredentials })), { pubKeyCredParams: pubKeyCredParams, rp: __assign({ name: rpName }, (rpId && { id: rpId })), timeout: timeout, user: {
displayName: userDisplayName,
id: txtEncoder.encode(userId),
name: userName,
},
};
} });
}
function parseWebAuthnAuthenticateText(text) {
var allowCredentials;
// e.g. `allowCredentials: [

@@ -82,24 +86,28 @@ // { \"type\": \"public-key\",

// ]`
var allowCredentialsText = getIndexOne(text.match(/allowCredentials:\s{0,}\[([^]+)\s{0,}]/)).trim();
// Splitting objects in array in case the user has multiple keys
var allowCredentialArr = allowCredentialsText.split('},') || [allowCredentialsText];
// Iterating over array of substrings
var allowCredentials = allowCredentialArr.map(function (str) {
// e.g. `{ \"type\": \"public-key\",
var type = getIndexOne(str.match(/"type":\s{0,}"([\w-]+)"/));
// e.g. \"id\": new Int8Array([-107, 93, 68, -67, ... -19, 7, 4]).buffer
var idArr = ensureArray(text.match(/"id":\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[-107, 93, 68, -67, ... -19, 7, 4]`
var idJSON = JSON.parse(idArr[2]);
// e.g. [-107, 93, 68, -67, ... -19, 7, 4]
var id = new Int8Array(idJSON).buffer;
return {
type: type,
id: id,
};
});
var allowCredentialsText = getIndexOne(text.match(/allowCredentials"{0,}:\s{0,}\[([^]+)\s{0,}]/)).trim();
// e.g. `"userVerification":"preferred"`
var userVerification = getIndexOne(text.match(/userVerification"{0,}:\s{0,}"(\w+)"/));
if (allowCredentialsText) {
// Splitting objects in array in case the user has multiple keys
var allowCredentialArr = allowCredentialsText.split('},') || [allowCredentialsText];
// Iterating over array of substrings
allowCredentials = allowCredentialArr.map(function (str) {
// e.g. `{ \"type\": \"public-key\",
var type = getIndexOne(str.match(/type"{0,}:\s{0,}"([\w-]+)"/));
// e.g. \"id\": new Int8Array([-107, 93, 68, -67, ... -19, 7, 4]).buffer
var idArr = ensureArray(str.match(/id"{0,}:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[-107, 93, 68, -67, ... -19, 7, 4]`
var idJSON = JSON.parse(idArr[2]);
// e.g. [-107, 93, 68, -67, ... -19, 7, 4]
var id = new Int8Array(idJSON).buffer;
return {
type: type,
id: id,
};
});
}
// e.g. `timeout: 60000`
var timeout = Number(getIndexOne(text.match(/timeout:\s{0,}(\d+)/)));
var timeout = Number(getIndexOne(text.match(/timeout"{0,}:\s{0,}(\d+)/)));
// e.g. `challenge: new Int8Array([87, -95, 18, ... -3, 49, 12, 81]).buffer,`
var challengeArr = ensureArray(text.match(/challenge:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
var challengeArr = ensureArray(text.match(/challenge"{0,}:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[87, -95, 18, ... -3, 49, 12, 81]`

@@ -109,9 +117,8 @@ var challengeJSON = JSON.parse(challengeArr[2]);

var challenge = new Int8Array(challengeJSON).buffer;
// e.g. `rpId: "user.example.com",`
var rpId = getIndexOne(text.match(/rpId:\s{0,}\[([^]+)\s{0,}]/));
return __assign({ allowCredentials: allowCredentials,
challenge: challenge,
timeout: timeout }, (rpId && { id: rpId }));
// e.g. `rpId: \"example.com\"`
var rpId = getIndexOne(text.match(/rpId"{0,}:\s{0,}\\{0,}"([^"\\]*)/));
return __assign(__assign(__assign({ challenge: challenge,
timeout: timeout }, (allowCredentials && { allowCredentials: allowCredentials })), (userVerification && { userVerification: userVerification })), (rpId && { rpId: rpId }));
}
export { parseWebAuthnAuthenticateText, parseWebAuthnRegisterText };
//# sourceMappingURL=script-parser.js.map

@@ -1,12 +0,51 @@

declare const authenticateInput = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const authenticateOuput: {
allowCredentials: {
declare const authenticateInputWithRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n rpId: \"example.com\",\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ type: \"public-key\", id: new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const authenticateInputWithRpidAllowCredentialsAndQuotes = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n \"rpId\": \"example.com\",\n \"challenge\": new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n \"timeout\": 60000,\n \"allowCredentials\": [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const authenticateInputWithoutRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerInputWithRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"bob_lee-tester@me.co.uk\"\n },\n pubKeyCredParams: [ { type: \"public-key\", alg: -257 }, { type: \"public-key\", alg: -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\n userVerification: \"preferred\"\n authenticatorAttachment:\"cross-platform\"\n }\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerInputWithRpidAndQuotes = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\n if (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n }\n\n var publicKey = {\n \"challenge\": new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n \"rp\": {\n \"id\": \"example.com\",\n \"name\": \"ForgeRock\"\n },\n // User:\n \"user\": {\n \"id\": Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n \"name\": \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n \"displayName\": \"bob_lee-tester@me.co.uk\"\n },\n \"pubKeyCredParams\": [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n \"attestation\": \"none\",\n \"timeout\": 60000,\n \"excludeCredentials\": [],\n \"authenticatorSelection\": {\"userVerification\":\"preferred\",\"authenticatorAttachment\":\"cross-platform\"}\n };\n\n navigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutputWithRpid: {
attestation: string;
authenticatorSelection: {
userVerification: string;
authenticatorAttachment: string;
};
challenge: never[];
pubKeyCredParams: {
type: string;
alg: number;
}[];
rp: {
id: string;
name: string;
};
timeout: number;
user: {
displayName: string;
id: never[];
name: string;
};
};
declare const registerInputWithoutRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutputWithoutRpid: {
attestation: string;
authenticatorSelection: {
userVerification: string;
};
challenge: never[];
pubKeyCredParams: {
type: string;
alg: number;
}[];
challenge: never[];
rp: {
name: string;
};
timeout: number;
user: {
displayName: string;
id: never[];
name: string;
};
};
declare const registerInput = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"user.example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutput: {
declare const registerInputWithExcludeCreds = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([49, -96, -107, 113, 106, 5, 115, 22, 68, 121, -85, -27, 8, -58, -113, 127, -105, -37, -10, -12, -58, -25, 29, -82, -18, 69, -99, 125, 33, 82, 38, -66, -27, -128, -91, -86, 87, 68, 94, 0, -78, 70, -11, -70, -14, -53, 38, -60, 46, 27, 66, 46, 21, -125, -70, 123, -46, -124, 86, -2, 102, 70, -52, 54]).buffer },{ \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, -123, -21, 127, 76, -120, 90, -112, -5, 54, 105, 93, 82, -104, -79, 107, -69, -3, -113, -94, -59, -4, 126, -33, 117, 32, -44, 122, -97, 8, -112, 105, -96, 96, 90, 44, -128, -121, 107, 79, -98, -68, -93, 11, -105, -47, 102, 13, 110, 84, 59, -91, -30, 37, -3, -22, 39, 111, -10, 87, -50, -35]).buffer }],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutputWithExcludeCreds: {
attestation: string;

@@ -17,3 +56,6 @@ authenticatorSelection: {

challenge: never[];
excludeCredentials: never[];
excludeCredentials: {
type: string;
id: string;
}[];
pubKeyCredParams: {

@@ -24,3 +66,2 @@ type: string;

rp: {
id: string;
name: string;

@@ -35,2 +76,2 @@ };

};
export { authenticateInput, authenticateOuput, registerInput, registerOutput };
export { authenticateInputWithRpidAndAllowCredentials, authenticateInputWithRpidAllowCredentialsAndQuotes, authenticateInputWithoutRpidAndAllowCredentials, registerInputWithRpid, registerInputWithRpidAndQuotes, registerOutputWithRpid, registerInputWithoutRpid, registerOutputWithoutRpid, registerInputWithExcludeCreds, registerOutputWithExcludeCreds, };
/* eslint-disable max-len */
var authenticateInput = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
// Currently not used
var authenticateOuput = {
allowCredentials: [
{
type: 'public-key',
id: [
/* don't directly test */
],
},
var authenticateInputWithRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n rpId: \"example.com\",\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ type: \"public-key\", id: new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var authenticateInputWithRpidAllowCredentialsAndQuotes = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n \"rpId\": \"example.com\",\n \"challenge\": new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n \"timeout\": 60000,\n \"allowCredentials\": [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var authenticateInputWithoutRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var registerInputWithRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"bob_lee-tester@me.co.uk\"\n },\n pubKeyCredParams: [ { type: \"public-key\", alg: -257 }, { type: \"public-key\", alg: -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\n userVerification: \"preferred\"\n authenticatorAttachment:\"cross-platform\"\n }\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var registerInputWithRpidAndQuotes = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\n if (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n }\n\n var publicKey = {\n \"challenge\": new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n \"rp\": {\n \"id\": \"example.com\",\n \"name\": \"ForgeRock\"\n },\n // User:\n \"user\": {\n \"id\": Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n \"name\": \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n \"displayName\": \"bob_lee-tester@me.co.uk\"\n },\n \"pubKeyCredParams\": [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n \"attestation\": \"none\",\n \"timeout\": 60000,\n \"excludeCredentials\": [],\n \"authenticatorSelection\": {\"userVerification\":\"preferred\",\"authenticatorAttachment\":\"cross-platform\"}\n };\n\n navigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var registerOutputWithRpid = {
attestation: 'none',
authenticatorSelection: {
userVerification: 'preferred',
authenticatorAttachment: 'cross-platform',
},
challenge: [
/* don't directly test */
],
pubKeyCredParams: [
{ type: 'public-key', alg: -257 },
{ type: 'public-key', alg: -7 },
],
rp: { id: 'example.com', name: 'ForgeRock' },
timeout: 60000,
user: {
displayName: 'bob_lee-tester@me.co.uk',
id: [
/* don't directly test */
],
name: '57a5b4e4-6999-4b45-bf86-a4f2e5d4b629',
},
};
var registerInputWithoutRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var registerOutputWithoutRpid = {
attestation: 'none',
authenticatorSelection: { userVerification: 'preferred' },
challenge: [
/* don't directly test */
],
pubKeyCredParams: [
{ type: 'public-key', alg: -257 },
{ type: 'public-key', alg: -7 },
],
rp: { name: 'ForgeRock' },
timeout: 60000,
user: {
displayName: 'Bob Tester',
id: [
/* don't directly test */
],
name: '57a5b4e4-6999-4b45-bf86-a4f2e5d4b629',
},
};
/* eslint-disable max-len */
var registerInput = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"user.example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var registerOutput = {
var registerInputWithExcludeCreds = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([49, -96, -107, 113, 106, 5, 115, 22, 68, 121, -85, -27, 8, -58, -113, 127, -105, -37, -10, -12, -58, -25, 29, -82, -18, 69, -99, 125, 33, 82, 38, -66, -27, -128, -91, -86, 87, 68, 94, 0, -78, 70, -11, -70, -14, -53, 38, -60, 46, 27, 66, 46, 21, -125, -70, 123, -46, -124, 86, -2, 102, 70, -52, 54]).buffer },{ \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, -123, -21, 127, 76, -120, 90, -112, -5, 54, 105, 93, 82, -104, -79, 107, -69, -3, -113, -94, -59, -4, 126, -33, 117, 32, -44, 122, -97, 8, -112, 105, -96, 96, 90, 44, -128, -121, 107, 79, -98, -68, -93, 11, -105, -47, 102, 13, 110, 84, 59, -91, -30, 37, -3, -22, 39, 111, -10, 87, -50, -35]).buffer }],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
var registerOutputWithExcludeCreds = {
attestation: 'none',

@@ -26,3 +58,12 @@ authenticatorSelection: { userVerification: 'preferred' },

],
excludeCredentials: [],
excludeCredentials: [
{
type: 'public-key',
id: 'Do not directly test',
},
{
type: 'public-key',
id: 'Do not directly test',
},
],
pubKeyCredParams: [

@@ -32,6 +73,6 @@ { type: 'public-key', alg: -257 },

],
rp: { id: 'user.example.com', name: 'ForgeRock' },
rp: { name: 'ForgeRock' },
timeout: 60000,
user: {
displayName: '57a5b4e4-6999-4b45-bf86-a4f2e5d4b629',
displayName: 'Bob Tester',
id: [

@@ -43,3 +84,3 @@ /* don't directly test */

};
export { authenticateInput, authenticateOuput, registerInput, registerOutput };
export { authenticateInputWithRpidAndAllowCredentials, authenticateInputWithRpidAllowCredentialsAndQuotes, authenticateInputWithoutRpidAndAllowCredentials, registerInputWithRpid, registerInputWithRpidAndQuotes, registerOutputWithRpid, registerInputWithoutRpid, registerOutputWithoutRpid, registerInputWithExcludeCreds, registerOutputWithExcludeCreds, };
//# sourceMappingURL=script-text.mock.data.js.map

@@ -59,3 +59,3 @@ var __extends = (this && this.__extends) || (function () {

import { withTimeout } from '../util/timeout';
import { addAuthzInfoToHeaders, addAuthzInfoToURL, buildAuthzOptions, examineForIGAuthz, examineForRESTAuthz, hasAuthzAdvice, isAuthzStep, newTokenRequired, normalizeIGJSON, normalizeRESTJSON, } from './util';
import { addAuthzInfoToHeaders, addAuthzInfoToURL, buildAuthzOptions, examineForIGAuthz, examineForRESTAuthz, hasAuthzAdvice, isAuthzStep, newTokenRequired, normalizeIGJSON, normalizeRESTJSON, } from './helpers';
import middlewareWrapper from '../util/middleware';

@@ -62,0 +62,0 @@ /**

@@ -20,2 +20,3 @@ import Auth from './auth';

import ReCaptchaCallback from './fr-auth/callbacks/recaptcha-callback';
import SuspendedTextOutputCallback from './fr-auth/callbacks/suspended-text-output-callback';
import TermsAndConditionsCallback from './fr-auth/callbacks/terms-and-conditions-callback';

@@ -33,2 +34,3 @@ import TextOutputCallback from './fr-auth/callbacks/text-output-callback';

import defaultMessageCreator from './fr-policy/message-creator';
import FRRecoveryCodes from './fr-recovery-codes';
import FRUI from './fr-ui';

@@ -48,2 +50,2 @@ import FRUser from './fr-user';

import LocalStorage from './util/storage';
export { defaultMessageCreator, nonce, AttributeInputCallback, Auth, AuthResponse, Callback, CallbackContainer, CallbackType, ChoiceCallback, Config, ConfigOptions, ConfirmationCallback, Deferred, DeviceProfileCallback, Dispatcher, ErrorCode, FailureDetail, FRAuth, FRCallback, FRCallbackFactory, FRDevice, FREvent, FRLoginFailure, FRLoginSuccess, FRPolicy, FRStep, FRStepHandler, FRUI, FRUser, FRWebAuthn, GetAuthorizationUrlOptions, GetOAuth2TokensOptions, GetTokensOptions, HiddenValueCallback, HttpClient, KbaCreateCallback, Listener, LocalStorage, MessageCreator, MetadataCallback, NameCallback, NameValue, OAuth2Client, OAuth2Tokens, PasswordCallback, PKCE, PolicyKey, PolicyRequirement, PollingWaitCallback, ProcessedPropertyError, ReCaptchaCallback, RelyingParty, ResponseType, SessionManager, Step, StepDetail, StepType, TermsAndConditionsCallback, TextOutputCallback, TokenManager, Tokens, TokenStorage, UserManager, ValidatedCreatePasswordCallback, ValidatedCreateUsernameCallback, ValidConfigOptions, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnOutcome, WebAuthnRegistrationMetadata, WebAuthnStepType, };
export { defaultMessageCreator, nonce, AttributeInputCallback, Auth, AuthResponse, Callback, CallbackContainer, CallbackType, ChoiceCallback, Config, ConfigOptions, ConfirmationCallback, Deferred, DeviceProfileCallback, Dispatcher, ErrorCode, FailureDetail, FRAuth, FRCallback, FRCallbackFactory, FRDevice, FREvent, FRLoginFailure, FRLoginSuccess, FRPolicy, FRRecoveryCodes, FRStep, FRStepHandler, FRUI, FRUser, FRWebAuthn, GetAuthorizationUrlOptions, GetOAuth2TokensOptions, GetTokensOptions, HiddenValueCallback, HttpClient, KbaCreateCallback, Listener, LocalStorage, MessageCreator, MetadataCallback, NameCallback, NameValue, OAuth2Client, OAuth2Tokens, PasswordCallback, PKCE, PolicyKey, PolicyRequirement, PollingWaitCallback, ProcessedPropertyError, ReCaptchaCallback, RelyingParty, ResponseType, SessionManager, Step, StepDetail, StepType, SuspendedTextOutputCallback, TermsAndConditionsCallback, TextOutputCallback, TokenManager, Tokens, TokenStorage, UserManager, ValidatedCreatePasswordCallback, ValidatedCreateUsernameCallback, ValidConfigOptions, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnOutcome, WebAuthnRegistrationMetadata, WebAuthnStepType, };

@@ -18,2 +18,3 @@ import Auth from './auth';

import ReCaptchaCallback from './fr-auth/callbacks/recaptcha-callback';
import SuspendedTextOutputCallback from './fr-auth/callbacks/suspended-text-output-callback';
import TermsAndConditionsCallback from './fr-auth/callbacks/terms-and-conditions-callback';

@@ -32,2 +33,3 @@ import TextOutputCallback from './fr-auth/callbacks/text-output-callback';

import defaultMessageCreator from './fr-policy/message-creator';
import FRRecoveryCodes from './fr-recovery-codes';
import FRUser from './fr-user';

@@ -45,3 +47,3 @@ import FRWebAuthn, { WebAuthnOutcome, WebAuthnStepType, } from './fr-webauthn';

import LocalStorage from './util/storage';
export { defaultMessageCreator, nonce, AttributeInputCallback, Auth, CallbackType, ChoiceCallback, Config, ConfirmationCallback, Deferred, DeviceProfileCallback, Dispatcher, ErrorCode, FRAuth, FRCallback, FRDevice, FRLoginFailure, FRLoginSuccess, FRPolicy, FRStep, FRUser, FRWebAuthn, HiddenValueCallback, HttpClient, KbaCreateCallback, LocalStorage, MetadataCallback, NameCallback, OAuth2Client, PasswordCallback, PKCE, PolicyKey, PollingWaitCallback, ReCaptchaCallback, ResponseType, SessionManager, StepType, TermsAndConditionsCallback, TextOutputCallback, TokenManager, TokenStorage, UserManager, ValidatedCreatePasswordCallback, ValidatedCreateUsernameCallback, WebAuthnOutcome, WebAuthnStepType, };
export { defaultMessageCreator, nonce, AttributeInputCallback, Auth, CallbackType, ChoiceCallback, Config, ConfirmationCallback, Deferred, DeviceProfileCallback, Dispatcher, ErrorCode, FRAuth, FRCallback, FRDevice, FRLoginFailure, FRLoginSuccess, FRPolicy, FRRecoveryCodes, FRStep, FRUser, FRWebAuthn, HiddenValueCallback, HttpClient, KbaCreateCallback, LocalStorage, MetadataCallback, NameCallback, OAuth2Client, PasswordCallback, PKCE, PolicyKey, PollingWaitCallback, ReCaptchaCallback, ResponseType, SessionManager, StepType, SuspendedTextOutputCallback, TermsAndConditionsCallback, TextOutputCallback, TokenManager, TokenStorage, UserManager, ValidatedCreatePasswordCallback, ValidatedCreateUsernameCallback, WebAuthnOutcome, WebAuthnStepType, };
//# sourceMappingURL=index.js.map

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

case 0:
console.warn('Deprecation warning: this `getAuthorizeUrl` method will be renamed in v3.');
_a = Config.get(options), serverConfig = _a.serverConfig, clientId = _a.clientId, redirectUri = _a.redirectUri, scope = _a.scope;

@@ -64,0 +65,0 @@ requestParams = {

@@ -50,3 +50,2 @@ var __assign = (this && this.__assign) || function () {

import TokenStorage from '../token-storage';
import nonce from '../util/nonce';
import PKCE from '../util/pkce';

@@ -80,3 +79,3 @@ import { parseQuery } from '../util/url';

verifier = PKCE.createVerifier();
state = nonce()().toString();
state = PKCE.createState();
authorizeUrlOptions = __assign(__assign({}, options), { responseType: ResponseType.Code, state: state, verifier: verifier });

@@ -83,0 +82,0 @@ return [4 /*yield*/, OAuth2Client.getAuthorizeUrl(authorizeUrlOptions)];

@@ -8,2 +8,3 @@ /**

if (length === void 0) { length = 15; }
console.warn('Deprecation warning: the `nonce` method will be removed in v3.');
var last = -1;

@@ -10,0 +11,0 @@ var repeat = 0;

/**
* Helper class for generating verifier and challenge strings used for
* Helper class for generating verifier, challenge and state strings used for
* Proof Key for Code Exchange (PKCE).

@@ -7,7 +7,9 @@ */

/**
* Creates a random state.
*/
static createState(): string;
/**
* Creates a random verifier.
*
* @param size The length of the verifier (default 32 characters)
*/
static createVerifier(size?: number): string;
static createVerifier(num?: number): string;
/**

@@ -31,3 +33,9 @@ * Creates a SHA-256 hash of the verifier.

static sha256(value: string): Promise<Uint8Array>;
/**
* Creates a random string.
*
* @param size The number for entropy (default: 32)
*/
private static createRandomString;
}
export default PKCE;

@@ -38,3 +38,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

/**
* Helper class for generating verifier and challenge strings used for
* Helper class for generating verifier, challenge and state strings used for
* Proof Key for Code Exchange (PKCE).

@@ -46,12 +46,15 @@ */

/**
* Creates a random state.
*/
PKCE.createState = function () {
return this.createRandomString(16);
};
/**
* Creates a random verifier.
*
* @param size The length of the verifier (default 32 characters)
*/
PKCE.createVerifier = function (size) {
if (size === void 0) { size = 32; }
var array = new Uint8Array(size);
window.crypto.getRandomValues(array);
var verifier = this.base64UrlEncode(array);
return verifier;
PKCE.createVerifier = function (num) {
if (num) {
console.warn('Deprecation warning: the parameter for `createVerifier` will be removed in v3');
}
return this.createRandomString(num || 32);
};

@@ -109,2 +112,13 @@ /**

};
/**
* Creates a random string.
*
* @param size The number for entropy (default: 32)
*/
PKCE.createRandomString = function (num) {
if (num === void 0) { num = 32; }
var random = new Uint8Array(num);
window.crypto.getRandomValues(random);
return btoa(random.join('')).replace(/[^a-zA-Z0-9]+/, '');
};
return PKCE;

@@ -111,0 +125,0 @@ }());

@@ -22,2 +22,3 @@ /**

NameCallback = "NameCallback",
NumberAttributeInputCallback = "NumberAttributeInputCallback",
PasswordCallback = "PasswordCallback",

@@ -27,2 +28,3 @@ PollingWaitCallback = "PollingWaitCallback",

StringAttributeInputCallback = "StringAttributeInputCallback",
SuspendedTextOutputCallback = "SuspendedTextOutputCallback",
TermsAndConditionsCallback = "TermsAndConditionsCallback",

@@ -29,0 +31,0 @@ TextOutputCallback = "TextOutputCallback",

@@ -28,2 +28,3 @@ "use strict";

CallbackType["NameCallback"] = "NameCallback";
CallbackType["NumberAttributeInputCallback"] = "NumberAttributeInputCallback";
CallbackType["PasswordCallback"] = "PasswordCallback";

@@ -33,2 +34,3 @@ CallbackType["PollingWaitCallback"] = "PollingWaitCallback";

CallbackType["StringAttributeInputCallback"] = "StringAttributeInputCallback";
CallbackType["SuspendedTextOutputCallback"] = "SuspendedTextOutputCallback";
CallbackType["TermsAndConditionsCallback"] = "TermsAndConditionsCallback";

@@ -35,0 +37,0 @@ CallbackType["TextOutputCallback"] = "TextOutputCallback";

import FRCallback from '.';
import { Callback, PolicyRequirement } from '../../auth/interfaces';
import { StringDict } from '../../shared/interfaces';
/**
* Represents a callback used to collect attributes.
*
* @typeparam T Maps to StringAttributeInputCallback and BooleanAttributeInputCallback, respectively
* @typeparam T Maps to StringAttributeInputCallback, NumberAttributeInputCallback and
* BooleanAttributeInputCallback, respectively
*/
declare class AttributeInputCallback<T extends string | boolean> extends FRCallback {
declare class AttributeInputCallback<T extends string | number | boolean> extends FRCallback {
payload: Callback;

@@ -33,4 +35,8 @@ /**

*/
getPolicies(): string[];
getPolicies(): StringDict<any>;
/**
* Set if validating value only.
*/
setValidateOnly(value: boolean): void;
/**
* Sets the attribute's value.

@@ -37,0 +43,0 @@ */

@@ -23,3 +23,4 @@ "use strict";

*
* @typeparam T Maps to StringAttributeInputCallback and BooleanAttributeInputCallback, respectively
* @typeparam T Maps to StringAttributeInputCallback, NumberAttributeInputCallback and
* BooleanAttributeInputCallback, respectively
*/

@@ -63,6 +64,14 @@ var AttributeInputCallback = /** @class */ (function (_super) {

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
AttributeInputCallback.prototype.getPolicies = function () {
return this.getOutputByName('policies', []);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.getOutputByName('policies', {});
};
/**
* Set if validating value only.
*/
AttributeInputCallback.prototype.setValidateOnly = function (value) {
this.setInputValue(value, /validateOnly/);
};
/**
* Sets the attribute's value.

@@ -69,0 +78,0 @@ */

@@ -19,2 +19,3 @@ "use strict";

var recaptcha_callback_1 = __importDefault(require("./recaptcha-callback"));
var suspended_text_output_callback_1 = __importDefault(require("./suspended-text-output-callback"));
var terms_and_conditions_callback_1 = __importDefault(require("./terms-and-conditions-callback"));

@@ -45,2 +46,4 @@ var text_output_callback_1 = __importDefault(require("./text-output-callback"));

return new name_callback_1.default(callback);
case enums_1.CallbackType.NumberAttributeInputCallback:
return new attribute_input_callback_1.default(callback);
case enums_1.CallbackType.PasswordCallback:

@@ -54,2 +57,4 @@ return new password_callback_1.default(callback);

return new attribute_input_callback_1.default(callback);
case enums_1.CallbackType.SuspendedTextOutputCallback:
return new suspended_text_output_callback_1.default(callback);
case enums_1.CallbackType.TermsAndConditionsCallback:

@@ -56,0 +61,0 @@ return new terms_and_conditions_callback_1.default(callback);

@@ -28,3 +28,3 @@ import { Callback } from '../../auth/interfaces';

*/
setInputValue(value: unknown, selector?: number | string): void;
setInputValue(value: unknown, selector?: number | string | RegExp): void;
/**

@@ -31,0 +31,0 @@ * Gets the value of the specified output element, or the first element if `selector`

@@ -77,2 +77,10 @@ "use strict";

}
// Duck typing for RegEx
if (typeof selector === 'object' && selector.test && selector.exec) {
var input = array.find(function (x) { return selector.test(x.name); });
if (!input) {
throw new Error("Missing callback input entry \"" + selector + "\"");
}
return input;
}
throw new Error('Invalid selector value type');

@@ -79,0 +87,0 @@ };

import FRCallback from '.';
import { Callback, PolicyRequirement } from '../../auth/interfaces';
import { StringDict } from '../../shared/interfaces';
/**

@@ -19,3 +20,3 @@ * Represents a callback used to collect a valid platform password.

*/
getPolicies(): string[];
getPolicies(): StringDict<any>;
/**

@@ -33,3 +34,7 @@ * Gets the callback's prompt.

setPassword(password: string): void;
/**
* Set if validating value only.
*/
setValidateOnly(value: boolean): void;
}
export default ValidatedCreatePasswordCallback;

@@ -42,4 +42,6 @@ "use strict";

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ValidatedCreatePasswordCallback.prototype.getPolicies = function () {
return this.getOutputByName('policies', []);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.getOutputByName('policies', {});
};

@@ -64,2 +66,8 @@ /**

};
/**
* Set if validating value only.
*/
ValidatedCreatePasswordCallback.prototype.setValidateOnly = function (value) {
this.setInputValue(value, /validateOnly/);
};
return ValidatedCreatePasswordCallback;

@@ -66,0 +74,0 @@ }(_1.default));

import FRCallback from '.';
import { Callback, PolicyRequirement } from '../../auth/interfaces';
import { StringDict } from '../../shared/interfaces';
/**

@@ -23,3 +24,3 @@ * Represents a callback used to collect a valid platform username.

*/
getPolicies(): string[];
getPolicies(): StringDict<any>;
/**

@@ -33,3 +34,7 @@ * Gets whether the username is required.

setName(name: string): void;
/**
* Set if validating value only.
*/
setValidateOnly(value: boolean): void;
}
export default ValidatedCreateUsernameCallback;

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

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ValidatedCreateUsernameCallback.prototype.getPolicies = function () {
return this.getOutputByName('policies', []);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.getOutputByName('policies', {});
};

@@ -64,2 +66,8 @@ /**

};
/**
* Set if validating value only.
*/
ValidatedCreateUsernameCallback.prototype.setValidateOnly = function (value) {
this.setInputValue(value, /validateOnly/);
};
return ValidatedCreateUsernameCallback;

@@ -66,0 +74,0 @@ }(_1.default));

@@ -42,3 +42,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var config_1 = __importDefault(require("../config"));
var oauth2_client_1 = __importDefault(require("../oauth2-client"));
var session_manager_1 = __importDefault(require("../session-manager"));
var token_manager_1 = __importDefault(require("../token-manager"));

@@ -107,27 +109,29 @@ var user_manager_1 = __importDefault(require("../user-manager"));

return __awaiter(this, void 0, void 0, function () {
var error_2;
var serverConfig, error_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 4, , 5]);
// TODO: Determine if we're using logout() or endSession(). logout() removes
// the cookie, but fails with CORS issues currently.
// await SessionManager.logout();
return [4 /*yield*/, oauth2_client_1.default.endSession(options)];
serverConfig = config_1.default.get(options).serverConfig;
_a.label = 1;
case 1:
// TODO: Determine if we're using logout() or endSession(). logout() removes
// the cookie, but fails with CORS issues currently.
// await SessionManager.logout();
_a.trys.push([1, 7, , 8]);
if (!!serverConfig.baseUrl.includes('forgeblocks.com')) return [3 /*break*/, 3];
return [4 /*yield*/, session_manager_1.default.logout()];
case 2:
_a.sent();
_a.label = 3;
case 3: return [4 /*yield*/, oauth2_client_1.default.endSession(options)];
case 4:
_a.sent();
return [4 /*yield*/, oauth2_client_1.default.revokeToken(options)];
case 2:
case 5:
_a.sent();
return [4 /*yield*/, token_manager_1.default.deleteTokens()];
case 3:
case 6:
_a.sent();
return [3 /*break*/, 5];
case 4:
return [3 /*break*/, 8];
case 7:
error_2 = _a.sent();
throw new Error('Logout failed');
case 5: return [2 /*return*/];
case 8: return [2 /*return*/];
}

@@ -134,0 +138,0 @@ });

@@ -1,4 +0,9 @@

import { ParsedCredential, ResponseCredential } from './interfaces';
/**
* @module
* @ignore
* These are private utility functions for HttpClient
*/
import { ParsedCredential } from './interfaces';
declare function ensureArray(arr: RegExpMatchArray | null): string[];
declare function getClientDataJson(credential: ResponseCredential): string;
declare function arrayBufferToString(arrayBuffer: ArrayBuffer): string;
declare function getIndexOne(arr: RegExpMatchArray | null): string;

@@ -17,2 +22,2 @@ declare function parseCredentials(value: string): ParsedCredential[];

declare function parseRelyingPartyId(relyingPartyId: string): string;
export { ensureArray, getClientDataJson, getIndexOne, parseCredentials, parseNumberArray, parseAllowCredentialsArray, parsePubKeyArray, parseRelyingPartyId, };
export { ensureArray, arrayBufferToString, getIndexOne, parseCredentials, parseNumberArray, parseAllowCredentialsArray, parsePubKeyArray, parseRelyingPartyId, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseRelyingPartyId = exports.parsePubKeyArray = exports.parseAllowCredentialsArray = exports.parseNumberArray = exports.parseCredentials = exports.getIndexOne = exports.getClientDataJson = exports.ensureArray = void 0;
exports.parseRelyingPartyId = exports.parsePubKeyArray = exports.parseAllowCredentialsArray = exports.parseNumberArray = exports.parseCredentials = exports.getIndexOne = exports.arrayBufferToString = exports.ensureArray = void 0;
function ensureArray(arr) {

@@ -8,6 +8,6 @@ return arr || [];

exports.ensureArray = ensureArray;
function getClientDataJson(credential) {
function arrayBufferToString(arrayBuffer) {
// https://goo.gl/yabPex - To future-proof, we'll pass along whatever the browser
// gives us and let AM disregard randomly-injected properties
var uint8Array = new Uint8Array(credential.response.clientDataJSON);
var uint8Array = new Uint8Array(arrayBuffer);
var txtDecoder = new TextDecoder();

@@ -17,3 +17,3 @@ var json = txtDecoder.decode(uint8Array);

}
exports.getClientDataJson = getClientDataJson;
exports.arrayBufferToString = arrayBufferToString;
function getIndexOne(arr) {

@@ -20,0 +20,0 @@ return arr ? arr[1] : '';

@@ -22,2 +22,3 @@ import HiddenValueCallback from '../fr-auth/callbacks/hidden-value-callback';

* }
* ```
*/

@@ -120,5 +121,4 @@ declare abstract class FRWebAuthn {

static createRegistrationPublicKey(metadata: WebAuthnRegistrationMetadata): PublicKeyCredentialCreationOptions;
private static getErrorOutcome;
}
export default FRWebAuthn;
export { RelyingParty, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnOutcome, WebAuthnRegistrationMetadata, WebAuthnStepType, };

@@ -72,2 +72,3 @@ "use strict";

* }
* ```
*/

@@ -138,8 +139,7 @@ var FRWebAuthn = /** @class */ (function () {

error_1 = _b.sent();
outcome = this.getErrorOutcome(error_1);
return [3 /*break*/, 4];
throw new Error("WebAuthn: " + error_1.message);
case 4:
hiddenCallback.setInputValue(outcome);
return [2 /*return*/, step];
case 5: throw new Error('Invalid webauthn payload');
case 5: throw new Error('WebAuthn: Invalid payload');
}

@@ -182,8 +182,7 @@ });

error_2 = _b.sent();
outcome = this.getErrorOutcome(error_2);
return [3 /*break*/, 4];
throw new Error("WebAuthn: " + error_2.message);
case 4:
hiddenCallback.setInputValue(outcome);
return [2 /*return*/, step];
case 5: throw new Error('Invalid webauthn payload');
case 5: throw new Error('WebAuthn: Invalid payload');
}

@@ -284,12 +283,21 @@ });

if (credential === null) {
throw new Error('No credential provided');
throw new Error('WebAuthn: No credential provided');
}
var clientDataJSON = helpers_1.getClientDataJson(credential);
var clientDataJSON = helpers_1.arrayBufferToString(credential.response.clientDataJSON);
var assertionResponse = credential.response;
var authenticatorData = new Int8Array(assertionResponse.authenticatorData).toString();
var signature = new Int8Array(assertionResponse.signature).toString();
return clientDataJSON + "::" + authenticatorData + "::" + signature + "::" + credential.id;
// Current native typing for PublicKeyCredential does not include `userHandle`
// eslint-disable-next-line
// @ts-ignore
var userHandle = helpers_1.arrayBufferToString(credential.response.userHandle);
var stringOutput = clientDataJSON + "::" + authenticatorData + "::" + signature + "::" + credential.id;
// Check if Username is stored on device
if (userHandle) {
stringOutput = stringOutput + "::" + userHandle;
}
return stringOutput;
}
catch (error) {
return this.getErrorOutcome(error);
throw new Error(error.message);
}

@@ -305,15 +313,9 @@ };

return __awaiter(this, void 0, void 0, function () {
var credential, error_3;
var credential;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, navigator.credentials.create({ publicKey: options })];
case 0: return [4 /*yield*/, navigator.credentials.create({ publicKey: options })];
case 1:
credential = _a.sent();
return [3 /*break*/, 3];
case 2:
error_3 = _a.sent();
throw new Error(error_3.message);
case 3: return [2 /*return*/, credential];
return [2 /*return*/, credential];
}

@@ -337,3 +339,3 @@ });

}
var clientDataJSON = helpers_1.getClientDataJson(credential);
var clientDataJSON = helpers_1.arrayBufferToString(credential.response.clientDataJSON);
var attestationResponse = credential.response;

@@ -344,3 +346,3 @@ var attestationObject = new Int8Array(attestationResponse.attestationObject).toString();

catch (error) {
return this.getErrorOutcome(error);
throw new Error(error.message);
}

@@ -356,5 +358,6 @@ };

FRWebAuthn.createAuthenticationPublicKey = function (metadata) {
var allowCredentials = metadata.allowCredentials, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, timeout = metadata.timeout;
var allowCredentials = metadata.allowCredentials, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, timeout = metadata.timeout, userVerification = metadata.userVerification;
var rpId = helpers_1.parseRelyingPartyId(relyingPartyId);
return __assign({ allowCredentials: helpers_1.parseCredentials(allowCredentials), challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer, timeout: timeout }, (rpId && { rpId: rpId }));
var allowCredentialsValue = helpers_1.parseCredentials(allowCredentials);
return __assign(__assign(__assign({ challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer, timeout: timeout }, (allowCredentialsValue && { allowCredentials: allowCredentialsValue })), (userVerification && { userVerification: userVerification })), (rpId && { rpId: rpId }));
};

@@ -371,26 +374,17 @@ /**

var pubKeyCredParams = helpers_1.parsePubKeyArray(pubKeyCredParamsString);
if (!pubKeyCredParams) {
if (!pubKeyCredParams || !pubKeyCredParams.length) {
throw new Error('Missing pubKeyCredParams');
}
var attestationPreference = metadata.attestationPreference, authenticatorSelection = metadata.authenticatorSelection, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, relyingPartyName = metadata.relyingPartyName, timeout = metadata.timeout, userId = metadata.userId, userName = metadata.userName;
var excludeCredentials = helpers_1.parseCredentials(metadata.excludeCredentials);
var attestationPreference = metadata.attestationPreference, authenticatorSelection = metadata.authenticatorSelection, challenge = metadata.challenge, relyingPartyId = metadata.relyingPartyId, relyingPartyName = metadata.relyingPartyName, timeout = metadata.timeout, userId = metadata.userId, userName = metadata.userName, displayName = metadata.displayName;
var rpId = helpers_1.parseRelyingPartyId(relyingPartyId);
var rp = __assign({ name: relyingPartyName }, (rpId && { id: rpId }));
return {
attestation: attestationPreference,
authenticatorSelection: JSON.parse(authenticatorSelection),
challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer,
pubKeyCredParams: pubKeyCredParams,
return __assign(__assign({ attestation: attestationPreference, authenticatorSelection: JSON.parse(authenticatorSelection), challenge: Uint8Array.from(atob(challenge), function (c) { return c.charCodeAt(0); }).buffer }, (excludeCredentials.length && { excludeCredentials: excludeCredentials })), { pubKeyCredParams: pubKeyCredParams,
rp: rp,
timeout: timeout,
user: {
displayName: userName,
timeout: timeout, user: {
displayName: displayName,
id: Int8Array.from(userId.split('').map(function (c) { return c.charCodeAt(0); })),
name: userName,
},
};
} });
};
FRWebAuthn.getErrorOutcome = function (error) {
var name = error.name ? error.name + ":" : '';
return enums_2.WebAuthnOutcome.Error + "::" + name + error.message;
};
return FRWebAuthn;

@@ -397,0 +391,0 @@ }());

@@ -51,2 +51,3 @@ import HiddenValueCallback from '../fr-auth/callbacks/hidden-value-callback';

challenge: string;
excludeCredentials: string;
pubKeyCredParams: string;

@@ -58,2 +59,3 @@ relyingPartyId: string;

userName: string;
displayName: string;
}

@@ -65,2 +67,3 @@ interface WebAuthnAuthenticationMetadata {

timeout: number;
userVerification: UserVerificationType;
}

@@ -67,0 +70,0 @@ interface WebAuthnCallbacks {

@@ -19,13 +19,18 @@ "use strict";

// e.g. `attestation: "none"`
var attestation = helpers_1.getIndexOne(text.match(/attestation:\s{0,}"(\w+)"/));
var attestation = helpers_1.getIndexOne(text.match(/attestation"{0,}:\s{0,}"(\w+)"/));
// e.g. `timeout: 60000`
var timeout = Number(helpers_1.getIndexOne(text.match(/timeout:\s{0,}(\d+)/)));
// e.g. `"userVerification":"preferred"`
var userVerification = helpers_1.getIndexOne(text.match(/"userVerification":\s{0,}"(\w+)"/));
var timeout = Number(helpers_1.getIndexOne(text.match(/timeout"{0,}:\s{0,}(\d+)/)));
// e.g. from 7.0: `"userVerification":"preferred"`
// e.g. from 6.5: `userVerification: "preferred"`
var userVerification = helpers_1.getIndexOne(text.match(/userVerification"{0,}:\s{0,}"(\w+)"/));
// e.g. `"requireResidentKey":true`
var requireResidentKey = helpers_1.getIndexOne(text.match(/requireResidentKey"{0,}:\s{0,}(\w+)/));
// e.g. `"authenticatorAttachment":"cross-platform"`
var authenticatorAttachment = helpers_1.getIndexOne(text.match(/authenticatorAttachment"{0,}:\s{0,}"([\w-]+)/));
// e.g. `rp: {\n id: \"https://user.example.com:3002\",\n name: \"ForgeRock\"\n }`
var rp = helpers_1.getIndexOne(text.match(/rp:\s{0,}{([^}]+)}/)).trim();
// e.g. `id: \"https://user.example.com:3002\"
var rpId = helpers_1.getIndexOne(rp.match(/id:\s{0,}"([^"]*)"/));
var rp = helpers_1.getIndexOne(text.match(/rp"{0,}:\s{0,}{([^}]+)}/)).trim();
// e.g. `id: \"example.com\"
var rpId = helpers_1.getIndexOne(rp.match(/id"{0,}:\s{0,}"([^"]*)"/));
// e.g. `name: \"ForgeRock\"`
var rpName = helpers_1.getIndexOne(rp.match(/name:\s{0,}"([^"]*)"/));
var rpName = helpers_1.getIndexOne(rp.match(/name"{0,}:\s{0,}"([^"]*)"/));
// e.g. `user: {\n id: Uint8Array.from(\"NTdhN...RiNjI5\",

@@ -35,13 +40,18 @@ // function (c) { return c.charCodeAt(0) }),\n

// displayName: \"57a5b4e4-...-a4f2e5d4b629\"\n }`
var user = helpers_1.getIndexOne(text.match(/user:\s{0,}{([^]{0,})},/)).trim();
var user = helpers_1.getIndexOne(text.match(/user"{0,}:\s{0,}{([^]{0,})},/)).trim();
// e.g `id: Uint8Array.from(\"NTdhN...RiNjI5\",`
var userId = helpers_1.getIndexOne(user.match(/id:\s{0,}Uint8Array.from\("([^"]+)"/));
var userId = helpers_1.getIndexOne(user.match(/id"{0,}:\s{0,}Uint8Array.from\("([^"]+)"/));
// e.g. `name: \"57a5b4e4-...-a4f2e5d4b629\",`
var userName = helpers_1.getIndexOne(user.match(/name:\s{0,}"([\d\w._-]+)"/));
var userName = helpers_1.getIndexOne(user.match(/name"{0,}:\s{0,}"([\d\w._-]+)"/));
// e.g. `displayName: \"57a5b4e4-...-a4f2e5d4b629\"`
var userDisplayName = helpers_1.getIndexOne(user.match(/displayName:\s{0,}"([\d\w._-]+)"/));
var userDisplayName = helpers_1.getIndexOne(user.match(/displayName"{0,}:\s{0,}"([\d\w\s.@_-]+)"/));
// e.g. `pubKeyCredParams: [
// { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 }
// ]`
var pubKeyCredParamsString = helpers_1.getIndexOne(text.match(/pubKeyCredParams:\s{0,}\[([^]+) ]/)).trim();
var pubKeyCredParamsString = helpers_1.getIndexOne(
// Capture the `pubKeyCredParams` without also matching `excludeCredentials` as well.
// `excludeCredentials` values are very similar to this property, so we need to make sure
// our last value doesn't end with "buffer", so we are only capturing objects that
// end in a digit and possibly a space.
text.match(/pubKeyCredParams"{0,}:\s{0,}\[([^]+\d\s?})\s?]/)).trim();
// e.g. `{ \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 }`

@@ -52,4 +62,11 @@ var pubKeyCredParams = helpers_1.parsePubKeyArray(pubKeyCredParamsString);

}
// e.g. `excludeCredentials: [{
// \"type\": \"public-key\", \"id\": new Int8Array([-18, 69, -99, 82, 38, -66]).buffer },
// { \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, 56, -32, 91]).buffer }],\n`
var excludeCredentialsString = helpers_1.getIndexOne(text.match(/excludeCredentials"{0,}:\s{0,}\[([^]+)\s{0,}]/)).trim();
// e.g. `{ \"type\": \"public-key\", \"id\": new Int8Array([-18, 69, -99, 82, 38, -66]).buffer },
// { \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, 56, -32, 91]).buffer }`
var excludeCredentials = helpers_1.parseCredentials(excludeCredentialsString);
// e.g. `challenge: new Int8Array([87, -95, 18, ... -3, 49, 12, 81]).buffer,`
var challengeArr = helpers_1.ensureArray(text.match(/challenge:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
var challengeArr = helpers_1.ensureArray(text.match(/challenge"{0,}:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[87, -95, 18, ... -3, 49, 12, 81]`

@@ -59,24 +76,11 @@ var challengeJSON = JSON.parse(challengeArr[2]);

var challenge = new Int8Array(challengeJSON).buffer;
return {
attestation: attestation,
authenticatorSelection: {
userVerification: userVerification,
},
challenge: challenge,
excludeCredentials: [],
pubKeyCredParams: pubKeyCredParams,
rp: {
id: rpId,
name: rpName,
},
timeout: timeout,
user: {
return __assign(__assign({ attestation: attestation, authenticatorSelection: __assign(__assign({ userVerification: userVerification }, (authenticatorAttachment && { authenticatorAttachment: authenticatorAttachment })), (requireResidentKey === 'true' && { requireResidentKey: !!requireResidentKey })), challenge: challenge }, (excludeCredentials.length && { excludeCredentials: excludeCredentials })), { pubKeyCredParams: pubKeyCredParams, rp: __assign({ name: rpName }, (rpId && { id: rpId })), timeout: timeout, user: {
displayName: userDisplayName,
id: txtEncoder.encode(userId),
name: userName,
},
};
} });
}
exports.parseWebAuthnRegisterText = parseWebAuthnRegisterText;
function parseWebAuthnAuthenticateText(text) {
var allowCredentials;
// e.g. `allowCredentials: [

@@ -86,24 +90,28 @@ // { \"type\": \"public-key\",

// ]`
var allowCredentialsText = helpers_1.getIndexOne(text.match(/allowCredentials:\s{0,}\[([^]+)\s{0,}]/)).trim();
// Splitting objects in array in case the user has multiple keys
var allowCredentialArr = allowCredentialsText.split('},') || [allowCredentialsText];
// Iterating over array of substrings
var allowCredentials = allowCredentialArr.map(function (str) {
// e.g. `{ \"type\": \"public-key\",
var type = helpers_1.getIndexOne(str.match(/"type":\s{0,}"([\w-]+)"/));
// e.g. \"id\": new Int8Array([-107, 93, 68, -67, ... -19, 7, 4]).buffer
var idArr = helpers_1.ensureArray(text.match(/"id":\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[-107, 93, 68, -67, ... -19, 7, 4]`
var idJSON = JSON.parse(idArr[2]);
// e.g. [-107, 93, 68, -67, ... -19, 7, 4]
var id = new Int8Array(idJSON).buffer;
return {
type: type,
id: id,
};
});
var allowCredentialsText = helpers_1.getIndexOne(text.match(/allowCredentials"{0,}:\s{0,}\[([^]+)\s{0,}]/)).trim();
// e.g. `"userVerification":"preferred"`
var userVerification = helpers_1.getIndexOne(text.match(/userVerification"{0,}:\s{0,}"(\w+)"/));
if (allowCredentialsText) {
// Splitting objects in array in case the user has multiple keys
var allowCredentialArr = allowCredentialsText.split('},') || [allowCredentialsText];
// Iterating over array of substrings
allowCredentials = allowCredentialArr.map(function (str) {
// e.g. `{ \"type\": \"public-key\",
var type = helpers_1.getIndexOne(str.match(/type"{0,}:\s{0,}"([\w-]+)"/));
// e.g. \"id\": new Int8Array([-107, 93, 68, -67, ... -19, 7, 4]).buffer
var idArr = helpers_1.ensureArray(str.match(/id"{0,}:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[-107, 93, 68, -67, ... -19, 7, 4]`
var idJSON = JSON.parse(idArr[2]);
// e.g. [-107, 93, 68, -67, ... -19, 7, 4]
var id = new Int8Array(idJSON).buffer;
return {
type: type,
id: id,
};
});
}
// e.g. `timeout: 60000`
var timeout = Number(helpers_1.getIndexOne(text.match(/timeout:\s{0,}(\d+)/)));
var timeout = Number(helpers_1.getIndexOne(text.match(/timeout"{0,}:\s{0,}(\d+)/)));
// e.g. `challenge: new Int8Array([87, -95, 18, ... -3, 49, 12, 81]).buffer,`
var challengeArr = helpers_1.ensureArray(text.match(/challenge:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
var challengeArr = helpers_1.ensureArray(text.match(/challenge"{0,}:\s{0,}new\s{0,}(Uint|Int)8Array\(([^\)]+)/));
// e.g. `[87, -95, 18, ... -3, 49, 12, 81]`

@@ -113,9 +121,8 @@ var challengeJSON = JSON.parse(challengeArr[2]);

var challenge = new Int8Array(challengeJSON).buffer;
// e.g. `rpId: "user.example.com",`
var rpId = helpers_1.getIndexOne(text.match(/rpId:\s{0,}\[([^]+)\s{0,}]/));
return __assign({ allowCredentials: allowCredentials,
challenge: challenge,
timeout: timeout }, (rpId && { id: rpId }));
// e.g. `rpId: \"example.com\"`
var rpId = helpers_1.getIndexOne(text.match(/rpId"{0,}:\s{0,}\\{0,}"([^"\\]*)/));
return __assign(__assign(__assign({ challenge: challenge,
timeout: timeout }, (allowCredentials && { allowCredentials: allowCredentials })), (userVerification && { userVerification: userVerification })), (rpId && { rpId: rpId }));
}
exports.parseWebAuthnAuthenticateText = parseWebAuthnAuthenticateText;
//# sourceMappingURL=script-parser.js.map

@@ -1,12 +0,51 @@

declare const authenticateInput = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const authenticateOuput: {
allowCredentials: {
declare const authenticateInputWithRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n rpId: \"example.com\",\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ type: \"public-key\", id: new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const authenticateInputWithRpidAllowCredentialsAndQuotes = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n \"rpId\": \"example.com\",\n \"challenge\": new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n \"timeout\": 60000,\n \"allowCredentials\": [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const authenticateInputWithoutRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerInputWithRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"bob_lee-tester@me.co.uk\"\n },\n pubKeyCredParams: [ { type: \"public-key\", alg: -257 }, { type: \"public-key\", alg: -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\n userVerification: \"preferred\"\n authenticatorAttachment:\"cross-platform\"\n }\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerInputWithRpidAndQuotes = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\n if (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n }\n\n var publicKey = {\n \"challenge\": new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n \"rp\": {\n \"id\": \"example.com\",\n \"name\": \"ForgeRock\"\n },\n // User:\n \"user\": {\n \"id\": Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n \"name\": \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n \"displayName\": \"bob_lee-tester@me.co.uk\"\n },\n \"pubKeyCredParams\": [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n \"attestation\": \"none\",\n \"timeout\": 60000,\n \"excludeCredentials\": [],\n \"authenticatorSelection\": {\"userVerification\":\"preferred\",\"authenticatorAttachment\":\"cross-platform\"}\n };\n\n navigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutputWithRpid: {
attestation: string;
authenticatorSelection: {
userVerification: string;
authenticatorAttachment: string;
};
challenge: never[];
pubKeyCredParams: {
type: string;
alg: number;
}[];
rp: {
id: string;
name: string;
};
timeout: number;
user: {
displayName: string;
id: never[];
name: string;
};
};
declare const registerInputWithoutRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutputWithoutRpid: {
attestation: string;
authenticatorSelection: {
userVerification: string;
};
challenge: never[];
pubKeyCredParams: {
type: string;
alg: number;
}[];
challenge: never[];
rp: {
name: string;
};
timeout: number;
user: {
displayName: string;
id: never[];
name: string;
};
};
declare const registerInput = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"user.example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutput: {
declare const registerInputWithExcludeCreds = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([49, -96, -107, 113, 106, 5, 115, 22, 68, 121, -85, -27, 8, -58, -113, 127, -105, -37, -10, -12, -58, -25, 29, -82, -18, 69, -99, 125, 33, 82, 38, -66, -27, -128, -91, -86, 87, 68, 94, 0, -78, 70, -11, -70, -14, -53, 38, -60, 46, 27, 66, 46, 21, -125, -70, 123, -46, -124, 86, -2, 102, 70, -52, 54]).buffer },{ \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, -123, -21, 127, 76, -120, 90, -112, -5, 54, 105, 93, 82, -104, -79, 107, -69, -3, -113, -94, -59, -4, 126, -33, 117, 32, -44, 122, -97, 8, -112, 105, -96, 96, 90, 44, -128, -121, 107, 79, -98, -68, -93, 11, -105, -47, 102, 13, 110, 84, 59, -91, -30, 37, -3, -22, 39, 111, -10, 87, -50, -35]).buffer }],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
declare const registerOutputWithExcludeCreds: {
attestation: string;

@@ -17,3 +56,6 @@ authenticatorSelection: {

challenge: never[];
excludeCredentials: never[];
excludeCredentials: {
type: string;
id: string;
}[];
pubKeyCredParams: {

@@ -24,3 +66,2 @@ type: string;

rp: {
id: string;
name: string;

@@ -35,2 +76,2 @@ };

};
export { authenticateInput, authenticateOuput, registerInput, registerOutput };
export { authenticateInputWithRpidAndAllowCredentials, authenticateInputWithRpidAllowCredentialsAndQuotes, authenticateInputWithoutRpidAndAllowCredentials, registerInputWithRpid, registerInputWithRpidAndQuotes, registerOutputWithRpid, registerInputWithoutRpid, registerOutputWithoutRpid, registerInputWithExcludeCreds, registerOutputWithExcludeCreds, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerOutput = exports.registerInput = exports.authenticateOuput = exports.authenticateInput = void 0;
exports.registerOutputWithExcludeCreds = exports.registerInputWithExcludeCreds = exports.registerOutputWithoutRpid = exports.registerInputWithoutRpid = exports.registerOutputWithRpid = exports.registerInputWithRpidAndQuotes = exports.registerInputWithRpid = exports.authenticateInputWithoutRpidAndAllowCredentials = exports.authenticateInputWithRpidAllowCredentialsAndQuotes = exports.authenticateInputWithRpidAndAllowCredentials = void 0;
/* eslint-disable max-len */
var authenticateInput = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.authenticateInput = authenticateInput;
// Currently not used
var authenticateOuput = {
allowCredentials: [
{
type: 'public-key',
id: [
/* don't directly test */
],
},
var authenticateInputWithRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n rpId: \"example.com\",\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n allowCredentials: [{ type: \"public-key\", id: new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.authenticateInputWithRpidAndAllowCredentials = authenticateInputWithRpidAndAllowCredentials;
var authenticateInputWithRpidAllowCredentialsAndQuotes = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n \"rpId\": \"example.com\",\n \"challenge\": new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n \"timeout\": 60000,\n \"allowCredentials\": [{ \"type\": \"public-key\", \"id\": new Int8Array([-107, 93, 68, -67, -5, 107, 18, 16, -25, -30, 80, 103, -75, -53, -2, -95, 102, 42, 47, 126, -1, 85, 93, 45, -85, 8, -108, 107, 47, -25, 66, 12, -96, 81, 104, -127, 26, -59, -69, -23, 75, 89, 58, 124, -93, 4, 28, -128, 121, 35, 39, 103, -86, -86, 123, -67, -7, -4, 79, -49, 127, -19, 7, 4]).buffer }]\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.authenticateInputWithRpidAllowCredentialsAndQuotes = authenticateInputWithRpidAllowCredentialsAndQuotes;
var authenticateInputWithoutRpidAndAllowCredentials = "/*\n* Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n*\n* Use of this code requires a commercial software license with ForgeRock AS.\n* or with one of its affiliates. All use shall be exclusively subject\n* to such license between the licensee and ForgeRock AS.\n*/\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar options = {\n challenge: new Int8Array([14, 126, -110, -74, 64, -66, 20, -56, -40, -28, 116, -61, -128, -20, 72, 24, 42, 79, -105, 94, -84, -12, -17, -97, 105, -31, -30, 92, 55, 67, -83, 65]).buffer,\n timeout: 60000,\n};\n\nnavigator.credentials.get({ \"publicKey\" : options })\n .then(function (assertion) {\n var clientData = String.fromCharCode.apply(null, new Uint8Array(assertion.response.clientDataJSON));\n var authenticatorData = new Int8Array(assertion.response.authenticatorData).toString();\n var signature = new Int8Array(assertion.response.signature).toString();\n var rawId = assertion.id;\n var userHandle = String.fromCharCode.apply(null, new Uint8Array(assertion.response.userHandle));\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + authenticatorData + \"::\" + signature + \"::\" + rawId + \"::\" + userHandle;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.authenticateInputWithoutRpidAndAllowCredentials = authenticateInputWithoutRpidAndAllowCredentials;
var registerInputWithRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"bob_lee-tester@me.co.uk\"\n },\n pubKeyCredParams: [ { type: \"public-key\", alg: -257 }, { type: \"public-key\", alg: -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\n userVerification: \"preferred\"\n authenticatorAttachment:\"cross-platform\"\n }\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.registerInputWithRpid = registerInputWithRpid;
var registerInputWithRpidAndQuotes = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\n if (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n }\n\n var publicKey = {\n \"challenge\": new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n \"rp\": {\n \"id\": \"example.com\",\n \"name\": \"ForgeRock\"\n },\n // User:\n \"user\": {\n \"id\": Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n \"name\": \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n \"displayName\": \"bob_lee-tester@me.co.uk\"\n },\n \"pubKeyCredParams\": [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n \"attestation\": \"none\",\n \"timeout\": 60000,\n \"excludeCredentials\": [],\n \"authenticatorSelection\": {\"userVerification\":\"preferred\",\"authenticatorAttachment\":\"cross-platform\"}\n };\n\n navigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.registerInputWithRpidAndQuotes = registerInputWithRpidAndQuotes;
var registerOutputWithRpid = {
attestation: 'none',
authenticatorSelection: {
userVerification: 'preferred',
authenticatorAttachment: 'cross-platform',
},
challenge: [
/* don't directly test */
],
pubKeyCredParams: [
{ type: 'public-key', alg: -257 },
{ type: 'public-key', alg: -7 },
],
rp: { id: 'example.com', name: 'ForgeRock' },
timeout: 60000,
user: {
displayName: 'bob_lee-tester@me.co.uk',
id: [
/* don't directly test */
],
name: '57a5b4e4-6999-4b45-bf86-a4f2e5d4b629',
},
};
exports.registerOutputWithRpid = registerOutputWithRpid;
var registerInputWithoutRpid = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.registerInputWithoutRpid = registerInputWithoutRpid;
var registerOutputWithoutRpid = {
attestation: 'none',
authenticatorSelection: { userVerification: 'preferred' },
challenge: [
/* don't directly test */
],
pubKeyCredParams: [
{ type: 'public-key', alg: -257 },
{ type: 'public-key', alg: -7 },
],
rp: { name: 'ForgeRock' },
timeout: 60000,
user: {
displayName: 'Bob Tester',
id: [
/* don't directly test */
],
name: '57a5b4e4-6999-4b45-bf86-a4f2e5d4b629',
},
};
exports.authenticateOuput = authenticateOuput;
/* eslint-disable max-len */
var registerInput = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n id: \"user.example.com\",\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.registerInput = registerInput;
var registerOutput = {
exports.registerOutputWithoutRpid = registerOutputWithoutRpid;
var registerInputWithExcludeCreds = "/*\n * Copyright 2018-2020 ForgeRock AS. All Rights Reserved\n *\n * Use of this code requires a commercial software license with ForgeRock AS.\n * or with one of its affiliates. All use shall be exclusively subject\n * to such license between the licensee and ForgeRock AS.\n */\n\nif (!window.PublicKeyCredential) {\n document.getElementById('webAuthnOutcome').value = \"unsupported\";\n document.getElementById(\"loginButton_0\").click();\n}\n\nvar publicKey = {\n challenge: new Int8Array([102, -15, -36, -101, -95, 10, -20, 39, 29, 70, 122, 25, 53, 83, 72, -38, 83, -92, 31, -30, 26, -94, 92, -94, -83, 7, 82, -66, -125, -95, -4, -75]).buffer,\n // Relying Party:\n rp: {\n name: \"ForgeRock\"\n },\n // User:\n user: {\n id: Uint8Array.from(\"NTdhNWI0ZTQtNjk5OS00YjQ1LWJmODYtYTRmMmU1ZDRiNjI5\", function (c) { return c.charCodeAt(0) }),\n name: \"57a5b4e4-6999-4b45-bf86-a4f2e5d4b629\",\n displayName: \"Bob Tester\"\n },\n pubKeyCredParams: [ { \"type\": \"public-key\", \"alg\": -257 }, { \"type\": \"public-key\", \"alg\": -7 } ],\n attestation: \"none\",\n timeout: 60000,\n excludeCredentials: [{ \"type\": \"public-key\", \"id\": new Int8Array([49, -96, -107, 113, 106, 5, 115, 22, 68, 121, -85, -27, 8, -58, -113, 127, -105, -37, -10, -12, -58, -25, 29, -82, -18, 69, -99, 125, 33, 82, 38, -66, -27, -128, -91, -86, 87, 68, 94, 0, -78, 70, -11, -70, -14, -53, 38, -60, 46, 27, 66, 46, 21, -125, -70, 123, -46, -124, 86, -2, 102, 70, -52, 54]).buffer },{ \"type\": \"public-key\", \"id\": new Int8Array([64, 17, -15, -123, -21, 127, 76, -120, 90, -112, -5, 54, 105, 93, 82, -104, -79, 107, -69, -3, -113, -94, -59, -4, 126, -33, 117, 32, -44, 122, -97, 8, -112, 105, -96, 96, 90, 44, -128, -121, 107, 79, -98, -68, -93, 11, -105, -47, 102, 13, 110, 84, 59, -91, -30, 37, -3, -22, 39, 111, -10, 87, -50, -35]).buffer }],\n authenticatorSelection: {\"userVerification\":\"preferred\"}\n};\n\nnavigator.credentials.create({publicKey: publicKey})\n .then(function (newCredentialInfo) {\n var rawId = newCredentialInfo.id;\n var clientData = String.fromCharCode.apply(null, new Uint8Array(newCredentialInfo.response.clientDataJSON));\n var keyData = new Int8Array(newCredentialInfo.response.attestationObject).toString();\n document.getElementById('webAuthnOutcome').value = clientData + \"::\" + keyData + \"::\" + rawId;\n document.getElementById(\"loginButton_0\").click();\n }).catch(function (err) {\n document.getElementById('webAuthnOutcome').value = \"ERROR\" + \"::\" + err;\n document.getElementById(\"loginButton_0\").click();\n });";
exports.registerInputWithExcludeCreds = registerInputWithExcludeCreds;
var registerOutputWithExcludeCreds = {
attestation: 'none',

@@ -32,3 +70,12 @@ authenticatorSelection: { userVerification: 'preferred' },

],
excludeCredentials: [],
excludeCredentials: [
{
type: 'public-key',
id: 'Do not directly test',
},
{
type: 'public-key',
id: 'Do not directly test',
},
],
pubKeyCredParams: [

@@ -38,6 +85,6 @@ { type: 'public-key', alg: -257 },

],
rp: { id: 'user.example.com', name: 'ForgeRock' },
rp: { name: 'ForgeRock' },
timeout: 60000,
user: {
displayName: '57a5b4e4-6999-4b45-bf86-a4f2e5d4b629',
displayName: 'Bob Tester',
id: [

@@ -49,3 +96,3 @@ /* don't directly test */

};
exports.registerOutput = registerOutput;
exports.registerOutputWithExcludeCreds = registerOutputWithExcludeCreds;
//# sourceMappingURL=script-text.mock.data.js.map

@@ -64,3 +64,3 @@ "use strict";

var timeout_1 = require("../util/timeout");
var util_1 = require("./util");
var helpers_1 = require("./helpers");
var middleware_1 = __importDefault(require("../util/middleware"));

@@ -108,3 +108,3 @@ /**

hasIG = false;
if (!util_1.newTokenRequired(res, options.requiresNewToken)) return [3 /*break*/, 3];
if (!helpers_1.newTokenRequired(res, options.requiresNewToken)) return [3 /*break*/, 3];
return [4 /*yield*/, this._request(options, true)];

@@ -116,10 +116,10 @@ case 2:

if (!(options.authorization && options.authorization.handleStep)) return [3 /*break*/, 18];
if (!(res.redirected && util_1.examineForIGAuthz(res))) return [3 /*break*/, 4];
if (!(res.redirected && helpers_1.examineForIGAuthz(res))) return [3 /*break*/, 4];
hasIG = true;
authorizationJSON = util_1.normalizeIGJSON(res);
authorizationJSON = helpers_1.normalizeIGJSON(res);
return [3 /*break*/, 7];
case 4: return [4 /*yield*/, util_1.examineForRESTAuthz(res)];
case 4: return [4 /*yield*/, helpers_1.examineForRESTAuthz(res)];
case 5:
if (!_c.sent()) return [3 /*break*/, 7];
return [4 /*yield*/, util_1.normalizeRESTJSON(res)];
return [4 /*yield*/, helpers_1.normalizeRESTJSON(res)];
case 6:

@@ -131,3 +131,3 @@ authorizationJSON = _c.sent();

_a = config_1.default.get(options.authorization.config), realmPath = _a.realmPath, serverConfig = _a.serverConfig;
authzOptions = util_1.buildAuthzOptions(authorizationJSON, serverConfig.baseUrl, options.timeout, realmPath, serverConfig.paths);
authzOptions = helpers_1.buildAuthzOptions(authorizationJSON, serverConfig.baseUrl, options.timeout, realmPath, serverConfig.paths);
url = new URL(authzOptions.url);

@@ -145,3 +145,3 @@ type = url.searchParams.get('authIndexType');

initialStep = _c.sent();
return [4 /*yield*/, util_1.isAuthzStep(initialStep)];
return [4 /*yield*/, helpers_1.isAuthzStep(initialStep)];
case 9:

@@ -151,3 +151,3 @@ if (!(_c.sent())) {

}
if (!util_1.hasAuthzAdvice(authorizationJSON)) {
if (!helpers_1.hasAuthzAdvice(authorizationJSON)) {
throw new Error("Error: Transactional or Service Advice is empty.");

@@ -177,7 +177,7 @@ }

// Update URL with IDs and tokens for IG
options.url = util_1.addAuthzInfoToURL(options.url, authorizationJSON.advices, tokens);
options.url = helpers_1.addAuthzInfoToURL(options.url, authorizationJSON.advices, tokens);
}
else {
// Update headers with IDs and tokens for REST API
options.init.headers = util_1.addAuthzInfoToHeaders(options.init, authorizationJSON.advices, tokens);
options.init.headers = helpers_1.addAuthzInfoToHeaders(options.init, authorizationJSON.advices, tokens);
}

@@ -184,0 +184,0 @@ return [4 /*yield*/, this._request(options, false)];

@@ -20,2 +20,3 @@ import Auth from './auth';

import ReCaptchaCallback from './fr-auth/callbacks/recaptcha-callback';
import SuspendedTextOutputCallback from './fr-auth/callbacks/suspended-text-output-callback';
import TermsAndConditionsCallback from './fr-auth/callbacks/terms-and-conditions-callback';

@@ -33,2 +34,3 @@ import TextOutputCallback from './fr-auth/callbacks/text-output-callback';

import defaultMessageCreator from './fr-policy/message-creator';
import FRRecoveryCodes from './fr-recovery-codes';
import FRUI from './fr-ui';

@@ -48,2 +50,2 @@ import FRUser from './fr-user';

import LocalStorage from './util/storage';
export { defaultMessageCreator, nonce, AttributeInputCallback, Auth, AuthResponse, Callback, CallbackContainer, CallbackType, ChoiceCallback, Config, ConfigOptions, ConfirmationCallback, Deferred, DeviceProfileCallback, Dispatcher, ErrorCode, FailureDetail, FRAuth, FRCallback, FRCallbackFactory, FRDevice, FREvent, FRLoginFailure, FRLoginSuccess, FRPolicy, FRStep, FRStepHandler, FRUI, FRUser, FRWebAuthn, GetAuthorizationUrlOptions, GetOAuth2TokensOptions, GetTokensOptions, HiddenValueCallback, HttpClient, KbaCreateCallback, Listener, LocalStorage, MessageCreator, MetadataCallback, NameCallback, NameValue, OAuth2Client, OAuth2Tokens, PasswordCallback, PKCE, PolicyKey, PolicyRequirement, PollingWaitCallback, ProcessedPropertyError, ReCaptchaCallback, RelyingParty, ResponseType, SessionManager, Step, StepDetail, StepType, TermsAndConditionsCallback, TextOutputCallback, TokenManager, Tokens, TokenStorage, UserManager, ValidatedCreatePasswordCallback, ValidatedCreateUsernameCallback, ValidConfigOptions, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnOutcome, WebAuthnRegistrationMetadata, WebAuthnStepType, };
export { defaultMessageCreator, nonce, AttributeInputCallback, Auth, AuthResponse, Callback, CallbackContainer, CallbackType, ChoiceCallback, Config, ConfigOptions, ConfirmationCallback, Deferred, DeviceProfileCallback, Dispatcher, ErrorCode, FailureDetail, FRAuth, FRCallback, FRCallbackFactory, FRDevice, FREvent, FRLoginFailure, FRLoginSuccess, FRPolicy, FRRecoveryCodes, FRStep, FRStepHandler, FRUI, FRUser, FRWebAuthn, GetAuthorizationUrlOptions, GetOAuth2TokensOptions, GetTokensOptions, HiddenValueCallback, HttpClient, KbaCreateCallback, Listener, LocalStorage, MessageCreator, MetadataCallback, NameCallback, NameValue, OAuth2Client, OAuth2Tokens, PasswordCallback, PKCE, PolicyKey, PolicyRequirement, PollingWaitCallback, ProcessedPropertyError, ReCaptchaCallback, RelyingParty, ResponseType, SessionManager, Step, StepDetail, StepType, SuspendedTextOutputCallback, TermsAndConditionsCallback, TextOutputCallback, TokenManager, Tokens, TokenStorage, UserManager, ValidatedCreatePasswordCallback, ValidatedCreateUsernameCallback, ValidConfigOptions, WebAuthnAuthenticationMetadata, WebAuthnCallbacks, WebAuthnOutcome, WebAuthnRegistrationMetadata, WebAuthnStepType, };

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.WebAuthnStepType = exports.WebAuthnOutcome = exports.ValidatedCreateUsernameCallback = exports.ValidatedCreatePasswordCallback = exports.UserManager = exports.TokenStorage = exports.TokenManager = exports.TextOutputCallback = exports.TermsAndConditionsCallback = exports.StepType = exports.SessionManager = exports.ResponseType = exports.ReCaptchaCallback = exports.PollingWaitCallback = exports.PolicyKey = exports.PKCE = exports.PasswordCallback = exports.OAuth2Client = exports.NameCallback = exports.MetadataCallback = exports.LocalStorage = exports.KbaCreateCallback = exports.HttpClient = exports.HiddenValueCallback = exports.FRWebAuthn = exports.FRUser = exports.FRStep = exports.FRPolicy = exports.FRLoginSuccess = exports.FRLoginFailure = exports.FRDevice = exports.FRCallback = exports.FRAuth = exports.ErrorCode = exports.Dispatcher = exports.DeviceProfileCallback = exports.Deferred = exports.ConfirmationCallback = exports.Config = exports.ChoiceCallback = exports.CallbackType = exports.Auth = exports.AttributeInputCallback = exports.nonce = exports.defaultMessageCreator = void 0;
exports.WebAuthnStepType = exports.WebAuthnOutcome = exports.ValidatedCreateUsernameCallback = exports.ValidatedCreatePasswordCallback = exports.UserManager = exports.TokenStorage = exports.TokenManager = exports.TextOutputCallback = exports.TermsAndConditionsCallback = exports.SuspendedTextOutputCallback = exports.StepType = exports.SessionManager = exports.ResponseType = exports.ReCaptchaCallback = exports.PollingWaitCallback = exports.PolicyKey = exports.PKCE = exports.PasswordCallback = exports.OAuth2Client = exports.NameCallback = exports.MetadataCallback = exports.LocalStorage = exports.KbaCreateCallback = exports.HttpClient = exports.HiddenValueCallback = exports.FRWebAuthn = exports.FRUser = exports.FRStep = exports.FRRecoveryCodes = exports.FRPolicy = exports.FRLoginSuccess = exports.FRLoginFailure = exports.FRDevice = exports.FRCallback = exports.FRAuth = exports.ErrorCode = exports.Dispatcher = exports.DeviceProfileCallback = exports.Deferred = exports.ConfirmationCallback = exports.Config = exports.ChoiceCallback = exports.CallbackType = exports.Auth = exports.AttributeInputCallback = exports.nonce = exports.defaultMessageCreator = void 0;
var auth_1 = __importDefault(require("./auth"));

@@ -62,2 +62,4 @@ exports.Auth = auth_1.default;

exports.ReCaptchaCallback = recaptcha_callback_1.default;
var suspended_text_output_callback_1 = __importDefault(require("./fr-auth/callbacks/suspended-text-output-callback"));
exports.SuspendedTextOutputCallback = suspended_text_output_callback_1.default;
var terms_and_conditions_callback_1 = __importDefault(require("./fr-auth/callbacks/terms-and-conditions-callback"));

@@ -88,2 +90,4 @@ exports.TermsAndConditionsCallback = terms_and_conditions_callback_1.default;

exports.defaultMessageCreator = message_creator_1.default;
var fr_recovery_codes_1 = __importDefault(require("./fr-recovery-codes"));
exports.FRRecoveryCodes = fr_recovery_codes_1.default;
var fr_user_1 = __importDefault(require("./fr-user"));

@@ -90,0 +94,0 @@ exports.FRUser = fr_user_1.default;

@@ -69,2 +69,3 @@ "use strict";

case 0:
console.warn('Deprecation warning: this `getAuthorizeUrl` method will be renamed in v3.');
_a = index_1.default.get(options), serverConfig = _a.serverConfig, clientId = _a.clientId, redirectUri = _a.redirectUri, scope = _a.scope;

@@ -71,0 +72,0 @@ requestParams = {

@@ -74,3 +74,2 @@ "use strict";

var token_storage_1 = __importDefault(require("../token-storage"));
var nonce_1 = __importDefault(require("../util/nonce"));
var pkce_1 = __importDefault(require("../util/pkce"));

@@ -104,3 +103,3 @@ var url_1 = require("../util/url");

verifier = pkce_1.default.createVerifier();
state = nonce_1.default()().toString();
state = pkce_1.default.createState();
authorizeUrlOptions = __assign(__assign({}, options), { responseType: oauth2_client_1.ResponseType.Code, state: state, verifier: verifier });

@@ -107,0 +106,0 @@ return [4 /*yield*/, oauth2_client_1.default.getAuthorizeUrl(authorizeUrlOptions)];

@@ -10,2 +10,3 @@ "use strict";

if (length === void 0) { length = 15; }
console.warn('Deprecation warning: the `nonce` method will be removed in v3.');
var last = -1;

@@ -12,0 +13,0 @@ var repeat = 0;

/**
* Helper class for generating verifier and challenge strings used for
* Helper class for generating verifier, challenge and state strings used for
* Proof Key for Code Exchange (PKCE).

@@ -7,7 +7,9 @@ */

/**
* Creates a random state.
*/
static createState(): string;
/**
* Creates a random verifier.
*
* @param size The length of the verifier (default 32 characters)
*/
static createVerifier(size?: number): string;
static createVerifier(num?: number): string;
/**

@@ -31,3 +33,9 @@ * Creates a SHA-256 hash of the verifier.

static sha256(value: string): Promise<Uint8Array>;
/**
* Creates a random string.
*
* @param size The number for entropy (default: 32)
*/
private static createRandomString;
}
export default PKCE;

@@ -40,3 +40,3 @@ "use strict";

/**
* Helper class for generating verifier and challenge strings used for
* Helper class for generating verifier, challenge and state strings used for
* Proof Key for Code Exchange (PKCE).

@@ -48,12 +48,15 @@ */

/**
* Creates a random state.
*/
PKCE.createState = function () {
return this.createRandomString(16);
};
/**
* Creates a random verifier.
*
* @param size The length of the verifier (default 32 characters)
*/
PKCE.createVerifier = function (size) {
if (size === void 0) { size = 32; }
var array = new Uint8Array(size);
window.crypto.getRandomValues(array);
var verifier = this.base64UrlEncode(array);
return verifier;
PKCE.createVerifier = function (num) {
if (num) {
console.warn('Deprecation warning: the parameter for `createVerifier` will be removed in v3');
}
return this.createRandomString(num || 32);
};

@@ -111,2 +114,13 @@ /**

};
/**
* Creates a random string.
*
* @param size The number for entropy (default: 32)
*/
PKCE.createRandomString = function (num) {
if (num === void 0) { num = 32; }
var random = new Uint8Array(num);
window.crypto.getRandomValues(random);
return btoa(random.join('')).replace(/[^a-zA-Z0-9]+/, '');
};
return PKCE;

@@ -113,0 +127,0 @@ }());

{
"name": "@forgerock/javascript-sdk",
"version": "2.0.1",
"version": "2.1.0-rc1",
"description": "ForgeRock JavaScript SDK",

@@ -17,4 +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",
"certs:make": "sh ./bin/create_certs.sh",
"clean:all": "npm run clean && shx rm -rf node_modules package-lock.json && git clean -fX -e '!*.pem'",
"docs": "typedoc",

@@ -24,10 +23,10 @@ "docs:watch": "watch 'npm run docs' ./src",

"prepublishOnly": "npm run clean:all && npm i && npm run build && npm t",
"start:e2e": "http-server tests/e2e/app -c1 -p 8443 --ssl --cert tests/e2e/certs/samples.crt --key tests/e2e/certs/samples.key",
"start:server": "APP_PORT=8443 SERVER_PORT=9443 node tests/e2e/server/index.mjs",
"start:server:live": "LIVE=true APP_PORT=8443 SERVER_PORT=9443 node tests/e2e/server/index.mjs",
"start:samples": "http-server samples -c1 -p 8443 --ssl --cert tests/e2e/certs/samples.crt --key tests/e2e/certs/samples.key",
"start:e2e": "http-server tests/e2e/app -c1 -p 8443 --ssl --cert example.com+5.pem --key example.com+5-key.pem",
"start:server": "node tests/e2e/server/index.mjs",
"start:server:live": "LIVE=true node tests/e2e/server/index.mjs",
"start:samples": "http-server samples -c1 -p 8443 --ssl --cert example.com+5.pem --key example.com+5-key.pem",
"test": "npm run test:unit && npm run test:integration && npm run test:e2e",
"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:e2e:live": "LIVE=true jest --testMatch='<rootDir>/tests/e2e/**/*.lc.test.ts' --config=./tests/jest.e2e.config.js",
"test:integration": "jest --testMatch='<rootDir>/tests/integration/**/*.test.ts' --config=./tests/jest.basic.config.js",

@@ -85,2 +84,3 @@ "test:unit": "jest --testMatch='<rootDir>/src/**/*.test.ts' --config=./tests/jest.basic.config.js --env=./tests/jest.env.config.js",

"util": "^0.12.3",
"uuid": "^8.3.0",
"watch": "^1.0.2",

@@ -87,0 +87,0 @@ "webpack": "^4.42.1",

@@ -10,3 +10,3 @@ [![npm (scoped)](https://img.shields.io/npm/v/@forgerock/javascript-sdk?color=%23f46200&label=Version&style=flat-square)](CHANGELOG.md)

<p align="center">
<a href="./blob/master/CHANGELOG.md">Change Log</a>
<a href="https://github.com/ForgeRock/forgerock-javascript-sdk/blob/master/CHANGELOG.md">Change Log</a>
·

@@ -58,5 +58,7 @@ <a href="#support">Support</a>

See [Enabling CORS Support](https://sdks.forgerock.com/js/01_prepare-am/#enabling-cors-support) in the Documentation.
2. Create an authentication tree in AM.
See [Creating a User Authentication Tree](https://sdks.forgerock.com/js/01_prepare-am/#creating-a-user-authentication-tree) in the Documentation.
3. Clone this repo:

@@ -81,14 +83,26 @@

6. Open `samples/custom-ui/index.html` and edit the configuration values to match your AM instance.
7. Serve the `samples` directory by using a simple HTTP server, for example:
`npm run start:samples`
8. Edit your `/etc/hosts` file to point your localhost to `sdkapp.example.com`
8. In a [supported web browser](#requirements), navigate to `https://sdkapp.example.com:8443`, and then click
7. This SDK requires HTTPS (secure protocol) which means security (SSL/TLS) certificates are necessary. For local testing and development, it's common to generate your own self-signed certificates. You're free to use any method to do this, but if you need assistance in generating your own certs, the following can be helpful:
- Using [this utility (`mkcert`) can help simplify the process of creating trusted certs](https://github.com/FiloSottile/mkcert)
- After following `mkcert`'s installation guide and simple example of creating certs, you should have two files: `example.com+5.pem` & `example.com+5-key.pem`
(Ensure these two files are in the root of this project)
> **Warning: Self-signed certificates or certificates not from an industry-recognized, certificate authority (CA) should never be used in production.**
8. Serve the `samples` directory by using a simple HTTP server.
- If you used the `mkcert` utility from above, followed their tutorial, and the files are in the root of this project, simply run `npm run start:samples`
- Or, if you generated certs using a different method, you will need to run the below with your certificate and key file names you created:
```
http-server samples -c1 -p 8443 --ssl --cert <your_certificate> --key <your_private_key>
```
9. Edit your `/etc/hosts` file to point your localhost (e.g. `127.0.0.1`) to `sdkapp.example.com`
10. In a [supported web browser](#requirements), navigate to `https://sdkapp.example.com:8443`, and then click
**Custom UI**.
> **Note**:
>
> Using the supplied self-signed certs is for testing and evaluation purposes **only**.
>
> Use your own production certifications from a valid Certificate Authority in production environments.
<!------------------------------------------------------------------------------------------------------------------------------------>

@@ -95,0 +109,0 @@ <!-- SAMPLES - List the samples we include with the SDKs, where they are, briefly what they show. -->

Sorry, the diff of this file is too big to display

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

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

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

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

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

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