@oxyhq/contracts 0.4.0 → 0.6.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/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.verifiableCredentialResponseSchema = exports.credentialRecordSchema = exports.vouchResultSchema = exports.personhoodStatusResultSchema = exports.personhoodBreakdownSchema = exports.personhoodVouchRecordSchema = exports.validationVoteResultSchema = exports.validationRequestSummarySchema = exports.validationOpenResultSchema = exports.validationOpenRequestSchema = exports.validationVerdictRecordSchema = exports.realLifeAttestationResultSchema = exports.realLifeAttestationRecordSchema = exports.signedPublicCardSchema = exports.publicCardSchema = exports.exportBundleSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = exports.appUserSignalIngestSchema = exports.appInterestInputSchema = exports.appEndorsementInputSchema = exports.recommendationResponseSchema = exports.recommendationItemSchema = exports.recommendationCountSchema = exports.recommendationRequestSchema = exports.recommendationSignalWeightsSchema = exports.recommendationBoostSchema = exports.recommendationExcludeTypeSchema = exports.fedcmTokenPayloadSchema = exports.sessionStatusSchema = exports.publicApplicationSchema = exports.applicationTypeSchema = exports.safeParseContract = exports.resolveUserId = exports.deviceSessionsResponseSchema = exports.deviceSessionAccountSchema = exports.currentUserResponseSchema = exports.refreshAllResponseSchema = exports.refreshAllAccountSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.userNameSchema = void 0;
15
- exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = void 0;
15
+ exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = void 0;
16
16
  var userResponse_1 = require("./userResponse");
17
17
  // Schemas
18
18
  Object.defineProperty(exports, "userNameSchema", { enumerable: true, get: function () { return userResponse_1.userNameSchema; } });
@@ -80,3 +80,9 @@ Object.defineProperty(exports, "verifiableCredentialResponseSchema", { enumerabl
80
80
  Object.defineProperty(exports, "credentialIssueResultSchema", { enumerable: true, get: function () { return civic_1.credentialIssueResultSchema; } });
81
81
  Object.defineProperty(exports, "credentialListResultSchema", { enumerable: true, get: function () { return civic_1.credentialListResultSchema; } });
82
82
  Object.defineProperty(exports, "credentialVerifyResultSchema", { enumerable: true, get: function () { return civic_1.credentialVerifyResultSchema; } });
83
+ var links_1 = require("./links");
84
+ // Schemas
85
+ Object.defineProperty(exports, "linkPreviewSchema", { enumerable: true, get: function () { return links_1.linkPreviewSchema; } });
86
+ Object.defineProperty(exports, "linkPreviewBatchRequestSchema", { enumerable: true, get: function () { return links_1.linkPreviewBatchRequestSchema; } });
87
+ Object.defineProperty(exports, "linkPreviewBatchResponseSchema", { enumerable: true, get: function () { return links_1.linkPreviewBatchResponseSchema; } });
88
+ Object.defineProperty(exports, "linkPreviewResponseSchema", { enumerable: true, get: function () { return links_1.linkPreviewResponseSchema; } });
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * Link-preview / unfurl API contracts.
4
+ *
5
+ * SINGLE SOURCE OF TRUTH for the wire shape of Oxy's link-preview ("unfurl")
6
+ * resolution surface: the single `GET` lookup and the `POST` batch lookup that
7
+ * every app calls through the SDK so apps stop duplicating their own
8
+ * link-metadata fetching. The API validates its OUTPUT against these schemas;
9
+ * every consumer (`@oxyhq/core`'s link mixin and the apps that call it)
10
+ * validates its INPUT against the same definitions, so producer and consumers
11
+ * cannot drift.
12
+ *
13
+ * Design anchors:
14
+ * - Oxy owns resolution. The `image` (and `favicon`) URLs a preview carries are
15
+ * re-hosted on Oxy media (`cloud.oxy.so/<fileId>`), never raw remote URLs —
16
+ * apps render them directly with no per-app proxy.
17
+ * - Resolution is best-effort and asynchronous. A preview is `'resolved'` once
18
+ * metadata is materialised, `'pending'` while a first-seen URL is being
19
+ * fetched in the background, or `'empty'` when the target yielded no usable
20
+ * metadata. `resolvedAt` (ISO datetime) is present only once `'resolved'`.
21
+ * - The batch response is keyed by the REQUESTED url (the exact string the
22
+ * caller sent), not the canonical/final URL, so a caller can always look its
23
+ * own input back up; the canonical URL lives on `LinkPreview.url`.
24
+ *
25
+ * The `LinkPreview` / `LinkPreviewBatchResponse` exports are declared as explicit
26
+ * `interface`s (with their runtime schemas annotated `z.ZodType<Interface>`),
27
+ * following the same rationale as `UserNameResponse` in `./userResponse`: a
28
+ * `z.infer<>` of a nested-object schema can degrade to `{}` under a consumer's
29
+ * `moduleResolution: "node"` (node10) resolution. A literal interface emits the
30
+ * field types verbatim in the `.d.ts` and survives BOTH `node` and `bundler`
31
+ * resolution. The flat batch-request schema (no nested-object hazard) is inferred
32
+ * via `z.infer<>`.
33
+ *
34
+ * Platform-agnostic — zod only, no react/react-native/expo. ESM-safe (no
35
+ * `require()`).
36
+ */
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = void 0;
39
+ const zod_1 = require("zod");
40
+ exports.linkPreviewSchema = zod_1.z.object({
41
+ url: zod_1.z.string(),
42
+ status: zod_1.z.enum(['resolved', 'pending', 'empty']),
43
+ title: zod_1.z.string().optional(),
44
+ description: zod_1.z.string().optional(),
45
+ image: zod_1.z.string().optional(),
46
+ siteName: zod_1.z.string().optional(),
47
+ favicon: zod_1.z.string().optional(),
48
+ resolvedAt: zod_1.z.string().optional(),
49
+ });
50
+ /* -------------------------------------------------------------------------- */
51
+ /* Batch request / response */
52
+ /* -------------------------------------------------------------------------- */
53
+ /**
54
+ * Request body for the batch unfurl endpoint. Between 1 and 50 URLs per call;
55
+ * the server resolves each (returning a `'pending'` placeholder for any URL it
56
+ * has not seen before and is fetching in the background).
57
+ */
58
+ exports.linkPreviewBatchRequestSchema = zod_1.z.object({
59
+ urls: zod_1.z.array(zod_1.z.string().max(2048)).min(1).max(50),
60
+ });
61
+ exports.linkPreviewBatchResponseSchema = zod_1.z.object({
62
+ data: zod_1.z.record(zod_1.z.string(), exports.linkPreviewSchema),
63
+ });
64
+ /**
65
+ * Wire shape of the single-URL unfurl lookup (`GET`) — a bare
66
+ * {@link LinkPreview}.
67
+ */
68
+ exports.linkPreviewResponseSchema = exports.linkPreviewSchema;
@@ -42,14 +42,16 @@ exports.userNameSchema = zod_1.z
42
42
  first: zod_1.z.string().optional(),
43
43
  last: zod_1.z.string().optional(),
44
44
  full: zod_1.z.string().optional(),
45
- displayName: zod_1.z.string(),
45
+ displayName: zod_1.z.string().optional(),
46
46
  })
47
47
  .passthrough();
48
48
  /**
49
49
  * The canonical user object emitted by `formatUserResponse`.
50
50
  *
51
- * `id` and `name.displayName` are guaranteed on formatted user DTOs. The rest
52
- * is forwarded from the user document and may be absent depending on the query's
51
+ * `id` is present on formatted user DTOs. `name.displayName` is OPTIONAL on the
52
+ * contract the API still synthesizes a default today, but consumers must not
53
+ * assume it is present and should fall back to a handle when it is absent. The
54
+ * rest is forwarded from the user document and may be absent depending on the query's
53
55
  * `.select(...)`/`.lean()` projection. Both `id` and `_id` are accepted because
54
56
  * some raw-document responses carry `_id` instead of `id`; resolve the
55
57
  * identifier with {@link resolveUserId}.