@oxyhq/contracts 0.7.0 → 0.8.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.
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ export const sessionAccountSchema = z.object({
3
+ accountId: z.string(),
4
+ sessionId: z.string(),
5
+ authuser: z.number().int().nonnegative(),
6
+ operatedByUserId: z.string().optional(),
7
+ });
8
+ export const deviceSessionStateSchema = z.object({
9
+ deviceId: z.string(),
10
+ accounts: z.array(sessionAccountSchema),
11
+ activeAccountId: z.string().nullable(),
12
+ revision: z.number().int().nonnegative(),
13
+ updatedAt: z.number(),
14
+ });
15
+ export const activeTokenSchema = z.object({
16
+ accessToken: z.string(),
17
+ expiresAt: z.string(),
18
+ });
19
+ export const deviceSessionSyncSchema = z.object({
20
+ state: deviceSessionStateSchema,
21
+ activeToken: activeTokenSchema.nullable(),
22
+ });
@@ -42,5 +42,12 @@ export const fedcmTokenPayloadSchema = z
42
42
  exp: z.number().optional(),
43
43
  iat: z.number().optional(),
44
44
  nonce: z.string().optional(),
45
+ /**
46
+ * An explicit central deviceId minted by the IdP, threaded through so the
47
+ * RP session can inherit a unified device id instead of deriving one from
48
+ * the (userId, RP origin) stableDeviceKey. Optional and additive — omitted
49
+ * tokens fall back to the existing stableDeviceKey/UA-IP derivation.
50
+ */
51
+ deviceId: z.string().optional(),
45
52
  })
46
53
  .passthrough();
@@ -38,12 +38,27 @@
38
38
  * `require()`).
39
39
  */
40
40
  import { z } from 'zod';
41
- export const verificationMethodSchema = z.object({
41
+ // The option schemas are left UN-annotated so they keep their concrete
42
+ // `ZodObject` type — `z.discriminatedUnion` requires object options and an
43
+ // explicit `z.ZodType<>` annotation would erase the shape it discriminates on.
44
+ // `z.object` already infers each option's type exactly (id/type/controller +
45
+ // the key field), so the union is structurally `VerificationMethod`.
46
+ const secp256k1VerificationMethodSchema = z.object({
42
47
  id: z.string(),
43
48
  type: z.literal('EcdsaSecp256k1VerificationKey2019'),
44
49
  controller: z.string(),
45
50
  publicKeyHex: z.string(),
46
51
  });
52
+ const multikeyVerificationMethodSchema = z.object({
53
+ id: z.string(),
54
+ type: z.literal('Multikey'),
55
+ controller: z.string(),
56
+ publicKeyMultibase: z.string(),
57
+ });
58
+ export const verificationMethodSchema = z.discriminatedUnion('type', [
59
+ secp256k1VerificationMethodSchema,
60
+ multikeyVerificationMethodSchema,
61
+ ]);
47
62
  export const didServiceSchema = z.object({
48
63
  id: z.string(),
49
64
  type: z.string(),
package/dist/esm/index.js CHANGED
@@ -40,3 +40,4 @@ credentialRecordSchema, verifiableCredentialResponseSchema, credentialIssueResul
40
40
  export {
41
41
  // Schemas
42
42
  linkPreviewSchema, linkPreviewBatchRequestSchema, linkPreviewBatchResponseSchema, linkPreviewResponseSchema, } from './links.js';
43
+ export { sessionAccountSchema, deviceSessionStateSchema, activeTokenSchema, deviceSessionSyncSchema, } from './deviceSession.js';