@explorins/pers-sdk 2.1.26 → 2.1.29
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/chunks/environment-C_hPDl8L.cjs +46 -0
- package/dist/chunks/environment-C_hPDl8L.cjs.map +1 -0
- package/dist/chunks/environment-DEI_L882.js +42 -0
- package/dist/chunks/environment-DEI_L882.js.map +1 -0
- package/dist/chunks/{pers-sdk-tAxjWu7_.cjs → pers-sdk-CD_E4Eq6.cjs} +204 -16
- package/dist/chunks/pers-sdk-CD_E4Eq6.cjs.map +1 -0
- package/dist/chunks/{pers-sdk-Ddw3SoDH.js → pers-sdk-DyzCX7_p.js} +204 -17
- package/dist/chunks/pers-sdk-DyzCX7_p.js.map +1 -0
- package/dist/core/auth/default-auth-provider.d.ts +3 -1
- package/dist/core/auth/default-auth-provider.d.ts.map +1 -1
- package/dist/core/auth/dpop/dpop-manager.d.ts +19 -1
- package/dist/core/auth/dpop/dpop-manager.d.ts.map +1 -1
- package/dist/core/auth/token-storage.d.ts +5 -0
- package/dist/core/auth/token-storage.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/version.d.ts +6 -4
- package/dist/core/version.d.ts.map +1 -1
- package/dist/core.cjs +3 -3
- package/dist/core.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/dist/managers/auth-manager.d.ts.map +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/package.json +2 -1
- package/package.json +2 -1
- package/dist/chunks/environment-C73snhIJ.cjs +0 -145
- package/dist/chunks/environment-C73snhIJ.cjs.map +0 -1
- package/dist/chunks/environment-CKVwRAEL.js +0 -140
- package/dist/chunks/environment-CKVwRAEL.js.map +0 -1
- package/dist/chunks/pers-sdk-Ddw3SoDH.js.map +0 -1
- package/dist/chunks/pers-sdk-tAxjWu7_.cjs.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Environment Detection Utility
|
|
5
|
+
* Detects runtime environment for platform-specific behaviors
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Detects the current runtime environment
|
|
9
|
+
*/
|
|
10
|
+
function detectEnvironment() {
|
|
11
|
+
const global = globalThis;
|
|
12
|
+
const isNode = typeof process !== 'undefined' &&
|
|
13
|
+
process.versions?.node != null &&
|
|
14
|
+
typeof global.window === 'undefined';
|
|
15
|
+
const isBrowser = typeof global.window !== 'undefined' &&
|
|
16
|
+
typeof global.document !== 'undefined';
|
|
17
|
+
const isReactNative = typeof global.navigator?.product === 'string' &&
|
|
18
|
+
global.navigator.product.toLowerCase() === 'reactnative';
|
|
19
|
+
const isWeb = isBrowser || isReactNative;
|
|
20
|
+
const needsNodeStreamPolyfills = isWeb;
|
|
21
|
+
return {
|
|
22
|
+
isNode,
|
|
23
|
+
isBrowser,
|
|
24
|
+
isReactNative,
|
|
25
|
+
isWeb,
|
|
26
|
+
needsNodeStreamPolyfills
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Global environment info (cached)
|
|
31
|
+
*/
|
|
32
|
+
const environment = detectEnvironment();
|
|
33
|
+
/**
|
|
34
|
+
* Warns if environment might have bundling issues
|
|
35
|
+
*/
|
|
36
|
+
function warnIfProblematicEnvironment(feature) {
|
|
37
|
+
if (environment.needsNodeStreamPolyfills) {
|
|
38
|
+
console.warn(`[PERS SDK] ${feature} may require additional polyfills in web environments. ` +
|
|
39
|
+
`If you encounter 'readable-stream' errors, ensure proper polyfills are configured.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.detectEnvironment = detectEnvironment;
|
|
44
|
+
exports.environment = environment;
|
|
45
|
+
exports.warnIfProblematicEnvironment = warnIfProblematicEnvironment;
|
|
46
|
+
//# sourceMappingURL=environment-C_hPDl8L.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-C_hPDl8L.cjs","sources":["../../src/core/environment.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAUH;;AAEG;SACa,iBAAiB,GAAA;IAC/B,MAAM,MAAM,GAAG,UAAiB;AAEhC,IAAA,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,WAAW;AAC9B,QAAA,OAAO,CAAC,QAAQ,EAAE,IAAI,IAAI,IAAI;AAC9B,QAAA,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW;AAEnD,IAAA,MAAM,SAAS,GAAG,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW;AACpC,QAAA,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;IAExD,MAAM,aAAa,GAAG,OAAO,MAAM,CAAC,SAAS,EAAE,OAAO,KAAK,QAAQ;QAC7C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,aAAa;AAE9E,IAAA,MAAM,KAAK,GAAG,SAAS,IAAI,aAAa;IACxC,MAAM,wBAAwB,GAAG,KAAK;IAEtC,OAAO;QACL,MAAM;QACN,SAAS;QACT,aAAa;QACb,KAAK;QACL;KACD;AACH;AAEA;;AAEG;AACI,MAAM,WAAW,GAAG,iBAAiB;AAE5C;;AAEG;AACG,SAAU,4BAA4B,CAAC,OAAe,EAAA;AAC1D,IAAA,IAAI,WAAW,CAAC,wBAAwB,EAAE;AACxC,QAAA,OAAO,CAAC,IAAI,CACV,CAAA,WAAA,EAAc,OAAO,CAAA,uDAAA,CAAyD;AAC9E,YAAA,CAAA,kFAAA,CAAoF,CACrF;IACH;AACF;;;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment Detection Utility
|
|
3
|
+
* Detects runtime environment for platform-specific behaviors
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Detects the current runtime environment
|
|
7
|
+
*/
|
|
8
|
+
function detectEnvironment() {
|
|
9
|
+
const global = globalThis;
|
|
10
|
+
const isNode = typeof process !== 'undefined' &&
|
|
11
|
+
process.versions?.node != null &&
|
|
12
|
+
typeof global.window === 'undefined';
|
|
13
|
+
const isBrowser = typeof global.window !== 'undefined' &&
|
|
14
|
+
typeof global.document !== 'undefined';
|
|
15
|
+
const isReactNative = typeof global.navigator?.product === 'string' &&
|
|
16
|
+
global.navigator.product.toLowerCase() === 'reactnative';
|
|
17
|
+
const isWeb = isBrowser || isReactNative;
|
|
18
|
+
const needsNodeStreamPolyfills = isWeb;
|
|
19
|
+
return {
|
|
20
|
+
isNode,
|
|
21
|
+
isBrowser,
|
|
22
|
+
isReactNative,
|
|
23
|
+
isWeb,
|
|
24
|
+
needsNodeStreamPolyfills
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Global environment info (cached)
|
|
29
|
+
*/
|
|
30
|
+
const environment = detectEnvironment();
|
|
31
|
+
/**
|
|
32
|
+
* Warns if environment might have bundling issues
|
|
33
|
+
*/
|
|
34
|
+
function warnIfProblematicEnvironment(feature) {
|
|
35
|
+
if (environment.needsNodeStreamPolyfills) {
|
|
36
|
+
console.warn(`[PERS SDK] ${feature} may require additional polyfills in web environments. ` +
|
|
37
|
+
`If you encounter 'readable-stream' errors, ensure proper polyfills are configured.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { detectEnvironment as d, environment as e, warnIfProblematicEnvironment as w };
|
|
42
|
+
//# sourceMappingURL=environment-DEI_L882.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-DEI_L882.js","sources":["../../src/core/environment.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AAUH;;AAEG;SACa,iBAAiB,GAAA;IAC/B,MAAM,MAAM,GAAG,UAAiB;AAEhC,IAAA,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,WAAW;AAC9B,QAAA,OAAO,CAAC,QAAQ,EAAE,IAAI,IAAI,IAAI;AAC9B,QAAA,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW;AAEnD,IAAA,MAAM,SAAS,GAAG,OAAO,MAAM,CAAC,MAAM,KAAK,WAAW;AACpC,QAAA,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;IAExD,MAAM,aAAa,GAAG,OAAO,MAAM,CAAC,SAAS,EAAE,OAAO,KAAK,QAAQ;QAC7C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,aAAa;AAE9E,IAAA,MAAM,KAAK,GAAG,SAAS,IAAI,aAAa;IACxC,MAAM,wBAAwB,GAAG,KAAK;IAEtC,OAAO;QACL,MAAM;QACN,SAAS;QACT,aAAa;QACb,KAAK;QACL;KACD;AACH;AAEA;;AAEG;AACI,MAAM,WAAW,GAAG,iBAAiB;AAE5C;;AAEG;AACG,SAAU,4BAA4B,CAAC,OAAe,EAAA;AAC1D,IAAA,IAAI,WAAW,CAAC,wBAAwB,EAAE;AACxC,QAAA,OAAO,CAAC,IAAI,CACV,CAAA,WAAA,EAAc,OAAO,CAAA,uDAAA,CAAyD;AAC9E,YAAA,CAAA,kFAAA,CAAoF,CACrF;IACH;AACF;;;;"}
|
|
@@ -677,8 +677,114 @@ class AuthTokenManager {
|
|
|
677
677
|
const token = await this.getRefreshToken();
|
|
678
678
|
return !!token;
|
|
679
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Clears only the refresh token.
|
|
682
|
+
* Used when DPoP keys are regenerated, invalidating the token binding.
|
|
683
|
+
*/
|
|
684
|
+
async clearRefreshToken() {
|
|
685
|
+
this.cache.refreshToken = null;
|
|
686
|
+
await this.storage.remove(AUTH_STORAGE_KEYS.REFRESH_TOKEN);
|
|
687
|
+
}
|
|
680
688
|
}
|
|
681
689
|
|
|
690
|
+
class IndexedDBTokenStorage {
|
|
691
|
+
constructor() {
|
|
692
|
+
this.supportsObjects = true;
|
|
693
|
+
this.dbPromise = null;
|
|
694
|
+
if (typeof indexedDB === 'undefined') {
|
|
695
|
+
console.warn('IndexedDB is not available in this environment');
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
getDB() {
|
|
699
|
+
if (this.dbPromise)
|
|
700
|
+
return this.dbPromise;
|
|
701
|
+
this.dbPromise = new Promise((resolve, reject) => {
|
|
702
|
+
if (typeof indexedDB === 'undefined') {
|
|
703
|
+
return reject(new Error('IndexedDB not supported'));
|
|
704
|
+
}
|
|
705
|
+
const request = indexedDB.open(IndexedDBTokenStorage.DB_NAME, IndexedDBTokenStorage.DB_VERSION);
|
|
706
|
+
request.onupgradeneeded = (event) => {
|
|
707
|
+
const db = event.target.result;
|
|
708
|
+
if (!db.objectStoreNames.contains(IndexedDBTokenStorage.STORE_NAME)) {
|
|
709
|
+
db.createObjectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
request.onsuccess = (event) => {
|
|
713
|
+
resolve(event.target.result);
|
|
714
|
+
};
|
|
715
|
+
request.onerror = (event) => {
|
|
716
|
+
reject(event.target.error);
|
|
717
|
+
};
|
|
718
|
+
});
|
|
719
|
+
return this.dbPromise;
|
|
720
|
+
}
|
|
721
|
+
async get(key) {
|
|
722
|
+
try {
|
|
723
|
+
const db = await this.getDB();
|
|
724
|
+
return new Promise((resolve, reject) => {
|
|
725
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readonly');
|
|
726
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
727
|
+
const request = store.get(key);
|
|
728
|
+
request.onsuccess = () => resolve(request.result || null);
|
|
729
|
+
request.onerror = () => reject(request.error);
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
catch (e) {
|
|
733
|
+
console.warn('[IndexedDBTokenStorage] Failed to get key', key, e);
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
async set(key, value) {
|
|
738
|
+
try {
|
|
739
|
+
const db = await this.getDB();
|
|
740
|
+
return new Promise((resolve, reject) => {
|
|
741
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readwrite');
|
|
742
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
743
|
+
const request = store.put(value, key);
|
|
744
|
+
request.onsuccess = () => resolve();
|
|
745
|
+
request.onerror = () => reject(request.error);
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
catch (e) {
|
|
749
|
+
console.error('[IndexedDBTokenStorage] Failed to set key', key, e);
|
|
750
|
+
throw e;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
async remove(key) {
|
|
754
|
+
try {
|
|
755
|
+
const db = await this.getDB();
|
|
756
|
+
return new Promise((resolve, reject) => {
|
|
757
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readwrite');
|
|
758
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
759
|
+
const request = store.delete(key);
|
|
760
|
+
request.onsuccess = () => resolve();
|
|
761
|
+
request.onerror = () => reject(request.error);
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
catch (e) {
|
|
765
|
+
console.warn('[IndexedDBTokenStorage] Failed to remove key', key, e);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
async clear() {
|
|
769
|
+
try {
|
|
770
|
+
const db = await this.getDB();
|
|
771
|
+
return new Promise((resolve, reject) => {
|
|
772
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readwrite');
|
|
773
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
774
|
+
const request = store.clear();
|
|
775
|
+
request.onsuccess = () => resolve();
|
|
776
|
+
request.onerror = () => reject(request.error);
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
catch (e) {
|
|
780
|
+
console.warn('[IndexedDBTokenStorage] Failed to clear storage', e);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
IndexedDBTokenStorage.DB_NAME = 'pers-sdk-storage';
|
|
785
|
+
IndexedDBTokenStorage.STORE_NAME = 'auth-tokens';
|
|
786
|
+
IndexedDBTokenStorage.DB_VERSION = 1;
|
|
787
|
+
|
|
682
788
|
class WebDPoPCryptoProvider {
|
|
683
789
|
get crypto() {
|
|
684
790
|
// Basic environment check
|
|
@@ -813,13 +919,30 @@ const DPOP_STORAGE_KEYS = {
|
|
|
813
919
|
PRIVATE: 'pers_dpop_private_key'
|
|
814
920
|
};
|
|
815
921
|
class DPoPManager {
|
|
816
|
-
constructor(storage, cryptoProvider) {
|
|
922
|
+
constructor(storage, cryptoProvider, callbacks) {
|
|
817
923
|
this.storage = storage;
|
|
818
924
|
this.memoryKeyPair = null;
|
|
819
925
|
this.cryptoProvider = cryptoProvider || new WebDPoPCryptoProvider();
|
|
926
|
+
this.callbacks = callbacks || {};
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Checks if DPoP keys exist in storage without generating new ones.
|
|
930
|
+
* Useful for detecting if a key regeneration would be needed.
|
|
931
|
+
*/
|
|
932
|
+
async hasStoredKeys() {
|
|
933
|
+
if (this.memoryKeyPair)
|
|
934
|
+
return true;
|
|
935
|
+
const storedPublic = await this.storage.get(DPOP_STORAGE_KEYS.PUBLIC);
|
|
936
|
+
const storedPrivate = await this.storage.get(DPOP_STORAGE_KEYS.PRIVATE);
|
|
937
|
+
return !!(storedPublic && storedPrivate);
|
|
820
938
|
}
|
|
821
939
|
/**
|
|
822
940
|
* Ensures a DPoP key pair exists, loading from storage or generating new one.
|
|
941
|
+
*
|
|
942
|
+
* IMPORTANT: If keys are regenerated (not loaded from storage), this will
|
|
943
|
+
* invalidate any refresh tokens bound to the old keys. The onKeysRegenerated
|
|
944
|
+
* callback should clear the refresh token to prevent "DPoP proof does not
|
|
945
|
+
* match refresh token binding" errors.
|
|
823
946
|
*/
|
|
824
947
|
async ensureKeyPair() {
|
|
825
948
|
if (this.memoryKeyPair)
|
|
@@ -835,10 +958,12 @@ class DPoPManager {
|
|
|
835
958
|
return this.memoryKeyPair;
|
|
836
959
|
}
|
|
837
960
|
catch (e) {
|
|
838
|
-
console.warn('Corrupted DPoP keys in storage, regenerating.');
|
|
961
|
+
console.warn('[DPoPManager] Corrupted DPoP keys in storage, regenerating.');
|
|
839
962
|
}
|
|
840
963
|
}
|
|
841
964
|
// Generate new key pair
|
|
965
|
+
// IMPORTANT: This invalidates any existing refresh tokens bound to the old keys
|
|
966
|
+
console.info('[DPoPManager] Generating new DPoP key pair');
|
|
842
967
|
// Adaptation: If storage supports raw objects (like IndexedDB or Native Keychain),
|
|
843
968
|
// we can generate Non-Extractable keys for maximum security.
|
|
844
969
|
// If storage is text-only (LocalStorage), we must use Extractable keys to serialize them.
|
|
@@ -850,6 +975,15 @@ class DPoPManager {
|
|
|
850
975
|
await this.storage.set(DPOP_STORAGE_KEYS.PUBLIC, keyPair.publicKey);
|
|
851
976
|
await this.storage.set(DPOP_STORAGE_KEYS.PRIVATE, keyPair.privateKey);
|
|
852
977
|
this.memoryKeyPair = keyPair;
|
|
978
|
+
// Notify that keys were regenerated - refresh tokens bound to old keys are now invalid
|
|
979
|
+
if (this.callbacks.onKeysRegenerated) {
|
|
980
|
+
try {
|
|
981
|
+
this.callbacks.onKeysRegenerated();
|
|
982
|
+
}
|
|
983
|
+
catch (e) {
|
|
984
|
+
console.warn('[DPoPManager] onKeysRegenerated callback failed:', e);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
853
987
|
return keyPair;
|
|
854
988
|
}
|
|
855
989
|
/**
|
|
@@ -903,16 +1037,61 @@ class DefaultAuthProvider {
|
|
|
903
1037
|
this.config = config;
|
|
904
1038
|
this.authTypeCache = null;
|
|
905
1039
|
this.authType = config.authType || persShared.AccountOwnerType.USER;
|
|
1040
|
+
// Determine if DPoP can be enabled:
|
|
1041
|
+
// 1. Custom crypto provider is supplied (e.g., React Native), OR
|
|
1042
|
+
// 2. IndexedDB is available for browser CryptoKey persistence
|
|
1043
|
+
const hasCustomCryptoProvider = !!config.dpop?.cryptoProvider;
|
|
1044
|
+
const hasIndexedDB = this.canEnableDPoP();
|
|
1045
|
+
const canUseDPoP = hasCustomCryptoProvider || hasIndexedDB;
|
|
1046
|
+
this.dpopEnabled = !!(config.dpop?.enabled && canUseDPoP);
|
|
1047
|
+
// Debug logging for DPoP configuration
|
|
1048
|
+
console.log('[DefaultAuthProvider] DPoP config:', {
|
|
1049
|
+
requestedEnabled: config.dpop?.enabled ?? false,
|
|
1050
|
+
hasCustomCryptoProvider,
|
|
1051
|
+
hasIndexedDB,
|
|
1052
|
+
canUseDPoP,
|
|
1053
|
+
finalEnabled: this.dpopEnabled,
|
|
1054
|
+
cryptoProviderType: config.dpop?.cryptoProvider?.constructor?.name || 'none'
|
|
1055
|
+
});
|
|
1056
|
+
if (config.dpop?.enabled && !canUseDPoP) {
|
|
1057
|
+
console.warn('[DefaultAuthProvider] DPoP disabled: IndexedDB not available and no custom crypto provider supplied. CryptoKey persistence requires IndexedDB or a custom provider.');
|
|
1058
|
+
}
|
|
906
1059
|
const storage = config.storage || this.createStorage();
|
|
907
1060
|
this.tokenManager = new AuthTokenManager(storage);
|
|
908
|
-
if (
|
|
909
|
-
this.dpopManager = new DPoPManager(storage, config.dpop
|
|
1061
|
+
if (this.dpopEnabled) {
|
|
1062
|
+
this.dpopManager = new DPoPManager(storage, config.dpop?.cryptoProvider, {
|
|
1063
|
+
// When DPoP keys are regenerated (corrupted/missing), the refresh token
|
|
1064
|
+
// bound to the old keys becomes invalid. Clear it to prevent
|
|
1065
|
+
// "DPoP proof does not match refresh token binding" errors.
|
|
1066
|
+
onKeysRegenerated: () => {
|
|
1067
|
+
console.info('[DefaultAuthProvider] DPoP keys regenerated, clearing invalid refresh token');
|
|
1068
|
+
this.tokenManager.clearRefreshToken().catch(err => {
|
|
1069
|
+
console.warn('[DefaultAuthProvider] Failed to clear refresh token:', err);
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
910
1073
|
}
|
|
911
1074
|
}
|
|
1075
|
+
canEnableDPoP() {
|
|
1076
|
+
// DPoP requires IndexedDB for proper CryptoKey persistence
|
|
1077
|
+
// LocalStorage cannot serialize CryptoKey objects correctly
|
|
1078
|
+
return typeof window !== 'undefined' && typeof indexedDB !== 'undefined';
|
|
1079
|
+
}
|
|
912
1080
|
createStorage() {
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1081
|
+
// Server-side: use memory storage
|
|
1082
|
+
if (typeof window === 'undefined') {
|
|
1083
|
+
return new MemoryTokenStorage();
|
|
1084
|
+
}
|
|
1085
|
+
// Browser with DPoP enabled: use IndexedDB for CryptoKey persistence
|
|
1086
|
+
if (this.dpopEnabled) {
|
|
1087
|
+
return new IndexedDBTokenStorage();
|
|
1088
|
+
}
|
|
1089
|
+
// Browser without DPoP: use LocalStorage
|
|
1090
|
+
if (typeof localStorage !== 'undefined') {
|
|
1091
|
+
return new LocalStorageTokenStorage();
|
|
1092
|
+
}
|
|
1093
|
+
// Fallback
|
|
1094
|
+
return new MemoryTokenStorage();
|
|
916
1095
|
}
|
|
917
1096
|
getToken() {
|
|
918
1097
|
return this.tokenManager.getAccessToken();
|
|
@@ -994,10 +1173,9 @@ class DefaultAuthProvider {
|
|
|
994
1173
|
async hasValidToken() {
|
|
995
1174
|
return this.tokenManager.hasAccessToken();
|
|
996
1175
|
}
|
|
997
|
-
async setAuthType(
|
|
998
|
-
//
|
|
999
|
-
//
|
|
1000
|
-
// This method exists to satisfy the ExtendedTokenStorageProvider interface
|
|
1176
|
+
async setAuthType(_authType) {
|
|
1177
|
+
// No-op: authType is derived from JWT payload via getAuthType()
|
|
1178
|
+
// @see getAuthType() - reads accountType directly from JWT
|
|
1001
1179
|
}
|
|
1002
1180
|
async getAuthType() {
|
|
1003
1181
|
// Read from JWT instead of separate storage for single source of truth
|
|
@@ -1038,12 +1216,14 @@ class DefaultAuthProvider {
|
|
|
1038
1216
|
* Exported for consumers who need version info.
|
|
1039
1217
|
* Used internally for X-SDK-Version header.
|
|
1040
1218
|
*
|
|
1219
|
+
* Version is injected at build time via @rollup/plugin-replace
|
|
1220
|
+
*
|
|
1041
1221
|
* @module @explorins/pers-sdk/core
|
|
1042
1222
|
*/
|
|
1043
1223
|
/** SDK package name */
|
|
1044
|
-
const SDK_NAME =
|
|
1045
|
-
/** SDK version -
|
|
1046
|
-
const SDK_VERSION =
|
|
1224
|
+
const SDK_NAME = "@explorins/pers-sdk";
|
|
1225
|
+
/** SDK version - injected from package.json at build time */
|
|
1226
|
+
const SDK_VERSION = "2.1.29";
|
|
1047
1227
|
/** Full SDK identifier for headers */
|
|
1048
1228
|
const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
|
|
1049
1229
|
|
|
@@ -1973,7 +2153,14 @@ class AuthManager {
|
|
|
1973
2153
|
*/
|
|
1974
2154
|
async loginWithRawData(rawUserData) {
|
|
1975
2155
|
const authService = this.apiClient.getAuthService();
|
|
1976
|
-
|
|
2156
|
+
const result = await authService.loginUserWithRawData(rawUserData);
|
|
2157
|
+
this.events?.emitSuccess({
|
|
2158
|
+
domain: 'authentication',
|
|
2159
|
+
type: 'login_success',
|
|
2160
|
+
userMessage: 'Successfully logged in',
|
|
2161
|
+
details: { user: result.user }
|
|
2162
|
+
});
|
|
2163
|
+
return result;
|
|
1977
2164
|
}
|
|
1978
2165
|
/**
|
|
1979
2166
|
* Get current authenticated user
|
|
@@ -9966,6 +10153,7 @@ exports.DonationManager = DonationManager;
|
|
|
9966
10153
|
exports.FileApi = FileApi;
|
|
9967
10154
|
exports.FileManager = FileManager;
|
|
9968
10155
|
exports.FileService = FileService;
|
|
10156
|
+
exports.IndexedDBTokenStorage = IndexedDBTokenStorage;
|
|
9969
10157
|
exports.LocalStorageTokenStorage = LocalStorageTokenStorage;
|
|
9970
10158
|
exports.MemoryTokenStorage = MemoryTokenStorage;
|
|
9971
10159
|
exports.PersApiClient = PersApiClient;
|
|
@@ -9993,4 +10181,4 @@ exports.buildWalletEventsWsUrl = buildWalletEventsWsUrl;
|
|
|
9993
10181
|
exports.createPersEventsClient = createPersEventsClient;
|
|
9994
10182
|
exports.createPersSDK = createPersSDK;
|
|
9995
10183
|
exports.mergeWithDefaults = mergeWithDefaults;
|
|
9996
|
-
//# sourceMappingURL=pers-sdk-
|
|
10184
|
+
//# sourceMappingURL=pers-sdk-CD_E4Eq6.cjs.map
|