@mdbase-dev/connect 0.1.0-beta.100
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/LICENSE +21 -0
- package/README.md +696 -0
- package/dist/advanced.d.ts +9 -0
- package/dist/advanced.js +6 -0
- package/dist/application-contract.d.ts +22 -0
- package/dist/application-contract.js +75 -0
- package/dist/application-identity.d.ts +34 -0
- package/dist/application-identity.js +148 -0
- package/dist/application-session.d.ts +167 -0
- package/dist/application-session.js +722 -0
- package/dist/async.d.ts +1 -0
- package/dist/async.js +19 -0
- package/dist/authority-proof.d.ts +3 -0
- package/dist/authority-proof.js +24 -0
- package/dist/authority-sync-request.d.ts +3 -0
- package/dist/authority-sync-request.js +20 -0
- package/dist/authorization-refresh.d.ts +14 -0
- package/dist/authorization-refresh.js +41 -0
- package/dist/authorization-types.d.ts +7 -0
- package/dist/authorization-types.js +1 -0
- package/dist/authorization-url.d.ts +5 -0
- package/dist/authorization-url.js +34 -0
- package/dist/base64.d.ts +3 -0
- package/dist/base64.js +21 -0
- package/dist/browser/integrity.json +4 -0
- package/dist/browser/mdbase-connect.min.js +3 -0
- package/dist/browser/mdbase-connect.min.js.sha384 +1 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +5 -0
- package/dist/capabilities.d.ts +24 -0
- package/dist/capabilities.js +91 -0
- package/dist/collection-client.d.ts +66 -0
- package/dist/collection-client.js +686 -0
- package/dist/connect-authorization-helpers.d.ts +4 -0
- package/dist/connect-authorization-helpers.js +25 -0
- package/dist/connect-options.d.ts +35 -0
- package/dist/connect-options.js +1 -0
- package/dist/connect.d.ts +66 -0
- package/dist/connect.js +711 -0
- package/dist/connection-file-transport.d.ts +34 -0
- package/dist/connection-file-transport.js +85 -0
- package/dist/connection-index.d.ts +3 -0
- package/dist/connection-index.js +20 -0
- package/dist/connection-notifications.d.ts +31 -0
- package/dist/connection-notifications.js +197 -0
- package/dist/connection-transport-internals.d.ts +24 -0
- package/dist/connection-transport-internals.js +1 -0
- package/dist/connection-transport.d.ts +64 -0
- package/dist/connection-transport.js +725 -0
- package/dist/connection-types.d.ts +38 -0
- package/dist/connection-types.js +1 -0
- package/dist/connection.d.ts +175 -0
- package/dist/connection.js +606 -0
- package/dist/crypto-entry.d.ts +7 -0
- package/dist/crypto-entry.js +4 -0
- package/dist/crypto.d.ts +63 -0
- package/dist/crypto.js +409 -0
- package/dist/direct-access.d.ts +3 -0
- package/dist/direct-access.js +29 -0
- package/dist/errors.d.ts +45 -0
- package/dist/errors.js +142 -0
- package/dist/external-store.d.ts +10 -0
- package/dist/external-store.js +10 -0
- package/dist/file-crypto.d.ts +25 -0
- package/dist/file-crypto.js +132 -0
- package/dist/file-sha256.d.ts +12 -0
- package/dist/file-sha256.js +143 -0
- package/dist/file-stream-source.d.ts +17 -0
- package/dist/file-stream-source.js +157 -0
- package/dist/file-transfer-internals.d.ts +23 -0
- package/dist/file-transfer-internals.js +228 -0
- package/dist/files.d.ts +115 -0
- package/dist/files.js +563 -0
- package/dist/fresh-encrypted-request.d.ts +4 -0
- package/dist/fresh-encrypted-request.js +28 -0
- package/dist/grant-key-leases.d.ts +24 -0
- package/dist/grant-key-leases.js +144 -0
- package/dist/hosted-file-request.d.ts +6 -0
- package/dist/hosted-file-request.js +63 -0
- package/dist/hosted-operation-response.d.ts +5 -0
- package/dist/hosted-operation-response.js +26 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +10 -0
- package/dist/internal-types.d.ts +100 -0
- package/dist/internal-types.js +1 -0
- package/dist/local-file-transport.d.ts +37 -0
- package/dist/local-file-transport.js +457 -0
- package/dist/mdbase-connect.d.ts +28 -0
- package/dist/mdbase-connect.js +53 -0
- package/dist/notifications.d.ts +48 -0
- package/dist/notifications.js +52 -0
- package/dist/operation-helpers.d.ts +27 -0
- package/dist/operation-helpers.js +144 -0
- package/dist/operation-types.d.ts +707 -0
- package/dist/operation-types.js +1 -0
- package/dist/outcomes.d.ts +51 -0
- package/dist/outcomes.js +194 -0
- package/dist/pending-mutation-store.d.ts +13 -0
- package/dist/pending-mutation-store.js +64 -0
- package/dist/pending-recovery-transports.d.ts +5 -0
- package/dist/pending-recovery-transports.js +52 -0
- package/dist/popup-authorization.d.ts +31 -0
- package/dist/popup-authorization.js +100 -0
- package/dist/query-pagination.d.ts +6 -0
- package/dist/query-pagination.js +119 -0
- package/dist/request-budget.d.ts +34 -0
- package/dist/request-budget.js +104 -0
- package/dist/request-coordinator.d.ts +29 -0
- package/dist/request-coordinator.js +213 -0
- package/dist/retired-grant-keys.d.ts +9 -0
- package/dist/retired-grant-keys.js +56 -0
- package/dist/runtime-utils.d.ts +52 -0
- package/dist/runtime-utils.js +368 -0
- package/dist/saved-view-pagination.d.ts +6 -0
- package/dist/saved-view-pagination.js +76 -0
- package/dist/selection.d.ts +48 -0
- package/dist/selection.js +112 -0
- package/dist/session.d.ts +114 -0
- package/dist/session.js +569 -0
- package/dist/shared-operation.d.ts +7 -0
- package/dist/shared-operation.js +41 -0
- package/dist/stored-token.d.ts +10 -0
- package/dist/stored-token.js +64 -0
- package/dist/structured-readiness.d.ts +77 -0
- package/dist/structured-readiness.js +126 -0
- package/dist/token-response.d.ts +12 -0
- package/dist/token-response.js +81 -0
- package/dist/transient-retry.d.ts +22 -0
- package/dist/transient-retry.js +59 -0
- package/dist/watch-policy.d.ts +8 -0
- package/dist/watch-policy.js +12 -0
- package/package.json +51 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { APPLICATION_AUTHORIZATION_V2_ISSUANCE_CAPABILITY } from "@mdbase-dev/connect-protocol";
|
|
2
|
+
import { MdbaseConnectError, connectError } from "./errors.js";
|
|
3
|
+
export async function assertFreshV2AuthorizationSupport(serverUrl, signal) {
|
|
4
|
+
const response = await fetch(`${serverUrl}/health`, { signal, cache: "no-store" });
|
|
5
|
+
const health = await response.json().catch(() => null);
|
|
6
|
+
if (!response.ok || !Array.isArray(health?.capabilities)
|
|
7
|
+
|| !health.capabilities.every((value) => typeof value === "string")
|
|
8
|
+
|| !health.capabilities.includes(APPLICATION_AUTHORIZATION_V2_ISSUANCE_CAPABILITY)) {
|
|
9
|
+
throw connectError("capability_contract_incompatible", "This server does not support new version-2 application authorizations.", {
|
|
10
|
+
details: { contract: "fresh_application_authorization", required: [2], supported: [], peer: "server" }
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function declarationIdFromFamilyIdentity(familyIdentity) {
|
|
15
|
+
const prefix = "bundle:";
|
|
16
|
+
if (!familyIdentity.startsWith(prefix) || familyIdentity.length === prefix.length) {
|
|
17
|
+
throw new Error("The registered application has no valid declaration identity.");
|
|
18
|
+
}
|
|
19
|
+
return familyIdentity.slice(prefix.length);
|
|
20
|
+
}
|
|
21
|
+
export function authorizationAbort(signal, message, cause) {
|
|
22
|
+
if (signal.reason instanceof MdbaseConnectError)
|
|
23
|
+
return signal.reason;
|
|
24
|
+
return connectError("authorization_cancelled", message, { cause });
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MdbaseApplicationManifest as MdbaseAppManifest } from "./application-contract.js";
|
|
2
|
+
import type { JsonObject } from "@mdbase-dev/connect-protocol";
|
|
3
|
+
import type { GrantKeyStore } from "./crypto.js";
|
|
4
|
+
import type { ApplicationIdentityStore } from "./application-identity.js";
|
|
5
|
+
export interface MdbaseConnectTimeouts {
|
|
6
|
+
requestMs?: number | null;
|
|
7
|
+
watchStartMs?: number | null;
|
|
8
|
+
fileIndexMs?: number | null;
|
|
9
|
+
uploadMs?: number | null;
|
|
10
|
+
syncMs?: number | null;
|
|
11
|
+
}
|
|
12
|
+
export interface MdbaseConnectOptions {
|
|
13
|
+
serverUrl: string | URL;
|
|
14
|
+
/**
|
|
15
|
+
* A bundled v1 application manifest or its app-local URL. String values
|
|
16
|
+
* are loaded by this SDK and posted inline; Connect never fetches them.
|
|
17
|
+
*/
|
|
18
|
+
manifest?: MdbaseAppManifest | string | URL;
|
|
19
|
+
redirectUri?: string | URL;
|
|
20
|
+
storage?: Storage;
|
|
21
|
+
/** Encrypted relay is required by default for newly authorized grants. */
|
|
22
|
+
relayEncryption?: "required" | "disabled";
|
|
23
|
+
keyStore?: GrantKeyStore;
|
|
24
|
+
/** Persistent installation signing identity; separate from disposable grant keys. */
|
|
25
|
+
identityStore?: ApplicationIdentityStore;
|
|
26
|
+
/** Prefer same-computer connector access when the browser permits it. */
|
|
27
|
+
directAccess?: "auto" | "disabled";
|
|
28
|
+
/** Loopback origin override for development and automated testing. */
|
|
29
|
+
loopbackUrl?: string | URL;
|
|
30
|
+
/** Override browser navigation, for example to use a native system browser. */
|
|
31
|
+
navigate?: (url: string) => void | Promise<void>;
|
|
32
|
+
/** Workload-specific defaults. Per-call timeoutMs always wins. */
|
|
33
|
+
timeouts?: MdbaseConnectTimeouts;
|
|
34
|
+
}
|
|
35
|
+
export type MdbaseFrontmatter = JsonObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { JsonObject } from "@mdbase-dev/connect-protocol";
|
|
2
|
+
import { type MdbaseApplicationManifest as MdbaseAppManifest } from "./application-contract.js";
|
|
3
|
+
import { type ApplicationIdentityStore } from "./application-identity.js";
|
|
4
|
+
import { MdbaseConnection, type MdbaseAuthorizationOutcome, type MdbaseAuthorizationResult, type MdbaseAuthorizeOptions, type MdbaseConnectEnvironment } from "./connection.js";
|
|
5
|
+
import type { MdbaseConnectOptions } from "./connect-options.js";
|
|
6
|
+
import type { MdbaseConnectionInfo } from "./connection-types.js";
|
|
7
|
+
import { type GrantKeyStore } from "./crypto.js";
|
|
8
|
+
import { type Application, type StoredToken } from "./internal-types.js";
|
|
9
|
+
import type { ConnectRequestOptions } from "./operation-types.js";
|
|
10
|
+
import { type ResolvedConnectTimeouts } from "./request-budget.js";
|
|
11
|
+
import type { MdbaseUnavailableReason } from "./session.js";
|
|
12
|
+
export declare class MdbaseConnectInternals<Frontmatter extends JsonObject> {
|
|
13
|
+
readonly serverUrl: string;
|
|
14
|
+
readonly manifest: MdbaseAppManifest | string;
|
|
15
|
+
readonly manifestSource: string;
|
|
16
|
+
readonly redirectUri: string;
|
|
17
|
+
readonly storage: Storage;
|
|
18
|
+
readonly relayEncryption: "required" | "disabled";
|
|
19
|
+
readonly keyStore: GrantKeyStore;
|
|
20
|
+
readonly identityStore: ApplicationIdentityStore;
|
|
21
|
+
readonly directAccessMode: "auto" | "disabled";
|
|
22
|
+
readonly loopbackUrl: string;
|
|
23
|
+
readonly navigate?: (url: string) => void | Promise<void>;
|
|
24
|
+
readonly timeouts: ResolvedConnectTimeouts;
|
|
25
|
+
readonly credentialStorage: MdbaseConnectEnvironment["credentialStorage"];
|
|
26
|
+
private application;
|
|
27
|
+
private manifestPromise;
|
|
28
|
+
private readonly completionPromises;
|
|
29
|
+
private readonly grantKeyLeases;
|
|
30
|
+
private readonly connectionCache;
|
|
31
|
+
private readonly listeners;
|
|
32
|
+
private readonly invalidatedConnections;
|
|
33
|
+
constructor(options: MdbaseConnectOptions);
|
|
34
|
+
environment(): MdbaseConnectEnvironment;
|
|
35
|
+
register(options?: ConnectRequestOptions): Promise<Application>;
|
|
36
|
+
private registerWithinBudget;
|
|
37
|
+
manifestDeclaration(options?: ConnectRequestOptions): Promise<MdbaseAppManifest>;
|
|
38
|
+
private loadManifest;
|
|
39
|
+
authorize(options?: MdbaseAuthorizeOptions): Promise<MdbaseAuthorizationOutcome<Frontmatter>>;
|
|
40
|
+
private authorizeWithinBudget;
|
|
41
|
+
private authorizeWeb;
|
|
42
|
+
private authorizePortable;
|
|
43
|
+
completeAuthorization(callbackUrl: string, options?: ConnectRequestOptions): Promise<MdbaseAuthorizationResult<Frontmatter>>;
|
|
44
|
+
private performAuthorizationCompletion;
|
|
45
|
+
connections(): MdbaseConnectionInfo[];
|
|
46
|
+
connection(collectionId: string): MdbaseConnection<Frontmatter> | null;
|
|
47
|
+
unavailableReason(collectionId: string): MdbaseUnavailableReason | null;
|
|
48
|
+
connectionApplicationId(collectionId: string): string | null;
|
|
49
|
+
onConnectionsChange(listener: (connections: MdbaseConnectionInfo[]) => void): () => void;
|
|
50
|
+
storeTokenResponse(body: any, clientId: string, keyHandle?: string): StoredToken;
|
|
51
|
+
forgetConnectorIdentity(connectorId: string): void;
|
|
52
|
+
private pinConnectorIdentity;
|
|
53
|
+
private connectorPinKey;
|
|
54
|
+
private loadApplicationIdentity;
|
|
55
|
+
removeToken(collectionId: string, keyHandle?: string, reason?: MdbaseUnavailableReason, discardPending?: boolean): void;
|
|
56
|
+
acquireGrantKeyLease(collectionId: string, keyHandle: string, signal?: AbortSignal): Promise<() => void>;
|
|
57
|
+
deleteGrantKeyWhenUnused(collectionId: string, keyHandle: string): void;
|
|
58
|
+
tokenKey(collectionId: string): string;
|
|
59
|
+
pendingMutationKey(collectionId: string): string;
|
|
60
|
+
notificationKey(collectionId: string, transport?: "web_push" | "fcm"): string;
|
|
61
|
+
directPreferenceKey(): string;
|
|
62
|
+
defaultApplicationOrigin(): string;
|
|
63
|
+
private pendingKey;
|
|
64
|
+
private storagePrefix;
|
|
65
|
+
private emitConnections;
|
|
66
|
+
}
|