Skip to content

Commit 6aa1967

Browse files
committed
Added github workflow
1 parent f48b587 commit 6aa1967

File tree

7 files changed

+489
-2
lines changed

7 files changed

+489
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# InteraApps JS API Clients
22

3+
## Packages
4+
- [@interaapps/accounts](https://npmjs.com/package/@interaapps/accounts)
5+
- [@interaapps/pastefy](https://npmjs.com/package/@interaapps/pastefy)
6+
- [@interaapps/punyshort](https://npmjs.com/package/@interaapps/punyshort)
7+
- _(Internal) [@interaapps/base-client](https://npmjs.com/package/@interaapps/accounts)_
8+
39
## Example: Login in browser and access pastefy pastes
410

511
```bash

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@interaapps/clients",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "",
55
"main": "index.js",
66
"type": "module",

packages/accounts/README.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# InteraApps Accounts SDK
2+
3+
A TypeScript/JavaScript SDK for interacting with the [InteraApps Accounts API](https://accounts.interaapps.de). This SDK provides all the necessary tools for user authentication, user management, OAuth2 integrations, and project/app management through a simple and consistent API.
4+
5+
---
6+
7+
## 🌐 Features
8+
9+
- 🔐 Login, registration, password reset
10+
- 👥 User and contact management
11+
- 📁 Project and app management
12+
- 🔄 OAuth2 authentication flows
13+
- 📦 Fully typed request and response models
14+
- 🧪 Built-in exception handling
15+
16+
---
17+
18+
## 📦 Installation
19+
20+
```bash
21+
npm install @interaapps/accounts
22+
````
23+
24+
---
25+
26+
## 🚀 Getting Started
27+
28+
### Initialize the client:
29+
30+
```ts
31+
import { AccountsClient } from '@interaapps/accounts-client';
32+
33+
const client = new AccountsClient('YOUR_API_TOKEN');
34+
35+
// Or without token (you can set it later)
36+
const client = new AccountsClient();
37+
client.setApiToken('YOUR_API_TOKEN');
38+
```
39+
40+
---
41+
42+
## 🔐 Authentication
43+
44+
```ts
45+
import { LoginRequest } from '@interaapps/accounts-client';
46+
47+
const authKey = await client.login({
48+
name: 'your-username',
49+
password: 'your-password',
50+
});
51+
```
52+
53+
---
54+
55+
## 👤 User Management
56+
57+
```ts
58+
const user = await client.getCurrentUser();
59+
60+
await client.editUser({
61+
full_name: 'New Name',
62+
favorite_color: '#123456'
63+
});
64+
```
65+
66+
---
67+
68+
## 🧑‍💻 Projects & Apps
69+
70+
```ts
71+
const project = await client.createProject({ name: 'My Project' });
72+
73+
await client.createProjectApp(project.id, {
74+
name: 'My App',
75+
type: 'OAUTH2',
76+
url: 'https://myapp.com',
77+
});
78+
```
79+
80+
---
81+
82+
## 🔄 OAuth2 Integration
83+
84+
### Create a URL for OAuth2 login:
85+
86+
```ts
87+
import { InteraAppsOAuth2Client } from '@interaapps/accounts-client';
88+
89+
const oauthClient = new InteraAppsOAuth2Client(
90+
'your-client-id',
91+
'your-client-secret'
92+
);
93+
94+
const url = oauthClient.urlBuilder()
95+
.setRedirectUri('https://yourapp.com/callback')
96+
.setScopes(['user'])
97+
.build();
98+
99+
// Redirect user to this URL
100+
```
101+
102+
### Token Exchange
103+
104+
```ts
105+
const token = await oauthClient.exchangeToken('oauth-code');
106+
```
107+
108+
109+
### Get Key for App
110+
```js
111+
oauthClient.urlBuilder()
112+
.setRedirectUri('https://yourapp.com/callback')
113+
.setScopes(['profile', 'pastefy|pastes'])
114+
.build();
115+
// ...
116+
117+
const userClient = await oauthClient.exchangeTokenAndGetClient('oauth-code');
118+
const pastefyToken = userClient.getKeyFor('pastefy')
119+
const pastefyClient = new PastefyClient(pastefyToken)
120+
121+
```
122+
123+
---
124+
125+
## 🛠 Exceptions
126+
127+
All exceptions inherit from `InteraAppsAccountsException` and include:
128+
129+
* `AlreadyLinked`
130+
* `AccountNotGrantedApp`
131+
* `Authentication`
132+
* `AuthenticationInvalid`
133+
* `ChallengeFailed`
134+
* `HTTP`
135+
* `InternalError`
136+
* `InvalidRequest`
137+
* `NamespacePermissionsDenied`
138+
* `NotFound`
139+
* `PermissionsDenied`
140+
* `PrivacyPoliciesNotChecked`
141+
* `TokenExpired`
142+
143+
You can handle them like this:
144+
145+
```ts
146+
try {
147+
await client.login({ name: 'user', password: 'wrong-pass' });
148+
} catch (e) {
149+
if (e instanceof AuthenticationInvalid) {
150+
console.error('Invalid login credentials');
151+
}
152+
}
153+
```
154+
155+
---
156+
157+
## 📘 Types
158+
159+
All request and response types are fully typed. For example:
160+
161+
* `LoginRequest`, `RegisterRequest`, `EditUserRequest`
162+
* `User`, `Project`, `OAuth2App`, `AuthKey`, etc.
163+
164+
---
165+
166+
## 🧪 Testing
167+
168+
> No test framework included, but you can mock `BaseClient` methods for integration testing.
169+
170+
---
171+
172+
## 📝 License
173+
174+
MIT License © InteraApps
175+
176+
```
177+
178+
---
179+
180+
Let me know if you'd like the README in German or want a `tsdoc` style API documentation as well.
181+
```

packages/base-client/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Base-client for interaapps api clients

packages/pastefy/README.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Pastefy Client
2+
3+
A TypeScript client for interacting with the [Pastefy.app](https://pastefy.app) API (v2). This library provides full access to pastes, folders, tags, users, and more, and supports both authenticated and public endpoints.
4+
5+
## ✨ Features
6+
7+
* Create, edit, delete and fetch pastes (including support for multipaste)
8+
* Manage folders and organize pastes
9+
* Fetch and filter public trending or latest pastes
10+
* Manage users and authentication
11+
* API key management
12+
* Fully typed with TypeScript
13+
* Built-in error handling with custom exceptions
14+
15+
## 🚀 Installation
16+
17+
```bash
18+
npm install @interaapps/pastefy
19+
```
20+
21+
## 📦 Usage
22+
23+
```ts
24+
import { PastefyClient } from '@interaapps/pastefy-client';
25+
26+
const client = new PastefyClient('YOUR_API_KEY');
27+
28+
// Create a paste
29+
const paste = await client.createPaste({
30+
title: 'Hello World',
31+
content: 'This is a sample paste.',
32+
visibility: 'PUBLIC',
33+
});
34+
console.log(paste.id);
35+
```
36+
37+
## 📚 API Overview
38+
39+
### 📝 Paste
40+
41+
* `createPaste(paste: CreatePasteRequest)`
42+
* `editPaste(id: string, data: EditPasteRequest)`
43+
* `getPastes(query: PasteFilters)`
44+
* `getPaste(id: string)`
45+
* `getPasteRaw(id: string)`
46+
* `deletePaste(id: string)`
47+
* `starPaste(id: string)`
48+
* `unstarPaste(id: string)`
49+
* `getPublicPastes(query: PasteFilters)`
50+
* `getPublicTrendingPastes(query: PasteFilters)`
51+
* `getLatestPublicPastes(query: PasteFilters)`
52+
* `getUserPastes(query: PasteFilters)`
53+
* `getStarredPastes(query: PasteFilters)`
54+
55+
### 📁 Folders
56+
57+
* `createFolder(data: CreateFolderRequest)`
58+
* `getFolder(id: string, options?)`
59+
* `getFolders(query: Filters)`
60+
* `getUserFolders(query?)`
61+
62+
### 👤 User
63+
64+
* `getCurrentUser()`
65+
* `getUserOverview()`
66+
* `getPublicUser(id: string)`
67+
* `getUser(id: string)`
68+
* `getUsers(query: string)`
69+
* `editUser(id: string, data: EditUser)`
70+
* `deleteUser(id: string)`
71+
72+
### 🔑 API Keys
73+
74+
* `createApiKey()`
75+
* `getApiKeys()`
76+
* `deleteApiKey(id: string)`
77+
78+
### 🏷 Tags
79+
80+
* `getTags(query: Filters)`
81+
* `getTag(id: string)`
82+
83+
## 🔐 Authentication
84+
85+
Pass your API token when creating the client instance:
86+
87+
```ts
88+
const client = new PastefyClient('your-api-token');
89+
```
90+
91+
You can also update the token later:
92+
93+
```ts
94+
client.setApiToken('new-token');
95+
```
96+
97+
## ❗ Exceptions
98+
99+
Custom exceptions are automatically thrown for common error types:
100+
101+
* `AuthenticationException`
102+
* `AwaitingAccessException`
103+
* `BlockedException`
104+
* `FeatureDisabledException`
105+
* `NotFoundException`
106+
* `PastePrivateException`
107+
* `PermissionsDeniedException`
108+
109+
Catch them like this:
110+
111+
```ts
112+
try {
113+
await client.getPaste('invalid-id');
114+
} catch (e) {
115+
if (e instanceof NotFoundException) {
116+
console.error('Paste not found');
117+
}
118+
}
119+
```
120+
121+
## 🧱 Types
122+
123+
The library exports many useful types:
124+
125+
* `Paste`, `CreatePasteRequest`, `EditPasteRequest`
126+
* `Folder`, `CreateFolderRequest`
127+
* `User`, `PublicUser`, `UserAsAdmin`, `EditUser`
128+
* `Tag`
129+
* `Filters`, `PasteFilters`
130+
* `ApiKey`
131+
* `UserOverview`
132+
133+
## 🧪 Example
134+
135+
```ts
136+
const paste = await client.createPaste({
137+
title: 'My First Paste',
138+
content: 'Welcome to Pastefy!',
139+
visibility: 'UNLISTED',
140+
tags: ['welcome', 'test'],
141+
});
142+
143+
console.log(`Paste created at: https://pastefy.app/${paste.id}`);
144+
```
145+
146+
## 🔗 Related
147+
148+
* [Pastefy.app](https://pastefy.app)
149+
150+
## 📄 License
151+
152+
MIT License

0 commit comments

Comments
 (0)