@tinycloud/sdk-core 3.0.0-beta.14 → 3.0.0-beta.15
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/index.cjs +16 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -16
- package/dist/index.d.ts +7 -16
- package/dist/index.js +11 -25
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -127,6 +127,7 @@ __export(index_exports, {
|
|
|
127
127
|
LOCAL_LINK_PROBE_TIMEOUT_MS: () => LOCAL_LINK_PROBE_TIMEOUT_MS,
|
|
128
128
|
LOCAL_LOOPBACK_PROBE_TIMEOUT_MS: () => LOCAL_LOOPBACK_PROBE_TIMEOUT_MS,
|
|
129
129
|
LocationRecordValidationError: () => LocationRecordValidationError,
|
|
130
|
+
LocationRegistryHttpError: () => LocationRegistryHttpError,
|
|
130
131
|
MAX_CONTENT_BYTES: () => MAX_CONTENT_BYTES,
|
|
131
132
|
MAX_LEGACY_ENVELOPE_EXPIRES_AT: () => MAX_LEGACY_ENVELOPE_EXPIRES_AT,
|
|
132
133
|
MAX_SEALED_SHARE_CONTENT_BYTES: () => MAX_SEALED_SHARE_CONTENT_BYTES,
|
|
@@ -246,10 +247,10 @@ __export(index_exports, {
|
|
|
246
247
|
buildPolicyCredentialPresentationV4: () => buildPolicyCredentialPresentationV4,
|
|
247
248
|
buildSpaceUri: () => buildSpaceUri,
|
|
248
249
|
canonicalDigest: () => canonicalDigest,
|
|
249
|
-
canonicalEmailDomain: () => canonicalEmailDomain,
|
|
250
|
+
canonicalEmailDomain: () => import_share_envelope.canonicalEmailDomain,
|
|
250
251
|
canonicalHashHex: () => import_sdk_services8.canonicalHashHex,
|
|
251
252
|
canonicalLocationPayload: () => canonicalLocationPayload,
|
|
252
|
-
canonicalMailbox: () => canonicalMailbox,
|
|
253
|
+
canonicalMailbox: () => import_share_envelope.canonicalMailbox,
|
|
253
254
|
canonicalOwnerSharePolicy: () => canonicalOwnerSharePolicy,
|
|
254
255
|
canonicalSignedResponse: () => import_sdk_services8.canonicalSignedResponse,
|
|
255
256
|
canonicalizeAddress: () => canonicalizeAddress,
|
|
@@ -350,7 +351,7 @@ __export(index_exports, {
|
|
|
350
351
|
importPortableDelegation: () => importPortableDelegation,
|
|
351
352
|
installTinyCloudDebugGlobals: () => import_sdk_services8.installTinyCloudDebugGlobals,
|
|
352
353
|
intersectShareCapabilities: () => intersectShareCapabilities,
|
|
353
|
-
isCanonicalEmailDomain: () => isCanonicalEmailDomain,
|
|
354
|
+
isCanonicalEmailDomain: () => import_share_envelope.isCanonicalEmailDomain,
|
|
354
355
|
isCapabilitySubset: () => isCapabilitySubset,
|
|
355
356
|
isDigest: () => isDigest,
|
|
356
357
|
isEvmAddress: () => isEvmAddress,
|
|
@@ -361,7 +362,7 @@ __export(index_exports, {
|
|
|
361
362
|
jcsCanonicalize: () => jcsCanonicalize,
|
|
362
363
|
loadManifest: () => loadManifest,
|
|
363
364
|
locationPayloadForRecord: () => locationPayloadForRecord,
|
|
364
|
-
mailboxBelongsToDomain: () => mailboxBelongsToDomain,
|
|
365
|
+
mailboxBelongsToDomain: () => import_share_envelope.mailboxBelongsToDomain,
|
|
365
366
|
makePkhSpaceId: () => makePkhSpaceId,
|
|
366
367
|
makePublicSpaceId: () => makePublicSpaceId,
|
|
367
368
|
manifestAbilitiesUnion: () => manifestAbilitiesUnion,
|
|
@@ -1030,29 +1031,7 @@ function isDigest(value) {
|
|
|
1030
1031
|
}
|
|
1031
1032
|
|
|
1032
1033
|
// src/credentials/email-domain.ts
|
|
1033
|
-
var
|
|
1034
|
-
function isCanonicalEmailDomain(value) {
|
|
1035
|
-
if (value.length === 0 || value.length > 253) return false;
|
|
1036
|
-
const labels = value.split(".");
|
|
1037
|
-
return labels.length >= 2 && labels.every((label) => LABEL.test(label)) && !/^[0-9]+$/.test(labels.at(-1));
|
|
1038
|
-
}
|
|
1039
|
-
function canonicalEmailDomain(value) {
|
|
1040
|
-
const domain = value.trim().replace(/^@/, "").toLowerCase();
|
|
1041
|
-
if (!/^[\x21-\x7e]+$/.test(domain) || !isCanonicalEmailDomain(domain)) throw new TypeError("email domain must be lowercase ASCII DNS labels (use the xn-- form for international domains)");
|
|
1042
|
-
return domain;
|
|
1043
|
-
}
|
|
1044
|
-
function canonicalMailbox(value) {
|
|
1045
|
-
const email = value.trim().toLowerCase();
|
|
1046
|
-
const at = email.indexOf("@");
|
|
1047
|
-
if (at <= 0 || at !== email.lastIndexOf("@")) return void 0;
|
|
1048
|
-
const local = email.slice(0, at);
|
|
1049
|
-
const domain = email.slice(at + 1);
|
|
1050
|
-
if (local.length > 64 || !/^[a-z0-9#$&'*+/=?^_`{|}~-]+(?:\.[a-z0-9#$&'*+/=?^_`{|}~-]+)*$/.test(local) || !isCanonicalEmailDomain(domain)) return void 0;
|
|
1051
|
-
return Object.freeze({ email, domain });
|
|
1052
|
-
}
|
|
1053
|
-
function mailboxBelongsToDomain(mailbox, domain) {
|
|
1054
|
-
return canonicalMailbox(mailbox)?.domain === domain && isCanonicalEmailDomain(domain);
|
|
1055
|
-
}
|
|
1034
|
+
var import_share_envelope = require("@tinycloud/share-envelope");
|
|
1056
1035
|
|
|
1057
1036
|
// src/credentials/requirement.ts
|
|
1058
1037
|
var ID2 = /^[a-z0-9][a-z0-9._-]{0,127}(?:\/v1)?$/;
|
|
@@ -1070,7 +1049,7 @@ function createEmailCredentialRequirement(input) {
|
|
|
1070
1049
|
});
|
|
1071
1050
|
}
|
|
1072
1051
|
function createEmailDomainCredentialRequirement(input) {
|
|
1073
|
-
if (!isCanonicalEmailDomain(input.domain)) throw new CredentialError("UNSUPPORTED_PROFILE", "Email domain is not canonical");
|
|
1052
|
+
if (!(0, import_share_envelope.isCanonicalEmailDomain)(input.domain)) throw new CredentialError("UNSUPPORTED_PROFILE", "Email domain is not canonical");
|
|
1074
1053
|
return validateCredentialRequirement({
|
|
1075
1054
|
type: "TinyCloudCredentialRequirement",
|
|
1076
1055
|
version: 1,
|
|
@@ -18002,6 +17981,13 @@ var LocationRecordValidationError = class extends Error {
|
|
|
18002
17981
|
this.name = "LocationRecordValidationError";
|
|
18003
17982
|
}
|
|
18004
17983
|
};
|
|
17984
|
+
var LocationRegistryHttpError = class extends Error {
|
|
17985
|
+
constructor(message, status) {
|
|
17986
|
+
super(message);
|
|
17987
|
+
this.status = status;
|
|
17988
|
+
this.name = "LocationRegistryHttpError";
|
|
17989
|
+
}
|
|
17990
|
+
};
|
|
18005
17991
|
var CloudLocationResolutionError = class extends Error {
|
|
18006
17992
|
constructor(subject, attempts) {
|
|
18007
17993
|
super(`Unable to resolve TinyCloud location for ${subject}`);
|
|
@@ -18095,7 +18081,7 @@ async function fetchLocationRecord(registryUrl, subject, fetchFn = globalThis.fe
|
|
|
18095
18081
|
return null;
|
|
18096
18082
|
}
|
|
18097
18083
|
if (!response.ok) {
|
|
18098
|
-
throw new
|
|
18084
|
+
throw new LocationRegistryHttpError(`location registry returned HTTP ${response.status}`, response.status);
|
|
18099
18085
|
}
|
|
18100
18086
|
const text2 = await boundedResponseText(response, "location registry", 64 * 1024);
|
|
18101
18087
|
let body;
|
|
@@ -18140,7 +18126,7 @@ async function publishLocationRecord(options2) {
|
|
|
18140
18126
|
}
|
|
18141
18127
|
);
|
|
18142
18128
|
if (!response.ok) {
|
|
18143
|
-
throw new
|
|
18129
|
+
throw new LocationRegistryHttpError(`location registry publish returned HTTP ${response.status}`, response.status);
|
|
18144
18130
|
}
|
|
18145
18131
|
const text2 = await boundedResponseText(response, "location registry", 64 * 1024);
|
|
18146
18132
|
let body;
|