emblem-vault-sdk 1.6.2 → 1.7.0
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 +102 -2
- package/dist/index.js +6 -1
- package/dist/utils.js +96 -1
- package/docs/bundle.js +102 -2
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/utils.ts +101 -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.0';
|
|
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;
|
|
@@ -685021,6 +685026,52 @@ function getHandlerContract(web3) {
|
|
|
685021
685026
|
});
|
|
685022
685027
|
}
|
|
685023
685028
|
exports.getHandlerContract = getHandlerContract;
|
|
685029
|
+
function checkContentType(url) {
|
|
685030
|
+
return new Promise((resolve, reject) => {
|
|
685031
|
+
let returnVal = {};
|
|
685032
|
+
fetch(url, { method: 'HEAD' })
|
|
685033
|
+
.then(response => {
|
|
685034
|
+
if (!response.ok) {
|
|
685035
|
+
throw new Error('Network response was not ok');
|
|
685036
|
+
}
|
|
685037
|
+
if (response.status === 200) {
|
|
685038
|
+
const contentType = response.headers.get('content-type');
|
|
685039
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
685040
|
+
returnVal.valid = true;
|
|
685041
|
+
returnVal.contentType = contentType;
|
|
685042
|
+
returnVal.extension = extension;
|
|
685043
|
+
returnVal.embed = !isValidDirect(extension);
|
|
685044
|
+
console.log('Content-Type:', contentType);
|
|
685045
|
+
resolve(returnVal);
|
|
685046
|
+
}
|
|
685047
|
+
else {
|
|
685048
|
+
resolve(returnVal);
|
|
685049
|
+
}
|
|
685050
|
+
})
|
|
685051
|
+
.catch(error => {
|
|
685052
|
+
console.error('Error while fetching URL:', error);
|
|
685053
|
+
reject(error);
|
|
685054
|
+
});
|
|
685055
|
+
});
|
|
685056
|
+
}
|
|
685057
|
+
exports.checkContentType = checkContentType;
|
|
685058
|
+
function isValidDirect(extension) {
|
|
685059
|
+
switch (extension) {
|
|
685060
|
+
case '.png':
|
|
685061
|
+
case '.jpg':
|
|
685062
|
+
case '.jpeg':
|
|
685063
|
+
case '.gif':
|
|
685064
|
+
case '.webp':
|
|
685065
|
+
case '.tif':
|
|
685066
|
+
case '.tiff':
|
|
685067
|
+
return true;
|
|
685068
|
+
default:
|
|
685069
|
+
return false;
|
|
685070
|
+
}
|
|
685071
|
+
}
|
|
685072
|
+
function getFileExtensionFromMimeType(mimeType) {
|
|
685073
|
+
return mimeType ? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
685074
|
+
}
|
|
685024
685075
|
exports.COIN_TO_NETWORK = {
|
|
685025
685076
|
'xcp': 'BTC',
|
|
685026
685077
|
'ordinalsbtc': 'BTC',
|
|
@@ -685031,6 +685082,55 @@ exports.COIN_TO_NETWORK = {
|
|
|
685031
685082
|
'bel': 'Bel',
|
|
685032
685083
|
'nmc': 'Namecoin'
|
|
685033
685084
|
};
|
|
685085
|
+
const mimeToExtensionMap = {
|
|
685086
|
+
// Image formats
|
|
685087
|
+
"image/png": ".png",
|
|
685088
|
+
"image/jpeg": ".jpg",
|
|
685089
|
+
"image/jpe": ".jpe",
|
|
685090
|
+
"image/gif": ".gif",
|
|
685091
|
+
"image/webp": ".webp",
|
|
685092
|
+
"image/heif": ".heif",
|
|
685093
|
+
"image/bmp": ".bmp",
|
|
685094
|
+
"image/tiff": ".tiff",
|
|
685095
|
+
"image/tif": ".tif",
|
|
685096
|
+
"image/x-icon": ".ico",
|
|
685097
|
+
"image/svg+xml": ".svg",
|
|
685098
|
+
"image/heic": ".heic",
|
|
685099
|
+
"image/avif": ".avif",
|
|
685100
|
+
"image/apng": ".apng",
|
|
685101
|
+
"image/jp2": ".jp2",
|
|
685102
|
+
"image/jxr": ".jxr",
|
|
685103
|
+
"image/astc": ".astc",
|
|
685104
|
+
"image/jxl": ".jxl",
|
|
685105
|
+
"image/x-jng": ".jng",
|
|
685106
|
+
"image/x-ms-bmp": ".bmp",
|
|
685107
|
+
"image/x-png": ".png",
|
|
685108
|
+
"image/x-xbitmap": ".xbm",
|
|
685109
|
+
"image/x-xpixmap": ".xpm",
|
|
685110
|
+
"image/x-rgb": ".rgb",
|
|
685111
|
+
"image/x-portable-anymap": ".pnm",
|
|
685112
|
+
"image/x-portable-bitmap": ".pbm",
|
|
685113
|
+
"image/x-portable-graymap": ".pgm",
|
|
685114
|
+
"image/x-portable-pixmap": ".ppm",
|
|
685115
|
+
// Video formats
|
|
685116
|
+
"video/mp4": ".mp4",
|
|
685117
|
+
"video/x-m4v": ".m4v",
|
|
685118
|
+
"video/3gpp": ".3gp",
|
|
685119
|
+
"video/3gpp2": ".3g2",
|
|
685120
|
+
"video/webm": ".webm",
|
|
685121
|
+
"video/ogg": ".ogv",
|
|
685122
|
+
"video/x-msvideo": ".avi",
|
|
685123
|
+
"video/ms-asf": ".asf",
|
|
685124
|
+
"video/x-ms-wmv": ".wmv",
|
|
685125
|
+
"video/mpeg": ".mpeg",
|
|
685126
|
+
"video/quicktime": ".mov",
|
|
685127
|
+
"video/x-flv": ".flv",
|
|
685128
|
+
"video/x-matroska": ".mkv",
|
|
685129
|
+
"video/h264": ".h264",
|
|
685130
|
+
"video/h265": ".h265",
|
|
685131
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
685132
|
+
// Add more mappings if needed
|
|
685133
|
+
};
|
|
685034
685134
|
|
|
685035
685135
|
},{"./abi/abi.json":1,"./curated/metadata.json":2,"node-fetch":15}],5:[function(require,module,exports){
|
|
685036
685136
|
"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.0';
|
|
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;
|
|
@@ -526,6 +526,52 @@ function getHandlerContract(web3) {
|
|
|
526
526
|
});
|
|
527
527
|
}
|
|
528
528
|
exports.getHandlerContract = getHandlerContract;
|
|
529
|
+
function checkContentType(url) {
|
|
530
|
+
return new Promise((resolve, reject) => {
|
|
531
|
+
let returnVal = {};
|
|
532
|
+
fetch(url, { method: 'HEAD' })
|
|
533
|
+
.then(response => {
|
|
534
|
+
if (!response.ok) {
|
|
535
|
+
throw new Error('Network response was not ok');
|
|
536
|
+
}
|
|
537
|
+
if (response.status === 200) {
|
|
538
|
+
const contentType = response.headers.get('content-type');
|
|
539
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
540
|
+
returnVal.valid = true;
|
|
541
|
+
returnVal.contentType = contentType;
|
|
542
|
+
returnVal.extension = extension;
|
|
543
|
+
returnVal.embed = !isValidDirect(extension);
|
|
544
|
+
console.log('Content-Type:', contentType);
|
|
545
|
+
resolve(returnVal);
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
resolve(returnVal);
|
|
549
|
+
}
|
|
550
|
+
})
|
|
551
|
+
.catch(error => {
|
|
552
|
+
console.error('Error while fetching URL:', error);
|
|
553
|
+
reject(error);
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
exports.checkContentType = checkContentType;
|
|
558
|
+
function isValidDirect(extension) {
|
|
559
|
+
switch (extension) {
|
|
560
|
+
case '.png':
|
|
561
|
+
case '.jpg':
|
|
562
|
+
case '.jpeg':
|
|
563
|
+
case '.gif':
|
|
564
|
+
case '.webp':
|
|
565
|
+
case '.tif':
|
|
566
|
+
case '.tiff':
|
|
567
|
+
return true;
|
|
568
|
+
default:
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function getFileExtensionFromMimeType(mimeType) {
|
|
573
|
+
return mimeType ? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
574
|
+
}
|
|
529
575
|
exports.COIN_TO_NETWORK = {
|
|
530
576
|
'xcp': 'BTC',
|
|
531
577
|
'ordinalsbtc': 'BTC',
|
|
@@ -536,3 +582,52 @@ exports.COIN_TO_NETWORK = {
|
|
|
536
582
|
'bel': 'Bel',
|
|
537
583
|
'nmc': 'Namecoin'
|
|
538
584
|
};
|
|
585
|
+
const mimeToExtensionMap = {
|
|
586
|
+
// Image formats
|
|
587
|
+
"image/png": ".png",
|
|
588
|
+
"image/jpeg": ".jpg",
|
|
589
|
+
"image/jpe": ".jpe",
|
|
590
|
+
"image/gif": ".gif",
|
|
591
|
+
"image/webp": ".webp",
|
|
592
|
+
"image/heif": ".heif",
|
|
593
|
+
"image/bmp": ".bmp",
|
|
594
|
+
"image/tiff": ".tiff",
|
|
595
|
+
"image/tif": ".tif",
|
|
596
|
+
"image/x-icon": ".ico",
|
|
597
|
+
"image/svg+xml": ".svg",
|
|
598
|
+
"image/heic": ".heic",
|
|
599
|
+
"image/avif": ".avif",
|
|
600
|
+
"image/apng": ".apng",
|
|
601
|
+
"image/jp2": ".jp2",
|
|
602
|
+
"image/jxr": ".jxr",
|
|
603
|
+
"image/astc": ".astc",
|
|
604
|
+
"image/jxl": ".jxl",
|
|
605
|
+
"image/x-jng": ".jng",
|
|
606
|
+
"image/x-ms-bmp": ".bmp",
|
|
607
|
+
"image/x-png": ".png",
|
|
608
|
+
"image/x-xbitmap": ".xbm",
|
|
609
|
+
"image/x-xpixmap": ".xpm",
|
|
610
|
+
"image/x-rgb": ".rgb",
|
|
611
|
+
"image/x-portable-anymap": ".pnm",
|
|
612
|
+
"image/x-portable-bitmap": ".pbm",
|
|
613
|
+
"image/x-portable-graymap": ".pgm",
|
|
614
|
+
"image/x-portable-pixmap": ".ppm",
|
|
615
|
+
// Video formats
|
|
616
|
+
"video/mp4": ".mp4",
|
|
617
|
+
"video/x-m4v": ".m4v",
|
|
618
|
+
"video/3gpp": ".3gp",
|
|
619
|
+
"video/3gpp2": ".3g2",
|
|
620
|
+
"video/webm": ".webm",
|
|
621
|
+
"video/ogg": ".ogv",
|
|
622
|
+
"video/x-msvideo": ".avi",
|
|
623
|
+
"video/ms-asf": ".asf",
|
|
624
|
+
"video/x-ms-wmv": ".wmv",
|
|
625
|
+
"video/mpeg": ".mpeg",
|
|
626
|
+
"video/quicktime": ".mov",
|
|
627
|
+
"video/x-flv": ".flv",
|
|
628
|
+
"video/x-matroska": ".mkv",
|
|
629
|
+
"video/h264": ".h264",
|
|
630
|
+
"video/h265": ".h265",
|
|
631
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
632
|
+
// Add more mappings if needed
|
|
633
|
+
};
|
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.0';
|
|
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;
|
|
@@ -685021,6 +685026,52 @@ function getHandlerContract(web3) {
|
|
|
685021
685026
|
});
|
|
685022
685027
|
}
|
|
685023
685028
|
exports.getHandlerContract = getHandlerContract;
|
|
685029
|
+
function checkContentType(url) {
|
|
685030
|
+
return new Promise((resolve, reject) => {
|
|
685031
|
+
let returnVal = {};
|
|
685032
|
+
fetch(url, { method: 'HEAD' })
|
|
685033
|
+
.then(response => {
|
|
685034
|
+
if (!response.ok) {
|
|
685035
|
+
throw new Error('Network response was not ok');
|
|
685036
|
+
}
|
|
685037
|
+
if (response.status === 200) {
|
|
685038
|
+
const contentType = response.headers.get('content-type');
|
|
685039
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
685040
|
+
returnVal.valid = true;
|
|
685041
|
+
returnVal.contentType = contentType;
|
|
685042
|
+
returnVal.extension = extension;
|
|
685043
|
+
returnVal.embed = !isValidDirect(extension);
|
|
685044
|
+
console.log('Content-Type:', contentType);
|
|
685045
|
+
resolve(returnVal);
|
|
685046
|
+
}
|
|
685047
|
+
else {
|
|
685048
|
+
resolve(returnVal);
|
|
685049
|
+
}
|
|
685050
|
+
})
|
|
685051
|
+
.catch(error => {
|
|
685052
|
+
console.error('Error while fetching URL:', error);
|
|
685053
|
+
reject(error);
|
|
685054
|
+
});
|
|
685055
|
+
});
|
|
685056
|
+
}
|
|
685057
|
+
exports.checkContentType = checkContentType;
|
|
685058
|
+
function isValidDirect(extension) {
|
|
685059
|
+
switch (extension) {
|
|
685060
|
+
case '.png':
|
|
685061
|
+
case '.jpg':
|
|
685062
|
+
case '.jpeg':
|
|
685063
|
+
case '.gif':
|
|
685064
|
+
case '.webp':
|
|
685065
|
+
case '.tif':
|
|
685066
|
+
case '.tiff':
|
|
685067
|
+
return true;
|
|
685068
|
+
default:
|
|
685069
|
+
return false;
|
|
685070
|
+
}
|
|
685071
|
+
}
|
|
685072
|
+
function getFileExtensionFromMimeType(mimeType) {
|
|
685073
|
+
return mimeType ? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
685074
|
+
}
|
|
685024
685075
|
exports.COIN_TO_NETWORK = {
|
|
685025
685076
|
'xcp': 'BTC',
|
|
685026
685077
|
'ordinalsbtc': 'BTC',
|
|
@@ -685031,6 +685082,55 @@ exports.COIN_TO_NETWORK = {
|
|
|
685031
685082
|
'bel': 'Bel',
|
|
685032
685083
|
'nmc': 'Namecoin'
|
|
685033
685084
|
};
|
|
685085
|
+
const mimeToExtensionMap = {
|
|
685086
|
+
// Image formats
|
|
685087
|
+
"image/png": ".png",
|
|
685088
|
+
"image/jpeg": ".jpg",
|
|
685089
|
+
"image/jpe": ".jpe",
|
|
685090
|
+
"image/gif": ".gif",
|
|
685091
|
+
"image/webp": ".webp",
|
|
685092
|
+
"image/heif": ".heif",
|
|
685093
|
+
"image/bmp": ".bmp",
|
|
685094
|
+
"image/tiff": ".tiff",
|
|
685095
|
+
"image/tif": ".tif",
|
|
685096
|
+
"image/x-icon": ".ico",
|
|
685097
|
+
"image/svg+xml": ".svg",
|
|
685098
|
+
"image/heic": ".heic",
|
|
685099
|
+
"image/avif": ".avif",
|
|
685100
|
+
"image/apng": ".apng",
|
|
685101
|
+
"image/jp2": ".jp2",
|
|
685102
|
+
"image/jxr": ".jxr",
|
|
685103
|
+
"image/astc": ".astc",
|
|
685104
|
+
"image/jxl": ".jxl",
|
|
685105
|
+
"image/x-jng": ".jng",
|
|
685106
|
+
"image/x-ms-bmp": ".bmp",
|
|
685107
|
+
"image/x-png": ".png",
|
|
685108
|
+
"image/x-xbitmap": ".xbm",
|
|
685109
|
+
"image/x-xpixmap": ".xpm",
|
|
685110
|
+
"image/x-rgb": ".rgb",
|
|
685111
|
+
"image/x-portable-anymap": ".pnm",
|
|
685112
|
+
"image/x-portable-bitmap": ".pbm",
|
|
685113
|
+
"image/x-portable-graymap": ".pgm",
|
|
685114
|
+
"image/x-portable-pixmap": ".ppm",
|
|
685115
|
+
// Video formats
|
|
685116
|
+
"video/mp4": ".mp4",
|
|
685117
|
+
"video/x-m4v": ".m4v",
|
|
685118
|
+
"video/3gpp": ".3gp",
|
|
685119
|
+
"video/3gpp2": ".3g2",
|
|
685120
|
+
"video/webm": ".webm",
|
|
685121
|
+
"video/ogg": ".ogv",
|
|
685122
|
+
"video/x-msvideo": ".avi",
|
|
685123
|
+
"video/ms-asf": ".asf",
|
|
685124
|
+
"video/x-ms-wmv": ".wmv",
|
|
685125
|
+
"video/mpeg": ".mpeg",
|
|
685126
|
+
"video/quicktime": ".mov",
|
|
685127
|
+
"video/x-flv": ".flv",
|
|
685128
|
+
"video/x-matroska": ".mkv",
|
|
685129
|
+
"video/h264": ".h264",
|
|
685130
|
+
"video/h265": ".h265",
|
|
685131
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
685132
|
+
// Add more mappings if needed
|
|
685133
|
+
};
|
|
685034
685134
|
|
|
685035
685135
|
},{"./abi/abi.json":1,"./curated/metadata.json":2,"node-fetch":15}],5:[function(require,module,exports){
|
|
685036
685136
|
"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
|
@@ -486,6 +486,56 @@ export async function getHandlerContract(web3: any) {
|
|
|
486
486
|
return handlerContract
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
+
export function checkContentType(url: string) {
|
|
490
|
+
return new Promise((resolve, reject) => {
|
|
491
|
+
// Making a HTTP HEAD request to get only the headers
|
|
492
|
+
type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean };
|
|
493
|
+
let returnVal: ReturnVal = {};
|
|
494
|
+
fetch(url, { method: 'HEAD' })
|
|
495
|
+
.then(response => {
|
|
496
|
+
if (!response.ok) {
|
|
497
|
+
throw new Error('Network response was not ok');
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (response.status === 200) {
|
|
501
|
+
const contentType = response.headers.get('content-type');
|
|
502
|
+
let extension = getFileExtensionFromMimeType(contentType)
|
|
503
|
+
returnVal.valid = true
|
|
504
|
+
returnVal.contentType = contentType
|
|
505
|
+
returnVal.extension = extension
|
|
506
|
+
returnVal.embed = !isValidDirect(extension)
|
|
507
|
+
console.log('Content-Type:', contentType);
|
|
508
|
+
resolve(returnVal);
|
|
509
|
+
} else {
|
|
510
|
+
resolve(returnVal);
|
|
511
|
+
}
|
|
512
|
+
})
|
|
513
|
+
.catch(error => {
|
|
514
|
+
console.error('Error while fetching URL:', error);
|
|
515
|
+
reject(error);
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function isValidDirect(extension: string) {
|
|
521
|
+
switch (extension) {
|
|
522
|
+
case '.png':
|
|
523
|
+
case '.jpg':
|
|
524
|
+
case '.jpeg':
|
|
525
|
+
case '.gif':
|
|
526
|
+
case '.webp':
|
|
527
|
+
case '.tif':
|
|
528
|
+
case '.tiff':
|
|
529
|
+
return true;
|
|
530
|
+
default:
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function getFileExtensionFromMimeType(mimeType: string | null) {
|
|
536
|
+
return mimeType? mimeToExtensionMap[mimeType] : ''; // return an empty string if no match
|
|
537
|
+
}
|
|
538
|
+
|
|
489
539
|
export const COIN_TO_NETWORK: any = {
|
|
490
540
|
'xcp': 'BTC',
|
|
491
541
|
'ordinalsbtc': 'BTC',
|
|
@@ -496,3 +546,54 @@ export const COIN_TO_NETWORK: any = {
|
|
|
496
546
|
'bel': 'Bel',
|
|
497
547
|
'nmc':'Namecoin'
|
|
498
548
|
}
|
|
549
|
+
|
|
550
|
+
const mimeToExtensionMap: any = {
|
|
551
|
+
// Image formats
|
|
552
|
+
"image/png": ".png",
|
|
553
|
+
"image/jpeg": ".jpg",
|
|
554
|
+
"image/jpe": ".jpe",
|
|
555
|
+
"image/gif": ".gif",
|
|
556
|
+
"image/webp": ".webp",
|
|
557
|
+
"image/heif": ".heif",
|
|
558
|
+
"image/bmp": ".bmp",
|
|
559
|
+
"image/tiff": ".tiff",
|
|
560
|
+
"image/tif": ".tif",
|
|
561
|
+
"image/x-icon": ".ico",
|
|
562
|
+
"image/svg+xml": ".svg",
|
|
563
|
+
"image/heic": ".heic",
|
|
564
|
+
"image/avif": ".avif",
|
|
565
|
+
"image/apng": ".apng",
|
|
566
|
+
"image/jp2": ".jp2",
|
|
567
|
+
"image/jxr": ".jxr",
|
|
568
|
+
"image/astc": ".astc",
|
|
569
|
+
"image/jxl": ".jxl",
|
|
570
|
+
"image/x-jng": ".jng",
|
|
571
|
+
"image/x-ms-bmp": ".bmp",
|
|
572
|
+
"image/x-png": ".png",
|
|
573
|
+
"image/x-xbitmap": ".xbm",
|
|
574
|
+
"image/x-xpixmap": ".xpm",
|
|
575
|
+
"image/x-rgb": ".rgb",
|
|
576
|
+
"image/x-portable-anymap": ".pnm",
|
|
577
|
+
"image/x-portable-bitmap": ".pbm",
|
|
578
|
+
"image/x-portable-graymap": ".pgm",
|
|
579
|
+
"image/x-portable-pixmap": ".ppm",
|
|
580
|
+
|
|
581
|
+
// Video formats
|
|
582
|
+
"video/mp4": ".mp4",
|
|
583
|
+
"video/x-m4v": ".m4v",
|
|
584
|
+
"video/3gpp": ".3gp",
|
|
585
|
+
"video/3gpp2": ".3g2",
|
|
586
|
+
"video/webm": ".webm",
|
|
587
|
+
"video/ogg": ".ogv",
|
|
588
|
+
"video/x-msvideo": ".avi",
|
|
589
|
+
"video/ms-asf": ".asf",
|
|
590
|
+
"video/x-ms-wmv": ".wmv",
|
|
591
|
+
"video/mpeg": ".mpeg",
|
|
592
|
+
"video/quicktime": ".mov",
|
|
593
|
+
"video/x-flv": ".flv",
|
|
594
|
+
"video/x-matroska": ".mkv",
|
|
595
|
+
"video/h264": ".h264",
|
|
596
|
+
"video/h265": ".h265",
|
|
597
|
+
"video/vnd.dlna.mpeg-tts": ".ts"
|
|
598
|
+
// Add more mappings if needed
|
|
599
|
+
};
|
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;
|