@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.
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/schemas/permissionsV2.js +577 -6
- package/dist/cjs/schemas/permissionsV2UserParameters.js +85 -0
- package/dist/cjs/types/authFactor.js +9 -7
- package/dist/cjs/types/authState.js +15 -16
- package/dist/esm/index.js +1 -0
- package/dist/esm/schemas/permissionsV2.js +575 -5
- package/dist/esm/schemas/permissionsV2UserParameters.js +82 -0
- package/dist/esm/types/authFactor.js +9 -7
- package/dist/esm/types/authState.js +15 -16
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/schemas/permissionsV2.d.ts +12656 -513
- package/dist/types/schemas/permissionsV2.d.ts.map +1 -1
- package/dist/types/schemas/permissionsV2UserParameters.d.ts +468 -0
- package/dist/types/schemas/permissionsV2UserParameters.d.ts.map +1 -0
- package/dist/types/types/auth.d.ts +46 -0
- package/dist/types/types/auth.d.ts.map +1 -1
- package/dist/types/types/authFactor.d.ts +57 -23
- package/dist/types/types/authFactor.d.ts.map +1 -1
- package/dist/types/types/authState.d.ts +224 -88
- package/dist/types/types/authState.d.ts.map +1 -1
- package/dist/types/types/partner.d.ts +2 -0
- package/dist/types/types/partner.d.ts.map +1 -1
- package/dist/types/types/pending-transaction.d.ts +2 -0
- package/dist/types/types/pending-transaction.d.ts.map +1 -1
- package/dist/types/types/permissions.d.ts +25 -2
- package/dist/types/types/permissions.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const templateRevisionFields = {
|
|
3
|
+
policyVersion: z.string().min(1),
|
|
4
|
+
policyHash: z.string().min(1),
|
|
5
|
+
expectedRevision: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
6
|
+
};
|
|
7
|
+
export const permissionsV2UserParameterSaveSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
...templateRevisionFields,
|
|
10
|
+
values: z.record(z.string()),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const permissionsV2UserParameterResetSchema = z.object(templateRevisionFields).strict();
|
|
14
|
+
const storedRevision = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
|
|
15
|
+
const provenance = z.enum(['default', 'personal']);
|
|
16
|
+
const parameterDescriptor = z
|
|
17
|
+
.object({
|
|
18
|
+
id: z.string().min(1),
|
|
19
|
+
label: z.string().min(1),
|
|
20
|
+
defaultValue: z.string(),
|
|
21
|
+
fact: z.string().min(1),
|
|
22
|
+
asset: z.string().optional(),
|
|
23
|
+
window: z.string().optional(),
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
const viewFields = {
|
|
27
|
+
userId: z.string().min(1),
|
|
28
|
+
partnerId: z.string().min(1),
|
|
29
|
+
appId: z.string().min(1),
|
|
30
|
+
policyId: z.string().min(1),
|
|
31
|
+
policyVersion: z.string().min(1),
|
|
32
|
+
policyHash: z.string().min(1),
|
|
33
|
+
parameters: z.array(parameterDescriptor),
|
|
34
|
+
};
|
|
35
|
+
export const permissionsV2UserParameterReadyViewSchema = z.union([
|
|
36
|
+
z
|
|
37
|
+
.object({
|
|
38
|
+
...viewFields,
|
|
39
|
+
status: z.literal('ready'),
|
|
40
|
+
revision: z.literal(0),
|
|
41
|
+
provenance: z.literal('default'),
|
|
42
|
+
values: z.record(z.string()),
|
|
43
|
+
})
|
|
44
|
+
.strict(),
|
|
45
|
+
z
|
|
46
|
+
.object({
|
|
47
|
+
...viewFields,
|
|
48
|
+
status: z.literal('ready'),
|
|
49
|
+
revision: storedRevision,
|
|
50
|
+
provenance,
|
|
51
|
+
values: z.record(z.string()),
|
|
52
|
+
configurationHash: z.string().min(1),
|
|
53
|
+
})
|
|
54
|
+
.strict(),
|
|
55
|
+
]);
|
|
56
|
+
export const permissionsV2UserParameterViewSchema = z.union([
|
|
57
|
+
permissionsV2UserParameterReadyViewSchema,
|
|
58
|
+
z
|
|
59
|
+
.object({
|
|
60
|
+
...viewFields,
|
|
61
|
+
status: z.literal('needs_confirmation'),
|
|
62
|
+
revision: storedRevision,
|
|
63
|
+
provenance,
|
|
64
|
+
previousValues: z.record(z.string()),
|
|
65
|
+
})
|
|
66
|
+
.strict(),
|
|
67
|
+
]);
|
|
68
|
+
export const permissionsV2UserParameterHistorySchema = z
|
|
69
|
+
.object({
|
|
70
|
+
revisions: z.array(z
|
|
71
|
+
.object({
|
|
72
|
+
policyVersion: z.string().min(1),
|
|
73
|
+
policyHash: z.string().min(1),
|
|
74
|
+
revision: storedRevision,
|
|
75
|
+
provenance,
|
|
76
|
+
values: z.record(z.string()),
|
|
77
|
+
changedAt: z.string().datetime(),
|
|
78
|
+
})
|
|
79
|
+
.strict()),
|
|
80
|
+
nextBeforeRevision: storedRevision.optional(),
|
|
81
|
+
})
|
|
82
|
+
.strict();
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Auth factors are the ways an account authenticates: the identity-bearing
|
|
3
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
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', //
|
|
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
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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'];
|
package/dist/types/index.d.ts
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 };
|
|
@@ -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,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,0CAA0C,CAAC;AACzD,cAAc,kBAAkB,CAAC;AAEjC,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|