@oxy.so/contracts 4.16.0 → 4.17.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.
Files changed (113) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountEmail.js +12 -34
  3. package/dist/cjs/accountGraph.js +22 -320
  4. package/dist/cjs/agentKeys.js +11 -13
  5. package/dist/cjs/client/accountEmail.js +48 -0
  6. package/dist/cjs/client/accountGraph.js +323 -0
  7. package/dist/cjs/client/agentKeys.js +77 -0
  8. package/dist/cjs/client/check.js +466 -0
  9. package/dist/cjs/client/deviceBoot.js +22 -0
  10. package/dist/cjs/client/deviceDirectory.js +51 -0
  11. package/dist/cjs/client/deviceSession.js +63 -0
  12. package/dist/cjs/client/externalIdentity.js +19 -0
  13. package/dist/cjs/client/identity.js +45 -0
  14. package/dist/cjs/client/identityLink.js +55 -0
  15. package/dist/cjs/client/identityProof.js +109 -0
  16. package/dist/cjs/client/index.js +190 -0
  17. package/dist/cjs/client/organizations.js +114 -0
  18. package/dist/cjs/client/products.js +153 -0
  19. package/dist/cjs/client/recommendations.js +33 -0
  20. package/dist/cjs/client/reputation.js +41 -0
  21. package/dist/cjs/client/safety.js +15 -0
  22. package/dist/cjs/client/sessionStatus.js +23 -0
  23. package/dist/cjs/client/signIn.js +157 -0
  24. package/dist/cjs/client/userResponse.js +15 -0
  25. package/dist/cjs/client/username.js +173 -0
  26. package/dist/cjs/deviceSession.js +3 -16
  27. package/dist/cjs/identityLink.js +13 -34
  28. package/dist/cjs/identityProof.js +18 -106
  29. package/dist/cjs/organizations.js +21 -41
  30. package/dist/cjs/reputation.js +3 -34
  31. package/dist/cjs/signIn.js +33 -111
  32. package/dist/cjs/username.js +23 -158
  33. package/dist/esm/.tsbuildinfo +1 -1
  34. package/dist/esm/accountEmail.js +4 -32
  35. package/dist/esm/accountGraph.js +4 -309
  36. package/dist/esm/agentKeys.js +4 -10
  37. package/dist/esm/client/accountEmail.js +45 -0
  38. package/dist/esm/client/accountGraph.js +314 -0
  39. package/dist/esm/client/agentKeys.js +74 -0
  40. package/dist/esm/client/check.js +428 -0
  41. package/dist/esm/client/deviceBoot.js +19 -0
  42. package/dist/esm/client/deviceDirectory.js +48 -0
  43. package/dist/esm/client/deviceSession.js +60 -0
  44. package/dist/esm/client/externalIdentity.js +16 -0
  45. package/dist/esm/client/identity.js +42 -0
  46. package/dist/esm/client/identityLink.js +50 -0
  47. package/dist/esm/client/identityProof.js +104 -0
  48. package/dist/esm/client/index.js +37 -0
  49. package/dist/esm/client/organizations.js +111 -0
  50. package/dist/esm/client/products.js +150 -0
  51. package/dist/esm/client/recommendations.js +30 -0
  52. package/dist/esm/client/reputation.js +37 -0
  53. package/dist/esm/client/safety.js +12 -0
  54. package/dist/esm/client/sessionStatus.js +20 -0
  55. package/dist/esm/client/signIn.js +151 -0
  56. package/dist/esm/client/userResponse.js +12 -0
  57. package/dist/esm/client/username.js +167 -0
  58. package/dist/esm/deviceSession.js +1 -15
  59. package/dist/esm/identityLink.js +4 -27
  60. package/dist/esm/identityProof.js +4 -99
  61. package/dist/esm/organizations.js +4 -31
  62. package/dist/esm/reputation.js +1 -32
  63. package/dist/esm/signIn.js +4 -96
  64. package/dist/esm/username.js +4 -148
  65. package/dist/types/.tsbuildinfo +1 -1
  66. package/dist/types/accountEmail.d.ts +2 -34
  67. package/dist/types/accountGraph.d.ts +12 -208
  68. package/dist/types/agency.d.ts +24 -24
  69. package/dist/types/agentKeys.d.ts +8 -6
  70. package/dist/types/client/accountEmail.d.ts +44 -0
  71. package/dist/types/client/accountGraph.d.ts +203 -0
  72. package/dist/types/client/agentKeys.d.ts +113 -0
  73. package/dist/types/client/check.d.ts +184 -0
  74. package/dist/types/client/deviceBoot.d.ts +6 -0
  75. package/dist/types/client/deviceDirectory.d.ts +134 -0
  76. package/dist/types/client/deviceSession.d.ts +91 -0
  77. package/dist/types/client/externalIdentity.d.ts +14 -0
  78. package/dist/types/client/identity.d.ts +8 -0
  79. package/dist/types/client/identityLink.d.ts +21 -0
  80. package/dist/types/client/identityProof.d.ts +73 -0
  81. package/dist/types/client/index.d.ts +37 -0
  82. package/dist/types/client/organizations.d.ts +167 -0
  83. package/dist/types/client/products.d.ts +145 -0
  84. package/dist/types/client/recommendations.d.ts +27 -0
  85. package/dist/types/client/reputation.d.ts +28 -0
  86. package/dist/types/client/safety.d.ts +13 -0
  87. package/dist/types/client/sessionStatus.d.ts +19 -0
  88. package/dist/types/client/signIn.d.ts +107 -0
  89. package/dist/types/client/userResponse.d.ts +7 -0
  90. package/dist/types/client/username.d.ts +126 -0
  91. package/dist/types/deviceDirectory.d.ts +28 -28
  92. package/dist/types/deviceSession.d.ts +1 -12
  93. package/dist/types/externalIdentity.d.ts +11 -11
  94. package/dist/types/identityLink.d.ts +3 -11
  95. package/dist/types/identityProof.d.ts +2 -65
  96. package/dist/types/inference/decisions.d.ts +10 -10
  97. package/dist/types/inference/embeddings.d.ts +16 -16
  98. package/dist/types/inference/errors.d.ts +8 -8
  99. package/dist/types/inference/inbox.d.ts +8 -8
  100. package/dist/types/inference/privateAutoExecution.d.ts +6 -6
  101. package/dist/types/inference/realtime.d.ts +30 -30
  102. package/dist/types/inference/request.d.ts +28 -28
  103. package/dist/types/inference/streamEvents.d.ts +16 -16
  104. package/dist/types/inference/usage.d.ts +4 -4
  105. package/dist/types/oauth.d.ts +2 -2
  106. package/dist/types/organizations.d.ts +8 -10
  107. package/dist/types/products/billing.d.ts +3 -0
  108. package/dist/types/reputation.d.ts +1 -11
  109. package/dist/types/sessionStatus.d.ts +2 -2
  110. package/dist/types/signIn.d.ts +6 -89
  111. package/dist/types/userResponse.d.ts +20 -20
  112. package/dist/types/username.d.ts +1 -96
  113. package/package.json +20 -1
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.identityLinkCompleteRequestSchema = exports.identityLinkProofRequestSchema = exports.identityLinkStateSchema = exports.identityLinkCreateResponseSchema = exports.identityLinkIdSchema = exports.IDENTITY_LINK_QR_PREFIX = exports.IDENTITY_LINK_STATUSES = void 0;
4
- exports.buildIdentityLinkQrPayload = buildIdentityLinkQrPayload;
5
- exports.parseIdentityLinkQrPayload = parseIdentityLinkQrPayload;
3
+ exports.identityLinkCompleteRequestSchema = exports.identityLinkProofRequestSchema = exports.identityLinkStateSchema = exports.identityLinkCreateResponseSchema = exports.identityLinkIdSchema = exports.parseIdentityLinkQrPayload = exports.buildIdentityLinkQrPayload = exports.IDENTITY_LINK_QR_PREFIX = exports.IDENTITY_LINK_STATUSES = void 0;
6
4
  /**
7
5
  * Linking Commons to an account without a key (ADR 0029 D3) — the two-device
8
6
  * relay.
@@ -31,45 +29,26 @@ exports.parseIdentityLinkQrPayload = parseIdentityLinkQrPayload;
31
29
  const zod_1 = require("zod");
32
30
  const identityProof_1 = require("./identityProof");
33
31
  const signIn_1 = require("./signIn");
34
- exports.IDENTITY_LINK_STATUSES = ['pending', 'signed', 'completed', 'cancelled'];
35
- /** The scheme and host Commons routes a link QR to. */
36
- exports.IDENTITY_LINK_QR_PREFIX = 'oxycommons://link';
37
- const LINK_ID = /^[0-9a-f]{32}$/;
38
- const CHALLENGE = /^[0-9a-f]{64}$/;
32
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
33
+ // it is re-exported here so the root entry is unchanged.
34
+ const identityLink_1 = require("./client/identityLink");
35
+ var identityLink_2 = require("./client/identityLink");
36
+ Object.defineProperty(exports, "IDENTITY_LINK_STATUSES", { enumerable: true, get: function () { return identityLink_2.IDENTITY_LINK_STATUSES; } });
37
+ Object.defineProperty(exports, "IDENTITY_LINK_QR_PREFIX", { enumerable: true, get: function () { return identityLink_2.IDENTITY_LINK_QR_PREFIX; } });
38
+ Object.defineProperty(exports, "buildIdentityLinkQrPayload", { enumerable: true, get: function () { return identityLink_2.buildIdentityLinkQrPayload; } });
39
+ Object.defineProperty(exports, "parseIdentityLinkQrPayload", { enumerable: true, get: function () { return identityLink_2.parseIdentityLinkQrPayload; } });
39
40
  exports.identityLinkIdSchema = zod_1.z
40
41
  .string()
41
42
  .trim()
42
- .regex(LINK_ID, 'linkId must be 32 lowercase hex characters');
43
- /** The QR auth.oxy.so shows: the request's id and the challenge Commons signs. */
44
- function buildIdentityLinkQrPayload(linkId, challenge) {
45
- return `${exports.IDENTITY_LINK_QR_PREFIX}?id=${linkId}&c=${challenge}`;
46
- }
47
- /** The request a scanned code names, or `null` for anything that is not a link QR. */
48
- function parseIdentityLinkQrPayload(raw) {
49
- const value = raw.trim();
50
- if (!value.startsWith(`${exports.IDENTITY_LINK_QR_PREFIX}?`))
51
- return null;
52
- // Parsed by hand: React Native's `URLSearchParams` does not implement `get`.
53
- const params = new Map();
54
- for (const pair of value.slice(exports.IDENTITY_LINK_QR_PREFIX.length + 1).split('&')) {
55
- const separator = pair.indexOf('=');
56
- if (separator > 0)
57
- params.set(pair.slice(0, separator), pair.slice(separator + 1));
58
- }
59
- const linkId = params.get('id') ?? '';
60
- const challenge = params.get('c') ?? '';
61
- if (!LINK_ID.test(linkId) || !CHALLENGE.test(challenge))
62
- return null;
63
- return { linkId, challenge };
64
- }
43
+ .regex(identityLink_1.LINK_ID, 'linkId must be 32 lowercase hex characters');
65
44
  exports.identityLinkCreateResponseSchema = zod_1.z.object({
66
45
  linkId: exports.identityLinkIdSchema,
67
- challenge: zod_1.z.string().regex(CHALLENGE),
46
+ challenge: zod_1.z.string().regex(identityLink_1.CHALLENGE),
68
47
  expiresAt: zod_1.z.number().int().positive(),
69
- qrPayload: zod_1.z.string().startsWith(exports.IDENTITY_LINK_QR_PREFIX),
48
+ qrPayload: zod_1.z.string().startsWith(identityLink_1.IDENTITY_LINK_QR_PREFIX),
70
49
  });
71
50
  exports.identityLinkStateSchema = zod_1.z.object({
72
- status: zod_1.z.enum(exports.IDENTITY_LINK_STATUSES),
51
+ status: zod_1.z.enum(identityLink_1.IDENTITY_LINK_STATUSES),
73
52
  userId: zod_1.z.string().min(1),
74
53
  username: zod_1.z.string().nullable(),
75
54
  publicKey: zod_1.z.string().nullable(),
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.identityRootStatusSchema = exports.IDENTITY_ERROR_CODES = exports.identityProofChallengeResponseSchema = exports.identityProofChallengeRequestSchema = exports.identityProofSchema = exports.IDENTITY_PROOF_ACTION_VALUES = exports.IDENTITY_PROOF_ACTIONS = exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = exports.IDENTITY_PROOF_AUDIENCE = exports.IDENTITY_PROOF_DOMAIN = exports.IDENTITY_PROOF_VERSION = void 0;
4
- exports.canonicalJson = canonicalJson;
5
- exports.buildIdentityProofMessage = buildIdentityProofMessage;
3
+ exports.identityRootStatusSchema = exports.identityProofChallengeResponseSchema = exports.identityProofChallengeRequestSchema = exports.identityProofSchema = exports.IDENTITY_ERROR_CODES = exports.buildIdentityProofMessage = exports.canonicalJson = exports.IDENTITY_PROOF_ACTION_VALUES = exports.IDENTITY_PROOF_ACTIONS = exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = exports.IDENTITY_PROOF_AUDIENCE = exports.IDENTITY_PROOF_DOMAIN = exports.IDENTITY_PROOF_VERSION = void 0;
6
4
  /**
7
5
  * Identity proof contract — the ONE signed format for operations on a personal root.
8
6
  *
@@ -21,121 +19,35 @@ exports.buildIdentityProofMessage = buildIdentityProofMessage;
21
19
  * primitive and passes the hex digest in).
22
20
  */
23
21
  const zod_1 = require("zod");
24
- exports.IDENTITY_PROOF_VERSION = 2;
25
- exports.IDENTITY_PROOF_DOMAIN = 'oxy-identity-proof';
26
- /** The audience every API-verified identity proof names. */
27
- exports.IDENTITY_PROOF_AUDIENCE = 'oxy-api/identity';
28
- /** How long a proof challenge lives: one interactive ceremony. */
29
- exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = 5 * 60 * 1000;
30
- /**
31
- * Everything a root proof may authorize. A challenge is minted for exactly one
32
- * action and spent only by a proof for that action.
33
- */
34
- exports.IDENTITY_PROOF_ACTIONS = {
35
- /**
36
- * Link Commons' root to an account that has none (`POST /auth/link`).
37
- * The account becomes self-custodied and its email is deleted
38
- * (ADR 0029 D3).
39
- */
40
- link: 'link_identity',
41
- };
42
- exports.IDENTITY_PROOF_ACTION_VALUES = Object.values(exports.IDENTITY_PROOF_ACTIONS);
43
- const HEX_DIGEST = /^[0-9a-f]{64}$/;
44
- const ROOT_KEY = /^04[0-9a-f]{128}$/;
45
- const CHALLENGE = /^[0-9a-f]{64}$/;
46
- /**
47
- * Canonical JSON: object keys sorted by UTF-16 code unit, no whitespace,
48
- * `undefined` members omitted, arrays in order. Numbers must be finite. This is
49
- * the ONLY serializer for anything digested into a proof.
50
- */
51
- function canonicalJson(value) {
52
- if (value === null)
53
- return 'null';
54
- switch (typeof value) {
55
- case 'string':
56
- case 'boolean':
57
- return JSON.stringify(value);
58
- case 'number':
59
- if (!Number.isFinite(value))
60
- throw new Error('canonicalJson: non-finite number');
61
- return JSON.stringify(value);
62
- case 'object': {
63
- if (Array.isArray(value)) {
64
- return `[${value.map((entry) => (entry === undefined ? 'null' : canonicalJson(entry))).join(',')}]`;
65
- }
66
- const record = value;
67
- const keys = Object.keys(record)
68
- .filter((key) => record[key] !== undefined)
69
- .sort();
70
- return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(',')}}`;
71
- }
72
- default:
73
- throw new Error(`canonicalJson: unsupported ${typeof value}`);
74
- }
75
- }
76
- /**
77
- * The exact bytes a root signs. Throws on a malformed claim rather than signing
78
- * (or verifying) something ambiguous.
79
- */
80
- function buildIdentityProofMessage(claims) {
81
- if (!exports.IDENTITY_PROOF_ACTION_VALUES.includes(claims.action))
82
- throw new Error('identity proof: unknown action');
83
- if (!claims.subject || !claims.actor)
84
- throw new Error('identity proof: subject and actor are required');
85
- if (!ROOT_KEY.test(claims.rootPublicKey))
86
- throw new Error('identity proof: rootPublicKey must be canonical');
87
- if (claims.payloadDigest !== null && !HEX_DIGEST.test(claims.payloadDigest)) {
88
- throw new Error('identity proof: payloadDigest must be a lowercase SHA-256 hex digest');
89
- }
90
- if (claims.expectedRevision !== null &&
91
- (!Number.isSafeInteger(claims.expectedRevision) || claims.expectedRevision < 0)) {
92
- throw new Error('identity proof: expectedRevision must be a non-negative integer');
93
- }
94
- if (!CHALLENGE.test(claims.challenge))
95
- throw new Error('identity proof: challenge must be 64 lowercase hex characters');
96
- if (!Number.isSafeInteger(claims.expiresAt) || claims.expiresAt <= 0)
97
- throw new Error('identity proof: expiresAt must be unix milliseconds');
98
- return canonicalJson({
99
- v: exports.IDENTITY_PROOF_VERSION,
100
- domain: exports.IDENTITY_PROOF_DOMAIN,
101
- action: claims.action,
102
- subject: claims.subject,
103
- actor: claims.actor,
104
- rootPublicKey: claims.rootPublicKey,
105
- payloadDigest: claims.payloadDigest,
106
- expectedRevision: claims.expectedRevision,
107
- audience: claims.audience,
108
- challenge: claims.challenge,
109
- expiresAt: claims.expiresAt,
110
- });
111
- }
22
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
23
+ // it is re-exported here so the root entry is unchanged.
24
+ const identityProof_1 = require("./client/identityProof");
25
+ var identityProof_2 = require("./client/identityProof");
26
+ Object.defineProperty(exports, "IDENTITY_PROOF_VERSION", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_VERSION; } });
27
+ Object.defineProperty(exports, "IDENTITY_PROOF_DOMAIN", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_DOMAIN; } });
28
+ Object.defineProperty(exports, "IDENTITY_PROOF_AUDIENCE", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_AUDIENCE; } });
29
+ Object.defineProperty(exports, "IDENTITY_PROOF_CHALLENGE_TTL_MS", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_CHALLENGE_TTL_MS; } });
30
+ Object.defineProperty(exports, "IDENTITY_PROOF_ACTIONS", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_ACTIONS; } });
31
+ Object.defineProperty(exports, "IDENTITY_PROOF_ACTION_VALUES", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_ACTION_VALUES; } });
32
+ Object.defineProperty(exports, "canonicalJson", { enumerable: true, get: function () { return identityProof_2.canonicalJson; } });
33
+ Object.defineProperty(exports, "buildIdentityProofMessage", { enumerable: true, get: function () { return identityProof_2.buildIdentityProofMessage; } });
34
+ Object.defineProperty(exports, "IDENTITY_ERROR_CODES", { enumerable: true, get: function () { return identityProof_2.IDENTITY_ERROR_CODES; } });
112
35
  /** The proof as it travels: the signature plus the two claims the verifier cannot derive. */
113
36
  exports.identityProofSchema = zod_1.z.object({
114
- v: zod_1.z.literal(exports.IDENTITY_PROOF_VERSION),
115
- challenge: zod_1.z.string().trim().regex(CHALLENGE, 'challenge must be 64 lowercase hex characters'),
37
+ v: zod_1.z.literal(identityProof_1.IDENTITY_PROOF_VERSION),
38
+ challenge: zod_1.z.string().trim().regex(identityProof_1.CHALLENGE, 'challenge must be 64 lowercase hex characters'),
116
39
  expiresAt: zod_1.z.number().int().positive(),
117
40
  signature: zod_1.z.string().trim().min(1).max(512),
118
41
  });
119
42
  /** `POST /identity/proof-challenge` */
120
43
  exports.identityProofChallengeRequestSchema = zod_1.z.object({
121
- action: zod_1.z.enum(exports.IDENTITY_PROOF_ACTION_VALUES),
44
+ action: zod_1.z.enum(identityProof_1.IDENTITY_PROOF_ACTION_VALUES),
122
45
  });
123
46
  exports.identityProofChallengeResponseSchema = zod_1.z.object({
124
- challenge: zod_1.z.string().regex(CHALLENGE),
47
+ challenge: zod_1.z.string().regex(identityProof_1.CHALLENGE),
125
48
  expiresAt: zod_1.z.number().int().positive(),
126
49
  audience: zod_1.z.string().min(1),
127
50
  });
128
- /**
129
- * Stable error codes the root routes answer with (`error.code` in the API error
130
- * body). Clients map these through their localization, never the English message.
131
- */
132
- exports.IDENTITY_ERROR_CODES = {
133
- proofInvalid: 'IDENTITY_PROOF_INVALID',
134
- rootAlreadyLinked: 'IDENTITY_ROOT_ALREADY_LINKED',
135
- rootLinkedElsewhere: 'IDENTITY_ROOT_LINKED_ELSEWHERE',
136
- freshFactorRequired: 'IDENTITY_FRESH_FACTOR_REQUIRED',
137
- notPersonal: 'IDENTITY_NOT_PERSONAL_ACCOUNT',
138
- };
139
51
  exports.identityRootStatusSchema = zod_1.z.object({
140
52
  rootLinked: zod_1.z.boolean(),
141
53
  recoveryEmail: zod_1.z.string().nullable(),
@@ -1,46 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.organizationCurationResultSchema = exports.organizationCurationSchema = exports.organizationErrorSchema = exports.ORGANIZATION_ERROR_CODES = exports.organizationMergeSchema = exports.organizationExternalResolutionSchema = exports.organizationExternalSchema = exports.organizationImportBatchResultSchema = exports.organizationImportBatchSchema = exports.organizationExternalInputSchema = exports.organizationClaimReviewSchema = exports.organizationClaimListSchema = exports.organizationClaimListQuerySchema = exports.organizationClaimDetailSchema = exports.organizationClaimSchema = exports.organizationClaimInputSchema = exports.organizationBatchSchema = exports.organizationBatchInputSchema = exports.organizationListSchema = exports.organizationSearchSchema = exports.organizationSchema = exports.updateOrganizationSchema = exports.createOrganizationSchema = exports.organizationNameSchema = exports.ORGANIZATION_NAME_MAX_LENGTH = exports.organizationAliasSchema = exports.ORGANIZATION_CLAIM_DECISIONS = exports.ORGANIZATION_ALIAS_KINDS = exports.ORGANIZATION_CLAIM_STATUSES = exports.ORGANIZATION_STATUSES = exports.ORGANIZATION_TYPES = void 0;
3
+ exports.organizationCurationResultSchema = exports.organizationCurationSchema = exports.organizationErrorSchema = exports.organizationMergeSchema = exports.organizationExternalResolutionSchema = exports.organizationExternalSchema = exports.organizationImportBatchResultSchema = exports.organizationImportBatchSchema = exports.organizationExternalInputSchema = exports.organizationClaimReviewSchema = exports.organizationClaimListSchema = exports.organizationClaimListQuerySchema = exports.organizationClaimDetailSchema = exports.organizationClaimSchema = exports.organizationClaimInputSchema = exports.organizationBatchSchema = exports.organizationBatchInputSchema = exports.organizationListSchema = exports.organizationSearchSchema = exports.organizationSchema = exports.updateOrganizationSchema = exports.createOrganizationSchema = exports.organizationNameSchema = exports.organizationAliasSchema = exports.ORGANIZATION_ERROR_CODES = exports.ORGANIZATION_NAME_MAX_LENGTH = exports.ORGANIZATION_CLAIM_DECISIONS = exports.ORGANIZATION_ALIAS_KINDS = exports.ORGANIZATION_CLAIM_STATUSES = exports.ORGANIZATION_STATUSES = exports.ORGANIZATION_TYPES = void 0;
4
4
  const zod_1 = require("zod");
5
- /** Real-world identity classification, independent of account topics and permissions. */
6
- exports.ORGANIZATION_TYPES = [
7
- 'business',
8
- 'nonprofit',
9
- 'public_body',
10
- 'community',
11
- 'other',
12
- ];
13
- exports.ORGANIZATION_STATUSES = ['active', 'inactive', 'merged', 'suppressed'];
14
- exports.ORGANIZATION_CLAIM_STATUSES = ['unclaimed', 'claimed'];
15
- exports.ORGANIZATION_ALIAS_KINDS = [
16
- 'name_variant',
17
- 'former_name',
18
- 'localized_name',
19
- 'marketing_name',
20
- 'misspelling',
21
- ];
22
- exports.ORGANIZATION_CLAIM_DECISIONS = ['pending', 'approved', 'rejected'];
5
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
6
+ // it is re-exported here so the root entry is unchanged.
7
+ const organizations_1 = require("./client/organizations");
8
+ var organizations_2 = require("./client/organizations");
9
+ Object.defineProperty(exports, "ORGANIZATION_TYPES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_TYPES; } });
10
+ Object.defineProperty(exports, "ORGANIZATION_STATUSES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_STATUSES; } });
11
+ Object.defineProperty(exports, "ORGANIZATION_CLAIM_STATUSES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_CLAIM_STATUSES; } });
12
+ Object.defineProperty(exports, "ORGANIZATION_ALIAS_KINDS", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_ALIAS_KINDS; } });
13
+ Object.defineProperty(exports, "ORGANIZATION_CLAIM_DECISIONS", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_CLAIM_DECISIONS; } });
14
+ Object.defineProperty(exports, "ORGANIZATION_NAME_MAX_LENGTH", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_NAME_MAX_LENGTH; } });
15
+ Object.defineProperty(exports, "ORGANIZATION_ERROR_CODES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_ERROR_CODES; } });
23
16
  const id = zod_1.z.string().min(1).max(128);
24
17
  const optionalText = (max) => zod_1.z.string().trim().min(1).max(max).nullable().optional();
25
18
  exports.organizationAliasSchema = zod_1.z
26
19
  .object({
27
20
  alias: zod_1.z.string().trim().min(1).max(300),
28
- kind: zod_1.z.enum(exports.ORGANIZATION_ALIAS_KINDS),
21
+ kind: zod_1.z.enum(organizations_1.ORGANIZATION_ALIAS_KINDS),
29
22
  language: zod_1.z.string().min(2).max(35).optional(),
30
23
  })
31
24
  .strict();
32
- exports.ORGANIZATION_NAME_MAX_LENGTH = 300;
33
25
  exports.organizationNameSchema = zod_1.z
34
26
  .string()
35
27
  .trim()
36
28
  .min(1)
37
- .max(exports.ORGANIZATION_NAME_MAX_LENGTH)
29
+ .max(organizations_1.ORGANIZATION_NAME_MAX_LENGTH)
38
30
  .refine((value) => !/[<>]/.test(value) &&
39
31
  Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127), 'Organization name must be plain text');
40
32
  exports.createOrganizationSchema = zod_1.z
41
33
  .object({
42
34
  name: exports.organizationNameSchema,
43
- organizationType: zod_1.z.enum(exports.ORGANIZATION_TYPES),
35
+ organizationType: zod_1.z.enum(organizations_1.ORGANIZATION_TYPES),
44
36
  legalName: optionalText(300),
45
37
  websiteUrl: zod_1.z
46
38
  .string()
@@ -68,8 +60,8 @@ exports.organizationSchema = exports.createOrganizationSchema
68
60
  countryCode: zod_1.z.string().nullable(),
69
61
  aliases: zod_1.z.array(exports.organizationAliasSchema),
70
62
  verifiedDomains: zod_1.z.array(zod_1.z.string()),
71
- claimStatus: zod_1.z.enum(exports.ORGANIZATION_CLAIM_STATUSES),
72
- status: zod_1.z.enum(exports.ORGANIZATION_STATUSES),
63
+ claimStatus: zod_1.z.enum(organizations_1.ORGANIZATION_CLAIM_STATUSES),
64
+ status: zod_1.z.enum(organizations_1.ORGANIZATION_STATUSES),
73
65
  mergedIntoAccountId: id.nullable(),
74
66
  createdAt: zod_1.z.string().datetime(),
75
67
  updatedAt: zod_1.z.string().datetime(),
@@ -78,7 +70,7 @@ exports.organizationSchema = exports.createOrganizationSchema
78
70
  exports.organizationSearchSchema = zod_1.z
79
71
  .object({
80
72
  query: zod_1.z.string().trim().max(200).default(''),
81
- organizationType: zod_1.z.enum(exports.ORGANIZATION_TYPES).optional(),
73
+ organizationType: zod_1.z.enum(organizations_1.ORGANIZATION_TYPES).optional(),
82
74
  limit: zod_1.z.coerce.number().int().min(1).max(50).default(20),
83
75
  cursor: zod_1.z.string().min(1).max(2048).optional(),
84
76
  })
@@ -103,7 +95,7 @@ exports.organizationClaimSchema = zod_1.z
103
95
  id,
104
96
  accountId: id,
105
97
  claimantUserId: id,
106
- status: zod_1.z.enum(exports.ORGANIZATION_CLAIM_DECISIONS),
98
+ status: zod_1.z.enum(organizations_1.ORGANIZATION_CLAIM_DECISIONS),
107
99
  createdAt: zod_1.z.string().datetime(),
108
100
  })
109
101
  .strict();
@@ -116,7 +108,7 @@ exports.organizationClaimDetailSchema = exports.organizationClaimSchema
116
108
  .strict();
117
109
  exports.organizationClaimListQuerySchema = zod_1.z
118
110
  .object({
119
- status: zod_1.z.enum(exports.ORGANIZATION_CLAIM_DECISIONS).optional(),
111
+ status: zod_1.z.enum(organizations_1.ORGANIZATION_CLAIM_DECISIONS).optional(),
120
112
  limit: zod_1.z.coerce.number().int().min(1).max(50).default(20),
121
113
  cursor: zod_1.z.string().min(1).max(2048).optional(),
122
114
  })
@@ -171,23 +163,11 @@ exports.organizationMergeSchema = zod_1.z
171
163
  evidenceReference: zod_1.z.string().trim().min(1).max(1000),
172
164
  })
173
165
  .strict();
174
- exports.ORGANIZATION_ERROR_CODES = [
175
- 'bad_request',
176
- 'unauthorized',
177
- 'forbidden',
178
- 'not_found',
179
- 'unknown_route',
180
- 'conflict',
181
- 'validation_failed',
182
- 'rate_limited',
183
- 'internal_error',
184
- 'service_unavailable',
185
- ];
186
166
  exports.organizationErrorSchema = zod_1.z
187
167
  .object({
188
168
  error: zod_1.z
189
169
  .object({
190
- code: zod_1.z.enum(exports.ORGANIZATION_ERROR_CODES),
170
+ code: zod_1.z.enum(organizations_1.ORGANIZATION_ERROR_CODES),
191
171
  message: zod_1.z.string(),
192
172
  details: zod_1.z
193
173
  .record(zod_1.z.string(), zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]))
@@ -40,11 +40,12 @@
40
40
  * `require()`).
41
41
  */
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.awardReputationSchema = exports.reputationInfluenceResultSchema = exports.reputationLeaderboardEntrySchema = exports.reputationLeaderboardUserSchema = exports.reputationRulesResponseSchema = exports.reputationRuleSchema = exports.reputationBalanceSchema = exports.reputationBalanceSummarySchema = exports.reputationReliabilitySchema = exports.reputationInfluenceSchema = exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema = exports.reputationInfluenceContextSchema = exports.REPUTATION_INFLUENCE_CONTEXTS = exports.reputationTargetEntityTypeSchema = exports.REPUTATION_TARGET_ENTITY_TYPES = exports.trustTierSchema = exports.TRUST_TIERS = exports.reputationTransactionStatusSchema = exports.REPUTATION_TRANSACTION_STATUSES = exports.reputationCategorySchema = exports.REPUTATION_CATEGORIES = void 0;
44
- exports.isFullReputationBalance = isFullReputationBalance;
43
+ exports.awardReputationSchema = exports.reputationInfluenceResultSchema = exports.reputationLeaderboardEntrySchema = exports.reputationLeaderboardUserSchema = exports.reputationRulesResponseSchema = exports.reputationRuleSchema = exports.reputationBalanceSchema = exports.reputationBalanceSummarySchema = exports.reputationReliabilitySchema = exports.reputationInfluenceSchema = exports.reputationBalanceBreakdownSchema = exports.reputationTransactionSchema = exports.reputationInfluenceContextSchema = exports.REPUTATION_INFLUENCE_CONTEXTS = exports.reputationTargetEntityTypeSchema = exports.REPUTATION_TARGET_ENTITY_TYPES = exports.trustTierSchema = exports.TRUST_TIERS = exports.reputationTransactionStatusSchema = exports.REPUTATION_TRANSACTION_STATUSES = exports.reputationCategorySchema = exports.REPUTATION_CATEGORIES = exports.isFullReputationBalance = void 0;
45
44
  const zod_1 = require("zod");
46
45
  const userResponse_1 = require("./userResponse");
47
46
  const moderationReputation_1 = require("./moderationReputation");
47
+ var reputation_1 = require("./client/reputation");
48
+ Object.defineProperty(exports, "isFullReputationBalance", { enumerable: true, get: function () { return reputation_1.isFullReputationBalance; } });
48
49
  /* -------------------------------------------------------------------------- */
49
50
  /* Closed value sets */
50
51
  /* -------------------------------------------------------------------------- */
@@ -174,38 +175,6 @@ exports.reputationBalanceSchema = zod_1.z.object({
174
175
  reviewing: moderationReputation_1.reputationReviewingSchema.optional(),
175
176
  contextualInfluence: moderationReputation_1.reputationContextualInfluenceSchema.optional(),
176
177
  });
177
- /**
178
- * The fields the full {@link ReputationBalance} carries beyond the public
179
- * {@link ReputationBalanceSummary} that the API sends ALL-OR-NOTHING. The
180
- * runtime discriminant between the two views.
181
- *
182
- * The V2 blocks (`conduct`, `contribution`, …) are deliberately NOT listed:
183
- * they are optional on the wire, so requiring them here would make a balance
184
- * from a server that predates them fail to narrow, hiding the whole private
185
- * view. Read a V2 block by checking that block.
186
- */
187
- const FULL_BALANCE_FIELDS = [
188
- 'positive',
189
- 'negative',
190
- 'breakdown',
191
- 'influence',
192
- 'reliability',
193
- 'recalculatedAt',
194
- 'updatedAt',
195
- ];
196
- /**
197
- * Whether a balance came back as the SUBJECT view, and so carries the
198
- * breakdown / influence / reliability blocks.
199
- *
200
- * Checks every extra field rather than one representative: the point of the
201
- * guard is that the caller then dereferences those blocks, so a partial payload
202
- * must not narrow.
203
- *
204
- * @param balance - A balance from `getReputationBalance`.
205
- */
206
- function isFullReputationBalance(balance) {
207
- return FULL_BALANCE_FIELDS.every((field) => field in balance);
208
- }
209
178
  exports.reputationRuleSchema = zod_1.z.object({
210
179
  actionType: zod_1.z.string(),
211
180
  points: zod_1.z.number(),
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SIGN_IN_ERROR_CODES = exports.totpBackupCodesResponseSchema = exports.totpReauthRequestSchema = exports.totpConfirmRequestSchema = exports.totpEnrollResponseSchema = exports.signInMethodsSchema = exports.passwordSetRequestSchema = exports.emailReauthProofSchema = exports.reauthProofSchema = exports.reauthEmailStartRequestSchema = exports.REAUTH_ACTIONS = exports.emailSignInChooseRequestSchema = exports.emailSignInChooseAccountSchema = exports.emailSignInAccountOptionSchema = exports.EMAIL_ACCOUNTS_MAX = exports.EMAIL_SIGNIN_CHOICE_TTL_MS = exports.emailSignInPendingSchema = exports.secondFactorRequiredSchema = exports.signUpRequestSchema = exports.secondFactorSignInRequestSchema = exports.passwordSignInRequestSchema = exports.emailSignInLinkResponseSchema = exports.emailSignInLinkRequestSchema = exports.emailSignInCollectRequestSchema = exports.emailSignInConfirmRequestSchema = exports.emailSignInCodeSchema = exports.emailSignInStartResponseSchema = exports.emailSignInStartRequestSchema = exports.secondFactorCodeSchema = exports.newPasswordSchema = exports.passwordInputSchema = exports.signInIdentifierSchema = exports.EMAIL_SIGNIN_LONG_CODE_LENGTH = exports.EMAIL_SIGNIN_LONG_CODE_ALPHABET = exports.TOTP_BACKUP_CODE_COUNT = exports.TOTP_PERIOD_SECONDS = exports.TOTP_DIGITS = exports.PASSWORD_MAX_LENGTH = exports.PASSWORD_MIN_LENGTH = exports.SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = exports.SIGNIN_SECOND_FACTOR_TTL_MS = exports.EMAIL_SIGNIN_LINK_TTL_MS = void 0;
4
- exports.normalizeEmailSignInCode = normalizeEmailSignInCode;
5
- exports.isSecondFactorRequired = isSecondFactorRequired;
6
- exports.isEmailSignInChooseAccount = isEmailSignInChooseAccount;
3
+ exports.totpBackupCodesResponseSchema = exports.totpReauthRequestSchema = exports.totpConfirmRequestSchema = exports.totpEnrollResponseSchema = exports.signInMethodsSchema = exports.passwordSetRequestSchema = exports.emailReauthProofSchema = exports.reauthProofSchema = exports.reauthEmailStartRequestSchema = exports.emailSignInChooseRequestSchema = exports.emailSignInChooseAccountSchema = exports.emailSignInAccountOptionSchema = exports.emailSignInPendingSchema = exports.secondFactorRequiredSchema = exports.signUpRequestSchema = exports.secondFactorSignInRequestSchema = exports.passwordSignInRequestSchema = exports.emailSignInLinkResponseSchema = exports.emailSignInLinkRequestSchema = exports.emailSignInCollectRequestSchema = exports.emailSignInConfirmRequestSchema = exports.emailSignInCodeSchema = exports.emailSignInStartResponseSchema = exports.emailSignInStartRequestSchema = exports.secondFactorCodeSchema = exports.newPasswordSchema = exports.passwordInputSchema = exports.signInIdentifierSchema = exports.SIGN_IN_ERROR_CODES = exports.REAUTH_ACTIONS = exports.isEmailSignInChooseAccount = exports.isSecondFactorRequired = exports.EMAIL_ACCOUNTS_MAX = exports.EMAIL_SIGNIN_CHOICE_TTL_MS = exports.normalizeEmailSignInCode = exports.EMAIL_SIGNIN_LONG_CODE_LENGTH = exports.EMAIL_SIGNIN_LONG_CODE_ALPHABET = exports.TOTP_BACKUP_CODE_COUNT = exports.TOTP_PERIOD_SECONDS = exports.TOTP_DIGITS = exports.PASSWORD_MAX_LENGTH = exports.PASSWORD_MIN_LENGTH = exports.SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = exports.SIGNIN_SECOND_FACTOR_TTL_MS = exports.EMAIL_SIGNIN_LINK_TTL_MS = void 0;
7
4
  /**
8
5
  * Signing in: an email code or link, an optional password,
9
6
  * and an optional authenticator app (TOTP) as a second factor.
@@ -38,40 +35,27 @@ exports.isEmailSignInChooseAccount = isEmailSignInChooseAccount;
38
35
  const zod_1 = require("zod");
39
36
  const accountEmail_1 = require("./accountEmail");
40
37
  const deviceSession_1 = require("./deviceSession");
41
- /** How long the link in a sign-in email can be opened. */
42
- exports.EMAIL_SIGNIN_LINK_TTL_MS = 15 * 60 * 1000;
43
- /** How long a second-factor challenge can be answered. */
44
- exports.SIGNIN_SECOND_FACTOR_TTL_MS = 5 * 60 * 1000;
45
- /** Wrong second-factor codes one challenge accepts. */
46
- exports.SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS = 5;
47
- /** Shortest password Oxy accepts when one is set. */
48
- exports.PASSWORD_MIN_LENGTH = 10;
49
- /** Longest password Oxy accepts (characters). */
50
- exports.PASSWORD_MAX_LENGTH = 256;
51
- /** Digits in an authenticator code. */
52
- exports.TOTP_DIGITS = 6;
53
- /** Seconds each authenticator code lasts. */
54
- exports.TOTP_PERIOD_SECONDS = 30;
55
- /** Backup codes issued when an authenticator is enabled or they are regenerated. */
56
- exports.TOTP_BACKUP_CODE_COUNT = 10;
57
- /**
58
- * The long sign-in code: ten characters of Crockford base32 without the
59
- * look-alikes (no 0, O, 1, I, L, U), shown as `XXXXX-XXXXX`. An account whose
60
- * sign-in codes were guessed at too often today (the per-account ceiling) is
61
- * sent this instead of 6 digits for the rest of the day, so its owner can still
62
- * type a code while guessing one is infeasible.
63
- */
64
- exports.EMAIL_SIGNIN_LONG_CODE_ALPHABET = '23456789ABCDEFGHJKMNPQRSTVWXYZ';
65
- exports.EMAIL_SIGNIN_LONG_CODE_LENGTH = 10;
66
- /**
67
- * Normalise a typed sign-in code: 6 digits stay as they are; a long code is
68
- * upper-cased with its dash and spaces removed. Anything else is returned
69
- * trimmed (and will simply be wrong).
70
- */
71
- function normalizeEmailSignInCode(code) {
72
- const compact = code.trim().replace(/[\s-]/g, '').toUpperCase();
73
- return compact;
74
- }
38
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
39
+ // it is re-exported here so the root entry is unchanged.
40
+ const signIn_1 = require("./client/signIn");
41
+ var signIn_2 = require("./client/signIn");
42
+ Object.defineProperty(exports, "EMAIL_SIGNIN_LINK_TTL_MS", { enumerable: true, get: function () { return signIn_2.EMAIL_SIGNIN_LINK_TTL_MS; } });
43
+ Object.defineProperty(exports, "SIGNIN_SECOND_FACTOR_TTL_MS", { enumerable: true, get: function () { return signIn_2.SIGNIN_SECOND_FACTOR_TTL_MS; } });
44
+ Object.defineProperty(exports, "SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS", { enumerable: true, get: function () { return signIn_2.SIGNIN_SECOND_FACTOR_MAX_ATTEMPTS; } });
45
+ Object.defineProperty(exports, "PASSWORD_MIN_LENGTH", { enumerable: true, get: function () { return signIn_2.PASSWORD_MIN_LENGTH; } });
46
+ Object.defineProperty(exports, "PASSWORD_MAX_LENGTH", { enumerable: true, get: function () { return signIn_2.PASSWORD_MAX_LENGTH; } });
47
+ Object.defineProperty(exports, "TOTP_DIGITS", { enumerable: true, get: function () { return signIn_2.TOTP_DIGITS; } });
48
+ Object.defineProperty(exports, "TOTP_PERIOD_SECONDS", { enumerable: true, get: function () { return signIn_2.TOTP_PERIOD_SECONDS; } });
49
+ Object.defineProperty(exports, "TOTP_BACKUP_CODE_COUNT", { enumerable: true, get: function () { return signIn_2.TOTP_BACKUP_CODE_COUNT; } });
50
+ Object.defineProperty(exports, "EMAIL_SIGNIN_LONG_CODE_ALPHABET", { enumerable: true, get: function () { return signIn_2.EMAIL_SIGNIN_LONG_CODE_ALPHABET; } });
51
+ Object.defineProperty(exports, "EMAIL_SIGNIN_LONG_CODE_LENGTH", { enumerable: true, get: function () { return signIn_2.EMAIL_SIGNIN_LONG_CODE_LENGTH; } });
52
+ Object.defineProperty(exports, "normalizeEmailSignInCode", { enumerable: true, get: function () { return signIn_2.normalizeEmailSignInCode; } });
53
+ Object.defineProperty(exports, "EMAIL_SIGNIN_CHOICE_TTL_MS", { enumerable: true, get: function () { return signIn_2.EMAIL_SIGNIN_CHOICE_TTL_MS; } });
54
+ Object.defineProperty(exports, "EMAIL_ACCOUNTS_MAX", { enumerable: true, get: function () { return signIn_2.EMAIL_ACCOUNTS_MAX; } });
55
+ Object.defineProperty(exports, "isSecondFactorRequired", { enumerable: true, get: function () { return signIn_2.isSecondFactorRequired; } });
56
+ Object.defineProperty(exports, "isEmailSignInChooseAccount", { enumerable: true, get: function () { return signIn_2.isEmailSignInChooseAccount; } });
57
+ Object.defineProperty(exports, "REAUTH_ACTIONS", { enumerable: true, get: function () { return signIn_2.REAUTH_ACTIONS; } });
58
+ Object.defineProperty(exports, "SIGN_IN_ERROR_CODES", { enumerable: true, get: function () { return signIn_2.SIGN_IN_ERROR_CODES; } });
75
59
  const sixDigits = zod_1.z
76
60
  .string()
77
61
  .trim()
@@ -84,17 +68,17 @@ const opaqueTokenSchema = accountEmail_1.emailTicketSchema;
84
68
  /** A username or an email. */
85
69
  exports.signInIdentifierSchema = zod_1.z.string().trim().min(1).max(254);
86
70
  /** A password as typed. Its policy applies only when one is set. */
87
- exports.passwordInputSchema = zod_1.z.string().min(1).max(exports.PASSWORD_MAX_LENGTH);
71
+ exports.passwordInputSchema = zod_1.z.string().min(1).max(signIn_1.PASSWORD_MAX_LENGTH);
88
72
  /** A new password. */
89
73
  exports.newPasswordSchema = zod_1.z
90
74
  .string()
91
- .min(exports.PASSWORD_MIN_LENGTH, `password must be at least ${exports.PASSWORD_MIN_LENGTH} characters`)
92
- .max(exports.PASSWORD_MAX_LENGTH, `password must be at most ${exports.PASSWORD_MAX_LENGTH} characters`);
75
+ .min(signIn_1.PASSWORD_MIN_LENGTH, `password must be at least ${signIn_1.PASSWORD_MIN_LENGTH} characters`)
76
+ .max(signIn_1.PASSWORD_MAX_LENGTH, `password must be at most ${signIn_1.PASSWORD_MAX_LENGTH} characters`);
93
77
  /**
94
78
  * An authenticator code (6 digits) or a backup code (10 characters, with or
95
79
  * without its dash). Normalised server-side.
96
80
  */
97
- exports.secondFactorCodeSchema = zod_1.z.string().trim().min(exports.TOTP_DIGITS).max(16);
81
+ exports.secondFactorCodeSchema = zod_1.z.string().trim().min(signIn_1.TOTP_DIGITS).max(16);
98
82
  /** The device-session fields every body that ends in a session may carry. */
99
83
  const sessionEnvelope = {
100
84
  deviceName: zod_1.z.string().trim().min(1).max(120).optional(),
@@ -127,11 +111,11 @@ exports.emailSignInCodeSchema = zod_1.z
127
111
  .string()
128
112
  .trim()
129
113
  .refine((value) => {
130
- const code = normalizeEmailSignInCode(value);
114
+ const code = (0, signIn_1.normalizeEmailSignInCode)(value);
131
115
  return (new RegExp(`^\\d{${accountEmail_1.EMAIL_CODE_LENGTH}}$`).test(code) ||
132
- new RegExp(`^[${exports.EMAIL_SIGNIN_LONG_CODE_ALPHABET}]{${exports.EMAIL_SIGNIN_LONG_CODE_LENGTH}}$`).test(code));
116
+ new RegExp(`^[${signIn_1.EMAIL_SIGNIN_LONG_CODE_ALPHABET}]{${signIn_1.EMAIL_SIGNIN_LONG_CODE_LENGTH}}$`).test(code));
133
117
  }, {
134
- message: `code must be ${accountEmail_1.EMAIL_CODE_LENGTH} digits or the ${exports.EMAIL_SIGNIN_LONG_CODE_LENGTH}-character code from the email`,
118
+ message: `code must be ${accountEmail_1.EMAIL_CODE_LENGTH} digits or the ${signIn_1.EMAIL_SIGNIN_LONG_CODE_LENGTH}-character code from the email`,
135
119
  });
136
120
  /** `POST /auth/signin/email/confirm` — the code from the email. */
137
121
  exports.emailSignInConfirmRequestSchema = zod_1.z
@@ -199,13 +183,6 @@ exports.emailSignInPendingSchema = zod_1.z.object({
199
183
  status: zod_1.z.literal('pending'),
200
184
  expiresAt: zod_1.z.number().int().positive(),
201
185
  });
202
- /**
203
- * How long, once the email is proven, the person has to choose which of its
204
- * accounts signs in.
205
- */
206
- exports.EMAIL_SIGNIN_CHOICE_TTL_MS = 5 * 60 * 1000;
207
- /** Most accounts one email can hold; sign-up refuses another past it. */
208
- exports.EMAIL_ACCOUNTS_MAX = 20;
209
186
  exports.emailSignInAccountOptionSchema = zod_1.z.object({
210
187
  id: zod_1.z.string().min(1).max(64),
211
188
  username: zod_1.z.string().min(1).optional(),
@@ -214,7 +191,7 @@ exports.emailSignInAccountOptionSchema = zod_1.z.object({
214
191
  });
215
192
  exports.emailSignInChooseAccountSchema = zod_1.z.object({
216
193
  chooseAccount: zod_1.z.literal(true),
217
- accounts: zod_1.z.array(exports.emailSignInAccountOptionSchema).min(2).max(exports.EMAIL_ACCOUNTS_MAX),
194
+ accounts: zod_1.z.array(exports.emailSignInAccountOptionSchema).min(2).max(signIn_1.EMAIL_ACCOUNTS_MAX),
218
195
  expiresAt: zod_1.z.number().int().positive(),
219
196
  });
220
197
  /** `POST /auth/signin/email/choose` — the account, from those {@link EmailSignInChooseAccount} listed. */
@@ -226,27 +203,8 @@ exports.emailSignInChooseRequestSchema = zod_1.z
226
203
  ...sessionEnvelope,
227
204
  })
228
205
  .strict();
229
- /** Narrow a {@link SignInStepResult}. */
230
- function isSecondFactorRequired(result) {
231
- return result.secondFactorRequired === true;
232
- }
233
- /** Narrow an {@link EmailSignInStepResult}. */
234
- function isEmailSignInChooseAccount(result) {
235
- return result.chooseAccount === true;
236
- }
237
- /**
238
- * What a re-verification email code confirms. The code is bound to it: a code
239
- * asked for one change never authorises another, and the email names it.
240
- */
241
- exports.REAUTH_ACTIONS = [
242
- 'change_password',
243
- 'totp',
244
- 'link_commons',
245
- 'delete_account',
246
- 'credentials_manage',
247
- ];
248
206
  /** `POST /users/me/reauth/email` */
249
- exports.reauthEmailStartRequestSchema = zod_1.z.object({ action: zod_1.z.enum(exports.REAUTH_ACTIONS) }).strict();
207
+ exports.reauthEmailStartRequestSchema = zod_1.z.object({ action: zod_1.z.enum(signIn_1.REAUTH_ACTIONS) }).strict();
250
208
  /**
251
209
  * A fresh proof that the person, not only their session, is asking: the
252
210
  * current password, or a code just sent to the account's email
@@ -307,7 +265,7 @@ exports.totpConfirmRequestSchema = zod_1.z
307
265
  code: zod_1.z
308
266
  .string()
309
267
  .trim()
310
- .regex(new RegExp(`^\\d{${exports.TOTP_DIGITS}}$`)),
268
+ .regex(new RegExp(`^\\d{${signIn_1.TOTP_DIGITS}}$`)),
311
269
  reauth: exports.reauthProofSchema,
312
270
  })
313
271
  .strict();
@@ -316,41 +274,5 @@ exports.totpReauthRequestSchema = zod_1.z.object({ reauth: exports.reauthProofSc
316
274
  exports.totpBackupCodesResponseSchema = zod_1.z.object({
317
275
  backupCodes: zod_1.z
318
276
  .array(zod_1.z.string().regex(/^[a-z2-9]{5}-[a-z2-9]{5}$/))
319
- .length(exports.TOTP_BACKUP_CODE_COUNT),
277
+ .length(signIn_1.TOTP_BACKUP_CODE_COUNT),
320
278
  });
321
- /**
322
- * Stable error codes (`error.code` in the API error body). Clients map these
323
- * through their localization, never the English message.
324
- */
325
- exports.SIGN_IN_ERROR_CODES = {
326
- /** Wrong identifier or password — never says which. */
327
- invalidCredentials: 'SIGNIN_INVALID_CREDENTIALS',
328
- /** The request is unknown, expired, spent, or its secret is wrong. */
329
- requestInvalid: 'SIGNIN_REQUEST_INVALID',
330
- /** The link is unknown, expired or already used. */
331
- linkInvalid: 'SIGNIN_LINK_INVALID',
332
- /** The link was opened in another browser: type the code in the app instead. */
333
- linkOtherDevice: 'SIGNIN_LINK_OTHER_DEVICE',
334
- /** The second-factor challenge or its code is wrong, expired or spent. */
335
- secondFactorInvalid: 'SECOND_FACTOR_INVALID',
336
- /** Too many failures for this account: wait and try again. */
337
- locked: 'SIGNIN_LOCKED',
338
- /** The step needs a fresh proof (`reauth`). */
339
- reauthRequired: 'REAUTH_REQUIRED',
340
- /** The fresh proof was wrong. */
341
- reauthInvalid: 'REAUTH_INVALID',
342
- /** The account has an authenticator: the proof must carry its code. */
343
- totpRequired: 'TOTP_REQUIRED',
344
- /** Enrolling or confirming an authenticator that is already on. */
345
- totpAlreadyEnabled: 'TOTP_ALREADY_ENABLED',
346
- /** Disabling, confirming or regenerating codes with no authenticator (or no pending one). */
347
- totpNotEnabled: 'TOTP_NOT_ENABLED',
348
- /** The code the authenticator showed at enrolment is wrong. */
349
- totpCodeInvalid: 'TOTP_CODE_INVALID',
350
- /** Only official Oxy apps and auth.oxy.so may sign people in here. */
351
- originNotAllowed: 'SIGNIN_ORIGIN_NOT_ALLOWED',
352
- /** The username is taken. */
353
- usernameTaken: 'USERNAME_TAKEN',
354
- /** The email already holds `EMAIL_ACCOUNTS_MAX` accounts: no sign-up adds another. */
355
- emailAccountsFull: 'EMAIL_ACCOUNTS_FULL',
356
- };