@authyon/auth 0.2.0-beta.14 → 0.2.0-beta.15
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/README.md +14 -12
- package/dist/{ability-DbnbsQEX.d.cts → ability-5_xXXbDF.d.cts} +40 -62
- package/dist/{ability-DbnbsQEX.d.ts → ability-5_xXXbDF.d.ts} +40 -62
- package/dist/index.cjs +25 -27
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +25 -27
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -273,26 +273,28 @@ Métodos de sessão/auth ficam soltos no client; os que giram em torno de um rec
|
|
|
273
273
|
| `sso.startUrl(provider, params)` | monta a URL de `GET /auth/sso/{provider}/start` (não faz a chamada — navegue até ela) |
|
|
274
274
|
| `sso.exchange(code)` | `POST /auth/sso/exchange` |
|
|
275
275
|
|
|
276
|
-
### `authyon.
|
|
276
|
+
### `authyon.security` (aprovação com OTP/passkey)
|
|
277
277
|
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
`security.approvals`: o cliente aprova o que o seu backend pediu
|
|
279
|
+
(`@authyon/server` → `security.approvals.create`, com um `payload` livre) usando o código
|
|
280
|
+
do app autenticador ou a passkey. Para só validar um código, use `security.otp.check` no
|
|
281
|
+
`@authyon/server`. Guia completo: [`docs/security-otp-approvals.md`](../../docs/security-otp-approvals.md).
|
|
280
282
|
|
|
281
283
|
```ts
|
|
282
|
-
const pending = await authyon.
|
|
283
|
-
// mostre pending.
|
|
284
|
-
await authyon.
|
|
284
|
+
const pending = await authyon.security.approvals.get(approvalId);
|
|
285
|
+
// mostre pending.payload ao cliente
|
|
286
|
+
await authyon.security.approvals.confirm(approvalId, {
|
|
285
287
|
method: "authenticator",
|
|
286
288
|
code: "123456",
|
|
287
289
|
});
|
|
288
290
|
```
|
|
289
291
|
|
|
290
|
-
| Método
|
|
291
|
-
|
|
|
292
|
-
| `
|
|
293
|
-
| `
|
|
294
|
-
| `
|
|
295
|
-
| `
|
|
292
|
+
| Método | Endpoint |
|
|
293
|
+
| ---------------------------------------- | ------------------------------------------------- |
|
|
294
|
+
| `security.approvals.get(id)` | `GET /auth/authorizations/{id}` |
|
|
295
|
+
| `security.approvals.webauthnOptions(id)` | `POST /auth/authorizations/{id}/webauthn/options` |
|
|
296
|
+
| `security.approvals.confirm(id, input?)` | `POST /auth/authorizations/{id}/confirm` |
|
|
297
|
+
| `security.approvals.reject(id)` | `POST /auth/authorizations/{id}/reject` |
|
|
296
298
|
|
|
297
299
|
## Invalidação de token
|
|
298
300
|
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
/** Lifecycle of
|
|
2
|
-
type
|
|
1
|
+
/** Lifecycle of an approval. */
|
|
2
|
+
type ApprovalStatus = "pending" | "approved" | "denied" | "consumed" | "expired";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Free-form JSON object describing what the customer approves (up to 16 KiB).
|
|
5
|
+
* The API stores it, shows it back to the customer and binds its canonical
|
|
6
|
+
* hash (keys sorted) to the approval.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
/** Business action, e.g. `"pix.transfer"`. Max 100 characters. */
|
|
10
|
-
action: string;
|
|
11
|
-
/** Positive amount, up to 15 integer digits and 4 decimal places. */
|
|
12
|
-
amount: number;
|
|
13
|
-
/** ISO 4217 currency code, e.g. `"BRL"`. */
|
|
14
|
-
currency: string;
|
|
15
|
-
/** Human-readable beneficiary shown to the customer. Max 256 characters. */
|
|
16
|
-
beneficiary: string;
|
|
17
|
-
/** Optional JSON object bound into the hash (max 16 KiB). */
|
|
18
|
-
metadata?: Record<string, unknown>;
|
|
19
|
-
}
|
|
8
|
+
type ApprovalPayload = Record<string, unknown>;
|
|
20
9
|
/** Evidence of how the customer proved their identity when approving. */
|
|
21
|
-
interface
|
|
10
|
+
interface ApprovalAssurance {
|
|
22
11
|
/** `urn:authyon:loa:3` (passkey) or `urn:authyon:loa:2` (authenticator code). */
|
|
23
12
|
acr: string;
|
|
24
13
|
/** Authentication methods, e.g. `["pwd", "otp"]` or `["pwd", "webauthn"]`. */
|
|
@@ -26,28 +15,25 @@ interface FinancialAssurance {
|
|
|
26
15
|
/** When the second factor was verified (ISO 8601). */
|
|
27
16
|
authTime: string;
|
|
28
17
|
}
|
|
29
|
-
|
|
18
|
+
/** A request for the customer to approve something with a second factor. */
|
|
19
|
+
interface Approval {
|
|
30
20
|
id: string;
|
|
31
|
-
status:
|
|
21
|
+
status: ApprovalStatus;
|
|
32
22
|
subjectId: string;
|
|
33
23
|
tenantId?: string | null;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/** SHA-256 (hex) of the canonical transaction. */
|
|
39
|
-
transactionHash: string;
|
|
24
|
+
/** The payload given to `create()`, with keys in canonical order. */
|
|
25
|
+
payload: ApprovalPayload;
|
|
26
|
+
/** SHA-256 (hex) of the canonical payload. */
|
|
27
|
+
payloadHash: string;
|
|
40
28
|
createdAt: string;
|
|
41
29
|
expiresAt: string;
|
|
42
30
|
decidedAt?: string | null;
|
|
43
31
|
consumedAt?: string | null;
|
|
44
|
-
/** Full canonical transaction — returned only to the customer (subject) view. */
|
|
45
|
-
transaction?: FinancialTransaction | null;
|
|
46
32
|
/** Present once approved. */
|
|
47
|
-
assurance?:
|
|
33
|
+
assurance?: ApprovalAssurance | null;
|
|
48
34
|
}
|
|
49
|
-
/**
|
|
50
|
-
type
|
|
35
|
+
/** Second factor sent with `confirm()`. */
|
|
36
|
+
type ConfirmApprovalInput = {
|
|
51
37
|
method: "authenticator";
|
|
52
38
|
/** Six-digit code from the customer's authenticator app. */
|
|
53
39
|
code: string;
|
|
@@ -60,15 +46,13 @@ type ConfirmFinancialAuthorizationInput = {
|
|
|
60
46
|
assertionJson: string;
|
|
61
47
|
};
|
|
62
48
|
};
|
|
63
|
-
/** Passkey assertion options for approving one
|
|
64
|
-
interface
|
|
49
|
+
/** Passkey assertion options for approving one approval. */
|
|
50
|
+
interface ApprovalWebAuthnOptions {
|
|
65
51
|
ceremonyToken: string;
|
|
66
52
|
/** JSON `PublicKeyCredentialRequestOptions` to pass to `navigator.credentials.get()`. */
|
|
67
53
|
optionsJson: string;
|
|
68
54
|
}
|
|
69
55
|
|
|
70
|
-
type QueryParams = object;
|
|
71
|
-
|
|
72
56
|
interface HttpAdapterRequest {
|
|
73
57
|
url: string;
|
|
74
58
|
method: string;
|
|
@@ -126,35 +110,29 @@ declare class LoggingHttpAdapter implements HttpAdapter {
|
|
|
126
110
|
private log;
|
|
127
111
|
}
|
|
128
112
|
|
|
129
|
-
|
|
130
|
-
interface
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** Sends a request already authenticated as the customer (end-user bearer). */
|
|
138
|
-
type SubjectRequest = <T>(path: string, options?: JsonRequestOptions) => Promise<T>;
|
|
139
|
-
/** Customer-side operations on a financial authorization (`/auth/authorizations`). */
|
|
140
|
-
declare function subjectFinancialAuthorizations(request: SubjectRequest): {
|
|
141
|
-
/** GET /auth/authorizations/{id} — the pending transaction, to show before asking for the code. */
|
|
142
|
-
get: (id: string) => Promise<FinancialAuthorization>;
|
|
143
|
-
/** POST /auth/authorizations/{id}/webauthn/options — passkey options for approving this authorization. */
|
|
144
|
-
webauthnOptions: (id: string) => Promise<FinancialWebAuthnOptions>;
|
|
113
|
+
/** Customer-side operations on an approval (`/auth/authorizations`). */
|
|
114
|
+
interface SubjectApprovals {
|
|
115
|
+
/** GET /auth/authorizations/{id} — the pending payload, to show before asking for the code. */
|
|
116
|
+
get(id: string): Promise<Approval>;
|
|
117
|
+
/** POST /auth/authorizations/{id}/webauthn/options — passkey options for approving it. */
|
|
118
|
+
webauthnOptions(id: string): Promise<ApprovalWebAuthnOptions>;
|
|
145
119
|
/**
|
|
146
|
-
* POST /auth/authorizations/{id}/confirm — approves
|
|
120
|
+
* POST /auth/authorizations/{id}/confirm — approves it.
|
|
147
121
|
*
|
|
148
122
|
* Pass the authenticator code or passkey assertion to verify the second
|
|
149
123
|
* factor inline (recommended). Without `input`, the session itself must
|
|
150
124
|
* have used a passkey or authenticator code within the last 5 minutes,
|
|
151
125
|
* otherwise the API answers `step_up_required`.
|
|
152
126
|
*/
|
|
153
|
-
confirm
|
|
154
|
-
/** POST /auth/authorizations/{id}/reject — the customer declines
|
|
155
|
-
reject
|
|
156
|
-
}
|
|
157
|
-
|
|
127
|
+
confirm(id: string, input?: ConfirmApprovalInput): Promise<Approval>;
|
|
128
|
+
/** POST /auth/authorizations/{id}/reject — the customer declines it. */
|
|
129
|
+
reject(id: string): Promise<Approval>;
|
|
130
|
+
}
|
|
131
|
+
/** The `security` namespace an end-user client exposes. */
|
|
132
|
+
interface SubjectSecurity {
|
|
133
|
+
/** Approve or reject what your backend asked the customer to confirm. */
|
|
134
|
+
readonly approvals: SubjectApprovals;
|
|
135
|
+
}
|
|
158
136
|
|
|
159
137
|
interface PaginationOptions {
|
|
160
138
|
skip?: number;
|
|
@@ -620,12 +598,12 @@ declare class AuthyonClient {
|
|
|
620
598
|
};
|
|
621
599
|
};
|
|
622
600
|
/**
|
|
623
|
-
*
|
|
624
|
-
* (`@authyon/server` → `
|
|
625
|
-
* Show the
|
|
601
|
+
* `security.approvals`: approve or reject what your backend asked the
|
|
602
|
+
* customer to confirm (`@authyon/server` → `security.approvals.create`).
|
|
603
|
+
* Show the payload with `get()`, then `confirm()` with the customer's
|
|
626
604
|
* authenticator code or passkey, or `reject()`.
|
|
627
605
|
*/
|
|
628
|
-
readonly
|
|
606
|
+
readonly security: SubjectSecurity;
|
|
629
607
|
/**
|
|
630
608
|
* POST /auth/introspect — lightweight token introspection (RFC 7662).
|
|
631
609
|
*
|
|
@@ -750,4 +728,4 @@ declare function hasPermissionGroup(source: AuthyonPermissionSource | readonly s
|
|
|
750
728
|
/** Converts Authyon's `subject:action` permission strings to authorization rules. */
|
|
751
729
|
declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
|
|
752
730
|
|
|
753
|
-
export { type
|
|
731
|
+
export { type TwoFactorMethod as $, AuthyonClient as A, type InviteMemberInput as B, type ConfirmApprovalInput as C, type LoginInput as D, type LoginResult as E, FetchHttpAdapter as F, type OrganizationMember as G, type HttpAdapter as H, type IntrospectResult as I, type PaginationOptions as J, type PermissionGroup as K, LoggingHttpAdapter as L, type Role as M, type SessionControllerOptions as N, type Organization as O, type Paged as P, type SessionInfo as Q, type RegisterInput as R, type Session as S, type TokenStorage as T, type SessionSnapshot as U, type SessionSnapshotListener as V, type SessionStatus as W, type SsoProvider as X, type SubjectApprovals as Y, type SubjectSecurity as Z, type TwoFactorChallenge as _, type HttpLoggerOptions as a, type TwoFactorStatus as a0, type User as a1, type ValidateResult as a2, type VerifyTwoFactorInput as a3, type WebAuthnAssertion as a4, type WebAuthnCeremonyStart as a5, type WebAuthnCredential as a6, createAuthyonAbility as a7, createAuthyonRules as a8, createClient as a9, hasPermission as aa, hasPermissionGroup as ab, type AbilityConditions as b, type AbilityEvent as c, type AbilityListener as d, type AbilityRule as e, type AbilitySubject as f, type Activity as g, type Approval as h, type ApprovalAssurance as i, type ApprovalPayload as j, type ApprovalStatus as k, type ApprovalWebAuthnOptions as l, type AuthEvent as m, type AuthState as n, type AuthStateListener as o, type AuthenticatorSetup as p, AuthyonAbility as q, AuthyonAbilityBuilder as r, type AuthyonAbilityOptions as s, type AuthyonClientOptions as t, type AuthyonPermissionSource as u, AuthyonSessionController as v, type CreateOrganizationInput as w, type HttpAdapterRequest as x, type HttpLogEvent as y, type HttpLogger as z };
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
/** Lifecycle of
|
|
2
|
-
type
|
|
1
|
+
/** Lifecycle of an approval. */
|
|
2
|
+
type ApprovalStatus = "pending" | "approved" | "denied" | "consumed" | "expired";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Free-form JSON object describing what the customer approves (up to 16 KiB).
|
|
5
|
+
* The API stores it, shows it back to the customer and binds its canonical
|
|
6
|
+
* hash (keys sorted) to the approval.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
/** Business action, e.g. `"pix.transfer"`. Max 100 characters. */
|
|
10
|
-
action: string;
|
|
11
|
-
/** Positive amount, up to 15 integer digits and 4 decimal places. */
|
|
12
|
-
amount: number;
|
|
13
|
-
/** ISO 4217 currency code, e.g. `"BRL"`. */
|
|
14
|
-
currency: string;
|
|
15
|
-
/** Human-readable beneficiary shown to the customer. Max 256 characters. */
|
|
16
|
-
beneficiary: string;
|
|
17
|
-
/** Optional JSON object bound into the hash (max 16 KiB). */
|
|
18
|
-
metadata?: Record<string, unknown>;
|
|
19
|
-
}
|
|
8
|
+
type ApprovalPayload = Record<string, unknown>;
|
|
20
9
|
/** Evidence of how the customer proved their identity when approving. */
|
|
21
|
-
interface
|
|
10
|
+
interface ApprovalAssurance {
|
|
22
11
|
/** `urn:authyon:loa:3` (passkey) or `urn:authyon:loa:2` (authenticator code). */
|
|
23
12
|
acr: string;
|
|
24
13
|
/** Authentication methods, e.g. `["pwd", "otp"]` or `["pwd", "webauthn"]`. */
|
|
@@ -26,28 +15,25 @@ interface FinancialAssurance {
|
|
|
26
15
|
/** When the second factor was verified (ISO 8601). */
|
|
27
16
|
authTime: string;
|
|
28
17
|
}
|
|
29
|
-
|
|
18
|
+
/** A request for the customer to approve something with a second factor. */
|
|
19
|
+
interface Approval {
|
|
30
20
|
id: string;
|
|
31
|
-
status:
|
|
21
|
+
status: ApprovalStatus;
|
|
32
22
|
subjectId: string;
|
|
33
23
|
tenantId?: string | null;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/** SHA-256 (hex) of the canonical transaction. */
|
|
39
|
-
transactionHash: string;
|
|
24
|
+
/** The payload given to `create()`, with keys in canonical order. */
|
|
25
|
+
payload: ApprovalPayload;
|
|
26
|
+
/** SHA-256 (hex) of the canonical payload. */
|
|
27
|
+
payloadHash: string;
|
|
40
28
|
createdAt: string;
|
|
41
29
|
expiresAt: string;
|
|
42
30
|
decidedAt?: string | null;
|
|
43
31
|
consumedAt?: string | null;
|
|
44
|
-
/** Full canonical transaction — returned only to the customer (subject) view. */
|
|
45
|
-
transaction?: FinancialTransaction | null;
|
|
46
32
|
/** Present once approved. */
|
|
47
|
-
assurance?:
|
|
33
|
+
assurance?: ApprovalAssurance | null;
|
|
48
34
|
}
|
|
49
|
-
/**
|
|
50
|
-
type
|
|
35
|
+
/** Second factor sent with `confirm()`. */
|
|
36
|
+
type ConfirmApprovalInput = {
|
|
51
37
|
method: "authenticator";
|
|
52
38
|
/** Six-digit code from the customer's authenticator app. */
|
|
53
39
|
code: string;
|
|
@@ -60,15 +46,13 @@ type ConfirmFinancialAuthorizationInput = {
|
|
|
60
46
|
assertionJson: string;
|
|
61
47
|
};
|
|
62
48
|
};
|
|
63
|
-
/** Passkey assertion options for approving one
|
|
64
|
-
interface
|
|
49
|
+
/** Passkey assertion options for approving one approval. */
|
|
50
|
+
interface ApprovalWebAuthnOptions {
|
|
65
51
|
ceremonyToken: string;
|
|
66
52
|
/** JSON `PublicKeyCredentialRequestOptions` to pass to `navigator.credentials.get()`. */
|
|
67
53
|
optionsJson: string;
|
|
68
54
|
}
|
|
69
55
|
|
|
70
|
-
type QueryParams = object;
|
|
71
|
-
|
|
72
56
|
interface HttpAdapterRequest {
|
|
73
57
|
url: string;
|
|
74
58
|
method: string;
|
|
@@ -126,35 +110,29 @@ declare class LoggingHttpAdapter implements HttpAdapter {
|
|
|
126
110
|
private log;
|
|
127
111
|
}
|
|
128
112
|
|
|
129
|
-
|
|
130
|
-
interface
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** Sends a request already authenticated as the customer (end-user bearer). */
|
|
138
|
-
type SubjectRequest = <T>(path: string, options?: JsonRequestOptions) => Promise<T>;
|
|
139
|
-
/** Customer-side operations on a financial authorization (`/auth/authorizations`). */
|
|
140
|
-
declare function subjectFinancialAuthorizations(request: SubjectRequest): {
|
|
141
|
-
/** GET /auth/authorizations/{id} — the pending transaction, to show before asking for the code. */
|
|
142
|
-
get: (id: string) => Promise<FinancialAuthorization>;
|
|
143
|
-
/** POST /auth/authorizations/{id}/webauthn/options — passkey options for approving this authorization. */
|
|
144
|
-
webauthnOptions: (id: string) => Promise<FinancialWebAuthnOptions>;
|
|
113
|
+
/** Customer-side operations on an approval (`/auth/authorizations`). */
|
|
114
|
+
interface SubjectApprovals {
|
|
115
|
+
/** GET /auth/authorizations/{id} — the pending payload, to show before asking for the code. */
|
|
116
|
+
get(id: string): Promise<Approval>;
|
|
117
|
+
/** POST /auth/authorizations/{id}/webauthn/options — passkey options for approving it. */
|
|
118
|
+
webauthnOptions(id: string): Promise<ApprovalWebAuthnOptions>;
|
|
145
119
|
/**
|
|
146
|
-
* POST /auth/authorizations/{id}/confirm — approves
|
|
120
|
+
* POST /auth/authorizations/{id}/confirm — approves it.
|
|
147
121
|
*
|
|
148
122
|
* Pass the authenticator code or passkey assertion to verify the second
|
|
149
123
|
* factor inline (recommended). Without `input`, the session itself must
|
|
150
124
|
* have used a passkey or authenticator code within the last 5 minutes,
|
|
151
125
|
* otherwise the API answers `step_up_required`.
|
|
152
126
|
*/
|
|
153
|
-
confirm
|
|
154
|
-
/** POST /auth/authorizations/{id}/reject — the customer declines
|
|
155
|
-
reject
|
|
156
|
-
}
|
|
157
|
-
|
|
127
|
+
confirm(id: string, input?: ConfirmApprovalInput): Promise<Approval>;
|
|
128
|
+
/** POST /auth/authorizations/{id}/reject — the customer declines it. */
|
|
129
|
+
reject(id: string): Promise<Approval>;
|
|
130
|
+
}
|
|
131
|
+
/** The `security` namespace an end-user client exposes. */
|
|
132
|
+
interface SubjectSecurity {
|
|
133
|
+
/** Approve or reject what your backend asked the customer to confirm. */
|
|
134
|
+
readonly approvals: SubjectApprovals;
|
|
135
|
+
}
|
|
158
136
|
|
|
159
137
|
interface PaginationOptions {
|
|
160
138
|
skip?: number;
|
|
@@ -620,12 +598,12 @@ declare class AuthyonClient {
|
|
|
620
598
|
};
|
|
621
599
|
};
|
|
622
600
|
/**
|
|
623
|
-
*
|
|
624
|
-
* (`@authyon/server` → `
|
|
625
|
-
* Show the
|
|
601
|
+
* `security.approvals`: approve or reject what your backend asked the
|
|
602
|
+
* customer to confirm (`@authyon/server` → `security.approvals.create`).
|
|
603
|
+
* Show the payload with `get()`, then `confirm()` with the customer's
|
|
626
604
|
* authenticator code or passkey, or `reject()`.
|
|
627
605
|
*/
|
|
628
|
-
readonly
|
|
606
|
+
readonly security: SubjectSecurity;
|
|
629
607
|
/**
|
|
630
608
|
* POST /auth/introspect — lightweight token introspection (RFC 7662).
|
|
631
609
|
*
|
|
@@ -750,4 +728,4 @@ declare function hasPermissionGroup(source: AuthyonPermissionSource | readonly s
|
|
|
750
728
|
/** Converts Authyon's `subject:action` permission strings to authorization rules. */
|
|
751
729
|
declare function createAuthyonRules(source?: AuthyonPermissionSource, options?: AuthyonAbilityOptions): AbilityRule[];
|
|
752
730
|
|
|
753
|
-
export { type
|
|
731
|
+
export { type TwoFactorMethod as $, AuthyonClient as A, type InviteMemberInput as B, type ConfirmApprovalInput as C, type LoginInput as D, type LoginResult as E, FetchHttpAdapter as F, type OrganizationMember as G, type HttpAdapter as H, type IntrospectResult as I, type PaginationOptions as J, type PermissionGroup as K, LoggingHttpAdapter as L, type Role as M, type SessionControllerOptions as N, type Organization as O, type Paged as P, type SessionInfo as Q, type RegisterInput as R, type Session as S, type TokenStorage as T, type SessionSnapshot as U, type SessionSnapshotListener as V, type SessionStatus as W, type SsoProvider as X, type SubjectApprovals as Y, type SubjectSecurity as Z, type TwoFactorChallenge as _, type HttpLoggerOptions as a, type TwoFactorStatus as a0, type User as a1, type ValidateResult as a2, type VerifyTwoFactorInput as a3, type WebAuthnAssertion as a4, type WebAuthnCeremonyStart as a5, type WebAuthnCredential as a6, createAuthyonAbility as a7, createAuthyonRules as a8, createClient as a9, hasPermission as aa, hasPermissionGroup as ab, type AbilityConditions as b, type AbilityEvent as c, type AbilityListener as d, type AbilityRule as e, type AbilitySubject as f, type Activity as g, type Approval as h, type ApprovalAssurance as i, type ApprovalPayload as j, type ApprovalStatus as k, type ApprovalWebAuthnOptions as l, type AuthEvent as m, type AuthState as n, type AuthStateListener as o, type AuthenticatorSetup as p, AuthyonAbility as q, AuthyonAbilityBuilder as r, type AuthyonAbilityOptions as s, type AuthyonClientOptions as t, type AuthyonPermissionSource as u, AuthyonSessionController as v, type CreateOrganizationInput as w, type HttpAdapterRequest as x, type HttpLogEvent as y, type HttpLogger as z };
|
package/dist/index.cjs
CHANGED
|
@@ -40,29 +40,20 @@ __export(index_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
|
-
// ../../internal/core/
|
|
43
|
+
// ../../internal/core/security/approvals.ts
|
|
44
44
|
function path(id, suffix = "") {
|
|
45
45
|
if (typeof id !== "string" || !id.trim())
|
|
46
|
-
throw new TypeError("Authyon:
|
|
46
|
+
throw new TypeError("Authyon: an approval id is required.");
|
|
47
47
|
return `/auth/authorizations/${encodeURIComponent(id)}${suffix}`;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function subjectSecurity(request) {
|
|
50
50
|
return {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* Pass the authenticator code or passkey assertion to verify the second
|
|
59
|
-
* factor inline (recommended). Without `input`, the session itself must
|
|
60
|
-
* have used a passkey or authenticator code within the last 5 minutes,
|
|
61
|
-
* otherwise the API answers `step_up_required`.
|
|
62
|
-
*/
|
|
63
|
-
confirm: (id, input) => request(path(id, "/confirm"), { method: "POST", body: input }),
|
|
64
|
-
/** POST /auth/authorizations/{id}/reject — the customer declines the transaction. */
|
|
65
|
-
reject: (id) => request(path(id, "/reject"), { method: "POST" })
|
|
51
|
+
approvals: {
|
|
52
|
+
get: (id) => request(path(id)),
|
|
53
|
+
webauthnOptions: (id) => request(path(id, "/webauthn/options"), { method: "POST" }),
|
|
54
|
+
confirm: (id, input) => request(path(id, "/confirm"), { method: "POST", body: input }),
|
|
55
|
+
reject: (id) => request(path(id, "/reject"), { method: "POST" })
|
|
56
|
+
}
|
|
66
57
|
};
|
|
67
58
|
}
|
|
68
59
|
|
|
@@ -83,10 +74,17 @@ var ErrorCodes = {
|
|
|
83
74
|
InvalidSecondFactorCode: "invalid_code",
|
|
84
75
|
VerificationAttemptsExhausted: "verification_attempts_exhausted",
|
|
85
76
|
MethodNotEnrolled: "method_not_enrolled",
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
IdempotencyConflict: "idempotency_conflict"
|
|
77
|
+
InvalidApprovalState: "invalid_authorization_state",
|
|
78
|
+
PayloadMismatch: "payload_mismatch",
|
|
79
|
+
ApprovalNotConsumable: "authorization_not_consumable",
|
|
80
|
+
IdempotencyConflict: "idempotency_conflict",
|
|
81
|
+
UserDisabled: "user_disabled",
|
|
82
|
+
UserNotFound: "user_not_found",
|
|
83
|
+
TemporarilyUnavailable: "temporarily_unavailable",
|
|
84
|
+
InsufficientScope: "insufficient_scope",
|
|
85
|
+
ApprovalNotFound: "authorization_not_found",
|
|
86
|
+
SessionRevoked: "session_revoked",
|
|
87
|
+
TwoFactorTooManyFailures: "user.2fa.too_many_failures"
|
|
90
88
|
};
|
|
91
89
|
var STANDARD_ERROR_FIELDS = /* @__PURE__ */ new Set([
|
|
92
90
|
"type",
|
|
@@ -687,14 +685,14 @@ var AuthyonClient = class {
|
|
|
687
685
|
})
|
|
688
686
|
}
|
|
689
687
|
};
|
|
690
|
-
// ──
|
|
688
|
+
// ── Security (customer side) ─────────────────────────────────────────────
|
|
691
689
|
/**
|
|
692
|
-
*
|
|
693
|
-
* (`@authyon/server` → `
|
|
694
|
-
* Show the
|
|
690
|
+
* `security.approvals`: approve or reject what your backend asked the
|
|
691
|
+
* customer to confirm (`@authyon/server` → `security.approvals.create`).
|
|
692
|
+
* Show the payload with `get()`, then `confirm()` with the customer's
|
|
695
693
|
* authenticator code or passkey, or `reject()`.
|
|
696
694
|
*/
|
|
697
|
-
this.
|
|
695
|
+
this.security = subjectSecurity(
|
|
698
696
|
(path2, options) => this.request(path2, { ...options, bearer: true })
|
|
699
697
|
);
|
|
700
698
|
if (!options.envKey)
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-
|
|
2
|
-
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as Activity, h as
|
|
1
|
+
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-5_xXXbDF.cjs';
|
|
2
|
+
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as Activity, h as Approval, i as ApprovalAssurance, j as ApprovalPayload, k as ApprovalStatus, l as ApprovalWebAuthnOptions, m as AuthEvent, n as AuthState, o as AuthStateListener, p as AuthenticatorSetup, q as AuthyonAbility, r as AuthyonAbilityBuilder, s as AuthyonAbilityOptions, t as AuthyonClientOptions, u as AuthyonPermissionSource, v as AuthyonSessionController, C as ConfirmApprovalInput, w as CreateOrganizationInput, F as FetchHttpAdapter, x as HttpAdapterRequest, y as HttpLogEvent, z as HttpLogger, I as IntrospectResult, B as InviteMemberInput, L as LoggingHttpAdapter, D as LoginInput, E as LoginResult, O as Organization, G as OrganizationMember, P as Paged, J as PaginationOptions, K as PermissionGroup, R as RegisterInput, M as Role, S as Session, N as SessionControllerOptions, Q as SessionInfo, U as SessionSnapshot, V as SessionSnapshotListener, W as SessionStatus, X as SsoProvider, Y as SubjectApprovals, Z as SubjectSecurity, _ as TwoFactorChallenge, $ as TwoFactorMethod, a0 as TwoFactorStatus, a1 as User, a2 as ValidateResult, a3 as VerifyTwoFactorInput, a4 as WebAuthnAssertion, a5 as WebAuthnCeremonyStart, a6 as WebAuthnCredential, a7 as createAuthyonAbility, a8 as createAuthyonRules, a9 as createClient, aa as hasPermission, ab as hasPermissionGroup } from './ability-5_xXXbDF.cjs';
|
|
3
3
|
|
|
4
4
|
declare const ErrorCodes: {
|
|
5
5
|
readonly Unknown: "unknown";
|
|
@@ -17,10 +17,17 @@ declare const ErrorCodes: {
|
|
|
17
17
|
readonly InvalidSecondFactorCode: "invalid_code";
|
|
18
18
|
readonly VerificationAttemptsExhausted: "verification_attempts_exhausted";
|
|
19
19
|
readonly MethodNotEnrolled: "method_not_enrolled";
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
20
|
+
readonly InvalidApprovalState: "invalid_authorization_state";
|
|
21
|
+
readonly PayloadMismatch: "payload_mismatch";
|
|
22
|
+
readonly ApprovalNotConsumable: "authorization_not_consumable";
|
|
23
23
|
readonly IdempotencyConflict: "idempotency_conflict";
|
|
24
|
+
readonly UserDisabled: "user_disabled";
|
|
25
|
+
readonly UserNotFound: "user_not_found";
|
|
26
|
+
readonly TemporarilyUnavailable: "temporarily_unavailable";
|
|
27
|
+
readonly InsufficientScope: "insufficient_scope";
|
|
28
|
+
readonly ApprovalNotFound: "authorization_not_found";
|
|
29
|
+
readonly SessionRevoked: "session_revoked";
|
|
30
|
+
readonly TwoFactorTooManyFailures: "user.2fa.too_many_failures";
|
|
24
31
|
};
|
|
25
32
|
type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
26
33
|
type AuthyonErrorCategory = "network" | "timeout" | "authentication" | "authorization" | "validation" | "not_found" | "conflict" | "rate_limit" | "server" | "unknown";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-
|
|
2
|
-
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as Activity, h as
|
|
1
|
+
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-5_xXXbDF.js';
|
|
2
|
+
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as Activity, h as Approval, i as ApprovalAssurance, j as ApprovalPayload, k as ApprovalStatus, l as ApprovalWebAuthnOptions, m as AuthEvent, n as AuthState, o as AuthStateListener, p as AuthenticatorSetup, q as AuthyonAbility, r as AuthyonAbilityBuilder, s as AuthyonAbilityOptions, t as AuthyonClientOptions, u as AuthyonPermissionSource, v as AuthyonSessionController, C as ConfirmApprovalInput, w as CreateOrganizationInput, F as FetchHttpAdapter, x as HttpAdapterRequest, y as HttpLogEvent, z as HttpLogger, I as IntrospectResult, B as InviteMemberInput, L as LoggingHttpAdapter, D as LoginInput, E as LoginResult, O as Organization, G as OrganizationMember, P as Paged, J as PaginationOptions, K as PermissionGroup, R as RegisterInput, M as Role, S as Session, N as SessionControllerOptions, Q as SessionInfo, U as SessionSnapshot, V as SessionSnapshotListener, W as SessionStatus, X as SsoProvider, Y as SubjectApprovals, Z as SubjectSecurity, _ as TwoFactorChallenge, $ as TwoFactorMethod, a0 as TwoFactorStatus, a1 as User, a2 as ValidateResult, a3 as VerifyTwoFactorInput, a4 as WebAuthnAssertion, a5 as WebAuthnCeremonyStart, a6 as WebAuthnCredential, a7 as createAuthyonAbility, a8 as createAuthyonRules, a9 as createClient, aa as hasPermission, ab as hasPermissionGroup } from './ability-5_xXXbDF.js';
|
|
3
3
|
|
|
4
4
|
declare const ErrorCodes: {
|
|
5
5
|
readonly Unknown: "unknown";
|
|
@@ -17,10 +17,17 @@ declare const ErrorCodes: {
|
|
|
17
17
|
readonly InvalidSecondFactorCode: "invalid_code";
|
|
18
18
|
readonly VerificationAttemptsExhausted: "verification_attempts_exhausted";
|
|
19
19
|
readonly MethodNotEnrolled: "method_not_enrolled";
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
22
|
-
readonly
|
|
20
|
+
readonly InvalidApprovalState: "invalid_authorization_state";
|
|
21
|
+
readonly PayloadMismatch: "payload_mismatch";
|
|
22
|
+
readonly ApprovalNotConsumable: "authorization_not_consumable";
|
|
23
23
|
readonly IdempotencyConflict: "idempotency_conflict";
|
|
24
|
+
readonly UserDisabled: "user_disabled";
|
|
25
|
+
readonly UserNotFound: "user_not_found";
|
|
26
|
+
readonly TemporarilyUnavailable: "temporarily_unavailable";
|
|
27
|
+
readonly InsufficientScope: "insufficient_scope";
|
|
28
|
+
readonly ApprovalNotFound: "authorization_not_found";
|
|
29
|
+
readonly SessionRevoked: "session_revoked";
|
|
30
|
+
readonly TwoFactorTooManyFailures: "user.2fa.too_many_failures";
|
|
24
31
|
};
|
|
25
32
|
type KnownErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
26
33
|
type AuthyonErrorCategory = "network" | "timeout" | "authentication" | "authorization" | "validation" | "not_found" | "conflict" | "rate_limit" | "server" | "unknown";
|
package/dist/index.js
CHANGED
|
@@ -8,29 +8,20 @@ import {
|
|
|
8
8
|
hasPermissionGroup
|
|
9
9
|
} from "./chunk-3XJY6BCI.js";
|
|
10
10
|
|
|
11
|
-
// ../../internal/core/
|
|
11
|
+
// ../../internal/core/security/approvals.ts
|
|
12
12
|
function path(id, suffix = "") {
|
|
13
13
|
if (typeof id !== "string" || !id.trim())
|
|
14
|
-
throw new TypeError("Authyon:
|
|
14
|
+
throw new TypeError("Authyon: an approval id is required.");
|
|
15
15
|
return `/auth/authorizations/${encodeURIComponent(id)}${suffix}`;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function subjectSecurity(request) {
|
|
18
18
|
return {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
* Pass the authenticator code or passkey assertion to verify the second
|
|
27
|
-
* factor inline (recommended). Without `input`, the session itself must
|
|
28
|
-
* have used a passkey or authenticator code within the last 5 minutes,
|
|
29
|
-
* otherwise the API answers `step_up_required`.
|
|
30
|
-
*/
|
|
31
|
-
confirm: (id, input) => request(path(id, "/confirm"), { method: "POST", body: input }),
|
|
32
|
-
/** POST /auth/authorizations/{id}/reject — the customer declines the transaction. */
|
|
33
|
-
reject: (id) => request(path(id, "/reject"), { method: "POST" })
|
|
19
|
+
approvals: {
|
|
20
|
+
get: (id) => request(path(id)),
|
|
21
|
+
webauthnOptions: (id) => request(path(id, "/webauthn/options"), { method: "POST" }),
|
|
22
|
+
confirm: (id, input) => request(path(id, "/confirm"), { method: "POST", body: input }),
|
|
23
|
+
reject: (id) => request(path(id, "/reject"), { method: "POST" })
|
|
24
|
+
}
|
|
34
25
|
};
|
|
35
26
|
}
|
|
36
27
|
|
|
@@ -51,10 +42,17 @@ var ErrorCodes = {
|
|
|
51
42
|
InvalidSecondFactorCode: "invalid_code",
|
|
52
43
|
VerificationAttemptsExhausted: "verification_attempts_exhausted",
|
|
53
44
|
MethodNotEnrolled: "method_not_enrolled",
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
IdempotencyConflict: "idempotency_conflict"
|
|
45
|
+
InvalidApprovalState: "invalid_authorization_state",
|
|
46
|
+
PayloadMismatch: "payload_mismatch",
|
|
47
|
+
ApprovalNotConsumable: "authorization_not_consumable",
|
|
48
|
+
IdempotencyConflict: "idempotency_conflict",
|
|
49
|
+
UserDisabled: "user_disabled",
|
|
50
|
+
UserNotFound: "user_not_found",
|
|
51
|
+
TemporarilyUnavailable: "temporarily_unavailable",
|
|
52
|
+
InsufficientScope: "insufficient_scope",
|
|
53
|
+
ApprovalNotFound: "authorization_not_found",
|
|
54
|
+
SessionRevoked: "session_revoked",
|
|
55
|
+
TwoFactorTooManyFailures: "user.2fa.too_many_failures"
|
|
58
56
|
};
|
|
59
57
|
var STANDARD_ERROR_FIELDS = /* @__PURE__ */ new Set([
|
|
60
58
|
"type",
|
|
@@ -655,14 +653,14 @@ var AuthyonClient = class {
|
|
|
655
653
|
})
|
|
656
654
|
}
|
|
657
655
|
};
|
|
658
|
-
// ──
|
|
656
|
+
// ── Security (customer side) ─────────────────────────────────────────────
|
|
659
657
|
/**
|
|
660
|
-
*
|
|
661
|
-
* (`@authyon/server` → `
|
|
662
|
-
* Show the
|
|
658
|
+
* `security.approvals`: approve or reject what your backend asked the
|
|
659
|
+
* customer to confirm (`@authyon/server` → `security.approvals.create`).
|
|
660
|
+
* Show the payload with `get()`, then `confirm()` with the customer's
|
|
663
661
|
* authenticator code or passkey, or `reject()`.
|
|
664
662
|
*/
|
|
665
|
-
this.
|
|
663
|
+
this.security = subjectSecurity(
|
|
666
664
|
(path2, options) => this.request(path2, { ...options, bearer: true })
|
|
667
665
|
);
|
|
668
666
|
if (!options.envKey)
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { a1 as User, N as SessionControllerOptions, A as AuthyonClient, U as SessionSnapshot, S as Session, f as AbilitySubject, s as AuthyonAbilityOptions, q as AuthyonAbility } from '../ability-5_xXXbDF.cjs';
|
|
4
|
+
export { v as AuthyonSessionController, V as SessionSnapshotListener, W as SessionStatus } from '../ability-5_xXXbDF.cjs';
|
|
5
5
|
|
|
6
6
|
interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
|
|
7
7
|
client: AuthyonClient;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { a1 as User, N as SessionControllerOptions, A as AuthyonClient, U as SessionSnapshot, S as Session, f as AbilitySubject, s as AuthyonAbilityOptions, q as AuthyonAbility } from '../ability-5_xXXbDF.js';
|
|
4
|
+
export { v as AuthyonSessionController, V as SessionSnapshotListener, W as SessionStatus } from '../ability-5_xXXbDF.js';
|
|
5
5
|
|
|
6
6
|
interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
|
|
7
7
|
client: AuthyonClient;
|