@oxy.so/contracts 1.5.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 +8 -22
- 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 -1
- package/dist/esm/linkedAccounts.js +33 -0
- package/dist/esm/notifications.js +19 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/deviceDirectory.d.ts +46 -46
- package/dist/types/deviceSession.d.ts +2 -2
- package/dist/types/externalIdentity.d.ts +4 -4
- package/dist/types/federationInstanceFetch.d.ts +63 -0
- package/dist/types/index.d.ts +1 -2
- package/dist/types/inference/aliaModelRelease.d.ts +12 -12
- package/dist/types/inference/modelDocumentation.d.ts +16 -16
- package/dist/types/inference/providerConnection.d.ts +4 -4
- package/dist/types/linkedAccounts.d.ts +49 -16
- package/dist/types/notifications.d.ts +26 -0
- package/dist/types/oauth.d.ts +16 -16
- package/dist/types/sessionStatus.d.ts +6 -6
- package/dist/types/userResponse.d.ts +4 -4
- package/package.json +1 -1
- package/dist/cjs/browserHub.js +0 -215
- package/dist/esm/browserHub.js +0 -212
- package/dist/types/browserHub.d.ts +0 -856
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract for `POST /federation/instance-fetch/sign`: Oxy's INSTANCE
|
|
3
|
+
* actor signs one ActivityPub GET for a first-party service, so the service can
|
|
4
|
+
* read an instance running in authorized-fetch ("secure") mode without holding
|
|
5
|
+
* a key.
|
|
6
|
+
*
|
|
7
|
+
* The caller sends a URL, never a signing string: Oxy builds the string itself
|
|
8
|
+
* (`(request-target): get <path>`, `host`, `date`), the method is always GET
|
|
9
|
+
* and the key is always the instance actor's. The caller sends the returned
|
|
10
|
+
* headers, unchanged, on exactly that URL, within the few minutes remote
|
|
11
|
+
* servers accept a `Date` for. A redirect is a new URL and needs a new
|
|
12
|
+
* signature.
|
|
13
|
+
*
|
|
14
|
+
* Needs a service token whose application holds the privileged
|
|
15
|
+
* `federation:instance-fetch` scope.
|
|
16
|
+
*
|
|
17
|
+
* Platform-agnostic — zod only.
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
/** The longest URL Oxy will sign (the same cap as its own safe fetch). */
|
|
21
|
+
export const INSTANCE_FETCH_MAX_URL_LENGTH = 2048;
|
|
22
|
+
export const instanceFetchSignRequestSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
/** The absolute public `https://` URL the caller is about to GET. */
|
|
25
|
+
url: z.string().trim().min(1).max(INSTANCE_FETCH_MAX_URL_LENGTH),
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
export const instanceFetchSignResponseSchema = z
|
|
29
|
+
.object({
|
|
30
|
+
/** The instance actor's key, e.g. `https://oxy.so/ap/users/instance#main-key`. */
|
|
31
|
+
keyId: z.string().url(),
|
|
32
|
+
/** Send all three on the GET, as they are. */
|
|
33
|
+
headers: z
|
|
34
|
+
.object({
|
|
35
|
+
Host: z.string().min(1),
|
|
36
|
+
Date: z.string().min(1),
|
|
37
|
+
Signature: z.string().min(1),
|
|
38
|
+
})
|
|
39
|
+
.strict(),
|
|
40
|
+
})
|
|
41
|
+
.strict();
|
package/dist/esm/index.js
CHANGED
|
@@ -70,7 +70,6 @@ reputationPersonhoodSchema, reputationContributionSchema, reputationConductSchem
|
|
|
70
70
|
export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, deviceTokenMintRequestSchema, deviceTokenMintResponseSchema, deviceBackgroundCredentialResponseSchema, deviceBackgroundTokenRequestSchema, deviceBackgroundTokenResponseSchema, SESSION_ACCOUNTS_CHANGED_EVENT, sessionAccountsChangedReasonSchema, sessionAccountsChangedEventSchema, } from './deviceSession.js';
|
|
71
71
|
export { deviceContextRelationshipSchema, deviceDirectoryProfileSchema, deviceAccountContextSchema, devicePrincipalSchema, deviceDirectorySchema, deviceActivateRequestSchema, deviceActivateResponseSchema, deviceDirectorySyncSchema, } from './deviceDirectory.js';
|
|
72
72
|
export { oauthConsentDecisionSchema, oauthAuthorizeCodeResponseSchema, mcpOAuthClientApplicationSchema, mcpOAuthWriteActionSchema, mcpOAuthConsentContextSchema, mcpOAuthClientInfoResponseSchema, mcpOAuthConsentResponseSchema, } from './oauth.js';
|
|
73
|
-
export { BROWSER_HUB_COOKIE_NAME, BROWSER_HUB_COOKIE_ATTRIBUTES, BROWSER_HUB_HANDLE_TTL_MS, browserHubHandleSchema, browserHubHandleRequestSchema, browserHubHandleResponseSchema, browserHubResolveResponseSchema, browserHubErrorSchema, browserHubRevokeResponseSchema, hubSessionSchema, hubClaimRequestSchema, hubActivateRequestSchema, hubAuthorizeRequestSchema, hubAuthorizeResultSchema, } from './browserHub.js';
|
|
74
73
|
export {
|
|
75
74
|
// Schemas
|
|
76
75
|
loginResultSchema, } from './deviceBoot.js';
|
|
@@ -179,4 +178,5 @@ export { emailContextAddressSchema, emailContextMailboxSchema, emailContextMessa
|
|
|
179
178
|
export { inboxComposeRequestSchema, inboxDailyBriefRequestSchema, inboxNaturalSearchRequestSchema, inboxMessageInferenceParamsSchema, inboxInferenceTextResponseSchema, inboxNaturalSearchResponseSchema, inboxSmartRepliesResponseSchema, inboxThreadSummaryResponseSchema, inboxInferenceStreamEventSchema, } from './inference/inbox.js';
|
|
180
179
|
export * from './externalIdentity.js';
|
|
181
180
|
export * from './linkedAccounts.js';
|
|
181
|
+
export * from './federationInstanceFetch.js';
|
|
182
182
|
export * from './notifications.js';
|
|
@@ -88,3 +88,36 @@ export const LINKED_ACCOUNT_CALLBACK_ERRORS = [
|
|
|
88
88
|
'verification_failed',
|
|
89
89
|
'provider_unavailable',
|
|
90
90
|
];
|
|
91
|
+
/**
|
|
92
|
+
* Why `POST /linked-accounts/:network/start` refused, as `details.reason` on
|
|
93
|
+
* its 400 (`{ error: 'BAD_REQUEST', message, details: { reason } }`). The
|
|
94
|
+
* message is for logs; show the user a text chosen from the reason.
|
|
95
|
+
*
|
|
96
|
+
* - `instance_invalid`: the ActivityPub `instance` is not a server name.
|
|
97
|
+
* - `instance_unreachable`: the server does not resolve to a public address, or
|
|
98
|
+
* could not be connected to.
|
|
99
|
+
* - `handle_unresolvable`: the atproto handle or DID does not resolve to an
|
|
100
|
+
* account. The only reason that means "check what you typed".
|
|
101
|
+
* - `provider_rejected`: the other network answered and refused Oxy's
|
|
102
|
+
* request — for atproto an authorization-server error such as
|
|
103
|
+
* `invalid_client_metadata`; for a Mastodon-API server a refused app
|
|
104
|
+
* registration (often: not a Mastodon-compatible server). Nothing the user
|
|
105
|
+
* typed is wrong.
|
|
106
|
+
* - `provider_unavailable`: the other network could not be asked right now
|
|
107
|
+
* (its OAuth metadata did not load, a 5xx, a timeout). Try again later.
|
|
108
|
+
*
|
|
109
|
+
* A refusal with no `details.reason` (a bad `returnTo`, a missing field) is a
|
|
110
|
+
* client bug, not something to show.
|
|
111
|
+
*/
|
|
112
|
+
export const LINKED_ACCOUNT_START_ERROR_REASONS = [
|
|
113
|
+
'instance_invalid',
|
|
114
|
+
'instance_unreachable',
|
|
115
|
+
'handle_unresolvable',
|
|
116
|
+
'provider_rejected',
|
|
117
|
+
'provider_unavailable',
|
|
118
|
+
];
|
|
119
|
+
export const linkedAccountStartErrorReasonSchema = z.enum(LINKED_ACCOUNT_START_ERROR_REASONS);
|
|
120
|
+
/** The `details` of a start refusal. */
|
|
121
|
+
export const linkedAccountStartErrorDetailsSchema = z
|
|
122
|
+
.object({ reason: linkedAccountStartErrorReasonSchema })
|
|
123
|
+
.strict();
|
|
@@ -76,3 +76,22 @@ export const createOxyNotificationRequestSchema = z
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* Android notification channel a `system` notification is pushed on — a wire
|
|
81
|
+
* contract, because Android 8+ silently drops a push whose channel the app has
|
|
82
|
+
* not created. Created by the vault (Commons) before it registers its token.
|
|
83
|
+
*/
|
|
84
|
+
export const OXY_ACCOUNT_PUSH_CHANNEL = 'account';
|
|
85
|
+
/** Runtime type discriminator of the push that announces a `system` notification. */
|
|
86
|
+
export const OXY_SYSTEM_NOTIFICATION_PUSH_TYPE = 'oxy_system_notification';
|
|
87
|
+
/**
|
|
88
|
+
* The ONLY data a `system` notification's push carries: its id. The title and
|
|
89
|
+
* message ride as the push's own title and body; the deep link does NOT travel,
|
|
90
|
+
* because a push payload is untrusted at the receiver. On a tap the vault
|
|
91
|
+
* re-reads the notification from Oxy by id (scoped to the signed-in recipient)
|
|
92
|
+
* and opens the `url` stored there.
|
|
93
|
+
*/
|
|
94
|
+
export const oxySystemNotificationPushDataSchema = z.object({
|
|
95
|
+
type: z.literal(OXY_SYSTEM_NOTIFICATION_PUSH_TYPE),
|
|
96
|
+
notificationId: z.string().min(1).max(64),
|
|
97
|
+
});
|