@mdbase-dev/sdk 0.2.77 → 0.2.79
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/app-grant/client.js +42 -22
- package/dist/app-grant/client.js.map +1 -1
- package/dist/app-host/web-sign-in-session.js +3 -3
- package/dist/app-host/web-sign-in-session.js.map +1 -1
- package/dist/application/collection-selection.d.ts +2 -2
- package/dist/application/collection-selection.js +11 -6
- package/dist/application/collection-selection.js.map +1 -1
- package/dist/application/entry.d.ts +2 -2
- package/dist/application/entry.js +12 -4
- package/dist/application/entry.js.map +1 -1
- package/dist/application/phase.js +4 -0
- package/dist/application/phase.js.map +1 -1
- package/dist/application/private-collections.d.ts +4 -7
- package/dist/application/private-collections.js +41 -20
- package/dist/application/private-collections.js.map +1 -1
- package/dist/application/return-url.d.ts +3 -0
- package/dist/application/return-url.js +21 -0
- package/dist/application/return-url.js.map +1 -1
- package/dist/application/worker.js +26 -21
- package/dist/browser/mdbase-sdk.js +170 -100
- package/dist/browser/mdbase-sdk.min.js +60 -60
- package/dist/describe-error.d.ts +1 -1
- package/dist/describe-error.js +2 -1
- package/dist/describe-error.js.map +1 -1
- package/dist/native/provenance.json +1 -1
- package/node_modules/@mdbase-dev/connect-protocol/dist/application-authorization.js +6 -9
- package/node_modules/@mdbase-dev/connect-protocol/dist/manifest.js +35 -24
- package/node_modules/@mdbase-dev/connect-protocol/dist/mutation-fingerprint.js +4 -12
- package/package.json +2 -2
- package/vendor/mdbase-connect-sdk-9b36f55c7774.json +13 -0
- package/vendor/mdbase-dev-connect-protocol-0.1.0-beta.152-9b36f55c7774.tgz +0 -0
- package/vendor/mdbase-connect-sdk-3d3f95b80c9a.json +0 -13
- package/vendor/mdbase-dev-connect-protocol-0.1.0-beta.152-3d3f95b80c9a.tgz +0 -0
|
@@ -9890,6 +9890,7 @@ var MdbaseSDK = (() => {
|
|
|
9890
9890
|
"refused",
|
|
9891
9891
|
"expired",
|
|
9892
9892
|
"approval_window_closed",
|
|
9893
|
+
"private_authorization_failed",
|
|
9893
9894
|
"account_confirmation_required",
|
|
9894
9895
|
"recovery_required",
|
|
9895
9896
|
"installation_removed",
|
|
@@ -10030,6 +10031,7 @@ var MdbaseSDK = (() => {
|
|
|
10030
10031
|
installation_removed: ["This app's access was removed", "Sign out of this app on this device, then sign in to approve a new installation.", "none", "warning"],
|
|
10031
10032
|
expired: ["Sign-in timed out", "The sign-in request expired. Start again to get a new one.", "sign_in", "warning"],
|
|
10032
10033
|
approval_window_closed: ["Sign-in wasn't finished", "The mdbase window was closed before access was approved. Sign in again to continue.", "sign_in", "info"],
|
|
10034
|
+
private_authorization_failed: ["Couldn't prepare Private collection access", "This app couldn't prepare its authorization request. Check for an app update and start sign-in again.", "update_app", "warning"],
|
|
10033
10035
|
account_confirmation_required: ["Confirm your account", "Confirm which mdbase account to use, then continue.", "sign_in", "info"],
|
|
10034
10036
|
recovery_account_mismatch: ["Use a different account", "Sign in with the account you originally used for this collection to continue.", "approve", "info", false, "Use a different account"],
|
|
10035
10037
|
recovery_required: ["Reload required", "The app stopped to keep your data safe. Reload to continue.", "reload", "error"],
|
|
@@ -25030,10 +25032,11 @@ ${end.comment}` : end.comment;
|
|
|
25030
25032
|
});
|
|
25031
25033
|
|
|
25032
25034
|
// node_modules/@mdbase-dev/connect-protocol/dist/mutation-fingerprint.js
|
|
25033
|
-
var encoder;
|
|
25035
|
+
var encoder, isWellFormed2;
|
|
25034
25036
|
var init_mutation_fingerprint = __esm({
|
|
25035
25037
|
"node_modules/@mdbase-dev/connect-protocol/dist/mutation-fingerprint.js"() {
|
|
25036
25038
|
encoder = new TextEncoder();
|
|
25039
|
+
({ isWellFormed: isWellFormed2 } = String.prototype);
|
|
25037
25040
|
}
|
|
25038
25041
|
});
|
|
25039
25042
|
|
|
@@ -25195,10 +25198,13 @@ ${end.comment}` : end.comment;
|
|
|
25195
25198
|
throw new Error("Invalid base64url value.");
|
|
25196
25199
|
const normalized = value2.replaceAll("-", "+").replaceAll("_", "/");
|
|
25197
25200
|
const padded = normalized.padEnd(Math.ceil(normalized.length / 4) * 4, "=");
|
|
25198
|
-
const
|
|
25199
|
-
if (
|
|
25201
|
+
const binary2 = atob(padded);
|
|
25202
|
+
if (btoa(binary2) !== padded)
|
|
25200
25203
|
throw new Error("Non-canonical base64url value.");
|
|
25201
|
-
|
|
25204
|
+
const bytes10 = new Uint8Array(binary2.length);
|
|
25205
|
+
for (let index = 0; index < binary2.length; index++)
|
|
25206
|
+
bytes10[index] = binary2.charCodeAt(index);
|
|
25207
|
+
return bytes10;
|
|
25202
25208
|
}
|
|
25203
25209
|
function uuidBytes(value2) {
|
|
25204
25210
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(value2)) {
|
|
@@ -25230,9 +25236,6 @@ ${end.comment}` : end.comment;
|
|
|
25230
25236
|
}
|
|
25231
25237
|
return output;
|
|
25232
25238
|
}
|
|
25233
|
-
function base64Url(value2) {
|
|
25234
|
-
return btoa(String.fromCharCode(...value2)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
25235
|
-
}
|
|
25236
25239
|
function equalBytes(left, right) {
|
|
25237
25240
|
return left.byteLength === right.byteLength && left.every((value2, index) => value2 === right[index]);
|
|
25238
25241
|
}
|
|
@@ -25406,36 +25409,40 @@ ${end.comment}` : end.comment;
|
|
|
25406
25409
|
return `${parent}/${escaped}`;
|
|
25407
25410
|
}
|
|
25408
25411
|
function validateSerializedSize(value2, maxBytes2) {
|
|
25409
|
-
const jsonIssue = validateJsonValue(value2,
|
|
25412
|
+
const jsonIssue = validateJsonValue(value2, /* @__PURE__ */ new WeakSet());
|
|
25410
25413
|
if (jsonIssue)
|
|
25411
|
-
return jsonIssue;
|
|
25414
|
+
return { ...jsonIssue, path: jsonIssue.path || "/" };
|
|
25412
25415
|
try {
|
|
25413
25416
|
const serialized = JSON.stringify(value2);
|
|
25417
|
+
if (serialized.length * 3 <= maxBytes2)
|
|
25418
|
+
return void 0;
|
|
25414
25419
|
const bytes10 = new TextEncoder().encode(serialized).byteLength;
|
|
25415
25420
|
return bytes10 <= maxBytes2 ? void 0 : issue2("/", "maxBytes", `must not exceed ${maxBytes2} UTF-8 bytes`, { maxBytes: maxBytes2, actualBytes: bytes10 });
|
|
25416
25421
|
} catch {
|
|
25417
25422
|
return issue2("/", "json", "must be serializable as JSON");
|
|
25418
25423
|
}
|
|
25419
25424
|
}
|
|
25420
|
-
function validateJsonValue(value2,
|
|
25425
|
+
function validateJsonValue(value2, ancestors) {
|
|
25421
25426
|
if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2))
|
|
25422
25427
|
return void 0;
|
|
25423
25428
|
if (typeof value2 !== "object") {
|
|
25424
|
-
return issue2(
|
|
25429
|
+
return issue2("", "json", "must be a JSON value");
|
|
25425
25430
|
}
|
|
25426
25431
|
if (ancestors.has(value2)) {
|
|
25427
|
-
return issue2(
|
|
25432
|
+
return issue2("", "json", "must not contain circular references");
|
|
25428
25433
|
}
|
|
25429
25434
|
const prototype = Object.getPrototypeOf(value2);
|
|
25430
25435
|
if (!Array.isArray(value2) && prototype !== Object.prototype && prototype !== null) {
|
|
25431
|
-
return issue2(
|
|
25436
|
+
return issue2("", "json", "must be a plain JSON object");
|
|
25432
25437
|
}
|
|
25433
25438
|
ancestors.add(value2);
|
|
25434
|
-
const entries = Array.isArray(value2) ?
|
|
25439
|
+
const entries = Array.isArray(value2) ? Array.prototype.entries.call(value2) : Object.entries(value2);
|
|
25435
25440
|
for (const [key3, child] of entries) {
|
|
25436
|
-
const childIssue = validateJsonValue(child,
|
|
25437
|
-
if (childIssue)
|
|
25441
|
+
const childIssue = validateJsonValue(child, ancestors);
|
|
25442
|
+
if (childIssue) {
|
|
25443
|
+
childIssue.path = joinPointer("", String(key3)) + childIssue.path;
|
|
25438
25444
|
return childIssue;
|
|
25445
|
+
}
|
|
25439
25446
|
}
|
|
25440
25447
|
ancestors.delete(value2);
|
|
25441
25448
|
return void 0;
|
|
@@ -25498,7 +25505,11 @@ ${end.comment}` : end.comment;
|
|
|
25498
25505
|
return [issue2(`/redirect_uris/${index}`, "protocol", "must use HTTPS (or loopback HTTP in local mode)")];
|
|
25499
25506
|
}
|
|
25500
25507
|
const nativeAllowed = nativeRedirectMatchesApplication(url2, String(manifest.id));
|
|
25501
|
-
|
|
25508
|
+
const mobileAllowed = !native && url2.protocol === "capacitor:" && !url2.username && !url2.password && !url2.port && !url2.search && !url2.hash && url2.href === redirect && Object.values(asObject(manifest.installation_origins)).some((policy) => {
|
|
25509
|
+
const mobile = asObject(policy).mobile;
|
|
25510
|
+
return Array.isArray(mobile) && mobile.includes(`capacitor://${url2.hostname}`);
|
|
25511
|
+
});
|
|
25512
|
+
if (url2.origin !== homepage.origin && !nativeAllowed && !mobileAllowed) {
|
|
25502
25513
|
return [issue2(`/redirect_uris/${index}`, "origin", "must use the homepage origin or a private-use scheme matching the application ID")];
|
|
25503
25514
|
}
|
|
25504
25515
|
}
|
|
@@ -25670,23 +25681,20 @@ ${end.comment}` : end.comment;
|
|
|
25670
25681
|
if (path === RECORD_EXTENSIONS_CONFIGURATION_PATH) {
|
|
25671
25682
|
return APPLICATION_RECORD_EXTENSIONS.includes(value2) ? void 0 : "accepts only the record extensions md and base";
|
|
25672
25683
|
}
|
|
25673
|
-
if (!path.startsWith("/") || new TextEncoder().encode(path).byteLength > 1024) {
|
|
25684
|
+
if (!path.startsWith("/") || path.length * 3 > 1024 && new TextEncoder().encode(path).byteLength > 1024) {
|
|
25674
25685
|
return "must be a bounded RFC 6901 JSON pointer";
|
|
25675
25686
|
}
|
|
25676
25687
|
const encoded = path.slice(1).split("/");
|
|
25677
25688
|
if (encoded.length < 2 || encoded.length > 16) {
|
|
25678
25689
|
return "must address a value below an x-* extension namespace";
|
|
25679
25690
|
}
|
|
25680
|
-
const
|
|
25681
|
-
|
|
25682
|
-
if (/~(?:[^01]|$)/u.test(value3))
|
|
25691
|
+
for (const segment2 of encoded) {
|
|
25692
|
+
if (/~(?:[^01]|$)/u.test(segment2))
|
|
25683
25693
|
return "contains an invalid RFC 6901 escape";
|
|
25684
|
-
|
|
25685
|
-
if (segment2.length === 0 || segment2 === "-" || /^\d+$/u.test(segment2) || [...segment2].some((character) => /\p{Cc}/u.test(character)))
|
|
25694
|
+
if (segment2.length === 0 || segment2 === "-" || /^\d+$/u.test(segment2) || /\p{Cc}/u.test(segment2))
|
|
25686
25695
|
return "contains a disallowed object-key segment";
|
|
25687
|
-
segments.push(segment2);
|
|
25688
25696
|
}
|
|
25689
|
-
return /^x-[a-z0-9][a-z0-9-]*$/u.test(
|
|
25697
|
+
return /^x-[a-z0-9][a-z0-9-]*$/u.test(encoded[0]) ? void 0 : "must be inside a top-level x-* extension namespace";
|
|
25690
25698
|
}
|
|
25691
25699
|
function validateCapabilityRequirements(value2) {
|
|
25692
25700
|
const manifest = asObject(value2);
|
|
@@ -26084,6 +26092,54 @@ ${end.comment}` : end.comment;
|
|
|
26084
26092
|
}
|
|
26085
26093
|
});
|
|
26086
26094
|
|
|
26095
|
+
// src/application/return-url.ts
|
|
26096
|
+
function declaredReturnUrl(value2, manifest) {
|
|
26097
|
+
if (typeof value2 !== "string" || !value2 || value2.length > 2048 || value2.includes("*")) return false;
|
|
26098
|
+
const declared = manifest && typeof manifest === "object" ? manifest.redirect_uris : void 0;
|
|
26099
|
+
if (!Array.isArray(declared) || !declared.includes(value2)) return false;
|
|
26100
|
+
const { id: id6, homepage } = manifest;
|
|
26101
|
+
let url2;
|
|
26102
|
+
try {
|
|
26103
|
+
url2 = new URL(value2);
|
|
26104
|
+
} catch {
|
|
26105
|
+
return false;
|
|
26106
|
+
}
|
|
26107
|
+
if (url2.username || url2.password || url2.hash) return false;
|
|
26108
|
+
if (url2.protocol === "https:" || url2.protocol === "http:") {
|
|
26109
|
+
let home;
|
|
26110
|
+
try {
|
|
26111
|
+
home = new URL(String(homepage));
|
|
26112
|
+
} catch {
|
|
26113
|
+
return false;
|
|
26114
|
+
}
|
|
26115
|
+
return url2.origin === home.origin && (url2.protocol === "https:" || loopbackHttpOrigin(url2.origin));
|
|
26116
|
+
}
|
|
26117
|
+
const scheme = url2.protocol.slice(0, -1);
|
|
26118
|
+
return typeof id6 === "string" && scheme.includes(".") && /^[a-z][a-z0-9+.-]*$/.test(scheme) && !RESERVED.includes(scheme) && (scheme === id6 || scheme.startsWith(`${id6}.`)) && url2.hostname.length > 0;
|
|
26119
|
+
}
|
|
26120
|
+
function mobileGrantReturnUrl(value2, origin4, manifest) {
|
|
26121
|
+
if (!origin4.startsWith("capacitor://")) return false;
|
|
26122
|
+
const redirects = manifest?.redirect_uris;
|
|
26123
|
+
if (!Array.isArray(redirects) || !redirects.includes(value2) || value2.includes("*")) return false;
|
|
26124
|
+
let url2;
|
|
26125
|
+
try {
|
|
26126
|
+
url2 = new URL(value2);
|
|
26127
|
+
} catch {
|
|
26128
|
+
return false;
|
|
26129
|
+
}
|
|
26130
|
+
if (url2.href !== value2 || url2.username || url2.password || url2.search || url2.hash) return false;
|
|
26131
|
+
if (url2.protocol === "capacitor:") return `capacitor://${url2.host}` === origin4;
|
|
26132
|
+
return url2.protocol !== "http:" && url2.protocol !== "https:" && declaredReturnUrl(value2, manifest);
|
|
26133
|
+
}
|
|
26134
|
+
var RESERVED;
|
|
26135
|
+
var init_return_url = __esm({
|
|
26136
|
+
"src/application/return-url.ts"() {
|
|
26137
|
+
"use strict";
|
|
26138
|
+
init_local_build2();
|
|
26139
|
+
RESERVED = ["http", "https", "file", "javascript", "data", "blob", "about", "capacitor", "chrome-extension", "moz-extension"];
|
|
26140
|
+
}
|
|
26141
|
+
});
|
|
26142
|
+
|
|
26087
26143
|
// src/app-host/app-environment.ts
|
|
26088
26144
|
function origin(value2, loopbackAllowed) {
|
|
26089
26145
|
if (typeof value2 !== "string" || !value2.length) throw invalid6();
|
|
@@ -38419,6 +38475,8 @@ ${end.comment}` : end.comment;
|
|
|
38419
38475
|
"src/app-grant/client.ts"() {
|
|
38420
38476
|
"use strict";
|
|
38421
38477
|
init_dist2();
|
|
38478
|
+
init_return_url();
|
|
38479
|
+
init_app_origin();
|
|
38422
38480
|
init_app_environment();
|
|
38423
38481
|
init_declaration();
|
|
38424
38482
|
init_storage_scope();
|
|
@@ -38483,8 +38541,9 @@ ${end.comment}` : end.comment;
|
|
|
38483
38541
|
} catch {
|
|
38484
38542
|
throw mdbaseError("invalid_request", "redirectUri must be an absolute URL", "redirect_uri");
|
|
38485
38543
|
}
|
|
38486
|
-
|
|
38487
|
-
|
|
38544
|
+
const validRedirect = this.declaration.origin.startsWith("capacitor://") ? mobileGrantReturnUrl(options.redirectUri, this.declaration.origin, this.declaration.manifest) : this.redirect.protocol === new URL(this.declaration.origin).protocol && this.redirect.origin === this.declaration.origin && !this.redirect.hash;
|
|
38545
|
+
if (!validRedirect) {
|
|
38546
|
+
throw mdbaseError("invalid_request", "redirectUri must be a valid callback for this app", "redirect_uri");
|
|
38488
38547
|
}
|
|
38489
38548
|
this.fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
38490
38549
|
this.callbacks = options.callbacks ?? broadcastCallbacks();
|
|
@@ -38702,7 +38761,7 @@ ${end.comment}` : end.comment;
|
|
|
38702
38761
|
declarationId: binding2.application_declaration_id,
|
|
38703
38762
|
manifestDigest: registration.manifestDigest,
|
|
38704
38763
|
applicationInstallationId: binding2.application_installation_id,
|
|
38705
|
-
applicationOrigin: this.
|
|
38764
|
+
applicationOrigin: this.declaration.origin,
|
|
38706
38765
|
collectionId: collection2,
|
|
38707
38766
|
grantSigningPublicKey: grantSigning.publicKey,
|
|
38708
38767
|
clientNoisePublicKey: b64u(noise.publicKey)
|
|
@@ -38736,7 +38795,7 @@ ${end.comment}` : end.comment;
|
|
|
38736
38795
|
} catch {
|
|
38737
38796
|
return;
|
|
38738
38797
|
}
|
|
38739
|
-
if (url2
|
|
38798
|
+
if (urlOrigin(url2) !== urlOrigin(this.redirect) || url2.username || url2.password || url2.hash || url2.pathname !== this.redirect.pathname || url2.searchParams.get("state") !== state2) return;
|
|
38740
38799
|
const error5 = url2.searchParams.get("error");
|
|
38741
38800
|
if (error5) return finish(() => reject(mdbaseError("forbidden", "access was not approved", "authorization_denied")));
|
|
38742
38801
|
const code = url2.searchParams.get("code");
|
|
@@ -38765,7 +38824,7 @@ ${end.comment}` : end.comment;
|
|
|
38765
38824
|
async saveTokens(res, from) {
|
|
38766
38825
|
const b = res.body;
|
|
38767
38826
|
if (res.status !== 200 || !b) {
|
|
38768
|
-
if (res.status === 400 && b &&
|
|
38827
|
+
if (res.status === 400 && b && (b.error === "invalid_grant" || fieldOf(b.error, "code") === "invalid_grant")) {
|
|
38769
38828
|
throw mdbaseError("unauthenticated", "the grant is no longer valid", "grant_invalid");
|
|
38770
38829
|
}
|
|
38771
38830
|
if (res.status === 400) throw collectionUnavailableError("sync_required");
|
|
@@ -38925,31 +38984,42 @@ ${end.comment}` : end.comment;
|
|
|
38925
38984
|
if (options.bindings === void 0 || options.bindings.some((c) => c.collection_id === record5.collection && c.application_origin === this.declaration.origin && b64u(record5.noisePublicKey) === c.client_noise_public_key)) local.push(record5);
|
|
38926
38985
|
}
|
|
38927
38986
|
const held = new Set(local.map((g) => g.collection));
|
|
38928
|
-
|
|
38929
|
-
|
|
38930
|
-
|
|
38931
|
-
|
|
38932
|
-
|
|
38933
|
-
|
|
38934
|
-
|
|
38935
|
-
|
|
38936
|
-
|
|
38937
|
-
|
|
38938
|
-
|
|
38939
|
-
|
|
38987
|
+
const denied = /* @__PURE__ */ new Set();
|
|
38988
|
+
grants: for (const grant of local) {
|
|
38989
|
+
let res;
|
|
38990
|
+
for (let attempt = 0; ; attempt++) {
|
|
38991
|
+
let token;
|
|
38992
|
+
try {
|
|
38993
|
+
token = await this.accessToken(grant.collection);
|
|
38994
|
+
} catch (e) {
|
|
38995
|
+
if (isMdbaseError(e, "unauthenticated") && e.reason === "grant_invalid") {
|
|
38996
|
+
denied.add(grant.collection);
|
|
38997
|
+
continue grants;
|
|
38998
|
+
}
|
|
38999
|
+
if (isMdbaseError(e, "forbidden") && e.reason === "sync_required") continue grants;
|
|
39000
|
+
throw e;
|
|
39001
|
+
}
|
|
39002
|
+
await this.assertCurrent(grant);
|
|
39003
|
+
res = await this.request("/v1/next/apps/collections", { headers: { authorization: `Bearer ${token}` } }, options.signal);
|
|
39004
|
+
await this.assertCurrent(grant);
|
|
39005
|
+
if (res.status === 403) {
|
|
39006
|
+
denied.add(grant.collection);
|
|
39007
|
+
continue grants;
|
|
39008
|
+
}
|
|
39009
|
+
if (res.status !== 401) break;
|
|
38940
39010
|
await this.withLock(grant.collection, "commit", async () => {
|
|
38941
39011
|
await this.assertCurrent(grant);
|
|
38942
39012
|
const cached = this.tokens.get(grant.collection);
|
|
38943
39013
|
if (cached?.access !== token || !sameGrant(grant, cached)) throw grantChanged();
|
|
38944
39014
|
this.tokens.delete(grant.collection);
|
|
38945
39015
|
});
|
|
38946
|
-
throw mdbaseError("unauthenticated", "the control plane refused the collection listing token");
|
|
39016
|
+
if (attempt > 0) throw mdbaseError("unauthenticated", "the control plane refused the collection listing token");
|
|
38947
39017
|
}
|
|
38948
39018
|
if (res.status !== 200 || !Array.isArray(res.body?.collections)) throw mdbaseError("unavailable", `control plane answered ${res.status}`, "control_error");
|
|
38949
39019
|
const out = [];
|
|
38950
39020
|
for (const raw of res.body.collections) {
|
|
38951
39021
|
const id6 = typeof raw.collection === "string" ? raw.collection.toLowerCase() : "";
|
|
38952
|
-
if (!UUID10.test(id6) || out.some((c) => c.collectionId === id6)) continue;
|
|
39022
|
+
if (!UUID10.test(id6) || denied.has(id6) || out.some((c) => c.collectionId === id6)) continue;
|
|
38953
39023
|
const parsed = parseCollectionAvailability(raw.availability);
|
|
38954
39024
|
if (raw.state !== "synced_e2e" && !parsed) continue;
|
|
38955
39025
|
const availability = !held.has(id6) ? { state: "unavailable", reason: "sync_required" } : parsed ?? { state: "opening" };
|
|
@@ -51135,6 +51205,7 @@ ${end.comment}` : end.comment;
|
|
|
51135
51205
|
if (sel?.state === "invalid") return { kind: "problem", collectionId: null, problem: fallback(sel.problem ?? "application_selection_invalid", cp) };
|
|
51136
51206
|
const paired = s.signIn?.state === "paired";
|
|
51137
51207
|
if (sel?.state === "approving" || s.status === "authorizing") {
|
|
51208
|
+
if (s.problem === "private_authorization_failed") return { kind: "problem", collectionId: requested?.collectionId ?? null, problem: fallback(s.problem, cp) };
|
|
51138
51209
|
const approval = sel?.approval ?? null;
|
|
51139
51210
|
if (!paired) return { kind: "authorizing", purpose: "sign_in", collectionId: approval?.collectionId ?? requested?.collectionId ?? null };
|
|
51140
51211
|
return approval?.kind === "add" ? { kind: "authorizing", purpose: "add", collectionId: null } : { kind: "authorizing", purpose: "approve", collectionId: approval?.collectionId ?? requested?.collectionId ?? null };
|
|
@@ -51173,6 +51244,8 @@ ${end.comment}` : end.comment;
|
|
|
51173
51244
|
return { kind: "problem", collectionId: requested.collectionId, problem: fallback("installation_scope_removed", cp) };
|
|
51174
51245
|
if (sel?.state === "approval_required" && requested?.collectionId)
|
|
51175
51246
|
return { kind: "needs_approval", collectionId: requested.collectionId, displayName: requested.displayName, declined: sel.problem === "application_selection_not_approved" };
|
|
51247
|
+
if (sel?.state === "blocked" && requested?.collectionId && !requested.approved)
|
|
51248
|
+
return { kind: "problem", collectionId: requested.collectionId, problem: fallback("unavailable", cp) };
|
|
51176
51249
|
if (sel?.state === "pending" && requested?.collectionId)
|
|
51177
51250
|
return { kind: "opening", collectionId: requested.collectionId, displayName: requested.displayName, slow: !!o.slow };
|
|
51178
51251
|
const usable = sel?.usable ?? (s.status === "ready" || s.status === "setup_required" ? s.collections.find((c) => c.collectionId === s.selectedCollectionId) ?? null : null);
|
|
@@ -51222,36 +51295,7 @@ ${end.comment}` : end.comment;
|
|
|
51222
51295
|
init_describe_error();
|
|
51223
51296
|
init_app_origin();
|
|
51224
51297
|
init_manifest2();
|
|
51225
|
-
|
|
51226
|
-
// src/application/return-url.ts
|
|
51227
|
-
init_local_build2();
|
|
51228
|
-
var RESERVED = ["http", "https", "file", "javascript", "data", "blob", "about", "capacitor", "chrome-extension", "moz-extension"];
|
|
51229
|
-
function declaredReturnUrl(value2, manifest) {
|
|
51230
|
-
if (typeof value2 !== "string" || !value2 || value2.length > 2048 || value2.includes("*")) return false;
|
|
51231
|
-
const declared = manifest && typeof manifest === "object" ? manifest.redirect_uris : void 0;
|
|
51232
|
-
if (!Array.isArray(declared) || !declared.includes(value2)) return false;
|
|
51233
|
-
const { id: id6, homepage } = manifest;
|
|
51234
|
-
let url2;
|
|
51235
|
-
try {
|
|
51236
|
-
url2 = new URL(value2);
|
|
51237
|
-
} catch {
|
|
51238
|
-
return false;
|
|
51239
|
-
}
|
|
51240
|
-
if (url2.username || url2.password || url2.hash) return false;
|
|
51241
|
-
if (url2.protocol === "https:" || url2.protocol === "http:") {
|
|
51242
|
-
let home;
|
|
51243
|
-
try {
|
|
51244
|
-
home = new URL(String(homepage));
|
|
51245
|
-
} catch {
|
|
51246
|
-
return false;
|
|
51247
|
-
}
|
|
51248
|
-
return url2.origin === home.origin && (url2.protocol === "https:" || loopbackHttpOrigin(url2.origin));
|
|
51249
|
-
}
|
|
51250
|
-
const scheme = url2.protocol.slice(0, -1);
|
|
51251
|
-
return typeof id6 === "string" && scheme.includes(".") && /^[a-z][a-z0-9+.-]*$/.test(scheme) && !RESERVED.includes(scheme) && (scheme === id6 || scheme.startsWith(`${id6}.`)) && url2.hostname.length > 0;
|
|
51252
|
-
}
|
|
51253
|
-
|
|
51254
|
-
// src/application/entry.ts
|
|
51298
|
+
init_return_url();
|
|
51255
51299
|
init_registration();
|
|
51256
51300
|
|
|
51257
51301
|
// src/application/asset-loader.ts
|
|
@@ -51875,10 +51919,14 @@ ${end.comment}` : end.comment;
|
|
|
51875
51919
|
else if (s.selectedCollectionId === id6 && (s.status === "blocked" || s.status === "opening" || isLocked(s))) state2 = s.status === "blocked" ? "blocked" : "opening";
|
|
51876
51920
|
else if (!settled(s)) state2 = "pending";
|
|
51877
51921
|
else if (wanted) state2 = "opening";
|
|
51878
|
-
else if (this.session.listing?.()) state2 = "pending";
|
|
51879
51922
|
else {
|
|
51880
|
-
|
|
51881
|
-
if (
|
|
51923
|
+
const listing = this.session.listing?.();
|
|
51924
|
+
if (listing === "unavailable") state2 = "blocked";
|
|
51925
|
+
else if (listing) state2 = "pending";
|
|
51926
|
+
else {
|
|
51927
|
+
state2 = "approval_required";
|
|
51928
|
+
if (this.declined === id6) problem7 = "application_selection_not_approved";
|
|
51929
|
+
}
|
|
51882
51930
|
}
|
|
51883
51931
|
const approval = this.approval ? Object.freeze({ kind: this.approval.kind, collectionId: this.approval.collectionId, reopenable: this.approval.settled }) : null;
|
|
51884
51932
|
return Object.freeze({
|
|
@@ -51926,7 +51974,7 @@ ${end.comment}` : end.comment;
|
|
|
51926
51974
|
} else {
|
|
51927
51975
|
if (!this.approval.settled || inFlight(s)) return;
|
|
51928
51976
|
const native = s.signIn?.nativeSelection;
|
|
51929
|
-
if (native && native.requestId !== this.approval.receipt && !approved(s, native.collectionId) && this.session.listing?.()) return;
|
|
51977
|
+
if (native && native.requestId !== this.approval.receipt && !approved(s, native.collectionId) && this.session.listing?.() === true) return;
|
|
51930
51978
|
this.finishApproval(s);
|
|
51931
51979
|
}
|
|
51932
51980
|
}
|
|
@@ -52967,6 +53015,7 @@ ${end.comment}` : end.comment;
|
|
|
52967
53015
|
// src/application/private-collections.ts
|
|
52968
53016
|
init_relay_close();
|
|
52969
53017
|
init_errors();
|
|
53018
|
+
init_return_url();
|
|
52970
53019
|
init_app_origin();
|
|
52971
53020
|
init_plain();
|
|
52972
53021
|
function assessmentDelay(signal, ms) {
|
|
@@ -53011,6 +53060,11 @@ ${end.comment}` : end.comment;
|
|
|
53011
53060
|
function appGrantRedirectUri(declaration) {
|
|
53012
53061
|
const declared = declaration.manifest?.redirect_uris;
|
|
53013
53062
|
const uris = Array.isArray(declared) ? declared.filter((uri) => typeof uri === "string") : [];
|
|
53063
|
+
if (declaration.origin.startsWith("capacitor://")) {
|
|
53064
|
+
const callback = uris.find((uri) => mobileGrantReturnUrl(uri, declaration.origin, declaration.manifest));
|
|
53065
|
+
if (!callback) throw mdbaseError("invalid_request", "Declare an iOS Private collection callback in redirect_uris", "redirect_uri");
|
|
53066
|
+
return callback;
|
|
53067
|
+
}
|
|
53014
53068
|
return uris.find((uri) => {
|
|
53015
53069
|
try {
|
|
53016
53070
|
return urlOrigin(new URL(uri)) === declaration.origin;
|
|
@@ -53044,9 +53098,7 @@ ${end.comment}` : end.comment;
|
|
|
53044
53098
|
list = Object.freeze([]);
|
|
53045
53099
|
open = null;
|
|
53046
53100
|
listed = null;
|
|
53047
|
-
|
|
53048
|
-
* requested collection missing from the list may still be in it. */
|
|
53049
|
-
settled = null;
|
|
53101
|
+
failedListing = null;
|
|
53050
53102
|
refreshing = null;
|
|
53051
53103
|
closed = false;
|
|
53052
53104
|
bindings = null;
|
|
@@ -53082,7 +53134,7 @@ ${end.comment}` : end.comment;
|
|
|
53082
53134
|
const previous = this.bindings;
|
|
53083
53135
|
this.bindingsAccount = account;
|
|
53084
53136
|
this.bindings = Object.freeze([...next]);
|
|
53085
|
-
this.
|
|
53137
|
+
this.failedListing = null;
|
|
53086
53138
|
this.listed = null;
|
|
53087
53139
|
const open2 = this.open;
|
|
53088
53140
|
if (open2) {
|
|
@@ -53140,39 +53192,48 @@ ${end.comment}` : end.comment;
|
|
|
53140
53192
|
const open2 = this.open;
|
|
53141
53193
|
return open2 && open2.id === collectionId && open2.state.status === "ready" ? open2.connection : null;
|
|
53142
53194
|
}
|
|
53143
|
-
/**
|
|
53144
|
-
* read): a collection not yet listed may still be one of them. */
|
|
53195
|
+
/** Only a successful read settles whether an unlisted collection is absent. */
|
|
53145
53196
|
listing(account) {
|
|
53146
|
-
|
|
53197
|
+
if (this.closed || account === null) return false;
|
|
53198
|
+
if (this.failedListing === account) return "unavailable";
|
|
53199
|
+
return this.listed !== account;
|
|
53147
53200
|
}
|
|
53148
|
-
/** Read
|
|
53201
|
+
/** Read once per binding. Explicit refreshes and reconnects can retry a failure. */
|
|
53149
53202
|
ensure(account) {
|
|
53150
|
-
if (this.
|
|
53203
|
+
if (this.listing(account) === true && !this.refreshing) void this.refresh(account).catch(() => {
|
|
53151
53204
|
});
|
|
53152
53205
|
}
|
|
53153
|
-
refresh(account = this.listed) {
|
|
53206
|
+
refresh(account = this.bindings === null ? this.listed : this.bindingsAccount) {
|
|
53154
53207
|
if (this.closed) return Promise.resolve();
|
|
53155
53208
|
if (this.refreshing) return this.refreshing;
|
|
53209
|
+
const bindings = this.bindings;
|
|
53210
|
+
const current3 = () => !this.closed && bindings === this.bindings;
|
|
53156
53211
|
const pending = (async () => {
|
|
53157
53212
|
try {
|
|
53158
53213
|
const grants = await this.grants();
|
|
53159
|
-
const bindings = this.bindings;
|
|
53160
53214
|
const verified = [];
|
|
53161
53215
|
if (bindings) {
|
|
53162
53216
|
for (const c of bindings) if (c.account_id === account && await grants.verifiedStoredNativeGrant?.(c)) verified.push(c);
|
|
53163
53217
|
}
|
|
53164
53218
|
const found = await grants.collections(bindings === null ? {} : { bindings: verified });
|
|
53165
|
-
if (
|
|
53219
|
+
if (!current3()) return;
|
|
53220
|
+
const changed3 = this.listing(account) !== false;
|
|
53166
53221
|
this.listed = account;
|
|
53222
|
+
this.failedListing = null;
|
|
53223
|
+
const revision = this.revision;
|
|
53167
53224
|
this.setList(found);
|
|
53168
|
-
|
|
53169
|
-
|
|
53170
|
-
|
|
53225
|
+
if (changed3 && revision === this.revision) this.changed();
|
|
53226
|
+
} catch (error5) {
|
|
53227
|
+
if (current3() && account !== null && this.failedListing !== account) {
|
|
53228
|
+
this.failedListing = account;
|
|
53171
53229
|
this.changed();
|
|
53172
53230
|
}
|
|
53231
|
+
throw error5;
|
|
53173
53232
|
}
|
|
53174
53233
|
})().finally(() => {
|
|
53175
|
-
if (this.refreshing
|
|
53234
|
+
if (this.refreshing !== pending) return;
|
|
53235
|
+
this.refreshing = null;
|
|
53236
|
+
if (!current3() && this.bindingsAccount !== null) this.ensure(this.bindingsAccount);
|
|
53176
53237
|
});
|
|
53177
53238
|
this.refreshing = pending;
|
|
53178
53239
|
return pending;
|
|
@@ -53373,7 +53434,7 @@ ${end.comment}` : end.comment;
|
|
|
53373
53434
|
} finally {
|
|
53374
53435
|
this.list = Object.freeze([]);
|
|
53375
53436
|
this.listed = null;
|
|
53376
|
-
this.
|
|
53437
|
+
this.failedListing = null;
|
|
53377
53438
|
this.changed();
|
|
53378
53439
|
}
|
|
53379
53440
|
}
|
|
@@ -53516,7 +53577,7 @@ ${end.comment}` : end.comment;
|
|
|
53516
53577
|
if (returnUrl !== void 0) {
|
|
53517
53578
|
if (!declaredReturnUrl(returnUrl, declaration.manifest)) fail20();
|
|
53518
53579
|
}
|
|
53519
|
-
if (grantReturnUrl !== void 0 && (!declaredReturnUrl(grantReturnUrl, declaration.manifest) || new URL(grantReturnUrl).origin !== declaration.origin)) fail20();
|
|
53580
|
+
if (grantReturnUrl !== void 0 && !mobileGrantReturnUrl(grantReturnUrl, declaration.origin, declaration.manifest) && (!declaredReturnUrl(grantReturnUrl, declaration.manifest) || new URL(grantReturnUrl).origin !== declaration.origin)) fail20();
|
|
53520
53581
|
const open2 = value2.open.bind(value2), close = value2.close?.bind(value2);
|
|
53521
53582
|
return Object.freeze({ open: open2, ...close ? { close } : {}, ...returnUrl !== void 0 ? { returnUrl } : {}, ...grantReturnUrl !== void 0 ? { grantReturnUrl } : {} });
|
|
53522
53583
|
}
|
|
@@ -53673,6 +53734,9 @@ ${end.comment}` : end.comment;
|
|
|
53673
53734
|
this.notify(false);
|
|
53674
53735
|
}
|
|
53675
53736
|
return this.call(async (runtime2) => {
|
|
53737
|
+
const account = this.account();
|
|
53738
|
+
if (this.privates?.listing(account) === "unavailable") await this.privates.refresh(account).catch(() => {
|
|
53739
|
+
});
|
|
53676
53740
|
const native = runtime2.getNativeSnapshot();
|
|
53677
53741
|
if (native.status === "blocked" && native.signIn && native.selectedCollectionId === null)
|
|
53678
53742
|
await runtime2.queue(() => runtime2.start(options2));
|
|
@@ -54430,7 +54494,13 @@ ${end.comment}` : end.comment;
|
|
|
54430
54494
|
this.revision++;
|
|
54431
54495
|
this.notify(false);
|
|
54432
54496
|
};
|
|
54433
|
-
scope.addEventListener("online",
|
|
54497
|
+
scope.addEventListener("online", () => {
|
|
54498
|
+
const account = this.account();
|
|
54499
|
+
if (!this.closed && !this.hidden && this.privates?.listing(account) === "unavailable")
|
|
54500
|
+
void this.privates.refresh(account).catch(() => {
|
|
54501
|
+
});
|
|
54502
|
+
changed3();
|
|
54503
|
+
}, { signal: this.lifetime.signal });
|
|
54434
54504
|
scope.addEventListener("offline", changed3, { signal: this.lifetime.signal });
|
|
54435
54505
|
}
|
|
54436
54506
|
/** Back/forward cache: a page parked there is frozen with its Worker, which
|
|
@@ -55710,7 +55780,7 @@ ${end.comment}` : end.comment;
|
|
|
55710
55780
|
} else {
|
|
55711
55781
|
await this.prepareNativeChoice();
|
|
55712
55782
|
this.resumeApprovalWindow();
|
|
55713
|
-
this.publish({ status: "authorizing", problem: null });
|
|
55783
|
+
this.publish({ status: "authorizing", problem: this.nativePending?.failed ? "private_authorization_failed" : null });
|
|
55714
55784
|
}
|
|
55715
55785
|
return;
|
|
55716
55786
|
}
|
|
@@ -55751,7 +55821,7 @@ ${end.comment}` : end.comment;
|
|
|
55751
55821
|
this.check();
|
|
55752
55822
|
if (unfinished) this.publish({ approval: Object.freeze({ outcome: "closed" }) });
|
|
55753
55823
|
await this.refreshCollections();
|
|
55754
|
-
} else this.publish({ status: "authorizing", problem: null });
|
|
55824
|
+
} else this.publish({ status: "authorizing", problem: this.nativePending?.failed ? "private_authorization_failed" : null });
|
|
55755
55825
|
}
|
|
55756
55826
|
/** A receipt with no collection pick is complete only for device access:
|
|
55757
55827
|
* Connect never names a Private device collection as the selection, so an
|
|
@@ -55783,7 +55853,7 @@ ${end.comment}` : end.comment;
|
|
|
55783
55853
|
if (!this.attested) return false;
|
|
55784
55854
|
if (!this.approvalWindow?.nativeAuthorization || !this.installation || !this.flow.nativeAuthorizationContext(this.installation)) return true;
|
|
55785
55855
|
const slot = this.nativePending;
|
|
55786
|
-
return slot !== null &&
|
|
55856
|
+
return slot !== null && slot.attempted && !slot.failed;
|
|
55787
55857
|
}
|
|
55788
55858
|
/** Preparation is optional and never blocks a genuine Hosted approval. Only
|
|
55789
55859
|
* the original lifecycle turn attaches after observing its matching context. */
|