Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This module help you to verify domain ownership.
Verify by uploading a specific HTML to a given domain.

### Parameters:
* domain_url: The URL where the html file can be formed.
* domain_url: The URL where the html file can be formed (http://example.com).
* domain_html_name: The name of the html file expected at 'domain_url'
* hash_value: The value in the html file body

Expand Down
35 changes: 21 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var metafetch = require('metafetch');
var request = require('request');
var Promise = require("bluebird");
var dns = require("dns");
var parser = require('getdomain');

var DomainVerification = (function() {

Expand All @@ -14,7 +15,7 @@ var DomainVerification = (function() {
if(original_args.length == 3)
{
var obj = {};
obj.verified = "Html Verification";
obj.verified = "htmlVerification";
var url = domain_url+'/'+domain_html_name+'.html';
var options = {
method: 'GET',
Expand Down Expand Up @@ -47,25 +48,31 @@ var DomainVerification = (function() {
return new Promise(function (resolve,reject){
if(original_args.length == 3){
var obj = {};
obj.verified = "Txt Verification";
dns.resolveTxt(domain_url, function(error,records){
obj.verified = "txtVerification";
var domain = parser.hostname(domain_url);
dns.resolveTxt(domain, function(error,records){
if(records == undefined)
{
obj.status = false;
resolve(obj);
} else {
var success = [];
var expected = domain_key+'='+domain_value;
records.forEach(function(record){
var expected = domain_key+'='+domain_value;
if(expected == record[0])
{
obj.status = true;
resolve(obj);
}
else {
obj.status = false;
resolve(obj);
}
success.push(obj.status);
}
});

if(success.length > 0)
{
obj.status = true;
resolve(obj);
} else {
obj.status = false;
resolve(obj);
}
}
});
}
Expand All @@ -79,7 +86,7 @@ var DomainVerification = (function() {
var original_args = arguments;
return new Promise(function(resolve,reject){
var obj = {};
obj.verified = "Meta tag Verification";
obj.verified = "metaTagVerification";

if(original_args.length == 3)
{
Expand Down Expand Up @@ -129,9 +136,9 @@ var DomainVerification = (function() {
results_data.forEach( data=>{
if(data.status)
{
success.push(data.name);
success.push(data.verified);
} else {
failure.push(data.name);
failure.push(data.verified);
}
});
if(success.length > 0)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"bluebird": "^3.5.1",
"getdomain": "^1.3.0",
"metafetch": "^1.8.1",
"request": "^2.87.0"
},
Expand Down