@getpara/shared 1.29.0 → 1.31.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,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.permissionsV2UserParameterHistorySchema = exports.permissionsV2UserParameterViewSchema = exports.permissionsV2UserParameterReadyViewSchema = exports.permissionsV2UserParameterResetSchema = exports.permissionsV2UserParameterSaveSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const templateRevisionFields = {
6
+ policyVersion: zod_1.z.string().min(1),
7
+ policyHash: zod_1.z.string().min(1),
8
+ expectedRevision: zod_1.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
9
+ };
10
+ exports.permissionsV2UserParameterSaveSchema = zod_1.z
11
+ .object({
12
+ ...templateRevisionFields,
13
+ values: zod_1.z.record(zod_1.z.string()),
14
+ })
15
+ .strict();
16
+ exports.permissionsV2UserParameterResetSchema = zod_1.z.object(templateRevisionFields).strict();
17
+ const storedRevision = zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
18
+ const provenance = zod_1.z.enum(['default', 'personal']);
19
+ const parameterDescriptor = zod_1.z
20
+ .object({
21
+ id: zod_1.z.string().min(1),
22
+ label: zod_1.z.string().min(1),
23
+ defaultValue: zod_1.z.string(),
24
+ fact: zod_1.z.string().min(1),
25
+ asset: zod_1.z.string().optional(),
26
+ window: zod_1.z.string().optional(),
27
+ })
28
+ .strict();
29
+ const viewFields = {
30
+ userId: zod_1.z.string().min(1),
31
+ partnerId: zod_1.z.string().min(1),
32
+ appId: zod_1.z.string().min(1),
33
+ policyId: zod_1.z.string().min(1),
34
+ policyVersion: zod_1.z.string().min(1),
35
+ policyHash: zod_1.z.string().min(1),
36
+ parameters: zod_1.z.array(parameterDescriptor),
37
+ };
38
+ exports.permissionsV2UserParameterReadyViewSchema = zod_1.z.union([
39
+ zod_1.z
40
+ .object({
41
+ ...viewFields,
42
+ status: zod_1.z.literal('ready'),
43
+ revision: zod_1.z.literal(0),
44
+ provenance: zod_1.z.literal('default'),
45
+ values: zod_1.z.record(zod_1.z.string()),
46
+ })
47
+ .strict(),
48
+ zod_1.z
49
+ .object({
50
+ ...viewFields,
51
+ status: zod_1.z.literal('ready'),
52
+ revision: storedRevision,
53
+ provenance,
54
+ values: zod_1.z.record(zod_1.z.string()),
55
+ configurationHash: zod_1.z.string().min(1),
56
+ })
57
+ .strict(),
58
+ ]);
59
+ exports.permissionsV2UserParameterViewSchema = zod_1.z.union([
60
+ exports.permissionsV2UserParameterReadyViewSchema,
61
+ zod_1.z
62
+ .object({
63
+ ...viewFields,
64
+ status: zod_1.z.literal('needs_confirmation'),
65
+ revision: storedRevision,
66
+ provenance,
67
+ previousValues: zod_1.z.record(zod_1.z.string()),
68
+ })
69
+ .strict(),
70
+ ]);
71
+ exports.permissionsV2UserParameterHistorySchema = zod_1.z
72
+ .object({
73
+ revisions: zod_1.z.array(zod_1.z
74
+ .object({
75
+ policyVersion: zod_1.z.string().min(1),
76
+ policyHash: zod_1.z.string().min(1),
77
+ revision: storedRevision,
78
+ provenance,
79
+ values: zod_1.z.record(zod_1.z.string()),
80
+ changedAt: zod_1.z.string().datetime(),
81
+ })
82
+ .strict()),
83
+ nextBeforeRevision: storedRevision.optional(),
84
+ })
85
+ .strict();
@@ -2,13 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AUTH_FACTOR_PROVENANCES = exports.AUTH_FACTOR_STATUSES = exports.AUTH_FACTOR_TIERS = exports.AUTH_FACTOR_TYPES = void 0;
4
4
  /**
5
- * Auth factors are the ways an account authenticates: the identity-bearing
6
- * FIRST factors (email, phone, OAuth, external wallet) plus, going forward,
7
- * SECOND factors. This is the correct "authentication factor" model.
5
+ * Auth factors are the ways an account authenticates: the identity-bearing FIRST factors (email, phone,
6
+ * OAuth, external wallet) plus, going forward, SECOND factors.
8
7
  *
9
- * NOTE: distinct from the legacy `AuthMethod` enum (PASSWORD/PASSKEY/PIN/
10
- * BASIC_LOGIN), which describes the legacy credential/unlock methods and is
11
- * being retired with the enclave migration. Existing passkeys/PINs/passwords/
8
+ * NOTE: distinct from the legacy `AuthMethod` enum (PASSWORD/PASSKEY/PIN/BASIC_LOGIN) — legacy
9
+ * credential/unlock methods being retired with the enclave migration. Existing passkeys/PINs/passwords/
12
10
  * TOTP are NEVER represented here — they stay in their own tables and age out.
13
11
  */
14
12
  exports.AUTH_FACTOR_TYPES = [
@@ -23,6 +21,10 @@ exports.AUTH_FACTOR_TYPES = [
23
21
  ];
24
22
  /** Which factor in the authentication sequence this is. */
25
23
  exports.AUTH_FACTOR_TIERS = ['FIRST', 'SECOND'];
26
- exports.AUTH_FACTOR_STATUSES = ['PENDING', 'VERIFIED', 'REVOKED'];
24
+ // PENDING = a login credential mid-proof (email/phone first-write before its OTP) — reserved. VERIFIED = a
25
+ // proven login credential. UNVERIFIED = a linking HINT: an OAuth vouched for this email but the owner never
26
+ // proved it, so it is NOT a login credential (can't log in) and several may coexist across accounts — powers
27
+ // only the needs_link linking UI. REVOKED = unlinked. (ENG-7075)
28
+ exports.AUTH_FACTOR_STATUSES = ['PENDING', 'VERIFIED', 'UNVERIFIED', 'REVOKED'];
27
29
  /** How this factor came to be attached to the account (drives migration/audit). */
28
30
  exports.AUTH_FACTOR_PROVENANCES = ['SIGNUP', 'EXPLICIT_LINK', 'IMPLICIT_MERGE_LEGACY', 'MIGRATION'];
@@ -1,32 +1,31 @@
1
1
  "use strict";
2
2
  /**
3
- * Status-model auth envelope returned by the `/v2/auth` endpoints and consumed
4
- * by the backend and new SDKs. Clerk-style: a single `status` drives the client,
5
- * with typed per-status fields. New statuses are added additively; a client that
6
- * sees a status it doesn't recognize should treat the flow as not-yet-complete
7
- * (show generic / hand off) rather than erroring (forward-compat).
8
- *
9
- * This is the canonical auth contract — new SDKs consume it directly instead of
10
- * a parallel client mirror. (ENG-6910)
3
+ * Status-model auth envelope returned by `/v2/auth`, consumed by the backend and new SDKs.
4
+ * Clerk-style: a single `status` drives the client, with typed per-status fields. Statuses are added
5
+ * additively; an unrecognized one is treated as not-yet-complete (show generic / hand off), never an
6
+ * error (forward-compat). The canonical auth contract — new SDKs consume it directly, not a parallel
7
+ * client mirror. (ENG-6910)
11
8
  */
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
10
  exports.AUTH_FLOW_METHODS = exports.AUTH_STATUSES = void 0;
14
11
  /**
15
- * Flow statuses. Only `needs_verification` and `authenticated` are emitted today;
16
- * the rest are reserved so the contract is forward-stable and added to as the
17
- * slices that emit them land (credential setup, cross-method link prompt).
12
+ * Flow statuses. Only `needs_verification` and `authenticated` are emitted today; the rest are
13
+ * reserved for forward-stability, emitted as their slices land (credential setup, link prompt).
18
14
  */
19
15
  exports.AUTH_STATUSES = [
20
16
  'needs_verification', // a code was sent; awaiting it
21
- 'needs_credential', // identity verified, account still needs a credential — reserved, not emitted yet
17
+ 'needs_credential', // first factor proven; the session is withheld until the account's share-gate credential is too (ENG-7075)
22
18
  'needs_link', // identifier collides with an account from another method — reserved (cross-method linking)
23
19
  'needs_second_factor', // first factor passed; awaiting a login-time MFA challenge (ENG-6906)
24
20
  'authenticated', // done; a session has been established
21
+ 'linked', // a factor-link flow (start+continue with intent:'link') attached the proven factor to the session's account (ENG-7075)
22
+ 'needs_step_up', // a factor-link or factor-unlink flow must prove the SESSION's existing account first (ENG-7075)
23
+ 'unlinked', // a factor-unlink flow proved the account and revoked the named factor (ENG-7075)
25
24
  ];
26
25
  /**
27
- * First-factor methods the `/v2/auth` flow handles. Email/phone authenticate via a delivered
28
- * one-time code; external-wallet by signing a SIWE challenge; passkey by a WebAuthn assertion
29
- * (usernameless — resolved from the credential at `continue`); oauth by a provider redirect
30
- * (the specific provider rides on the flow; the account is resolved at `continue`). (ENG-6911)
26
+ * First-factor methods `/v2/auth` handles: email/phone via a delivered one-time code; external-wallet
27
+ * via a SIWE signature; passkey via a WebAuthn assertion (usernameless — resolved from the credential at
28
+ * `continue`); oauth via a provider redirect (provider rides on the flow, account resolved at
29
+ * `continue`). (ENG-6911)
31
30
  */
32
31
  exports.AUTH_FLOW_METHODS = ['EMAIL', 'PHONE', 'EXTERNAL_WALLET', 'PASSKEY', 'OAUTH'];
package/dist/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './types/index.js';
2
2
  export * from './types/permissions.js';
3
3
  export * from './schemas/permissionsV2.js';
4
+ export * from './schemas/permissionsV2UserParameters.js';
4
5
  export * from './utils/index.js';
5
6
  import * as transactionTypes from './types/transaction.js';
6
7
  export { transactionTypes };