@oxyhq/contracts 0.9.1 → 0.11.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/fedcmToken.js +10 -0
- package/dist/cjs/index.js +4 -6
- package/dist/cjs/sessionStatus.js +10 -6
- package/dist/cjs/userResponse.js +5 -28
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/fedcmToken.js +10 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/sessionStatus.js +10 -6
- package/dist/esm/userResponse.js +4 -27
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/deviceBoot.d.ts +3 -3
- package/dist/types/deviceSession.d.ts +24 -24
- package/dist/types/fedcmToken.d.ts +10 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/sessionStatus.d.ts +24 -6
- package/dist/types/userResponse.d.ts +10 -363
- package/package.json +1 -1
package/dist/cjs/fedcmToken.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Canonical contract for the FedCM ID-token JWT payload.
|
|
4
4
|
*
|
|
5
|
+
* DEAD SINCE THE WAVE-2 FEDCM DELETION (found during the comment sweep, not
|
|
6
|
+
* fixed here — this is a published `@oxyhq/contracts` export, so removing it
|
|
7
|
+
* is a breaking change/major-version decision, out of scope for a comment
|
|
8
|
+
* fix): `POST /fedcm/exchange`, `fedcm.service.exchangeIdToken`, and
|
|
9
|
+
* `packages/auth/server/index.ts`'s `mintSessionForClient` — every consumer
|
|
10
|
+
* and producer this file describes — are all deleted. No current code
|
|
11
|
+
* imports `fedcmTokenPayloadSchema` / `FedcmTokenPayload` outside this
|
|
12
|
+
* package. Flag for a follow-up major-version cleanup.
|
|
13
|
+
*
|
|
14
|
+
* Original doc (historical, describes the now-deleted system):
|
|
5
15
|
* SINGLE SOURCE OF TRUTH for the decoded claims of the HS256 ID token the auth
|
|
6
16
|
* IdP (`auth.oxy.so`) signs and `POST /fedcm/exchange` consumes. The API decodes
|
|
7
17
|
* the JWT, verifies its signature, then validates the resulting claim object
|
package/dist/cjs/index.js
CHANGED
|
@@ -11,18 +11,16 @@
|
|
|
11
11
|
* expo, no `require()` in the ESM build.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.validationVoteResultSchema = exports.validationRequestSummarySchema = exports.validationOpenResultSchema = exports.validationOpenRequestSchema = exports.validationVerdictRecordSchema = exports.realLifeAttestationResultSchema = exports.realLifeAttestationRecordSchema = exports.signedPublicCardSchema = exports.publicCardSchema = exports.logPageResponseSchema = exports.chainHeadResponseSchema = exports.oxySignedRecordTypeSchema = exports.exportBundleSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = exports.appAffinityEventsIngestSchema = exports.appAffinityEventSchema = exports.appAffinityEventTypeSchema = 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.
|
|
15
|
-
exports.deviceResolveResponseSchema = exports.deviceResolveRequestSchema = exports.loginResultSchema = exports.deviceTokenIssueResponseSchema = exports.tokenRefreshResponseSchema = exports.tokenRefreshRequestSchema = exports.webSessionResultSchema = exports.authTokenBundleSchema = exports.deviceExchangeRequestSchema = exports.deviceBootFragmentSchema = exports.deviceBootReasonSchema = exports.deviceSessionSyncSchema = exports.activeTokenSchema = exports.deviceSessionStateSchema = exports.sessionAccountSchema = exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = exports.verifiableCredentialResponseSchema = exports.credentialRecordSchema = exports.vouchResultSchema = exports.personhoodStatusResultSchema =
|
|
14
|
+
exports.personhoodBreakdownSchema = exports.personhoodVouchRecordSchema = exports.validationVoteResultSchema = exports.validationRequestSummarySchema = exports.validationOpenResultSchema = exports.validationOpenRequestSchema = exports.validationVerdictRecordSchema = exports.realLifeAttestationResultSchema = exports.realLifeAttestationRecordSchema = exports.signedPublicCardSchema = exports.publicCardSchema = exports.logPageResponseSchema = exports.chainHeadResponseSchema = exports.oxySignedRecordTypeSchema = exports.exportBundleSchema = exports.exportAttestationSchema = exports.authMethodsResponseSchema = exports.authMethodEntrySchema = exports.domainVerificationInstructionsSchema = exports.domainVerificationRequestSchema = exports.verifiedDomainSchema = exports.signedRecordEnvelopeSchema = exports.didDocumentSchema = exports.didServiceSchema = exports.verificationMethodSchema = exports.appAffinityEventsIngestSchema = exports.appAffinityEventSchema = exports.appAffinityEventTypeSchema = 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.deviceLinkedSessionsResponseSchema = exports.deviceLinkedSessionSchema = exports.currentUserResponseSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.userNameSchema = void 0;
|
|
15
|
+
exports.deviceResolveResponseSchema = exports.deviceResolveRequestSchema = exports.loginResultSchema = exports.deviceTokenIssueResponseSchema = exports.tokenRefreshResponseSchema = exports.tokenRefreshRequestSchema = exports.webSessionResultSchema = exports.authTokenBundleSchema = exports.deviceExchangeRequestSchema = exports.deviceBootFragmentSchema = exports.deviceBootReasonSchema = exports.deviceSessionSyncSchema = exports.activeTokenSchema = exports.deviceSessionStateSchema = exports.sessionAccountSchema = exports.linkPreviewResponseSchema = exports.linkPreviewBatchResponseSchema = exports.linkPreviewBatchRequestSchema = exports.linkPreviewSchema = exports.credentialVerifyResultSchema = exports.credentialListResultSchema = exports.credentialIssueResultSchema = exports.verifiableCredentialResponseSchema = exports.credentialRecordSchema = exports.vouchResultSchema = exports.personhoodStatusResultSchema = 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; } });
|
|
19
19
|
Object.defineProperty(exports, "userResponseSchema", { enumerable: true, get: function () { return userResponse_1.userResponseSchema; } });
|
|
20
20
|
Object.defineProperty(exports, "userProfileUpdateSchema", { enumerable: true, get: function () { return userResponse_1.userProfileUpdateSchema; } });
|
|
21
|
-
Object.defineProperty(exports, "refreshAllAccountSchema", { enumerable: true, get: function () { return userResponse_1.refreshAllAccountSchema; } });
|
|
22
|
-
Object.defineProperty(exports, "refreshAllResponseSchema", { enumerable: true, get: function () { return userResponse_1.refreshAllResponseSchema; } });
|
|
23
21
|
Object.defineProperty(exports, "currentUserResponseSchema", { enumerable: true, get: function () { return userResponse_1.currentUserResponseSchema; } });
|
|
24
|
-
Object.defineProperty(exports, "
|
|
25
|
-
Object.defineProperty(exports, "
|
|
22
|
+
Object.defineProperty(exports, "deviceLinkedSessionSchema", { enumerable: true, get: function () { return userResponse_1.deviceLinkedSessionSchema; } });
|
|
23
|
+
Object.defineProperty(exports, "deviceLinkedSessionsResponseSchema", { enumerable: true, get: function () { return userResponse_1.deviceLinkedSessionsResponseSchema; } });
|
|
26
24
|
// Helpers
|
|
27
25
|
Object.defineProperty(exports, "resolveUserId", { enumerable: true, get: function () { return userResponse_1.resolveUserId; } });
|
|
28
26
|
Object.defineProperty(exports, "safeParseContract", { enumerable: true, get: function () { return userResponse_1.safeParseContract; } });
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
* Faithful to the producers:
|
|
21
21
|
* - `packages/api/src/utils/serializeApplication.ts` `serializePublicApplication`
|
|
22
22
|
* — the ONLY shape returned to an unauthenticated consent UI. Optional fields
|
|
23
|
-
* (`description`, `icon`, `websiteUrl`, `
|
|
24
|
-
* absent (never serialized as `null`), so
|
|
25
|
-
* `.nullable()`. `type` is the `Application.type`
|
|
23
|
+
* (`description`, `icon`, `websiteUrl`, `privacyPolicyUrl`, `termsUrl`,
|
|
24
|
+
* `developerName`) are OMITTED when absent (never serialized as `null`), so
|
|
25
|
+
* they are `.optional()` — NOT `.nullable()`. `type` is the `Application.type`
|
|
26
|
+
* enum.
|
|
26
27
|
* - `packages/api/src/routes/auth.ts` `GET /session/status/:sessionToken` — the
|
|
27
28
|
* inner object of the API's `{ data: ... }` success envelope. The handler
|
|
28
29
|
* ALWAYS emits `status`, `authorized` (`status === 'authorized'`),
|
|
@@ -55,9 +56,10 @@ exports.applicationTypeSchema = zod_1.z.enum([
|
|
|
55
56
|
* `GET /auth/oauth/client/:clientId` (OAuth code flow).
|
|
56
57
|
*
|
|
57
58
|
* Optional fields are `.optional()` (NOT `.nullable()`): the serializer OMITS
|
|
58
|
-
* `description` / `icon` / `websiteUrl` / `
|
|
59
|
-
* value is absent — it never writes `null`
|
|
60
|
-
* attached for non-official apps when a name
|
|
59
|
+
* `description` / `icon` / `websiteUrl` / `privacyPolicyUrl` / `termsUrl` /
|
|
60
|
+
* `developerName` when the underlying value is absent — it never writes `null`
|
|
61
|
+
* for them. `developerName` is only attached for non-official apps when a name
|
|
62
|
+
* could be resolved.
|
|
61
63
|
*/
|
|
62
64
|
exports.publicApplicationSchema = zod_1.z.object({
|
|
63
65
|
id: zod_1.z.string(),
|
|
@@ -65,6 +67,8 @@ exports.publicApplicationSchema = zod_1.z.object({
|
|
|
65
67
|
description: zod_1.z.string().optional(),
|
|
66
68
|
icon: zod_1.z.string().optional(),
|
|
67
69
|
websiteUrl: zod_1.z.string().optional(),
|
|
70
|
+
privacyPolicyUrl: zod_1.z.string().optional(),
|
|
71
|
+
termsUrl: zod_1.z.string().optional(),
|
|
68
72
|
type: exports.applicationTypeSchema,
|
|
69
73
|
isOfficial: zod_1.z.boolean(),
|
|
70
74
|
isInternal: zod_1.z.boolean(),
|
package/dist/cjs/userResponse.js
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
*
|
|
18
18
|
* Faithful to the producers:
|
|
19
19
|
* - `packages/api/src/utils/userTransform.ts` `formatUserResponse` — the
|
|
20
|
-
* canonical serialization used by
|
|
20
|
+
* canonical serialization used by the device-first bootstrap/exchange
|
|
21
|
+
* endpoints (`deviceAuth.ts`), login/signup, device sessions, etc.
|
|
21
22
|
* Emits `id` (NOT `_id`), forwards `username` verbatim (may be absent), and
|
|
22
23
|
* emits `name` as the structured `{ first, last, full, displayName }`
|
|
23
24
|
* subdocument.
|
|
@@ -25,14 +26,12 @@
|
|
|
25
26
|
* `''`; `full` and `displayName` are Mongoose VIRTUALS. Formatted API
|
|
26
27
|
* responses compose both fields, while raw-document responses may omit the
|
|
27
28
|
* virtuals if the query did not materialise them.
|
|
28
|
-
* - The `/auth/refresh-all` handler in `packages/api/src/routes/auth.ts`, whose
|
|
29
|
-
* per-slot `authuser` is the numeric `oxy_rt_${authuser}` cookie slot.
|
|
30
29
|
*
|
|
31
30
|
* Platform-agnostic — zod only, no react/react-native/expo. ESM-safe (no
|
|
32
31
|
* `require()`).
|
|
33
32
|
*/
|
|
34
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
34
|
+
exports.deviceLinkedSessionsResponseSchema = exports.deviceLinkedSessionSchema = exports.currentUserResponseSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.userNameSchema = void 0;
|
|
36
35
|
exports.resolveUserId = resolveUserId;
|
|
37
36
|
exports.safeParseContract = safeParseContract;
|
|
38
37
|
const zod_1 = require("zod");
|
|
@@ -136,28 +135,6 @@ exports.userProfileUpdateSchema = zod_1.z
|
|
|
136
135
|
function resolveUserId(user) {
|
|
137
136
|
return user.id ?? user._id;
|
|
138
137
|
}
|
|
139
|
-
/**
|
|
140
|
-
* One rotated account entry from `POST /auth/refresh-all`.
|
|
141
|
-
*
|
|
142
|
-
* `authuser` is the device-local slot index (`0..N-1`). `user` is the canonical
|
|
143
|
-
* {@link userResponseSchema} shape (the handler projects a whitelist and runs it
|
|
144
|
-
* through `formatUserResponse`).
|
|
145
|
-
*/
|
|
146
|
-
exports.refreshAllAccountSchema = zod_1.z.object({
|
|
147
|
-
authuser: zod_1.z.number().int().nonnegative(),
|
|
148
|
-
accessToken: zod_1.z.string(),
|
|
149
|
-
expiresAt: zod_1.z.string(),
|
|
150
|
-
sessionId: zod_1.z.string(),
|
|
151
|
-
user: exports.userResponseSchema,
|
|
152
|
-
});
|
|
153
|
-
/**
|
|
154
|
-
* Wire shape of `POST /auth/refresh-all`: every valid device-local account,
|
|
155
|
-
* sorted by `authuser` ascending. An empty `accounts` array means "no signed-in
|
|
156
|
-
* accounts on this device" — the IdP must show the sign-in form.
|
|
157
|
-
*/
|
|
158
|
-
exports.refreshAllResponseSchema = zod_1.z.object({
|
|
159
|
-
accounts: zod_1.z.array(exports.refreshAllAccountSchema),
|
|
160
|
-
});
|
|
161
138
|
/**
|
|
162
139
|
* Wire shape of `GET /users/me` — the API success envelope (`{ data: <user> }`)
|
|
163
140
|
* wrapping the current-user DTO. Some older producers use `_id` instead of
|
|
@@ -173,13 +150,13 @@ exports.currentUserResponseSchema = zod_1.z.object({
|
|
|
173
150
|
* session). Backs the multi-account chooser. The embedded user mirrors
|
|
174
151
|
* `formatUserResponse`; it is nullable on slots that lost their user document.
|
|
175
152
|
*/
|
|
176
|
-
exports.
|
|
153
|
+
exports.deviceLinkedSessionSchema = zod_1.z.object({
|
|
177
154
|
sessionId: zod_1.z.string(),
|
|
178
155
|
isCurrent: zod_1.z.boolean().optional(),
|
|
179
156
|
user: exports.userResponseSchema.nullable().optional(),
|
|
180
157
|
});
|
|
181
158
|
/** Wire shape of `GET /session/device/sessions/:sessionId` (an array). */
|
|
182
|
-
exports.
|
|
159
|
+
exports.deviceLinkedSessionsResponseSchema = zod_1.z.array(exports.deviceLinkedSessionSchema);
|
|
183
160
|
/**
|
|
184
161
|
* Safely parse a value against a contract schema. Returns the parsed (typed)
|
|
185
162
|
* value, or `null` when validation fails — the same ergonomics the auth app's
|