@ic-reactor/core 3.3.0 → 3.4.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.
@@ -1,5 +1,5 @@
1
1
  import type { HttpAgent, HttpAgentOptions, Identity } from "@icp-sdk/core/agent"
2
- import type { AuthClient } from "@icp-sdk/auth/client"
2
+ import type { Principal } from "@icp-sdk/core/principal"
3
3
  import type { QueryClient } from "@tanstack/query-core"
4
4
 
5
5
  /**
@@ -11,6 +11,86 @@ import type { QueryClient } from "@tanstack/query-core"
11
11
  * @property {boolean} [withLocalEnv] - If true, configures the agent for a local environment.
12
12
  * @property {boolean} [withProcessEnv] - If true, auto-configures the agent based on process.env settings.
13
13
  */
14
+ export interface SignedIdentityAttributes {
15
+ data: Uint8Array
16
+ signature: Uint8Array
17
+ }
18
+
19
+ export interface IdentityAttributeRequest {
20
+ keys: string[]
21
+ nonce: Uint8Array
22
+ }
23
+
24
+ export interface IdentityAttributeValues {
25
+ email?: string
26
+ name?: string
27
+ verified_email?: string
28
+ [key: string]: string | undefined
29
+ }
30
+
31
+ export interface IdentityAttributeResult {
32
+ principal: string
33
+ requestedKeys: string[]
34
+ signedAttributes: SignedIdentityAttributes
35
+ decodedAttributes: IdentityAttributeValues
36
+ completedAt: string
37
+ }
38
+
39
+ type IdentityAttributeOpenIdProviderAlias = "google" | "apple" | "microsoft"
40
+
41
+ export type IdentityAttributeOpenIdProvider =
42
+ | IdentityAttributeOpenIdProviderAlias
43
+ | (string & {})
44
+
45
+ export interface ClientManagerAuthClientOptions {
46
+ identityProvider?: string | URL
47
+ windowOpenerFeatures?: string
48
+ openIdProvider?: IdentityAttributeOpenIdProvider
49
+ }
50
+
51
+ export interface AuthClientSignInOptions {
52
+ maxTimeToLive?: bigint
53
+ targets?: Principal[]
54
+ }
55
+
56
+ export interface ClientManagerSignInOptions
57
+ extends AuthClientSignInOptions, ClientManagerAuthClientOptions {
58
+ onSuccess?: () => void | Promise<void>
59
+ onError?: (error?: string) => void | Promise<void>
60
+ }
61
+
62
+ export interface RequestIdentityAttributesParameters {
63
+ keys: string[]
64
+ nonce: Uint8Array
65
+ identityProvider?: string | URL
66
+ openIdProvider?: IdentityAttributeOpenIdProvider
67
+ windowOpenerFeatures?: string
68
+ signIn?: boolean
69
+ maxTimeToLive?: bigint
70
+ targets?: Principal[]
71
+ }
72
+
73
+ export interface RequestOpenIdIdentityAttributesParameters {
74
+ nonce: Uint8Array
75
+ openIdProvider: IdentityAttributeOpenIdProvider
76
+ keys: string[]
77
+ identityProvider?: string | URL
78
+ windowOpenerFeatures?: string
79
+ signIn?: boolean
80
+ maxTimeToLive?: bigint
81
+ targets?: Principal[]
82
+ }
83
+
84
+ export interface AuthClientLike {
85
+ getIdentity(): Promise<Identity> | Identity
86
+ isAuthenticated(): Promise<boolean> | boolean
87
+ signIn(options?: AuthClientSignInOptions): Promise<Identity>
88
+ logout(options?: { returnTo?: string }): Promise<void>
89
+ requestAttributes(
90
+ params: IdentityAttributeRequest
91
+ ): Promise<SignedIdentityAttributes>
92
+ }
93
+
14
94
  export interface ClientManagerParameters {
15
95
  /**
16
96
  * The TanStack QueryClient used for caching and state management.
@@ -39,7 +119,7 @@ export interface ClientManagerParameters {
39
119
  * This is useful for environments where dynamic imports are not supported or
40
120
  * when you want to share an AuthClient instance across multiple managers.
41
121
  */
42
- authClient?: AuthClient
122
+ authClient?: AuthClientLike
43
123
  /**
44
124
  * **EXPERIMENTAL** - If true, uses the canister environment from `@icp-sdk/core/agent/canister-env`
45
125
  * to automatically configure the agent host and root key based on the `ic_env` cookie.