@oxy.so/contracts 4.16.0 → 4.21.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/accountAccess.js +72 -0
- package/dist/cjs/accountEmail.js +12 -34
- package/dist/cjs/accountGraph.js +22 -320
- package/dist/cjs/agency.js +112 -1
- package/dist/cjs/agentKeys.js +11 -13
- package/dist/cjs/applicationRoles.js +211 -0
- package/dist/cjs/client/accountEmail.js +48 -0
- package/dist/cjs/client/accountGraph.js +323 -0
- package/dist/cjs/client/agentKeys.js +77 -0
- package/dist/cjs/client/check.js +475 -0
- package/dist/cjs/client/deviceBoot.js +22 -0
- package/dist/cjs/client/deviceDirectory.js +51 -0
- package/dist/cjs/client/deviceSession.js +63 -0
- package/dist/cjs/client/externalIdentity.js +19 -0
- package/dist/cjs/client/identity.js +45 -0
- package/dist/cjs/client/identityLink.js +55 -0
- package/dist/cjs/client/identityProof.js +109 -0
- package/dist/cjs/client/index.js +211 -0
- package/dist/cjs/client/organizations.js +114 -0
- package/dist/cjs/client/products.js +153 -0
- package/dist/cjs/client/recommendations.js +33 -0
- package/dist/cjs/client/reputation.js +41 -0
- package/dist/cjs/client/safety.js +196 -0
- package/dist/cjs/client/sessionStatus.js +23 -0
- package/dist/cjs/client/signIn.js +159 -0
- package/dist/cjs/client/userResponse.js +15 -0
- package/dist/cjs/client/username.js +173 -0
- package/dist/cjs/deviceSession.js +3 -16
- package/dist/cjs/identityLink.js +13 -34
- package/dist/cjs/identityProof.js +18 -106
- package/dist/cjs/index.js +13 -3
- package/dist/cjs/organizations.js +21 -41
- package/dist/cjs/reputation.js +3 -34
- package/dist/cjs/safety.js +430 -1
- package/dist/cjs/serviceToken.js +14 -0
- package/dist/cjs/signIn.js +33 -111
- package/dist/cjs/username.js +23 -158
- package/dist/esm/accountAccess.js +69 -0
- package/dist/esm/accountEmail.js +4 -32
- package/dist/esm/accountGraph.js +4 -309
- package/dist/esm/agency.js +111 -0
- package/dist/esm/agentKeys.js +4 -10
- package/dist/esm/applicationRoles.js +207 -0
- package/dist/esm/client/accountEmail.js +45 -0
- package/dist/esm/client/accountGraph.js +314 -0
- package/dist/esm/client/agentKeys.js +74 -0
- package/dist/esm/client/check.js +436 -0
- package/dist/esm/client/deviceBoot.js +19 -0
- package/dist/esm/client/deviceDirectory.js +48 -0
- package/dist/esm/client/deviceSession.js +60 -0
- package/dist/esm/client/externalIdentity.js +16 -0
- package/dist/esm/client/identity.js +42 -0
- package/dist/esm/client/identityLink.js +50 -0
- package/dist/esm/client/identityProof.js +104 -0
- package/dist/esm/client/index.js +37 -0
- package/dist/esm/client/organizations.js +111 -0
- package/dist/esm/client/products.js +150 -0
- package/dist/esm/client/recommendations.js +30 -0
- package/dist/esm/client/reputation.js +37 -0
- package/dist/esm/client/safety.js +193 -0
- package/dist/esm/client/sessionStatus.js +20 -0
- package/dist/esm/client/signIn.js +153 -0
- package/dist/esm/client/userResponse.js +12 -0
- package/dist/esm/client/username.js +167 -0
- package/dist/esm/deviceSession.js +1 -15
- package/dist/esm/identityLink.js +4 -27
- package/dist/esm/identityProof.js +4 -99
- package/dist/esm/index.js +4 -1
- package/dist/esm/organizations.js +4 -31
- package/dist/esm/reputation.js +1 -32
- package/dist/esm/safety.js +423 -0
- package/dist/esm/serviceToken.js +11 -0
- package/dist/esm/signIn.js +4 -96
- package/dist/esm/username.js +4 -148
- package/dist/types/accountAccess.d.ts +128 -0
- package/dist/types/accountEmail.d.ts +4 -36
- package/dist/types/accountGraph.d.ts +12 -208
- package/dist/types/agency.d.ts +351 -26
- package/dist/types/agentKeys.d.ts +14 -12
- package/dist/types/applicationRoles.d.ts +438 -0
- package/dist/types/client/accountEmail.d.ts +44 -0
- package/dist/types/client/accountGraph.d.ts +203 -0
- package/dist/types/client/agentKeys.d.ts +113 -0
- package/dist/types/client/check.d.ts +187 -0
- package/dist/types/client/deviceBoot.d.ts +6 -0
- package/dist/types/client/deviceDirectory.d.ts +134 -0
- package/dist/types/client/deviceSession.d.ts +91 -0
- package/dist/types/client/externalIdentity.d.ts +14 -0
- package/dist/types/client/identity.d.ts +8 -0
- package/dist/types/client/identityLink.d.ts +21 -0
- package/dist/types/client/identityProof.d.ts +73 -0
- package/dist/types/client/index.d.ts +37 -0
- package/dist/types/client/organizations.d.ts +167 -0
- package/dist/types/client/products.d.ts +145 -0
- package/dist/types/client/recommendations.d.ts +27 -0
- package/dist/types/client/reputation.d.ts +28 -0
- package/dist/types/client/safety.d.ts +213 -0
- package/dist/types/client/sessionStatus.d.ts +19 -0
- package/dist/types/client/signIn.d.ts +107 -0
- package/dist/types/client/userResponse.d.ts +7 -0
- package/dist/types/client/username.d.ts +126 -0
- package/dist/types/deviceDirectory.d.ts +28 -28
- package/dist/types/deviceSession.d.ts +5 -16
- package/dist/types/email/messages.d.ts +2 -2
- package/dist/types/externalIdentity.d.ts +15 -15
- package/dist/types/identityLink.d.ts +3 -11
- package/dist/types/identityProof.d.ts +2 -65
- package/dist/types/index.d.ts +5 -2
- package/dist/types/inference/accountBilling.d.ts +2 -2
- package/dist/types/inference/catalogue.d.ts +22 -22
- package/dist/types/inference/decisions.d.ts +10 -10
- package/dist/types/inference/embeddings.d.ts +16 -16
- package/dist/types/inference/errors.d.ts +8 -8
- package/dist/types/inference/inbox.d.ts +8 -8
- package/dist/types/inference/privateAutoExecution.d.ts +6 -6
- package/dist/types/inference/providerConnection.d.ts +4 -4
- package/dist/types/inference/realtime.d.ts +92 -92
- package/dist/types/inference/request.d.ts +48 -48
- package/dist/types/inference/streamEvents.d.ts +16 -16
- package/dist/types/inference/usage.d.ts +4 -4
- package/dist/types/oauth.d.ts +2 -2
- package/dist/types/organizations.d.ts +8 -10
- package/dist/types/products/access.d.ts +4 -4
- package/dist/types/products/billing.d.ts +3 -0
- package/dist/types/reputation.d.ts +1 -11
- package/dist/types/safety.d.ts +2374 -2
- package/dist/types/serviceToken.d.ts +11 -0
- package/dist/types/sessionStatus.d.ts +2 -2
- package/dist/types/signIn.d.ts +11 -94
- package/dist/types/userResponse.d.ts +22 -22
- package/dist/types/username.d.ts +1 -96
- package/package.json +24 -20
- package/dist/cjs/.tsbuildinfo +0 -1
- package/dist/esm/.tsbuildinfo +0 -1
- package/dist/types/.tsbuildinfo +0 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safety and supervision checks, without Zod. Schemas: `../safety.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Only what a browser or device sends and reads is here: the profile-access
|
|
5
|
+
* read, supervision management and the guardian's purchase review. The service
|
|
6
|
+
* decision lanes are server-only (`@oxy.so/core/server`) and parse with the
|
|
7
|
+
* Zod schemas directly.
|
|
8
|
+
*
|
|
9
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
10
|
+
*/
|
|
11
|
+
import { type Check } from './check';
|
|
12
|
+
/** Supervision is a personal-account safety policy, never a new login/account kind. */
|
|
13
|
+
export declare const SUPERVISED_ACTIONS: readonly ["profile", "messaging", "content", "purchases"];
|
|
14
|
+
export declare const SAFETY_POLICY_VERSION: "2";
|
|
15
|
+
export declare const SUPERVISION_CONSENT_VERSION: "1";
|
|
16
|
+
export declare const SUPERVISION_STATUSES: readonly ["active", "orphaned", "ended"];
|
|
17
|
+
export declare const SUPERVISION_INVITATION_STATUSES: readonly ["pending", "accepted", "cancelled"];
|
|
18
|
+
export declare const PURCHASE_APPROVAL_STATUSES: readonly ["pending", "approved", "rejected", "reserved", "confirmed", "cancelled"];
|
|
19
|
+
export declare const profileAccessInputCheck: Check<{
|
|
20
|
+
subjectAccountId: string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const profileAccessDecisionCheck: Check<{
|
|
23
|
+
allowed: boolean;
|
|
24
|
+
reason: "owner" | "unavailable" | "public" | "private" | "blocked";
|
|
25
|
+
policyVersion: "1";
|
|
26
|
+
}>;
|
|
27
|
+
export declare const supervisionInvitationCheck: Check<{
|
|
28
|
+
status: "pending" | "accepted" | "cancelled";
|
|
29
|
+
createdAt: string;
|
|
30
|
+
id: string;
|
|
31
|
+
expiresAt: string;
|
|
32
|
+
childAccountId: string;
|
|
33
|
+
guardianAccountId: string;
|
|
34
|
+
consentVersion: "1";
|
|
35
|
+
}>;
|
|
36
|
+
export declare const supervisionStateCheck: Check<{
|
|
37
|
+
self: {
|
|
38
|
+
status: "active" | "orphaned" | "ended";
|
|
39
|
+
createdAt: string;
|
|
40
|
+
policyVersion: "2";
|
|
41
|
+
childAccountId: string;
|
|
42
|
+
guardianAccountId: string | null;
|
|
43
|
+
consentVersion: "1";
|
|
44
|
+
} | null;
|
|
45
|
+
children: {
|
|
46
|
+
status: "active" | "orphaned" | "ended";
|
|
47
|
+
createdAt: string;
|
|
48
|
+
policyVersion: "2";
|
|
49
|
+
childAccountId: string;
|
|
50
|
+
guardianAccountId: string | null;
|
|
51
|
+
consentVersion: "1";
|
|
52
|
+
}[];
|
|
53
|
+
invitations: {
|
|
54
|
+
status: "pending" | "accepted" | "cancelled";
|
|
55
|
+
createdAt: string;
|
|
56
|
+
id: string;
|
|
57
|
+
expiresAt: string;
|
|
58
|
+
childAccountId: string;
|
|
59
|
+
guardianAccountId: string;
|
|
60
|
+
consentVersion: "1";
|
|
61
|
+
}[];
|
|
62
|
+
}>;
|
|
63
|
+
export declare const supervisionContactsResponseCheck: Check<{
|
|
64
|
+
items: {
|
|
65
|
+
childAccountId: string;
|
|
66
|
+
contactAccountId: string;
|
|
67
|
+
approvedAt: string;
|
|
68
|
+
}[];
|
|
69
|
+
}>;
|
|
70
|
+
export declare const supervisionInviteInputCheck: Check<{
|
|
71
|
+
reauth: {
|
|
72
|
+
password?: string | undefined;
|
|
73
|
+
emailCode?: {
|
|
74
|
+
code: string;
|
|
75
|
+
verificationId: string;
|
|
76
|
+
} | undefined;
|
|
77
|
+
totpCode?: string | undefined;
|
|
78
|
+
};
|
|
79
|
+
guardianAccountId: string;
|
|
80
|
+
consentVersion: "1";
|
|
81
|
+
}>;
|
|
82
|
+
export declare const supervisionAcceptInputCheck: Check<{
|
|
83
|
+
reauth: {
|
|
84
|
+
password?: string | undefined;
|
|
85
|
+
emailCode?: {
|
|
86
|
+
code: string;
|
|
87
|
+
verificationId: string;
|
|
88
|
+
} | undefined;
|
|
89
|
+
totpCode?: string | undefined;
|
|
90
|
+
};
|
|
91
|
+
consentVersion: "1";
|
|
92
|
+
}>;
|
|
93
|
+
export declare const supervisionContactInputCheck: Check<{
|
|
94
|
+
reauth: {
|
|
95
|
+
password?: string | undefined;
|
|
96
|
+
emailCode?: {
|
|
97
|
+
code: string;
|
|
98
|
+
verificationId: string;
|
|
99
|
+
} | undefined;
|
|
100
|
+
totpCode?: string | undefined;
|
|
101
|
+
};
|
|
102
|
+
childAccountId: string;
|
|
103
|
+
contactAccountId: string;
|
|
104
|
+
}>;
|
|
105
|
+
export declare const supervisionReviewInputCheck: Check<{
|
|
106
|
+
evidenceReference: string;
|
|
107
|
+
reauth: {
|
|
108
|
+
password?: string | undefined;
|
|
109
|
+
emailCode?: {
|
|
110
|
+
code: string;
|
|
111
|
+
verificationId: string;
|
|
112
|
+
} | undefined;
|
|
113
|
+
totpCode?: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
action: "end" | "transfer";
|
|
116
|
+
childAccountId: string;
|
|
117
|
+
guardianAccountId?: string | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
export declare const safetyPeopleInputCheck: Check<{
|
|
120
|
+
query: string;
|
|
121
|
+
} | {
|
|
122
|
+
accountIds: string[];
|
|
123
|
+
}>;
|
|
124
|
+
export declare const safetyPeopleResponseCheck: Check<{
|
|
125
|
+
items: {
|
|
126
|
+
accountId: string;
|
|
127
|
+
username: string | null;
|
|
128
|
+
displayName: string | null;
|
|
129
|
+
}[];
|
|
130
|
+
}>;
|
|
131
|
+
export declare const safetyOrganizationsInputCheck: Check<{
|
|
132
|
+
query: string;
|
|
133
|
+
limit?: number | undefined;
|
|
134
|
+
} | {
|
|
135
|
+
ids: string[];
|
|
136
|
+
}>;
|
|
137
|
+
export declare const safetyOrganizationsResponseCheck: Check<{
|
|
138
|
+
items: {
|
|
139
|
+
requestedAccountId: string;
|
|
140
|
+
organization: {
|
|
141
|
+
name: string;
|
|
142
|
+
organizationType: "business" | "nonprofit" | "public_body" | "community" | "other";
|
|
143
|
+
accountId: string;
|
|
144
|
+
username: string | null;
|
|
145
|
+
};
|
|
146
|
+
}[];
|
|
147
|
+
missingIds: string[];
|
|
148
|
+
}>;
|
|
149
|
+
export declare const purchaseApprovalCheck: Check<{
|
|
150
|
+
status: "pending" | "approved" | "rejected" | "cancelled" | "confirmed" | "reserved";
|
|
151
|
+
createdAt: string;
|
|
152
|
+
id: string;
|
|
153
|
+
expiresAt: string;
|
|
154
|
+
resourceId: string;
|
|
155
|
+
applicationId: string;
|
|
156
|
+
currency: string;
|
|
157
|
+
operationId: string;
|
|
158
|
+
summary: string;
|
|
159
|
+
childAccountId: string;
|
|
160
|
+
cartFingerprint: string;
|
|
161
|
+
merchantAccountIds: string[];
|
|
162
|
+
lineItems: {
|
|
163
|
+
title: string;
|
|
164
|
+
quantity: number;
|
|
165
|
+
itemReference: string;
|
|
166
|
+
optionsText: string;
|
|
167
|
+
merchantAccountId: string;
|
|
168
|
+
unitAmountMinor: number;
|
|
169
|
+
lineAmountMinor: number;
|
|
170
|
+
}[];
|
|
171
|
+
shippingMinor: number;
|
|
172
|
+
taxMinor: number;
|
|
173
|
+
discountMinor: number;
|
|
174
|
+
roundingAdjustmentMinor: number;
|
|
175
|
+
paymentFingerprint: string;
|
|
176
|
+
amountMinor: number;
|
|
177
|
+
receiptReference: string | null;
|
|
178
|
+
}>;
|
|
179
|
+
export declare const purchaseApprovalListCheck: Check<{
|
|
180
|
+
items: {
|
|
181
|
+
status: "pending" | "approved" | "rejected" | "cancelled" | "confirmed" | "reserved";
|
|
182
|
+
createdAt: string;
|
|
183
|
+
id: string;
|
|
184
|
+
expiresAt: string;
|
|
185
|
+
resourceId: string;
|
|
186
|
+
applicationId: string;
|
|
187
|
+
currency: string;
|
|
188
|
+
operationId: string;
|
|
189
|
+
summary: string;
|
|
190
|
+
childAccountId: string;
|
|
191
|
+
cartFingerprint: string;
|
|
192
|
+
merchantAccountIds: string[];
|
|
193
|
+
shippingMinor: number;
|
|
194
|
+
taxMinor: number;
|
|
195
|
+
discountMinor: number;
|
|
196
|
+
roundingAdjustmentMinor: number;
|
|
197
|
+
paymentFingerprint: string;
|
|
198
|
+
amountMinor: number;
|
|
199
|
+
receiptReference: string | null;
|
|
200
|
+
}[];
|
|
201
|
+
nextCursor: string | null;
|
|
202
|
+
}>;
|
|
203
|
+
export declare const purchaseReviewInputCheck: Check<{
|
|
204
|
+
decision: "approved" | "rejected";
|
|
205
|
+
reauth: {
|
|
206
|
+
password?: string | undefined;
|
|
207
|
+
emailCode?: {
|
|
208
|
+
code: string;
|
|
209
|
+
verificationId: string;
|
|
210
|
+
} | undefined;
|
|
211
|
+
totpCode?: string | undefined;
|
|
212
|
+
};
|
|
213
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public-application check, without Zod. Schemas: `../sessionStatus.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const publicApplicationCheck: import("./check").Check<{
|
|
7
|
+
type: "system" | "internal" | "first_party" | "third_party";
|
|
8
|
+
name: string;
|
|
9
|
+
id: string;
|
|
10
|
+
scopes: string[];
|
|
11
|
+
isOfficial: boolean;
|
|
12
|
+
isInternal: boolean;
|
|
13
|
+
websiteUrl?: string | undefined;
|
|
14
|
+
description?: string | undefined;
|
|
15
|
+
icon?: string | undefined;
|
|
16
|
+
privacyPolicyUrl?: string | undefined;
|
|
17
|
+
termsUrl?: string | undefined;
|
|
18
|
+
developerName?: string | undefined;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sign-in constants, guards and response checks, without Zod. Schemas: `../signIn.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
5
|
+
*/
|
|
6
|
+
import type { EmailSignInChooseAccount, EmailSignInLinkResponse, EmailSignInPending, EmailSignInStartResponse, EmailSignInStepResult, SecondFactorRequired, SignInMethods, TotpBackupCodesResponse, TotpEnrollResponse } from '../signIn';
|
|
7
|
+
/** How long the link in a sign-in email can be opened. */
|
|
8
|
+
export declare const EMAIL_SIGNIN_LINK_TTL_MS: number;
|
|
9
|
+
/** How long a second-factor challenge can be answered. */
|
|
10
|
+
export declare const SIGNIN_SECOND_FACTOR_TTL_MS: number;
|
|
11
|
+
/** Wrong second-factor codes one challenge accepts. */
|
|
12
|
+
export declare const SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = 5;
|
|
13
|
+
/** Shortest password Oxy accepts when one is set. */
|
|
14
|
+
export declare const PASSWORD_MIN_LENGTH = 10;
|
|
15
|
+
/** Longest password Oxy accepts (characters). */
|
|
16
|
+
export declare const PASSWORD_MAX_LENGTH = 256;
|
|
17
|
+
/** Digits in an authenticator code. */
|
|
18
|
+
export declare const TOTP_DIGITS = 6;
|
|
19
|
+
/** Seconds each authenticator code lasts. */
|
|
20
|
+
export declare const TOTP_PERIOD_SECONDS = 30;
|
|
21
|
+
/** Backup codes issued when an authenticator is enabled or they are regenerated. */
|
|
22
|
+
export declare const TOTP_BACKUP_CODE_COUNT = 10;
|
|
23
|
+
/**
|
|
24
|
+
* The long sign-in code: ten characters of Crockford base32 without the
|
|
25
|
+
* look-alikes (no 0, O, 1, I, L, U), shown as `XXXXX-XXXXX`. An account whose
|
|
26
|
+
* sign-in codes were guessed at too often today (the per-account ceiling) is
|
|
27
|
+
* sent this instead of 6 digits for the rest of the day, so its owner can still
|
|
28
|
+
* type a code while guessing one is infeasible.
|
|
29
|
+
*/
|
|
30
|
+
export declare const EMAIL_SIGNIN_LONG_CODE_ALPHABET = "23456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
31
|
+
export declare const EMAIL_SIGNIN_LONG_CODE_LENGTH = 10;
|
|
32
|
+
/**
|
|
33
|
+
* Normalise a typed sign-in code: 6 digits stay as they are; a long code is
|
|
34
|
+
* upper-cased with its dash and spaces removed. Anything else is returned
|
|
35
|
+
* trimmed (and will simply be wrong).
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeEmailSignInCode(code: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* How long, once the email is proven, the person has to choose which of its
|
|
40
|
+
* accounts signs in.
|
|
41
|
+
*/
|
|
42
|
+
export declare const EMAIL_SIGNIN_CHOICE_TTL_MS: number;
|
|
43
|
+
/** Most accounts one email can hold; sign-up refuses another past it. */
|
|
44
|
+
export declare const EMAIL_ACCOUNTS_MAX = 20;
|
|
45
|
+
/** Narrow a {@link SignInStepResult}. */
|
|
46
|
+
export declare function isSecondFactorRequired(result: EmailSignInStepResult | EmailSignInPending): result is SecondFactorRequired;
|
|
47
|
+
/** Narrow an {@link EmailSignInStepResult}. */
|
|
48
|
+
export declare function isEmailSignInChooseAccount(result: EmailSignInStepResult | EmailSignInPending): result is EmailSignInChooseAccount;
|
|
49
|
+
/**
|
|
50
|
+
* What a re-verification email code confirms. The code is bound to it: a code
|
|
51
|
+
* asked for one change never authorises another, and the email names it.
|
|
52
|
+
*/
|
|
53
|
+
export declare const REAUTH_ACTIONS: readonly ["change_password", "totp", "link_commons", "delete_account", "credentials_manage", "supervision", "supervision_purchase"];
|
|
54
|
+
export type ReauthAction = (typeof REAUTH_ACTIONS)[number];
|
|
55
|
+
/**
|
|
56
|
+
* Stable error codes (`error.code` in the API error body). Clients map these
|
|
57
|
+
* through their localization, never the English message.
|
|
58
|
+
*/
|
|
59
|
+
export declare const SIGN_IN_ERROR_CODES: {
|
|
60
|
+
/** Wrong identifier or password — never says which. */
|
|
61
|
+
readonly invalidCredentials: "SIGNIN_INVALID_CREDENTIALS";
|
|
62
|
+
/** The request is unknown, expired, spent, or its secret is wrong. */
|
|
63
|
+
readonly requestInvalid: "SIGNIN_REQUEST_INVALID";
|
|
64
|
+
/** The link is unknown, expired or already used. */
|
|
65
|
+
readonly linkInvalid: "SIGNIN_LINK_INVALID";
|
|
66
|
+
/** The link was opened in another browser: type the code in the app instead. */
|
|
67
|
+
readonly linkOtherDevice: "SIGNIN_LINK_OTHER_DEVICE";
|
|
68
|
+
/** The second-factor challenge or its code is wrong, expired or spent. */
|
|
69
|
+
readonly secondFactorInvalid: "SECOND_FACTOR_INVALID";
|
|
70
|
+
/** Too many failures for this account: wait and try again. */
|
|
71
|
+
readonly locked: "SIGNIN_LOCKED";
|
|
72
|
+
/** The step needs a fresh proof (`reauth`). */
|
|
73
|
+
readonly reauthRequired: "REAUTH_REQUIRED";
|
|
74
|
+
/** The fresh proof was wrong. */
|
|
75
|
+
readonly reauthInvalid: "REAUTH_INVALID";
|
|
76
|
+
/** The account has an authenticator: the proof must carry its code. */
|
|
77
|
+
readonly totpRequired: "TOTP_REQUIRED";
|
|
78
|
+
/** Enrolling or confirming an authenticator that is already on. */
|
|
79
|
+
readonly totpAlreadyEnabled: "TOTP_ALREADY_ENABLED";
|
|
80
|
+
/** Disabling, confirming or regenerating codes with no authenticator (or no pending one). */
|
|
81
|
+
readonly totpNotEnabled: "TOTP_NOT_ENABLED";
|
|
82
|
+
/** The code the authenticator showed at enrolment is wrong. */
|
|
83
|
+
readonly totpCodeInvalid: "TOTP_CODE_INVALID";
|
|
84
|
+
/** Only official Oxy apps and auth.oxy.so may sign people in here. */
|
|
85
|
+
readonly originNotAllowed: "SIGNIN_ORIGIN_NOT_ALLOWED";
|
|
86
|
+
/** The username is taken. */
|
|
87
|
+
readonly usernameTaken: "USERNAME_TAKEN";
|
|
88
|
+
/** The email already holds `EMAIL_ACCOUNTS_MAX` accounts: no sign-up adds another. */
|
|
89
|
+
readonly emailAccountsFull: "EMAIL_ACCOUNTS_FULL";
|
|
90
|
+
};
|
|
91
|
+
export type SignInErrorCode = (typeof SIGN_IN_ERROR_CODES)[keyof typeof SIGN_IN_ERROR_CODES];
|
|
92
|
+
export declare const emailSignInStartResponseCheck: import("./check").Check<EmailSignInStartResponse>;
|
|
93
|
+
export declare const emailSignInLinkResponseCheck: import("./check").Check<EmailSignInLinkResponse>;
|
|
94
|
+
export declare const secondFactorRequiredCheck: import("./check").Check<SecondFactorRequired>;
|
|
95
|
+
export declare const emailSignInPendingCheck: import("./check").Check<EmailSignInPending>;
|
|
96
|
+
export declare const emailSignInChooseAccountCheck: import("./check").Check<EmailSignInChooseAccount>;
|
|
97
|
+
export declare const signInMethodsCheck: import("./check").Check<SignInMethods>;
|
|
98
|
+
export declare const totpEnrollResponseCheck: import("./check").Check<TotpEnrollResponse>;
|
|
99
|
+
export declare const totpBackupCodesResponseCheck: import("./check").Check<TotpBackupCodesResponse>;
|
|
100
|
+
export declare const reauthProofCheck: import("./check").Check<{
|
|
101
|
+
password?: string | undefined;
|
|
102
|
+
emailCode?: {
|
|
103
|
+
code: string;
|
|
104
|
+
verificationId: string;
|
|
105
|
+
} | undefined;
|
|
106
|
+
totpCode?: string | undefined;
|
|
107
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-response checks, without Zod. Schemas: `../userResponse.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
5
|
+
*/
|
|
6
|
+
import type { UserNameResponse } from '../userResponse';
|
|
7
|
+
export declare const userNameCheck: import("./check").Check<UserNameResponse>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The username policy, without Zod. Schemas: `../username.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
|
|
5
|
+
*/
|
|
6
|
+
import type { AccountKind } from './accountGraph';
|
|
7
|
+
import { type Check } from './check';
|
|
8
|
+
/** Shortest storable handle. `oxy` sets the floor. */
|
|
9
|
+
export declare const USERNAME_MIN_LENGTH = 3;
|
|
10
|
+
/** Longest storable handle, and the `maxLength` an input field should carry. */
|
|
11
|
+
export declare const USERNAME_MAX_LENGTH = 30;
|
|
12
|
+
/** The 400 / inline-validation copy for every path that rejects a handle. */
|
|
13
|
+
export declare const USERNAME_INVALID_MESSAGE: string;
|
|
14
|
+
/**
|
|
15
|
+
* Exact-match handles nobody may newly claim, regardless of account kind.
|
|
16
|
+
*
|
|
17
|
+
* This is NOT a namespace tightening like the bot suffix — it is a list of
|
|
18
|
+
* names withheld from `users_lower_username_key` before anybody asks for
|
|
19
|
+
* them. Compared against the same normalization the unique index applies
|
|
20
|
+
* (`lower(btrim(username))`), so `Admin`, ` ADMIN ` and `admin` are the one
|
|
21
|
+
* name this list means.
|
|
22
|
+
*
|
|
23
|
+
* `oxy`, `mention`, `homiio`, `clarity`, `faircoin`, `astro` and `mercaria`
|
|
24
|
+
* are deliberately NOT here: each already has an `organization`/`project`
|
|
25
|
+
* row, so the unique index already refuses a second one, and `oxy` is the
|
|
26
|
+
* name `USERNAME_MIN_LENGTH` is pinned against in
|
|
27
|
+
* `__tests__/username.test.ts` — listing it would make
|
|
28
|
+
* `usernameSchema.safeParse('oxy')` fail and falsify that comment. A brand
|
|
29
|
+
* with no account of its own yet (measured 2026-09-18: Alia, Allo, TNP,
|
|
30
|
+
* Kaana, Bloom) has no row to protect it, so it is listed until one exists.
|
|
31
|
+
*/
|
|
32
|
+
export declare const RESERVED_USERNAMES: ReadonlySet<string>;
|
|
33
|
+
/** The 400 / inline-validation copy for a handle on {@link RESERVED_USERNAMES}. */
|
|
34
|
+
export declare const RESERVED_USERNAME_MESSAGE = "This username is reserved and cannot be registered";
|
|
35
|
+
/**
|
|
36
|
+
* {@link RESERVED_USERNAMES}, minus `alia`, checked against each `-`/`_`
|
|
37
|
+
* separated SEGMENT of a candidate rather than the whole string — so
|
|
38
|
+
* `official-oxy`, `super-admin` and `team-kaana` are refused the same as the
|
|
39
|
+
* bare words, without banning every word that merely CONTAINS one as a
|
|
40
|
+
* substring (`superman`, `modern`, `grassroot`, `homeowner` all stay legal:
|
|
41
|
+
* none of them separates the reserved word from the rest with `-` or `_`).
|
|
42
|
+
*
|
|
43
|
+
* `alia` is excluded because `alia-` is the live internal-cost-centre
|
|
44
|
+
* namespace: `alia-production-chat` is a minted account and
|
|
45
|
+
* `alia-research` / `alia-voice` / `alia-evaluations` are pinned as legal
|
|
46
|
+
* slugs in `__tests__/username.test.ts` and `internalCostCenterSpecs.test.ts`.
|
|
47
|
+
* Segment-matching `alia` would refuse all four. The bare word `alia` is
|
|
48
|
+
* still refused — {@link RESERVED_USERNAMES} above catches it exactly.
|
|
49
|
+
*/
|
|
50
|
+
export declare const RESERVED_USERNAME_SEGMENTS: ReadonlySet<string>;
|
|
51
|
+
/** The 400 / inline-validation copy for a handle that is only digits. */
|
|
52
|
+
export declare const NUMERIC_USERNAME_MESSAGE = "Username cannot be only numbers";
|
|
53
|
+
/**
|
|
54
|
+
* Alphanumeric runs joined by single separators, as a SOURCE string.
|
|
55
|
+
*
|
|
56
|
+
* A string rather than a literal because the OpenAPI docblocks that publish this
|
|
57
|
+
* rule (`POST /auth/register`, `PUT /users/:userId`) must quote it verbatim, and
|
|
58
|
+
* `usernamePolicySingleSource.test.ts` compares them against THIS constant. A
|
|
59
|
+
* published `pattern:` that drifts from the enforced rule is a lie told to every
|
|
60
|
+
* client that generates from the spec, and it is exactly the kind of copy nobody
|
|
61
|
+
* notices going stale.
|
|
62
|
+
*
|
|
63
|
+
* Deliberately NOT re-exported from the package barrel: it exists for the
|
|
64
|
+
* schema below and for that one gate. Anything validating a username uses
|
|
65
|
+
* {@link usernameSchema}, so there is no second way to ask the question.
|
|
66
|
+
*
|
|
67
|
+
* Written as an unambiguous alternation rather than a lookahead: every character
|
|
68
|
+
* belongs to exactly one branch, so matching is linear and there is no
|
|
69
|
+
* backtracking to bound. It also carries no `\p{…}` property escape, which
|
|
70
|
+
* mobile Hermes throws on at runtime — this module is reachable from every React
|
|
71
|
+
* Native consumer.
|
|
72
|
+
*/
|
|
73
|
+
export declare const USERNAME_PATTERN_SOURCE = "^[A-Za-z0-9]+(?:[-_][A-Za-z0-9]+)*$";
|
|
74
|
+
export declare const USERNAME_PATTERN: RegExp;
|
|
75
|
+
/**
|
|
76
|
+
* Drop the characters the policy forbids, for an input field that filters
|
|
77
|
+
* keystrokes.
|
|
78
|
+
*
|
|
79
|
+
* This is a TYPING aid and nothing else — the result still has to pass
|
|
80
|
+
* {@link usernameSchema}, which is what decides. It does not lower-case (case is
|
|
81
|
+
* preserved, see the header) and it cannot repair a name: a value that is too
|
|
82
|
+
* short, edge-separated or doubly-separated comes back unchanged and fails
|
|
83
|
+
* validation with a message, which is the outcome the coercing rules this
|
|
84
|
+
* replaces used to hide.
|
|
85
|
+
*/
|
|
86
|
+
export declare function stripDisallowedUsernameCharacters(input: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* The label a bot's handle ends in — the ONE exception the policy carries.
|
|
89
|
+
*
|
|
90
|
+
* Lower-case here because it is what a generator appends; the comparison that
|
|
91
|
+
* enforces it folds case, so `MyBot` satisfies it just as `mybot` does.
|
|
92
|
+
*
|
|
93
|
+
* Deliberately NOT re-exported from the package barrel, for the same reason
|
|
94
|
+
* {@link USERNAME_PATTERN_SOURCE} is not: it exists for the schema and the
|
|
95
|
+
* generator aid below. A consumer that wants to SAY the rule uses
|
|
96
|
+
* {@link BOT_USERNAME_INVALID_MESSAGE}, which already quotes it, and one that
|
|
97
|
+
* wants to APPLY it uses {@link applyBotUsernameSuffix} — so there is no second
|
|
98
|
+
* way to spell the check.
|
|
99
|
+
*/
|
|
100
|
+
export declare const BOT_USERNAME_SUFFIX = "bot";
|
|
101
|
+
/** The 400 / inline-validation copy for a bot handle that carries no label. */
|
|
102
|
+
export declare const BOT_USERNAME_INVALID_MESSAGE = "A bot account's username must end in \"bot\"";
|
|
103
|
+
/**
|
|
104
|
+
* Label a proposed bot handle, so a generator PROPOSES something the server will
|
|
105
|
+
* accept.
|
|
106
|
+
*
|
|
107
|
+
* Alia builds an agent's handle from its display name; without this it would
|
|
108
|
+
* propose `garden-helper` for a bot and be 400ed on submit, which is the same
|
|
109
|
+
* "suggest, then refuse" defect the minimum length already caused once.
|
|
110
|
+
*
|
|
111
|
+
* It appends and never inserts: a separator is the caller's choice, so
|
|
112
|
+
* `garden-helper` becomes `garden-helperbot` while a caller who typed
|
|
113
|
+
* `garden-helper-` gets `garden-helper-bot`. It truncates to leave room rather
|
|
114
|
+
* than overflowing {@link USERNAME_MAX_LENGTH}.
|
|
115
|
+
*
|
|
116
|
+
* Like {@link stripDisallowedUsernameCharacters} it is an aid, not a decision: it
|
|
117
|
+
* cannot repair a handle the base policy refuses, and the result still has to
|
|
118
|
+
* pass {@link botUsernameSchema}.
|
|
119
|
+
*/
|
|
120
|
+
export declare function applyBotUsernameSuffix(candidate: string): string;
|
|
121
|
+
/** The username policy as a check — the twin of `usernameSchema`, same messages. */
|
|
122
|
+
export declare const usernameCheck: Check<string>;
|
|
123
|
+
/** A bot's username: the policy plus the `bot` suffix — the twin of `botUsernameSchema`. */
|
|
124
|
+
export declare const botUsernameCheck: Check<string>;
|
|
125
|
+
/** The twin of `usernameSchemaForAccountKind`. */
|
|
126
|
+
export declare function usernameCheckForAccountKind(kind: AccountKind | null | undefined): Check<string>;
|