@matanetwork/sovereign-id-react 0.1.0 → 0.1.1
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/LICENSE +21 -21
- package/README.md +1 -1
- package/package.json +8 -5
- package/src/index.d.ts +225 -225
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 MATA Network
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MATA Network
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -226,7 +226,7 @@ const verified = await verifyResponse(req.body.jwt, {
|
|
|
226
226
|
```
|
|
227
227
|
|
|
228
228
|
See the
|
|
229
|
-
[main docs](https://github.com/
|
|
229
|
+
[main docs](https://github.com/Remade-With-Rust/sovereign-id/tree/main/docs/sovereign-id)
|
|
230
230
|
for the integration guide, error-handling matrix, and protocol spec.
|
|
231
231
|
|
|
232
232
|
## What you don't have to think about
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matanetwork/sovereign-id-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React adapter for @matanetwork/sovereign-id — drop-in <SignInButton/>, useSignIn() hook, useResumePendingSignIn() boot helper. Lowers Sovereign ID RP integration from ~20 LOC to one import.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=18"
|
|
41
41
|
},
|
|
42
|
-
"homepage": "https://github.com/
|
|
42
|
+
"homepage": "https://github.com/Remade-With-Rust/sovereign-id/tree/main/packages/sovereign-id-react#readme",
|
|
43
43
|
"bugs": {
|
|
44
|
-
"url": "https://github.com/
|
|
44
|
+
"url": "https://github.com/Remade-With-Rust/sovereign-id/issues"
|
|
45
45
|
},
|
|
46
46
|
"repository": {
|
|
47
47
|
"type": "git",
|
|
48
|
-
"url": "git+https://github.com/
|
|
49
|
-
"directory": "packages/
|
|
48
|
+
"url": "git+https://github.com/Remade-With-Rust/sovereign-id.git",
|
|
49
|
+
"directory": "packages/sovereign-id-react"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@matanetwork/sovereign-id": "^0.1.0",
|
|
@@ -63,5 +63,8 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@matanetwork/sovereign-id": "^0.1.0",
|
|
65
65
|
"react": "^18.3.1"
|
|
66
|
+
},
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public"
|
|
66
69
|
}
|
|
67
70
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,225 +1,225 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type declarations for @matanetwork/sovereign-id-react.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors the JS runtime exactly. The runtime is pure JS (no build
|
|
5
|
-
* step); this `.d.ts` exists so consumers using TypeScript get full
|
|
6
|
-
* type-checking + IDE intellisense.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { CSSProperties, ReactNode, ButtonHTMLAttributes } from 'react';
|
|
10
|
-
import type {
|
|
11
|
-
SignInError,
|
|
12
|
-
SignInRequest,
|
|
13
|
-
SignInSuccess,
|
|
14
|
-
ErrorCode,
|
|
15
|
-
} from '@matanetwork/sovereign-id';
|
|
16
|
-
|
|
17
|
-
// ─── Hook: useSignIn ───────────────────────────────────────────────────────
|
|
18
|
-
|
|
19
|
-
export interface UseSignInOptions {
|
|
20
|
-
/**
|
|
21
|
-
* Default `rpOrigin` used by `signIn()`. If omitted, falls back to
|
|
22
|
-
* `window.location.origin`. RPs running SSR should set this
|
|
23
|
-
* explicitly.
|
|
24
|
-
*/
|
|
25
|
-
rpOrigin?: string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Async function that returns a fresh single-use nonce. Called
|
|
29
|
-
* once per `signIn()` invocation; the resolved string is passed
|
|
30
|
-
* through to the SDK. If omitted, `signIn()` must be called with
|
|
31
|
-
* a `nonce` override directly.
|
|
32
|
-
*/
|
|
33
|
-
getNonce?: () => Promise<string>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Default `claims` payload, merged with the per-call override.
|
|
37
|
-
* Almost always `{ required: ['did'], optional: [...] }`.
|
|
38
|
-
*/
|
|
39
|
-
defaultClaims?: SignInRequest['claims'];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Forwarded to the SDK. When `false`, throws
|
|
43
|
-
* `ERR_NO_WALLET_INSTALLED` raw instead of showing the install
|
|
44
|
-
* upsell. Default: SDK default (`true`).
|
|
45
|
-
*/
|
|
46
|
-
installUpsell?: boolean;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Forwarded to the SDK. Referral code attributed to signups that
|
|
50
|
-
* flow through the install upsell. Defaults to the hostname of
|
|
51
|
-
* `rpOrigin`. Pass `null` to opt out.
|
|
52
|
-
*/
|
|
53
|
-
ref?: string | null;
|
|
54
|
-
|
|
55
|
-
/** Forwarded to the SDK. */
|
|
56
|
-
timeoutMs?: number;
|
|
57
|
-
|
|
58
|
-
/** Forwarded to the SDK. */
|
|
59
|
-
nativeAppCallback?: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type SignInStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
63
|
-
|
|
64
|
-
export interface SignInOverrides {
|
|
65
|
-
rpOrigin?: string;
|
|
66
|
-
nonce?: string;
|
|
67
|
-
claims?: SignInRequest['claims'];
|
|
68
|
-
installUpsell?: boolean;
|
|
69
|
-
ref?: string | null;
|
|
70
|
-
timeoutMs?: number;
|
|
71
|
-
nativeAppCallback?: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface UseSignInReturn {
|
|
75
|
-
/**
|
|
76
|
-
* Fires a sign-in. Merges `overrides` over the hook-level
|
|
77
|
-
* options. Resolves to the result on success, `null` if the call
|
|
78
|
-
* was superseded by a newer signIn, or rejects with `SignInError`
|
|
79
|
-
* on failure.
|
|
80
|
-
*/
|
|
81
|
-
signIn(overrides?: SignInOverrides): Promise<SignInSuccess | null>;
|
|
82
|
-
/** Drops result/error and returns to idle. */
|
|
83
|
-
reset(): void;
|
|
84
|
-
status: SignInStatus;
|
|
85
|
-
/** True iff `status === 'pending'`. */
|
|
86
|
-
isLoading: boolean;
|
|
87
|
-
result: SignInSuccess | null;
|
|
88
|
-
error: SignInError | null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function useSignIn(options?: UseSignInOptions): UseSignInReturn;
|
|
92
|
-
|
|
93
|
-
// ─── Hook: useResumePendingSignIn ──────────────────────────────────────────
|
|
94
|
-
|
|
95
|
-
export interface UseResumeOptions {
|
|
96
|
-
/**
|
|
97
|
-
* Called when a pending sign-in resumes and completes. RPs hand
|
|
98
|
-
* the JWT to their backend here.
|
|
99
|
-
*/
|
|
100
|
-
onSuccess?: (result: SignInSuccess) => void;
|
|
101
|
-
/**
|
|
102
|
-
* Called when a pending sign-in was found but its resume threw.
|
|
103
|
-
* `err.code` is the same set the regular signIn() throws.
|
|
104
|
-
*/
|
|
105
|
-
onError?: (err: SignInError) => void;
|
|
106
|
-
/**
|
|
107
|
-
* Called when there's no pending resume — most boots. Lets RPs
|
|
108
|
-
* record analytics on "did we hit the resume path on this boot"
|
|
109
|
-
* without watching the `noResume` flag.
|
|
110
|
-
*/
|
|
111
|
-
onNothingPending?: () => void;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface UseResumeReturn {
|
|
115
|
-
status: SignInStatus;
|
|
116
|
-
result: SignInSuccess | null;
|
|
117
|
-
error: SignInError | null;
|
|
118
|
-
/**
|
|
119
|
-
* `true` once we've finished checking and confirmed no pending
|
|
120
|
-
* sign-in was waiting. Useful for RPs that want to delay
|
|
121
|
-
* rendering their logged-out UI until the resume check is done.
|
|
122
|
-
*/
|
|
123
|
-
noResume: boolean;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function useResumePendingSignIn(options?: UseResumeOptions): UseResumeReturn;
|
|
127
|
-
|
|
128
|
-
// ─── Component: SignInButton ───────────────────────────────────────────────
|
|
129
|
-
|
|
130
|
-
export interface SignInButtonProps {
|
|
131
|
-
/** Defaults to `window.location.origin`. */
|
|
132
|
-
rpOrigin?: string;
|
|
133
|
-
/** Async fn returning a fresh single-use nonce from your backend. */
|
|
134
|
-
getNonce: () => Promise<string>;
|
|
135
|
-
/** Claim catalog. `{ required: [...], optional?: [...] }`. */
|
|
136
|
-
claims: SignInRequest['claims'];
|
|
137
|
-
/** Called with the resulting JWT. */
|
|
138
|
-
onSuccess: (result: SignInSuccess) => void;
|
|
139
|
-
/**
|
|
140
|
-
* Called when the user explicitly chose not to sign in
|
|
141
|
-
* (`user_denied` from the consent screen, `upsell_canceled` from
|
|
142
|
-
* the install upsell modal).
|
|
143
|
-
*/
|
|
144
|
-
onCancel?: (code: 'user_denied' | 'upsell_canceled') => void;
|
|
145
|
-
/**
|
|
146
|
-
* Called for any other failure path (timeout, wallet_unavailable,
|
|
147
|
-
* etc.). If omitted, errors are silently swallowed — RPs should
|
|
148
|
-
* usually pass at least a logger here.
|
|
149
|
-
*/
|
|
150
|
-
onError?: (err: SignInError) => void;
|
|
151
|
-
/** SDK option pass-through. */
|
|
152
|
-
installUpsell?: boolean;
|
|
153
|
-
/** SDK referral code; defaults to the hostname of `rpOrigin`. */
|
|
154
|
-
ref?: string | null;
|
|
155
|
-
/** SDK option pass-through. */
|
|
156
|
-
timeoutMs?: number;
|
|
157
|
-
/** SDK option pass-through. */
|
|
158
|
-
nativeAppCallback?: string;
|
|
159
|
-
/** Button label. Defaults to `"Sign in with Sovereign ID"`. */
|
|
160
|
-
children?: ReactNode;
|
|
161
|
-
/**
|
|
162
|
-
* When set, the default inline styles are NOT applied; the RP has
|
|
163
|
-
* full control via CSS.
|
|
164
|
-
*/
|
|
165
|
-
className?: string;
|
|
166
|
-
/**
|
|
167
|
-
* Merged with the default inline styles when `className` is not
|
|
168
|
-
* provided.
|
|
169
|
-
*/
|
|
170
|
-
style?: CSSProperties;
|
|
171
|
-
/**
|
|
172
|
-
* Explicitly disable the button. The button is also disabled
|
|
173
|
-
* internally while a sign-in is in flight.
|
|
174
|
-
*/
|
|
175
|
-
disabled?: boolean;
|
|
176
|
-
/** Spread onto the underlying `<button>`. */
|
|
177
|
-
buttonProps?: Omit<
|
|
178
|
-
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
179
|
-
'onClick' | 'disabled' | 'type' | 'style' | 'className' | 'children'
|
|
180
|
-
>;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export function SignInButton(props: SignInButtonProps): JSX.Element;
|
|
184
|
-
|
|
185
|
-
// ─── Re-exports from @matanetwork/sovereign-id ────────────────────────────
|
|
186
|
-
|
|
187
|
-
export {
|
|
188
|
-
SignInError,
|
|
189
|
-
hasExtension,
|
|
190
|
-
showInstallUpsell,
|
|
191
|
-
pickInstallCta,
|
|
192
|
-
defaultRefFromOrigin,
|
|
193
|
-
clearPendingSignIn,
|
|
194
|
-
resumePendingSignIn,
|
|
195
|
-
signIn,
|
|
196
|
-
PROTOCOL_VERSION,
|
|
197
|
-
WINDOW_MID_GLOBAL,
|
|
198
|
-
MESSAGE_DISCRIMINATOR,
|
|
199
|
-
KIND_SIGN_IN_REQUEST,
|
|
200
|
-
KIND_SIGN_IN_RESPONSE,
|
|
201
|
-
URL_SCHEME,
|
|
202
|
-
SCHEME_PATH_REQUEST,
|
|
203
|
-
QUERY_PARAM_PAYLOAD,
|
|
204
|
-
FRAGMENT_KEY_RESPONSE,
|
|
205
|
-
ERR_USER_DENIED,
|
|
206
|
-
ERR_ORIGIN_MISMATCH,
|
|
207
|
-
ERR_INVALID_REQUEST,
|
|
208
|
-
ERR_WALLET_UNAVAILABLE,
|
|
209
|
-
ERR_REQUIRED_CLAIM_UNAVAILABLE,
|
|
210
|
-
ERR_INTERNAL,
|
|
211
|
-
ERR_NO_WALLET_INSTALLED,
|
|
212
|
-
ERR_TIMEOUT,
|
|
213
|
-
ERR_UPSELL_CANCELED,
|
|
214
|
-
} from '@matanetwork/sovereign-id';
|
|
215
|
-
|
|
216
|
-
export type {
|
|
217
|
-
SignInRequest,
|
|
218
|
-
SignInSuccess,
|
|
219
|
-
ErrorCode,
|
|
220
|
-
CustomClaim,
|
|
221
|
-
InstallCta,
|
|
222
|
-
InstallUpsellOptions,
|
|
223
|
-
InstallUpsellResult,
|
|
224
|
-
SignInOptions,
|
|
225
|
-
} from '@matanetwork/sovereign-id';
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for @matanetwork/sovereign-id-react.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the JS runtime exactly. The runtime is pure JS (no build
|
|
5
|
+
* step); this `.d.ts` exists so consumers using TypeScript get full
|
|
6
|
+
* type-checking + IDE intellisense.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { CSSProperties, ReactNode, ButtonHTMLAttributes } from 'react';
|
|
10
|
+
import type {
|
|
11
|
+
SignInError,
|
|
12
|
+
SignInRequest,
|
|
13
|
+
SignInSuccess,
|
|
14
|
+
ErrorCode,
|
|
15
|
+
} from '@matanetwork/sovereign-id';
|
|
16
|
+
|
|
17
|
+
// ─── Hook: useSignIn ───────────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
export interface UseSignInOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Default `rpOrigin` used by `signIn()`. If omitted, falls back to
|
|
22
|
+
* `window.location.origin`. RPs running SSR should set this
|
|
23
|
+
* explicitly.
|
|
24
|
+
*/
|
|
25
|
+
rpOrigin?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Async function that returns a fresh single-use nonce. Called
|
|
29
|
+
* once per `signIn()` invocation; the resolved string is passed
|
|
30
|
+
* through to the SDK. If omitted, `signIn()` must be called with
|
|
31
|
+
* a `nonce` override directly.
|
|
32
|
+
*/
|
|
33
|
+
getNonce?: () => Promise<string>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Default `claims` payload, merged with the per-call override.
|
|
37
|
+
* Almost always `{ required: ['did'], optional: [...] }`.
|
|
38
|
+
*/
|
|
39
|
+
defaultClaims?: SignInRequest['claims'];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Forwarded to the SDK. When `false`, throws
|
|
43
|
+
* `ERR_NO_WALLET_INSTALLED` raw instead of showing the install
|
|
44
|
+
* upsell. Default: SDK default (`true`).
|
|
45
|
+
*/
|
|
46
|
+
installUpsell?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Forwarded to the SDK. Referral code attributed to signups that
|
|
50
|
+
* flow through the install upsell. Defaults to the hostname of
|
|
51
|
+
* `rpOrigin`. Pass `null` to opt out.
|
|
52
|
+
*/
|
|
53
|
+
ref?: string | null;
|
|
54
|
+
|
|
55
|
+
/** Forwarded to the SDK. */
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
|
|
58
|
+
/** Forwarded to the SDK. */
|
|
59
|
+
nativeAppCallback?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type SignInStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
63
|
+
|
|
64
|
+
export interface SignInOverrides {
|
|
65
|
+
rpOrigin?: string;
|
|
66
|
+
nonce?: string;
|
|
67
|
+
claims?: SignInRequest['claims'];
|
|
68
|
+
installUpsell?: boolean;
|
|
69
|
+
ref?: string | null;
|
|
70
|
+
timeoutMs?: number;
|
|
71
|
+
nativeAppCallback?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface UseSignInReturn {
|
|
75
|
+
/**
|
|
76
|
+
* Fires a sign-in. Merges `overrides` over the hook-level
|
|
77
|
+
* options. Resolves to the result on success, `null` if the call
|
|
78
|
+
* was superseded by a newer signIn, or rejects with `SignInError`
|
|
79
|
+
* on failure.
|
|
80
|
+
*/
|
|
81
|
+
signIn(overrides?: SignInOverrides): Promise<SignInSuccess | null>;
|
|
82
|
+
/** Drops result/error and returns to idle. */
|
|
83
|
+
reset(): void;
|
|
84
|
+
status: SignInStatus;
|
|
85
|
+
/** True iff `status === 'pending'`. */
|
|
86
|
+
isLoading: boolean;
|
|
87
|
+
result: SignInSuccess | null;
|
|
88
|
+
error: SignInError | null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function useSignIn(options?: UseSignInOptions): UseSignInReturn;
|
|
92
|
+
|
|
93
|
+
// ─── Hook: useResumePendingSignIn ──────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
export interface UseResumeOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Called when a pending sign-in resumes and completes. RPs hand
|
|
98
|
+
* the JWT to their backend here.
|
|
99
|
+
*/
|
|
100
|
+
onSuccess?: (result: SignInSuccess) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Called when a pending sign-in was found but its resume threw.
|
|
103
|
+
* `err.code` is the same set the regular signIn() throws.
|
|
104
|
+
*/
|
|
105
|
+
onError?: (err: SignInError) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Called when there's no pending resume — most boots. Lets RPs
|
|
108
|
+
* record analytics on "did we hit the resume path on this boot"
|
|
109
|
+
* without watching the `noResume` flag.
|
|
110
|
+
*/
|
|
111
|
+
onNothingPending?: () => void;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface UseResumeReturn {
|
|
115
|
+
status: SignInStatus;
|
|
116
|
+
result: SignInSuccess | null;
|
|
117
|
+
error: SignInError | null;
|
|
118
|
+
/**
|
|
119
|
+
* `true` once we've finished checking and confirmed no pending
|
|
120
|
+
* sign-in was waiting. Useful for RPs that want to delay
|
|
121
|
+
* rendering their logged-out UI until the resume check is done.
|
|
122
|
+
*/
|
|
123
|
+
noResume: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function useResumePendingSignIn(options?: UseResumeOptions): UseResumeReturn;
|
|
127
|
+
|
|
128
|
+
// ─── Component: SignInButton ───────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
export interface SignInButtonProps {
|
|
131
|
+
/** Defaults to `window.location.origin`. */
|
|
132
|
+
rpOrigin?: string;
|
|
133
|
+
/** Async fn returning a fresh single-use nonce from your backend. */
|
|
134
|
+
getNonce: () => Promise<string>;
|
|
135
|
+
/** Claim catalog. `{ required: [...], optional?: [...] }`. */
|
|
136
|
+
claims: SignInRequest['claims'];
|
|
137
|
+
/** Called with the resulting JWT. */
|
|
138
|
+
onSuccess: (result: SignInSuccess) => void;
|
|
139
|
+
/**
|
|
140
|
+
* Called when the user explicitly chose not to sign in
|
|
141
|
+
* (`user_denied` from the consent screen, `upsell_canceled` from
|
|
142
|
+
* the install upsell modal).
|
|
143
|
+
*/
|
|
144
|
+
onCancel?: (code: 'user_denied' | 'upsell_canceled') => void;
|
|
145
|
+
/**
|
|
146
|
+
* Called for any other failure path (timeout, wallet_unavailable,
|
|
147
|
+
* etc.). If omitted, errors are silently swallowed — RPs should
|
|
148
|
+
* usually pass at least a logger here.
|
|
149
|
+
*/
|
|
150
|
+
onError?: (err: SignInError) => void;
|
|
151
|
+
/** SDK option pass-through. */
|
|
152
|
+
installUpsell?: boolean;
|
|
153
|
+
/** SDK referral code; defaults to the hostname of `rpOrigin`. */
|
|
154
|
+
ref?: string | null;
|
|
155
|
+
/** SDK option pass-through. */
|
|
156
|
+
timeoutMs?: number;
|
|
157
|
+
/** SDK option pass-through. */
|
|
158
|
+
nativeAppCallback?: string;
|
|
159
|
+
/** Button label. Defaults to `"Sign in with Sovereign ID"`. */
|
|
160
|
+
children?: ReactNode;
|
|
161
|
+
/**
|
|
162
|
+
* When set, the default inline styles are NOT applied; the RP has
|
|
163
|
+
* full control via CSS.
|
|
164
|
+
*/
|
|
165
|
+
className?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Merged with the default inline styles when `className` is not
|
|
168
|
+
* provided.
|
|
169
|
+
*/
|
|
170
|
+
style?: CSSProperties;
|
|
171
|
+
/**
|
|
172
|
+
* Explicitly disable the button. The button is also disabled
|
|
173
|
+
* internally while a sign-in is in flight.
|
|
174
|
+
*/
|
|
175
|
+
disabled?: boolean;
|
|
176
|
+
/** Spread onto the underlying `<button>`. */
|
|
177
|
+
buttonProps?: Omit<
|
|
178
|
+
ButtonHTMLAttributes<HTMLButtonElement>,
|
|
179
|
+
'onClick' | 'disabled' | 'type' | 'style' | 'className' | 'children'
|
|
180
|
+
>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function SignInButton(props: SignInButtonProps): JSX.Element;
|
|
184
|
+
|
|
185
|
+
// ─── Re-exports from @matanetwork/sovereign-id ────────────────────────────
|
|
186
|
+
|
|
187
|
+
export {
|
|
188
|
+
SignInError,
|
|
189
|
+
hasExtension,
|
|
190
|
+
showInstallUpsell,
|
|
191
|
+
pickInstallCta,
|
|
192
|
+
defaultRefFromOrigin,
|
|
193
|
+
clearPendingSignIn,
|
|
194
|
+
resumePendingSignIn,
|
|
195
|
+
signIn,
|
|
196
|
+
PROTOCOL_VERSION,
|
|
197
|
+
WINDOW_MID_GLOBAL,
|
|
198
|
+
MESSAGE_DISCRIMINATOR,
|
|
199
|
+
KIND_SIGN_IN_REQUEST,
|
|
200
|
+
KIND_SIGN_IN_RESPONSE,
|
|
201
|
+
URL_SCHEME,
|
|
202
|
+
SCHEME_PATH_REQUEST,
|
|
203
|
+
QUERY_PARAM_PAYLOAD,
|
|
204
|
+
FRAGMENT_KEY_RESPONSE,
|
|
205
|
+
ERR_USER_DENIED,
|
|
206
|
+
ERR_ORIGIN_MISMATCH,
|
|
207
|
+
ERR_INVALID_REQUEST,
|
|
208
|
+
ERR_WALLET_UNAVAILABLE,
|
|
209
|
+
ERR_REQUIRED_CLAIM_UNAVAILABLE,
|
|
210
|
+
ERR_INTERNAL,
|
|
211
|
+
ERR_NO_WALLET_INSTALLED,
|
|
212
|
+
ERR_TIMEOUT,
|
|
213
|
+
ERR_UPSELL_CANCELED,
|
|
214
|
+
} from '@matanetwork/sovereign-id';
|
|
215
|
+
|
|
216
|
+
export type {
|
|
217
|
+
SignInRequest,
|
|
218
|
+
SignInSuccess,
|
|
219
|
+
ErrorCode,
|
|
220
|
+
CustomClaim,
|
|
221
|
+
InstallCta,
|
|
222
|
+
InstallUpsellOptions,
|
|
223
|
+
InstallUpsellResult,
|
|
224
|
+
SignInOptions,
|
|
225
|
+
} from '@matanetwork/sovereign-id';
|