@oxyhq/contracts 0.9.0 → 0.9.1
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/deviceBoot.js +51 -8
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/userResponse.js +0 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/deviceBoot.js +50 -7
- package/dist/esm/index.js +1 -1
- package/dist/esm/userResponse.js +0 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/deviceBoot.d.ts +69 -14
- package/dist/types/index.d.ts +2 -2
- package/dist/types/userResponse.d.ts +0 -3
- package/package.json +1 -1
package/dist/cjs/deviceBoot.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* `require()`).
|
|
36
36
|
*/
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.deviceResolveResponseSchema = exports.deviceResolveRequestSchema = exports.loginResultSchema = exports.deviceTokenIssueResponseSchema = exports.tokenRefreshResponseSchema = exports.tokenRefreshRequestSchema = exports.authTokenBundleSchema = exports.deviceExchangeRequestSchema = exports.deviceBootFragmentSchema = exports.deviceBootReasonSchema = void 0;
|
|
38
|
+
exports.deviceResolveResponseSchema = exports.deviceResolveRequestSchema = exports.loginResultSchema = exports.deviceTokenIssueResponseSchema = exports.tokenRefreshResponseSchema = exports.tokenRefreshRequestSchema = exports.webSessionResultSchema = exports.authTokenBundleSchema = exports.deviceExchangeRequestSchema = exports.deviceBootFragmentSchema = exports.deviceBootReasonSchema = void 0;
|
|
39
39
|
const zod_1 = require("zod");
|
|
40
40
|
const userResponse_1 = require("./userResponse");
|
|
41
41
|
/* -------------------------------------------------------------------------- */
|
|
@@ -51,17 +51,36 @@ const userResponse_1 = require("./userResponse");
|
|
|
51
51
|
exports.deviceBootReasonSchema = zod_1.z.enum(['session', 'no_session', 'new_device']);
|
|
52
52
|
/**
|
|
53
53
|
* The `#oxy_boot=<json>` fragment `GET /auth/device/bootstrap` appends to the
|
|
54
|
-
* `return_to` URL. Carries the CSRF `state` echo, the resolution `reason`,
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* `return_to` URL. Carries the CSRF `state` echo, the resolution `reason`, the
|
|
55
|
+
* opaque `deviceToken`, and — ONLY on the `session` arm — the single-use
|
|
56
|
+
* exchange `code`. NEVER carries tokens or a deviceId.
|
|
57
|
+
*
|
|
58
|
+
* Discriminated on `reason` so the code↔reason coupling is enforced by the
|
|
59
|
+
* schema, not by the consumer: the `session` arm REQUIRES `code`, and the
|
|
60
|
+
* `no_session` / `new_device` arms omit it (a stray `code` on those arms is
|
|
61
|
+
* stripped). A `session` fragment WITHOUT a code therefore fails to parse and
|
|
62
|
+
* is treated as "no usable fragment" rather than half-processed.
|
|
57
63
|
*/
|
|
58
|
-
|
|
64
|
+
const deviceBootFragmentBase = {
|
|
59
65
|
v: zod_1.z.literal(1),
|
|
60
66
|
state: zod_1.z.string().min(1).max(256),
|
|
61
|
-
reason: exports.deviceBootReasonSchema,
|
|
62
|
-
code: zod_1.z.string().min(20).max(128).optional(),
|
|
63
67
|
deviceToken: zod_1.z.string().min(20).max(512),
|
|
64
|
-
}
|
|
68
|
+
};
|
|
69
|
+
exports.deviceBootFragmentSchema = zod_1.z.discriminatedUnion('reason', [
|
|
70
|
+
zod_1.z.object({
|
|
71
|
+
...deviceBootFragmentBase,
|
|
72
|
+
reason: zod_1.z.literal('session'),
|
|
73
|
+
code: zod_1.z.string().min(20).max(128),
|
|
74
|
+
}),
|
|
75
|
+
zod_1.z.object({
|
|
76
|
+
...deviceBootFragmentBase,
|
|
77
|
+
reason: zod_1.z.literal('no_session'),
|
|
78
|
+
}),
|
|
79
|
+
zod_1.z.object({
|
|
80
|
+
...deviceBootFragmentBase,
|
|
81
|
+
reason: zod_1.z.literal('new_device'),
|
|
82
|
+
}),
|
|
83
|
+
]);
|
|
65
84
|
/* -------------------------------------------------------------------------- */
|
|
66
85
|
/* Boot-code exchange */
|
|
67
86
|
/* -------------------------------------------------------------------------- */
|
|
@@ -76,6 +95,30 @@ exports.authTokenBundleSchema = zod_1.z.object({
|
|
|
76
95
|
expiresAt: zod_1.z.string(),
|
|
77
96
|
user: userResponse_1.userResponseSchema,
|
|
78
97
|
});
|
|
98
|
+
// Internal (unexported) arm schemas — PLAIN `z.object` literals (no
|
|
99
|
+
// `z.ZodType<>` annotation) so `z.discriminatedUnion` can introspect the
|
|
100
|
+
// `reason` discriminator. The node10 `.d.ts`-degradation safety comes from the
|
|
101
|
+
// EXPORTED symbols instead: the public types are explicit interfaces
|
|
102
|
+
// (`WebSessionSession` / `WebSessionNoSession` / `WebSessionResult`) and the
|
|
103
|
+
// exported schema is annotated `z.ZodType<WebSessionResult>` below, so the
|
|
104
|
+
// emitted declaration states the shape literally rather than a degradable
|
|
105
|
+
// `z.infer<>` of the nested `session` object.
|
|
106
|
+
const webSessionSessionSchema = zod_1.z.object({
|
|
107
|
+
reason: zod_1.z.literal('session'),
|
|
108
|
+
session: exports.authTokenBundleSchema,
|
|
109
|
+
deviceToken: zod_1.z.string().min(1),
|
|
110
|
+
});
|
|
111
|
+
const webSessionNoSessionSchema = zod_1.z.object({
|
|
112
|
+
reason: zod_1.z.enum(['no_session', 'new_device']),
|
|
113
|
+
deviceToken: zod_1.z.string().min(1),
|
|
114
|
+
});
|
|
115
|
+
// Discriminated on `reason` — a true `discriminatedUnion` (not `z.union`): it
|
|
116
|
+
// dispatches on the discriminator instead of sequentially probing each arm,
|
|
117
|
+
// giving precise per-arm errors.
|
|
118
|
+
exports.webSessionResultSchema = zod_1.z.discriminatedUnion('reason', [
|
|
119
|
+
webSessionSessionSchema,
|
|
120
|
+
webSessionNoSessionSchema,
|
|
121
|
+
]);
|
|
79
122
|
/* -------------------------------------------------------------------------- */
|
|
80
123
|
/* Refresh-token rotation (web + native, one implementation) */
|
|
81
124
|
/* -------------------------------------------------------------------------- */
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
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.deviceSessionsResponseSchema = exports.deviceSessionAccountSchema = exports.currentUserResponseSchema = exports.refreshAllResponseSchema = exports.refreshAllAccountSchema = exports.userProfileUpdateSchema = exports.userResponseSchema = exports.userNameSchema = void 0;
|
|
15
|
-
exports.deviceResolveResponseSchema = exports.deviceResolveRequestSchema = exports.loginResultSchema = exports.deviceTokenIssueResponseSchema = exports.tokenRefreshResponseSchema = exports.tokenRefreshRequestSchema = 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 = exports.personhoodBreakdownSchema = exports.personhoodVouchRecordSchema = 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 = exports.personhoodBreakdownSchema = exports.personhoodVouchRecordSchema = 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; } });
|
|
@@ -107,6 +107,7 @@ Object.defineProperty(exports, "deviceBootReasonSchema", { enumerable: true, get
|
|
|
107
107
|
Object.defineProperty(exports, "deviceBootFragmentSchema", { enumerable: true, get: function () { return deviceBoot_1.deviceBootFragmentSchema; } });
|
|
108
108
|
Object.defineProperty(exports, "deviceExchangeRequestSchema", { enumerable: true, get: function () { return deviceBoot_1.deviceExchangeRequestSchema; } });
|
|
109
109
|
Object.defineProperty(exports, "authTokenBundleSchema", { enumerable: true, get: function () { return deviceBoot_1.authTokenBundleSchema; } });
|
|
110
|
+
Object.defineProperty(exports, "webSessionResultSchema", { enumerable: true, get: function () { return deviceBoot_1.webSessionResultSchema; } });
|
|
110
111
|
Object.defineProperty(exports, "tokenRefreshRequestSchema", { enumerable: true, get: function () { return deviceBoot_1.tokenRefreshRequestSchema; } });
|
|
111
112
|
Object.defineProperty(exports, "tokenRefreshResponseSchema", { enumerable: true, get: function () { return deviceBoot_1.tokenRefreshResponseSchema; } });
|
|
112
113
|
Object.defineProperty(exports, "deviceTokenIssueResponseSchema", { enumerable: true, get: function () { return deviceBoot_1.deviceTokenIssueResponseSchema; } });
|
package/dist/cjs/userResponse.js
CHANGED
|
@@ -111,7 +111,6 @@ exports.userProfileUpdateSchema = zod_1.z
|
|
|
111
111
|
phone: zod_1.z.string().optional(),
|
|
112
112
|
address: zod_1.z.string().optional(),
|
|
113
113
|
birthday: zod_1.z.string().optional(),
|
|
114
|
-
location: zod_1.z.string().optional(),
|
|
115
114
|
locations: zod_1.z.array(zod_1.z.unknown()).optional(),
|
|
116
115
|
links: zod_1.z.array(zod_1.z.string()).optional(),
|
|
117
116
|
linksMetadata: zod_1.z
|