Skip to content

Commit

Permalink
Update docs (#22)
Browse files Browse the repository at this point in the history
* Update docs

* Add changeset

* Update package.json

* Update readme
  • Loading branch information
manzoorwanijk authored Jan 28, 2024
1 parent 5d7eb0c commit 0444dc6
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 99 deletions.
6 changes: 6 additions & 0 deletions .changeset/fifty-radios-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@telegram-auth/server": patch
"@telegram-auth/react": patch
---

Updated docs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import NextAuth, { NextAuthOptions } from 'next-auth';
import CredentialsProvider from 'next-auth/providers/credentials';

import { objectToAuthDataMap, AuthDataValidator } from '@telegram-auth/server';
import { AuthDataValidator } from '@telegram-auth/server';
import { objectToAuthDataMap } from '@telegram-auth/server/utils';

export type User = {
id: string;
Expand Down
3 changes: 2 additions & 1 deletion examples/next-auth/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import NextAuth, { NextAuthOptions } from 'next-auth';
import CredentialsProvider from 'next-auth/providers/credentials';
import { objectToAuthDataMap, AuthDataValidator } from '@telegram-auth/server';
import { AuthDataValidator } from '@telegram-auth/server';
import { objectToAuthDataMap } from '@telegram-auth/server/utils';

export const authOptions: NextAuthOptions = {
providers: [
Expand Down
3 changes: 2 additions & 1 deletion examples/remix-basic/app/routes/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { redirect } from '@remix-run/node';
import type { LoaderFunction } from '@remix-run/node';
import { urlStrToAuthDataMap, AuthDataValidator } from '@telegram-auth/server';
import { AuthDataValidator } from '@telegram-auth/server';
import { urlStrToAuthDataMap } from '@telegram-auth/server/utils';
import { getSession, commitSession } from '../sessions';

export const loader: LoaderFunction = async ({ request }) => {
Expand Down
3 changes: 0 additions & 3 deletions internal/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@
"prettier": "^3.0.3",
"react": "^18.2.0",
"typescript": "^5.2.2"
},
"publishConfig": {
"access": "public"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"release:dev": "changeset publish --tag dev",
"test": "turbo run test",
"typecheck": "tsc --noEmit",
"version-packages": "changeset version",
"version-packages": "changeset version && pnpm -r run version",
"version:dev": "changeset version --snapshot dev"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ You can use [`@telegram-auth/server`](../server) server-side to validate the dat

<!-- prettier-ignore -->
```ts title=validate.ts
import { urlStrToAuthDataMap, AuthDataValidator } from '@telegram-auth/server';
import { AuthDataValidator } from '@telegram-auth/server';
import { urlStrToAuthDataMap } from '@telegram-auth/server/utils';

const validator = new AuthDataValidator({ botToken: process.env.BOT_TOKEN });

Expand Down
30 changes: 15 additions & 15 deletions packages/react/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

## Table of contents

### Functions

- [LoginButton](README.md#loginbutton)
- [createScript](README.md#createscript)

### Interfaces

- [TelegramAuthData](interfaces/TelegramAuthData.md)
- [LoginButtonProps](interfaces/LoginButtonProps.md)
- [CreateScriptOptions](interfaces/CreateScriptOptions.md)

### Functions

- [LoginButton](README.md#loginbutton)
- [createScript](README.md#createscript)

## Functions

### LoginButton
Expand All @@ -23,10 +23,6 @@

A React component that renders a Telegram login button.

**`See`**

https://core.telegram.org/widgets/login

#### Parameters

| Name | Type | Description |
Expand All @@ -39,9 +35,13 @@ https://core.telegram.org/widgets/login

A React component that renders the Telegram login button.

**`See`**

https://core.telegram.org/widgets/login

#### Defined in

[LoginButton.tsx:23](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/LoginButton.tsx#L23)
[LoginButton.tsx:23](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/LoginButton.tsx#L23)

___

Expand All @@ -51,10 +51,6 @@ ___

It creates a script tag with the right attributes to load the Telegram widget

**`See`**

https://core.telegram.org/widgets/login

#### Parameters

| Name | Type | Description |
Expand All @@ -67,6 +63,10 @@ https://core.telegram.org/widgets/login

A script element

**`See`**

https://core.telegram.org/widgets/login

#### Defined in

[createScript.ts:11](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/createScript.ts#L11)
[createScript.ts:11](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/createScript.ts#L11)
26 changes: 17 additions & 9 deletions packages/react/docs/interfaces/CreateScriptOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The username of the bot that will be used to authenticate the user.

#### Defined in

[types.ts:25](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L25)
[types.ts:25](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L25)

___

Expand All @@ -54,7 +54,7 @@ The URL where the auth data from Telegram will be sent.

#### Defined in

[types.ts:20](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L20)
[types.ts:20](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L20)

___

Expand All @@ -66,15 +66,17 @@ The size of the button.

**`Default`**

```ts
'large'
```

#### Inherited from

[LoginButtonProps](LoginButtonProps.md).[buttonSize](LoginButtonProps.md#buttonsize)

#### Defined in

[types.ts:32](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L32)
[types.ts:32](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L32)

___

Expand All @@ -90,7 +92,7 @@ The radius of the button corners.

#### Defined in

[types.ts:37](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L37)
[types.ts:37](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L37)

___

Expand All @@ -102,15 +104,17 @@ The language of the button.

**`Default`**

```ts
"en"
```

#### Inherited from

[LoginButtonProps](LoginButtonProps.md).[lang](LoginButtonProps.md#lang)

#### Defined in

[types.ts:44](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L44)
[types.ts:44](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L44)

___

Expand Down Expand Up @@ -140,7 +144,7 @@ The callback function that will be called when the user is authenticated.

#### Defined in

[types.ts:49](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L49)
[types.ts:49](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L49)

___

Expand All @@ -152,15 +156,17 @@ The access level that the bot will request.

**`Default`**

```ts
"write"
```

#### Inherited from

[LoginButtonProps](LoginButtonProps.md).[requestAccess](LoginButtonProps.md#requestaccess)

#### Defined in

[types.ts:56](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L56)
[types.ts:56](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L56)

___

Expand All @@ -172,15 +178,17 @@ Whether to show the user's avatar.

**`Default`**

```ts
true
```

#### Inherited from

[LoginButtonProps](LoginButtonProps.md).[showAvatar](LoginButtonProps.md#showavatar)

#### Defined in

[types.ts:63](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L63)
[types.ts:63](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L63)

___

Expand All @@ -196,4 +204,4 @@ The version of the Telegram widget to deal with browser caching.

#### Defined in

[types.ts:68](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L68)
[types.ts:68](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L68)
26 changes: 17 additions & 9 deletions packages/react/docs/interfaces/LoginButtonProps.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The username of the bot that will be used to authenticate the user.

#### Defined in

[types.ts:25](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L25)
[types.ts:25](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L25)

___

Expand All @@ -44,7 +44,7 @@ The URL where the auth data from Telegram will be sent.

#### Defined in

[types.ts:20](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L20)
[types.ts:20](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L20)

___

Expand All @@ -56,11 +56,13 @@ The size of the button.

**`Default`**

```ts
'large'
```

#### Defined in

[types.ts:32](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L32)
[types.ts:32](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L32)

___

Expand All @@ -72,7 +74,7 @@ The radius of the button corners.

#### Defined in

[types.ts:37](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L37)
[types.ts:37](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L37)

___

Expand All @@ -84,11 +86,13 @@ The language of the button.

**`Default`**

```ts
"en"
```

#### Defined in

[types.ts:44](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L44)
[types.ts:44](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L44)

___

Expand All @@ -114,7 +118,7 @@ The callback function that will be called when the user is authenticated.

#### Defined in

[types.ts:49](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L49)
[types.ts:49](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L49)

___

Expand All @@ -126,11 +130,13 @@ The access level that the bot will request.

**`Default`**

```ts
"write"
```

#### Defined in

[types.ts:56](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L56)
[types.ts:56](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L56)

___

Expand All @@ -142,11 +148,13 @@ Whether to show the user's avatar.

**`Default`**

```ts
true
```

#### Defined in

[types.ts:63](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L63)
[types.ts:63](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L63)

___

Expand All @@ -158,4 +166,4 @@ The version of the Telegram widget to deal with browser caching.

#### Defined in

[types.ts:68](https://github.com/manzoorwanijk/telegram-auth/blob/063fb29/packages/react/src/types.ts#L68)
[types.ts:68](https://github.com/manzoorwanijk/telegram-auth/blob/5d7eb0c/packages/react/src/types.ts#L68)
Loading

0 comments on commit 0444dc6

Please sign in to comment.