@explorins/pers-sdk 2.1.24 → 2.1.27
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-DkCRHY5i.js → pers-sdk-C-3E3svL.js} +197 -13
- package/dist/chunks/pers-sdk-C-3E3svL.js.map +1 -0
- package/dist/chunks/{pers-sdk-DXCcAgUS.cjs → pers-sdk-CxfmzSB2.cjs} +197 -12
- package/dist/chunks/pers-sdk-CxfmzSB2.cjs.map +1 -0
- package/dist/core/auth/default-auth-provider.d.ts +3 -0
- 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-DXCcAgUS.cjs.map +0 -1
- package/dist/chunks/pers-sdk-DkCRHY5i.js.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;;;;"}
|
|
@@ -675,8 +675,114 @@ class AuthTokenManager {
|
|
|
675
675
|
const token = await this.getRefreshToken();
|
|
676
676
|
return !!token;
|
|
677
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* Clears only the refresh token.
|
|
680
|
+
* Used when DPoP keys are regenerated, invalidating the token binding.
|
|
681
|
+
*/
|
|
682
|
+
async clearRefreshToken() {
|
|
683
|
+
this.cache.refreshToken = null;
|
|
684
|
+
await this.storage.remove(AUTH_STORAGE_KEYS.REFRESH_TOKEN);
|
|
685
|
+
}
|
|
678
686
|
}
|
|
679
687
|
|
|
688
|
+
class IndexedDBTokenStorage {
|
|
689
|
+
constructor() {
|
|
690
|
+
this.supportsObjects = true;
|
|
691
|
+
this.dbPromise = null;
|
|
692
|
+
if (typeof indexedDB === 'undefined') {
|
|
693
|
+
console.warn('IndexedDB is not available in this environment');
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
getDB() {
|
|
697
|
+
if (this.dbPromise)
|
|
698
|
+
return this.dbPromise;
|
|
699
|
+
this.dbPromise = new Promise((resolve, reject) => {
|
|
700
|
+
if (typeof indexedDB === 'undefined') {
|
|
701
|
+
return reject(new Error('IndexedDB not supported'));
|
|
702
|
+
}
|
|
703
|
+
const request = indexedDB.open(IndexedDBTokenStorage.DB_NAME, IndexedDBTokenStorage.DB_VERSION);
|
|
704
|
+
request.onupgradeneeded = (event) => {
|
|
705
|
+
const db = event.target.result;
|
|
706
|
+
if (!db.objectStoreNames.contains(IndexedDBTokenStorage.STORE_NAME)) {
|
|
707
|
+
db.createObjectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
request.onsuccess = (event) => {
|
|
711
|
+
resolve(event.target.result);
|
|
712
|
+
};
|
|
713
|
+
request.onerror = (event) => {
|
|
714
|
+
reject(event.target.error);
|
|
715
|
+
};
|
|
716
|
+
});
|
|
717
|
+
return this.dbPromise;
|
|
718
|
+
}
|
|
719
|
+
async get(key) {
|
|
720
|
+
try {
|
|
721
|
+
const db = await this.getDB();
|
|
722
|
+
return new Promise((resolve, reject) => {
|
|
723
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readonly');
|
|
724
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
725
|
+
const request = store.get(key);
|
|
726
|
+
request.onsuccess = () => resolve(request.result || null);
|
|
727
|
+
request.onerror = () => reject(request.error);
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
catch (e) {
|
|
731
|
+
console.warn('[IndexedDBTokenStorage] Failed to get key', key, e);
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
async set(key, value) {
|
|
736
|
+
try {
|
|
737
|
+
const db = await this.getDB();
|
|
738
|
+
return new Promise((resolve, reject) => {
|
|
739
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readwrite');
|
|
740
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
741
|
+
const request = store.put(value, key);
|
|
742
|
+
request.onsuccess = () => resolve();
|
|
743
|
+
request.onerror = () => reject(request.error);
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
catch (e) {
|
|
747
|
+
console.error('[IndexedDBTokenStorage] Failed to set key', key, e);
|
|
748
|
+
throw e;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
async remove(key) {
|
|
752
|
+
try {
|
|
753
|
+
const db = await this.getDB();
|
|
754
|
+
return new Promise((resolve, reject) => {
|
|
755
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readwrite');
|
|
756
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
757
|
+
const request = store.delete(key);
|
|
758
|
+
request.onsuccess = () => resolve();
|
|
759
|
+
request.onerror = () => reject(request.error);
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
catch (e) {
|
|
763
|
+
console.warn('[IndexedDBTokenStorage] Failed to remove key', key, e);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
async clear() {
|
|
767
|
+
try {
|
|
768
|
+
const db = await this.getDB();
|
|
769
|
+
return new Promise((resolve, reject) => {
|
|
770
|
+
const transaction = db.transaction(IndexedDBTokenStorage.STORE_NAME, 'readwrite');
|
|
771
|
+
const store = transaction.objectStore(IndexedDBTokenStorage.STORE_NAME);
|
|
772
|
+
const request = store.clear();
|
|
773
|
+
request.onsuccess = () => resolve();
|
|
774
|
+
request.onerror = () => reject(request.error);
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
catch (e) {
|
|
778
|
+
console.warn('[IndexedDBTokenStorage] Failed to clear storage', e);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
IndexedDBTokenStorage.DB_NAME = 'pers-sdk-storage';
|
|
783
|
+
IndexedDBTokenStorage.STORE_NAME = 'auth-tokens';
|
|
784
|
+
IndexedDBTokenStorage.DB_VERSION = 1;
|
|
785
|
+
|
|
680
786
|
class WebDPoPCryptoProvider {
|
|
681
787
|
get crypto() {
|
|
682
788
|
// Basic environment check
|
|
@@ -811,13 +917,30 @@ const DPOP_STORAGE_KEYS = {
|
|
|
811
917
|
PRIVATE: 'pers_dpop_private_key'
|
|
812
918
|
};
|
|
813
919
|
class DPoPManager {
|
|
814
|
-
constructor(storage, cryptoProvider) {
|
|
920
|
+
constructor(storage, cryptoProvider, callbacks) {
|
|
815
921
|
this.storage = storage;
|
|
816
922
|
this.memoryKeyPair = null;
|
|
817
923
|
this.cryptoProvider = cryptoProvider || new WebDPoPCryptoProvider();
|
|
924
|
+
this.callbacks = callbacks || {};
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Checks if DPoP keys exist in storage without generating new ones.
|
|
928
|
+
* Useful for detecting if a key regeneration would be needed.
|
|
929
|
+
*/
|
|
930
|
+
async hasStoredKeys() {
|
|
931
|
+
if (this.memoryKeyPair)
|
|
932
|
+
return true;
|
|
933
|
+
const storedPublic = await this.storage.get(DPOP_STORAGE_KEYS.PUBLIC);
|
|
934
|
+
const storedPrivate = await this.storage.get(DPOP_STORAGE_KEYS.PRIVATE);
|
|
935
|
+
return !!(storedPublic && storedPrivate);
|
|
818
936
|
}
|
|
819
937
|
/**
|
|
820
938
|
* Ensures a DPoP key pair exists, loading from storage or generating new one.
|
|
939
|
+
*
|
|
940
|
+
* IMPORTANT: If keys are regenerated (not loaded from storage), this will
|
|
941
|
+
* invalidate any refresh tokens bound to the old keys. The onKeysRegenerated
|
|
942
|
+
* callback should clear the refresh token to prevent "DPoP proof does not
|
|
943
|
+
* match refresh token binding" errors.
|
|
821
944
|
*/
|
|
822
945
|
async ensureKeyPair() {
|
|
823
946
|
if (this.memoryKeyPair)
|
|
@@ -833,10 +956,12 @@ class DPoPManager {
|
|
|
833
956
|
return this.memoryKeyPair;
|
|
834
957
|
}
|
|
835
958
|
catch (e) {
|
|
836
|
-
console.warn('Corrupted DPoP keys in storage, regenerating.');
|
|
959
|
+
console.warn('[DPoPManager] Corrupted DPoP keys in storage, regenerating.');
|
|
837
960
|
}
|
|
838
961
|
}
|
|
839
962
|
// Generate new key pair
|
|
963
|
+
// IMPORTANT: This invalidates any existing refresh tokens bound to the old keys
|
|
964
|
+
console.info('[DPoPManager] Generating new DPoP key pair');
|
|
840
965
|
// Adaptation: If storage supports raw objects (like IndexedDB or Native Keychain),
|
|
841
966
|
// we can generate Non-Extractable keys for maximum security.
|
|
842
967
|
// If storage is text-only (LocalStorage), we must use Extractable keys to serialize them.
|
|
@@ -848,6 +973,15 @@ class DPoPManager {
|
|
|
848
973
|
await this.storage.set(DPOP_STORAGE_KEYS.PUBLIC, keyPair.publicKey);
|
|
849
974
|
await this.storage.set(DPOP_STORAGE_KEYS.PRIVATE, keyPair.privateKey);
|
|
850
975
|
this.memoryKeyPair = keyPair;
|
|
976
|
+
// Notify that keys were regenerated - refresh tokens bound to old keys are now invalid
|
|
977
|
+
if (this.callbacks.onKeysRegenerated) {
|
|
978
|
+
try {
|
|
979
|
+
this.callbacks.onKeysRegenerated();
|
|
980
|
+
}
|
|
981
|
+
catch (e) {
|
|
982
|
+
console.warn('[DPoPManager] onKeysRegenerated callback failed:', e);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
851
985
|
return keyPair;
|
|
852
986
|
}
|
|
853
987
|
/**
|
|
@@ -901,16 +1035,48 @@ class DefaultAuthProvider {
|
|
|
901
1035
|
this.config = config;
|
|
902
1036
|
this.authTypeCache = null;
|
|
903
1037
|
this.authType = config.authType || AccountOwnerType.USER;
|
|
1038
|
+
// Determine if DPoP can be enabled (requires IndexedDB for key persistence)
|
|
1039
|
+
const canUseDPoP = this.canEnableDPoP();
|
|
1040
|
+
this.dpopEnabled = !!(config.dpop?.enabled && canUseDPoP);
|
|
1041
|
+
if (config.dpop?.enabled && !canUseDPoP) {
|
|
1042
|
+
console.warn('[DefaultAuthProvider] DPoP disabled: IndexedDB not available. CryptoKey persistence requires IndexedDB.');
|
|
1043
|
+
}
|
|
904
1044
|
const storage = config.storage || this.createStorage();
|
|
905
1045
|
this.tokenManager = new AuthTokenManager(storage);
|
|
906
|
-
if (
|
|
907
|
-
this.dpopManager = new DPoPManager(storage, config.dpop
|
|
1046
|
+
if (this.dpopEnabled) {
|
|
1047
|
+
this.dpopManager = new DPoPManager(storage, config.dpop?.cryptoProvider, {
|
|
1048
|
+
// When DPoP keys are regenerated (corrupted/missing), the refresh token
|
|
1049
|
+
// bound to the old keys becomes invalid. Clear it to prevent
|
|
1050
|
+
// "DPoP proof does not match refresh token binding" errors.
|
|
1051
|
+
onKeysRegenerated: () => {
|
|
1052
|
+
console.info('[DefaultAuthProvider] DPoP keys regenerated, clearing invalid refresh token');
|
|
1053
|
+
this.tokenManager.clearRefreshToken().catch(err => {
|
|
1054
|
+
console.warn('[DefaultAuthProvider] Failed to clear refresh token:', err);
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
});
|
|
908
1058
|
}
|
|
909
1059
|
}
|
|
1060
|
+
canEnableDPoP() {
|
|
1061
|
+
// DPoP requires IndexedDB for proper CryptoKey persistence
|
|
1062
|
+
// LocalStorage cannot serialize CryptoKey objects correctly
|
|
1063
|
+
return typeof window !== 'undefined' && typeof indexedDB !== 'undefined';
|
|
1064
|
+
}
|
|
910
1065
|
createStorage() {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
1066
|
+
// Server-side: use memory storage
|
|
1067
|
+
if (typeof window === 'undefined') {
|
|
1068
|
+
return new MemoryTokenStorage();
|
|
1069
|
+
}
|
|
1070
|
+
// Browser with DPoP enabled: use IndexedDB for CryptoKey persistence
|
|
1071
|
+
if (this.dpopEnabled) {
|
|
1072
|
+
return new IndexedDBTokenStorage();
|
|
1073
|
+
}
|
|
1074
|
+
// Browser without DPoP: use LocalStorage
|
|
1075
|
+
if (typeof localStorage !== 'undefined') {
|
|
1076
|
+
return new LocalStorageTokenStorage();
|
|
1077
|
+
}
|
|
1078
|
+
// Fallback
|
|
1079
|
+
return new MemoryTokenStorage();
|
|
914
1080
|
}
|
|
915
1081
|
getToken() {
|
|
916
1082
|
return this.tokenManager.getAccessToken();
|
|
@@ -992,6 +1158,10 @@ class DefaultAuthProvider {
|
|
|
992
1158
|
async hasValidToken() {
|
|
993
1159
|
return this.tokenManager.hasAccessToken();
|
|
994
1160
|
}
|
|
1161
|
+
async setAuthType(_authType) {
|
|
1162
|
+
// No-op: authType is derived from JWT payload via getAuthType()
|
|
1163
|
+
// @see getAuthType() - reads accountType directly from JWT
|
|
1164
|
+
}
|
|
995
1165
|
async getAuthType() {
|
|
996
1166
|
// Read from JWT instead of separate storage for single source of truth
|
|
997
1167
|
const token = await this.tokenManager.getAccessToken();
|
|
@@ -1031,12 +1201,14 @@ class DefaultAuthProvider {
|
|
|
1031
1201
|
* Exported for consumers who need version info.
|
|
1032
1202
|
* Used internally for X-SDK-Version header.
|
|
1033
1203
|
*
|
|
1204
|
+
* Version is injected at build time via @rollup/plugin-replace
|
|
1205
|
+
*
|
|
1034
1206
|
* @module @explorins/pers-sdk/core
|
|
1035
1207
|
*/
|
|
1036
1208
|
/** SDK package name */
|
|
1037
|
-
const SDK_NAME =
|
|
1038
|
-
/** SDK version -
|
|
1039
|
-
const SDK_VERSION =
|
|
1209
|
+
const SDK_NAME = "@explorins/pers-sdk";
|
|
1210
|
+
/** SDK version - injected from package.json at build time */
|
|
1211
|
+
const SDK_VERSION = "2.1.27";
|
|
1040
1212
|
/** Full SDK identifier for headers */
|
|
1041
1213
|
const SDK_USER_AGENT = `${SDK_NAME}/${SDK_VERSION}`;
|
|
1042
1214
|
|
|
@@ -1966,7 +2138,14 @@ class AuthManager {
|
|
|
1966
2138
|
*/
|
|
1967
2139
|
async loginWithRawData(rawUserData) {
|
|
1968
2140
|
const authService = this.apiClient.getAuthService();
|
|
1969
|
-
|
|
2141
|
+
const result = await authService.loginUserWithRawData(rawUserData);
|
|
2142
|
+
this.events?.emitSuccess({
|
|
2143
|
+
domain: 'authentication',
|
|
2144
|
+
type: 'login_success',
|
|
2145
|
+
userMessage: 'Successfully logged in',
|
|
2146
|
+
details: { user: result.user }
|
|
2147
|
+
});
|
|
2148
|
+
return result;
|
|
1970
2149
|
}
|
|
1971
2150
|
/**
|
|
1972
2151
|
* Get current authenticated user
|
|
@@ -2067,6 +2246,11 @@ class AuthManager {
|
|
|
2067
2246
|
async clearAuth() {
|
|
2068
2247
|
const authService = this.apiClient.getAuthService();
|
|
2069
2248
|
await authService.clearTokens();
|
|
2249
|
+
this.events?.emitSuccess({
|
|
2250
|
+
domain: 'authentication',
|
|
2251
|
+
type: 'logout_success',
|
|
2252
|
+
userMessage: 'Successfully logged out'
|
|
2253
|
+
});
|
|
2070
2254
|
}
|
|
2071
2255
|
/**
|
|
2072
2256
|
* Ensure authentication token is valid
|
|
@@ -9936,5 +10120,5 @@ function createPersSDK(httpClient, config) {
|
|
|
9936
10120
|
return new PersSDK(httpClient, config);
|
|
9937
10121
|
}
|
|
9938
10122
|
|
|
9939
|
-
export { AuthStatus as A, BusinessManager as B, CampaignManager as C, DefaultAuthProvider as D, FileApi as E, FileManager as F, FileService as G, ApiKeyApi as H,
|
|
9940
|
-
//# sourceMappingURL=pers-sdk-
|
|
10123
|
+
export { AuthStatus as A, BusinessManager as B, CampaignManager as C, DefaultAuthProvider as D, FileApi as E, FileManager as F, FileService as G, ApiKeyApi as H, IndexedDBTokenStorage as I, WebhookApi as J, WebhookService as K, LocalStorageTokenStorage as L, MemoryTokenStorage as M, PersEventsClient as N, createPersEventsClient as O, PersSDK as P, RedemptionManager as R, SDK_NAME as S, TokenManager as T, UserManager as U, WebDPoPCryptoProvider as W, AuthTokenManager as a, AUTH_STORAGE_KEYS as b, createPersSDK as c, DPOP_STORAGE_KEYS as d, SDK_VERSION as e, SDK_USER_AGENT as f, PersApiClient as g, DEFAULT_PERS_CONFIG as h, buildApiRoot as i, buildWalletEventsWsUrl as j, StaticJwtAuthProvider as k, AuthApi as l, mergeWithDefaults as m, AuthService as n, DPoPManager as o, PersEventEmitter as p, AuthManager as q, UserStatusManager as r, TransactionManager as s, PurchaseManager as t, ApiKeyManager as u, AnalyticsManager as v, DonationManager as w, TriggerSourceManager as x, WebhookManager as y, WalletEventsManager as z };
|
|
10124
|
+
//# sourceMappingURL=pers-sdk-C-3E3svL.js.map
|