@ic-reactor/core 3.3.1 → 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.
- package/README.md +60 -0
- package/dist/client.d.ts +14 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +209 -54
- package/dist/client.js.map +1 -1
- package/dist/identity-attributes.d.ts +14 -0
- package/dist/identity-attributes.d.ts.map +1 -0
- package/dist/identity-attributes.js +138 -0
- package/dist/identity-attributes.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/client.d.ts +68 -2
- package/dist/types/client.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/client.ts +283 -59
- package/src/identity-attributes.ts +220 -0
- package/src/index.ts +1 -0
- package/src/types/client.ts +82 -2
package/src/types/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpAgent, HttpAgentOptions, Identity } from "@icp-sdk/core/agent"
|
|
2
|
-
import type {
|
|
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?:
|
|
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.
|