Skip to content

Instantly share code, notes, and snippets.

/*
- Data made available by nodes that have already executed are available in the sharedState variable.
- The script should set outcome to either "true" or "false".
*/
var userID = nodeState.get("_id");
var user = openidm.read("managed/alpha_user/" + userID);
var compID = user.memberOfOrgIDs[0];
var company = openidm.read("managed/alpha_organization/" + compID);
var checkDomainLib = require('checkDomainLib');
var status = (checkDomainLib.checkDomain(company.domain,company.dnsToken,httpClient))?"active":"inactive";
var requestURL = "https://dns.google/resolve?type=16";
var requestOptions = {
method: 'GET',
body: "",
headers:{
"accept": "application/dns-message",
"Content-Type": "application/dns-json"
}
};
@sorluc
sorluc / displayDnsToken.js
Created February 23, 2024 14:19
displayDnsToken.js
config = {
"message": {"en-GB": `Hi ${nodeState.get("username")}. Please add this token value to your dns ${nodeState.get('objectAttributes').get("dnsToken")}.`},
"messageYes": {"en-GB": "Ok"},
"messageNo": {"en-GB": "I'll do it later"},
}
if (object.domain){
var condition = `/mail co "` + object.domain + `"`;
object.condition = condition;
}
/*
- Data made available by nodes that have already executed are available in the sharedState variable.
- The script should set outcome to either "true" or "false".
*/
function createToken() {
return 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
var r = Math.trunc(Math.random()*16);
var v = r;
return v.toString(16);
/*
* Copyright 2021 ForgeRock AS. All Rights Reserved
* Use of this code requires a commercial software license with ForgeRock AS.
* or with one of its affiliates. All use shall be exclusively subject
* to such license between the licensee and ForgeRock AS.
*/
/*
* The script has these top level functions that could be executed during a SAML2 flow.
* - preSingleSignOn
var myCustomer = 'YOUR CUSTOMER NAME AT WHISPEAK';
var myApplication = 'with-asr/YOUR WHISPEAK APPLICATION ID';
var token, text;
var result = sharedState.get("voiceRecordedBlob").slice("data:audio/wav;base64,".length);
var decodedString = java.lang.String(org.forgerock.util.encode.Base64.decode(result),"ISO-8859-1");
var requestCheckVoice = new org.forgerock.http.protocol.Request();
var apiKey = 'YOUR WHISPEAK API KEY';
var myCustomer = 'YOUR CUSTOMER NAME AT WHISPEAK';
var myApplication = 'with-asr/YOUR WHISPEAK APPLICATION ID';
function createScript(text) {
return String("\n\
var div = document.createElement('div'); \n\
div.id = 'voiceRecorder'; \n\
div.innerHTML = '<div class=\"container\">' +\n\
'<h2>Record your voice</h2>' + \n\
'<span style=\"font-size:20px;\">Please read the text below to register:</span>' + \n\
var myCustomer = 'YOUR CUSTOMER NAME AT WHISPEAK';
var myApplication = 'with-asr/YOU WHISPEAK APPLICATION ID';
var id = idRepository.getAttribute(sharedState.get("_id"), "fr-attr-istr2").iterator().next();
var token, text;
var result = sharedState.get("voiceRecordedBlob").slice("data:audio/wav;base64,".length);
var decodedString = java.lang.String(org.forgerock.util.encode.Base64.decode(result),"ISO-8859-1");
var apiKey = 'YOUR WHISPEAK API KEY';
var myCustomer = 'YOUR CUSTOMER NAME AT WHISPEAK';
var myApplication = 'with-asr/YOUR WHISPEAK APPLICATION ID';
function createScript(text) {
return String("\n\
var div = document.createElement('div'); \n\
div.id = 'voiceRecorder'; \n\
div.innerHTML = '<div class=\"container\">' +\n\
'<h2>Record your voice</h2>' + \n\
'<span style=\"font-size:20px;\">Please read the text below:</span>' + \n\