@accesly/react 0.7.0 → 1.0.0-pre.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/index.d.ts CHANGED
@@ -1,60 +1,7 @@
1
- import { Environment, CognitoConfig, AuthClient, SessionStorage, TokenManager, AccesslyEndpoints, DeviceStore, AuthStatus, TelemetrySink, CredentialRecord, ConfigureRecoveryRequest, RecoveryConfigResponse, RecoverySignRequest, RecoverySignResponse, RecoveryDeleteResponse } from '@accesly/core';
1
+ import { Environment, CognitoConfig, AuthClient, SessionStorage, DeviceStore, TelemetrySink, TokenManager, AccesslyEndpoints, AuthStatus, CredentialRecord } from '@accesly/core';
2
2
  import * as react from 'react';
3
3
  import { ReactNode } from 'react';
4
4
 
5
- /**
6
- * Structural type for the optional ZK email prover. Defined here (not
7
- * imported from `@accesly/zkemail`) so this package stays
8
- * runtime-independent of zkemail. Apps that wire recovery pass an
9
- * `@accesly/zkemail` `ZkEmailProver` instance — its public shape is a
10
- * superset of this.
11
- */
12
- interface ZkEmailProverHandle {
13
- prove(args: {
14
- readonly eml: string;
15
- readonly recovery: {
16
- readonly recipientEmail: string;
17
- readonly walletAddress: string;
18
- readonly newPasskeyPubkey: Uint8Array;
19
- readonly domainSalt: Uint8Array;
20
- };
21
- readonly rsaModulus: bigint;
22
- }): Promise<{
23
- readonly bundle: {
24
- readonly proof: {
25
- readonly a: Uint8Array;
26
- readonly b: Uint8Array;
27
- readonly c: Uint8Array;
28
- };
29
- readonly publicSignals: readonly Uint8Array[];
30
- };
31
- readonly elapsedMs: number;
32
- }>;
33
- }
34
- interface AcceslyContextValue {
35
- readonly appId: string;
36
- readonly env: Environment;
37
- readonly apiUrl: string;
38
- readonly cognitoConfig: CognitoConfig;
39
- readonly authClient: AuthClient;
40
- readonly sessionStorage: SessionStorage;
41
- readonly tokenManager: TokenManager;
42
- readonly endpoints: AccesslyEndpoints;
43
- readonly deviceStore: DeviceStore;
44
- /** Current auth status — re-rendered whenever it changes. */
45
- readonly status: AuthStatus;
46
- readonly username: string | null;
47
- /** Force a re-read of `tokenManager.getStatus()`. */
48
- readonly refreshStatus: () => Promise<void>;
49
- /**
50
- * Optional ZK email prover for SEP-30 recovery. When omitted,
51
- * `auth.recover()` throws `RecoveryNotAvailableError`. Apps that need
52
- * recovery wire it via `<AcceslyProvider zkEmailProver={...}>`.
53
- */
54
- readonly zkEmailProver?: ZkEmailProverHandle;
55
- }
56
- declare const AcceslyContext: react.Context<AcceslyContextValue | null>;
57
-
58
5
  /**
59
6
  * `AcceslyProvider` — top-level React provider that creates the SDK instances
60
7
  * once and exposes them through context. All hooks consume this.
@@ -84,15 +31,27 @@ interface AcceslyProviderProps {
84
31
  };
85
32
  /** Optional telemetry sink — surfaces every API request/response/retry. */
86
33
  readonly telemetry?: TelemetrySink;
87
- /**
88
- * Optional ZK email prover for SEP-30 recovery. Pass an instance from
89
- * `@accesly/zkemail` (`createZkEmailProver({ artifactsBaseUrl })`). When
90
- * omitted, `auth.recover()` throws `RecoveryNotAvailableError`.
91
- */
92
- readonly zkEmailProver?: ZkEmailProverHandle;
93
34
  }
94
35
  declare function AcceslyProvider(props: AcceslyProviderProps): JSX.Element;
95
36
 
37
+ interface AcceslyContextValue {
38
+ readonly appId: string;
39
+ readonly env: Environment;
40
+ readonly apiUrl: string;
41
+ readonly cognitoConfig: CognitoConfig;
42
+ readonly authClient: AuthClient;
43
+ readonly sessionStorage: SessionStorage;
44
+ readonly tokenManager: TokenManager;
45
+ readonly endpoints: AccesslyEndpoints;
46
+ readonly deviceStore: DeviceStore;
47
+ /** Current auth status — re-rendered whenever it changes. */
48
+ readonly status: AuthStatus;
49
+ readonly username: string | null;
50
+ /** Force a re-read of `tokenManager.getStatus()`. */
51
+ readonly refreshStatus: () => Promise<void>;
52
+ }
53
+ declare const AcceslyContext: react.Context<AcceslyContextValue | null>;
54
+
96
55
  /**
97
56
  * Per-environment defaults — currently the only public stage is `dev`. The
98
57
  * others are placeholders so the SDK API doesn't change when `staging`/`prod`
@@ -136,58 +95,6 @@ declare const ENVIRONMENT_DEFAULTS: Record<Environment, EnvironmentDefaults>;
136
95
  * `auth` don't bring `wallet` into their render.
137
96
  */
138
97
 
139
- /**
140
- * Structural type of `@accesly/zkemail`'s `ZkEmailProver`. Defined here so
141
- * `@accesly/react` does not take a hard runtime dep on `@accesly/zkemail`.
142
- * Consumers who use recovery wire in a real prover via `<AcceslyProvider>`.
143
- */
144
- interface ZkEmailProverLike {
145
- prove(args: {
146
- readonly eml: string;
147
- readonly recovery: {
148
- readonly recipientEmail: string;
149
- readonly walletAddress: string;
150
- readonly newPasskeyPubkey: Uint8Array;
151
- readonly domainSalt: Uint8Array;
152
- };
153
- readonly rsaModulus: bigint;
154
- }): Promise<{
155
- readonly bundle: {
156
- readonly proof: {
157
- readonly a: Uint8Array;
158
- readonly b: Uint8Array;
159
- readonly c: Uint8Array;
160
- };
161
- readonly publicSignals: readonly Uint8Array[];
162
- };
163
- readonly elapsedMs: number;
164
- }>;
165
- }
166
- /** Input to `auth.recover()` once a `ZkEmailProver` is configured. */
167
- interface RecoverInput {
168
- /** Raw .eml as downloaded by the user from Gmail's "Show original". */
169
- readonly eml: string;
170
- /** Lowercase, trimmed recipient address that received the DKIM-signed message. */
171
- readonly recipientEmail: string;
172
- /** Wallet address being recovered (G... strkey). */
173
- readonly walletAddress: string;
174
- /** New passkey public key (secp256r1, 64 bytes) that will replace the lost one. */
175
- readonly newPasskeyPubkey: Uint8Array;
176
- /** Domain salt from the deployed Smart Account, per D1.4. 32 bytes. */
177
- readonly domainSalt: Uint8Array;
178
- /** RSA-2048 modulus of the DKIM key that signed the .eml. */
179
- readonly rsaModulus: bigint;
180
- }
181
- /** Output of a successful recovery proof build. The backend Lambda (Phase 6) submits this. */
182
- interface RecoverResult {
183
- readonly proof: {
184
- readonly a: Uint8Array;
185
- readonly b: Uint8Array;
186
- readonly c: Uint8Array;
187
- };
188
- readonly publicSignals: readonly Uint8Array[];
189
- readonly elapsedMs: number;
190
- }
191
98
  interface AuthNamespace {
192
99
  readonly status: AuthStatus;
193
100
  readonly username: string | null;
@@ -199,24 +106,6 @@ interface AuthNamespace {
199
106
  resendConfirmation(email: string): Promise<void>;
200
107
  signIn(email: string, password: string): Promise<void>;
201
108
  signOut(): Promise<void>;
202
- /**
203
- * SEP-30 account recovery via ZK email proof. Generates a Groth16 proof
204
- * client-side that the deployed Soroban verifier accepts. Throws
205
- * `RecoveryNotAvailableError` if no `zkEmailProver` was configured on
206
- * the `<AcceslyProvider>`.
207
- *
208
- * The returned `RecoverResult` is ready for the Phase 6 `sep30Handler`
209
- * Lambda, which submits the rotation tx to Soroban on the user's behalf.
210
- */
211
- recover(input: RecoverInput): Promise<RecoverResult>;
212
- }
213
- /**
214
- * Thrown by `auth.recover()` when the app did not configure a `zkEmailProver`
215
- * on the `<AcceslyProvider>`. To enable recovery, install `@accesly/zkemail`
216
- * and pass `<AcceslyProvider zkEmailProver={prover}>`.
217
- */
218
- declare class RecoveryNotAvailableError extends Error {
219
- constructor();
220
109
  }
221
110
  interface CreateWalletInput {
222
111
  readonly email: string;
@@ -520,35 +409,11 @@ interface YieldNamespace {
520
409
  declare class NotImplementedYetError extends Error {
521
410
  constructor(namespace: string, method: string);
522
411
  }
523
- /**
524
- * Backend-side SEP-30 recovery namespace. Wraps the public `/sep30/accounts/*`
525
- * endpoints exposed by the Phase 6 `sep30Handler` Lambda. These are SEP-30
526
- * standard — interoperable with Freighter/Lobstr/etc. — and stateful from the
527
- * backend's perspective (persists identities + signers in DynamoDB).
528
- *
529
- * The cryptographic proof generation that authorizes the actual rotation
530
- * lives in `auth.recover()` (when a `ZkEmailProver` is wired).
531
- */
532
- interface RecoveryNamespace {
533
- /** Persist or replace the recovery config for `walletAddress`. */
534
- configure(walletAddress: string, input: ConfigureRecoveryRequest): Promise<RecoveryConfigResponse>;
535
- /** Read the current recovery config, or `null` if none is registered. */
536
- get(walletAddress: string): Promise<RecoveryConfigResponse | null>;
537
- /**
538
- * Ask the backend to authorize a recovery transaction. In `mock` mode it
539
- * authorizes when the identity matches a registered one. In `real` mode it
540
- * polls the on-chain `zk-email-verifier` event before authorizing.
541
- */
542
- requestSignature(walletAddress: string, signingAddress: string, input: RecoverySignRequest): Promise<RecoverySignResponse>;
543
- /** Remove the recovery config. Returns `null` if it did not exist. */
544
- remove(walletAddress: string): Promise<RecoveryDeleteResponse | null>;
545
- }
546
412
  interface AcceslyHook {
547
413
  readonly auth: AuthNamespace;
548
414
  readonly wallet: WalletNamespace;
549
415
  readonly tx: TxNamespace;
550
416
  readonly kyc: KycNamespace;
551
- readonly recovery: RecoveryNamespace;
552
417
  readonly session: SessionNamespace;
553
418
  readonly settings: SettingsNamespace;
554
419
  readonly yieldOps: YieldNamespace;
@@ -581,4 +446,4 @@ declare function useAccesly(): AcceslyHook;
581
446
  */
582
447
  declare const REACT_ADAPTER_VERSION = "0.0.0";
583
448
 
584
- export { AcceslyContext, type AcceslyContextValue, type AcceslyHook, AcceslyProvider, type AcceslyProviderProps, type AuthNamespace, type CreateWalletInput, type CreatedWalletInfo, ENVIRONMENT_DEFAULTS, type EnsureWalletResult, type EnvironmentDefaults, type KycNamespace, NotImplementedYetError, REACT_ADAPTER_VERSION, type RecoverInput, type RecoverResult, type RecoveryNamespace, RecoveryNotAvailableError, type RemoteWalletInfo, type RetryDeployResult, type SendXlmInput, type SendXlmResult, type SessionNamespace, type SettingsNamespace, type TxNamespace, type WalletNamespace, type WalletStatus, type YieldNamespace, type ZkEmailProverHandle, type ZkEmailProverLike, useAccesly };
449
+ export { AcceslyContext, type AcceslyContextValue, type AcceslyHook, AcceslyProvider, type AcceslyProviderProps, type AuthNamespace, type CreateWalletInput, type CreatedWalletInfo, ENVIRONMENT_DEFAULTS, type EnsureWalletResult, type EnvironmentDefaults, type KycNamespace, NotImplementedYetError, REACT_ADAPTER_VERSION, type RemoteWalletInfo, type RetryDeployResult, type SendXlmInput, type SendXlmResult, type SessionNamespace, type SettingsNamespace, type TxNamespace, type WalletNamespace, type WalletStatus, type YieldNamespace, useAccesly };
package/dist/index.js CHANGED
@@ -114,20 +114,9 @@ function AcceslyProvider(props) {
114
114
  deviceStore: instances.deviceStore,
115
115
  status,
116
116
  username,
117
- refreshStatus,
118
- ...props.zkEmailProver ? { zkEmailProver: props.zkEmailProver } : {}
117
+ refreshStatus
119
118
  }),
120
- [
121
- props.appId,
122
- props.env,
123
- apiUrl,
124
- cognitoConfig,
125
- instances,
126
- status,
127
- username,
128
- refreshStatus,
129
- props.zkEmailProver
130
- ]
119
+ [props.appId, props.env, apiUrl, cognitoConfig, instances, status, username, refreshStatus]
131
120
  );
132
121
  return /* @__PURE__ */ jsx(AcceslyContext.Provider, { value, children: props.children });
133
122
  }
@@ -149,14 +138,6 @@ function isSorobanDeployPendingError(err) {
149
138
  }
150
139
 
151
140
  // src/hooks/useAccesly.ts
152
- var RecoveryNotAvailableError = class extends Error {
153
- constructor() {
154
- super(
155
- "recover() is not available because no zkEmailProver was configured. Install @accesly/zkemail and pass an instance to <AcceslyProvider zkEmailProver={...}>."
156
- );
157
- this.name = "RecoveryNotAvailableError";
158
- }
159
- };
160
141
  var NotImplementedYetError = class extends Error {
161
142
  constructor(namespace, method) {
162
143
  super(
@@ -193,26 +174,6 @@ function useAccesly() {
193
174
  async signOut() {
194
175
  await ctx.tokenManager.signOut();
195
176
  await ctx.refreshStatus();
196
- },
197
- async recover(input) {
198
- if (!ctx.zkEmailProver) {
199
- throw new RecoveryNotAvailableError();
200
- }
201
- const { bundle, elapsedMs } = await ctx.zkEmailProver.prove({
202
- eml: input.eml,
203
- rsaModulus: input.rsaModulus,
204
- recovery: {
205
- recipientEmail: input.recipientEmail,
206
- walletAddress: input.walletAddress,
207
- newPasskeyPubkey: input.newPasskeyPubkey,
208
- domainSalt: input.domainSalt
209
- }
210
- });
211
- return {
212
- proof: bundle.proof,
213
- publicSignals: bundle.publicSignals,
214
- elapsedMs
215
- };
216
177
  }
217
178
  }),
218
179
  [ctx]
@@ -542,23 +503,6 @@ function useAccesly() {
542
503
  }),
543
504
  [ctx]
544
505
  );
545
- const recovery = useMemo(
546
- () => ({
547
- configure(walletAddress, input) {
548
- return ctx.endpoints.configureRecovery(walletAddress, input);
549
- },
550
- get(walletAddress) {
551
- return ctx.endpoints.getRecoveryConfig(walletAddress);
552
- },
553
- requestSignature(walletAddress, signingAddress, input) {
554
- return ctx.endpoints.requestRecoverySignature(walletAddress, signingAddress, input);
555
- },
556
- remove(walletAddress) {
557
- return ctx.endpoints.deleteRecoveryConfig(walletAddress);
558
- }
559
- }),
560
- [ctx]
561
- );
562
506
  const session = useMemo(
563
507
  () => ({
564
508
  async create() {
@@ -601,7 +545,7 @@ function useAccesly() {
601
545
  }),
602
546
  []
603
547
  );
604
- return { auth, wallet, tx, kyc, recovery, session, settings, yieldOps, _internal: ctx };
548
+ return { auth, wallet, tx, kyc, session, settings, yieldOps, _internal: ctx };
605
549
  }
606
550
  function coderHelpers() {
607
551
  function hexFromBytes(bytes) {
@@ -646,6 +590,6 @@ function base64ToBytes(s) {
646
590
  // src/index.ts
647
591
  var REACT_ADAPTER_VERSION = "0.0.0";
648
592
 
649
- export { AcceslyContext, AcceslyProvider, ENVIRONMENT_DEFAULTS, NotImplementedYetError, REACT_ADAPTER_VERSION, RecoveryNotAvailableError, useAccesly };
593
+ export { AcceslyContext, AcceslyProvider, ENVIRONMENT_DEFAULTS, NotImplementedYetError, REACT_ADAPTER_VERSION, useAccesly };
650
594
  //# sourceMappingURL=index.js.map
651
595
  //# sourceMappingURL=index.js.map