@mdbase-dev/connect-protocol 0.1.0-beta.21
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/dist/index.d.ts +756 -0
- package/dist/index.js +57 -0
- package/package.json +35 -0
- package/schemas/catalog.json +12 -0
- package/schemas/connect-protocol.v1.schema.json +660 -0
- package/schemas/data-contract.schema.json +163 -0
- package/schemas/encrypted-relay.v1.schema.json +71 -0
- package/schemas/interop/v0.1/action-cancellation.schema.json +6 -0
- package/schemas/interop/v0.1/action-invocation.schema.json +6 -0
- package/schemas/interop/v0.1/action-outcome.schema.json +6 -0
- package/schemas/interop/v0.1/action-provider-declaration.schema.json +6 -0
- package/schemas/interop/v0.1/action-request.schema.json +6 -0
- package/schemas/interop/v0.1/conformance-claim.schema.json +6 -0
- package/schemas/interop/v0.1/event-source-declaration.schema.json +6 -0
- package/schemas/interop/v0.1/event.schema.json +6 -0
- package/schemas/interop/v0.1/profile.schema.json +456 -0
- package/schemas/mdbase-app.schema.json +246 -0
- package/schemas/notification-webhook.v1.schema.json +56 -0
- package/schemas/sync.v1.schema.json +256 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const CONTROL_PROTOCOL_VERSION = 1;
|
|
2
|
+
export const ENCRYPTED_RELAY_PROTOCOL_VERSION = 1;
|
|
3
|
+
export const LOOPBACK_PROTOCOL_VERSION = 1;
|
|
4
|
+
export const DEFAULT_LOOPBACK_PORT = 28_485;
|
|
5
|
+
export const RELAY_ENCRYPTION_SUITE = "P256-HKDF-SHA256-AES256GCM";
|
|
6
|
+
export const SYNC_PROTOCOL_VERSION = 1;
|
|
7
|
+
export const CONTRACT_SETUP_CAPABILITY = "contract-setup-v1";
|
|
8
|
+
export const RELAY_REQUIRED_CAPABILITIES = [
|
|
9
|
+
"authorization-activation",
|
|
10
|
+
"encrypted-relay",
|
|
11
|
+
"policy-ack"
|
|
12
|
+
];
|
|
13
|
+
export const RELAY_CAPABILITIES = [
|
|
14
|
+
...RELAY_REQUIRED_CAPABILITIES,
|
|
15
|
+
CONTRACT_SETUP_CAPABILITY
|
|
16
|
+
];
|
|
17
|
+
export const AUTHORITY_PROOF_VERSION = 1;
|
|
18
|
+
export const AUTHORITY_PROOF_ALGORITHM = "P256-SHA256";
|
|
19
|
+
export const AUTHORITY_PROOF_DOMAIN = "mdbase-authority-request-proof-v1";
|
|
20
|
+
export const AUTHORITY_PROOF_HEADERS = {
|
|
21
|
+
version: "x-mdbase-proof-version",
|
|
22
|
+
timestamp: "x-mdbase-proof-timestamp",
|
|
23
|
+
nonce: "x-mdbase-proof-nonce",
|
|
24
|
+
signature: "x-mdbase-proof-signature"
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Validate a native OAuth callback against the publisher of its web manifest.
|
|
28
|
+
* Reverse-domain private-use schemes keep native app identity tied to the
|
|
29
|
+
* manifest origin; PKCE remains mandatory at the authorization boundary.
|
|
30
|
+
*/
|
|
31
|
+
export function isNativeRedirectUri(url, publisherHostname) {
|
|
32
|
+
const scheme = url.protocol.slice(0, -1);
|
|
33
|
+
const publisherPrefix = publisherHostname
|
|
34
|
+
?.toLowerCase()
|
|
35
|
+
.split(".")
|
|
36
|
+
.reverse()
|
|
37
|
+
.join(".");
|
|
38
|
+
return scheme.includes(".")
|
|
39
|
+
&& /^[a-z][a-z0-9+.-]*$/.test(scheme)
|
|
40
|
+
&& !["http", "https", "file", "javascript", "data"].includes(scheme)
|
|
41
|
+
&& (!publisherPrefix
|
|
42
|
+
|| scheme === publisherPrefix
|
|
43
|
+
|| scheme.startsWith(`${publisherPrefix}.`))
|
|
44
|
+
&& url.username === ""
|
|
45
|
+
&& url.password === ""
|
|
46
|
+
&& url.hostname.length > 0
|
|
47
|
+
&& url.hash === "";
|
|
48
|
+
}
|
|
49
|
+
export const CONNECT_SCHEMA_IDS = {
|
|
50
|
+
appManifest: "https://mdbase.dev/connect/schemas/mdbase-app.v1.json",
|
|
51
|
+
notificationWebhook: "https://mdbase.dev/connect/schemas/notification-webhook.v1.json",
|
|
52
|
+
dataContract: "https://mdbase.dev/schemas/v0.3/data-contract.schema.json",
|
|
53
|
+
eventActionInterop: "https://mdbase.dev/schemas/interop/v0.1/profile.schema.json",
|
|
54
|
+
protocol: "https://mdbase.dev/connect/schemas/connect-protocol.v1.json",
|
|
55
|
+
encryptedRelay: "https://mdbase.dev/connect/schemas/encrypted-relay.v1.json",
|
|
56
|
+
sync: "https://mdbase.dev/connect/schemas/sync.v1.json"
|
|
57
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mdbase-dev/connect-protocol",
|
|
3
|
+
"version": "0.1.0-beta.21",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mdbase-dev/mdbase-connect.git",
|
|
10
|
+
"directory": "packages/protocol"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://mdbase.dev",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./schemas/*": "./schemas/*"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"schemas"
|
|
24
|
+
],
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"ajv": "^8.20.0",
|
|
27
|
+
"ajv-formats": "^3.0.1",
|
|
28
|
+
"typescript": "^7.0.2"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|
|
32
|
+
"test": "node --test test/*.test.mjs",
|
|
33
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 1,
|
|
3
|
+
"schemas": {
|
|
4
|
+
"app_manifest": "./mdbase-app.schema.json",
|
|
5
|
+
"data_contract": "./data-contract.schema.json",
|
|
6
|
+
"event_action_interop": "./interop/v0.1/profile.schema.json",
|
|
7
|
+
"connect_protocol": "./connect-protocol.v1.schema.json",
|
|
8
|
+
"encrypted_relay": "./encrypted-relay.v1.schema.json",
|
|
9
|
+
"notification_webhook": "./notification-webhook.v1.schema.json",
|
|
10
|
+
"sync": "./sync.v1.schema.json"
|
|
11
|
+
}
|
|
12
|
+
}
|