@getpara/shared 1.30.0 → 1.32.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/dist/cjs/index.js CHANGED
@@ -40,6 +40,7 @@ exports.transactionTypes = void 0;
40
40
  __exportStar(require("./types/index.js"), exports);
41
41
  __exportStar(require("./types/permissions.js"), exports);
42
42
  __exportStar(require("./schemas/permissionsV2.js"), exports);
43
+ __exportStar(require("./schemas/permissionsV2Lifecycle.js"), exports);
43
44
  __exportStar(require("./schemas/permissionsV2UserParameters.js"), exports);
44
45
  __exportStar(require("./utils/index.js"), exports);
45
46
  const transactionTypes = __importStar(require("./types/transaction.js"));
@@ -617,6 +617,7 @@ exports.permissionsV2TransactionSignatureCollectionSchema = zod_1.z
617
617
  exports.permissionsV2ConditionalApprovalCaseListSchema = zod_1.z
618
618
  .object({
619
619
  cases: zod_1.z.array(exports.permissionsV2ConditionalApprovalCaseViewSchema),
620
+ nextBeforeCaseId: conditionalApprovalIdentifierSchema.optional(),
620
621
  })
621
622
  .strict();
622
623
  exports.permissionsV2PolicyRuleSchema = zod_1.z
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.permissionsV2AuthorizationConfigurationHistorySchema = exports.permissionsV2AuthorizationScopeBindingHistorySchema = exports.permissionsV2AuthoritySetHistorySchema = exports.permissionsV2AuthorizationScopeMembersSchema = exports.permissionsV2AuthorizationScopeCapabilitiesSchema = exports.permissionsV2EffectiveAuthorizationConfigurationSchema = exports.permissionsV2ResolvedConditionalApprovalRequirementSchema = exports.permissionsV2ConditionalRequirementListSchema = exports.permissionsV2ConditionalRequirementViewSchema = exports.permissionsV2ConditionalApprovalPartnerCaseListSchema = exports.permissionsV2ConditionalApprovalCaseSummarySchema = exports.permissionsV2PolicyUsageSchema = exports.permissionsV2PolicyUsageMeterSchema = exports.permissionsV2PolicyVersionsResponseSchema = exports.permissionsV2PolicyResponseSchema = exports.permissionsV2PolicyListResponseSchema = exports.permissionsV2PolicyViewSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const permissionsV2_js_1 = require("./permissionsV2.js");
6
+ const nonEmptyStringSchema = zod_1.z.string().min(1);
7
+ const positiveRevisionSchema = zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
8
+ const permissionsV2PolicyViewSelectorSchema = permissionsV2_js_1.permissionsV2PartnerAuthoredPolicySelectorSchema.extend({
9
+ actorId: nonEmptyStringSchema.optional(),
10
+ partnerId: nonEmptyStringSchema.optional(),
11
+ appId: nonEmptyStringSchema.optional(),
12
+ userId: nonEmptyStringSchema.optional(),
13
+ walletOwnerPartnerId: nonEmptyStringSchema.optional(),
14
+ feature: nonEmptyStringSchema.optional(),
15
+ });
16
+ exports.permissionsV2PolicyViewSchema = zod_1.z
17
+ .object({
18
+ policyId: nonEmptyStringSchema,
19
+ policyVersion: nonEmptyStringSchema,
20
+ policyHash: nonEmptyStringSchema,
21
+ lifecycle: zod_1.z.enum(['active', 'inactive', 'superseded', 'archived']),
22
+ activation: zod_1.z
23
+ .object({
24
+ effectiveFrom: zod_1.z.string().datetime(),
25
+ effectiveUntil: zod_1.z.string().datetime().optional(),
26
+ })
27
+ .strict(),
28
+ binding: zod_1.z
29
+ .object({ kind: zod_1.z.literal('user_consent'), subject: zod_1.z.literal('user_wallet') })
30
+ .strict()
31
+ .optional(),
32
+ policy: zod_1.z
33
+ .object({
34
+ id: nonEmptyStringSchema,
35
+ schemaVersion: zod_1.z.literal('permissions.policy.v1'),
36
+ version: nonEmptyStringSchema,
37
+ layer: zod_1.z.literal('partner'),
38
+ selector: permissionsV2PolicyViewSelectorSchema,
39
+ rules: zod_1.z.array(permissionsV2_js_1.permissionsV2PolicyRuleSchema).min(1),
40
+ metadata: permissionsV2_js_1.permissionsV2PartnerPolicyMetadataSchema,
41
+ })
42
+ .strict(),
43
+ })
44
+ .strict();
45
+ exports.permissionsV2PolicyListResponseSchema = zod_1.z.object({ policies: zod_1.z.array(exports.permissionsV2PolicyViewSchema) }).strict();
46
+ exports.permissionsV2PolicyResponseSchema = zod_1.z.object({ policy: exports.permissionsV2PolicyViewSchema }).strict();
47
+ exports.permissionsV2PolicyVersionsResponseSchema = zod_1.z
48
+ .object({ versions: zod_1.z.array(exports.permissionsV2PolicyViewSchema) })
49
+ .strict();
50
+ exports.permissionsV2PolicyUsageMeterSchema = zod_1.z
51
+ .object({
52
+ ruleId: nonEmptyStringSchema,
53
+ conditionPath: nonEmptyStringSchema,
54
+ fact: zod_1.z.enum(['wallet.spend.native', 'wallet.spend.erc20']),
55
+ operator: zod_1.z.enum(['lt', 'lte', 'gt', 'gte']),
56
+ ruleEffect: permissionsV2_js_1.permissionsV2PolicyEffectSchema,
57
+ assetType: zod_1.z.enum(['NATIVE', 'ERC20']),
58
+ tokenAddress: nonEmptyStringSchema.optional(),
59
+ chainId: nonEmptyStringSchema,
60
+ windowMs: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
61
+ bucketStart: zod_1.z.string().datetime(),
62
+ resetAt: zod_1.z.string().datetime(),
63
+ limitBaseUnits: zod_1.z.string().regex(/^(0|[1-9][0-9]*)$/),
64
+ committedBaseUnits: zod_1.z.string().regex(/^(0|[1-9][0-9]*)$/),
65
+ reservedBaseUnits: zod_1.z.string().regex(/^(0|[1-9][0-9]*)$/),
66
+ usedBaseUnits: zod_1.z.string().regex(/^(0|[1-9][0-9]*)$/),
67
+ remainingBaseUnits: zod_1.z
68
+ .string()
69
+ .regex(/^(0|[1-9][0-9]*)$/)
70
+ .nullable(),
71
+ })
72
+ .strict();
73
+ exports.permissionsV2PolicyUsageSchema = zod_1.z
74
+ .object({
75
+ userId: nonEmptyStringSchema.nullable(),
76
+ partnerId: nonEmptyStringSchema,
77
+ appId: nonEmptyStringSchema,
78
+ walletId: nonEmptyStringSchema,
79
+ policyId: nonEmptyStringSchema,
80
+ policyVersion: nonEmptyStringSchema,
81
+ policyHash: nonEmptyStringSchema,
82
+ asOf: zod_1.z.string().datetime(),
83
+ configuration: zod_1.z
84
+ .object({
85
+ revision: zod_1.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
86
+ provenance: zod_1.z.enum(['default', 'personal']),
87
+ configurationHash: nonEmptyStringSchema.optional(),
88
+ })
89
+ .strict()
90
+ .nullable(),
91
+ meters: zod_1.z.array(exports.permissionsV2PolicyUsageMeterSchema),
92
+ })
93
+ .strict();
94
+ exports.permissionsV2ConditionalApprovalCaseSummarySchema = permissionsV2_js_1.permissionsV2ConditionalApprovalCaseViewSchema.omit({
95
+ decision: true,
96
+ });
97
+ exports.permissionsV2ConditionalApprovalPartnerCaseListSchema = zod_1.z
98
+ .object({
99
+ cases: zod_1.z.array(exports.permissionsV2ConditionalApprovalCaseSummarySchema),
100
+ nextBeforeCaseId: nonEmptyStringSchema.optional(),
101
+ })
102
+ .strict();
103
+ exports.permissionsV2ConditionalRequirementViewSchema = zod_1.z
104
+ .object({
105
+ policyId: nonEmptyStringSchema,
106
+ policyVersion: nonEmptyStringSchema,
107
+ policyHash: nonEmptyStringSchema,
108
+ ruleId: nonEmptyStringSchema,
109
+ requirementId: nonEmptyStringSchema,
110
+ requirement: permissionsV2_js_1.permissionsV2ConditionalApprovalRequirementSchema,
111
+ })
112
+ .strict();
113
+ exports.permissionsV2ConditionalRequirementListSchema = zod_1.z
114
+ .object({ requirements: zod_1.z.array(exports.permissionsV2ConditionalRequirementViewSchema) })
115
+ .strict();
116
+ // A resolved view can replace stage values while retaining the authored safe-knob catalog.
117
+ // Validate its transport structure without reapplying authoring-time default consistency checks.
118
+ exports.permissionsV2ResolvedConditionalApprovalRequirementSchema = permissionsV2_js_1.permissionsV2ConditionalApprovalRequirementSchema.innerType();
119
+ exports.permissionsV2EffectiveAuthorizationConfigurationSchema = exports.permissionsV2ConditionalRequirementViewSchema
120
+ .extend({
121
+ partnerId: nonEmptyStringSchema,
122
+ appId: nonEmptyStringSchema,
123
+ authorizationScopeId: nonEmptyStringSchema,
124
+ configuration: permissionsV2_js_1.permissionsV2AuthorizationConfigurationViewSchema.nullable(),
125
+ effectiveRequirement: exports.permissionsV2ResolvedConditionalApprovalRequirementSchema,
126
+ })
127
+ .strict();
128
+ exports.permissionsV2AuthorizationScopeCapabilitiesSchema = zod_1.z
129
+ .object({
130
+ partnerId: nonEmptyStringSchema,
131
+ appId: nonEmptyStringSchema,
132
+ authorizationScopeId: nonEmptyStringSchema,
133
+ userId: nonEmptyStringSchema,
134
+ requirements: zod_1.z.array(zod_1.z
135
+ .object({
136
+ policyId: nonEmptyStringSchema,
137
+ policyVersion: nonEmptyStringSchema,
138
+ policyHash: nonEmptyStringSchema,
139
+ ruleId: nonEmptyStringSchema,
140
+ requirementId: nonEmptyStringSchema,
141
+ canManageConfiguration: zod_1.z.literal(true),
142
+ })
143
+ .strict()),
144
+ })
145
+ .strict();
146
+ exports.permissionsV2AuthorizationScopeMembersSchema = zod_1.z
147
+ .object({
148
+ members: zod_1.z.array(permissionsV2_js_1.permissionsV2AuthoritySetViewSchema),
149
+ nextAfterUserId: nonEmptyStringSchema.optional(),
150
+ })
151
+ .strict();
152
+ exports.permissionsV2AuthoritySetHistorySchema = zod_1.z
153
+ .object({ assignments: zod_1.z.array(permissionsV2_js_1.permissionsV2AuthoritySetViewSchema) })
154
+ .strict();
155
+ exports.permissionsV2AuthorizationScopeBindingHistorySchema = zod_1.z
156
+ .object({
157
+ revisions: zod_1.z.array(permissionsV2_js_1.permissionsV2AuthorizationScopeBindingViewSchema),
158
+ nextBeforeRevision: positiveRevisionSchema.optional(),
159
+ })
160
+ .strict();
161
+ exports.permissionsV2AuthorizationConfigurationHistorySchema = zod_1.z
162
+ .object({ configurations: zod_1.z.array(permissionsV2_js_1.permissionsV2AuthorizationConfigurationViewSchema) })
163
+ .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/permissionsV2Lifecycle.js';
4
5
  export * from './schemas/permissionsV2UserParameters.js';
5
6
  export * from './utils/index.js';
6
7
  import * as transactionTypes from './types/transaction.js';
@@ -613,6 +613,7 @@ export const permissionsV2TransactionSignatureCollectionSchema = z
613
613
  export const permissionsV2ConditionalApprovalCaseListSchema = z
614
614
  .object({
615
615
  cases: z.array(permissionsV2ConditionalApprovalCaseViewSchema),
616
+ nextBeforeCaseId: conditionalApprovalIdentifierSchema.optional(),
616
617
  })
617
618
  .strict();
618
619
  export const permissionsV2PolicyRuleSchema = z
@@ -0,0 +1,160 @@
1
+ import { z } from 'zod';
2
+ import { permissionsV2AuthorizationConfigurationViewSchema, permissionsV2AuthorizationScopeBindingViewSchema, permissionsV2AuthoritySetViewSchema, permissionsV2ConditionalApprovalCaseViewSchema, permissionsV2ConditionalApprovalRequirementSchema, permissionsV2PartnerAuthoredPolicySelectorSchema, permissionsV2PartnerPolicyMetadataSchema, permissionsV2PolicyEffectSchema, permissionsV2PolicyRuleSchema, } from './permissionsV2.js';
3
+ const nonEmptyStringSchema = z.string().min(1);
4
+ const positiveRevisionSchema = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
5
+ const permissionsV2PolicyViewSelectorSchema = permissionsV2PartnerAuthoredPolicySelectorSchema.extend({
6
+ actorId: nonEmptyStringSchema.optional(),
7
+ partnerId: nonEmptyStringSchema.optional(),
8
+ appId: nonEmptyStringSchema.optional(),
9
+ userId: nonEmptyStringSchema.optional(),
10
+ walletOwnerPartnerId: nonEmptyStringSchema.optional(),
11
+ feature: nonEmptyStringSchema.optional(),
12
+ });
13
+ export const permissionsV2PolicyViewSchema = z
14
+ .object({
15
+ policyId: nonEmptyStringSchema,
16
+ policyVersion: nonEmptyStringSchema,
17
+ policyHash: nonEmptyStringSchema,
18
+ lifecycle: z.enum(['active', 'inactive', 'superseded', 'archived']),
19
+ activation: z
20
+ .object({
21
+ effectiveFrom: z.string().datetime(),
22
+ effectiveUntil: z.string().datetime().optional(),
23
+ })
24
+ .strict(),
25
+ binding: z
26
+ .object({ kind: z.literal('user_consent'), subject: z.literal('user_wallet') })
27
+ .strict()
28
+ .optional(),
29
+ policy: z
30
+ .object({
31
+ id: nonEmptyStringSchema,
32
+ schemaVersion: z.literal('permissions.policy.v1'),
33
+ version: nonEmptyStringSchema,
34
+ layer: z.literal('partner'),
35
+ selector: permissionsV2PolicyViewSelectorSchema,
36
+ rules: z.array(permissionsV2PolicyRuleSchema).min(1),
37
+ metadata: permissionsV2PartnerPolicyMetadataSchema,
38
+ })
39
+ .strict(),
40
+ })
41
+ .strict();
42
+ export const permissionsV2PolicyListResponseSchema = z.object({ policies: z.array(permissionsV2PolicyViewSchema) }).strict();
43
+ export const permissionsV2PolicyResponseSchema = z.object({ policy: permissionsV2PolicyViewSchema }).strict();
44
+ export const permissionsV2PolicyVersionsResponseSchema = z
45
+ .object({ versions: z.array(permissionsV2PolicyViewSchema) })
46
+ .strict();
47
+ export const permissionsV2PolicyUsageMeterSchema = z
48
+ .object({
49
+ ruleId: nonEmptyStringSchema,
50
+ conditionPath: nonEmptyStringSchema,
51
+ fact: z.enum(['wallet.spend.native', 'wallet.spend.erc20']),
52
+ operator: z.enum(['lt', 'lte', 'gt', 'gte']),
53
+ ruleEffect: permissionsV2PolicyEffectSchema,
54
+ assetType: z.enum(['NATIVE', 'ERC20']),
55
+ tokenAddress: nonEmptyStringSchema.optional(),
56
+ chainId: nonEmptyStringSchema,
57
+ windowMs: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
58
+ bucketStart: z.string().datetime(),
59
+ resetAt: z.string().datetime(),
60
+ limitBaseUnits: z.string().regex(/^(0|[1-9][0-9]*)$/),
61
+ committedBaseUnits: z.string().regex(/^(0|[1-9][0-9]*)$/),
62
+ reservedBaseUnits: z.string().regex(/^(0|[1-9][0-9]*)$/),
63
+ usedBaseUnits: z.string().regex(/^(0|[1-9][0-9]*)$/),
64
+ remainingBaseUnits: z
65
+ .string()
66
+ .regex(/^(0|[1-9][0-9]*)$/)
67
+ .nullable(),
68
+ })
69
+ .strict();
70
+ export const permissionsV2PolicyUsageSchema = z
71
+ .object({
72
+ userId: nonEmptyStringSchema.nullable(),
73
+ partnerId: nonEmptyStringSchema,
74
+ appId: nonEmptyStringSchema,
75
+ walletId: nonEmptyStringSchema,
76
+ policyId: nonEmptyStringSchema,
77
+ policyVersion: nonEmptyStringSchema,
78
+ policyHash: nonEmptyStringSchema,
79
+ asOf: z.string().datetime(),
80
+ configuration: z
81
+ .object({
82
+ revision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
83
+ provenance: z.enum(['default', 'personal']),
84
+ configurationHash: nonEmptyStringSchema.optional(),
85
+ })
86
+ .strict()
87
+ .nullable(),
88
+ meters: z.array(permissionsV2PolicyUsageMeterSchema),
89
+ })
90
+ .strict();
91
+ export const permissionsV2ConditionalApprovalCaseSummarySchema = permissionsV2ConditionalApprovalCaseViewSchema.omit({
92
+ decision: true,
93
+ });
94
+ export const permissionsV2ConditionalApprovalPartnerCaseListSchema = z
95
+ .object({
96
+ cases: z.array(permissionsV2ConditionalApprovalCaseSummarySchema),
97
+ nextBeforeCaseId: nonEmptyStringSchema.optional(),
98
+ })
99
+ .strict();
100
+ export const permissionsV2ConditionalRequirementViewSchema = z
101
+ .object({
102
+ policyId: nonEmptyStringSchema,
103
+ policyVersion: nonEmptyStringSchema,
104
+ policyHash: nonEmptyStringSchema,
105
+ ruleId: nonEmptyStringSchema,
106
+ requirementId: nonEmptyStringSchema,
107
+ requirement: permissionsV2ConditionalApprovalRequirementSchema,
108
+ })
109
+ .strict();
110
+ export const permissionsV2ConditionalRequirementListSchema = z
111
+ .object({ requirements: z.array(permissionsV2ConditionalRequirementViewSchema) })
112
+ .strict();
113
+ // A resolved view can replace stage values while retaining the authored safe-knob catalog.
114
+ // Validate its transport structure without reapplying authoring-time default consistency checks.
115
+ export const permissionsV2ResolvedConditionalApprovalRequirementSchema = permissionsV2ConditionalApprovalRequirementSchema.innerType();
116
+ export const permissionsV2EffectiveAuthorizationConfigurationSchema = permissionsV2ConditionalRequirementViewSchema
117
+ .extend({
118
+ partnerId: nonEmptyStringSchema,
119
+ appId: nonEmptyStringSchema,
120
+ authorizationScopeId: nonEmptyStringSchema,
121
+ configuration: permissionsV2AuthorizationConfigurationViewSchema.nullable(),
122
+ effectiveRequirement: permissionsV2ResolvedConditionalApprovalRequirementSchema,
123
+ })
124
+ .strict();
125
+ export const permissionsV2AuthorizationScopeCapabilitiesSchema = z
126
+ .object({
127
+ partnerId: nonEmptyStringSchema,
128
+ appId: nonEmptyStringSchema,
129
+ authorizationScopeId: nonEmptyStringSchema,
130
+ userId: nonEmptyStringSchema,
131
+ requirements: z.array(z
132
+ .object({
133
+ policyId: nonEmptyStringSchema,
134
+ policyVersion: nonEmptyStringSchema,
135
+ policyHash: nonEmptyStringSchema,
136
+ ruleId: nonEmptyStringSchema,
137
+ requirementId: nonEmptyStringSchema,
138
+ canManageConfiguration: z.literal(true),
139
+ })
140
+ .strict()),
141
+ })
142
+ .strict();
143
+ export const permissionsV2AuthorizationScopeMembersSchema = z
144
+ .object({
145
+ members: z.array(permissionsV2AuthoritySetViewSchema),
146
+ nextAfterUserId: nonEmptyStringSchema.optional(),
147
+ })
148
+ .strict();
149
+ export const permissionsV2AuthoritySetHistorySchema = z
150
+ .object({ assignments: z.array(permissionsV2AuthoritySetViewSchema) })
151
+ .strict();
152
+ export const permissionsV2AuthorizationScopeBindingHistorySchema = z
153
+ .object({
154
+ revisions: z.array(permissionsV2AuthorizationScopeBindingViewSchema),
155
+ nextBeforeRevision: positiveRevisionSchema.optional(),
156
+ })
157
+ .strict();
158
+ export const permissionsV2AuthorizationConfigurationHistorySchema = z
159
+ .object({ configurations: z.array(permissionsV2AuthorizationConfigurationViewSchema) })
160
+ .strict();
@@ -1,11 +1,9 @@
1
1
  /**
2
- * Auth factors are the ways an account authenticates: the identity-bearing
3
- * FIRST factors (email, phone, OAuth, external wallet) plus, going forward,
4
- * SECOND factors. This is the correct "authentication factor" model.
2
+ * Auth factors are the ways an account authenticates: the identity-bearing FIRST factors (email, phone,
3
+ * OAuth, external wallet) plus, going forward, SECOND factors.
5
4
  *
6
- * NOTE: distinct from the legacy `AuthMethod` enum (PASSWORD/PASSKEY/PIN/
7
- * BASIC_LOGIN), which describes the legacy credential/unlock methods and is
8
- * being retired with the enclave migration. Existing passkeys/PINs/passwords/
5
+ * NOTE: distinct from the legacy `AuthMethod` enum (PASSWORD/PASSKEY/PIN/BASIC_LOGIN) — legacy
6
+ * credential/unlock methods being retired with the enclave migration. Existing passkeys/PINs/passwords/
9
7
  * TOTP are NEVER represented here — they stay in their own tables and age out.
10
8
  */
11
9
  export const AUTH_FACTOR_TYPES = [
@@ -20,6 +18,10 @@ export const AUTH_FACTOR_TYPES = [
20
18
  ];
21
19
  /** Which factor in the authentication sequence this is. */
22
20
  export const AUTH_FACTOR_TIERS = ['FIRST', 'SECOND'];
23
- export const AUTH_FACTOR_STATUSES = ['PENDING', 'VERIFIED', 'REVOKED'];
21
+ // PENDING = a login credential mid-proof (email/phone first-write before its OTP) — reserved. VERIFIED = a
22
+ // proven login credential. UNVERIFIED = a linking HINT: an OAuth vouched for this email but the owner never
23
+ // proved it, so it is NOT a login credential (can't log in) and several may coexist across accounts — powers
24
+ // only the needs_link linking UI. REVOKED = unlinked. (ENG-7075)
25
+ export const AUTH_FACTOR_STATUSES = ['PENDING', 'VERIFIED', 'UNVERIFIED', 'REVOKED'];
24
26
  /** How this factor came to be attached to the account (drives migration/audit). */
25
27
  export const AUTH_FACTOR_PROVENANCES = ['SIGNUP', 'EXPLICIT_LINK', 'IMPLICIT_MERGE_LEGACY', 'MIGRATION'];
@@ -1,29 +1,28 @@
1
1
  /**
2
- * Status-model auth envelope returned by the `/v2/auth` endpoints and consumed
3
- * by the backend and new SDKs. Clerk-style: a single `status` drives the client,
4
- * with typed per-status fields. New statuses are added additively; a client that
5
- * sees a status it doesn't recognize should treat the flow as not-yet-complete
6
- * (show generic / hand off) rather than erroring (forward-compat).
7
- *
8
- * This is the canonical auth contract — new SDKs consume it directly instead of
9
- * a parallel client mirror. (ENG-6910)
2
+ * Status-model auth envelope returned by `/v2/auth`, consumed by the backend and new SDKs.
3
+ * Clerk-style: a single `status` drives the client, with typed per-status fields. Statuses are added
4
+ * additively; an unrecognized one is treated as not-yet-complete (show generic / hand off), never an
5
+ * error (forward-compat). The canonical auth contract — new SDKs consume it directly, not a parallel
6
+ * client mirror. (ENG-6910)
10
7
  */
11
8
  /**
12
- * Flow statuses. Only `needs_verification` and `authenticated` are emitted today;
13
- * the rest are reserved so the contract is forward-stable and added to as the
14
- * slices that emit them land (credential setup, cross-method link prompt).
9
+ * Flow statuses. Only `needs_verification` and `authenticated` are emitted today; the rest are
10
+ * reserved for forward-stability, emitted as their slices land (credential setup, link prompt).
15
11
  */
16
12
  export const AUTH_STATUSES = [
17
13
  'needs_verification', // a code was sent; awaiting it
18
- 'needs_credential', // identity verified, account still needs a credential — reserved, not emitted yet
14
+ 'needs_credential', // first factor proven; the session is withheld until the account's share-gate credential is too (ENG-7075)
19
15
  'needs_link', // identifier collides with an account from another method — reserved (cross-method linking)
20
16
  'needs_second_factor', // first factor passed; awaiting a login-time MFA challenge (ENG-6906)
21
17
  'authenticated', // done; a session has been established
18
+ 'linked', // a factor-link flow (start+continue with intent:'link') attached the proven factor to the session's account (ENG-7075)
19
+ 'needs_step_up', // a factor-link or factor-unlink flow must prove the SESSION's existing account first (ENG-7075)
20
+ 'unlinked', // a factor-unlink flow proved the account and revoked the named factor (ENG-7075)
22
21
  ];
23
22
  /**
24
- * First-factor methods the `/v2/auth` flow handles. Email/phone authenticate via a delivered
25
- * one-time code; external-wallet by signing a SIWE challenge; passkey by a WebAuthn assertion
26
- * (usernameless — resolved from the credential at `continue`); oauth by a provider redirect
27
- * (the specific provider rides on the flow; the account is resolved at `continue`). (ENG-6911)
23
+ * First-factor methods `/v2/auth` handles: email/phone via a delivered one-time code; external-wallet
24
+ * via a SIWE signature; passkey via a WebAuthn assertion (usernameless — resolved from the credential at
25
+ * `continue`); oauth via a provider redirect (provider rides on the flow, account resolved at
26
+ * `continue`). (ENG-6911)
28
27
  */
29
28
  export const AUTH_FLOW_METHODS = ['EMAIL', 'PHONE', 'EXTERNAL_WALLET', 'PASSKEY', 'OAUTH'];
@@ -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/permissionsV2Lifecycle.js';
4
5
  export * from './schemas/permissionsV2UserParameters.js';
5
6
  export * from './utils/index.js';
6
7
  import * as transactionTypes from './types/transaction.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0CAA0C,CAAC;AACzD,cAAc,kBAAkB,CAAC;AAEjC,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,kBAAkB,CAAC;AAEjC,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -2238,6 +2238,7 @@ export declare const permissionsV2ConditionalApprovalCaseListSchema: z.ZodObject
2238
2238
  evidence?: "authenticated_approval" | "transaction_signature" | undefined;
2239
2239
  terminalReason?: string | undefined;
2240
2240
  }>, "many">;
2241
+ nextBeforeCaseId: z.ZodOptional<z.ZodString>;
2241
2242
  }, "strict", z.ZodTypeAny, {
2242
2243
  cases: {
2243
2244
  status: "pending" | "completed" | "rejected" | "expired" | "invalidated";
@@ -2294,6 +2295,7 @@ export declare const permissionsV2ConditionalApprovalCaseListSchema: z.ZodObject
2294
2295
  evidence?: "authenticated_approval" | "transaction_signature" | undefined;
2295
2296
  terminalReason?: string | undefined;
2296
2297
  }[];
2298
+ nextBeforeCaseId?: string | undefined;
2297
2299
  }, {
2298
2300
  cases: {
2299
2301
  status: "pending" | "completed" | "rejected" | "expired" | "invalidated";
@@ -2350,6 +2352,7 @@ export declare const permissionsV2ConditionalApprovalCaseListSchema: z.ZodObject
2350
2352
  evidence?: "authenticated_approval" | "transaction_signature" | undefined;
2351
2353
  terminalReason?: string | undefined;
2352
2354
  }[];
2355
+ nextBeforeCaseId?: string | undefined;
2353
2356
  }>;
2354
2357
  export declare const permissionsV2PolicyRuleSchema: z.ZodEffects<z.ZodObject<{
2355
2358
  id: z.ZodString;