@opexa/portal-sdk 0.57.11 → 0.57.12

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/index.d.cts CHANGED
@@ -2167,6 +2167,8 @@ declare class Sdk {
2167
2167
  get cxd(): string | null;
2168
2168
  private get locale();
2169
2169
  private get authMiddleware();
2170
+ private get fingerprintMiddleware();
2171
+ getFingerprint(): Promise<string | null>;
2170
2172
  private get domainMiddleware();
2171
2173
  private get miscMiddleware();
2172
2174
  signIn(input: NameAndPasswordSignInInput): Promise<NameAndPasswordSignInReturn>;
package/dist/index.d.ts CHANGED
@@ -2167,6 +2167,8 @@ declare class Sdk {
2167
2167
  get cxd(): string | null;
2168
2168
  private get locale();
2169
2169
  private get authMiddleware();
2170
+ private get fingerprintMiddleware();
2171
+ getFingerprint(): Promise<string | null>;
2170
2172
  private get domainMiddleware();
2171
2173
  private get miscMiddleware();
2172
2174
  signIn(input: NameAndPasswordSignInInput): Promise<NameAndPasswordSignInReturn>;
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ObjectId } from '@opexa/object-id';
2
2
  export { ObjectId } from '@opexa/object-id';
3
3
  import { Capacitor } from '@capacitor/core';
4
+ import { Thumbmark } from '@thumbmarkjs/thumbmarkjs';
4
5
  import cookies from 'js-cookie';
5
6
 
6
7
  // src/sdk/object-id.ts
@@ -6187,8 +6188,6 @@ function addHours(date, hours) {
6187
6188
  result.setHours(result.getHours() + hours);
6188
6189
  return result;
6189
6190
  }
6190
-
6191
- // src/sdk/utils.ts
6192
6191
  function getLocaleByCurrency(currency) {
6193
6192
  if (currency === "INR") return "en-IN";
6194
6193
  if (currency === "MYR") return "en-MY";
@@ -6218,6 +6217,28 @@ function parseFbCxd(input) {
6218
6217
  const fbAdditionalCxd = input.split(cxd)[1].slice(1);
6219
6218
  return { cxd, fbAdditionalCxd };
6220
6219
  }
6220
+ var thumbmark_instance;
6221
+ async function getFingerprint() {
6222
+ if (typeof window === "undefined") return null;
6223
+ if (!thumbmark_instance) {
6224
+ thumbmark_instance = new Thumbmark({
6225
+ api_key: "8294c227c5194f96e4deb022e8e76293",
6226
+ logging: false,
6227
+ timeout: 3e4,
6228
+ cache_lifetime_in_ms: 24 * 60 * 60 * 1e3
6229
+ // 24h
6230
+ });
6231
+ }
6232
+ try {
6233
+ const cached = sessionStorage.getItem("fingerprint");
6234
+ if (cached) return cached;
6235
+ const result = await thumbmark_instance.get();
6236
+ sessionStorage.setItem("fingerprint", result.thumbmark);
6237
+ return result.thumbmark;
6238
+ } catch {
6239
+ return null;
6240
+ }
6241
+ }
6221
6242
 
6222
6243
  // src/sdk/cellexpert-manager.ts
6223
6244
  var CXD_STORAGE_KEY = "sdk/cxd";
@@ -8760,6 +8781,7 @@ var Sdk = class {
8760
8781
  /**/
8761
8782
  this.authMiddleware,
8762
8783
  this.domainMiddleware,
8784
+ this.fingerprintMiddleware,
8763
8785
  this.miscMiddleware,
8764
8786
  this.middleware
8765
8787
  ],
@@ -8957,6 +8979,23 @@ var Sdk = class {
8957
8979
  return request;
8958
8980
  };
8959
8981
  }
8982
+ /*
8983
+ *=============================================
8984
+ * FINGERPRINT MIDDLEWARE
8985
+ *=============================================
8986
+ */
8987
+ get fingerprintMiddleware() {
8988
+ return async (request) => {
8989
+ const fingerprint = await this.getFingerprint();
8990
+ if (fingerprint) {
8991
+ request.headers.set("Fingerprint", fingerprint);
8992
+ }
8993
+ return request;
8994
+ };
8995
+ }
8996
+ async getFingerprint() {
8997
+ return await getFingerprint();
8998
+ }
8960
8999
  /*
8961
9000
  *=============================================
8962
9001
  * DOMAIN MIDDLEWARE