@sidub-inc/licensing-client 1.5.85 → 1.6.0
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/README.md +101 -13
- package/dist/index.cjs +208 -173
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +178 -98
- package/dist/index.esm.js +209 -169
- package/dist/index.esm.js.map +1 -1
- package/docs/MIGRATION.md +122 -1
- package/docs/REACT_GUIDE.md +57 -10
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A single structured detail entry from the server's shared ApiError contract.
|
|
5
|
+
* Mirrors the .NET ApiErrorDetail entity {Code, Message, Field, TargetId}.
|
|
6
|
+
*/
|
|
7
|
+
interface ApiErrorDetail {
|
|
8
|
+
/** Machine-readable detail code. */
|
|
9
|
+
code?: string;
|
|
10
|
+
/** Human-readable detail message. */
|
|
11
|
+
message?: string;
|
|
12
|
+
/** The request field the detail refers to, when applicable. */
|
|
13
|
+
field?: string;
|
|
14
|
+
/** The identifier of the entity the detail refers to, when applicable. */
|
|
15
|
+
targetId?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Minimal structural view of a fetch Response used for error construction.
|
|
19
|
+
* Kept structural (rather than the DOM Response type) so Node callers and
|
|
20
|
+
* tests can supply plain objects.
|
|
21
|
+
*/
|
|
22
|
+
interface HttpErrorResponseLike {
|
|
23
|
+
status?: number;
|
|
24
|
+
statusText?: string;
|
|
25
|
+
text?: () => Promise<string>;
|
|
26
|
+
headers?: {
|
|
27
|
+
get?: (name: string) => string | null;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
3
30
|
/**
|
|
4
31
|
* Error class for licensing-related errors.
|
|
5
32
|
* Thrown when API requests fail, authorization is denied, or network errors occur.
|
|
33
|
+
*
|
|
34
|
+
* When the failure came from the licensing service over HTTP, the server's
|
|
35
|
+
* shared ApiError contract {Code, Message, CorrelationId, Details[]} is parsed
|
|
36
|
+
* onto the error (MON-334 SR2): branch on {@link code} for machine handling and
|
|
37
|
+
* quote {@link correlationId} in support requests. Both are undefined only for
|
|
38
|
+
* failures that never reached the server (network errors, timeouts) or when the
|
|
39
|
+
* server did not supply them.
|
|
6
40
|
*/
|
|
7
41
|
declare class LicensingError extends Error {
|
|
8
42
|
statusCode?: number | undefined;
|
|
@@ -13,6 +47,21 @@ declare class LicensingError extends Error {
|
|
|
13
47
|
* retry policy; undefined when the server did not supply one.
|
|
14
48
|
*/
|
|
15
49
|
retryAfterMs?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Machine-readable error code from the server's ApiError body (e.g.
|
|
52
|
+
* 'ApiKeyMissing', 'AuthorizationDenied', 'NotFound', 'ValidationError',
|
|
53
|
+
* 'ServerError'). Undefined when the response body was not a parseable
|
|
54
|
+
* ApiError or the failure never reached the server.
|
|
55
|
+
*/
|
|
56
|
+
code?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The request correlation id, from the ApiError body or the X-Correlation-Id
|
|
59
|
+
* response header. Quote this value in support requests — it stitches the
|
|
60
|
+
* client failure to the server-side logs.
|
|
61
|
+
*/
|
|
62
|
+
correlationId?: string;
|
|
63
|
+
/** Structured per-field details from the ApiError body, when supplied. */
|
|
64
|
+
details?: ApiErrorDetail[];
|
|
16
65
|
/**
|
|
17
66
|
* Creates a new licensing error.
|
|
18
67
|
* @param message A description of the error.
|
|
@@ -20,6 +69,23 @@ declare class LicensingError extends Error {
|
|
|
20
69
|
* @param response The raw response body from the server, if available.
|
|
21
70
|
*/
|
|
22
71
|
constructor(message: string, statusCode?: number | undefined, response?: unknown | undefined);
|
|
72
|
+
/**
|
|
73
|
+
* Builds a LicensingError from a non-OK HTTP response, parsing the server's
|
|
74
|
+
* shared ApiError contract {Code, Message, CorrelationId, Details[]} plus the
|
|
75
|
+
* X-Correlation-Id and Retry-After response headers (MON-334 SR2).
|
|
76
|
+
*
|
|
77
|
+
* The machine code and correlation id are never dropped: when the body is not
|
|
78
|
+
* a parseable ApiError the correlation id still comes from the header, and
|
|
79
|
+
* the raw body text is always preserved on {@link response}. The message
|
|
80
|
+
* prefers the server's human-readable ApiError.Message and falls back to the
|
|
81
|
+
* HTTP status text only when no server message is available.
|
|
82
|
+
*
|
|
83
|
+
* @param operation Human-readable operation name used as the message prefix
|
|
84
|
+
* (e.g. 'Authorization' → 'Authorization failed: ...').
|
|
85
|
+
* @param response The non-OK fetch response (or a structural equivalent).
|
|
86
|
+
* @returns The constructed error, ready to throw.
|
|
87
|
+
*/
|
|
88
|
+
static fromHttpResponse(operation: string, response: HttpErrorResponseLike): Promise<LicensingError>;
|
|
23
89
|
}
|
|
24
90
|
|
|
25
91
|
/**
|
|
@@ -87,11 +153,15 @@ declare enum BillingIntervalUnit {
|
|
|
87
153
|
declare function normalizeBillingIntervalUnit(value: number | string | null | undefined): BillingIntervalUnit | undefined;
|
|
88
154
|
|
|
89
155
|
/**
|
|
90
|
-
* Base interface for license features
|
|
156
|
+
* Base interface for license features.
|
|
157
|
+
*
|
|
158
|
+
* The identifier is `featureKey`, matching the wire vocabulary (the server
|
|
159
|
+
* serializes `FeatureKey`) and the rest of the SDK (assertions, consumption,
|
|
160
|
+
* state views). Renamed from `featureId` in 2.0 (MON-334 SR4).
|
|
91
161
|
*/
|
|
92
162
|
interface ILicenseFeature {
|
|
93
|
-
/** Unique
|
|
94
|
-
|
|
163
|
+
/** Unique key identifying the feature (wire field: FeatureKey). */
|
|
164
|
+
featureKey: string;
|
|
95
165
|
}
|
|
96
166
|
/**
|
|
97
167
|
* Rate agreement for subscription-based licenses
|
|
@@ -216,8 +286,25 @@ interface LicensingConfig {
|
|
|
216
286
|
* authorizations remain eligible to be served (flagged isStale) for this long
|
|
217
287
|
* when the licensing service is transiently unreachable. Default 24h; capped
|
|
218
288
|
* at 7 days. Set to 0 to disable stale-serve.
|
|
289
|
+
*
|
|
290
|
+
* Revocation trade-off: stale-serve only ever triggers on transient failures
|
|
291
|
+
* (network/408/429/5xx) and only for signature-validated entries — a denial
|
|
292
|
+
* (401/403/404) is never masked. But during an outage a revoked license can
|
|
293
|
+
* keep authorizing for up to this window past its freshness deadline.
|
|
219
294
|
*/
|
|
220
295
|
staleGraceMs?: number;
|
|
296
|
+
/**
|
|
297
|
+
* Optional: Upper bound in milliseconds on how long a cached authorization
|
|
298
|
+
* stays fresh before the SDK revalidates against the server (MON-334
|
|
299
|
+
* react-09). Default 24h (capped there); the no-expiry default remains 1h.
|
|
300
|
+
*
|
|
301
|
+
* Revocation trade-off: a revoked or downgraded license keeps authorizing
|
|
302
|
+
* from cache until its freshness deadline — revocation latency is
|
|
303
|
+
* min(cacheFreshTtlMs, remaining license window). Tighten this value for
|
|
304
|
+
* faster revocation pickup at the cost of more authorization calls; 0 makes
|
|
305
|
+
* every getAuthorization revalidate.
|
|
306
|
+
*/
|
|
307
|
+
cacheFreshTtlMs?: number;
|
|
221
308
|
/** Optional: Custom context provider for multi-tenant credential resolution */
|
|
222
309
|
contextProvider?: {
|
|
223
310
|
resolveContext(): Promise<{
|
|
@@ -300,6 +387,16 @@ interface LicensingCredential {
|
|
|
300
387
|
* Encodes a licensing credential to a portable string.
|
|
301
388
|
* This matches the .NET LicensingCredential.ToEncodedString() format.
|
|
302
389
|
*
|
|
390
|
+
* SECURITY (MON-334 react-08): the encoded string is base64-OBFUSCATED, not
|
|
391
|
+
* encrypted — it contains the apiAccessKey in recoverable form. Do not store
|
|
392
|
+
* it anywhere page JavaScript can read (localStorage, sessionStorage,
|
|
393
|
+
* non-httpOnly cookies): any XSS on the page reads the credential. For
|
|
394
|
+
* browser apps prefer a backend-held credential with a short-lived token.
|
|
395
|
+
* The SDK itself never writes this value (or the apiAccessKey) to
|
|
396
|
+
* localStorage — it persists only authorization payloads and consumption
|
|
397
|
+
* counters, and the apiAccessKey appears in storage key names only as a
|
|
398
|
+
* non-reversible hash.
|
|
399
|
+
*
|
|
303
400
|
* @param credential The credential to encode
|
|
304
401
|
* @returns A portable encoded string prefixed with SIDUB_LIC_
|
|
305
402
|
*/
|
|
@@ -330,7 +427,7 @@ declare function hasValidCryptoConfig(credential: LicensingCredential | null | u
|
|
|
330
427
|
|
|
331
428
|
/**
|
|
332
429
|
* Extended feature interface that accounts for server response casing variations.
|
|
333
|
-
* The server
|
|
430
|
+
* The server serializes PascalCase (FeatureKey); the SDK model uses camelCase (featureKey).
|
|
334
431
|
*/
|
|
335
432
|
interface ServerFeature extends ILicenseFeature {
|
|
336
433
|
/** Server-side PascalCase feature key */
|
|
@@ -356,7 +453,8 @@ interface ServerFeature extends ILicenseFeature {
|
|
|
356
453
|
}
|
|
357
454
|
/**
|
|
358
455
|
* Gets the normalized feature key from a feature object.
|
|
359
|
-
* Handles both
|
|
456
|
+
* Handles both the SDK model (featureKey) and raw server (FeatureKey) naming.
|
|
457
|
+
* The legacy `featureId` alias was removed in 2.0 (MON-334 SR4).
|
|
360
458
|
*
|
|
361
459
|
* @param feature The feature object to extract the key from
|
|
362
460
|
* @returns The feature key, or empty string if not found
|
|
@@ -364,7 +462,7 @@ interface ServerFeature extends ILicenseFeature {
|
|
|
364
462
|
declare function getFeatureKey(feature: ILicenseFeature | ServerFeature): string;
|
|
365
463
|
/**
|
|
366
464
|
* Checks if a feature matches the specified feature key.
|
|
367
|
-
* Handles both
|
|
465
|
+
* Handles both the SDK model (featureKey) and raw server (FeatureKey) naming.
|
|
368
466
|
*
|
|
369
467
|
* @param feature The feature to check
|
|
370
468
|
* @param featureKey The key to match against
|
|
@@ -390,6 +488,15 @@ declare function hasFeature(features: ILicenseFeature[] | undefined | null, feat
|
|
|
390
488
|
|
|
391
489
|
/**
|
|
392
490
|
* Status of a checkout session.
|
|
491
|
+
*
|
|
492
|
+
* Exactly three values travel the wire. The server holds a fourth internal
|
|
493
|
+
* state, PaymentPending (async bank-debit settlement, MON-191), which it
|
|
494
|
+
* DELIBERATELY surfaces as 'pending' — so 'pending' covers both "session just
|
|
495
|
+
* created, poll again in seconds" and "payment is settling, which can take
|
|
496
|
+
* days". A completed credential may therefore arrive up to 14 days after
|
|
497
|
+
* checkout; keep polling (or re-poll later) rather than treating a prolonged
|
|
498
|
+
* 'pending' as failure. Verified against CheckoutResultService (MON-334
|
|
499
|
+
* align-naming-shape-02).
|
|
393
500
|
*/
|
|
394
501
|
type CheckoutSessionStatus = 'pending' | 'completed' | 'failed';
|
|
395
502
|
/**
|
|
@@ -429,7 +536,14 @@ interface CheckoutSessionResult {
|
|
|
429
536
|
status: CheckoutSessionStatus;
|
|
430
537
|
/** Correlation ID from the original request */
|
|
431
538
|
correlationId?: string;
|
|
432
|
-
/**
|
|
539
|
+
/**
|
|
540
|
+
* Encoded licensing credential (SIDUB_LIC_...) — present when status is 'completed'.
|
|
541
|
+
*
|
|
542
|
+
* SECURITY (MON-334 react-08): this value is base64-obfuscated, NOT encrypted —
|
|
543
|
+
* it contains the tenant's apiAccessKey. Hand it to your backend for storage;
|
|
544
|
+
* do not persist it in localStorage or anywhere page JavaScript (and therefore
|
|
545
|
+
* any XSS) can read it.
|
|
546
|
+
*/
|
|
433
547
|
encodedCredential?: string;
|
|
434
548
|
/** License ID provisioned by checkout — present when status is 'completed' */
|
|
435
549
|
licenseId?: string;
|
|
@@ -498,8 +612,8 @@ declare function normalizeServiceAccessLevel(value: number | string | null | und
|
|
|
498
612
|
* Extends the base feature with service type and access level metadata.
|
|
499
613
|
*/
|
|
500
614
|
interface ServiceAccessLicenseFeature extends ILicenseFeature {
|
|
501
|
-
/** Unique
|
|
502
|
-
|
|
615
|
+
/** Unique key identifying the feature (wire field: FeatureKey). */
|
|
616
|
+
featureKey: string;
|
|
503
617
|
/** Optional service type identifier for finer-grained access control. */
|
|
504
618
|
serviceType?: string;
|
|
505
619
|
/** The access level granted for this feature (Allowed or Denied). */
|
|
@@ -589,8 +703,8 @@ declare class RateLimitFeatureState {
|
|
|
589
703
|
* Extends the base feature with rate limiting metadata and usage counters.
|
|
590
704
|
*/
|
|
591
705
|
interface RateLimitLicenseFeature extends ILicenseFeature {
|
|
592
|
-
/** Unique
|
|
593
|
-
|
|
706
|
+
/** Unique key identifying the feature (wire field: FeatureKey). */
|
|
707
|
+
featureKey: string;
|
|
594
708
|
/** Sliding window duration in seconds for rate limit evaluation. */
|
|
595
709
|
sampleSeconds?: number;
|
|
596
710
|
/** Maximum allowed consumption within the sample window. */
|
|
@@ -765,6 +879,7 @@ declare class LicensingClient {
|
|
|
765
879
|
private readonly disposables;
|
|
766
880
|
private contextResolved;
|
|
767
881
|
private contextResolutionPromise;
|
|
882
|
+
private signaturePostureWarned;
|
|
768
883
|
private readonly inFlightAuthorizations;
|
|
769
884
|
private static readonly METADATA_STORAGE_KEY;
|
|
770
885
|
private static readonly CONSUMPTION_STORAGE_PREFIX;
|
|
@@ -794,6 +909,20 @@ declare class LicensingClient {
|
|
|
794
909
|
* attempt. contextResolved only ever becomes true on success.
|
|
795
910
|
*/
|
|
796
911
|
private ensureContextResolved;
|
|
912
|
+
/**
|
|
913
|
+
* Applies the gateway credential headers to an outgoing request. Mirrors the
|
|
914
|
+
* .NET SDK's GatewayAuthHeaders/GatewayAuthHeaderNames exactly: the ApiAccessKey
|
|
915
|
+
* is sent as the branded `dub-apiKey` header (the gateway's configured
|
|
916
|
+
* subscription-key name) and additionally as the platform-default
|
|
917
|
+
* `Ocp-Apim-Subscription-Key` header, so the SDK keeps authenticating against a
|
|
918
|
+
* gateway provisioned with the Azure default name (the MON-42 → MON-52
|
|
919
|
+
* regression class). The gateway strips the redundant copy before forwarding.
|
|
920
|
+
*
|
|
921
|
+
* Header-only by design (MON-66 parity, MON-334 SR3): the key is never placed
|
|
922
|
+
* in the URL query string, where it would leak into browser history, Referer
|
|
923
|
+
* headers on redirects, and CDN/proxy/gateway access logs.
|
|
924
|
+
*/
|
|
925
|
+
private static applyAuthHeaders;
|
|
797
926
|
/**
|
|
798
927
|
* Builds the cryptography configuration from the resolved config values
|
|
799
928
|
*/
|
|
@@ -802,6 +931,22 @@ declare class LicensingClient {
|
|
|
802
931
|
* Gets whether cryptographic signature validation is enabled
|
|
803
932
|
*/
|
|
804
933
|
get isSignatureValidationEnabled(): boolean;
|
|
934
|
+
/**
|
|
935
|
+
* Makes the signature-validation posture explicit (MON-334 react-03).
|
|
936
|
+
* Runs after context resolution, before any authorization is accepted:
|
|
937
|
+
*
|
|
938
|
+
* - `validateSignatures: true` with no verification key is a contradiction —
|
|
939
|
+
* the integrator demanded validation that cannot happen. Previously this
|
|
940
|
+
* silently skipped; it now throws {@link LicensingConfigurationException}.
|
|
941
|
+
* - Validation silently OFF (no keys configured, `validateSignatures` unset)
|
|
942
|
+
* emits one prominent console warning per client. Setting
|
|
943
|
+
* `validateSignatures: false` explicitly acknowledges unsigned mode and
|
|
944
|
+
* suppresses the warning.
|
|
945
|
+
*
|
|
946
|
+
* Check {@link isSignatureValidationEnabled} at runtime to observe the
|
|
947
|
+
* effective posture.
|
|
948
|
+
*/
|
|
949
|
+
private assertSignaturePosture;
|
|
805
950
|
/**
|
|
806
951
|
* Gets the configured license ID (from credential or explicit config)
|
|
807
952
|
*/
|
|
@@ -839,10 +984,6 @@ declare class LicensingClient {
|
|
|
839
984
|
* server errors (5xx). Denials and client errors (401/403/404/4xx) are not.
|
|
840
985
|
*/
|
|
841
986
|
private static isTransientError;
|
|
842
|
-
/**
|
|
843
|
-
* Parses a Retry-After header value (delta-seconds or HTTP-date) into milliseconds.
|
|
844
|
-
*/
|
|
845
|
-
private static parseRetryAfter;
|
|
846
987
|
/**
|
|
847
988
|
* Retries transient failures with exponential backoff and jitter, honoring
|
|
848
989
|
* Retry-After when the server supplied one. config.timeout is the overall
|
|
@@ -1107,20 +1248,6 @@ interface SignatureValidationResult {
|
|
|
1107
1248
|
/** Error message if validation failed */
|
|
1108
1249
|
error?: string;
|
|
1109
1250
|
}
|
|
1110
|
-
/**
|
|
1111
|
-
* Raw server response for authorization (before client mapping).
|
|
1112
|
-
* Uses PascalCase property names matching the .NET server response.
|
|
1113
|
-
*/
|
|
1114
|
-
interface RawAuthorizationResponse {
|
|
1115
|
-
AuthorizationId: string;
|
|
1116
|
-
LicenseId: string;
|
|
1117
|
-
LicenseClassification: string | number;
|
|
1118
|
-
IssueDate: string;
|
|
1119
|
-
ExpiryDate?: string;
|
|
1120
|
-
Features: unknown[];
|
|
1121
|
-
__sidub_entitySignature?: string;
|
|
1122
|
-
[key: string]: unknown;
|
|
1123
|
-
}
|
|
1124
1251
|
/**
|
|
1125
1252
|
* Result of textually extracting the entity signature member from a raw JSON response.
|
|
1126
1253
|
*/
|
|
@@ -1171,35 +1298,17 @@ declare class SignatureValidator {
|
|
|
1171
1298
|
* Initializes the validator. Must be called before validating signatures.
|
|
1172
1299
|
*/
|
|
1173
1300
|
initialize(): Promise<void>;
|
|
1174
|
-
/**
|
|
1175
|
-
* Validates the signature of a license authorization using a PARSED server response.
|
|
1176
|
-
*
|
|
1177
|
-
* The validation process:
|
|
1178
|
-
* 1. Extracts the signature from __sidub_entitySignature
|
|
1179
|
-
* 2. Re-serializes the raw response data (excluding signature field)
|
|
1180
|
-
* 3. Verifies the signature using the configured public key
|
|
1181
|
-
*
|
|
1182
|
-
* @deprecated Use {@link validateResponseText} instead (MON-205). Step 2 re-serializes an
|
|
1183
|
-
* already-parsed object, and `JSON.stringify` does not round-trip byte-identically —
|
|
1184
|
-
* property order, number formatting and string escaping can each differ from what the
|
|
1185
|
-
* server actually signed, so a genuine authorization can fail verification.
|
|
1186
|
-
* `validateResponseText` verifies the original response bytes and is what
|
|
1187
|
-
* `LicensingClient` now uses; this method is retained only for compatibility.
|
|
1188
|
-
*
|
|
1189
|
-
* @param rawResponse The raw server response (before client mapping)
|
|
1190
|
-
* @param options Validation options
|
|
1191
|
-
* @returns Validation result
|
|
1192
|
-
* @throws {CryptoError} If throwOnInvalid is true and validation fails
|
|
1193
|
-
*/
|
|
1194
|
-
validateRawResponse(rawResponse: RawAuthorizationResponse, options?: SignatureValidationOptions): Promise<SignatureValidationResult>;
|
|
1195
1301
|
/**
|
|
1196
1302
|
* Validates the signature of a license authorization against the exact raw
|
|
1197
1303
|
* response text (MON-205).
|
|
1198
1304
|
*
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1305
|
+
* This is the ONLY validation entry point. The deprecated
|
|
1306
|
+
* `validateRawResponse` — which re-serialized a parsed object and was
|
|
1307
|
+
* therefore sensitive to property-order and formatting differences, letting
|
|
1308
|
+
* genuine authorizations fail verification — was removed in 2.0 (MON-334
|
|
1309
|
+
* react-10). This method verifies against the original bytes: the
|
|
1310
|
+
* `__sidub_entitySignature` member is removed textually and the remaining
|
|
1311
|
+
* text is what the server actually signed.
|
|
1203
1312
|
*
|
|
1204
1313
|
* @param rawText The exact response body text as received from the server.
|
|
1205
1314
|
* @param options Validation options (same required/throwOnInvalid semantics).
|
|
@@ -1207,11 +1316,6 @@ declare class SignatureValidator {
|
|
|
1207
1316
|
* @throws {CryptoError} If throwOnInvalid is true and validation fails
|
|
1208
1317
|
*/
|
|
1209
1318
|
validateResponseText(rawText: string, options?: SignatureValidationOptions): Promise<SignatureValidationResult>;
|
|
1210
|
-
/**
|
|
1211
|
-
* Serializes the raw server response for signature verification.
|
|
1212
|
-
* Removes the __sidub_entitySignature field and serializes to JSON.
|
|
1213
|
-
*/
|
|
1214
|
-
private serializeRawForVerification;
|
|
1215
1319
|
}
|
|
1216
1320
|
|
|
1217
1321
|
/**
|
|
@@ -1235,6 +1339,7 @@ declare class AuthorizationCache {
|
|
|
1235
1339
|
private maxSize;
|
|
1236
1340
|
private storagePrefix;
|
|
1237
1341
|
private graceMs;
|
|
1342
|
+
private freshTtlMs;
|
|
1238
1343
|
private unsubscribe;
|
|
1239
1344
|
/**
|
|
1240
1345
|
* Creates a new authorization cache.
|
|
@@ -1242,8 +1347,12 @@ declare class AuthorizationCache {
|
|
|
1242
1347
|
* @param storagePrefix Optional localStorage key prefix for persisting entries across page refreshes.
|
|
1243
1348
|
* @param graceMs Stale-serve grace window in milliseconds beyond the freshness deadline.
|
|
1244
1349
|
* Defaults to 24h; capped at 7 days.
|
|
1350
|
+
* @param freshTtlMs Upper bound in milliseconds on how long an entry stays fresh
|
|
1351
|
+
* before revalidation (MON-334 react-09). Defaults to 24h (the historical cap);
|
|
1352
|
+
* lower values tighten the revocation window at the cost of more server calls.
|
|
1353
|
+
* Capped at 24h; 0 means every read revalidates.
|
|
1245
1354
|
*/
|
|
1246
|
-
constructor(maxSize?: number, storagePrefix?: string, graceMs?: number);
|
|
1355
|
+
constructor(maxSize?: number, storagePrefix?: string, graceMs?: number, freshTtlMs?: number);
|
|
1247
1356
|
/**
|
|
1248
1357
|
* Builds the composite cache key. The API key is hashed so raw key material
|
|
1249
1358
|
* never appears in localStorage key names.
|
|
@@ -1276,10 +1385,16 @@ declare class AuthorizationCache {
|
|
|
1276
1385
|
* Stores an authorization in the cache.
|
|
1277
1386
|
* Evicts the oldest entry if max size is reached.
|
|
1278
1387
|
*
|
|
1279
|
-
* Freshness is min(license expiry, now +
|
|
1388
|
+
* Freshness is min(license expiry, now + freshTtlMs) — default 1h when the
|
|
1280
1389
|
* authorization has no expiry. The stale window extends freshness by graceMs
|
|
1281
1390
|
* but never past the license's own expiry.
|
|
1282
1391
|
*
|
|
1392
|
+
* Revocation trade-off (MON-334 react-09): a revoked/denied license keeps
|
|
1393
|
+
* authorizing from cache until its freshness deadline — up to freshTtlMs
|
|
1394
|
+
* (default 24h) — plus, on transient outages only, the stale-serve grace.
|
|
1395
|
+
* Tighten freshTtlMs to shrink that window; denials (401/403/404) are never
|
|
1396
|
+
* stale-served.
|
|
1397
|
+
*
|
|
1283
1398
|
* @param licenseId The license identifier.
|
|
1284
1399
|
* @param serviceKeyId The service key identifier.
|
|
1285
1400
|
* @param authorization The license authorization to cache.
|
|
@@ -1318,41 +1433,6 @@ declare class AuthorizationCache {
|
|
|
1318
1433
|
private deserializeEntry;
|
|
1319
1434
|
}
|
|
1320
1435
|
|
|
1321
|
-
/**
|
|
1322
|
-
* Thin localStorage abstraction for persisting SDK state across page refreshes.
|
|
1323
|
-
* All methods are SSR-safe — they no-op when `window`/`localStorage` is unavailable.
|
|
1324
|
-
*
|
|
1325
|
-
* Used by RateLimitFeatureState and AuthorizationCache for transparent persistence.
|
|
1326
|
-
*/
|
|
1327
|
-
/**
|
|
1328
|
-
* Serializes and stores a value under the given key.
|
|
1329
|
-
* No-op in SSR/Node environments.
|
|
1330
|
-
*/
|
|
1331
|
-
declare function save<T>(key: string, data: T): void;
|
|
1332
|
-
/**
|
|
1333
|
-
* Loads and deserializes a value from the given key.
|
|
1334
|
-
* Returns null if the key is missing, the value cannot be parsed, or in SSR.
|
|
1335
|
-
*/
|
|
1336
|
-
declare function load<T>(key: string): T | null;
|
|
1337
|
-
/**
|
|
1338
|
-
* Removes a value from localStorage.
|
|
1339
|
-
* No-op in SSR/Node environments.
|
|
1340
|
-
*/
|
|
1341
|
-
declare function remove(key: string): void;
|
|
1342
|
-
/**
|
|
1343
|
-
* Returns all localStorage keys that start with the given prefix.
|
|
1344
|
-
* Returns an empty array in SSR/Node environments.
|
|
1345
|
-
*/
|
|
1346
|
-
declare function listKeys(prefix: string): string[];
|
|
1347
|
-
/**
|
|
1348
|
-
* Registers a listener for localStorage changes from OTHER tabs.
|
|
1349
|
-
* Filters events by key prefix and calls the callback with the full key and new value.
|
|
1350
|
-
*
|
|
1351
|
-
* Returns an unsubscribe function that removes the listener.
|
|
1352
|
-
* Returns a no-op in SSR/Node environments.
|
|
1353
|
-
*/
|
|
1354
|
-
declare function onStorageChange(prefix: string, callback: (key: string, newValue: string | null) => void): () => void;
|
|
1355
|
-
|
|
1356
1436
|
/**
|
|
1357
1437
|
* Context for providing the LicensingClient to React components
|
|
1358
1438
|
*/
|
|
@@ -1508,5 +1588,5 @@ declare class ConfigurationContextProvider implements ILicensingContextProvider
|
|
|
1508
1588
|
resolveContext(): Promise<LicensingContextType | null>;
|
|
1509
1589
|
}
|
|
1510
1590
|
|
|
1511
|
-
export { AuthorizationCache, BillingIntervalUnit, CompositeAssertion, ConfigurationContextProvider, CryptoError, CryptoService, FeatureExistsAssertion, LicenseAssertion, LicenseClassificationType, LicensingClient, LicensingConfigurationException, LicensingError, LicensingProvider, NotAssertion, RateLimitAssertion, RateLimitError, RateLimitFeatureState, ServiceAccessAssertion, ServiceAccessLevel, SignatureValidator, decodeCredential, encodeCredential, extractEntitySignatureMember, findFeatureByKey, getFeatureKey, hasFeature, hasValidCryptoConfig, licensingContextFromEncodedString, licensingContextToEncodedString,
|
|
1512
|
-
export type { CheckoutRequest, CheckoutSession, CheckoutSessionResult, CheckoutSessionStatus, ClientLicenseConfiguration, ConsumptionView, CryptoConfig, FeatureView, GenerateLicenseAuthorizationParameters, ILicenseAssertion, ILicenseFeature, ILicensingContextProvider, License, LicenseAuthorization, LicenseFeatureStateOperation, LicenseStateView, LicensingConfig, LicensingContextType, LicensingCredential, LicensingProviderProps, RateAgreement, RateLimitLicenseFeature,
|
|
1591
|
+
export { AuthorizationCache, BillingIntervalUnit, CompositeAssertion, ConfigurationContextProvider, CryptoError, CryptoService, FeatureExistsAssertion, LicenseAssertion, LicenseClassificationType, LicensingClient, LicensingConfigurationException, LicensingError, LicensingProvider, NotAssertion, RateLimitAssertion, RateLimitError, RateLimitFeatureState, ServiceAccessAssertion, ServiceAccessLevel, SignatureValidator, decodeCredential, encodeCredential, extractEntitySignatureMember, findFeatureByKey, getFeatureKey, hasFeature, hasValidCryptoConfig, licensingContextFromEncodedString, licensingContextToEncodedString, matchesFeatureKey, normalizeBillingIntervalUnit, normalizeLicenseClassificationType, normalizeServiceAccessLevel, tryDecodeCredential, useLicensingContext, useLicensingContextValue };
|
|
1592
|
+
export type { ApiErrorDetail, CheckoutRequest, CheckoutSession, CheckoutSessionResult, CheckoutSessionStatus, ClientLicenseConfiguration, ConsumptionView, CryptoConfig, FeatureView, GenerateLicenseAuthorizationParameters, ILicenseAssertion, ILicenseFeature, ILicensingContextProvider, License, LicenseAuthorization, LicenseFeatureStateOperation, LicenseStateView, LicensingConfig, LicensingContextType, LicensingCredential, LicensingProviderProps, RateAgreement, RateLimitLicenseFeature, ServerFeature, ServiceAccessLicenseFeature, SignatureMemberExtraction, SignatureValidationOptions, SignatureValidationResult };
|