@authyon/server 0.2.0-beta.14 → 0.2.0-beta.16

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.
@@ -57,6 +57,82 @@ declare class LoggingHttpAdapter implements HttpAdapter {
57
57
  private log;
58
58
  }
59
59
 
60
+ /**
61
+ * Security methods active on the user's account, as returned in the
62
+ * `security` field of `GET /auth/me` and `POST /auth/validate`.
63
+ */
64
+ interface SecurityMethods {
65
+ /** A password is set (false for accounts created only through SSO or magic link). */
66
+ password: boolean;
67
+ /** Authenticator app (TOTP one-time codes). */
68
+ authenticator: boolean;
69
+ /** One-time codes sent by email. */
70
+ emailCode: boolean;
71
+ /** At least one passkey registered. */
72
+ passkey: boolean;
73
+ passkeyCount: number;
74
+ /** Unused recovery codes left. */
75
+ recoveryCodes: number;
76
+ /** SSO providers linked to the account, e.g. `["google", "github"]`. */
77
+ sso: string[];
78
+ /** Any second factor is active (authenticator, email code or passkey). */
79
+ twoFactor: boolean;
80
+ }
81
+ /** Lifecycle of an approval. */
82
+ type ApprovalStatus = "pending" | "approved" | "denied" | "consumed" | "expired";
83
+ /**
84
+ * Free-form JSON object describing what the customer approves (up to 16 KiB).
85
+ * The API stores it, shows it back to the customer and binds its canonical
86
+ * hash (keys sorted) to the approval.
87
+ */
88
+ type ApprovalPayload = Record<string, unknown>;
89
+ /** Evidence of how the customer proved their identity when approving. */
90
+ interface ApprovalAssurance {
91
+ /** `urn:authyon:loa:3` (passkey) or `urn:authyon:loa:2` (authenticator code). */
92
+ acr: string;
93
+ /** Authentication methods, e.g. `["pwd", "otp"]` or `["pwd", "webauthn"]`. */
94
+ amr: string[];
95
+ /** When the second factor was verified (ISO 8601). */
96
+ authTime: string;
97
+ }
98
+ /** A request for the customer to approve something with a second factor. */
99
+ interface Approval {
100
+ id: string;
101
+ status: ApprovalStatus;
102
+ subjectId: string;
103
+ tenantId?: string | null;
104
+ /** The payload given to `create()`, with keys in canonical order. */
105
+ payload: ApprovalPayload;
106
+ /** SHA-256 (hex) of the canonical payload. */
107
+ payloadHash: string;
108
+ createdAt: string;
109
+ expiresAt: string;
110
+ decidedAt?: string | null;
111
+ consumedAt?: string | null;
112
+ /** Present once approved. */
113
+ assurance?: ApprovalAssurance | null;
114
+ }
115
+ /** Second factor sent with `confirm()`. */
116
+ type ConfirmApprovalInput = {
117
+ method: "authenticator";
118
+ /** Six-digit code from the customer's authenticator app. */
119
+ code: string;
120
+ } | {
121
+ method: "webauthn";
122
+ /** Assertion for the options returned by `webauthnOptions()`. */
123
+ webAuthn: {
124
+ ceremonyToken: string;
125
+ /** JSON-serialized `PublicKeyCredential` from `navigator.credentials.get()`. */
126
+ assertionJson: string;
127
+ };
128
+ };
129
+ /** Passkey assertion options for approving one approval. */
130
+ interface ApprovalWebAuthnOptions {
131
+ ceremonyToken: string;
132
+ /** JSON `PublicKeyCredentialRequestOptions` to pass to `navigator.credentials.get()`. */
133
+ optionsJson: string;
134
+ }
135
+
60
136
  interface PaginationOptions {
61
137
  skip?: number;
62
138
  take?: number;
@@ -120,6 +196,8 @@ interface User {
120
196
  /** Environment-level roles from the database-validated user profile. */
121
197
  roles?: string[];
122
198
  permissions?: string[];
199
+ /** Security methods active on the account (authenticator, email code, passkey, SSO…). */
200
+ security?: SecurityMethods;
123
201
  }
124
202
  interface RoleGrant {
125
203
  role: string;
@@ -251,8 +329,15 @@ interface UpdateOrganizationInput {
251
329
  }
252
330
  interface CreateUserInput {
253
331
  email: string;
254
- username: string;
332
+ /**
333
+ * Same contract as `/auth/register`: optional only when the environment's
334
+ * username policy is `AutoFromEmail` (derived from the email). Collisions
335
+ * resolve by that policy.
336
+ */
337
+ username?: string;
255
338
  password: string;
339
+ firstName?: string;
340
+ lastName?: string;
256
341
  /** Values for custom user fields configured in the environment. */
257
342
  customFields?: Record<string, unknown>;
258
343
  emailConfirmed?: boolean;
@@ -429,6 +514,96 @@ interface TenantMember {
429
514
  lastLoginAt: string | null;
430
515
  }
431
516
  type TenantMemberPage = Paged<TenantMember>;
517
+ /**
518
+ * Invite an address to a tenant. The address may not have an account in the
519
+ * environment yet — accepting creates it. `sendEmail` defaults to `true`;
520
+ * `false` only returns the link, for delivery through your own channel.
521
+ */
522
+ interface TenantInviteInput {
523
+ email: string;
524
+ roles?: string[];
525
+ sendEmail?: boolean;
526
+ /**
527
+ * Where to send the invitee after they accept. Must be registered exactly in
528
+ * the environment's redirect URIs (the same list SSO and magic link use);
529
+ * otherwise the API rejects the invite. Comes back on `preview` and `accept`.
530
+ */
531
+ redirectUri?: string;
532
+ }
533
+ /** Returned when an invite is created or re-issued. `acceptUrl` is only ever
534
+ * readable here — the API keeps a hash of the token, not the token. */
535
+ interface TenantInviteIssued {
536
+ id: string;
537
+ tenantId: string;
538
+ email: string;
539
+ roles: string[];
540
+ acceptUrl: string;
541
+ expiresAt: string;
542
+ emailSent: boolean;
543
+ redirectUri: string | null;
544
+ }
545
+ type TenantInviteStatus = "pending" | "accepted" | "revoked" | "expired";
546
+ interface TenantInvite {
547
+ id: string;
548
+ tenantId: string;
549
+ email: string;
550
+ roles: string[];
551
+ status: TenantInviteStatus;
552
+ createdAt: string;
553
+ expiresAt: string;
554
+ emailSentAt: string | null;
555
+ acceptedAt: string | null;
556
+ acceptedByUserId: string | null;
557
+ revokedAt: string | null;
558
+ invitedByUserId: string | null;
559
+ redirectUri: string | null;
560
+ }
561
+ /** What an accept page shows before the invitee commits. */
562
+ interface TenantInvitePreview {
563
+ tenantId: string;
564
+ tenantName: string;
565
+ email: string;
566
+ roles: string[];
567
+ expiresAt: string;
568
+ /** True: accepting only needs the token. False: send a password (and a username when `usernameRequired`). */
569
+ accountExists: boolean;
570
+ usernameRequired: boolean;
571
+ /** Where the issuer asked to send the invitee after accepting, or `null`. */
572
+ redirectUri: string | null;
573
+ }
574
+ /**
575
+ * Redeem an invite. For an address that already has an account only `token`
576
+ * and the metadata are used; the rest is for creating the account.
577
+ */
578
+ interface AcceptTenantInviteInput {
579
+ token: string;
580
+ username?: string;
581
+ password?: string;
582
+ firstName?: string;
583
+ lastName?: string;
584
+ /**
585
+ * @deprecated Use `publicMetadata` / `privateMetadata`. Still sent and
586
+ * validated against the environment's user field schema for now.
587
+ */
588
+ customFields?: Record<string, unknown>;
589
+ /**
590
+ * Replaces the user's public metadata (readable by the user). Requires the
591
+ * client credentials (`clientId`/`clientSecret`) with `authyon:users:write`:
592
+ * when this or `privateMetadata` is set, `accept` calls
593
+ * `POST /env/tenant-invites/accept` instead of the public route.
594
+ */
595
+ publicMetadata?: Record<string, unknown>;
596
+ /** Replaces the user's private metadata (server-only). Same requirement as `publicMetadata`. */
597
+ privateMetadata?: Record<string, unknown>;
598
+ }
599
+ interface TenantInviteAccepted {
600
+ tenantId: string;
601
+ tenantName: string;
602
+ userId: string;
603
+ accountCreated: boolean;
604
+ /** Where the issuer asked to send the invitee, or `null`. Redirecting is up to the accept page. */
605
+ redirectUri: string | null;
606
+ }
432
607
 
433
608
  type QueryParams = object;
434
609
 
@@ -442,95 +617,34 @@ interface JsonRequestOptions {
442
617
 
443
618
  type ManagementRequest = <T>(path: string, options?: JsonRequestOptions) => Promise<T>;
444
619
 
445
- /** Lifecycle of a transaction-bound financial authorization. */
446
- type FinancialAuthorizationStatus = "pending" | "approved" | "denied" | "consumed" | "expired";
447
- /**
448
- * The transaction the customer approves. The API hashes a canonical form of
449
- * these fields; `consume()` must resend exactly the same values (amount is
450
- * normalized to four decimal places, metadata keys are sorted).
451
- */
452
- interface FinancialTransaction {
453
- /** Business action, e.g. `"pix.transfer"`. Max 100 characters. */
454
- action: string;
455
- /** Positive amount, up to 15 integer digits and 4 decimal places. */
456
- amount: number;
457
- /** ISO 4217 currency code, e.g. `"BRL"`. */
458
- currency: string;
459
- /** Human-readable beneficiary shown to the customer. Max 256 characters. */
460
- beneficiary: string;
461
- /** Optional JSON object bound into the hash (max 16 KiB). */
462
- metadata?: Record<string, unknown>;
463
- }
464
- /** Evidence of how the customer proved their identity when approving. */
465
- interface FinancialAssurance {
466
- /** `urn:authyon:loa:3` (passkey) or `urn:authyon:loa:2` (authenticator code). */
467
- acr: string;
468
- /** Authentication methods, e.g. `["pwd", "otp"]` or `["pwd", "webauthn"]`. */
469
- amr: string[];
470
- /** When the second factor was verified (ISO 8601). */
471
- authTime: string;
472
- }
473
- interface FinancialAuthorization {
474
- id: string;
475
- status: FinancialAuthorizationStatus;
476
- subjectId: string;
477
- tenantId?: string | null;
478
- action: string;
479
- amount: number;
480
- currency: string;
481
- beneficiary: string;
482
- /** SHA-256 (hex) of the canonical transaction. */
483
- transactionHash: string;
484
- createdAt: string;
485
- expiresAt: string;
486
- decidedAt?: string | null;
487
- consumedAt?: string | null;
488
- /** Full canonical transaction — returned only to the customer (subject) view. */
489
- transaction?: FinancialTransaction | null;
490
- /** Present once approved. */
491
- assurance?: FinancialAssurance | null;
492
- }
493
- /** Inline second factor sent with `confirm()`. */
494
- type ConfirmFinancialAuthorizationInput = {
495
- method: "authenticator";
496
- /** Six-digit code from the customer's authenticator app. */
497
- code: string;
498
- } | {
499
- method: "webauthn";
500
- /** Assertion for the options returned by `webauthnOptions()`. */
501
- webAuthn: {
502
- ceremonyToken: string;
503
- /** JSON-serialized `PublicKeyCredential` from `navigator.credentials.get()`. */
504
- assertionJson: string;
505
- };
506
- };
507
- /** Passkey assertion options for approving one authorization. */
508
- interface FinancialWebAuthnOptions {
509
- ceremonyToken: string;
510
- /** JSON `PublicKeyCredentialRequestOptions` to pass to `navigator.credentials.get()`. */
511
- optionsJson: string;
512
- }
513
-
514
- /** Sends a request already authenticated as the customer (end-user bearer). */
515
- type SubjectRequest = <T>(path: string, options?: JsonRequestOptions) => Promise<T>;
516
- /** Customer-side operations on a financial authorization (`/auth/authorizations`). */
517
- declare function subjectFinancialAuthorizations(request: SubjectRequest): {
518
- /** GET /auth/authorizations/{id} — the pending transaction, to show before asking for the code. */
519
- get: (id: string) => Promise<FinancialAuthorization>;
520
- /** POST /auth/authorizations/{id}/webauthn/options — passkey options for approving this authorization. */
521
- webauthnOptions: (id: string) => Promise<FinancialWebAuthnOptions>;
620
+ /** Customer-side operations on an approval (`/auth/authorizations`). */
621
+ interface SubjectApprovals {
622
+ /** GET /auth/authorizations/{id} — the pending payload, to show before asking for the code. */
623
+ get(id: string): Promise<Approval>;
624
+ /** POST /auth/authorizations/{id}/webauthn/options — passkey options for approving it. */
625
+ webauthnOptions(id: string): Promise<ApprovalWebAuthnOptions>;
522
626
  /**
523
- * POST /auth/authorizations/{id}/confirm — approves the transaction.
627
+ * POST /auth/authorizations/{id}/confirm — approves it.
524
628
  *
525
629
  * Pass the authenticator code or passkey assertion to verify the second
526
630
  * factor inline (recommended). Without `input`, the session itself must
527
631
  * have used a passkey or authenticator code within the last 5 minutes,
528
632
  * otherwise the API answers `step_up_required`.
529
633
  */
530
- confirm: (id: string, input?: ConfirmFinancialAuthorizationInput) => Promise<FinancialAuthorization>;
531
- /** POST /auth/authorizations/{id}/reject — the customer declines the transaction. */
532
- reject: (id: string) => Promise<FinancialAuthorization>;
533
- };
634
+ confirm(id: string, input?: ConfirmApprovalInput): Promise<Approval>;
635
+ /** POST /auth/authorizations/{id}/reject — the customer declines it. */
636
+ reject(id: string): Promise<Approval>;
637
+ }
638
+ /** The `security` namespace an end-user client exposes. */
639
+ interface SubjectSecurity {
640
+ /**
641
+ * GET /auth/me — which security methods the signed-in user has active
642
+ * (password, authenticator, email code, passkeys, recovery codes, SSO).
643
+ */
644
+ methods(): Promise<SecurityMethods>;
645
+ /** Approve or reject what your backend asked the customer to confirm. */
646
+ readonly approvals: SubjectApprovals;
647
+ }
534
648
 
535
649
  /** End-user operations require a user token and the environment publishable key. */
536
650
  declare class UserScopedClient {
@@ -538,11 +652,10 @@ declare class UserScopedClient {
538
652
  /** @hidden */
539
653
  constructor(request: ManagementRequest, token: AccessTokenSource);
540
654
  /**
541
- * Customer-side approval of a financial authorization, for backends (BFF)
542
- * that hold the customer's access token: `get`, `webauthnOptions`,
543
- * `confirm`, `reject`.
655
+ * The customer's side of `security.approvals`, for backends (BFF) that hold
656
+ * the customer's access token: `get`, `webauthnOptions`, `confirm`, `reject`.
544
657
  */
545
- readonly financialAuthorizations: ReturnType<typeof subjectFinancialAuthorizations>;
658
+ readonly security: SubjectSecurity;
546
659
  readonly tenants: {
547
660
  members: {
548
661
  list: (tenantId: string, options?: PaginationOptions) => Promise<TenantMemberPage>;
@@ -550,32 +663,71 @@ declare class UserScopedClient {
550
663
  invite: (tenantId: string, input: InviteTenantMemberInput) => Promise<TenantMember>;
551
664
  remove: (tenantId: string, userId: string) => Promise<void>;
552
665
  };
666
+ /**
667
+ * Invites by e-mail or by link, acting as the user. Requires the
668
+ * `tenants:members:invite` permission on the tenant.
669
+ */
670
+ invites: {
671
+ list: (tenantId: string) => Promise<TenantInvite[]>;
672
+ /** Always returns `acceptUrl`; `sendEmail: false` skips the e-mail. */
673
+ create: (tenantId: string, input: TenantInviteInput) => Promise<TenantInviteIssued>;
674
+ /** New link (the previous one stops working), mailed unless `sendEmail` is `false`. */
675
+ resend: (tenantId: string, inviteId: string, input?: {
676
+ sendEmail?: boolean;
677
+ }) => Promise<TenantInviteIssued>;
678
+ revoke: (tenantId: string, inviteId: string) => Promise<void>;
679
+ };
553
680
  };
554
681
  }
555
682
 
556
- /** POST /env/authorizations — a transaction awaiting the customer's approval. */
557
- interface CreateFinancialAuthorizationInput extends FinancialTransaction {
683
+ /** `security.approvals.create()` — something awaiting the customer's approval. */
684
+ interface CreateApprovalInput {
558
685
  /** Environment user who must approve. */
559
686
  subjectId: string;
687
+ /** Any JSON object (up to 16 KiB) describing what is being approved. Default `{}`. */
688
+ payload?: ApprovalPayload;
560
689
  /** Restrict approval to a session in this tenant. */
561
690
  tenantId?: string;
562
691
  /** Lifetime in seconds, clamped to 60–600. Default 300. */
563
692
  expiresInSeconds?: number;
564
693
  /**
565
- * Sent as the `Idempotency-Key` header (max 128 chars). Retrying with the
566
- * same key and transaction returns the same authorization; the same key
567
- * with a different transaction fails with `idempotency_conflict`.
694
+ * Optional. Sent as the `Idempotency-Key` header (max 128 chars): retrying
695
+ * with the same key and payload returns the same approval; the same key
696
+ * with a different payload fails with `idempotency_conflict`.
568
697
  */
569
- idempotencyKey: string;
698
+ idempotencyKey?: string;
570
699
  }
571
- /** POST /env/authorizations/{id}/consume — single-use redemption result. */
572
- interface ConsumedFinancialAuthorization {
700
+ /** `security.approvals.consume()` — single-use redemption result. */
701
+ interface ConsumedApproval {
573
702
  id: string;
574
703
  status: "consumed";
575
704
  consumedAt: string;
576
- transactionHash: string;
577
- assurance: FinancialAssurance | null;
705
+ /** The approved payload — execute exactly this. */
706
+ payload: ApprovalPayload;
707
+ payloadHash: string;
708
+ assurance: ApprovalAssurance | null;
578
709
  }
710
+ /** `security.otp.check()` result. */
711
+ type OtpCheckResult = {
712
+ valid: true;
713
+ userId: string;
714
+ /** Always `"otp"` (authenticator app). */
715
+ method: string;
716
+ verifiedAt: string;
717
+ } | {
718
+ valid: false;
719
+ /**
720
+ * Wrong codes left before the first consequence: the sign-out (3 in a
721
+ * row) or the 15-minute lock (5). `0` when the user was just signed out.
722
+ */
723
+ attemptsRemaining: number;
724
+ /**
725
+ * True when this was the 3rd wrong code in a row (counted across login
726
+ * 2FA, `security.otp.check` and `security.approvals.confirm`): every
727
+ * session of the user was ended and they must sign in again.
728
+ */
729
+ sessionsRevoked?: boolean;
730
+ };
579
731
 
580
732
  interface ClientRequestContext {
581
733
  /** Real end-user IP, resolved only from infrastructure trusted by the application. */
@@ -784,6 +936,44 @@ declare class AuthyonServerClient {
784
936
  /** DELETE .../members/{userId}/permissions/{permission} — revoke a permission from a tenant member. */
785
937
  revokePermission: (tenantId: string, userId: string, permission: string) => Promise<void>;
786
938
  };
939
+ /**
940
+ * Invites by e-mail or by link — for addresses that may not have an
941
+ * account yet; accepting creates it. Managing them needs the
942
+ * credential's `authyon:users:write` scope (listing, `authyon:tenants:read`).
943
+ */
944
+ invites: {
945
+ /** GET /env/tenants/{tenantId}/invites — every invite with its status, newest first. */
946
+ list: (tenantId: string) => Promise<TenantInvite[]>;
947
+ /**
948
+ * POST /env/tenants/{tenantId}/invites — invite an address. Always
949
+ * returns `acceptUrl`; with `sendEmail: false` Authyon does not mail
950
+ * it and you deliver the link yourself. Valid 7 days, single use, and
951
+ * not readable again later.
952
+ */
953
+ create: (tenantId: string, input: TenantInviteInput) => Promise<TenantInviteIssued>;
954
+ /** POST .../invites/{inviteId}/resend — new link (the previous one stops working), mailed unless `sendEmail` is `false`. */
955
+ resend: (tenantId: string, inviteId: string, input?: {
956
+ sendEmail?: boolean;
957
+ }) => Promise<TenantInviteIssued>;
958
+ /** DELETE /env/tenants/{tenantId}/invites/{inviteId} — revoke a pending invite. */
959
+ revoke: (tenantId: string, inviteId: string) => Promise<void>;
960
+ /**
961
+ * POST /auth/tenant-invites/preview — for a backend hosting the accept
962
+ * page. Public: needs only `envKey`, the token is the credential.
963
+ */
964
+ preview: (token: string) => Promise<TenantInvitePreview>;
965
+ /**
966
+ * Joins the tenant; for an address with no account, also creates it
967
+ * (password required) with the e-mail already confirmed. Does not
968
+ * sign the user in.
969
+ *
970
+ * Without metadata: POST /auth/tenant-invites/accept — public, needs
971
+ * only `envKey`. With `publicMetadata`/`privateMetadata`: POST
972
+ * /env/tenant-invites/accept with the environment credential
973
+ * (`authyon:users:write`), since only your backend may set them.
974
+ */
975
+ accept: (input: AcceptTenantInviteInput) => Promise<TenantInviteAccepted>;
976
+ };
787
977
  roles: {
788
978
  /** GET /env/tenants/{tenantId}/roles — list a tenant's roles. */
789
979
  list: (tenantId: string) => Promise<Role[]>;
@@ -819,32 +1009,44 @@ declare class AuthyonServerClient {
819
1009
  /** GET /permissions/reserved — reserved permission names you can't redefine. */
820
1010
  reserved: () => Promise<ReservedPermissions>;
821
1011
  };
1012
+ audit: {
1013
+ /** GET /env/audit — paginated list of the environment's audit events. */
1014
+ list: (params?: PaginationOptions) => Promise<Paged<AuditEvent>>;
1015
+ /** GET /env/audit/login-activity — paginated login activity in the environment. */
1016
+ loginActivity: (params?: PaginationOptions) => Promise<Paged<LoginActivity>>;
1017
+ };
1018
+ };
1019
+ readonly security: {
1020
+ otp: {
1021
+ /**
1022
+ * POST /env/users/{userId}/otp/verify — checks the user's authenticator
1023
+ * app (TOTP) code. A wrong code returns `{ valid: false }` instead of
1024
+ * throwing. Each code is accepted once; 3 wrong codes in a row sign the
1025
+ * user out everywhere (`sessionsRevoked: true`); 5 lock the check for 15
1026
+ * minutes (`rate_limited`). More than 50 wrong codes in 10 minutes from the
1027
+ * same credential pause it (`credential_throttled`). Needs `authyon:otp:verify`.
1028
+ */
1029
+ check: (userId: string, code: string) => Promise<OtpCheckResult>;
1030
+ };
822
1031
  /**
823
- * Transaction-bound step-up for financial operations. The environment
824
- * credential needs the `authyon:financial:authorize` scope.
1032
+ * The customer approves a payload with their authenticator code or
1033
+ * passkey, once.
825
1034
  *
826
- * 1. `create()` the authorization for the transaction and the customer.
827
- * 2. The customer approves it with their authenticator code or passkey
828
- * (`@authyon/auth` → `financialAuthorizations.confirm`).
829
- * 3. `consume()` it with the same transaction right before executing it.
1035
+ * 1. `create()` the approval with the payload and the customer.
1036
+ * 2. The customer confirms it (`@authyon/auth` → `security.approvals.confirm`).
1037
+ * 3. `consume()` it right before executing, and execute the returned payload.
830
1038
  */
831
- financialAuthorizations: {
832
- /** POST /env/authorizations — registers a transaction awaiting the customer's approval. */
833
- create: (input: CreateFinancialAuthorizationInput) => Promise<FinancialAuthorization>;
1039
+ approvals: {
1040
+ /** POST /env/authorizations — registers a payload awaiting the customer's approval. */
1041
+ create: (input: CreateApprovalInput) => Promise<Approval>;
834
1042
  /** GET /env/authorizations/{id} — current status and, once approved, the assurance evidence. */
835
- get: (id: string) => Promise<FinancialAuthorization>;
1043
+ get: (id: string) => Promise<Approval>;
836
1044
  /**
837
- * POST /env/authorizations/{id}/consume — redeems an approved
838
- * authorization exactly once. Resend the same transaction given to
839
- * `create()`; any difference fails with `transaction_mismatch`.
1045
+ * POST /env/authorizations/{id}/consume — redeems an approved approval
1046
+ * exactly once and returns the approved payload. Pass `payload` to have
1047
+ * the API check it matches (`payload_mismatch` otherwise).
840
1048
  */
841
- consume: (id: string, transaction: FinancialTransaction) => Promise<ConsumedFinancialAuthorization>;
842
- };
843
- audit: {
844
- /** GET /env/audit — paginated list of the environment's audit events. */
845
- list: (params?: PaginationOptions) => Promise<Paged<AuditEvent>>;
846
- /** GET /env/audit/login-activity — paginated login activity in the environment. */
847
- loginActivity: (params?: PaginationOptions) => Promise<Paged<LoginActivity>>;
1049
+ consume: (id: string, payload?: ApprovalPayload) => Promise<ConsumedApproval>;
848
1050
  };
849
1051
  };
850
1052
  readonly permissions: {
@@ -874,6 +1076,19 @@ declare class TenantScopedClient {
874
1076
  private request;
875
1077
  /** POST /tenant/auth/validate — validates this tenant client's current bearer token. */
876
1078
  validate(context?: ClientRequestContext): Promise<TenantClientValidationResult>;
1079
+ /** Invites to the token's tenant, by e-mail or by link. */
1080
+ readonly invites: {
1081
+ /** GET /tenant/invites — every invite with its status, newest first. */
1082
+ list: () => Promise<TenantInvite[]>;
1083
+ /** POST /tenant/invites — always returns `acceptUrl`; `sendEmail: false` skips the e-mail. */
1084
+ create: (input: TenantInviteInput) => Promise<TenantInviteIssued>;
1085
+ /** POST /tenant/invites/{inviteId}/resend — new link (the previous one stops working), mailed unless `sendEmail` is `false`. */
1086
+ resend: (inviteId: string, input?: {
1087
+ sendEmail?: boolean;
1088
+ }) => Promise<TenantInviteIssued>;
1089
+ /** DELETE /tenant/invites/{inviteId} — revoke a pending invite. */
1090
+ revoke: (inviteId: string) => Promise<void>;
1091
+ };
877
1092
  readonly members: {
878
1093
  /**
879
1094
  * GET /tenant/members — members of the token's tenant.
@@ -921,4 +1136,4 @@ declare class TenantScopedClient {
921
1136
  /** Convenience factory: `const authyon = createClient({ clientId, clientSecret })`. */
922
1137
  declare function createClient(options?: AuthyonServerClientOptions): AuthyonServerClient;
923
1138
 
924
- export { type TenantCredentialIssued as $, AuthyonServerClient as A, type HttpLogger as B, type ClientCredentials as C, type InviteTenantMemberInput as D, type EnvironmentUser as E, FetchHttpAdapter as F, JwksTokenVerifier as G, type HttpAdapter as H, type IntrospectResult as I, type JsonWebKeySet as J, type JwksTokenVerifierOptions as K, LoggingHttpAdapter as L, type LoginActivity as M, type Organization as N, type OpenIdConfiguration as O, type Paged as P, type PaginationOptions as Q, type Permission as R, type PermissionsByRole as S, type ReservedPermissions as T, type Role as U, type RoleGrant as V, type RoleInput as W, type RoleList as X, type RolePermissions as Y, type SafeJwtAlgorithm as Z, type TenantClientValidationResult as _, type HttpLoggerOptions as a, type TenantCredentialSummary as a0, type TenantMember as a1, type TenantMemberPage as a2, type TenantMembership as a3, TenantScopedClient as a4, type TokenResult as a5, TokenVerificationError as a6, type TokenVerificationErrorCode as a7, type UpdateOrganizationInput as a8, type User as a9, UserScopedClient as aa, type ValidateResult as ab, type VerifiedAccessToken as ac, createClient as ad, normalizeClientIp as ae, type AccessTokenSource as b, type AuditEvent as c, type AuthyonJwksDiscoveryOptions as d, type AuthyonJwtClaims as e, type AuthyonServerClientOptions as f, type ClientRequestContext as g, type ConfirmFinancialAuthorizationInput as h, type ConsumedFinancialAuthorization as i, type CreateCredentialInput as j, type CreateFinancialAuthorizationInput as k, type CreateOrganizationInput as l, type CreatePermissionInput as m, type CreateTenantCredentialInput as n, type CreateUserInput as o, type CredentialCreator as p, type CredentialDetail as q, type CredentialListOptions as r, type CredentialPermissionsInput as s, type FinancialAssurance as t, type FinancialAuthorization as u, type FinancialAuthorizationStatus as v, type FinancialTransaction as w, type FinancialWebAuthnOptions as x, type HttpAdapterRequest as y, type HttpLogEvent as z };
1139
+ export { type SafeJwtAlgorithm as $, AuthyonServerClient as A, type HttpLogEvent as B, type ClientCredentials as C, type HttpLogger as D, type EnvironmentUser as E, FetchHttpAdapter as F, type InviteTenantMemberInput as G, type HttpAdapter as H, type IntrospectResult as I, type JsonWebKeySet as J, JwksTokenVerifier as K, type JwksTokenVerifierOptions as L, LoggingHttpAdapter as M, type LoginActivity as N, type OpenIdConfiguration as O, type Organization as P, type OtpCheckResult as Q, type Paged as R, type PaginationOptions as S, type Permission as T, type PermissionsByRole as U, type ReservedPermissions as V, type Role as W, type RoleGrant as X, type RoleInput as Y, type RoleList as Z, type RolePermissions as _, type HttpLoggerOptions as a, type SecurityMethods as a0, type SubjectApprovals as a1, type SubjectSecurity as a2, type TenantClientValidationResult as a3, type TenantCredentialIssued as a4, type TenantCredentialSummary as a5, type TenantInvite as a6, type TenantInviteAccepted as a7, type TenantInviteInput as a8, type TenantInviteIssued as a9, type TenantInvitePreview as aa, type TenantInviteStatus as ab, type TenantMember as ac, type TenantMemberPage as ad, type TenantMembership as ae, TenantScopedClient as af, type TokenResult as ag, TokenVerificationError as ah, type TokenVerificationErrorCode as ai, type UpdateOrganizationInput as aj, type User as ak, UserScopedClient as al, type ValidateResult as am, type VerifiedAccessToken as an, createClient as ao, normalizeClientIp as ap, type AcceptTenantInviteInput as b, type AccessTokenSource as c, type Approval as d, type ApprovalAssurance as e, type ApprovalPayload as f, type ApprovalStatus as g, type ApprovalWebAuthnOptions as h, type AuditEvent as i, type AuthyonJwksDiscoveryOptions as j, type AuthyonJwtClaims as k, type AuthyonServerClientOptions as l, type ClientRequestContext as m, type ConfirmApprovalInput as n, type ConsumedApproval as o, type CreateApprovalInput as p, type CreateCredentialInput as q, type CreateOrganizationInput as r, type CreatePermissionInput as s, type CreateTenantCredentialInput as t, type CreateUserInput as u, type CredentialCreator as v, type CredentialDetail as w, type CredentialListOptions as x, type CredentialPermissionsInput as y, type HttpAdapterRequest as z };
package/dist/bff.cjs CHANGED
@@ -56,10 +56,18 @@ var ErrorCodes = {
56
56
  InvalidSecondFactorCode: "invalid_code",
57
57
  VerificationAttemptsExhausted: "verification_attempts_exhausted",
58
58
  MethodNotEnrolled: "method_not_enrolled",
59
- InvalidAuthorizationState: "invalid_authorization_state",
60
- TransactionMismatch: "transaction_mismatch",
61
- AuthorizationNotConsumable: "authorization_not_consumable",
62
- IdempotencyConflict: "idempotency_conflict"
59
+ InvalidApprovalState: "invalid_authorization_state",
60
+ PayloadMismatch: "payload_mismatch",
61
+ ApprovalNotConsumable: "authorization_not_consumable",
62
+ IdempotencyConflict: "idempotency_conflict",
63
+ UserDisabled: "user_disabled",
64
+ UserNotFound: "user_not_found",
65
+ TemporarilyUnavailable: "temporarily_unavailable",
66
+ InsufficientScope: "insufficient_scope",
67
+ CredentialThrottled: "credential_throttled",
68
+ ApprovalNotFound: "authorization_not_found",
69
+ SessionRevoked: "session_revoked",
70
+ TwoFactorTooManyFailures: "user.2fa.too_many_failures"
63
71
  };
64
72
  var STANDARD_ERROR_FIELDS = /* @__PURE__ */ new Set([
65
73
  "type",
package/dist/bff.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonServerClient } from './authyonServerClient-DmNnjw4z.cjs';
1
+ import { H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonServerClient } from './authyonServerClient-1_1qNRDa.cjs';
2
2
  import 'jose';
3
3
 
4
4
  interface BffLoginInput {
package/dist/bff.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonServerClient } from './authyonServerClient-DmNnjw4z.js';
1
+ import { H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonServerClient } from './authyonServerClient-1_1qNRDa.js';
2
2
  import 'jose';
3
3
 
4
4
  interface BffLoginInput {
package/dist/bff.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  DEFAULT_BASE_URL,
4
4
  JsonHttpClient,
5
5
  createSharedTransport
6
- } from "./chunk-TWUVXZOT.js";
6
+ } from "./chunk-TDJNBD3Z.js";
7
7
  import "./chunk-77J4NURK.js";
8
8
 
9
9
  // src/bff/contracts.ts
@@ -15,10 +15,18 @@ var ErrorCodes = {
15
15
  InvalidSecondFactorCode: "invalid_code",
16
16
  VerificationAttemptsExhausted: "verification_attempts_exhausted",
17
17
  MethodNotEnrolled: "method_not_enrolled",
18
- InvalidAuthorizationState: "invalid_authorization_state",
19
- TransactionMismatch: "transaction_mismatch",
20
- AuthorizationNotConsumable: "authorization_not_consumable",
21
- IdempotencyConflict: "idempotency_conflict"
18
+ InvalidApprovalState: "invalid_authorization_state",
19
+ PayloadMismatch: "payload_mismatch",
20
+ ApprovalNotConsumable: "authorization_not_consumable",
21
+ IdempotencyConflict: "idempotency_conflict",
22
+ UserDisabled: "user_disabled",
23
+ UserNotFound: "user_not_found",
24
+ TemporarilyUnavailable: "temporarily_unavailable",
25
+ InsufficientScope: "insufficient_scope",
26
+ CredentialThrottled: "credential_throttled",
27
+ ApprovalNotFound: "authorization_not_found",
28
+ SessionRevoked: "session_revoked",
29
+ TwoFactorTooManyFailures: "user.2fa.too_many_failures"
22
30
  };
23
31
  var STANDARD_ERROR_FIELDS = /* @__PURE__ */ new Set([
24
32
  "type",