@explorins/pers-sdk 2.1.40 → 2.1.42

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/core.js CHANGED
@@ -1,4 +1,4 @@
1
- export { b as AUTH_STORAGE_KEYS, x as AnalyticsManager, w as ApiKeyManager, l as AuthApi, r as AuthManager, o as AuthService, a as AuthTokenManager, B as BusinessManager, C as CampaignManager, h as DEFAULT_PERS_CONFIG, d as DPOP_STORAGE_KEYS, p as DPoPManager, D as DefaultAuthProvider, y as DonationManager, F as FATAL_AUTH_CODES, v as FileManager, I as IndexedDBTokenStorage, L as LocalStorageTokenStorage, M as MemoryTokenStorage, g as PersApiClient, q as PersEventEmitter, P as PersSDK, u as PurchaseManager, R as RedemptionManager, S as SDK_NAME, f as SDK_USER_AGENT, e as SDK_VERSION, k as StaticJwtAuthProvider, T as TokenManager, t as TransactionManager, z as TriggerSourceManager, U as UserManager, s as UserStatusManager, G as WalletEventsManager, W as WebDPoPCryptoProvider, E as WebhookManager, i as buildApiRoot, j as buildWalletEventsWsUrl, c as createPersSDK, n as isFatalAuthErrorInMessage, m as mergeWithDefaults } from './chunks/pers-sdk-DuDWwRWC.js';
1
+ export { a as AUTH_STORAGE_KEYS, w as AnalyticsManager, v as ApiKeyManager, k as AuthApi, q as AuthManager, n as AuthService, A as AuthTokenManager, B as BusinessManager, C as CampaignManager, g as DEFAULT_PERS_CONFIG, b as DPOP_STORAGE_KEYS, o as DPoPManager, D as DefaultAuthProvider, x as DonationManager, F as FATAL_AUTH_CODES, u as FileManager, I as IndexedDBTokenStorage, L as LocalStorageTokenStorage, M as MemoryTokenStorage, f as PersApiClient, p as PersEventEmitter, P as PersSDK, t as PurchaseManager, R as RedemptionManager, S as SDK_NAME, d as SDK_USER_AGENT, c as SDK_VERSION, j as StaticJwtAuthProvider, T as TokenManager, s as TransactionManager, y as TriggerSourceManager, U as UserManager, r as UserStatusManager, E as WalletEventsManager, W as WebDPoPCryptoProvider, z as WebhookManager, h as buildApiRoot, i as buildWalletEventsWsUrl, e as createPersSDK, l as isFatalAuthErrorInMessage, m as mergeWithDefaults } from './chunks/pers-sdk-DxYmXQcW.js';
2
2
  export { AccountOwnerType } from '@explorins/pers-shared';
3
3
  export { d as detectEnvironment, e as environment, w as warnIfProblematicEnvironment } from './chunks/environment-DEI_L882.js';
4
4
  export { c as ApiErrorDetector, A as AuthenticationError, a as CacheService, C as CacheTTL, E as ErrorUtils, L as LogoutRequired, N as NetworkError, b as PersApiError, P as ProviderTokenRefreshNeeded, S as SdkErrorCodes, T as TokenRefreshNeeded, g as globalCacheService } from './chunks/index--OssIds0.js';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var persSdk = require('./chunks/pers-sdk-CBvzmlL_.cjs');
3
+ var persSdk = require('./chunks/pers-sdk-DeFxjuRB.cjs');
4
4
  var persShared = require('@explorins/pers-shared');
5
5
  var environment = require('./chunks/environment-C_hPDl8L.cjs');
6
6
  var index = require('./chunks/index-C4K-jkRO.cjs');
@@ -22,7 +22,82 @@ var triggerSource = require('./trigger-source.cjs');
22
22
  var platformAdapters = require('./platform-adapters.cjs');
23
23
  var nodeHttpClient = require('./chunks/node-http-client-D_avaa5F.cjs');
24
24
 
25
-
25
+ /**
26
+ * Build optimized image URL with automatic IPFS resolution and CDN options
27
+ *
28
+ * Single entry point for all image URL building:
29
+ * - IPFS URIs → resolved via gateway + CDN options applied
30
+ * - HTTP URLs → CDN options applied directly
31
+ *
32
+ * @param url - Image URL (ipfs://, https://, or any URL)
33
+ * @param options - CDN optimization options (preset, quality, format, fit)
34
+ * @param gateway - IPFS gateway domain (required for ipfs:// URLs)
35
+ * @returns Optimized URL with query parameters
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // IPFS thumbnail
40
+ * buildImageUrl('ipfs://QmHash', { preset: 'thumb' }, 'cdn.example.com')
41
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=thumb'
42
+ *
43
+ * // IPFS hero with high quality
44
+ * buildImageUrl('ipfs://QmHash', { preset: 'hero', q: 95, fit: 'cover' }, 'cdn.example.com')
45
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=hero&q=95&fit=cover'
46
+ *
47
+ * // HTTP URL (gateway ignored)
48
+ * buildImageUrl('https://example.com/photo.jpg', { preset: 'card' })
49
+ * // => 'https://example.com/photo.jpg?preset=card'
50
+ *
51
+ * // No options - just IPFS resolution
52
+ * buildImageUrl('ipfs://QmHash', undefined, 'cdn.example.com')
53
+ * // => 'https://cdn.example.com/ipfs/QmHash'
54
+ * ```
55
+ */
56
+ function buildImageUrl(url, options, gateway) {
57
+ if (!url)
58
+ return '';
59
+ let resolvedUrl = url;
60
+ // Resolve IPFS to HTTP via gateway
61
+ if (url.startsWith('ipfs://')) {
62
+ if (!gateway) {
63
+ console.warn('[buildImageUrl] IPFS URL requires gateway parameter');
64
+ return url;
65
+ }
66
+ const cid = url.replace('ipfs://', '');
67
+ resolvedUrl = `https://${gateway}/ipfs/${cid}`;
68
+ }
69
+ // Apply CDN options
70
+ return persShared.buildImageCdnUrl(resolvedUrl, options);
71
+ }
72
+ /**
73
+ * Check if a URL is an IPFS URI
74
+ *
75
+ * @param url - URL to check
76
+ * @returns True if URL starts with ipfs://
77
+ */
78
+ function isIpfsUrl(url) {
79
+ return !!url && url.startsWith('ipfs://');
80
+ }
81
+ /**
82
+ * Extract CID from IPFS URI
83
+ *
84
+ * @param ipfsUri - IPFS URI (ipfs://Qm... or ipfs://baf...)
85
+ * @returns CID string, or null if not a valid IPFS URI
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * extractIpfsCid('ipfs://QmHash123')
90
+ * // => 'QmHash123'
91
+ *
92
+ * extractIpfsCid('https://example.com/image.jpg')
93
+ * // => null
94
+ * ```
95
+ */
96
+ function extractIpfsCid(ipfsUri) {
97
+ if (!isIpfsUrl(ipfsUri))
98
+ return null;
99
+ return ipfsUri.replace('ipfs://', '');
100
+ }
26
101
 
27
102
  exports.AUTH_STORAGE_KEYS = persSdk.AUTH_STORAGE_KEYS;
28
103
  exports.AnalyticsManager = persSdk.AnalyticsManager;
@@ -32,8 +107,8 @@ exports.AuthApi = persSdk.AuthApi;
32
107
  exports.AuthManager = persSdk.AuthManager;
33
108
  exports.AuthService = persSdk.AuthService;
34
109
  Object.defineProperty(exports, "AuthStatus", {
35
- enumerable: true,
36
- get: function () { return persSdk.AuthStatus; }
110
+ enumerable: true,
111
+ get: function () { return persSdk.AuthStatus; }
37
112
  });
38
113
  exports.AuthTokenManager = persSdk.AuthTokenManager;
39
114
  exports.BusinessManager = persSdk.BusinessManager;
@@ -77,40 +152,76 @@ exports.createPersSDK = persSdk.createPersSDK;
77
152
  exports.isFatalAuthErrorInMessage = persSdk.isFatalAuthErrorInMessage;
78
153
  exports.mergeWithDefaults = persSdk.mergeWithDefaults;
79
154
  Object.defineProperty(exports, "AccountOwnerType", {
80
- enumerable: true,
81
- get: function () { return persShared.AccountOwnerType; }
155
+ enumerable: true,
156
+ get: function () { return persShared.AccountOwnerType; }
157
+ });
158
+ Object.defineProperty(exports, "IMAGE_CDN_DEFAULT_FIT", {
159
+ enumerable: true,
160
+ get: function () { return persShared.IMAGE_CDN_DEFAULT_FIT; }
161
+ });
162
+ Object.defineProperty(exports, "IMAGE_CDN_DEFAULT_FORMAT", {
163
+ enumerable: true,
164
+ get: function () { return persShared.IMAGE_CDN_DEFAULT_FORMAT; }
165
+ });
166
+ Object.defineProperty(exports, "IMAGE_CDN_DEFAULT_QUALITY", {
167
+ enumerable: true,
168
+ get: function () { return persShared.IMAGE_CDN_DEFAULT_QUALITY; }
169
+ });
170
+ Object.defineProperty(exports, "IMAGE_CDN_MAX_DIMENSION", {
171
+ enumerable: true,
172
+ get: function () { return persShared.IMAGE_CDN_MAX_DIMENSION; }
173
+ });
174
+ Object.defineProperty(exports, "IMAGE_CDN_PRESETS", {
175
+ enumerable: true,
176
+ get: function () { return persShared.IMAGE_CDN_PRESETS; }
82
177
  });
83
178
  Object.defineProperty(exports, "SortOrder", {
84
- enumerable: true,
85
- get: function () { return persShared.SortOrder; }
179
+ enumerable: true,
180
+ get: function () { return persShared.SortOrder; }
86
181
  });
87
182
  Object.defineProperty(exports, "VALID_USER_RELATIONS", {
88
- enumerable: true,
89
- get: function () { return persShared.VALID_USER_RELATIONS; }
183
+ enumerable: true,
184
+ get: function () { return persShared.VALID_USER_RELATIONS; }
185
+ });
186
+ Object.defineProperty(exports, "buildImageCdnUrl", {
187
+ enumerable: true,
188
+ get: function () { return persShared.buildImageCdnUrl; }
189
+ });
190
+ Object.defineProperty(exports, "getPresetDimensions", {
191
+ enumerable: true,
192
+ get: function () { return persShared.getPresetDimensions; }
90
193
  });
91
194
  Object.defineProperty(exports, "isConnectedMessage", {
92
- enumerable: true,
93
- get: function () { return persShared.isConnectedMessage; }
195
+ enumerable: true,
196
+ get: function () { return persShared.isConnectedMessage; }
94
197
  });
95
198
  Object.defineProperty(exports, "isErrorMessage", {
96
- enumerable: true,
97
- get: function () { return persShared.isErrorMessage; }
199
+ enumerable: true,
200
+ get: function () { return persShared.isErrorMessage; }
98
201
  });
99
202
  Object.defineProperty(exports, "isEventMessage", {
100
- enumerable: true,
101
- get: function () { return persShared.isEventMessage; }
203
+ enumerable: true,
204
+ get: function () { return persShared.isEventMessage; }
102
205
  });
103
206
  Object.defineProperty(exports, "isServerMessage", {
104
- enumerable: true,
105
- get: function () { return persShared.isServerMessage; }
207
+ enumerable: true,
208
+ get: function () { return persShared.isServerMessage; }
106
209
  });
107
210
  Object.defineProperty(exports, "isSubscribedMessage", {
108
- enumerable: true,
109
- get: function () { return persShared.isSubscribedMessage; }
211
+ enumerable: true,
212
+ get: function () { return persShared.isSubscribedMessage; }
213
+ });
214
+ Object.defineProperty(exports, "isSupportedImageFormat", {
215
+ enumerable: true,
216
+ get: function () { return persShared.isSupportedImageFormat; }
217
+ });
218
+ Object.defineProperty(exports, "isValidPreset", {
219
+ enumerable: true,
220
+ get: function () { return persShared.isValidPreset; }
110
221
  });
111
222
  Object.defineProperty(exports, "isValidUserRelation", {
112
- enumerable: true,
113
- get: function () { return persShared.isValidUserRelation; }
223
+ enumerable: true,
224
+ get: function () { return persShared.isValidUserRelation; }
114
225
  });
115
226
  exports.detectEnvironment = environment.detectEnvironment;
116
227
  exports.environment = environment.environment;
@@ -179,10 +290,13 @@ exports.TriggerSourceService = triggerSource.TriggerSourceService;
179
290
  exports.AngularHttpClientAdapter = platformAdapters.AngularHttpClientAdapter;
180
291
  exports.BrowserFetchClientAdapter = platformAdapters.BrowserFetchClientAdapter;
181
292
  exports.NodeHttpClientAdapter = nodeHttpClient.NodeHttpClientAdapter;
293
+ exports.buildImageUrl = buildImageUrl;
294
+ exports.extractIpfsCid = extractIpfsCid;
295
+ exports.isIpfsUrl = isIpfsUrl;
182
296
  Object.keys(persShared).forEach(function (k) {
183
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
184
- enumerable: true,
185
- get: function () { return persShared[k]; }
186
- });
297
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
298
+ enumerable: true,
299
+ get: function () { return persShared[k]; }
300
+ });
187
301
  });
188
302
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/shared/utils/image-url-utils.ts"],"sourcesContent":[null],"names":["buildImageCdnUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;SACa,aAAa,CAC3B,GAAW,EACX,OAAyB,EACzB,OAAgB,EAAA;AAEhB,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;IAEnB,IAAI,WAAW,GAAG,GAAG;;AAGrB,IAAA,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC;AACnE,YAAA,OAAO,GAAG;QACZ;QACA,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACtC,QAAA,WAAW,GAAG,CAAA,QAAA,EAAW,OAAO,CAAA,MAAA,EAAS,GAAG,EAAE;IAChD;;AAGA,IAAA,OAAOA,2BAAgB,CAAC,WAAW,EAAE,OAAO,CAAC;AAC/C;AAEA;;;;;AAKG;AACG,SAAU,SAAS,CAAC,GAAW,EAAA;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;AAC3C;AAEA;;;;;;;;;;;;;;AAcG;AACG,SAAU,cAAc,CAAC,OAAe,EAAA;AAC5C,IAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;AAAE,QAAA,OAAO,IAAI;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
- export { b as AUTH_STORAGE_KEYS, x as AnalyticsManager, K as ApiKeyApi, w as ApiKeyManager, l as AuthApi, r as AuthManager, o as AuthService, A as AuthStatus, a as AuthTokenManager, B as BusinessManager, C as CampaignManager, h as DEFAULT_PERS_CONFIG, d as DPOP_STORAGE_KEYS, p as DPoPManager, D as DefaultAuthProvider, y as DonationManager, F as FATAL_AUTH_CODES, H as FileApi, v as FileManager, J as FileService, I as IndexedDBTokenStorage, L as LocalStorageTokenStorage, M as MemoryTokenStorage, g as PersApiClient, q as PersEventEmitter, Q as PersEventsClient, P as PersSDK, u as PurchaseManager, R as RedemptionManager, S as SDK_NAME, f as SDK_USER_AGENT, e as SDK_VERSION, k as StaticJwtAuthProvider, T as TokenManager, t as TransactionManager, z as TriggerSourceManager, U as UserManager, s as UserStatusManager, G as WalletEventsManager, W as WebDPoPCryptoProvider, N as WebhookApi, E as WebhookManager, O as WebhookService, i as buildApiRoot, j as buildWalletEventsWsUrl, V as createPersEventsClient, c as createPersSDK, n as isFatalAuthErrorInMessage, m as mergeWithDefaults } from './chunks/pers-sdk-DuDWwRWC.js';
1
+ export { a as AUTH_STORAGE_KEYS, w as AnalyticsManager, K as ApiKeyApi, v as ApiKeyManager, k as AuthApi, q as AuthManager, n as AuthService, G as AuthStatus, A as AuthTokenManager, B as BusinessManager, C as CampaignManager, g as DEFAULT_PERS_CONFIG, b as DPOP_STORAGE_KEYS, o as DPoPManager, D as DefaultAuthProvider, x as DonationManager, F as FATAL_AUTH_CODES, H as FileApi, u as FileManager, J as FileService, I as IndexedDBTokenStorage, L as LocalStorageTokenStorage, M as MemoryTokenStorage, f as PersApiClient, p as PersEventEmitter, Q as PersEventsClient, P as PersSDK, t as PurchaseManager, R as RedemptionManager, S as SDK_NAME, d as SDK_USER_AGENT, c as SDK_VERSION, j as StaticJwtAuthProvider, T as TokenManager, s as TransactionManager, y as TriggerSourceManager, U as UserManager, r as UserStatusManager, E as WalletEventsManager, W as WebDPoPCryptoProvider, N as WebhookApi, z as WebhookManager, O as WebhookService, h as buildApiRoot, i as buildWalletEventsWsUrl, V as createPersEventsClient, e as createPersSDK, l as isFatalAuthErrorInMessage, m as mergeWithDefaults } from './chunks/pers-sdk-DxYmXQcW.js';
2
+ import { buildImageCdnUrl } from '@explorins/pers-shared';
2
3
  export * from '@explorins/pers-shared';
3
- export { AccountOwnerType, SortOrder, VALID_USER_RELATIONS, isConnectedMessage, isErrorMessage, isEventMessage, isServerMessage, isSubscribedMessage, isValidUserRelation } from '@explorins/pers-shared';
4
+ export { AccountOwnerType, IMAGE_CDN_DEFAULT_FIT, IMAGE_CDN_DEFAULT_FORMAT, IMAGE_CDN_DEFAULT_QUALITY, IMAGE_CDN_MAX_DIMENSION, IMAGE_CDN_PRESETS, SortOrder, VALID_USER_RELATIONS, buildImageCdnUrl, getPresetDimensions, isConnectedMessage, isErrorMessage, isEventMessage, isServerMessage, isSubscribedMessage, isSupportedImageFormat, isValidPreset, isValidUserRelation } from '@explorins/pers-shared';
4
5
  export { d as detectEnvironment, e as environment, w as warnIfProblematicEnvironment } from './chunks/environment-DEI_L882.js';
5
6
  export { c as ApiErrorDetector, A as AuthenticationError, a as CacheService, C as CacheTTL, E as ErrorUtils, L as LogoutRequired, N as NetworkError, b as PersApiError, P as ProviderTokenRefreshNeeded, S as SdkErrorCodes, T as TokenRefreshNeeded, g as globalCacheService } from './chunks/index--OssIds0.js';
6
7
  export { T as TenantManager } from './chunks/tenant-manager-xmYKBFGu.js';
@@ -20,4 +21,83 @@ export { UserStatusApi, UserStatusService, createUserStatusSDK } from './user-st
20
21
  export { TriggerSourceApi, TriggerSourceService } from './trigger-source.js';
21
22
  export { AngularHttpClientAdapter, BrowserFetchClientAdapter } from './platform-adapters.js';
22
23
  export { N as NodeHttpClientAdapter } from './chunks/node-http-client-DloDLfm9.js';
24
+
25
+ /**
26
+ * Build optimized image URL with automatic IPFS resolution and CDN options
27
+ *
28
+ * Single entry point for all image URL building:
29
+ * - IPFS URIs → resolved via gateway + CDN options applied
30
+ * - HTTP URLs → CDN options applied directly
31
+ *
32
+ * @param url - Image URL (ipfs://, https://, or any URL)
33
+ * @param options - CDN optimization options (preset, quality, format, fit)
34
+ * @param gateway - IPFS gateway domain (required for ipfs:// URLs)
35
+ * @returns Optimized URL with query parameters
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * // IPFS thumbnail
40
+ * buildImageUrl('ipfs://QmHash', { preset: 'thumb' }, 'cdn.example.com')
41
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=thumb'
42
+ *
43
+ * // IPFS hero with high quality
44
+ * buildImageUrl('ipfs://QmHash', { preset: 'hero', q: 95, fit: 'cover' }, 'cdn.example.com')
45
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=hero&q=95&fit=cover'
46
+ *
47
+ * // HTTP URL (gateway ignored)
48
+ * buildImageUrl('https://example.com/photo.jpg', { preset: 'card' })
49
+ * // => 'https://example.com/photo.jpg?preset=card'
50
+ *
51
+ * // No options - just IPFS resolution
52
+ * buildImageUrl('ipfs://QmHash', undefined, 'cdn.example.com')
53
+ * // => 'https://cdn.example.com/ipfs/QmHash'
54
+ * ```
55
+ */
56
+ function buildImageUrl(url, options, gateway) {
57
+ if (!url)
58
+ return '';
59
+ let resolvedUrl = url;
60
+ // Resolve IPFS to HTTP via gateway
61
+ if (url.startsWith('ipfs://')) {
62
+ if (!gateway) {
63
+ console.warn('[buildImageUrl] IPFS URL requires gateway parameter');
64
+ return url;
65
+ }
66
+ const cid = url.replace('ipfs://', '');
67
+ resolvedUrl = `https://${gateway}/ipfs/${cid}`;
68
+ }
69
+ // Apply CDN options
70
+ return buildImageCdnUrl(resolvedUrl, options);
71
+ }
72
+ /**
73
+ * Check if a URL is an IPFS URI
74
+ *
75
+ * @param url - URL to check
76
+ * @returns True if URL starts with ipfs://
77
+ */
78
+ function isIpfsUrl(url) {
79
+ return !!url && url.startsWith('ipfs://');
80
+ }
81
+ /**
82
+ * Extract CID from IPFS URI
83
+ *
84
+ * @param ipfsUri - IPFS URI (ipfs://Qm... or ipfs://baf...)
85
+ * @returns CID string, or null if not a valid IPFS URI
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * extractIpfsCid('ipfs://QmHash123')
90
+ * // => 'QmHash123'
91
+ *
92
+ * extractIpfsCid('https://example.com/image.jpg')
93
+ * // => null
94
+ * ```
95
+ */
96
+ function extractIpfsCid(ipfsUri) {
97
+ if (!isIpfsUrl(ipfsUri))
98
+ return null;
99
+ return ipfsUri.replace('ipfs://', '');
100
+ }
101
+
102
+ export { buildImageUrl, extractIpfsCid, isIpfsUrl };
23
103
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/shared/utils/image-url-utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;SACa,aAAa,CAC3B,GAAW,EACX,OAAyB,EACzB,OAAgB,EAAA;AAEhB,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;IAEnB,IAAI,WAAW,GAAG,GAAG;;AAGrB,IAAA,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,OAAO,CAAC,IAAI,CAAC,qDAAqD,CAAC;AACnE,YAAA,OAAO,GAAG;QACZ;QACA,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACtC,QAAA,WAAW,GAAG,CAAA,QAAA,EAAW,OAAO,CAAA,MAAA,EAAS,GAAG,EAAE;IAChD;;AAGA,IAAA,OAAO,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC;AAC/C;AAEA;;;;;AAKG;AACG,SAAU,SAAS,CAAC,GAAW,EAAA;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;AAC3C;AAEA;;;;;;;;;;;;;;AAcG;AACG,SAAU,cAAc,CAAC,OAAe,EAAA;AAC5C,IAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;AAAE,QAAA,OAAO,IAAI;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;AACvC;;;;"}
package/dist/node.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var persSdk = require('./chunks/pers-sdk-CBvzmlL_.cjs');
3
+ var persSdk = require('./chunks/pers-sdk-DeFxjuRB.cjs');
4
4
  var persShared = require('@explorins/pers-shared');
5
5
  var nodeHttpClient = require('./chunks/node-http-client-D_avaa5F.cjs');
6
6
  require('./chunks/index-C4K-jkRO.cjs');
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { k as StaticJwtAuthProvider, P as PersSDK } from './chunks/pers-sdk-DuDWwRWC.js';
1
+ import { j as StaticJwtAuthProvider, P as PersSDK } from './chunks/pers-sdk-DxYmXQcW.js';
2
2
  import { AccountOwnerType } from '@explorins/pers-shared';
3
3
  export { AccountOwnerType } from '@explorins/pers-shared';
4
4
  import { N as NodeHttpClientAdapter } from './chunks/node-http-client-DloDLfm9.js';
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorins/pers-sdk",
3
- "version": "2.1.40",
3
+ "version": "2.1.42",
4
4
  "description": "Platform-agnostic SDK for PERS (Phygital Experience Rewards System) - Core business logic and API integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -133,7 +133,7 @@
133
133
  },
134
134
  "dependencies": {
135
135
  "@explorins/pers-sdk": "^2.1.32",
136
- "@explorins/pers-shared": "^2.1.147",
136
+ "@explorins/pers-shared": "^2.1.154",
137
137
  "@explorins/web3-ts": "^0.3.88",
138
138
  "@explorins/web3-types": "^1.2.0",
139
139
  "ethers": "^6.15.0"
@@ -4,4 +4,5 @@
4
4
  */
5
5
  export * from './interfaces/pers-shared-lib.interfaces';
6
6
  export * from './utils/pagination-utils';
7
+ export * from './utils/image-url-utils';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,yCAAyC,CAAC;AAGxD,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,yCAAyC,CAAC;AAGxD,cAAc,0BAA0B,CAAC;AAGzC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { ImageCdnOptions } from '@explorins/pers-shared';
2
+ /**
3
+ * Image URL Utilities
4
+ *
5
+ * Centralized helper for building optimized image URLs.
6
+ * Handles IPFS resolution and CDN optimization in one call.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { buildImageUrl } from '@explorins/pers-sdk';
11
+ *
12
+ * // IPFS with CDN preset
13
+ * const thumbUrl = buildImageUrl('ipfs://Qm...', { preset: 'thumb' }, 'cdn.example.com');
14
+ *
15
+ * // HTTP URL with CDN preset (no gateway needed)
16
+ * const cardUrl = buildImageUrl('https://example.com/photo.jpg', { preset: 'card' });
17
+ * ```
18
+ */
19
+ export { buildImageCdnUrl, isValidPreset, getPresetDimensions, isSupportedImageFormat, IMAGE_CDN_PRESETS, IMAGE_CDN_DEFAULT_QUALITY, IMAGE_CDN_DEFAULT_FIT, IMAGE_CDN_DEFAULT_FORMAT, IMAGE_CDN_MAX_DIMENSION, } from '@explorins/pers-shared';
20
+ export type { ImageCdnOptions, ImagePreset, ImageFit, ImageFormat, ImagePresetConfig, } from '@explorins/pers-shared';
21
+ /**
22
+ * Build optimized image URL with automatic IPFS resolution and CDN options
23
+ *
24
+ * Single entry point for all image URL building:
25
+ * - IPFS URIs → resolved via gateway + CDN options applied
26
+ * - HTTP URLs → CDN options applied directly
27
+ *
28
+ * @param url - Image URL (ipfs://, https://, or any URL)
29
+ * @param options - CDN optimization options (preset, quality, format, fit)
30
+ * @param gateway - IPFS gateway domain (required for ipfs:// URLs)
31
+ * @returns Optimized URL with query parameters
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // IPFS thumbnail
36
+ * buildImageUrl('ipfs://QmHash', { preset: 'thumb' }, 'cdn.example.com')
37
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=thumb'
38
+ *
39
+ * // IPFS hero with high quality
40
+ * buildImageUrl('ipfs://QmHash', { preset: 'hero', q: 95, fit: 'cover' }, 'cdn.example.com')
41
+ * // => 'https://cdn.example.com/ipfs/QmHash?preset=hero&q=95&fit=cover'
42
+ *
43
+ * // HTTP URL (gateway ignored)
44
+ * buildImageUrl('https://example.com/photo.jpg', { preset: 'card' })
45
+ * // => 'https://example.com/photo.jpg?preset=card'
46
+ *
47
+ * // No options - just IPFS resolution
48
+ * buildImageUrl('ipfs://QmHash', undefined, 'cdn.example.com')
49
+ * // => 'https://cdn.example.com/ipfs/QmHash'
50
+ * ```
51
+ */
52
+ export declare function buildImageUrl(url: string, options?: ImageCdnOptions, gateway?: string): string;
53
+ /**
54
+ * Check if a URL is an IPFS URI
55
+ *
56
+ * @param url - URL to check
57
+ * @returns True if URL starts with ipfs://
58
+ */
59
+ export declare function isIpfsUrl(url: string): boolean;
60
+ /**
61
+ * Extract CID from IPFS URI
62
+ *
63
+ * @param ipfsUri - IPFS URI (ipfs://Qm... or ipfs://baf...)
64
+ * @returns CID string, or null if not a valid IPFS URI
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * extractIpfsCid('ipfs://QmHash123')
69
+ * // => 'QmHash123'
70
+ *
71
+ * extractIpfsCid('https://example.com/image.jpg')
72
+ * // => null
73
+ * ```
74
+ */
75
+ export declare function extractIpfsCid(ipfsUri: string): string | null;
76
+ //# sourceMappingURL=image-url-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-url-utils.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/image-url-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,eAAe,EACf,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAiBR;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorins/pers-sdk",
3
- "version": "2.1.40",
3
+ "version": "2.1.42",
4
4
  "description": "Platform-agnostic SDK for PERS (Phygital Experience Rewards System) - Core business logic and API integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -133,7 +133,7 @@
133
133
  },
134
134
  "dependencies": {
135
135
  "@explorins/pers-sdk": "^2.1.32",
136
- "@explorins/pers-shared": "^2.1.147",
136
+ "@explorins/pers-shared": "^2.1.154",
137
137
  "@explorins/web3-ts": "^0.3.88",
138
138
  "@explorins/web3-types": "^1.2.0",
139
139
  "ethers": "^6.15.0"