Skip to content

Commit

Permalink
Vue SDK v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeLo123 committed Jun 25, 2024
1 parent 17fffd9 commit de90f06
Show file tree
Hide file tree
Showing 19 changed files with 905 additions and 625 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
README.md
src/**/*.min.css
.github/ISSUE_TEMPLATE/*.md
packages/sdk-vue/web-types.json
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './SDKCore';
export * from './SDKConfig';
export * from './SDKContext';
export { type SDKContext } from './SDKContext';
export * from './testUtils';
export { type CookieAdapter } from './CookieHelpers';
15 changes: 14 additions & 1 deletion packages/sdk-vue/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
fusionauth-vue-sdk Changes

Upcoming release
Changes in 1.2.0

- [`postLogoutRedirectUri`](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/main/packages/sdk-vue/docs/interfaces/types.FusionAuthConfig.md#postlogoutredirecturi) config option added.
- [`createFusionAuth`](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/main/packages/sdk-vue/docs/modules.md#createfusionauth) factory function is now an exported member of the package. This was suggested in issue [#104](https://github.com/FusionAuth/fusionauth-javascript-sdk/issues/104) and provides more flexibility in setting up your fusionauth plugin.
- `manageAccount` function and button added. [Self service account management](https://fusionauth.io/docs/lifecycle/manage-users/account-management/) is only available in FusionAuth paid plans.
- `userInfo` can now be custom typed with an optional generic argument. This may be helpful for SDK users with a non-hosted backend. Below is an example of what it may look like.
```typescript
interface MyUser {
customTrait: string;
// ...
}
const { userInfo } = useFusionAuth<MyUser>();
// where `userInfo.value` is inferred to be of type `Ref<MyUser | null>`
```
- Missing optional properties added to `UserInfo` type definition.
- sourcemaps included for debugging

Changes in 1.1.0
Expand Down
22 changes: 22 additions & 0 deletions packages/sdk-vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ export default defineNuxtPlugin((nuxtApp) => {
});
```

##### Alternate ways to define your nuxt plugin

Using `createFusionAuth`, the SDK can be configured more flexibly.

```typescript
export default defineNuxtPlugin({
setup(nuxtApp) {
const fusionauth = createFusionAuth(config);
nuxtApp.vueApp.use(FusionAuthVuePlugin, { instance: fusionauth })
return {
provide: { fusionauth }
};
},
hooks: {
"app:beforeMount"() {
const { $fusionauth } = useNuxtApp();
// ...
},
}
})
```

### `useFusionAuth` composable

You can interact with the SDK by using the `useFusionAuth`, which leverages [Vue's Composition API](https://vuejs.org/guide/reusability/composables).
Expand Down
24 changes: 23 additions & 1 deletion packages/sdk-vue/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@fusionauth/vue-sdk / [Modules](modules.md)
@fusionauth/vue-sdk / [Exports](modules.md)

An SDK for using FusionAuth in Vue applications.

Expand Down Expand Up @@ -123,6 +123,28 @@ export default defineNuxtPlugin((nuxtApp) => {
});
```

##### Alternate ways to define your nuxt plugin

Using `createFusionAuth`, the SDK can be configured more flexibly.

```typescript
export default defineNuxtPlugin({
setup(nuxtApp) {
const fusionauth = createFusionAuth(config);
nuxtApp.vueApp.use(FusionAuthVuePlugin, { instance: fusionauth })
return {
provide: { fusionauth }
};
},
hooks: {
"app:beforeMount"() {
const { $fusionauth } = useNuxtApp();
// ...
},
}
})
```

### `useFusionAuth` composable

You can interact with the SDK by using the `useFusionAuth`, which leverages [Vue's Composition API](https://vuejs.org/guide/reusability/composables).
Expand Down
231 changes: 231 additions & 0 deletions packages/sdk-vue/docs/interfaces/FusionAuth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
[@fusionauth/vue-sdk](../README.md) / [Exports](../modules.md) / FusionAuth

# Interface: FusionAuth\<T\>

FusionAuth object provided at app-level by FusionAuthVuePlugin

## Type parameters

| Name | Type |
| :--- | :------------------------ |
| `T` | [`UserInfo`](UserInfo.md) |

## Table of contents

### Properties

- [error](FusionAuth.md#error)
- [getUserInfo](FusionAuth.md#getuserinfo)
- [initAutoRefresh](FusionAuth.md#initautorefresh)
- [isGettingUserInfo](FusionAuth.md#isgettinguserinfo)
- [isLoggedIn](FusionAuth.md#isloggedin)
- [login](FusionAuth.md#login)
- [logout](FusionAuth.md#logout)
- [manageAccount](FusionAuth.md#manageaccount)
- [refreshToken](FusionAuth.md#refreshtoken)
- [register](FusionAuth.md#register)
- [userInfo](FusionAuth.md#userinfo)

## Properties

### error

**error**: `Ref`\<`null` \| `Error`\>

Error occurred within getUserInfo.

#### Defined in

[src/types.ts:134](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L134)

---

### getUserInfo

**getUserInfo**: () => `Promise`\<`undefined` \| `T`\>

This is handled automatically if the SDK is configured with `shouldAutoFetchUserInfo`.
Internally updates `isFetchingUser` and `userInfo` refs, as well as `error` if the request fails.

#### Type declaration

▸ (): `Promise`\<`undefined` \| `T`\>

##### Returns

`Promise`\<`undefined` \| `T`\>

#### Defined in

[src/types.ts:119](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L119)

---

### initAutoRefresh

**initAutoRefresh**: () => `undefined` \| `Timeout`

Initializes automatic refreshing of the access token.
Refresh is scheduled to happen at the configured `autoRefreshSecondsBeforeExpiry`.

#### Type declaration

▸ (): `undefined` \| `Timeout`

##### Returns

`undefined` \| `Timeout`

#### Defined in

[src/types.ts:169](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L169)

---

### isGettingUserInfo

**isGettingUserInfo**: `Ref`\<`boolean`\>

Indicates that the getUserInfo call is unresolved.

#### Defined in

[src/types.ts:129](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L129)

---

### isLoggedIn

**isLoggedIn**: `Ref`\<`boolean`\>

Whether the user is logged in.

#### Defined in

[src/types.ts:112](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L112)

---

### login

**login**: (`state?`: `string`) => `void`

Initiates login flow.

#### Type declaration

▸ (`state?`): `void`

##### Parameters

| Name | Type | Description |
| :------- | :------- | :--------------------------------------------------------- |
| `state?` | `string` | Optional value to be echoed back to the SDK upon redirect. |

##### Returns

`void`

#### Defined in

[src/types.ts:140](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L140)

---

### logout

**logout**: () => `void`

Initiates a logout.

#### Type declaration

▸ (): `void`

##### Returns

`void`

#### Defined in

[src/types.ts:151](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L151)

---

### manageAccount

**manageAccount**: () => `void`

Redirects to [self service account management](https://fusionauth.io/docs/lifecycle/manage-users/account-management/)
Self service account management is only available in FusionAuth paid plans.

#### Type declaration

▸ (): `void`

##### Returns

`void`

#### Defined in

[src/types.ts:157](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L157)

---

### refreshToken

**refreshToken**: () => `Promise`\<`Response`\>

Refreshes the access token a single time.
Token refreshing is handled automatically if configured with `shouldAutoRefresh`.

#### Type declaration

▸ (): `Promise`\<`Response`\>

##### Returns

`Promise`\<`Response`\>

#### Defined in

[src/types.ts:163](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L163)

---

### register

**register**: (`state?`: `string`) => `void`

Initiates register flow.

#### Type declaration

▸ (`state?`): `void`

##### Parameters

| Name | Type | Description |
| :------- | :------- | :--------------------------------------------------------- |
| `state?` | `string` | Optional value to be echoed back to the SDK upon redirect. |

##### Returns

`void`

#### Defined in

[src/types.ts:146](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L146)

---

### userInfo

**userInfo**: `Ref`\<`null` \| `T`\>

Data fetched from the configured 'me' endpoint.

#### Defined in

[src/types.ts:124](https://github.com/FusionAuth/fusionauth-javascript-sdk/blob/c51ae9700e9eba2a046df58b7bbac54492463b29/packages/sdk-vue/src/types.ts#L124)
Loading

0 comments on commit de90f06

Please sign in to comment.