@dotrino/identity 0.135.0 → 0.136.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotrino/identity",
3
- "version": "0.135.0",
3
+ "version": "0.136.0",
4
4
  "description": "Identidad y rating de usuarios compartidos entre apps de Dotrino (vault iframe + postMessage)",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -15,9 +15,11 @@
15
15
  "import": "./src/node.js"
16
16
  },
17
17
  "./capabilities": {
18
+ "types": "./types/capabilities.d.ts",
18
19
  "import": "./vault/capabilities.js"
19
20
  },
20
21
  "./avatar": {
22
+ "types": "./types/avatar.d.ts",
21
23
  "import": "./vault/avatar.js"
22
24
  },
23
25
  "./facade": {
@@ -28,7 +30,12 @@
28
30
  "./machine": {
29
31
  "import": "./vault/machine.js"
30
32
  },
33
+ "./vault-seal": {
34
+ "types": "./types/vaultSeal.d.ts",
35
+ "import": "./vault/vaultSeal.js"
36
+ },
31
37
  "./acta": {
38
+ "types": "./types/acta.d.ts",
32
39
  "import": "./vault/acta.js"
33
40
  },
34
41
  "./content": {
@@ -38,28 +45,34 @@
38
45
  "import": "./vault/channel.js"
39
46
  },
40
47
  "./assertion": {
48
+ "types": "./types/assertion.d.ts",
41
49
  "import": "./vault/assertion.js"
42
50
  },
43
51
  "./keyid": {
52
+ "types": "./types/keyid.d.ts",
44
53
  "import": "./vault/keyid.js"
45
54
  },
46
55
  "./session": {
56
+ "types": "./types/session.d.ts",
47
57
  "import": "./vault/session.js"
48
58
  },
49
59
  "./session-flow": {
60
+ "types": "./types/sessionFlow.d.ts",
50
61
  "import": "./vault/sessionFlow.js"
51
62
  }
52
63
  },
53
64
  "files": [
54
65
  "src",
55
66
  "vault",
67
+ "types",
56
68
  "README.md",
57
69
  "LICENSE"
58
70
  ],
59
71
  "scripts": {
60
72
  "vendor": "node vendor.mjs",
61
73
  "test": "node --test \"test/*.test.js\" \"test/*.test.mjs\"",
62
- "type-check": "tsc --noEmit"
74
+ "type-check": "tsc --noEmit",
75
+ "types": "tsc -p tsconfig.types.json"
63
76
  },
64
77
  "keywords": [
65
78
  "identity",
@@ -81,6 +94,6 @@
81
94
  "@types/node": "^22.0.0"
82
95
  },
83
96
  "peerDependencies": {
84
- "@dotrino/proxy-client": ">=0.13.1"
97
+ "@dotrino/proxy-client": ">=0.20.0"
85
98
  }
86
99
  }
package/src/index.d.ts CHANGED
@@ -68,8 +68,19 @@ export interface PeerInfo {
68
68
  /** You blocked them (private, never published). */
69
69
  blocked?: boolean
70
70
  changedAt?: number
71
+ /** In your contact book (`addContact`). */
72
+ isContact?: boolean
73
+ /** Your private notes on the contact. */
74
+ contactNotes?: string
75
+ /** The last proxy token they were seen on. */
76
+ lastToken?: string
77
+ /** Their verified profile card (`adoptPeerCard`). */
78
+ card?: ProfileCard | null
71
79
  }
72
80
 
81
+ /** La tarjeta de perfil de una persona: sus aparatos, sellada por su cuenta. */
82
+ export interface ProfileCard { profileId: string; seq: number; keys: any[]; [k: string]: any }
83
+
73
84
  export interface Challenge {
74
85
  nonce: string
75
86
  }
@@ -127,7 +138,8 @@ export class Identity {
127
138
  ): Promise<PeerInfo | null>
128
139
  removeContact (publickey: string): Promise<PeerInfo | null>
129
140
  listContacts (): Promise<PeerInfo[]>
130
- signData (data: any): Promise<{ signature: string; publickey: string }>
141
+ /** Firma `data`. `publickey` es la llave de ESTE aparato; `profileId` y `chain` dicen a nombre de quién y lo prueban. */
142
+ signData (data: any): Promise<{ signature: string; publickey: string; profileId: string; chain: Acta[] }>
131
143
  requestAssertion (args: { audience: string; nonce: string; scopes?: AssertionScope[]; ttlMs?: number; onBehalfOf?: string }): Promise<Assertion>
132
144
  /** Qué le has concedido a cada aplicación (permiso por origen). */
133
145
  listGrants (): Promise<Array<{ origin: string; scopes: AssertionScope[]; at: number; lastUsed: number; onBehalfOf?: string }>>
@@ -147,7 +159,7 @@ export class Identity {
147
159
  mergeEndorsements (
148
160
  subject: string,
149
161
  endorsements: SignedRating[],
150
- askerPubkey?: string
162
+ askerPubkey?: string | null
151
163
  ): Promise<{ merged: number; total: number }>
152
164
  getRatingsForSubject (
153
165
  subject: string
@@ -169,7 +181,12 @@ export class Identity {
169
181
  syncNow (): Promise<SyncStatus>
170
182
  onSync (handler: (event: SyncEvent) => void): () => void
171
183
  // vault (este dispositivo es cliente de un vault externo)
172
- enrollDevice (qr: string): Promise<any>
184
+ /**
185
+ * Empareja este aparato con la bóveda a partir de la invitación (el QR v2 ya leído, como
186
+ * objeto). `join`: `'new'` crea una cuenta más, `'current'` sigue con la abierta, `'adopt'`
187
+ * la lleva a vivir en la bóveda.
188
+ */
189
+ enrollDevice (qr: VaultInvitation, opts?: { label?: string; join?: 'new' | 'current' | 'adopt'; account?: string | null }): Promise<{ ok: boolean; deviceId: string; master: string; exp?: number; scope?: string[]; [k: string]: any }>
173
190
  vaultStatus (): Promise<any>
174
191
  vaultUnpair (): Promise<any>
175
192
  vaultSign (payload: any): Promise<{ signature: string; publickey: string }>
@@ -205,6 +222,40 @@ export class Identity {
205
222
  openContent (envelope: { gen: number; iv: string; ct: string; t?: string }): Promise<string>
206
223
  /** Mi copia de la llave de la cuenta vigente, o null si todavía no me la han envuelto. */
207
224
  contentKey (): Promise<{ gen: number; cek: string } | null>
225
+ /**
226
+ * El ACTA DE PERFIL vigente de este aparato (quién es de la cuenta y qué puede cada uno),
227
+ * si me consideran master y mis permisos efectivos. `null` si este perfil aún no tiene acta.
228
+ */
229
+ profileActa (): Promise<ProfileActa | null>
230
+ /** La cadena de selladores para mandar junto a una firma: `[génesis, …cambios de sellador…, acta actual]`. */
231
+ sealerChain (): Promise<Acta[]>
232
+ /** El candado del perfil activo. */
233
+ profileLockStatus (): Promise<{ protected: boolean; locked: boolean }>
234
+ /** Abre el perfil activo con su contraseña o PIN (la prueba queda por pestaña). */
235
+ unlockProfile (password: string): Promise<any>
236
+ /** Protege el perfil ACTIVO con contraseña o PIN (local de este aparato). */
237
+ setProfilePassword (password: string): Promise<{ ok: true }>
238
+ /** Quita la protección (requiere el perfil abierto). */
239
+ removeProfilePassword (): Promise<{ ok: true }>
240
+ /** Crea un perfil nuevo y lo deja activo (la app recarga). `forVault`: nace para adoptar la cuenta de una bóveda. */
241
+ createProfile (name?: string, opts?: { forVault?: boolean }): Promise<{ id: string; name?: string; pubkey: string; pendingJoin: boolean }>
242
+ /**
243
+ * Entra con `nombre@AB12-CD34-EF56` y contraseña (OPAQUE: la contraseña no sale de aquí).
244
+ * Errores con `code`: `login-failed`, `too-many-tries` (con `waitMs`), `no-vault`.
245
+ */
246
+ loginWithPassword (opts: { address: string; password: string; remember?: boolean; label?: string; proxyUrl?: string | null }): Promise<{ id: string; name: string; address: string; user: string; sid: string; volatile: boolean }>
247
+ /** Tu `me` completo (incluye lo oculto). */
248
+ getMe (): Promise<Me>
249
+ /** Renombra un perfil (o el activo, sin `id`). */
250
+ renameProfile (id: string | null, name: string): Promise<{ id: string; name: string }>
251
+ /** Borra un perfil y sus datos (no el único). */
252
+ deleteProfile (id: string): Promise<{ wasCurrent: boolean; [k: string]: any }>
253
+ /** La tarjeta de perfil de esta cuenta (sale del acta), o `null`. */
254
+ profileCard (): Promise<ProfileCard | null>
255
+ /** Guarda la tarjeta de otra persona en su ficha de contacto, verificándola. */
256
+ adoptPeerCard (card: ProfileCard): Promise<{ adopted: boolean; reason: string; devices: number }>
257
+ /** Actualiza tu perfil (merge): no pisa lo que no mandes. */
258
+ updateMe (patch: Partial<Me> & Record<string, any>): Promise<{ me: Me }>
208
259
  // self-vault (este dispositivo ES el vault, daemon dentro del iframe)
209
260
  selfVaultStatus (): Promise<{ enabled: boolean; running: boolean }>
210
261
  setSelfVault (enabled: boolean): Promise<{ ok: true; enabled: boolean }>
@@ -219,6 +270,35 @@ export class Identity {
219
270
  on (event: 'peer_updated' | 'me_updated' | 'sync' | 'vault' | 'selfVault', handler: (payload: any) => void): () => void
220
271
  }
221
272
 
273
+ /** Un miembro del acta: su llave pública y lo que el acta le deja hacer. */
274
+ export interface ActaMember {
275
+ pub: string
276
+ label?: string
277
+ caps?: string[]
278
+ /** Servicio o pieza del perfil (p. ej. `'vault'`, la llave de comunicación de una bóveda). */
279
+ cn?: string
280
+ /** Con `cn: 'vault'`: la maestra de esa bóveda. */
281
+ vault?: string
282
+ encPub?: string
283
+ [k: string]: any
284
+ }
285
+
286
+ /** El acta de perfil, sellada por su cuenta (`dotrino-vault/docs/acta-de-perfil.md`). */
287
+ export interface Acta {
288
+ v: number
289
+ profileId: string
290
+ seq: number
291
+ members: ActaMember[]
292
+ sealedBy?: string
293
+ sig?: string
294
+ [k: string]: any
295
+ }
296
+
297
+ export interface ProfileActa { acta: Acta; isMaster: boolean; myCaps: string[] }
298
+
299
+ /** La invitación de una bóveda (el QR v2 de `dotrino-vault pair`, ya leído). */
300
+ export interface VaultInvitation { v?: number; iss?: string; conn?: string; proxy?: string; token?: string; sn: string; m?: string; [k: string]: any }
301
+
222
302
  export interface SyncStatus {
223
303
  kind?: 'identity' | 'store'
224
304
  connected: boolean
@@ -260,6 +340,9 @@ export function makeDeviceKey (opts?: { label?: string }): Promise<DeviceKey>
260
340
  export function pubkeyId (publicJwkStr: string): Promise<string>
261
341
  /** Firma datos con una clave de dispositivo (formato byte-idéntico a signData). */
262
342
  export function signWithDevice (args: { privateJwk: JsonWebKey; data: any }): Promise<{ signature: string; publickey: string }>
343
+
344
+ /** ¿`signature` es la firma de `publickey` sobre `data` (JSON canónico)? */
345
+ export function verifyDeviceSig (args: { publickey: string; data: any; signature: string }): Promise<boolean>
263
346
  /** Verifica un certificado de delegación (firma de la maestra + exp + scope + sub + revocación). */
264
347
  export function verifyDelegation (args: { cert: CapabilityCert; expectedScope?: string; expectedSub?: string; now?: number; revoked?: ((nonce: string) => boolean) | Set<string> | Record<string, any> }): Promise<{ ok: boolean; reason?: string; iss?: string; sub?: string; scope?: string | string[]; iat?: number; exp?: number; nonce?: string }>
265
348
  /** Verifica la cadena de una acción/pin delegado: D firmó + cert prueba D←P + scope/exp/revocación. */