@oxy.so/contracts 1.4.0 → 2.0.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/index.js +9 -22
- package/dist/cjs/linkedAccounts.js +93 -0
- package/dist/cjs/notifications.js +81 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/linkedAccounts.js +90 -0
- package/dist/esm/notifications.js +78 -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/index.d.ts +2 -2
- package/dist/types/inference/aliaModelRelease.d.ts +4 -4
- package/dist/types/inference/modelDocumentation.d.ts +8 -8
- package/dist/types/inference/providerConnection.d.ts +4 -4
- package/dist/types/linkedAccounts.d.ts +341 -0
- package/dist/types/notifications.d.ts +93 -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
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';
|
|
@@ -178,3 +177,5 @@ export { AUTONOMY_LEVELS, CAPABILITY_PACKAGES, autonomyLevelSchema, capabilityPa
|
|
|
178
177
|
export { emailContextAddressSchema, emailContextMailboxSchema, emailContextMessageSchema, emailAgentContextSchema, } from './emailAgentContext.js';
|
|
179
178
|
export { inboxComposeRequestSchema, inboxDailyBriefRequestSchema, inboxNaturalSearchRequestSchema, inboxMessageInferenceParamsSchema, inboxInferenceTextResponseSchema, inboxNaturalSearchResponseSchema, inboxSmartRepliesResponseSchema, inboxThreadSummaryResponseSchema, inboxInferenceStreamEventSchema, } from './inference/inbox.js';
|
|
180
179
|
export * from './externalIdentity.js';
|
|
180
|
+
export * from './linkedAccounts.js';
|
|
181
|
+
export * from './notifications.js';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract for Oxy linked accounts — external accounts (any Mastodon-API
|
|
3
|
+
* server, Bluesky) a LOCAL Oxy user has proven they own by completing an OAuth
|
|
4
|
+
* authorization there.
|
|
5
|
+
*
|
|
6
|
+
* Every response schema is `.strict()` and carries no field a third-party token
|
|
7
|
+
* could occupy: Oxy uses the OAuth flow only to learn which account authorized
|
|
8
|
+
* it, then discards the token. See `docs/identity/linked-accounts.md`.
|
|
9
|
+
*
|
|
10
|
+
* Platform-agnostic — zod only, no react/react-native/expo.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
export const LINKED_ACCOUNT_NETWORKS = ['activitypub', 'atproto'];
|
|
14
|
+
export const linkedAccountNetworkSchema = z.enum(LINKED_ACCOUNT_NETWORKS);
|
|
15
|
+
/**
|
|
16
|
+
* `POST /linked-accounts/:network/start`.
|
|
17
|
+
*
|
|
18
|
+
* - `instance` (activitypub): `mastodon.social`, `https://mastodon.social` or
|
|
19
|
+
* `@user@mastodon.social`.
|
|
20
|
+
* - `handle` (atproto): a handle (`alice.bsky.social`) or a DID.
|
|
21
|
+
* - `returnTo` + `clientId`: where the browser lands afterwards, with
|
|
22
|
+
* `?link_code=` or `?link_error=`. `returnTo` must exactly match a redirect
|
|
23
|
+
* URI registered on the TRUSTED (first-party) application `clientId` names.
|
|
24
|
+
*/
|
|
25
|
+
export const startLinkedAccountRequestSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
instance: z.string().trim().min(1).max(320).optional(),
|
|
28
|
+
handle: z.string().trim().min(1).max(320).optional(),
|
|
29
|
+
clientId: z.string().trim().min(1).max(256),
|
|
30
|
+
returnTo: z.string().trim().min(1).max(2048),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export const startLinkedAccountResponseSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
authorizeUrl: z.string().url(),
|
|
36
|
+
expiresAt: z.string().datetime(),
|
|
37
|
+
})
|
|
38
|
+
.strict();
|
|
39
|
+
/**
|
|
40
|
+
* `POST /linked-accounts/complete`, with the session of the user who STARTED
|
|
41
|
+
* the flow: `code` is the one-time `link_code` the callback appended to
|
|
42
|
+
* `returnTo`. It expires five minutes after the callback. Presented by any
|
|
43
|
+
* other user it is refused (403) and burned.
|
|
44
|
+
*/
|
|
45
|
+
export const completeLinkedAccountRequestSchema = z
|
|
46
|
+
.object({ code: z.string().trim().min(1).max(256) })
|
|
47
|
+
.strict();
|
|
48
|
+
/** One live linked account, as its owner sees it. */
|
|
49
|
+
export const linkedAccountSchema = z
|
|
50
|
+
.object({
|
|
51
|
+
id: z.string().min(1),
|
|
52
|
+
network: linkedAccountNetworkSchema,
|
|
53
|
+
/** `username@domain` for ActivityPub; the DID for atproto. */
|
|
54
|
+
accountKey: z.string().min(1),
|
|
55
|
+
/** ActivityPub actor id, or the DID for atproto. */
|
|
56
|
+
actorUri: z.string().min(1),
|
|
57
|
+
handle: z.string().min(1),
|
|
58
|
+
host: z.string().min(1),
|
|
59
|
+
proofMethod: z.literal('oauth'),
|
|
60
|
+
verifiedAt: z.string().datetime(),
|
|
61
|
+
createdAt: z.string().datetime(),
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
export const completeLinkedAccountResponseSchema = z
|
|
65
|
+
.object({ linkedAccount: linkedAccountSchema })
|
|
66
|
+
.strict();
|
|
67
|
+
export const linkedAccountListResponseSchema = z
|
|
68
|
+
.object({ linkedAccounts: z.array(linkedAccountSchema) })
|
|
69
|
+
.strict();
|
|
70
|
+
/**
|
|
71
|
+
* `GET /linked-accounts/by-user/:userId` (service token with the privileged
|
|
72
|
+
* `linked-accounts:read`). Adds `federatedUserId`: the FEDERATED shadow user Oxy
|
|
73
|
+
* already holds for that external account, if any — the anchor for adopting
|
|
74
|
+
* content Oxy federated in before the account was linked.
|
|
75
|
+
*/
|
|
76
|
+
export const serviceLinkedAccountSchema = linkedAccountSchema
|
|
77
|
+
.extend({ federatedUserId: z.string().min(1).nullable() })
|
|
78
|
+
.strict();
|
|
79
|
+
export const serviceLinkedAccountListResponseSchema = z
|
|
80
|
+
.object({ userId: z.string().min(1), linkedAccounts: z.array(serviceLinkedAccountSchema) })
|
|
81
|
+
.strict();
|
|
82
|
+
/**
|
|
83
|
+
* Error codes the callback appends as `?link_error=<code>` to `returnTo`. An
|
|
84
|
+
* account already linked to someone else is reported by `/complete` (409).
|
|
85
|
+
*/
|
|
86
|
+
export const LINKED_ACCOUNT_CALLBACK_ERRORS = [
|
|
87
|
+
'access_denied',
|
|
88
|
+
'verification_failed',
|
|
89
|
+
'provider_unavailable',
|
|
90
|
+
];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed set of Oxy in-app notification types — owned here so the API's
|
|
3
|
+
* CHECK constraint (`notifications.type`), its request validation and the SDK
|
|
4
|
+
* all read one tuple.
|
|
5
|
+
*
|
|
6
|
+
* `system` is a message from an Oxy service about the recipient's OWN account
|
|
7
|
+
* (Oxy Move's "your migration finished"): the actor is the recipient, and the
|
|
8
|
+
* entity is their profile or an `app` id. It is the only type an actor does not
|
|
9
|
+
* cause.
|
|
10
|
+
*
|
|
11
|
+
* Platform-agnostic — zod only, no react/react-native/expo.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
export const OXY_NOTIFICATION_TYPES = [
|
|
15
|
+
'like',
|
|
16
|
+
'reply',
|
|
17
|
+
'mention',
|
|
18
|
+
'follow',
|
|
19
|
+
'repost',
|
|
20
|
+
'quote',
|
|
21
|
+
'welcome',
|
|
22
|
+
'system',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* What a notification's `entityId` names.
|
|
26
|
+
*
|
|
27
|
+
* `app` means `entityId` is an OPAQUE id in the notifying application's own
|
|
28
|
+
* namespace (Oxy Move's migration job id). Oxy never resolves it; it exists so
|
|
29
|
+
* a `system` notification about something that is not a post or a profile does
|
|
30
|
+
* not have to pretend to be one. Valid only with `type: 'system'`.
|
|
31
|
+
*/
|
|
32
|
+
export const OXY_NOTIFICATION_ENTITY_TYPES = ['post', 'reply', 'profile', 'app'];
|
|
33
|
+
/** Length caps on the text a `system` notification carries (enforced by CHECKs too). */
|
|
34
|
+
export const OXY_SYSTEM_NOTIFICATION_TITLE_MAX = 120;
|
|
35
|
+
export const OXY_SYSTEM_NOTIFICATION_MESSAGE_MAX = 500;
|
|
36
|
+
export const OXY_NOTIFICATION_URL_MAX = 2048;
|
|
37
|
+
/**
|
|
38
|
+
* `POST /notifications` (service token with `notifications:write`).
|
|
39
|
+
*
|
|
40
|
+
* Only a `system` notification carries text: `title` and `message` are REQUIRED
|
|
41
|
+
* for it and stored, and `url` is an optional deep link (https, or a custom
|
|
42
|
+
* scheme registered as a redirect URI on the calling application). For every
|
|
43
|
+
* other type the client renders from `type` + entity, and `title` / `message` /
|
|
44
|
+
* `data` are accepted but discarded, as they always were.
|
|
45
|
+
*
|
|
46
|
+
* `system` notifications share the duplicate guard (recipient, actor, type,
|
|
47
|
+
* entityId): use a caller-unique `entityId` (a job id) for each distinct event.
|
|
48
|
+
*/
|
|
49
|
+
export const createOxyNotificationRequestSchema = z
|
|
50
|
+
.object({
|
|
51
|
+
recipientId: z.string().min(1),
|
|
52
|
+
actorId: z.string().min(1),
|
|
53
|
+
type: z.enum(OXY_NOTIFICATION_TYPES),
|
|
54
|
+
entityId: z.string().min(1),
|
|
55
|
+
entityType: z.enum(OXY_NOTIFICATION_ENTITY_TYPES),
|
|
56
|
+
title: z.string().trim().min(1).max(OXY_SYSTEM_NOTIFICATION_TITLE_MAX).optional(),
|
|
57
|
+
message: z.string().trim().min(1).max(OXY_SYSTEM_NOTIFICATION_MESSAGE_MAX).optional(),
|
|
58
|
+
url: z.string().trim().min(1).max(OXY_NOTIFICATION_URL_MAX).optional(),
|
|
59
|
+
data: z.record(z.string(), z.unknown()).optional(),
|
|
60
|
+
})
|
|
61
|
+
.superRefine((value, context) => {
|
|
62
|
+
if (value.type === 'system') {
|
|
63
|
+
if (value.actorId !== value.recipientId)
|
|
64
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ['actorId'], message: 'a system notification is from the recipient\'s own account' });
|
|
65
|
+
if (!value.title)
|
|
66
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ['title'], message: 'title is required for a system notification' });
|
|
67
|
+
if (!value.message)
|
|
68
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ['message'], message: 'message is required for a system notification' });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (value.url !== undefined) {
|
|
72
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ['url'], message: 'url is only stored for a system notification' });
|
|
73
|
+
}
|
|
74
|
+
if (value.entityType === 'app') {
|
|
75
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ['entityType'], message: "entityType 'app' is only valid for a system notification" });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|