RTO_domainList.js
RTO_domainList.js.Summary
Allow-list API wrapper (site-side helper).
- Exports:
window.RTOAllowlist -
Depends on:
RTO_form_api.jsor the same page-side messaging bridge used by the site helpers. -
Current add flow:
add()first asks throughallowlistAddRequest, then waits for the user confirmation on the master tab. -
Current add behavior: repeated
add(host)calls for the same normalized host share one pending promise on the page side.
What it is
RTO_domainList.js exposes a small allow-list API helper (list / has / add / remove)
using the RTO messaging protocol.
In the current helper, add(host) keeps the page calm: a repeated click on the same host does not create a second local request while the first one is still waiting.
A user cancellation resolves as false, while real plugin problems still reject with a useful code/message.
Download
Download RTO_domainList.jsExample
This example checks whether the current host is allowed, and if not, requests an add and waits for the real user approval.
<script src="../RTO_helpers/RTO_form_api.js"></script>
<script src="../RTO_helpers/RTO_domainList.js"></script>
<script>
(function(){
var host = location.hostname;
RTOForm.detect(1500).then(function(){
return RTOAllowlist.has(host).then(function(ok){
console.log("allowed?", ok, "host=", host);
if (ok) return true;
console.log("Please confirm the allow-list request on the master tab.");
return RTOAllowlist.add(host, 130000).then(function(approved){
if (!approved) {
console.log("The request was cancelled or not approved.");
return false;
}
return RTOAllowlist.has(host);
});
});
}).then(function(finalOk){
console.log("final allowed?", finalOk);
}).catch(function(err){
console.warn("Allow-list request failed:", (err && err.code) || err, (err && err.message) || "");
});
})();
</script>
API
RTOAllowlist.list(timeoutMs?)→Promise<string[]>(normalized host list)RTOAllowlist.has(host, timeoutMs?)→Promise<boolean>RTOAllowlist.add(host, timeoutMs?)→Promise<boolean>after approval or rejection; returnsfalseforUSER_CANCELLED, rejects for real system/plugin errorsRTOAllowlist.remove(host, timeoutMs?)→Promise<boolean>RTOAllowlist.cached()→{ ts:number, items:string[] }RTOAllowlist.hasCached(host)→boolean
Compatibility
In 7.13.0, the normal page-side path is allowlistAddRequest for add requests, plus
allowlistList, allowlistCheck, and allowlistRemove.
This helper still keeps a small legacy fallback only if the modern add request does not answer.
Direct page-side allowlistAdd is no longer the normal documented path.
Tip
add(host) twice for the same normalized host while the first request is still pending,
the helper reuses the same promise instead of sending a second identical page-side request.
location.host includes the port (example.com:8080).
For allow-list without port, prefer location.hostname (example.com).
add() uses a longer wait by default because it may take a user a moment to switch back to the master tab and confirm the request.