@opexa/portal-sdk 0.59.138 → 0.59.141
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/{chunk-Q5CO6LH3.js → chunk-B7AF5D65.js} +113 -9
- package/dist/chunk-B7AF5D65.js.map +1 -0
- package/dist/index.cjs +113 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +110 -6
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-Q5CO6LH3.js.map +0 -1
|
@@ -4888,9 +4888,110 @@ var AccountService = class {
|
|
|
4888
4888
|
};
|
|
4889
4889
|
}
|
|
4890
4890
|
};
|
|
4891
|
+
|
|
4892
|
+
// src/utils/capture-fingerprint-preference.ts
|
|
4893
|
+
function captureFingerprintPreference(search) {
|
|
4894
|
+
if (typeof window === "undefined") return;
|
|
4895
|
+
const preference = new URLSearchParams(search ?? window.location.search).get(
|
|
4896
|
+
"useFingerPrint"
|
|
4897
|
+
);
|
|
4898
|
+
if (preference === "true") {
|
|
4899
|
+
sessionStorage.setItem("useFingerPrint", "true");
|
|
4900
|
+
} else if (preference === "false") {
|
|
4901
|
+
sessionStorage.removeItem("useFingerPrint");
|
|
4902
|
+
}
|
|
4903
|
+
}
|
|
4891
4904
|
var thumbmark_instance;
|
|
4905
|
+
var opexaFingerprintPromise;
|
|
4906
|
+
function isNonemptyString(value) {
|
|
4907
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
4908
|
+
}
|
|
4909
|
+
async function generateOpexaFingerprint() {
|
|
4910
|
+
try {
|
|
4911
|
+
const {
|
|
4912
|
+
generateHardwareSignal,
|
|
4913
|
+
generateSystemSignal,
|
|
4914
|
+
generatePluginSignal,
|
|
4915
|
+
generateWebglSignal,
|
|
4916
|
+
generateCanvasSignal
|
|
4917
|
+
} = await import('@opexa/fingerprint');
|
|
4918
|
+
const signals = await Promise.all([
|
|
4919
|
+
generateHardwareSignal(),
|
|
4920
|
+
generateSystemSignal(),
|
|
4921
|
+
generatePluginSignal(),
|
|
4922
|
+
generateWebglSignal(),
|
|
4923
|
+
generateCanvasSignal()
|
|
4924
|
+
]);
|
|
4925
|
+
if (!signals.every(isNonemptyString)) {
|
|
4926
|
+
throw new Error("Fingerprint generation returned an invalid signal");
|
|
4927
|
+
}
|
|
4928
|
+
const [hardware, system, plugin, webgl, canvas] = signals;
|
|
4929
|
+
const query = new URLSearchParams({
|
|
4930
|
+
hardware,
|
|
4931
|
+
system,
|
|
4932
|
+
plugin,
|
|
4933
|
+
webgl,
|
|
4934
|
+
canvas
|
|
4935
|
+
});
|
|
4936
|
+
const controller = new AbortController();
|
|
4937
|
+
let timeout;
|
|
4938
|
+
try {
|
|
4939
|
+
const request = async () => {
|
|
4940
|
+
const response = await fetch(
|
|
4941
|
+
`https://fingerprint.atalos.io/fingerprint?${query}`,
|
|
4942
|
+
{ cache: "no-store", signal: controller.signal }
|
|
4943
|
+
);
|
|
4944
|
+
if (!response.ok) {
|
|
4945
|
+
throw new Error(`Fingerprint request failed: ${response.status}`);
|
|
4946
|
+
}
|
|
4947
|
+
const payload = await response.json();
|
|
4948
|
+
if (!payload || typeof payload !== "object" || !("id" in payload) || !isNonemptyString(payload.id)) {
|
|
4949
|
+
throw new Error("Fingerprint response did not contain a valid id");
|
|
4950
|
+
}
|
|
4951
|
+
return payload.id;
|
|
4952
|
+
};
|
|
4953
|
+
const id = await Promise.race([
|
|
4954
|
+
request(),
|
|
4955
|
+
new Promise((_, reject) => {
|
|
4956
|
+
timeout = setTimeout(() => {
|
|
4957
|
+
reject(new Error("Fingerprint request timed out"));
|
|
4958
|
+
controller.abort();
|
|
4959
|
+
}, 3e4);
|
|
4960
|
+
})
|
|
4961
|
+
]);
|
|
4962
|
+
try {
|
|
4963
|
+
sessionStorage.setItem("opexaFingerprint", id);
|
|
4964
|
+
} catch {
|
|
4965
|
+
}
|
|
4966
|
+
return id;
|
|
4967
|
+
} finally {
|
|
4968
|
+
clearTimeout(timeout);
|
|
4969
|
+
}
|
|
4970
|
+
} catch (error) {
|
|
4971
|
+
throw error instanceof Error ? error : new Error("Fingerprint generation failed");
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4892
4974
|
async function getFingerPrint() {
|
|
4893
4975
|
if (typeof window === "undefined") return null;
|
|
4976
|
+
let useOpexaFingerprint;
|
|
4977
|
+
try {
|
|
4978
|
+
useOpexaFingerprint = sessionStorage.getItem("useFingerPrint") === "true";
|
|
4979
|
+
} catch {
|
|
4980
|
+
return null;
|
|
4981
|
+
}
|
|
4982
|
+
if (useOpexaFingerprint) {
|
|
4983
|
+
try {
|
|
4984
|
+
const cached = sessionStorage.getItem("opexaFingerprint");
|
|
4985
|
+
if (isNonemptyString(cached)) return cached;
|
|
4986
|
+
} catch {
|
|
4987
|
+
}
|
|
4988
|
+
if (!opexaFingerprintPromise) {
|
|
4989
|
+
opexaFingerprintPromise = generateOpexaFingerprint().finally(() => {
|
|
4990
|
+
opexaFingerprintPromise = void 0;
|
|
4991
|
+
});
|
|
4992
|
+
}
|
|
4993
|
+
return await opexaFingerprintPromise;
|
|
4994
|
+
}
|
|
4894
4995
|
if (!thumbmark_instance) {
|
|
4895
4996
|
thumbmark_instance = new Thumbmark({
|
|
4896
4997
|
logging: false,
|
|
@@ -4963,6 +5064,7 @@ var AuthService = class {
|
|
|
4963
5064
|
async createSession(input, version = 1) {
|
|
4964
5065
|
const headers = new Headers(this.headers);
|
|
4965
5066
|
if (version === 3 || version === 4) {
|
|
5067
|
+
captureFingerprintPreference();
|
|
4966
5068
|
const fingerprint = await getFingerPrint();
|
|
4967
5069
|
if (fingerprint) {
|
|
4968
5070
|
headers.append("Fingerprint", fingerprint);
|
|
@@ -5105,13 +5207,14 @@ var AuthService = class {
|
|
|
5105
5207
|
if (version !== 4 || refreshToken) {
|
|
5106
5208
|
headers.append("Authorization", `Bearer ${refreshToken}`);
|
|
5107
5209
|
}
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
}
|
|
5210
|
+
if (version === 3 || version === 4) {
|
|
5211
|
+
captureFingerprintPreference();
|
|
5212
|
+
const fingerprint = await getFingerPrint();
|
|
5213
|
+
if (fingerprint) {
|
|
5214
|
+
headers.append("Fingerprint", fingerprint);
|
|
5114
5215
|
}
|
|
5216
|
+
}
|
|
5217
|
+
try {
|
|
5115
5218
|
const isWeb = isWebPlatform();
|
|
5116
5219
|
const queryParam = isWeb && version === 4 ? "?type=web" : "";
|
|
5117
5220
|
const res = await fetch(
|
|
@@ -5169,6 +5272,7 @@ var AuthService = class {
|
|
|
5169
5272
|
const headers = new Headers(this.headers);
|
|
5170
5273
|
headers.append("Authorization", `Bearer ${accessToken}`);
|
|
5171
5274
|
if (version === 3 || version === 4) {
|
|
5275
|
+
captureFingerprintPreference();
|
|
5172
5276
|
const fingerprint = await getFingerPrint();
|
|
5173
5277
|
if (fingerprint) {
|
|
5174
5278
|
headers.append("Fingerprint", fingerprint);
|
|
@@ -7196,6 +7300,6 @@ var ExtensionService = class {
|
|
|
7196
7300
|
}
|
|
7197
7301
|
};
|
|
7198
7302
|
|
|
7199
|
-
export { AccountService, AuthService, CmsPortalService, ExtensionService, FileService, GameService, PortalService, ReportService, TriggerService, WalletService, getFingerPrint, isIOSPlatform };
|
|
7200
|
-
//# sourceMappingURL=chunk-
|
|
7201
|
-
//# sourceMappingURL=chunk-
|
|
7303
|
+
export { AccountService, AuthService, CmsPortalService, ExtensionService, FileService, GameService, PortalService, ReportService, TriggerService, WalletService, captureFingerprintPreference, getFingerPrint, isIOSPlatform };
|
|
7304
|
+
//# sourceMappingURL=chunk-B7AF5D65.js.map
|
|
7305
|
+
//# sourceMappingURL=chunk-B7AF5D65.js.map
|