emblem-vault-sdk 1.10.0 → 1.10.2
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 +71 -13
- package/dist/index.js +1 -1
- package/dist/utils.js +71 -13
- package/docs/bundle.js +71 -13
- package/package.json +1 -1
- package/src/utils.ts +78 -19
package/dist/bundle.js
CHANGED
|
@@ -711421,7 +711421,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
711421
711421
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
711422
711422
|
const utils_1 = require("./utils");
|
|
711423
711423
|
const derive_1 = require("./derive");
|
|
711424
|
-
const SDK_VERSION = '1.10.
|
|
711424
|
+
const SDK_VERSION = '1.10.2';
|
|
711425
711425
|
class EmblemVaultSDK {
|
|
711426
711426
|
constructor(apiKey, baseUrl) {
|
|
711427
711427
|
this.apiKey = apiKey;
|
|
@@ -712628,33 +712628,91 @@ exports.getLegacyContract = getLegacyContract;
|
|
|
712628
712628
|
function checkContentType(url) {
|
|
712629
712629
|
return new Promise((resolve, reject) => {
|
|
712630
712630
|
let returnVal = { valid: false };
|
|
712631
|
-
|
|
712632
|
-
|
|
712631
|
+
// Function to make fetch requests
|
|
712632
|
+
function fetchUrl(method) {
|
|
712633
|
+
const controller = new AbortController();
|
|
712634
|
+
const timeoutId = setTimeout(() => controller.abort(), 3000); // 10 seconds timeout
|
|
712635
|
+
return fetch(url, { method: method, signal: controller.signal })
|
|
712633
712636
|
.then(response => {
|
|
712637
|
+
clearTimeout(timeoutId);
|
|
712634
712638
|
if (!response.ok) {
|
|
712635
712639
|
returnVal.valid = false;
|
|
712640
|
+
return resolve(returnVal);
|
|
712636
712641
|
}
|
|
712637
712642
|
else if (response.status === 200) {
|
|
712638
712643
|
const contentType = response.headers.get('content-type');
|
|
712639
|
-
|
|
712640
|
-
|
|
712641
|
-
|
|
712642
|
-
|
|
712643
|
-
|
|
712644
|
-
|
|
712644
|
+
if (!contentType && method === 'HEAD') {
|
|
712645
|
+
// If content-type is not found in HEAD, make a GET request
|
|
712646
|
+
return fetchUrl('GET');
|
|
712647
|
+
}
|
|
712648
|
+
else {
|
|
712649
|
+
// Process the content type and resolve the promise
|
|
712650
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
712651
|
+
returnVal.valid = true;
|
|
712652
|
+
returnVal.contentType = contentType;
|
|
712653
|
+
returnVal.extension = extension;
|
|
712654
|
+
returnVal.method = method;
|
|
712655
|
+
returnVal.embed = !isValidDirect(extension);
|
|
712656
|
+
console.log('Content-Type:', contentType);
|
|
712657
|
+
return resolve(returnVal);
|
|
712658
|
+
}
|
|
712659
|
+
}
|
|
712660
|
+
else {
|
|
712661
|
+
return resolve(returnVal);
|
|
712645
712662
|
}
|
|
712646
|
-
resolve(returnVal);
|
|
712647
712663
|
})
|
|
712648
712664
|
.catch(error => {
|
|
712665
|
+
clearTimeout(timeoutId);
|
|
712649
712666
|
console.error('Error while fetching URL:', error);
|
|
712650
|
-
resolve(returnVal);
|
|
712667
|
+
return resolve(returnVal);
|
|
712651
712668
|
});
|
|
712652
712669
|
}
|
|
712653
|
-
|
|
712654
|
-
|
|
712670
|
+
// Start with a HEAD request
|
|
712671
|
+
fetchUrl('HEAD').catch((error) => {
|
|
712672
|
+
console.error('Initial fetch error:', error);
|
|
712673
|
+
resolve(returnVal);
|
|
712674
|
+
});
|
|
712655
712675
|
});
|
|
712656
712676
|
}
|
|
712657
712677
|
exports.checkContentType = checkContentType;
|
|
712678
|
+
// export function checkContentType(url: string) {
|
|
712679
|
+
// return new Promise((resolve, reject) => {
|
|
712680
|
+
// // Making a HTTP HEAD request to get only the headers
|
|
712681
|
+
// type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean, method?: string};
|
|
712682
|
+
// let returnVal: ReturnVal = {valid: false};
|
|
712683
|
+
// function fetchUrl(method: string) {
|
|
712684
|
+
// fetch(url, { method: method })
|
|
712685
|
+
// .then(response => {
|
|
712686
|
+
// if (!response.ok) {
|
|
712687
|
+
// returnVal.valid = false
|
|
712688
|
+
// }
|
|
712689
|
+
// else if (response.status === 200) {
|
|
712690
|
+
// const contentType = response.headers.get('content-type');
|
|
712691
|
+
// if (!contentType) {
|
|
712692
|
+
// return fetchUrl('GET')
|
|
712693
|
+
// } else {
|
|
712694
|
+
// let extension = getFileExtensionFromMimeType(contentType)
|
|
712695
|
+
// returnVal.valid = true
|
|
712696
|
+
// returnVal.contentType = contentType
|
|
712697
|
+
// returnVal.extension = extension
|
|
712698
|
+
// returnVal.method = method
|
|
712699
|
+
// returnVal.embed = !isValidDirect(extension)
|
|
712700
|
+
// console.log('Content-Type:', contentType);
|
|
712701
|
+
// }
|
|
712702
|
+
// }
|
|
712703
|
+
// return resolve(returnVal);
|
|
712704
|
+
// })
|
|
712705
|
+
// .catch(error => {
|
|
712706
|
+
// console.error('Error while fetching URL:', error);
|
|
712707
|
+
// resolve(returnVal);
|
|
712708
|
+
// });
|
|
712709
|
+
// }
|
|
712710
|
+
// try {
|
|
712711
|
+
// fetchUrl('HEAD');
|
|
712712
|
+
// } catch (error) {
|
|
712713
|
+
// }
|
|
712714
|
+
// });
|
|
712715
|
+
// }
|
|
712658
712716
|
function isValidDirect(extension) {
|
|
712659
712717
|
switch (extension) {
|
|
712660
712718
|
case '.png':
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
36
36
|
const utils_1 = require("./utils");
|
|
37
37
|
const derive_1 = require("./derive");
|
|
38
|
-
const SDK_VERSION = '1.10.
|
|
38
|
+
const SDK_VERSION = '1.10.2';
|
|
39
39
|
class EmblemVaultSDK {
|
|
40
40
|
constructor(apiKey, baseUrl) {
|
|
41
41
|
this.apiKey = apiKey;
|
package/dist/utils.js
CHANGED
|
@@ -599,33 +599,91 @@ exports.getLegacyContract = getLegacyContract;
|
|
|
599
599
|
function checkContentType(url) {
|
|
600
600
|
return new Promise((resolve, reject) => {
|
|
601
601
|
let returnVal = { valid: false };
|
|
602
|
-
|
|
603
|
-
|
|
602
|
+
// Function to make fetch requests
|
|
603
|
+
function fetchUrl(method) {
|
|
604
|
+
const controller = new AbortController();
|
|
605
|
+
const timeoutId = setTimeout(() => controller.abort(), 3000); // 10 seconds timeout
|
|
606
|
+
return fetch(url, { method: method, signal: controller.signal })
|
|
604
607
|
.then(response => {
|
|
608
|
+
clearTimeout(timeoutId);
|
|
605
609
|
if (!response.ok) {
|
|
606
610
|
returnVal.valid = false;
|
|
611
|
+
return resolve(returnVal);
|
|
607
612
|
}
|
|
608
613
|
else if (response.status === 200) {
|
|
609
614
|
const contentType = response.headers.get('content-type');
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
615
|
+
if (!contentType && method === 'HEAD') {
|
|
616
|
+
// If content-type is not found in HEAD, make a GET request
|
|
617
|
+
return fetchUrl('GET');
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
// Process the content type and resolve the promise
|
|
621
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
622
|
+
returnVal.valid = true;
|
|
623
|
+
returnVal.contentType = contentType;
|
|
624
|
+
returnVal.extension = extension;
|
|
625
|
+
returnVal.method = method;
|
|
626
|
+
returnVal.embed = !isValidDirect(extension);
|
|
627
|
+
console.log('Content-Type:', contentType);
|
|
628
|
+
return resolve(returnVal);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
return resolve(returnVal);
|
|
633
|
+
}
|
|
618
634
|
})
|
|
619
635
|
.catch(error => {
|
|
636
|
+
clearTimeout(timeoutId);
|
|
620
637
|
console.error('Error while fetching URL:', error);
|
|
621
|
-
resolve(returnVal);
|
|
638
|
+
return resolve(returnVal);
|
|
622
639
|
});
|
|
623
640
|
}
|
|
624
|
-
|
|
625
|
-
|
|
641
|
+
// Start with a HEAD request
|
|
642
|
+
fetchUrl('HEAD').catch((error) => {
|
|
643
|
+
console.error('Initial fetch error:', error);
|
|
644
|
+
resolve(returnVal);
|
|
645
|
+
});
|
|
626
646
|
});
|
|
627
647
|
}
|
|
628
648
|
exports.checkContentType = checkContentType;
|
|
649
|
+
// export function checkContentType(url: string) {
|
|
650
|
+
// return new Promise((resolve, reject) => {
|
|
651
|
+
// // Making a HTTP HEAD request to get only the headers
|
|
652
|
+
// type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean, method?: string};
|
|
653
|
+
// let returnVal: ReturnVal = {valid: false};
|
|
654
|
+
// function fetchUrl(method: string) {
|
|
655
|
+
// fetch(url, { method: method })
|
|
656
|
+
// .then(response => {
|
|
657
|
+
// if (!response.ok) {
|
|
658
|
+
// returnVal.valid = false
|
|
659
|
+
// }
|
|
660
|
+
// else if (response.status === 200) {
|
|
661
|
+
// const contentType = response.headers.get('content-type');
|
|
662
|
+
// if (!contentType) {
|
|
663
|
+
// return fetchUrl('GET')
|
|
664
|
+
// } else {
|
|
665
|
+
// let extension = getFileExtensionFromMimeType(contentType)
|
|
666
|
+
// returnVal.valid = true
|
|
667
|
+
// returnVal.contentType = contentType
|
|
668
|
+
// returnVal.extension = extension
|
|
669
|
+
// returnVal.method = method
|
|
670
|
+
// returnVal.embed = !isValidDirect(extension)
|
|
671
|
+
// console.log('Content-Type:', contentType);
|
|
672
|
+
// }
|
|
673
|
+
// }
|
|
674
|
+
// return resolve(returnVal);
|
|
675
|
+
// })
|
|
676
|
+
// .catch(error => {
|
|
677
|
+
// console.error('Error while fetching URL:', error);
|
|
678
|
+
// resolve(returnVal);
|
|
679
|
+
// });
|
|
680
|
+
// }
|
|
681
|
+
// try {
|
|
682
|
+
// fetchUrl('HEAD');
|
|
683
|
+
// } catch (error) {
|
|
684
|
+
// }
|
|
685
|
+
// });
|
|
686
|
+
// }
|
|
629
687
|
function isValidDirect(extension) {
|
|
630
688
|
switch (extension) {
|
|
631
689
|
case '.png':
|
package/docs/bundle.js
CHANGED
|
@@ -711421,7 +711421,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
711421
711421
|
const bignumber_1 = require("@ethersproject/bignumber");
|
|
711422
711422
|
const utils_1 = require("./utils");
|
|
711423
711423
|
const derive_1 = require("./derive");
|
|
711424
|
-
const SDK_VERSION = '1.10.
|
|
711424
|
+
const SDK_VERSION = '1.10.2';
|
|
711425
711425
|
class EmblemVaultSDK {
|
|
711426
711426
|
constructor(apiKey, baseUrl) {
|
|
711427
711427
|
this.apiKey = apiKey;
|
|
@@ -712628,33 +712628,91 @@ exports.getLegacyContract = getLegacyContract;
|
|
|
712628
712628
|
function checkContentType(url) {
|
|
712629
712629
|
return new Promise((resolve, reject) => {
|
|
712630
712630
|
let returnVal = { valid: false };
|
|
712631
|
-
|
|
712632
|
-
|
|
712631
|
+
// Function to make fetch requests
|
|
712632
|
+
function fetchUrl(method) {
|
|
712633
|
+
const controller = new AbortController();
|
|
712634
|
+
const timeoutId = setTimeout(() => controller.abort(), 3000); // 10 seconds timeout
|
|
712635
|
+
return fetch(url, { method: method, signal: controller.signal })
|
|
712633
712636
|
.then(response => {
|
|
712637
|
+
clearTimeout(timeoutId);
|
|
712634
712638
|
if (!response.ok) {
|
|
712635
712639
|
returnVal.valid = false;
|
|
712640
|
+
return resolve(returnVal);
|
|
712636
712641
|
}
|
|
712637
712642
|
else if (response.status === 200) {
|
|
712638
712643
|
const contentType = response.headers.get('content-type');
|
|
712639
|
-
|
|
712640
|
-
|
|
712641
|
-
|
|
712642
|
-
|
|
712643
|
-
|
|
712644
|
-
|
|
712644
|
+
if (!contentType && method === 'HEAD') {
|
|
712645
|
+
// If content-type is not found in HEAD, make a GET request
|
|
712646
|
+
return fetchUrl('GET');
|
|
712647
|
+
}
|
|
712648
|
+
else {
|
|
712649
|
+
// Process the content type and resolve the promise
|
|
712650
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
712651
|
+
returnVal.valid = true;
|
|
712652
|
+
returnVal.contentType = contentType;
|
|
712653
|
+
returnVal.extension = extension;
|
|
712654
|
+
returnVal.method = method;
|
|
712655
|
+
returnVal.embed = !isValidDirect(extension);
|
|
712656
|
+
console.log('Content-Type:', contentType);
|
|
712657
|
+
return resolve(returnVal);
|
|
712658
|
+
}
|
|
712659
|
+
}
|
|
712660
|
+
else {
|
|
712661
|
+
return resolve(returnVal);
|
|
712645
712662
|
}
|
|
712646
|
-
resolve(returnVal);
|
|
712647
712663
|
})
|
|
712648
712664
|
.catch(error => {
|
|
712665
|
+
clearTimeout(timeoutId);
|
|
712649
712666
|
console.error('Error while fetching URL:', error);
|
|
712650
|
-
resolve(returnVal);
|
|
712667
|
+
return resolve(returnVal);
|
|
712651
712668
|
});
|
|
712652
712669
|
}
|
|
712653
|
-
|
|
712654
|
-
|
|
712670
|
+
// Start with a HEAD request
|
|
712671
|
+
fetchUrl('HEAD').catch((error) => {
|
|
712672
|
+
console.error('Initial fetch error:', error);
|
|
712673
|
+
resolve(returnVal);
|
|
712674
|
+
});
|
|
712655
712675
|
});
|
|
712656
712676
|
}
|
|
712657
712677
|
exports.checkContentType = checkContentType;
|
|
712678
|
+
// export function checkContentType(url: string) {
|
|
712679
|
+
// return new Promise((resolve, reject) => {
|
|
712680
|
+
// // Making a HTTP HEAD request to get only the headers
|
|
712681
|
+
// type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean, method?: string};
|
|
712682
|
+
// let returnVal: ReturnVal = {valid: false};
|
|
712683
|
+
// function fetchUrl(method: string) {
|
|
712684
|
+
// fetch(url, { method: method })
|
|
712685
|
+
// .then(response => {
|
|
712686
|
+
// if (!response.ok) {
|
|
712687
|
+
// returnVal.valid = false
|
|
712688
|
+
// }
|
|
712689
|
+
// else if (response.status === 200) {
|
|
712690
|
+
// const contentType = response.headers.get('content-type');
|
|
712691
|
+
// if (!contentType) {
|
|
712692
|
+
// return fetchUrl('GET')
|
|
712693
|
+
// } else {
|
|
712694
|
+
// let extension = getFileExtensionFromMimeType(contentType)
|
|
712695
|
+
// returnVal.valid = true
|
|
712696
|
+
// returnVal.contentType = contentType
|
|
712697
|
+
// returnVal.extension = extension
|
|
712698
|
+
// returnVal.method = method
|
|
712699
|
+
// returnVal.embed = !isValidDirect(extension)
|
|
712700
|
+
// console.log('Content-Type:', contentType);
|
|
712701
|
+
// }
|
|
712702
|
+
// }
|
|
712703
|
+
// return resolve(returnVal);
|
|
712704
|
+
// })
|
|
712705
|
+
// .catch(error => {
|
|
712706
|
+
// console.error('Error while fetching URL:', error);
|
|
712707
|
+
// resolve(returnVal);
|
|
712708
|
+
// });
|
|
712709
|
+
// }
|
|
712710
|
+
// try {
|
|
712711
|
+
// fetchUrl('HEAD');
|
|
712712
|
+
// } catch (error) {
|
|
712713
|
+
// }
|
|
712714
|
+
// });
|
|
712715
|
+
// }
|
|
712658
712716
|
function isValidDirect(extension) {
|
|
712659
712717
|
switch (extension) {
|
|
712660
712718
|
case '.png':
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -568,35 +568,94 @@ export async function getLegacyContract(web3: any) {
|
|
|
568
568
|
|
|
569
569
|
export function checkContentType(url: string) {
|
|
570
570
|
return new Promise((resolve, reject) => {
|
|
571
|
-
//
|
|
572
|
-
type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean };
|
|
573
|
-
let returnVal: ReturnVal = {valid: false};
|
|
574
|
-
|
|
575
|
-
|
|
571
|
+
// Define the return value type
|
|
572
|
+
type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean, method?: string };
|
|
573
|
+
let returnVal: ReturnVal = { valid: false };
|
|
574
|
+
|
|
575
|
+
// Function to make fetch requests
|
|
576
|
+
function fetchUrl(method: string): any {
|
|
577
|
+
const controller = new AbortController();
|
|
578
|
+
const timeoutId = setTimeout(() => controller.abort(), 3000); // 3 seconds timeout (probably need to make this timeout only for HEAD)
|
|
579
|
+
|
|
580
|
+
return fetch(url, { method: method, signal: controller.signal })
|
|
576
581
|
.then(response => {
|
|
582
|
+
clearTimeout(timeoutId);
|
|
577
583
|
if (!response.ok) {
|
|
578
|
-
returnVal.valid = false
|
|
579
|
-
|
|
580
|
-
else if (response.status === 200) {
|
|
584
|
+
returnVal.valid = false;
|
|
585
|
+
return resolve(returnVal);
|
|
586
|
+
} else if (response.status === 200) {
|
|
581
587
|
const contentType = response.headers.get('content-type');
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
588
|
+
if (!contentType && method === 'HEAD') {
|
|
589
|
+
// If content-type is not found in HEAD, make a GET request
|
|
590
|
+
return fetchUrl('GET');
|
|
591
|
+
} else {
|
|
592
|
+
// Process the content type and resolve the promise
|
|
593
|
+
let extension = getFileExtensionFromMimeType(contentType);
|
|
594
|
+
returnVal.valid = true;
|
|
595
|
+
returnVal.contentType = contentType;
|
|
596
|
+
returnVal.extension = extension;
|
|
597
|
+
returnVal.method = method;
|
|
598
|
+
returnVal.embed = !isValidDirect(extension);
|
|
599
|
+
console.log('Content-Type:', contentType);
|
|
600
|
+
return resolve(returnVal);
|
|
601
|
+
}
|
|
602
|
+
} else {
|
|
603
|
+
return resolve(returnVal);
|
|
604
|
+
}
|
|
590
605
|
})
|
|
591
606
|
.catch(error => {
|
|
607
|
+
clearTimeout(timeoutId);
|
|
592
608
|
console.error('Error while fetching URL:', error);
|
|
593
|
-
resolve(returnVal);
|
|
609
|
+
return resolve(returnVal);
|
|
594
610
|
});
|
|
595
|
-
|
|
611
|
+
}
|
|
596
612
|
|
|
597
|
-
|
|
613
|
+
// Start with a HEAD request
|
|
614
|
+
fetchUrl('HEAD').catch((error: any) => {
|
|
615
|
+
console.error('Initial fetch error:', error);
|
|
616
|
+
resolve(returnVal);
|
|
617
|
+
});
|
|
598
618
|
});
|
|
599
619
|
}
|
|
620
|
+
// export function checkContentType(url: string) {
|
|
621
|
+
// return new Promise((resolve, reject) => {
|
|
622
|
+
// // Making a HTTP HEAD request to get only the headers
|
|
623
|
+
// type ReturnVal = { valid?: boolean, contentType?: string | null, extension?: string, embed?: boolean, method?: string};
|
|
624
|
+
// let returnVal: ReturnVal = {valid: false};
|
|
625
|
+
// function fetchUrl(method: string) {
|
|
626
|
+
// fetch(url, { method: method })
|
|
627
|
+
// .then(response => {
|
|
628
|
+
// if (!response.ok) {
|
|
629
|
+
// returnVal.valid = false
|
|
630
|
+
// }
|
|
631
|
+
// else if (response.status === 200) {
|
|
632
|
+
// const contentType = response.headers.get('content-type');
|
|
633
|
+
// if (!contentType) {
|
|
634
|
+
// return fetchUrl('GET')
|
|
635
|
+
// } else {
|
|
636
|
+
// let extension = getFileExtensionFromMimeType(contentType)
|
|
637
|
+
// returnVal.valid = true
|
|
638
|
+
// returnVal.contentType = contentType
|
|
639
|
+
// returnVal.extension = extension
|
|
640
|
+
// returnVal.method = method
|
|
641
|
+
// returnVal.embed = !isValidDirect(extension)
|
|
642
|
+
// console.log('Content-Type:', contentType);
|
|
643
|
+
// }
|
|
644
|
+
// }
|
|
645
|
+
// return resolve(returnVal);
|
|
646
|
+
// })
|
|
647
|
+
// .catch(error => {
|
|
648
|
+
// console.error('Error while fetching URL:', error);
|
|
649
|
+
// resolve(returnVal);
|
|
650
|
+
// });
|
|
651
|
+
// }
|
|
652
|
+
// try {
|
|
653
|
+
// fetchUrl('HEAD');
|
|
654
|
+
// } catch (error) {
|
|
655
|
+
|
|
656
|
+
// }
|
|
657
|
+
// });
|
|
658
|
+
// }
|
|
600
659
|
|
|
601
660
|
function isValidDirect(extension: string) {
|
|
602
661
|
switch (extension) {
|