@mdbase-dev/connect 0.1.0-beta.83 → 0.1.0-beta.85
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 +33 -6
- package/dist/advanced.d.ts +1 -1
- package/dist/application-session.d.ts +31 -10
- package/dist/application-session.js +278 -64
- package/dist/authorization-refresh.d.ts +14 -0
- package/dist/authorization-refresh.js +41 -0
- package/dist/authorization-url.d.ts +1 -0
- package/dist/authorization-url.js +9 -0
- package/dist/browser/integrity.json +1 -1
- package/dist/browser/mdbase-connect.min.js +3 -3
- package/dist/browser/mdbase-connect.min.js.sha384 +1 -1
- package/dist/connect.d.ts +4 -1
- package/dist/connect.js +33 -26
- package/dist/connection-file-transport.d.ts +3 -0
- package/dist/connection-file-transport.js +59 -16
- package/dist/connection-transport-internals.d.ts +2 -0
- package/dist/connection-transport.d.ts +3 -1
- package/dist/connection-transport.js +90 -82
- package/dist/grant-key-leases.d.ts +24 -0
- package/dist/grant-key-leases.js +144 -0
- package/dist/hosted-file-request.d.ts +2 -2
- package/dist/hosted-file-request.js +4 -4
- package/dist/hosted-operation-response.d.ts +5 -0
- package/dist/hosted-operation-response.js +26 -0
- package/dist/internal-types.d.ts +2 -0
- package/dist/local-file-transport.d.ts +8 -2
- package/dist/local-file-transport.js +71 -20
- package/dist/mdbase-connect.d.ts +1 -0
- package/dist/mdbase-connect.js +3 -0
- package/dist/outcomes.d.ts +12 -12
- package/dist/outcomes.js +6 -0
- package/dist/pending-recovery-transports.d.ts +1 -0
- package/dist/pending-recovery-transports.js +7 -3
- package/dist/retired-grant-keys.d.ts +9 -0
- package/dist/retired-grant-keys.js +56 -0
- package/dist/session.d.ts +36 -7
- package/dist/session.js +287 -34
- package/dist/shared-operation.d.ts +7 -0
- package/dist/shared-operation.js +41 -0
- package/dist/token-response.d.ts +2 -1
- package/dist/token-response.js +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { requestAbortReason, withRequestBudget } from "./request-budget.js";
|
|
2
|
+
export class SharedOperationMap {
|
|
3
|
+
operations = new Map();
|
|
4
|
+
run(key, options, defaultTimeoutMs, start) {
|
|
5
|
+
if (options?.signal?.aborted)
|
|
6
|
+
return Promise.reject(requestAbortReason(options.signal));
|
|
7
|
+
const operation = this.operations.get(key) ?? this.begin(key, start);
|
|
8
|
+
return this.wait(key, operation, options, defaultTimeoutMs);
|
|
9
|
+
}
|
|
10
|
+
begin(key, start) {
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const operation = {
|
|
13
|
+
controller,
|
|
14
|
+
waiters: 0,
|
|
15
|
+
settled: false,
|
|
16
|
+
promise: undefined
|
|
17
|
+
};
|
|
18
|
+
operation.promise = Promise.resolve()
|
|
19
|
+
.then(() => start(controller.signal))
|
|
20
|
+
.finally(() => {
|
|
21
|
+
operation.settled = true;
|
|
22
|
+
if (this.operations.get(key) === operation)
|
|
23
|
+
this.operations.delete(key);
|
|
24
|
+
});
|
|
25
|
+
this.operations.set(key, operation);
|
|
26
|
+
return operation;
|
|
27
|
+
}
|
|
28
|
+
async wait(key, operation, options, defaultTimeoutMs) {
|
|
29
|
+
operation.waiters += 1;
|
|
30
|
+
try {
|
|
31
|
+
return await withRequestBudget(options, defaultTimeoutMs, () => operation.promise);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
operation.waiters -= 1;
|
|
35
|
+
if (operation.waiters === 0 && !operation.settled && this.operations.get(key) === operation) {
|
|
36
|
+
this.operations.delete(key);
|
|
37
|
+
operation.controller.abort();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/dist/token-response.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ interface StoredTokenResponseOptions {
|
|
|
4
4
|
clientId: string;
|
|
5
5
|
keyHandle?: string;
|
|
6
6
|
previous: StoredToken | null;
|
|
7
|
+
retiredKeyHandles?: string[];
|
|
7
8
|
defaultApplicationOrigin: string;
|
|
8
9
|
pinConnectorIdentity(connectorId: string, publicKey: string): void;
|
|
9
10
|
}
|
|
10
|
-
export declare function storedTokenFromResponse({ body, clientId, keyHandle, previous, defaultApplicationOrigin, pinConnectorIdentity }: StoredTokenResponseOptions): StoredToken;
|
|
11
|
+
export declare function storedTokenFromResponse({ body, clientId, keyHandle, previous, retiredKeyHandles, defaultApplicationOrigin, pinConnectorIdentity }: StoredTokenResponseOptions): StoredToken;
|
|
11
12
|
export {};
|
package/dist/token-response.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { validateGrantEncryption } from "./crypto.js";
|
|
2
2
|
import { connectError } from "./errors.js";
|
|
3
3
|
import { parseGrantScope, validAuthorityTokenResponse, validFileCapability } from "./runtime-utils.js";
|
|
4
|
-
export function storedTokenFromResponse({ body, clientId, keyHandle, previous, defaultApplicationOrigin, pinConnectorIdentity }) {
|
|
4
|
+
export function storedTokenFromResponse({ body, clientId, keyHandle, previous, retiredKeyHandles, defaultApplicationOrigin, pinConnectorIdentity }) {
|
|
5
5
|
const collectionId = body.collection_id;
|
|
6
6
|
if (typeof collectionId !== "string") {
|
|
7
7
|
throw connectError("invalid_token_response", "Authorization returned no collection ID.");
|
|
@@ -64,6 +64,7 @@ export function storedTokenFromResponse({ body, clientId, keyHandle, previous, d
|
|
|
64
64
|
fileCapability: body.file_capability ?? undefined,
|
|
65
65
|
applicationOrigin: body.application_origin ?? defaultApplicationOrigin,
|
|
66
66
|
keyHandle,
|
|
67
|
+
...(retiredKeyHandles?.length ? { retiredKeyHandles } : {}),
|
|
67
68
|
savedAt: Date.now(),
|
|
68
69
|
authority: body.authority ? {
|
|
69
70
|
operationsUrl: body.authority.operations_url,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdbase-dev/connect",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.85",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@mdbase-dev/connect-protocol": "0.1.0-beta.
|
|
36
|
+
"@mdbase-dev/connect-protocol": "0.1.0-beta.85"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"esbuild": "^0.28.1",
|