@goplus123/core-api 1.0.2 → 1.0.3

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.js CHANGED
@@ -394,7 +394,7 @@ var WsClient = class {
394
394
  ...options.reconnect
395
395
  },
396
396
  heartbeat: {
397
- interval: 1e4,
397
+ interval: 3e4,
398
398
  timeout: 3e4,
399
399
  pingType: "ping",
400
400
  pongType: "pong",
@@ -680,6 +680,10 @@ var WsClient = class {
680
680
  this.lastPongTime = Date.now();
681
681
  return;
682
682
  }
683
+ if (this.isAliveAck(msg, payload)) {
684
+ this.lastPongTime = Date.now();
685
+ return;
686
+ }
683
687
  const requestId = msg.requestId ?? (payload && typeof payload === "object" ? payload.requestId ?? payload?.data?.requestId : void 0);
684
688
  const resolved = requestId ? this.tryResolvePending(requestId, type, payload) : false;
685
689
  if (!resolved) {
@@ -695,6 +699,10 @@ var WsClient = class {
695
699
  this.lastPongTime = Date.now();
696
700
  return;
697
701
  }
702
+ if (this.isAliveAck(msg, payload)) {
703
+ this.lastPongTime = Date.now();
704
+ return;
705
+ }
698
706
  const requestId = msg.requestId ?? (payload && typeof payload === "object" ? payload.requestId ?? payload?.data?.requestId : void 0);
699
707
  const resolved = requestId ? this.tryResolvePending(requestId, functionName, payload) : false;
700
708
  if (!resolved) {
@@ -744,7 +752,23 @@ var WsClient = class {
744
752
  const ping = () => {
745
753
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
746
754
  this.lastPingTime = Date.now();
747
- this.send(hb.pingType ?? "ping");
755
+ const requestId = this.requestId;
756
+ const deviceType = this.headerConfig.deviceType === "" || this.headerConfig.deviceType === void 0 ? 1 : this.headerConfig.deviceType;
757
+ const message = JSON.stringify({
758
+ service: "connection",
759
+ functionName: "isAlive",
760
+ data: {
761
+ _heartBeat: true,
762
+ deviceType,
763
+ deviceId: this.headerConfig.deviceId ?? "",
764
+ platformId: this.headerConfig.platformId ?? "",
765
+ version: this.headerConfig.version ?? "",
766
+ uuid: this.options.protocols,
767
+ requestId,
768
+ childPlatformId: this.headerConfig.childPlatformId ?? ""
769
+ }
770
+ });
771
+ this.ws.send(message);
748
772
  };
749
773
  ping();
750
774
  this.heartbeatTimer = window.setInterval(() => {
@@ -863,6 +887,12 @@ var WsClient = class {
863
887
  isPong(type) {
864
888
  return type === (this.options.heartbeat?.pongType ?? "pong");
865
889
  }
890
+ isAliveAck(msg, payload) {
891
+ if (!msg || typeof msg !== "object") return false;
892
+ if (msg.service !== "connection") return false;
893
+ if (msg.functionName !== "isAlive" && msg.type !== "isAlive") return false;
894
+ return payload && typeof payload === "object" && payload.status === 200;
895
+ }
866
896
  async buildURL(params) {
867
897
  let urlStr = this.options.url;
868
898
  if (!/^\w+:\/\//.test(urlStr)) {
@@ -4243,11 +4273,286 @@ var cmsEndpoints = {
4243
4273
  })
4244
4274
  };
4245
4275
 
4276
+ // src/spec/auth.ts
4277
+ var authEndpoints = {
4278
+ playerRegisterRequestCode: defineEndpoint({
4279
+ id: "auth.playerRegisterRequestCode",
4280
+ transport: "grpc",
4281
+ grpc: {
4282
+ service: FrontendAuthService,
4283
+ methodName: "playerRegisterRequestCode",
4284
+ requestSchema: PlayerRegisterRequestCodeReqSchema
4285
+ }
4286
+ }),
4287
+ playerRegisterWithCode: defineEndpoint({
4288
+ id: "auth.playerRegisterWithCode",
4289
+ transport: "grpc",
4290
+ grpc: {
4291
+ service: FrontendAuthService,
4292
+ methodName: "playerRegisterWithCode",
4293
+ requestSchema: PlayerRegisterWithCodeReqSchema
4294
+ }
4295
+ }),
4296
+ playerLoginWithSessionToken: defineEndpoint({
4297
+ id: "auth.playerLoginWithSessionToken",
4298
+ transport: "grpc",
4299
+ grpc: {
4300
+ service: FrontendAuthService,
4301
+ methodName: "playerLoginWithSessionToken",
4302
+ requestSchema: PlayerLoginWithSessionTokenReqSchema
4303
+ }
4304
+ }),
4305
+ phoneNumberLoginWithPassword: defineEndpoint({
4306
+ id: "auth.phoneNumberLoginWithPassword",
4307
+ transport: "grpc",
4308
+ grpc: {
4309
+ service: FrontendAuthService,
4310
+ methodName: "phoneNumberLoginWithPassword",
4311
+ requestSchema: PhoneNumberLoginWithPasswordReqSchema
4312
+ }
4313
+ }),
4314
+ playerLoginOrRegisterWithSMS: defineEndpoint({
4315
+ id: "auth.playerLoginOrRegisterWithSMS",
4316
+ transport: "grpc",
4317
+ grpc: {
4318
+ service: FrontendAuthService,
4319
+ methodName: "playerLoginOrRegisterWithSMS",
4320
+ requestSchema: PlayerLoginOrRegisterWithSMSReqSchema
4321
+ }
4322
+ }),
4323
+ playerLogout: defineEndpoint({
4324
+ id: "auth.playerLogout",
4325
+ transport: "grpc",
4326
+ grpc: {
4327
+ service: FrontendAuthService,
4328
+ methodName: "playerLogout",
4329
+ requestSchema: PlayerLogoutReqSchema
4330
+ }
4331
+ }),
4332
+ authenticate: defineEndpoint({
4333
+ id: "auth.authenticate",
4334
+ transport: "grpc",
4335
+ grpc: {
4336
+ service: FrontendAuthService,
4337
+ methodName: "authenticate",
4338
+ requestSchema: AuthenticateReqSchema
4339
+ }
4340
+ }),
4341
+ sendSmsCode: defineEndpoint({
4342
+ id: "auth.sendSmsCode",
4343
+ transport: "grpc",
4344
+ grpc: {
4345
+ service: FrontendAuthService,
4346
+ methodName: "sendSmsCode",
4347
+ requestSchema: SendSmsCodeReqSchema
4348
+ }
4349
+ }),
4350
+ sendSmsCodeViber: defineEndpoint({
4351
+ id: "auth.sendSmsCodeViber",
4352
+ transport: "grpc",
4353
+ grpc: {
4354
+ service: FrontendAuthService,
4355
+ methodName: "sendSmsCodeViber",
4356
+ requestSchema: SendSmsCodeViberReqSchema
4357
+ }
4358
+ }),
4359
+ playerLoginOrRegisterWithFacebook: defineEndpoint({
4360
+ id: "auth.playerLoginOrRegisterWithFacebook",
4361
+ transport: "grpc",
4362
+ grpc: {
4363
+ service: FrontendFacebookService,
4364
+ methodName: "playerLoginOrRegisterWithFacebook",
4365
+ requestSchema: PlayerLoginOrRegisterWithFacebookReqSchema
4366
+ }
4367
+ }),
4368
+ getFacebookConsentPage: defineEndpoint({
4369
+ id: "auth.getFacebookConsentPage",
4370
+ transport: "grpc",
4371
+ grpc: {
4372
+ service: FrontendFacebookService,
4373
+ methodName: "getFacebookConsentPage",
4374
+ requestSchema: GetFacebookConsentPageReqSchema
4375
+ }
4376
+ }),
4377
+ facebookAuthorization: defineEndpoint({
4378
+ id: "auth.facebookAuthorization",
4379
+ transport: "grpc",
4380
+ grpc: {
4381
+ service: FrontendFacebookService,
4382
+ methodName: "facebookAuthorization",
4383
+ requestSchema: FacebookAuthorizationReqSchema
4384
+ }
4385
+ }),
4386
+ getFacebookFriendList: defineEndpoint({
4387
+ id: "auth.getFacebookFriendList",
4388
+ transport: "grpc",
4389
+ grpc: {
4390
+ service: FrontendFacebookService,
4391
+ methodName: "getFacebookFriendList",
4392
+ requestSchema: GetFacebookFriendListReqSchema
4393
+ }
4394
+ }),
4395
+ manualFetchFacebookFriends: defineEndpoint({
4396
+ id: "auth.manualFetchFacebookFriends",
4397
+ transport: "grpc",
4398
+ grpc: {
4399
+ service: FrontendFacebookService,
4400
+ methodName: "manualFetchFacebookFriends",
4401
+ requestSchema: ManualFetchFacebookFriendsReqSchema
4402
+ }
4403
+ }),
4404
+ bindFacebookAccount: defineEndpoint({
4405
+ id: "auth.bindFacebookAccount",
4406
+ transport: "grpc",
4407
+ grpc: {
4408
+ service: FrontendFacebookService,
4409
+ methodName: "bindFacebookAccount",
4410
+ requestSchema: BindFacebookAccountReqSchema
4411
+ }
4412
+ }),
4413
+ unbindFacebookAccount: defineEndpoint({
4414
+ id: "auth.unbindFacebookAccount",
4415
+ transport: "grpc",
4416
+ grpc: {
4417
+ service: FrontendFacebookService,
4418
+ methodName: "unbindFacebookAccount",
4419
+ requestSchema: EmptySchema
4420
+ }
4421
+ }),
4422
+ facebookVerifyPhoneNumber: defineEndpoint({
4423
+ id: "auth.facebookVerifyPhoneNumber",
4424
+ transport: "grpc",
4425
+ grpc: {
4426
+ service: FrontendFacebookService,
4427
+ methodName: "facebookVerifyPhoneNumber",
4428
+ requestSchema: FacebookVerifyPhoneNumberReqSchema
4429
+ }
4430
+ }),
4431
+ enableFaceId: defineEndpoint({
4432
+ id: "auth.enableFaceId",
4433
+ transport: "grpc",
4434
+ grpc: {
4435
+ service: FrontendFaceIdService,
4436
+ methodName: "enableFaceId",
4437
+ requestSchema: EnableFaceIdReqSchema
4438
+ }
4439
+ }),
4440
+ initFaceIdSession: defineEndpoint({
4441
+ id: "auth.initFaceIdSession",
4442
+ transport: "grpc",
4443
+ grpc: {
4444
+ service: FrontendFaceIdService,
4445
+ methodName: "initFaceIdSession",
4446
+ requestSchema: InitFaceIdSessionReqSchema
4447
+ }
4448
+ }),
4449
+ playerLoginWithFaceId: defineEndpoint({
4450
+ id: "auth.playerLoginWithFaceId",
4451
+ transport: "grpc",
4452
+ grpc: {
4453
+ service: FrontendFaceIdService,
4454
+ methodName: "playerLoginWithFaceId",
4455
+ requestSchema: PlayerLoginWithFaceIdReqSchema
4456
+ }
4457
+ }),
4458
+ disableFaceId: defineEndpoint({
4459
+ id: "auth.disableFaceId",
4460
+ transport: "grpc",
4461
+ grpc: {
4462
+ service: FrontendFaceIdService,
4463
+ methodName: "disableFaceId",
4464
+ requestSchema: DisableFaceIdReqSchema
4465
+ }
4466
+ }),
4467
+ initEnrollSession: defineEndpoint({
4468
+ id: "auth.initEnrollSession",
4469
+ transport: "grpc",
4470
+ grpc: {
4471
+ service: FrontendFaceIdService,
4472
+ methodName: "initEnrollSession",
4473
+ requestSchema: InitEnrollSessionReqSchema
4474
+ }
4475
+ }),
4476
+ getFaceIdInfo: defineEndpoint({
4477
+ id: "auth.getFaceIdInfo",
4478
+ transport: "grpc",
4479
+ grpc: {
4480
+ service: FrontendFaceIdService,
4481
+ methodName: "getFaceIdInfo",
4482
+ requestSchema: GetFaceIdInfoReqSchema
4483
+ }
4484
+ }),
4485
+ verifyPassword: defineEndpoint({
4486
+ id: "auth.verifyPassword",
4487
+ transport: "grpc",
4488
+ grpc: {
4489
+ service: FrontendPlayerService,
4490
+ methodName: "verifyPassword",
4491
+ requestSchema: VerifyPasswordReqSchema
4492
+ }
4493
+ }),
4494
+ gLifeAuth: defineEndpoint({
4495
+ id: "auth.gLifeAuth",
4496
+ transport: "grpc",
4497
+ grpc: {
4498
+ service: GLifeService,
4499
+ methodName: "gLifeAuth",
4500
+ requestSchema: GLifeAuthReqSchema
4501
+ }
4502
+ }),
4503
+ playerLoginWithGLife: defineEndpoint({
4504
+ id: "auth.playerLoginWithGLife",
4505
+ transport: "grpc",
4506
+ grpc: {
4507
+ service: GLifeService,
4508
+ methodName: "playerLoginWithGLife",
4509
+ requestSchema: PlayerLoginWithGLifeReqSchema
4510
+ }
4511
+ }),
4512
+ playerLoginOrRegisterWithGLife: defineEndpoint({
4513
+ id: "auth.playerLoginOrRegisterWithGLife",
4514
+ transport: "grpc",
4515
+ grpc: {
4516
+ service: GLifeService,
4517
+ methodName: "playerLoginOrRegisterWithGLife",
4518
+ requestSchema: PlayerLoginOrRegisterWithGLifeReqSchema
4519
+ }
4520
+ }),
4521
+ mayaAuth: defineEndpoint({
4522
+ id: "auth.mayaAuth",
4523
+ transport: "grpc",
4524
+ grpc: {
4525
+ service: MayaService,
4526
+ methodName: "mayaAuth",
4527
+ requestSchema: MayaAuthReqSchema
4528
+ }
4529
+ }),
4530
+ playerLoginWithMaya: defineEndpoint({
4531
+ id: "auth.playerLoginWithMaya",
4532
+ transport: "grpc",
4533
+ grpc: {
4534
+ service: MayaService,
4535
+ methodName: "playerLoginWithMaya",
4536
+ requestSchema: PlayerLoginWithMayaReqSchema
4537
+ }
4538
+ }),
4539
+ playerLoginOrRegisterWithMaya: defineEndpoint({
4540
+ id: "auth.playerLoginOrRegisterWithMaya",
4541
+ transport: "grpc",
4542
+ grpc: {
4543
+ service: MayaService,
4544
+ methodName: "playerLoginOrRegisterWithMaya",
4545
+ requestSchema: PlayerLoginOrRegisterWithMayaReqSchema
4546
+ }
4547
+ })
4548
+ };
4549
+
4246
4550
  // src/spec/index.ts
4247
4551
  var apiMap = {
4248
4552
  platform: platformEndpoints,
4249
4553
  admin: adminEndpoints,
4250
- cms: cmsEndpoints
4554
+ cms: cmsEndpoints,
4555
+ auth: authEndpoints
4251
4556
  };
4252
4557
 
4253
4558
  // src/routing/router.ts
@@ -4420,54 +4725,207 @@ function pickEndpoint(variants, transport, specDefaultTransport, service, functi
4420
4725
  return fallback;
4421
4726
  }
4422
4727
 
4423
- // src/utils/uniqueKey.ts
4424
- var fetchGuid = () => {
4425
- let guid = getLocalItem("uKey");
4426
- console.log("fetchGuid", JSON.stringify(guid));
4427
- if (!guid) {
4428
- guid = generateGuid();
4429
- setLocalItem("uKey", maskingGuid(true, guid));
4430
- } else {
4431
- guid = maskingGuid(false, null);
4728
+ // src/utils/adapters/web.ts
4729
+ var webStorage = {
4730
+ get(key) {
4731
+ if (typeof window === "undefined") return null;
4732
+ try {
4733
+ const storage = window.localStorage;
4734
+ if (!storage) return null;
4735
+ return storage.getItem(key);
4736
+ } catch {
4737
+ return null;
4738
+ }
4739
+ },
4740
+ set(key, value) {
4741
+ if (typeof window === "undefined") return;
4742
+ try {
4743
+ const storage = window.localStorage;
4744
+ if (!storage) return;
4745
+ storage.setItem(key, value);
4746
+ } catch {
4747
+ return;
4748
+ }
4432
4749
  }
4433
- return guid;
4434
- };
4435
- var generateGuid = () => {
4436
- return "10000000-1000-4000-8000-100000000000".replace(
4437
- /[018]/g,
4438
- (c) => (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
4439
- );
4440
4750
  };
4441
- var maskingGuid = (isMask, oriUKey) => {
4442
- let _uKey2;
4443
- let uKey = oriUKey || getLocalItem("uKey");
4444
- if (isMask) {
4445
- let _uKey;
4446
- uKey = ((_uKey = uKey) == null ? void 0 : _uKey.replace(/-/g, "")) || "";
4447
- const _buffer = new Uint8Array(uKey.length / 2);
4448
- for (let i = 0; i < uKey.length; i += 2) {
4449
- _buffer[i / 2] = parseInt(uKey.substr(i, 2), 16);
4450
- }
4451
- return btoa(String.fromCharCode.apply(null, Array.from(_buffer)));
4751
+
4752
+ // src/utils/fetchGuid.ts
4753
+ var defaultKey = "uKey";
4754
+ var guidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4755
+ var hex32Pattern = /^[0-9a-f]{32}$/i;
4756
+ function createFetchGuid(storage, options) {
4757
+ return () => fetchGuidWithStorage(storage, options);
4758
+ }
4759
+ function fetchGuidWithStorage(storage, options) {
4760
+ const key = options?.key ?? defaultKey;
4761
+ const current = safeGet(storage, key);
4762
+ if (current) {
4763
+ const unmasked = unmaskGuid(current);
4764
+ if (unmasked) return formatGuid(unmasked, options);
4765
+ }
4766
+ const guid = generateGuid();
4767
+ safeSet(storage, key, maskGuid(guid));
4768
+ return formatGuid(guid, options);
4769
+ }
4770
+ function safeGet(storage, key) {
4771
+ try {
4772
+ return storage.get(key);
4773
+ } catch {
4774
+ return null;
4775
+ }
4776
+ }
4777
+ function safeSet(storage, key, value) {
4778
+ try {
4779
+ storage.set(key, value);
4780
+ } catch {
4781
+ return;
4782
+ }
4783
+ }
4784
+ function generateGuid() {
4785
+ const cryptoObj = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
4786
+ if (cryptoObj && cryptoObj.getRandomValues) {
4787
+ return "10000000-1000-4000-8000-100000000000".replace(
4788
+ /[018]/g,
4789
+ (c) => (+c ^ cryptoObj.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
4790
+ );
4791
+ }
4792
+ return "xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx".replace(/[xy]/g, (ch) => {
4793
+ const r = Math.random() * 16 | 0;
4794
+ const v = ch === "x" ? r : r & 3 | 8;
4795
+ return v.toString(16);
4796
+ });
4797
+ }
4798
+ function maskGuid(guid) {
4799
+ const hex = guid.replace(/-/g, "");
4800
+ const buffer = new Uint8Array(hex.length / 2);
4801
+ for (let i = 0; i < hex.length; i += 2) {
4802
+ buffer[i / 2] = parseInt(hex.slice(i, i + 2), 16);
4803
+ }
4804
+ return base64Encode(buffer);
4805
+ }
4806
+ function unmaskGuid(value) {
4807
+ const clean = value.replace(/"/g, "").trim();
4808
+ if (guidPattern.test(clean)) return clean;
4809
+ if (hex32Pattern.test(clean)) {
4810
+ return clean.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
4452
4811
  }
4453
- uKey = ((_uKey2 = uKey) == null ? void 0 : _uKey2.replace(/"/g, "")) || "";
4454
- const buffer = atob(uKey);
4455
- const hex = Array.prototype.map.call(
4456
- new Uint8Array(buffer.length).map((_, i) => buffer.charCodeAt(i)),
4457
- (byte) => ("0" + (byte & 255).toString(16)).slice(-2)
4458
- ).join("");
4812
+ const bytes = base64Decode(clean);
4813
+ if (!bytes) return null;
4814
+ const hex = Array.prototype.map.call(bytes, (byte) => ("0" + (byte & 255).toString(16)).slice(-2)).join("");
4815
+ if (hex.length !== 32) return null;
4459
4816
  return hex.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
4460
- };
4461
- var getLocalItem = (key) => {
4462
- if (typeof window !== "undefined") {
4463
- return window.localStorage.getItem(key);
4817
+ }
4818
+ function formatGuid(guid, options) {
4819
+ const format = options?.format ?? "uuid";
4820
+ const prefix = options?.prefix ?? "";
4821
+ if (format === "uuid") return prefix + guid;
4822
+ const hex = guid.replace(/-/g, "");
4823
+ if (format === "hex") return prefix + hex;
4824
+ const buffer = new Uint8Array(hex.length / 2);
4825
+ for (let i = 0; i < hex.length; i += 2) {
4826
+ buffer[i / 2] = parseInt(hex.slice(i, i + 2), 16);
4827
+ }
4828
+ return prefix + base64Encode(buffer);
4829
+ }
4830
+ function base64Encode(bytes) {
4831
+ const btoaFn = typeof globalThis !== "undefined" ? globalThis.btoa : void 0;
4832
+ if (btoaFn) {
4833
+ let binary = "";
4834
+ for (let i2 = 0; i2 < bytes.length; i2++) binary += String.fromCharCode(bytes[i2]);
4835
+ return btoaFn(binary);
4836
+ }
4837
+ const BufferCtor = typeof globalThis !== "undefined" ? globalThis.Buffer : void 0;
4838
+ if (BufferCtor) return BufferCtor.from(bytes).toString("base64");
4839
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4840
+ let out = "";
4841
+ let i = 0;
4842
+ while (i < bytes.length) {
4843
+ const rem = bytes.length - i;
4844
+ const b1 = bytes[i++];
4845
+ const b2 = rem > 1 ? bytes[i++] : 0;
4846
+ const b3 = rem > 2 ? bytes[i++] : 0;
4847
+ const n = b1 << 16 | b2 << 8 | b3;
4848
+ out += chars[n >> 18 & 63] + chars[n >> 12 & 63] + (rem > 1 ? chars[n >> 6 & 63] : "=") + (rem > 2 ? chars[n & 63] : "=");
4849
+ }
4850
+ return out;
4851
+ }
4852
+ function base64Decode(b64) {
4853
+ const atobFn = typeof globalThis !== "undefined" ? globalThis.atob : void 0;
4854
+ if (atobFn) {
4855
+ try {
4856
+ const bin = atobFn(b64);
4857
+ const out = new Uint8Array(bin.length);
4858
+ for (let i2 = 0; i2 < bin.length; i2++) out[i2] = bin.charCodeAt(i2);
4859
+ return out;
4860
+ } catch {
4861
+ return null;
4862
+ }
4863
+ }
4864
+ const BufferCtor = typeof globalThis !== "undefined" ? globalThis.Buffer : void 0;
4865
+ if (BufferCtor) {
4866
+ try {
4867
+ const buf = BufferCtor.from(b64, "base64");
4868
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
4869
+ } catch {
4870
+ return null;
4871
+ }
4872
+ }
4873
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4874
+ const map = {};
4875
+ for (let i2 = 0; i2 < chars.length; i2++) map[chars[i2]] = i2;
4876
+ const clean = b64.replace(/[^A-Za-z0-9+/=]/g, "");
4877
+ if (!clean) return null;
4878
+ const bytes = [];
4879
+ let i = 0;
4880
+ while (i < clean.length) {
4881
+ const c1 = clean[i++];
4882
+ const c2 = clean[i++];
4883
+ const c3 = clean[i++];
4884
+ const c4 = clean[i++];
4885
+ if (!c1 || !c2) break;
4886
+ const e1 = map[c1];
4887
+ const e2 = map[c2];
4888
+ if (e1 === void 0 || e2 === void 0) return null;
4889
+ const e3 = c3 === "=" || !c3 ? 0 : map[c3];
4890
+ const e4 = c4 === "=" || !c4 ? 0 : map[c4];
4891
+ if (e3 === void 0 || e4 === void 0) return null;
4892
+ const n = e1 << 18 | e2 << 12 | e3 << 6 | e4;
4893
+ const b1 = n >> 16 & 255;
4894
+ const b2 = n >> 8 & 255;
4895
+ const b3 = n & 255;
4896
+ bytes.push(b1);
4897
+ if (c3 !== "=") bytes.push(b2);
4898
+ if (c4 !== "=") bytes.push(b3);
4899
+ }
4900
+ return new Uint8Array(bytes);
4901
+ }
4902
+
4903
+ // src/utils/uniqueKey.ts
4904
+ var memoryStore = /* @__PURE__ */ new Map();
4905
+ var memoryStorage = {
4906
+ get(key) {
4907
+ return memoryStore.get(key) ?? null;
4908
+ },
4909
+ set(key, val) {
4910
+ memoryStore.set(key, val);
4464
4911
  }
4465
4912
  };
4466
- var setLocalItem = (key, val) => {
4467
- if (typeof window !== "undefined") {
4468
- window.localStorage.setItem(key, val);
4913
+ var defaultStorage = {
4914
+ get(key) {
4915
+ return webStorage.get(key) ?? memoryStorage.get(key);
4916
+ },
4917
+ set(key, val) {
4918
+ webStorage.set(key, val);
4919
+ memoryStorage.set(key, val);
4469
4920
  }
4470
4921
  };
4922
+ var storageAdapter = defaultStorage;
4923
+ var fetchGuidImpl = createFetchGuid(storageAdapter);
4924
+ var setUniqueKeyStorage = (adapter) => {
4925
+ storageAdapter = adapter ?? defaultStorage;
4926
+ fetchGuidImpl = createFetchGuid(storageAdapter);
4927
+ };
4928
+ var fetchGuid = () => fetchGuidImpl();
4471
4929
 
4472
4930
  // src/index.ts
4473
4931
  var api;
@@ -4846,6 +5304,7 @@ function createApiServiceClient(service) {
4846
5304
  export {
4847
5305
  apiError,
4848
5306
  requestApi as callApi,
5307
+ createFetchGuid,
4849
5308
  destroySDK,
4850
5309
  fetchGuid,
4851
5310
  getSDK,
@@ -4853,6 +5312,8 @@ export {
4853
5312
  initSDK,
4854
5313
  notify,
4855
5314
  requestApi,
4856
- requestApi as requestApiSpec
5315
+ requestApi as requestApiSpec,
5316
+ setUniqueKeyStorage,
5317
+ webStorage
4857
5318
  };
4858
5319
  //# sourceMappingURL=index.js.map