@seamless-auth/vue 0.0.0-stage → 0.2.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/CHANGELOG.md +34 -0
- package/LICENSE +202 -0
- package/README.md +224 -2
- package/dist/chunks/shared-C2_q4dvU.js +2 -0
- package/dist/chunks/shared-C2_q4dvU.js.map +1 -0
- package/dist/config.d.ts +51 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +79 -0
- package/dist/router/components/AuthLayout.d.ts +20 -0
- package/dist/router/components/FallbackOptions.d.ts +51 -0
- package/dist/router/components/Login.d.ts +4 -0
- package/dist/router/components/MagicLinkSent.d.ts +8 -0
- package/dist/router/components/OAuthCallback.d.ts +4 -0
- package/dist/router/components/OAuthProviderButtons.d.ts +24 -0
- package/dist/router/components/OtpInput.d.ts +47 -0
- package/dist/router/components/PasskeyLogin.d.ts +4 -0
- package/dist/router/components/RegisterPasskey.d.ts +8 -0
- package/dist/router/components/VerifyMagicLink.d.ts +9 -0
- package/dist/router/components/VerifyOtp.d.ts +22 -0
- package/dist/router/guards.d.ts +31 -0
- package/dist/router/index.d.ts +18 -0
- package/dist/router/navigation.d.ts +27 -0
- package/dist/router/paths.d.ts +20 -0
- package/dist/router/routes.d.ts +15 -0
- package/dist/router.js +2 -0
- package/dist/router.js.map +1 -0
- package/dist/seamless-auth.css +260 -0
- package/package.json +69 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @seamless-auth/vue
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 59802e2: Add a confirmation step for magic links opened on another device.
|
|
8
|
+
|
|
9
|
+
A magic link opened on a device other than the one that asked for it now waits for the reader to approve it (auth API 0.19.0 and later). The bundled verify screens show which kind of device asked and when, and offer "Yes, sign in that device" or "No, this wasn't me". Approving signs in the requesting device and tells the reader to return to it; declining changes nothing.
|
|
10
|
+
|
|
11
|
+
`@seamless-auth/client` adds `client.confirmMagicLink(token)`, the `getMagicLinkConfirmation`, `isMagicLinkConfirmationRequired`, `describeMagicLinkDevice`, `magicLinkConfirmationPrompt` and `confirmMagicLinkSignIn` helpers, and the `MagicLinkConfirmation` and `MagicLinkDeviceClass` types. In bearer mode the verify call now sends the sign-in's ephemeral token when one is held. A custom verify screen that treats every failure as an invalid link should check `getMagicLinkConfirmation(error)` first.
|
|
12
|
+
|
|
13
|
+
The React Native README describes the new step for apps that handle magic links.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [59802e2]
|
|
18
|
+
- @seamless-auth/client@0.6.0
|
|
19
|
+
|
|
20
|
+
## 0.1.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- bab12a7: First release of `@seamless-auth/vue`, the Vue binding for Seamless Auth (Vue 3.5 and later).
|
|
25
|
+
- `createSeamlessAuth({ apiHost })` is a plugin that gives each application its own session, and `useSeamlessAuth()` exposes it as read-only refs (`user`, `isAuthenticated`, `loading`, and the rest) plus every auth action.
|
|
26
|
+
- `@seamless-auth/vue/router` provides `authGuard`, `guestGuard`, `requireAuth({ roles })` and `requireGuest()` for `vue-router` 4.4 and later. Each one waits for the session to be read.
|
|
27
|
+
- `createSeamlessAuthRoutes()` adds the sign-in screens (login, email and phone codes, magic link, OAuth callback, passkey login and enrolment) as named routes under any base path. They are themed with the same `--seamless-*` properties as the React and Angular screens.
|
|
28
|
+
|
|
29
|
+
The binding uses cookie transport only: tokens stay in the server adapter, and nothing is written where page scripts can read it.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [d1e3310]
|
|
34
|
+
- @seamless-auth/client@0.5.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,225 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @seamless-auth/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@seamless-auth/vue)
|
|
4
|
+
[](https://github.com/fells-code/seamless-auth-react/actions/workflows/ci.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
Vue bindings for Seamless Auth: a plugin and a `useSeamlessAuth()` composable for session state and
|
|
8
|
+
auth actions, `vue-router` guards, and optional sign-in screens. It is a thin binding over
|
|
9
|
+
[`@seamless-auth/client`](../client/README.md), the same core the React and Angular bindings use, so
|
|
10
|
+
the flows behave the same in all of them.
|
|
11
|
+
|
|
12
|
+
## Start here
|
|
13
|
+
|
|
14
|
+
New to Seamless Auth? The [self-hosted quickstart](https://docs.seamlessauth.com/start/quickstart/)
|
|
15
|
+
runs the full stack locally with Docker. The [compatibility matrix](https://docs.seamlessauth.com/build/ecosystem/#compatibility-matrix)
|
|
16
|
+
lists which package versions work together.
|
|
17
|
+
|
|
18
|
+
The browser talks only to your backend's `/auth` routes, served by a server adapter. The adapter keeps
|
|
19
|
+
the tokens; the browser holds only HttpOnly cookies. This package has no bearer mode and never writes
|
|
20
|
+
a token to `localStorage`, `sessionStorage`, or anywhere page scripts can read it.
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- Vue 3.5 or later
|
|
25
|
+
- `vue-router` 4.4 or later (including 5) for the guards and screens in `@seamless-auth/vue/router`.
|
|
26
|
+
The root entry does not need it
|
|
27
|
+
- A Seamless Auth server adapter mounted at `/auth` on `apiHost`
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @seamless-auth/vue
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// main.ts
|
|
39
|
+
import { createApp } from 'vue';
|
|
40
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
|
41
|
+
import { createSeamlessAuth } from '@seamless-auth/vue';
|
|
42
|
+
import {
|
|
43
|
+
authGuard,
|
|
44
|
+
createSeamlessAuthRoutes,
|
|
45
|
+
guestGuard,
|
|
46
|
+
} from '@seamless-auth/vue/router';
|
|
47
|
+
|
|
48
|
+
import App from './App.vue';
|
|
49
|
+
import HomePage from './HomePage.vue';
|
|
50
|
+
|
|
51
|
+
const router = createRouter({
|
|
52
|
+
history: createWebHistory(),
|
|
53
|
+
routes: [
|
|
54
|
+
{ path: '/', component: HomePage, beforeEnter: authGuard },
|
|
55
|
+
...createSeamlessAuthRoutes(),
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
createApp(App)
|
|
60
|
+
.use(router)
|
|
61
|
+
.use(createSeamlessAuth({ apiHost: 'https://app.example.com' }))
|
|
62
|
+
.mount('#app');
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Each application the plugin is installed in gets its own session, so a server rendering many requests
|
|
66
|
+
never shares one. The session is read as soon as the application starts in the browser.
|
|
67
|
+
|
|
68
|
+
| Option | Default | Purpose |
|
|
69
|
+
| -------------------------- | ---------------- | ----------------------------------------------------------- |
|
|
70
|
+
| `apiHost` | required | Origin of the server adapter |
|
|
71
|
+
| `basePath` | `/auth` | Where the adapter is mounted |
|
|
72
|
+
| `magicLinkRedirectUri` | the deployment's | Where an emailed magic link lands |
|
|
73
|
+
| `autoDetectPreviousSignIn` | `true` | Open the login screen on Sign In for a returning browser |
|
|
74
|
+
| `initialSession` | none | A session the server already resolved, for server rendering |
|
|
75
|
+
| `ports` | browser | `passkeys` and `oauthRedirect` ports |
|
|
76
|
+
| `fetch` | global `fetch` | The fetch auth requests go through |
|
|
77
|
+
| `trustedOrigins` | none | Other origins of yours that may receive the session cookies |
|
|
78
|
+
| `injectStyles` | `true` | Whether the screens add their stylesheet to the page |
|
|
79
|
+
| `cspNonce` | none | A CSP nonce for that stylesheet |
|
|
80
|
+
| `signedInPath` | `/` | Where the bundled screens go after sign-in |
|
|
81
|
+
| `loginPath` | `/login` | Where `requireAuth` sends someone signed out |
|
|
82
|
+
|
|
83
|
+
### Read session state
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
import { useRouter } from 'vue-router';
|
|
88
|
+
import { useSeamlessAuth } from '@seamless-auth/vue';
|
|
89
|
+
|
|
90
|
+
const auth = useSeamlessAuth();
|
|
91
|
+
const router = useRouter();
|
|
92
|
+
|
|
93
|
+
async function signOut() {
|
|
94
|
+
await auth.logout();
|
|
95
|
+
await router.push('/login');
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<template>
|
|
100
|
+
<span v-if="auth.user.value">{{ auth.user.value.email }}</span>
|
|
101
|
+
<button v-if="auth.isAuthenticated.value" type="button" @click="signOut">Logout</button>
|
|
102
|
+
</template>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## `useSeamlessAuth()` API
|
|
106
|
+
|
|
107
|
+
Read-only refs: `state`, `user`, `isAuthenticated`, `loading`, `credentials`, `organizations`,
|
|
108
|
+
`activeOrganization`, `stepUpStatus`, `hasSignedInBefore`, plus `loginMethods`,
|
|
109
|
+
`loginMethodsLoading`, `passkeySupported`, and `passkeySupportLoading`.
|
|
110
|
+
|
|
111
|
+
Actions, each resolving to a `SeamlessAuthResult<T>` (`{ data, error }`) that never throws for an HTTP
|
|
112
|
+
failure: `login`, `handlePasskeyLogin`, `registerPasskey`, `refreshSession`, `logout`,
|
|
113
|
+
`logoutAllSessions`, `deleteUser`, `updateCredential`, `deleteCredential`, `switchOrganization`,
|
|
114
|
+
`listOAuthProviders`, `startOAuthLogin`, `finishOAuthLogin`, `refreshStepUpStatus`,
|
|
115
|
+
`verifyStepUpWithPasskey`, `verifyStepUpWithPasskeyPrf`, `verifyStepUpWithTotp`.
|
|
116
|
+
|
|
117
|
+
Also: `hasRole`, `hasScopedRole`, `markSignedIn`, `whenSettled()` (resolves once the session is read),
|
|
118
|
+
`loadLoginMethods()` and `checkPasskeySupport()` (each read once and cached), `authorizedFetch` (a
|
|
119
|
+
fetch for your own API that carries the cookies to `apiHost` and `trustedOrigins` only), `client`
|
|
120
|
+
(the headless client for everything else, such as OTP and magic link calls), and `ports`.
|
|
121
|
+
|
|
122
|
+
## Guards
|
|
123
|
+
|
|
124
|
+
`@seamless-auth/vue/router` exports guards for `beforeEnter` or `router.beforeEach`. They wait for the
|
|
125
|
+
session to be read before deciding, so reloading a protected page does not bounce a signed-in user to
|
|
126
|
+
the login screen.
|
|
127
|
+
|
|
128
|
+
| Guard | Admits | Otherwise |
|
|
129
|
+
| --------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
130
|
+
| `authGuard` / `requireAuth(options?)` | A signed-in user, with `roles` when given | `redirectTo` (default `loginPath`); `forbiddenRedirectTo` or refusal when a role is missing |
|
|
131
|
+
| `guestGuard` / `requireGuest(options?)` | Someone signed out | `redirectTo` (default `signedInPath`) |
|
|
132
|
+
|
|
133
|
+
`roles` uses the same matching as the auth API, scoped roles such as `org:admin` included. A guard is
|
|
134
|
+
a convenience for navigation, not access control: your server still checks every request.
|
|
135
|
+
|
|
136
|
+
## Built-in screens
|
|
137
|
+
|
|
138
|
+
`createSeamlessAuthRoutes({ basePath? })` returns the screens as named routes (`seamless-auth-login`
|
|
139
|
+
and so on) to spread into your router. They reach each other by name, so any `basePath` works. There
|
|
140
|
+
is no catch-all among them, so they never swallow your own unknown paths.
|
|
141
|
+
|
|
142
|
+
| Path | Component | Purpose |
|
|
143
|
+
| ------------------ | ------------------- | ----------------------------------------------------------- |
|
|
144
|
+
| `login` | `SaLogin` | Sign in with an email or phone number, or create an account |
|
|
145
|
+
| `passkey-login` | `SaPasskeyLogin` | Sign in with a passkey alone |
|
|
146
|
+
| `verify-email-otp` | `SaVerifyOtp` | Check an email code |
|
|
147
|
+
| `verify-phone-otp` | `SaVerifyOtp` | Check a text message code |
|
|
148
|
+
| `magic-link-sent` | `SaMagicLinkSent` | Wait for an emailed link to be used |
|
|
149
|
+
| `verify-magiclink` | `SaVerifyMagicLink` | Where the emailed link lands. The auth API builds this URL |
|
|
150
|
+
| `oauth/callback` | `SaOAuthCallback` | The OAuth redirect URI to register with providers |
|
|
151
|
+
| `register-passkey` | `SaRegisterPasskey` | Offer passkey enrolment after sign-up |
|
|
152
|
+
|
|
153
|
+
The building blocks are exported too: `SaOtpInput` (bind with `v-model`), `SaFallbackOptions`,
|
|
154
|
+
`SaOAuthProviderButtons`, `SaAuthLayout`, `authRoutePaths`, `authRouteName`, and
|
|
155
|
+
`useAuthNavigation`.
|
|
156
|
+
|
|
157
|
+
Put `guestGuard` only on the screens that start a sign-in (`login`, `passkey-login`,
|
|
158
|
+
`magic-link-sent`). A user can already have a session when `register-passkey`, `oauth/callback`, or
|
|
159
|
+
`verify-magiclink` renders, and the guard would send them on before they finish.
|
|
160
|
+
|
|
161
|
+
The magic link and OAuth callback screens remove the token or code from the URL once they have read
|
|
162
|
+
it, so a single-use secret does not stay in history or travel in a `Referer`.
|
|
163
|
+
|
|
164
|
+
## Headless use
|
|
165
|
+
|
|
166
|
+
Every screen is a thin view over a flow in `@seamless-auth/client` (`beginSignIn`,
|
|
167
|
+
`registerWithEmail`, `verifyOtp`, `watchMagicLink`, `finishMagicLinkSignIn`,
|
|
168
|
+
`confirmMagicLinkSignIn`, `startOAuthSignIn`, `completeOAuthCallback`, `enrollPasskey`, and helpers). A custom screen calls the same flows with the
|
|
169
|
+
session as its actions:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import { beginSignIn } from '@seamless-auth/client';
|
|
173
|
+
|
|
174
|
+
const step = await beginSignIn(auth, {
|
|
175
|
+
identifier: email.value,
|
|
176
|
+
passkeySupported: await auth.checkPasskeySupport(),
|
|
177
|
+
configuredMethods: await auth.loadLoginMethods(),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (step.kind === 'signed_in') await router.push('/');
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
See the [client README](../client/README.md#flows) for the full list.
|
|
184
|
+
|
|
185
|
+
## Styling
|
|
186
|
+
|
|
187
|
+
The screens render inside `.sa-auth` with plain `.sa-*` classes. The first screen to mount adds the
|
|
188
|
+
stylesheet to the top of `<head>`, so your own styles override it. Colours come from the same
|
|
189
|
+
`--seamless-*` custom properties the React and Angular screens read, so one theme covers every
|
|
190
|
+
binding:
|
|
191
|
+
|
|
192
|
+
```css
|
|
193
|
+
:root {
|
|
194
|
+
--seamless-accent: #1f3a34;
|
|
195
|
+
--seamless-accent-hover: #16302b;
|
|
196
|
+
--seamless-surface: #f7f5f0;
|
|
197
|
+
--seamless-surface-raised: #ffffff;
|
|
198
|
+
--seamless-text: #1a1a1a;
|
|
199
|
+
--seamless-text-muted: #4b5563;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The stylesheet also ships as `@seamless-auth/vue/seamless-auth.css`. Link it yourself when you render
|
|
204
|
+
on the server, so the first paint is already styled. Under a Content Security Policy, pass
|
|
205
|
+
`cspNonce` so the injected `<style>` carries your nonce, or set `injectStyles: false` and link the
|
|
206
|
+
file instead.
|
|
207
|
+
|
|
208
|
+
## Server rendering
|
|
209
|
+
|
|
210
|
+
On the server the session is not read and no screen starts a request: a server render has none of the
|
|
211
|
+
browser's cookies, and a magic link or OAuth code is single use. `loading` stays true unless you pass
|
|
212
|
+
`initialSession`. Without it, `requireAuth` treats the request as signed out and redirects to
|
|
213
|
+
`loginPath`, so a protected page's data never renders into a response for someone the server could not
|
|
214
|
+
identify; the browser decides again when the application boots. Resolve the session on your server
|
|
215
|
+
through your adapter and hand it over as `initialSession`, building the plugin's config per request so
|
|
216
|
+
one visitor's session is never another's. The browser then revalidates it in the background. Never
|
|
217
|
+
forward the browser's cookies to the adapter's `/auth/users/me` from a server.
|
|
218
|
+
|
|
219
|
+
The magic link and OAuth callback URLs carry a single-use secret until the screen drops it. Serve
|
|
220
|
+
those routes with `Referrer-Policy: no-referrer` (or `same-origin`) so it does not leave in a
|
|
221
|
+
`Referer` before then.
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
Apache-2.0. See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createBrowserOAuthRedirect as e,createBrowserPasskeyPort as t,createAuthSession as s,createMemoryStorage as n,detectPasskeySupport as i,loadLoginMethods as a}from"@seamless-auth/client";import{inject as o,shallowRef as r,ref as l,readonly as u,computed as c}from"vue";const d=Symbol("seamless-auth");function p(o){const d="undefined"!=typeof window&&"undefined"!=typeof document,p={passkeys:o.ports?.passkeys??t(),oauthRedirect:o.ports?.oauthRedirect??e()},h=s({apiHost:o.apiHost,magicLinkRedirectUri:o.magicLinkRedirectUri,transport:{basePath:o.basePath,fetch:o.fetch,trustedOrigins:o.trustedOrigins},passkeys:p.passkeys,detectPreviousSignIn:o.autoDetectPreviousSignIn??!0,initialSession:o.initialSession,storage:d?void 0:n()}),g=d?h.getState:h.getServerState,v=r(g()),S=h.subscribe(()=>{v.value=g()}),f=l(null),m=l(!0);let y=null;const k=new Set,P=l(!1),b=l(!0);let w=null;const z={...h.actions,state:u(v),user:c(()=>v.value.user),isAuthenticated:c(()=>v.value.isAuthenticated),loading:c(()=>v.value.loading),credentials:c(()=>v.value.credentials),organizations:c(()=>v.value.organizations),activeOrganization:c(()=>v.value.activeOrganization),stepUpStatus:c(()=>v.value.stepUpStatus),hasSignedInBefore:c(()=>v.value.hasSignedInBefore),loginMethods:u(f),loginMethodsLoading:u(m),passkeySupported:u(P),passkeySupportLoading:u(b),loadLoginMethods:()=>(y??(y=a(h.client).then(e=>(f.value=e,m.value=!1,e))),y),checkPasskeySupport:()=>(w??(w=(d?i(p.passkeys):Promise.resolve(!1)).then(e=>(P.value=e,b.value=!1,e))),w),whenSettled(){const e=v.value;return e.loading&&d?new Promise(e=>{const t=t=>{n(),k.delete(s),e(t)},s=()=>t(v.value),n=h.subscribe(()=>{const e=h.getState();e.loading||t(e)});k.add(s)}):Promise.resolve(e)},client:h.client,authorizedFetch:(e,t)=>h.client.authorizedFetch(e,t),ports:p,styles:{inject:o.injectStyles??!0,nonce:o.cspNonce},signedInPath:o.signedInPath??"/",loginPath:o.loginPath??"/login",destroy(){[...k].forEach(e=>e()),S(),h.destroy()}};return d&&h.actions.refreshSession({background:void 0!==o.initialSession}),z}function h(e){return{install(t){const s=p(e);t.provide(d,s),t.onUnmount(()=>s.destroy())}}}function g(){const e=o(d,null);if(!e)throw new Error("Seamless Auth is not installed. Add app.use(createSeamlessAuth({ apiHost })) before mounting the app.");return e}export{d as S,h as c,g as u};
|
|
2
|
+
//# sourceMappingURL=shared-C2_q4dvU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-C2_q4dvU.js","sources":["../../src/plugin.ts"],"sourcesContent":[null],"names":["SEAMLESS_AUTH_KEY","Symbol","createSeamlessAuthInstance","config","browser","window","document","ports","passkeys","createBrowserPasskeyPort","oauthRedirect","createBrowserOAuthRedirect","session","createAuthSession","apiHost","magicLinkRedirectUri","transport","basePath","fetch","trustedOrigins","detectPreviousSignIn","autoDetectPreviousSignIn","initialSession","storage","undefined","createMemoryStorage","read","getState","getServerState","state","shallowRef","unsubscribe","subscribe","value","loginMethods","ref","loginMethodsLoading","loginMethodsRequest","pendingSettles","Set","passkeySupported","passkeySupportLoading","passkeySupportRequest","instance","actions","readonly","user","computed","isAuthenticated","loading","credentials","organizations","activeOrganization","stepUpStatus","hasSignedInBefore","loadLoginMethods","client","then","methods","checkPasskeySupport","detectPasskeySupport","Promise","resolve","supported","whenSettled","current","settle","next","stop","delete","abandon","add","authorizedFetch","input","init","styles","inject","injectStyles","nonce","cspNonce","signedInPath","loginPath","destroy","forEach","refreshSession","background","createSeamlessAuth","install","app","provide","onUnmount","useSeamlessAuth","auth","Error"],"mappings":"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"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { InitialSession, OAuthRedirectPort, PasskeyPort } from '@seamless-auth/client';
|
|
2
|
+
/**
|
|
3
|
+
* What a browser application configures. There is no transport mode: a Vue
|
|
4
|
+
* application runs in the browser, where the server adapter holds the tokens
|
|
5
|
+
* and the browser holds only its HttpOnly cookies.
|
|
6
|
+
*/
|
|
7
|
+
export interface SeamlessAuthConfig {
|
|
8
|
+
/** Origin of the server adapter, for example `https://app.example.com`. */
|
|
9
|
+
apiHost: string;
|
|
10
|
+
/** Where the adapter is mounted on `apiHost`. Defaults to `/auth`. */
|
|
11
|
+
basePath?: string;
|
|
12
|
+
/** Where a magic link sent by the bundled screens should land. */
|
|
13
|
+
magicLinkRedirectUri?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether `hasSignedInBefore` reports a previous sign-in from this browser,
|
|
16
|
+
* which the bundled login screen uses to open on Sign In rather than Create
|
|
17
|
+
* Account. Defaults to true.
|
|
18
|
+
*/
|
|
19
|
+
autoDetectPreviousSignIn?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The session a server already resolved for this request, or `null` when it
|
|
22
|
+
* found none. The first render is then settled rather than loading, and the
|
|
23
|
+
* session revalidates in the background once the app runs in the browser.
|
|
24
|
+
*/
|
|
25
|
+
initialSession?: InitialSession | null;
|
|
26
|
+
/** Platform ports. Each one left out falls back to the browser's. */
|
|
27
|
+
ports?: Partial<SeamlessAuthPorts>;
|
|
28
|
+
/** A fetch to send auth requests with. Defaults to the global one. */
|
|
29
|
+
fetch?: typeof fetch;
|
|
30
|
+
/**
|
|
31
|
+
* Origins besides `apiHost` that `authorizedFetch` may send the session
|
|
32
|
+
* cookies to. Every other origin is refused.
|
|
33
|
+
*/
|
|
34
|
+
trustedOrigins?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Whether the bundled screens add their stylesheet to the page. Defaults to
|
|
37
|
+
* true. Set false to link `@seamless-auth/vue/seamless-auth.css` yourself,
|
|
38
|
+
* for example under a CSP that allows no inline styles.
|
|
39
|
+
*/
|
|
40
|
+
injectStyles?: boolean;
|
|
41
|
+
/** A CSP nonce for the stylesheet the screens add, when `injectStyles` is on. */
|
|
42
|
+
cspNonce?: string;
|
|
43
|
+
/** Where the bundled screens go once someone is signed in. Defaults to `/`. */
|
|
44
|
+
signedInPath?: string;
|
|
45
|
+
/** Where `requireAuth` sends someone who is signed out. Defaults to `/login`. */
|
|
46
|
+
loginPath?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface SeamlessAuthPorts {
|
|
49
|
+
passkeys: PasskeyPort;
|
|
50
|
+
oauthRedirect: OAuthRedirectPort;
|
|
51
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { SeamlessAuthConfig, SeamlessAuthPorts } from './config';
|
|
2
|
+
export { createSeamlessAuth, SEAMLESS_AUTH_KEY, useSeamlessAuth } from './plugin';
|
|
3
|
+
export type { SeamlessAuth } from './plugin';
|
|
4
|
+
export { getOAuthErrorCode, getPasskeyPolicyErrorCode, getWebAuthnErrorDetail, hasScopedRole, isUnauthenticated, roleGrantsAccess, SeamlessAuthError, UntrustedOriginError, } from '@seamless-auth/client';
|
|
5
|
+
export type { AuthSessionState, Credential, CurrentUserResult, InitialSession, LoginMethod, OAuthProvider, OAuthRedirectPort, Organization, PasskeyPort, RefreshSessionOptions, SeamlessAuthClient, SeamlessAuthResult, StepUpStatus, User, } from '@seamless-auth/client';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export{S as SEAMLESS_AUTH_KEY,c as createSeamlessAuth,u as useSeamlessAuth}from"./chunks/shared-C2_q4dvU.js";export{SeamlessAuthError,UntrustedOriginError,getOAuthErrorCode,getPasskeyPolicyErrorCode,getWebAuthnErrorDetail,hasScopedRole,isUnauthenticated,roleGrantsAccess}from"@seamless-auth/client";import"vue";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type AuthSessionActions, type AuthSessionState, type LoginMethod, type SeamlessAuthClient } from '@seamless-auth/client';
|
|
2
|
+
import { type ComputedRef, type InjectionKey, type Plugin, type Ref } from 'vue';
|
|
3
|
+
import type { SeamlessAuthConfig, SeamlessAuthPorts } from './config';
|
|
4
|
+
/**
|
|
5
|
+
* Session state and auth actions for a Vue application, from `useSeamlessAuth()`.
|
|
6
|
+
*
|
|
7
|
+
* A thin binding over the framework-agnostic session store in
|
|
8
|
+
* `@seamless-auth/client`: the store owns the state machine, and this exposes
|
|
9
|
+
* it as reactive refs. Every ref is read-only; change the session through the
|
|
10
|
+
* actions.
|
|
11
|
+
*/
|
|
12
|
+
export interface SeamlessAuth extends AuthSessionActions {
|
|
13
|
+
/** Everything the session knows. Replaced wholesale on every change. */
|
|
14
|
+
state: Readonly<Ref<AuthSessionState>>;
|
|
15
|
+
user: ComputedRef<AuthSessionState['user']>;
|
|
16
|
+
isAuthenticated: ComputedRef<boolean>;
|
|
17
|
+
/** True until the session has been read. Guards wait on this. */
|
|
18
|
+
loading: ComputedRef<boolean>;
|
|
19
|
+
credentials: ComputedRef<AuthSessionState['credentials']>;
|
|
20
|
+
organizations: ComputedRef<AuthSessionState['organizations']>;
|
|
21
|
+
activeOrganization: ComputedRef<AuthSessionState['activeOrganization']>;
|
|
22
|
+
stepUpStatus: ComputedRef<AuthSessionState['stepUpStatus']>;
|
|
23
|
+
hasSignedInBefore: ComputedRef<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Sign-in methods this instance has enabled, once `loadLoginMethods()` has
|
|
26
|
+
* answered. Null means unknown, never "none".
|
|
27
|
+
*/
|
|
28
|
+
loginMethods: Readonly<Ref<LoginMethod[] | null>>;
|
|
29
|
+
loginMethodsLoading: Readonly<Ref<boolean>>;
|
|
30
|
+
/** Whether this device can use a passkey, once `checkPasskeySupport()` has answered. */
|
|
31
|
+
passkeySupported: Readonly<Ref<boolean>>;
|
|
32
|
+
passkeySupportLoading: Readonly<Ref<boolean>>;
|
|
33
|
+
/** Reads the instance's sign-in methods once and caches the answer. */
|
|
34
|
+
loadLoginMethods(): Promise<LoginMethod[] | null>;
|
|
35
|
+
/** Detects passkey support once and caches the answer. */
|
|
36
|
+
checkPasskeySupport(): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Resolves with the state once the session has been read. During a server
|
|
39
|
+
* render the session is never read there, so this resolves at once with what
|
|
40
|
+
* the server knows.
|
|
41
|
+
*/
|
|
42
|
+
whenSettled(): Promise<AuthSessionState>;
|
|
43
|
+
/** The client behind the session, for calls the session does not wrap. */
|
|
44
|
+
client: SeamlessAuthClient;
|
|
45
|
+
/**
|
|
46
|
+
* A fetch for the application's own API that carries the session cookies.
|
|
47
|
+
* A path resolves on `apiHost`. Only `apiHost` and `trustedOrigins` receive
|
|
48
|
+
* the session; any other origin rejects with `UntrustedOriginError`.
|
|
49
|
+
*/
|
|
50
|
+
authorizedFetch: SeamlessAuthClient['authorizedFetch'];
|
|
51
|
+
/** The platform ports the bundled screens go through. */
|
|
52
|
+
ports: SeamlessAuthPorts;
|
|
53
|
+
/** How the bundled screens add their stylesheet. */
|
|
54
|
+
styles: {
|
|
55
|
+
inject: boolean;
|
|
56
|
+
nonce?: string;
|
|
57
|
+
};
|
|
58
|
+
/** Where the bundled screens go once someone is signed in. */
|
|
59
|
+
signedInPath: string;
|
|
60
|
+
/** Where `requireAuth` sends someone who is signed out. */
|
|
61
|
+
loginPath: string;
|
|
62
|
+
}
|
|
63
|
+
export declare const SEAMLESS_AUTH_KEY: InjectionKey<SeamlessAuth>;
|
|
64
|
+
/**
|
|
65
|
+
* The Vue plugin. Each application it is installed in gets its own session, so
|
|
66
|
+
* a server rendering many requests never shares one between them:
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* createApp(App).use(router).use(createSeamlessAuth({ apiHost: 'https://app.example.com' }))
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* The session is read as soon as the application is installed in the browser.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createSeamlessAuth(config: SeamlessAuthConfig): Plugin;
|
|
75
|
+
/**
|
|
76
|
+
* The session for the current application. Call it in `setup`, a composable,
|
|
77
|
+
* or a navigation guard.
|
|
78
|
+
*/
|
|
79
|
+
export declare function useSeamlessAuth(): SeamlessAuth;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame every bundled screen renders in. Its stylesheet is unscoped, so an
|
|
3
|
+
* application themes the `.sa-*` classes and `--seamless-*` properties like any
|
|
4
|
+
* other global style.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SaAuthLayout: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
|
+
card: {
|
|
8
|
+
type: BooleanConstructor;
|
|
9
|
+
default: boolean;
|
|
10
|
+
};
|
|
11
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
+
card: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
}>> & Readonly<{}>, {
|
|
19
|
+
card: boolean;
|
|
20
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|