Skip to content

Commit 0807f24

Browse files
committed
typings: delegation record origin, account emails with the resend cooldown
@pryv/delegation: DelegateRecord and ControlledRecord gain the optional, core-set origin ('created' | 'attached', type DelegationOrigin), absent from cores up to 2.0.0-rc.92 (open-pryv.io issue 174). pryv: AccountInformation gains the optional emails (AccountEmail[]) returned by account.get / account.update, matching the server's result schema: value, primary, status, verifiedAt, verificationMethod and the optional verificationCooldownUntil. Typings test TYP5. Types only, no runtime change.
1 parent fa1afe0 commit 0807f24

5 files changed

Lines changed: 81 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Added
88

99
- **`@pryv/cmc` `errorIds`: `ACCEPT_WITHDRAWN`** (`'cmc-accept-withdrawn'`, on the accepter's accept trigger: a queued retry of an accept whose consent ended meanwhile, or that a newer accept for the same counterparty and scope replaced; nothing is minted or delivered again) **and `INCOMING_ACCEPT_SUPERSEDED`** (`'cmc-incoming-accept-superseded'`, on the requester's core: an accept received before the one the relationship is paired with, refused when retried). Both are permanent, never retried, and returned by open-pryv.io 2.0.0-rc.90 and later. Also in the `CmcErrorId` typing.
10+
- **`@pryv/delegation` typings: `DelegateRecord.origin` and `ControlledRecord.origin`** (`DelegationOrigin`, `'created' | 'attached'`): how the relationship was made, set by the core (open-pryv.io issue 174). Optional: absent from cores up to 2.0.0-rc.92. Types only, no runtime change.
11+
- **`pryv` typings: `AccountInformation.emails`** (`AccountEmail[]`, the result of `account.get` / `account.update` on cores with multiple emails per account): `value`, `primary`, `status` (`'pending' | 'verified'`), `verifiedAt`, `verificationMethod` (`AccountEmailVerificationMethod`) and `verificationCooldownUntil` (the time until which a new verification mail for the address is refused, `null` when no cooldown runs; optional, absent from cores up to 2.0.0-rc.92; a refused resend's `retryAfterSeconds` stays authoritative). Types only, no runtime change.
1012

1113
## 3.24.0 - 2026-11-25
1214

‎components/pryv-delegation/src/index.d.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ declare module '@pryv/delegation' {
6767
hostSlug: string;
6868
};
6969

70+
/** How a relationship was made, set by the core (read-only). */
71+
export type DelegationOrigin = 'created' | 'attached';
72+
7073
/** An entry of `listDelegates()` (B side). */
7174
export type DelegateRecord = {
7275
relId: string;
@@ -75,6 +78,8 @@ declare module '@pryv/delegation' {
7578
requestedAt: number;
7679
activatedAt?: number | null;
7780
lastTokenIssuedAt?: number | null;
81+
/** How the relationship was made: `'created'` (the delegate created the account) or `'attached'` (the account invited an existing delegate). Absent from cores up to 2.0.0-rc.92. */
82+
origin?: DelegationOrigin;
7883
};
7984

8085
/** An entry of `listControlled()` (A side). */
@@ -84,6 +89,8 @@ declare module '@pryv/delegation' {
8489
status: RelationshipStatus;
8590
requestedAt: number;
8691
activatedAt?: number | null;
92+
/** How the relationship was made: `'created'` (the delegate created the account) or `'attached'` (the account invited an existing delegate). Absent from cores up to 2.0.0-rc.92. */
93+
origin?: DelegationOrigin;
8794
};
8895

8996
/**

‎components/pryv/src/index.d.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@ declare module 'pryv' {
9090
accessToken: string;
9191
};
9292

93+
/** How an account email's ownership was established (`null`: stored before provenance was recorded). */
94+
export type AccountEmailVerificationMethod = 'email-link' | 'email-code' | 'operator' | 'registration' | 'legacy' | null;
95+
96+
/** An entry of `AccountInformation.emails`. */
97+
export type AccountEmail = {
98+
value: string;
99+
primary: boolean;
100+
status: 'pending' | 'verified';
101+
/** When the address was proved, `null` when it was not. */
102+
verifiedAt: Timestamp | null;
103+
verificationMethod: AccountEmailVerificationMethod;
104+
/**
105+
* Pryv timestamp until which a new verification mail for the address is refused;
106+
* `null` when no cooldown runs. A refused resend's `retryAfterSeconds` stays authoritative.
107+
* Absent from cores up to 2.0.0-rc.92.
108+
*/
109+
verificationCooldownUntil?: Timestamp | null;
110+
};
111+
93112
export type AccountInformation = {
94113
username: string;
95114
email: string;
@@ -98,6 +117,8 @@ declare module 'pryv' {
98117
dbDocuments: number;
99118
attachedFiles: number;
100119
};
120+
/** The account's email addresses (cores with multiple emails per account). */
121+
emails?: AccountEmail[];
101122
};
102123

103124
/** Trigger of an account auto-deletion schedule. */

‎components/pryv/test/typings.test.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ describe('[TYPX] typings', function () {
4747
it('[TYP4] the platform of a controller and of a stored sign-in', function () {
4848
expect(compile('storedPlatform.ts')).to.deep.equal([]);
4949
});
50+
51+
it('[TYP5] account emails: entries of account.get / account.update, optional verificationCooldownUntil', function () {
52+
expect(compile('accountEmails.ts')).to.deep.equal([]);
53+
});
5054
});
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license
3+
* [BSD-3-Clause](https://github.com/pryv/lib-js/blob/master/LICENSE)
4+
*/
5+
// Compiled (never run) by typings.test.js: the emails of `account.get` /
6+
// `account.update`, with the resend cooldown of newer cores.
7+
import type { AccountInformation as Account, AccountEmail as Email } from 'pryv';
8+
9+
export const pending: Email = {
10+
value: 'alice@example.com',
11+
primary: false,
12+
status: 'pending',
13+
verifiedAt: null,
14+
verificationMethod: null,
15+
verificationCooldownUntil: 1764320000
16+
};
17+
18+
// a core that does not return the cooldown
19+
export const older: Email = {
20+
value: 'alice@example.org',
21+
primary: true,
22+
status: 'verified',
23+
verifiedAt: null,
24+
verificationMethod: 'registration'
25+
};
26+
27+
// a core without multiple emails
28+
export const account: Account = {
29+
username: 'alice',
30+
email: 'alice@example.org',
31+
language: 'en',
32+
storageUsed: { dbDocuments: 0, attachedFiles: 0 }
33+
};
34+
35+
export function cooldownOf (a: Account, value: string): number | null {
36+
const entry = a.emails?.find((e) => e.value === value);
37+
return entry?.verificationCooldownUntil ?? null;
38+
}
39+
40+
export const bad: Email = {
41+
value: 'alice@example.net',
42+
primary: false,
43+
// @ts-expect-error not a status
44+
status: 'unknown',
45+
verifiedAt: null,
46+
verificationMethod: null
47+
};

0 commit comments

Comments
 (0)