emblem-vault-sdk 1.6.2 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +105 -2
- package/dist/index.js +6 -1
- package/dist/utils.js +99 -1
- package/docs/bundle.js +105 -2
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/utils.ts +102 -0
- package/types/index.d.ts +1 -0
- package/types/utils.d.ts +1 -0
package/dist/bundle.js
CHANGED
|
@@ -684293,7 +684293,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
684293
684293
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
684294
684294
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
684295
684295
|
const utils_1 = require("./utils");
|
|
684296
|
-
const SDK_VERSION = '1.
|
|
684296
|
+
const SDK_VERSION = '1.7.1';
|
|
684297
684297
|
class EmblemVaultSDK {
|
|
684298
684298
|
constructor(apiKey, baseUrl) {
|
|
684299
684299
|
this.apiKey = apiKey;
|
|
@@ -684486,6 +684486,11 @@ class EmblemVaultSDK {
|
|
|
684486
684486
|
return mintResponse;
|
|
684487
684487
|
});
|
|
684488
684488
|
}
|
|
684489
|
+
contentTypeReport(url) {
|
|
684490
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
684491
|
+
return yield (0, utils_1.checkContentType)(url);
|
|
684492
|
+
});
|
|
684493
|
+
}
|
|
684489
684494
|
}
|
|
684490
684495
|
if (typeof window !== 'undefined') {
|
|
684491
684496
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
|
@@ -684507,7 +684512,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
684507
684512
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
684508
684513
|
};
|
|
684509
684514
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
684510
|
-
exports.COIN_TO_NETWORK = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
684515
|
+
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
684511
684516
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
684512
684517
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
684513
684518
|
exports.NFT_DATA = metadata_json_1.default;
|
|
@@ -684745,6 +684750,9 @@ function generateTemplate(record) {
|
|
|
684745
684750
|
else if (recordName == "Embels") {
|
|
684746
684751
|
allowed = true;
|
|
684747
684752
|
}
|
|
684753
|
+
else if (recordName == "BitcoinOrdinals ") {
|
|
684754
|
+
allowed = data && data[0].coin == "ordinalsbtc";
|
|
684755
|
+
}
|
|
684748
684756
|
else { // XCP
|
|
684749
684757
|
allowed = data[0].project == _this.name && data[0].balance == 1;
|
|
684750
684758
|
}
|
|
@@ -684788,6 +684796,9 @@ function generateTemplate(record) {
|
|
|
684788
684796
|
else if (recordName == "Embels") {
|
|
684789
684797
|
allowedName = true;
|
|
684790
684798
|
}
|
|
684799
|
+
else if (recordName == "BitcoinOrdinals") {
|
|
684800
|
+
allowedName = true;
|
|
684801
|
+
}
|
|
684791
684802
|
else { // XCP
|
|
684792
684803
|
let curatedItemFound = exports.NFT_DATA[asset];
|
|
684793
684804
|
allowedName = asset && curatedItemFound ? true : false;
|
|
@@ -685021,6 +685032,49 @@ function getHandlerContract(web3) {
|
|
|
685021
685032
|
});
|
|
685022
685033
|
}
|
|
685023
685034
|
exports.getHandlerContract = getHandlerContract;
|
|
685035
|
+
function checkContentType(url) {
|
|
685036
|
+
return new Promise((resolve, reject) => {
|
|
685037
|
+
let returnVal = {};
|
|
685038
|
+
fetch(url, { method: 'HEAD' })
|
|
685039
|
+
.then(response => {
|
|
685040
|
+
if (!response.ok) {
|
|
685041
|
+
returnVal.valid = false;
|
|
685042
|
+
}
|
|
685043
|
+
else if (response.status === 200) {
|
|
685044
|
+
const contentType = response.headers.get('content-type');
|
|
685045
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
685046
|
+
returnVal.valid = true;
|
|
685047
|
+
returnVal.contentType = contentType;
|
|
685048
|
+
returnVal.extension = extension;
|
|
685049
|
+
returnVal.embed = !isValidDirect(extension);
|
|
685050
|
+
console.log('Content-Type:', contentType);
|
|
685051
|
+
}
|
|
685052
|
+
resolve(returnVal);
|
|
685053
|
+
})
|
|
685054
|
+
.catch(error => {
|
|
685055
|
+
console.error('Error while fetching URL:', error);
|
|
685056
|
+
reject(error);
|
|
685057
|
+
});
|
|
685058
|
+
});
|
|
685059
|
+
}
|
|
685060
|
+
exports.checkContentType = checkContentType;
|
|
685061
|
+
function isValidDirect(extension) {
|
|
685062
|
+
switch (extension) {
|
|
685063
|
+
case '.png':
|
|
685064
|
+
case '.jpg':
|
|
685065
|
+
case '.jpeg':
|
|
685066
|
+
case '.gif':
|
|
685067
|
+
case '.webp':
|
|
685068
|
+
case '.tif':
|
|
685069
|
+
case '.tiff':
|
|
685070
|
+
return true;
|
|
685071
|
+
default:
|
|
685072
|
+
return false;
|
|
685073
|
+
}
|
|
685074
|
+
}
|
|
685075
|
+
function getFileExtensionFromMimeType(mimeType) {
|
|
685076
|
+
return mimeType ? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
685077
|
+
}
|
|
685024
685078
|
exports.COIN_TO_NETWORK = {
|
|
685025
685079
|
'xcp': 'BTC',
|
|
685026
685080
|
'ordinalsbtc': 'BTC',
|
|
@@ -685031,6 +685085,55 @@ exports.COIN_TO_NETWORK = {
|
|
|
685031
685085
|
'bel': 'Bel',
|
|
685032
685086
|
'nmc': 'Namecoin'
|
|
685033
685087
|
};
|
|
685088
|
+
const mimeToExtensionMap = {
|
|
685089
|
+
// Image formats
|
|
685090
|
+
"image/png": ".png",
|
|
685091
|
+
"image/jpeg": ".jpg",
|
|
685092
|
+
"image/jpe": ".jpe",
|
|
685093
|
+
"image/gif": ".gif",
|
|
685094
|
+
"image/webp": ".webp",
|
|
685095
|
+
"image/heif": ".heif",
|
|
685096
|
+
"image/bmp": ".bmp",
|
|
685097
|
+
"image/tiff": ".tiff",
|
|
685098
|
+
"image/tif": ".tif",
|
|
685099
|
+
"image/x-icon": ".ico",
|
|
685100
|
+
"image/svg+xml": ".svg",
|
|
685101
|
+
"image/heic": ".heic",
|
|
685102
|
+
"image/avif": ".avif",
|
|
685103
|
+
"image/apng": ".apng",
|
|
685104
|
+
"image/jp2": ".jp2",
|
|
685105
|
+
"image/jxr": ".jxr",
|
|
685106
|
+
"image/astc": ".astc",
|
|
685107
|
+
"image/jxl": ".jxl",
|
|
685108
|
+
"image/x-jng": ".jng",
|
|
685109
|
+
"image/x-ms-bmp": ".bmp",
|
|
685110
|
+
"image/x-png": ".png",
|
|
685111
|
+
"image/x-xbitmap": ".xbm",
|
|
685112
|
+
"image/x-xpixmap": ".xpm",
|
|
685113
|
+
"image/x-rgb": ".rgb",
|
|
685114
|
+
"image/x-portable-anymap": ".pnm",
|
|
685115
|
+
"image/x-portable-bitmap": ".pbm",
|
|
685116
|
+
"image/x-portable-graymap": ".pgm",
|
|
685117
|
+
"image/x-portable-pixmap": ".ppm",
|
|
685118
|
+
// Video formats
|
|
685119
|
+
"video/mp4": ".mp4",
|
|
685120
|
+
"video/x-m4v": ".m4v",
|
|
685121
|
+
"video/3gpp": ".3gp",
|
|
685122
|
+
"video/3gpp2": ".3g2",
|
|
685123
|
+
"video/webm": ".webm",
|
|
685124
|
+
"video/ogg": ".ogv",
|
|
685125
|
+
"video/x-msvideo": ".avi",
|
|
685126
|
+
"video/ms-asf": ".asf",
|
|
685127
|
+
"video/x-ms-wmv": ".wmv",
|
|
685128
|
+
"video/mpeg": ".mpeg",
|
|
685129
|
+
"video/quicktime": ".mov",
|
|
685130
|
+
"video/x-flv": ".flv",
|
|
685131
|
+
"video/x-matroska": ".mkv",
|
|
685132
|
+
"video/h264": ".h264",
|
|
685133
|
+
"video/h265": ".h265",
|
|
685134
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
685135
|
+
// Add more mappings if needed
|
|
685136
|
+
};
|
|
685034
685137
|
|
|
685035
685138
|
},{"./abi/abi.json":1,"./curated/metadata.json":2,"node-fetch":15}],5:[function(require,module,exports){
|
|
685036
685139
|
"use strict";
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
36
36
|
const utils_1 = require("./utils");
|
|
37
|
-
const SDK_VERSION = '1.
|
|
37
|
+
const SDK_VERSION = '1.7.1';
|
|
38
38
|
class EmblemVaultSDK {
|
|
39
39
|
constructor(apiKey, baseUrl) {
|
|
40
40
|
this.apiKey = apiKey;
|
|
@@ -227,6 +227,11 @@ class EmblemVaultSDK {
|
|
|
227
227
|
return mintResponse;
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
+
contentTypeReport(url) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
return yield (0, utils_1.checkContentType)(url);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
230
235
|
}
|
|
231
236
|
if (typeof window !== 'undefined') {
|
|
232
237
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
package/dist/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.COIN_TO_NETWORK = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
15
|
+
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
16
16
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
17
17
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
18
18
|
exports.NFT_DATA = metadata_json_1.default;
|
|
@@ -250,6 +250,9 @@ function generateTemplate(record) {
|
|
|
250
250
|
else if (recordName == "Embels") {
|
|
251
251
|
allowed = true;
|
|
252
252
|
}
|
|
253
|
+
else if (recordName == "BitcoinOrdinals ") {
|
|
254
|
+
allowed = data && data[0].coin == "ordinalsbtc";
|
|
255
|
+
}
|
|
253
256
|
else { // XCP
|
|
254
257
|
allowed = data[0].project == _this.name && data[0].balance == 1;
|
|
255
258
|
}
|
|
@@ -293,6 +296,9 @@ function generateTemplate(record) {
|
|
|
293
296
|
else if (recordName == "Embels") {
|
|
294
297
|
allowedName = true;
|
|
295
298
|
}
|
|
299
|
+
else if (recordName == "BitcoinOrdinals") {
|
|
300
|
+
allowedName = true;
|
|
301
|
+
}
|
|
296
302
|
else { // XCP
|
|
297
303
|
let curatedItemFound = exports.NFT_DATA[asset];
|
|
298
304
|
allowedName = asset && curatedItemFound ? true : false;
|
|
@@ -526,6 +532,49 @@ function getHandlerContract(web3) {
|
|
|
526
532
|
});
|
|
527
533
|
}
|
|
528
534
|
exports.getHandlerContract = getHandlerContract;
|
|
535
|
+
function checkContentType(url) {
|
|
536
|
+
return new Promise((resolve, reject) => {
|
|
537
|
+
let returnVal = {};
|
|
538
|
+
fetch(url, { method: 'HEAD' })
|
|
539
|
+
.then(response => {
|
|
540
|
+
if (!response.ok) {
|
|
541
|
+
returnVal.valid = false;
|
|
542
|
+
}
|
|
543
|
+
else if (response.status === 200) {
|
|
544
|
+
const contentType = response.headers.get('content-type');
|
|
545
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
546
|
+
returnVal.valid = true;
|
|
547
|
+
returnVal.contentType = contentType;
|
|
548
|
+
returnVal.extension = extension;
|
|
549
|
+
returnVal.embed = !isValidDirect(extension);
|
|
550
|
+
console.log('Content-Type:', contentType);
|
|
551
|
+
}
|
|
552
|
+
resolve(returnVal);
|
|
553
|
+
})
|
|
554
|
+
.catch(error => {
|
|
555
|
+
console.error('Error while fetching URL:', error);
|
|
556
|
+
reject(error);
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
exports.checkContentType = checkContentType;
|
|
561
|
+
function isValidDirect(extension) {
|
|
562
|
+
switch (extension) {
|
|
563
|
+
case '.png':
|
|
564
|
+
case '.jpg':
|
|
565
|
+
case '.jpeg':
|
|
566
|
+
case '.gif':
|
|
567
|
+
case '.webp':
|
|
568
|
+
case '.tif':
|
|
569
|
+
case '.tiff':
|
|
570
|
+
return true;
|
|
571
|
+
default:
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function getFileExtensionFromMimeType(mimeType) {
|
|
576
|
+
return mimeType ? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
577
|
+
}
|
|
529
578
|
exports.COIN_TO_NETWORK = {
|
|
530
579
|
'xcp': 'BTC',
|
|
531
580
|
'ordinalsbtc': 'BTC',
|
|
@@ -536,3 +585,52 @@ exports.COIN_TO_NETWORK = {
|
|
|
536
585
|
'bel': 'Bel',
|
|
537
586
|
'nmc': 'Namecoin'
|
|
538
587
|
};
|
|
588
|
+
const mimeToExtensionMap = {
|
|
589
|
+
// Image formats
|
|
590
|
+
"image/png": ".png",
|
|
591
|
+
"image/jpeg": ".jpg",
|
|
592
|
+
"image/jpe": ".jpe",
|
|
593
|
+
"image/gif": ".gif",
|
|
594
|
+
"image/webp": ".webp",
|
|
595
|
+
"image/heif": ".heif",
|
|
596
|
+
"image/bmp": ".bmp",
|
|
597
|
+
"image/tiff": ".tiff",
|
|
598
|
+
"image/tif": ".tif",
|
|
599
|
+
"image/x-icon": ".ico",
|
|
600
|
+
"image/svg+xml": ".svg",
|
|
601
|
+
"image/heic": ".heic",
|
|
602
|
+
"image/avif": ".avif",
|
|
603
|
+
"image/apng": ".apng",
|
|
604
|
+
"image/jp2": ".jp2",
|
|
605
|
+
"image/jxr": ".jxr",
|
|
606
|
+
"image/astc": ".astc",
|
|
607
|
+
"image/jxl": ".jxl",
|
|
608
|
+
"image/x-jng": ".jng",
|
|
609
|
+
"image/x-ms-bmp": ".bmp",
|
|
610
|
+
"image/x-png": ".png",
|
|
611
|
+
"image/x-xbitmap": ".xbm",
|
|
612
|
+
"image/x-xpixmap": ".xpm",
|
|
613
|
+
"image/x-rgb": ".rgb",
|
|
614
|
+
"image/x-portable-anymap": ".pnm",
|
|
615
|
+
"image/x-portable-bitmap": ".pbm",
|
|
616
|
+
"image/x-portable-graymap": ".pgm",
|
|
617
|
+
"image/x-portable-pixmap": ".ppm",
|
|
618
|
+
// Video formats
|
|
619
|
+
"video/mp4": ".mp4",
|
|
620
|
+
"video/x-m4v": ".m4v",
|
|
621
|
+
"video/3gpp": ".3gp",
|
|
622
|
+
"video/3gpp2": ".3g2",
|
|
623
|
+
"video/webm": ".webm",
|
|
624
|
+
"video/ogg": ".ogv",
|
|
625
|
+
"video/x-msvideo": ".avi",
|
|
626
|
+
"video/ms-asf": ".asf",
|
|
627
|
+
"video/x-ms-wmv": ".wmv",
|
|
628
|
+
"video/mpeg": ".mpeg",
|
|
629
|
+
"video/quicktime": ".mov",
|
|
630
|
+
"video/x-flv": ".flv",
|
|
631
|
+
"video/x-matroska": ".mkv",
|
|
632
|
+
"video/h264": ".h264",
|
|
633
|
+
"video/h265": ".h265",
|
|
634
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
635
|
+
// Add more mappings if needed
|
|
636
|
+
};
|
package/docs/bundle.js
CHANGED
|
@@ -684293,7 +684293,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
684293
684293
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
684294
684294
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
684295
684295
|
const utils_1 = require("./utils");
|
|
684296
|
-
const SDK_VERSION = '1.
|
|
684296
|
+
const SDK_VERSION = '1.7.1';
|
|
684297
684297
|
class EmblemVaultSDK {
|
|
684298
684298
|
constructor(apiKey, baseUrl) {
|
|
684299
684299
|
this.apiKey = apiKey;
|
|
@@ -684486,6 +684486,11 @@ class EmblemVaultSDK {
|
|
|
684486
684486
|
return mintResponse;
|
|
684487
684487
|
});
|
|
684488
684488
|
}
|
|
684489
|
+
contentTypeReport(url) {
|
|
684490
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
684491
|
+
return yield (0, utils_1.checkContentType)(url);
|
|
684492
|
+
});
|
|
684493
|
+
}
|
|
684489
684494
|
}
|
|
684490
684495
|
if (typeof window !== 'undefined') {
|
|
684491
684496
|
window.EmblemVaultSDK = EmblemVaultSDK;
|
|
@@ -684507,7 +684512,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
684507
684512
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
684508
684513
|
};
|
|
684509
684514
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
684510
|
-
exports.COIN_TO_NETWORK = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
684515
|
+
exports.COIN_TO_NETWORK = exports.checkContentType = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
|
|
684511
684516
|
const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
|
|
684512
684517
|
const abi_json_1 = __importDefault(require("./abi/abi.json"));
|
|
684513
684518
|
exports.NFT_DATA = metadata_json_1.default;
|
|
@@ -684745,6 +684750,9 @@ function generateTemplate(record) {
|
|
|
684745
684750
|
else if (recordName == "Embels") {
|
|
684746
684751
|
allowed = true;
|
|
684747
684752
|
}
|
|
684753
|
+
else if (recordName == "BitcoinOrdinals ") {
|
|
684754
|
+
allowed = data && data[0].coin == "ordinalsbtc";
|
|
684755
|
+
}
|
|
684748
684756
|
else { // XCP
|
|
684749
684757
|
allowed = data[0].project == _this.name && data[0].balance == 1;
|
|
684750
684758
|
}
|
|
@@ -684788,6 +684796,9 @@ function generateTemplate(record) {
|
|
|
684788
684796
|
else if (recordName == "Embels") {
|
|
684789
684797
|
allowedName = true;
|
|
684790
684798
|
}
|
|
684799
|
+
else if (recordName == "BitcoinOrdinals") {
|
|
684800
|
+
allowedName = true;
|
|
684801
|
+
}
|
|
684791
684802
|
else { // XCP
|
|
684792
684803
|
let curatedItemFound = exports.NFT_DATA[asset];
|
|
684793
684804
|
allowedName = asset && curatedItemFound ? true : false;
|
|
@@ -685021,6 +685032,49 @@ function getHandlerContract(web3) {
|
|
|
685021
685032
|
});
|
|
685022
685033
|
}
|
|
685023
685034
|
exports.getHandlerContract = getHandlerContract;
|
|
685035
|
+
function checkContentType(url) {
|
|
685036
|
+
return new Promise((resolve, reject) => {
|
|
685037
|
+
let returnVal = {};
|
|
685038
|
+
fetch(url, { method: 'HEAD' })
|
|
685039
|
+
.then(response => {
|
|
685040
|
+
if (!response.ok) {
|
|
685041
|
+
returnVal.valid = false;
|
|
685042
|
+
}
|
|
685043
|
+
else if (response.status === 200) {
|
|
685044
|
+
const contentType = response.headers.get('content-type');
|
|
685045
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
685046
|
+
returnVal.valid = true;
|
|
685047
|
+
returnVal.contentType = contentType;
|
|
685048
|
+
returnVal.extension = extension;
|
|
685049
|
+
returnVal.embed = !isValidDirect(extension);
|
|
685050
|
+
console.log('Content-Type:', contentType);
|
|
685051
|
+
}
|
|
685052
|
+
resolve(returnVal);
|
|
685053
|
+
})
|
|
685054
|
+
.catch(error => {
|
|
685055
|
+
console.error('Error while fetching URL:', error);
|
|
685056
|
+
reject(error);
|
|
685057
|
+
});
|
|
685058
|
+
});
|
|
685059
|
+
}
|
|
685060
|
+
exports.checkContentType = checkContentType;
|
|
685061
|
+
function isValidDirect(extension) {
|
|
685062
|
+
switch (extension) {
|
|
685063
|
+
case '.png':
|
|
685064
|
+
case '.jpg':
|
|
685065
|
+
case '.jpeg':
|
|
685066
|
+
case '.gif':
|
|
685067
|
+
case '.webp':
|
|
685068
|
+
case '.tif':
|
|
685069
|
+
case '.tiff':
|
|
685070
|
+
return true;
|
|
685071
|
+
default:
|
|
685072
|
+
return false;
|
|
685073
|
+
}
|
|
685074
|
+
}
|
|
685075
|
+
function getFileExtensionFromMimeType(mimeType) {
|
|
685076
|
+
return mimeType ? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
685077
|
+
}
|
|
685024
685078
|
exports.COIN_TO_NETWORK = {
|
|
685025
685079
|
'xcp': 'BTC',
|
|
685026
685080
|
'ordinalsbtc': 'BTC',
|
|
@@ -685031,6 +685085,55 @@ exports.COIN_TO_NETWORK = {
|
|
|
685031
685085
|
'bel': 'Bel',
|
|
685032
685086
|
'nmc': 'Namecoin'
|
|
685033
685087
|
};
|
|
685088
|
+
const mimeToExtensionMap = {
|
|
685089
|
+
// Image formats
|
|
685090
|
+
"image/png": ".png",
|
|
685091
|
+
"image/jpeg": ".jpg",
|
|
685092
|
+
"image/jpe": ".jpe",
|
|
685093
|
+
"image/gif": ".gif",
|
|
685094
|
+
"image/webp": ".webp",
|
|
685095
|
+
"image/heif": ".heif",
|
|
685096
|
+
"image/bmp": ".bmp",
|
|
685097
|
+
"image/tiff": ".tiff",
|
|
685098
|
+
"image/tif": ".tif",
|
|
685099
|
+
"image/x-icon": ".ico",
|
|
685100
|
+
"image/svg+xml": ".svg",
|
|
685101
|
+
"image/heic": ".heic",
|
|
685102
|
+
"image/avif": ".avif",
|
|
685103
|
+
"image/apng": ".apng",
|
|
685104
|
+
"image/jp2": ".jp2",
|
|
685105
|
+
"image/jxr": ".jxr",
|
|
685106
|
+
"image/astc": ".astc",
|
|
685107
|
+
"image/jxl": ".jxl",
|
|
685108
|
+
"image/x-jng": ".jng",
|
|
685109
|
+
"image/x-ms-bmp": ".bmp",
|
|
685110
|
+
"image/x-png": ".png",
|
|
685111
|
+
"image/x-xbitmap": ".xbm",
|
|
685112
|
+
"image/x-xpixmap": ".xpm",
|
|
685113
|
+
"image/x-rgb": ".rgb",
|
|
685114
|
+
"image/x-portable-anymap": ".pnm",
|
|
685115
|
+
"image/x-portable-bitmap": ".pbm",
|
|
685116
|
+
"image/x-portable-graymap": ".pgm",
|
|
685117
|
+
"image/x-portable-pixmap": ".ppm",
|
|
685118
|
+
// Video formats
|
|
685119
|
+
"video/mp4": ".mp4",
|
|
685120
|
+
"video/x-m4v": ".m4v",
|
|
685121
|
+
"video/3gpp": ".3gp",
|
|
685122
|
+
"video/3gpp2": ".3g2",
|
|
685123
|
+
"video/webm": ".webm",
|
|
685124
|
+
"video/ogg": ".ogv",
|
|
685125
|
+
"video/x-msvideo": ".avi",
|
|
685126
|
+
"video/ms-asf": ".asf",
|
|
685127
|
+
"video/x-ms-wmv": ".wmv",
|
|
685128
|
+
"video/mpeg": ".mpeg",
|
|
685129
|
+
"video/quicktime": ".mov",
|
|
685130
|
+
"video/x-flv": ".flv",
|
|
685131
|
+
"video/x-matroska": ".mkv",
|
|
685132
|
+
"video/h264": ".h264",
|
|
685133
|
+
"video/h265": ".h265",
|
|
685134
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
685135
|
+
// Add more mappings if needed
|
|
685136
|
+
};
|
|
685034
685137
|
|
|
685035
685138
|
},{"./abi/abi.json":1,"./curated/metadata.json":2,"node-fetch":15}],5:[function(require,module,exports){
|
|
685036
685139
|
"use strict";
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber'
|
|
2
2
|
import { Collection, CuratedCollectionsResponse, MetaData, Vault } from './types';
|
|
3
|
-
import { COIN_TO_NETWORK, NFT_DATA, evaluateFacts, fetchData, generateTemplate, genericGuard, getHandlerContract, getQuoteContractObject, metadataAllProjects, metadataObj2Arr, pad, templateGuard } from './utils';
|
|
3
|
+
import { COIN_TO_NETWORK, NFT_DATA, checkContentType, evaluateFacts, fetchData, generateTemplate, genericGuard, getHandlerContract, getQuoteContractObject, metadataAllProjects, metadataObj2Arr, pad, templateGuard } from './utils';
|
|
4
4
|
|
|
5
5
|
const SDK_VERSION = '__SDK_VERSION__';
|
|
6
6
|
class EmblemVaultSDK {
|
|
@@ -167,6 +167,10 @@ class EmblemVaultSDK {
|
|
|
167
167
|
return mintResponse
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
async contentTypeReport(url: string) {
|
|
171
|
+
return await checkContentType(url)
|
|
172
|
+
}
|
|
173
|
+
|
|
170
174
|
|
|
171
175
|
}
|
|
172
176
|
|
package/src/utils.ts
CHANGED
|
@@ -222,6 +222,8 @@ export function generateTemplate(record: any) {
|
|
|
222
222
|
allowed = data && record.nativeAssets.includes(data[0].coin) ? true: false
|
|
223
223
|
} else if (recordName == "Embels"){
|
|
224
224
|
allowed = true
|
|
225
|
+
} else if (recordName == "BitcoinOrdinals ") {
|
|
226
|
+
allowed = data && data[0].coin == "ordinalsbtc"
|
|
225
227
|
} else { // XCP
|
|
226
228
|
allowed = data[0].project == _this.name && data[0].balance == 1;
|
|
227
229
|
}
|
|
@@ -255,6 +257,8 @@ export function generateTemplate(record: any) {
|
|
|
255
257
|
allowedName = asset? true: false
|
|
256
258
|
} else if (recordName == "Embels"){
|
|
257
259
|
allowedName = true
|
|
260
|
+
} else if (recordName == "BitcoinOrdinals"){
|
|
261
|
+
allowedName = true
|
|
258
262
|
} else { // XCP
|
|
259
263
|
let curatedItemFound = NFT_DATA[asset];
|
|
260
264
|
allowedName = asset && curatedItemFound ? true : false;
|
|
@@ -486,6 +490,53 @@ export async function getHandlerContract(web3: any) {
|
|
|
486
490
|
return handlerContract
|
|
487
491
|
}
|
|
488
492
|
|
|
493
|
+
export function checkContentType(url: string) {
|
|
494
|
+
return new Promise((resolve, reject) => {
|
|
495
|
+
// Making a HTTP HEAD request to get only the headers
|
|
496
|
+
type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean };
|
|
497
|
+
let returnVal: ReturnVal = {};
|
|
498
|
+
fetch(url, { method: 'HEAD' })
|
|
499
|
+
.then(response => {
|
|
500
|
+
if (!response.ok) {
|
|
501
|
+
returnVal.valid = false
|
|
502
|
+
}
|
|
503
|
+
else if (response.status === 200) {
|
|
504
|
+
const contentType = response.headers.get('content-type');
|
|
505
|
+
let extension = getFileExtensionFromMimeType(contentType)
|
|
506
|
+
returnVal.valid = true
|
|
507
|
+
returnVal.contentType = contentType
|
|
508
|
+
returnVal.extension = extension
|
|
509
|
+
returnVal.embed = !isValidDirect(extension)
|
|
510
|
+
console.log('Content-Type:', contentType);
|
|
511
|
+
}
|
|
512
|
+
resolve(returnVal);
|
|
513
|
+
})
|
|
514
|
+
.catch(error => {
|
|
515
|
+
console.error('Error while fetching URL:', error);
|
|
516
|
+
reject(error);
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function isValidDirect(extension: string) {
|
|
522
|
+
switch (extension) {
|
|
523
|
+
case '.png':
|
|
524
|
+
case '.jpg':
|
|
525
|
+
case '.jpeg':
|
|
526
|
+
case '.gif':
|
|
527
|
+
case '.webp':
|
|
528
|
+
case '.tif':
|
|
529
|
+
case '.tiff':
|
|
530
|
+
return true;
|
|
531
|
+
default:
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function getFileExtensionFromMimeType(mimeType: string | null) {
|
|
537
|
+
return mimeType? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
538
|
+
}
|
|
539
|
+
|
|
489
540
|
export const COIN_TO_NETWORK: any = {
|
|
490
541
|
'xcp': 'BTC',
|
|
491
542
|
'ordinalsbtc': 'BTC',
|
|
@@ -496,3 +547,54 @@ export const COIN_TO_NETWORK: any = {
|
|
|
496
547
|
'bel': 'Bel',
|
|
497
548
|
'nmc':'Namecoin'
|
|
498
549
|
}
|
|
550
|
+
|
|
551
|
+
const mimeToExtensionMap: any = {
|
|
552
|
+
// Image formats
|
|
553
|
+
"image/png": ".png",
|
|
554
|
+
"image/jpeg": ".jpg",
|
|
555
|
+
"image/jpe": ".jpe",
|
|
556
|
+
"image/gif": ".gif",
|
|
557
|
+
"image/webp": ".webp",
|
|
558
|
+
"image/heif": ".heif",
|
|
559
|
+
"image/bmp": ".bmp",
|
|
560
|
+
"image/tiff": ".tiff",
|
|
561
|
+
"image/tif": ".tif",
|
|
562
|
+
"image/x-icon": ".ico",
|
|
563
|
+
"image/svg+xml": ".svg",
|
|
564
|
+
"image/heic": ".heic",
|
|
565
|
+
"image/avif": ".avif",
|
|
566
|
+
"image/apng": ".apng",
|
|
567
|
+
"image/jp2": ".jp2",
|
|
568
|
+
"image/jxr": ".jxr",
|
|
569
|
+
"image/astc": ".astc",
|
|
570
|
+
"image/jxl": ".jxl",
|
|
571
|
+
"image/x-jng": ".jng",
|
|
572
|
+
"image/x-ms-bmp": ".bmp",
|
|
573
|
+
"image/x-png": ".png",
|
|
574
|
+
"image/x-xbitmap": ".xbm",
|
|
575
|
+
"image/x-xpixmap": ".xpm",
|
|
576
|
+
"image/x-rgb": ".rgb",
|
|
577
|
+
"image/x-portable-anymap": ".pnm",
|
|
578
|
+
"image/x-portable-bitmap": ".pbm",
|
|
579
|
+
"image/x-portable-graymap": ".pgm",
|
|
580
|
+
"image/x-portable-pixmap": ".ppm",
|
|
581
|
+
|
|
582
|
+
// Video formats
|
|
583
|
+
"video/mp4": ".mp4",
|
|
584
|
+
"video/x-m4v": ".m4v",
|
|
585
|
+
"video/3gpp": ".3gp",
|
|
586
|
+
"video/3gpp2": ".3g2",
|
|
587
|
+
"video/webm": ".webm",
|
|
588
|
+
"video/ogg": ".ogv",
|
|
589
|
+
"video/x-msvideo": ".avi",
|
|
590
|
+
"video/ms-asf": ".asf",
|
|
591
|
+
"video/x-ms-wmv": ".wmv",
|
|
592
|
+
"video/mpeg": ".mpeg",
|
|
593
|
+
"video/quicktime": ".mov",
|
|
594
|
+
"video/x-flv": ".flv",
|
|
595
|
+
"video/x-matroska": ".mkv",
|
|
596
|
+
"video/h264": ".h264",
|
|
597
|
+
"video/h265": ".h265",
|
|
598
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
599
|
+
// Add more mappings if needed
|
|
600
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare class EmblemVaultSDK {
|
|
|
20
20
|
requestRemoteMintSignature(web3: any, tokenId: string, signature: string, callback?: any): Promise<any>;
|
|
21
21
|
getQuote(web3: any, amount: number, callback?: any): Promise<BigNumber>;
|
|
22
22
|
performMint(web3: any, quote: any, remoteMintSig: any, callback?: any): Promise<any>;
|
|
23
|
+
contentTypeReport(url: string): Promise<unknown>;
|
|
23
24
|
}
|
|
24
25
|
declare global {
|
|
25
26
|
interface Window {
|
package/types/utils.d.ts
CHANGED
|
@@ -17,4 +17,5 @@ export declare function templateGuard(input: {
|
|
|
17
17
|
export declare function genericGuard(input: any, type: string, key: string): void;
|
|
18
18
|
export declare function getQuoteContractObject(web3: any): Promise<any>;
|
|
19
19
|
export declare function getHandlerContract(web3: any): Promise<any>;
|
|
20
|
+
export declare function checkContentType(url: string): Promise<unknown>;
|
|
20
21
|
export declare const COIN_TO_NETWORK: any;
|