@lessly/sdk-app 93.0.0 → 94.1.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/CHANGELOG.md +15 -11
- package/dist/_types/index.d.ts +1 -1
- package/dist/_types/runtime/errors.d.ts +13 -0
- package/dist/index.cjs +23 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/recipes/entitlements.md +96 -0
- package/docs/recipes/sdk-usage.md +5 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,6 +31,27 @@ function isAccessDenied(err) {
|
|
|
31
31
|
const { status, code } = err;
|
|
32
32
|
return status === 403 && typeof code === "string" && ACCESS_DENIED_CODES.has(code);
|
|
33
33
|
}
|
|
34
|
+
var ENTITLEMENT_ERRORS = /* @__PURE__ */ new Set(["entitlement_exhausted", "entitlement_unavailable"]);
|
|
35
|
+
function entitlementRefusal(err) {
|
|
36
|
+
if (typeof err !== "object" || err === null) return null;
|
|
37
|
+
const { status, body } = err;
|
|
38
|
+
if (status !== 402 || typeof body !== "object" || body === null) return null;
|
|
39
|
+
const { error } = body;
|
|
40
|
+
return typeof error === "string" && ENTITLEMENT_ERRORS.has(error) ? body : null;
|
|
41
|
+
}
|
|
42
|
+
function isEntitlementError(err) {
|
|
43
|
+
return entitlementRefusal(err) !== null;
|
|
44
|
+
}
|
|
45
|
+
function upgradeUrl(err) {
|
|
46
|
+
const url = entitlementRefusal(err)?.upgrade_url;
|
|
47
|
+
if (typeof url !== "string") return null;
|
|
48
|
+
try {
|
|
49
|
+
const { protocol } = new URL(url);
|
|
50
|
+
return protocol === "https:" || protocol === "http:" ? url : null;
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
34
55
|
|
|
35
56
|
// src/runtime/csrf.ts
|
|
36
57
|
var CSRF_COOKIES = ["lepsto_csrf", "lessly_csrf"];
|
|
@@ -12732,6 +12753,6 @@ var operations2 = operations;
|
|
|
12732
12753
|
// src/runtime/compositions.ts
|
|
12733
12754
|
var compositions2 = compositions;
|
|
12734
12755
|
|
|
12735
|
-
export { LesslyApiError, accessReason, compositions2 as compositions, connectStream, createLesslyApp, isAccessDenied, operations2 as operations, platformApiBaseUrl };
|
|
12756
|
+
export { LesslyApiError, accessReason, compositions2 as compositions, connectStream, createLesslyApp, isAccessDenied, isEntitlementError, operations2 as operations, platformApiBaseUrl, upgradeUrl };
|
|
12736
12757
|
//# sourceMappingURL=index.js.map
|
|
12737
12758
|
//# sourceMappingURL=index.js.map
|