@oxy.so/contracts 2.0.0 → 2.1.0
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/federationInstanceFetch.js +44 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/linkedAccounts.js +34 -1
- package/dist/cjs/notifications.js +20 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/federationInstanceFetch.js +41 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/linkedAccounts.js +33 -0
- package/dist/esm/notifications.js +19 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/federationInstanceFetch.d.ts +63 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/inference/aliaModelRelease.d.ts +8 -8
- package/dist/types/inference/modelDocumentation.d.ts +8 -8
- package/dist/types/linkedAccounts.d.ts +33 -0
- package/dist/types/notifications.d.ts +26 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Wire contract for `POST /federation/instance-fetch/sign`: Oxy's INSTANCE
|
|
4
|
+
* actor signs one ActivityPub GET for a first-party service, so the service can
|
|
5
|
+
* read an instance running in authorized-fetch ("secure") mode without holding
|
|
6
|
+
* a key.
|
|
7
|
+
*
|
|
8
|
+
* The caller sends a URL, never a signing string: Oxy builds the string itself
|
|
9
|
+
* (`(request-target): get <path>`, `host`, `date`), the method is always GET
|
|
10
|
+
* and the key is always the instance actor's. The caller sends the returned
|
|
11
|
+
* headers, unchanged, on exactly that URL, within the few minutes remote
|
|
12
|
+
* servers accept a `Date` for. A redirect is a new URL and needs a new
|
|
13
|
+
* signature.
|
|
14
|
+
*
|
|
15
|
+
* Needs a service token whose application holds the privileged
|
|
16
|
+
* `federation:instance-fetch` scope.
|
|
17
|
+
*
|
|
18
|
+
* Platform-agnostic — zod only.
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.instanceFetchSignResponseSchema = exports.instanceFetchSignRequestSchema = exports.INSTANCE_FETCH_MAX_URL_LENGTH = void 0;
|
|
22
|
+
const zod_1 = require("zod");
|
|
23
|
+
/** The longest URL Oxy will sign (the same cap as its own safe fetch). */
|
|
24
|
+
exports.INSTANCE_FETCH_MAX_URL_LENGTH = 2048;
|
|
25
|
+
exports.instanceFetchSignRequestSchema = zod_1.z
|
|
26
|
+
.object({
|
|
27
|
+
/** The absolute public `https://` URL the caller is about to GET. */
|
|
28
|
+
url: zod_1.z.string().trim().min(1).max(exports.INSTANCE_FETCH_MAX_URL_LENGTH),
|
|
29
|
+
})
|
|
30
|
+
.strict();
|
|
31
|
+
exports.instanceFetchSignResponseSchema = zod_1.z
|
|
32
|
+
.object({
|
|
33
|
+
/** The instance actor's key, e.g. `https://oxy.so/ap/users/instance#main-key`. */
|
|
34
|
+
keyId: zod_1.z.string().url(),
|
|
35
|
+
/** Send all three on the GET, as they are. */
|
|
36
|
+
headers: zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
Host: zod_1.z.string().min(1),
|
|
39
|
+
Date: zod_1.z.string().min(1),
|
|
40
|
+
Signature: zod_1.z.string().min(1),
|
|
41
|
+
})
|
|
42
|
+
.strict(),
|
|
43
|
+
})
|
|
44
|
+
.strict();
|
package/dist/cjs/index.js
CHANGED
|
@@ -683,4 +683,5 @@ Object.defineProperty(exports, "inboxThreadSummaryResponseSchema", { enumerable:
|
|
|
683
683
|
Object.defineProperty(exports, "inboxInferenceStreamEventSchema", { enumerable: true, get: function () { return inbox_1.inboxInferenceStreamEventSchema; } });
|
|
684
684
|
__exportStar(require("./externalIdentity"), exports);
|
|
685
685
|
__exportStar(require("./linkedAccounts"), exports);
|
|
686
|
+
__exportStar(require("./federationInstanceFetch"), exports);
|
|
686
687
|
__exportStar(require("./notifications"), exports);
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Platform-agnostic — zod only, no react/react-native/expo.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.LINKED_ACCOUNT_CALLBACK_ERRORS = exports.serviceLinkedAccountListResponseSchema = exports.serviceLinkedAccountSchema = exports.linkedAccountListResponseSchema = exports.completeLinkedAccountResponseSchema = exports.linkedAccountSchema = exports.completeLinkedAccountRequestSchema = exports.startLinkedAccountResponseSchema = exports.startLinkedAccountRequestSchema = exports.linkedAccountNetworkSchema = exports.LINKED_ACCOUNT_NETWORKS = void 0;
|
|
14
|
+
exports.linkedAccountStartErrorDetailsSchema = exports.linkedAccountStartErrorReasonSchema = exports.LINKED_ACCOUNT_START_ERROR_REASONS = exports.LINKED_ACCOUNT_CALLBACK_ERRORS = exports.serviceLinkedAccountListResponseSchema = exports.serviceLinkedAccountSchema = exports.linkedAccountListResponseSchema = exports.completeLinkedAccountResponseSchema = exports.linkedAccountSchema = exports.completeLinkedAccountRequestSchema = exports.startLinkedAccountResponseSchema = exports.startLinkedAccountRequestSchema = exports.linkedAccountNetworkSchema = exports.LINKED_ACCOUNT_NETWORKS = void 0;
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
exports.LINKED_ACCOUNT_NETWORKS = ['activitypub', 'atproto'];
|
|
17
17
|
exports.linkedAccountNetworkSchema = zod_1.z.enum(exports.LINKED_ACCOUNT_NETWORKS);
|
|
@@ -91,3 +91,36 @@ exports.LINKED_ACCOUNT_CALLBACK_ERRORS = [
|
|
|
91
91
|
'verification_failed',
|
|
92
92
|
'provider_unavailable',
|
|
93
93
|
];
|
|
94
|
+
/**
|
|
95
|
+
* Why `POST /linked-accounts/:network/start` refused, as `details.reason` on
|
|
96
|
+
* its 400 (`{ error: 'BAD_REQUEST', message, details: { reason } }`). The
|
|
97
|
+
* message is for logs; show the user a text chosen from the reason.
|
|
98
|
+
*
|
|
99
|
+
* - `instance_invalid`: the ActivityPub `instance` is not a server name.
|
|
100
|
+
* - `instance_unreachable`: the server does not resolve to a public address, or
|
|
101
|
+
* could not be connected to.
|
|
102
|
+
* - `handle_unresolvable`: the atproto handle or DID does not resolve to an
|
|
103
|
+
* account. The only reason that means "check what you typed".
|
|
104
|
+
* - `provider_rejected`: the other network answered and refused Oxy's
|
|
105
|
+
* request — for atproto an authorization-server error such as
|
|
106
|
+
* `invalid_client_metadata`; for a Mastodon-API server a refused app
|
|
107
|
+
* registration (often: not a Mastodon-compatible server). Nothing the user
|
|
108
|
+
* typed is wrong.
|
|
109
|
+
* - `provider_unavailable`: the other network could not be asked right now
|
|
110
|
+
* (its OAuth metadata did not load, a 5xx, a timeout). Try again later.
|
|
111
|
+
*
|
|
112
|
+
* A refusal with no `details.reason` (a bad `returnTo`, a missing field) is a
|
|
113
|
+
* client bug, not something to show.
|
|
114
|
+
*/
|
|
115
|
+
exports.LINKED_ACCOUNT_START_ERROR_REASONS = [
|
|
116
|
+
'instance_invalid',
|
|
117
|
+
'instance_unreachable',
|
|
118
|
+
'handle_unresolvable',
|
|
119
|
+
'provider_rejected',
|
|
120
|
+
'provider_unavailable',
|
|
121
|
+
];
|
|
122
|
+
exports.linkedAccountStartErrorReasonSchema = zod_1.z.enum(exports.LINKED_ACCOUNT_START_ERROR_REASONS);
|
|
123
|
+
/** The `details` of a start refusal. */
|
|
124
|
+
exports.linkedAccountStartErrorDetailsSchema = zod_1.z
|
|
125
|
+
.object({ reason: exports.linkedAccountStartErrorReasonSchema })
|
|
126
|
+
.strict();
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Platform-agnostic — zod only, no react/react-native/expo.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.createOxyNotificationRequestSchema = exports.OXY_NOTIFICATION_URL_MAX = exports.OXY_SYSTEM_NOTIFICATION_MESSAGE_MAX = exports.OXY_SYSTEM_NOTIFICATION_TITLE_MAX = exports.OXY_NOTIFICATION_ENTITY_TYPES = exports.OXY_NOTIFICATION_TYPES = void 0;
|
|
15
|
+
exports.oxySystemNotificationPushDataSchema = exports.OXY_SYSTEM_NOTIFICATION_PUSH_TYPE = exports.OXY_ACCOUNT_PUSH_CHANNEL = exports.createOxyNotificationRequestSchema = exports.OXY_NOTIFICATION_URL_MAX = exports.OXY_SYSTEM_NOTIFICATION_MESSAGE_MAX = exports.OXY_SYSTEM_NOTIFICATION_TITLE_MAX = exports.OXY_NOTIFICATION_ENTITY_TYPES = exports.OXY_NOTIFICATION_TYPES = void 0;
|
|
16
16
|
const zod_1 = require("zod");
|
|
17
17
|
exports.OXY_NOTIFICATION_TYPES = [
|
|
18
18
|
'like',
|
|
@@ -79,3 +79,22 @@ exports.createOxyNotificationRequestSchema = zod_1.z
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
+
/**
|
|
83
|
+
* Android notification channel a `system` notification is pushed on — a wire
|
|
84
|
+
* contract, because Android 8+ silently drops a push whose channel the app has
|
|
85
|
+
* not created. Created by the vault (Commons) before it registers its token.
|
|
86
|
+
*/
|
|
87
|
+
exports.OXY_ACCOUNT_PUSH_CHANNEL = 'account';
|
|
88
|
+
/** Runtime type discriminator of the push that announces a `system` notification. */
|
|
89
|
+
exports.OXY_SYSTEM_NOTIFICATION_PUSH_TYPE = 'oxy_system_notification';
|
|
90
|
+
/**
|
|
91
|
+
* The ONLY data a `system` notification's push carries: its id. The title and
|
|
92
|
+
* message ride as the push's own title and body; the deep link does NOT travel,
|
|
93
|
+
* because a push payload is untrusted at the receiver. On a tap the vault
|
|
94
|
+
* re-reads the notification from Oxy by id (scoped to the signed-in recipient)
|
|
95
|
+
* and opens the `url` stored there.
|
|
96
|
+
*/
|
|
97
|
+
exports.oxySystemNotificationPushDataSchema = zod_1.z.object({
|
|
98
|
+
type: zod_1.z.literal(exports.OXY_SYSTEM_NOTIFICATION_PUSH_TYPE),
|
|
99
|
+
notificationId: zod_1.z.string().min(1).max(64),
|
|
100
|
+
});
|