@openpeepshq/client 0.1.36

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.
Files changed (54) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/common/authenticated.d.ts +8 -0
  3. package/dist/common/authenticated.js +23 -0
  4. package/dist/common/base.d.ts +3 -0
  5. package/dist/common/base.js +5 -0
  6. package/dist/endpoints/accounts.d.ts +321 -0
  7. package/dist/endpoints/accounts.js +12 -0
  8. package/dist/endpoints/admin.d.ts +17353 -0
  9. package/dist/endpoints/admin.js +123 -0
  10. package/dist/endpoints/auth.d.ts +85 -0
  11. package/dist/endpoints/auth.js +10 -0
  12. package/dist/endpoints/conversations.d.ts +9818 -0
  13. package/dist/endpoints/conversations.js +6 -0
  14. package/dist/endpoints/groups.d.ts +341 -0
  15. package/dist/endpoints/groups.js +15 -0
  16. package/dist/endpoints/helpers.d.ts +16 -0
  17. package/dist/endpoints/helpers.js +15 -0
  18. package/dist/endpoints/i18n.d.ts +16 -0
  19. package/dist/endpoints/i18n.js +5 -0
  20. package/dist/endpoints/jams.d.ts +3347 -0
  21. package/dist/endpoints/jams.js +25 -0
  22. package/dist/endpoints/location.d.ts +24 -0
  23. package/dist/endpoints/location.js +4 -0
  24. package/dist/endpoints/media.d.ts +47 -0
  25. package/dist/endpoints/media.js +18 -0
  26. package/dist/endpoints/payments.d.ts +68 -0
  27. package/dist/endpoints/payments.js +8 -0
  28. package/dist/endpoints/plugins.d.ts +45 -0
  29. package/dist/endpoints/plugins.js +6 -0
  30. package/dist/endpoints/posts.d.ts +76856 -0
  31. package/dist/endpoints/posts.js +65 -0
  32. package/dist/endpoints/previewLink.d.ts +17 -0
  33. package/dist/endpoints/previewLink.js +2 -0
  34. package/dist/endpoints/profiles.d.ts +6929 -0
  35. package/dist/endpoints/profiles.js +26 -0
  36. package/dist/endpoints/reports.d.ts +59 -0
  37. package/dist/endpoints/reports.js +8 -0
  38. package/dist/endpoints/search.d.ts +9650 -0
  39. package/dist/endpoints/search.js +9 -0
  40. package/dist/endpoints/server.d.ts +152 -0
  41. package/dist/endpoints/server.js +13 -0
  42. package/dist/endpoints/sso.d.ts +40 -0
  43. package/dist/endpoints/sso.js +10 -0
  44. package/dist/endpoints/streaming.d.ts +33 -0
  45. package/dist/endpoints/streaming.js +13 -0
  46. package/dist/endpoints/types.d.ts +61 -0
  47. package/dist/endpoints/types.js +1 -0
  48. package/dist/index.d.ts +8 -0
  49. package/dist/index.js +62 -0
  50. package/dist/types/index.d.ts +4 -0
  51. package/dist/types/index.js +1 -0
  52. package/dist/webhooks/index.d.ts +4 -0
  53. package/dist/webhooks/index.js +27 -0
  54. package/package.json +40 -0
@@ -0,0 +1,9 @@
1
+ import { allpeepNoPayloadEndpoint } from "./helpers.js";
2
+ export const search = (rawClient) => ({
3
+ posts: allpeepNoPayloadEndpoint(rawClient, '/search/posts'),
4
+ profiles: allpeepNoPayloadEndpoint(rawClient, '/search/profiles'),
5
+ events: allpeepNoPayloadEndpoint(rawClient, '/search/events'),
6
+ jams: allpeepNoPayloadEndpoint(rawClient, '/search/jams'),
7
+ groups: allpeepNoPayloadEndpoint(rawClient, '/search/groups'),
8
+ counts: allpeepNoPayloadEndpoint(rawClient, '/search/counts'),
9
+ });
@@ -0,0 +1,152 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ export declare const server: (rawClient: FetchClient) => {
3
+ info: import("@openpeepshq/fetch-client").TypedNoPayloadEndpoint<{
4
+ version: string;
5
+ environment: string;
6
+ publicContent: boolean;
7
+ communityConfig: {
8
+ theme: {
9
+ base: string;
10
+ primaryHex: string;
11
+ light: {
12
+ primaryHex: string;
13
+ logoSmall?: string | undefined;
14
+ defaultProfileAvatar?: string | undefined;
15
+ defaultGroupAvatar?: string | undefined;
16
+ backgroundAuth?: string | undefined;
17
+ background?: string | undefined;
18
+ };
19
+ dark: {
20
+ primaryHex: string;
21
+ logoSmall?: string | undefined;
22
+ defaultProfileAvatar?: string | undefined;
23
+ defaultGroupAvatar?: string | undefined;
24
+ backgroundAuth?: string | undefined;
25
+ background?: string | undefined;
26
+ };
27
+ icon?: string | undefined;
28
+ mobileIcon?: string | undefined;
29
+ logoFull?: string | undefined;
30
+ logoSmall?: string | undefined;
31
+ defaultProfileAvatar?: string | undefined;
32
+ defaultGroupAvatar?: string | undefined;
33
+ backgroundAuth?: string | undefined;
34
+ background?: string | undefined;
35
+ };
36
+ info: {
37
+ name: string;
38
+ tagLine: string;
39
+ contactEmail?: string | undefined;
40
+ privacyPolicy?: string | undefined;
41
+ termsAndConditions?: string | undefined;
42
+ };
43
+ content: {
44
+ aboutPage?: string | undefined;
45
+ welcomePage?: string | undefined;
46
+ codeOfConduct?: string | undefined;
47
+ welcomeEmail?: string | undefined;
48
+ pinnedPost?: string | undefined;
49
+ };
50
+ settings: {
51
+ openRegistrations: boolean;
52
+ defaultLanguage?: string | undefined;
53
+ };
54
+ roles: {
55
+ onRegistration: {
56
+ add: string[];
57
+ remove: string[];
58
+ };
59
+ onEmailValidation: {
60
+ add: string[];
61
+ remove: string[];
62
+ };
63
+ };
64
+ profiles?: {
65
+ additionalFields?: {
66
+ key: string;
67
+ label: string;
68
+ icon?: string | undefined;
69
+ linkPattern?: string | undefined;
70
+ }[] | undefined;
71
+ } | undefined;
72
+ };
73
+ jams: {
74
+ livekit: {
75
+ url: string;
76
+ enabled: boolean;
77
+ recordingEnabled: boolean;
78
+ };
79
+ };
80
+ vapid: {
81
+ publicKey?: string | undefined;
82
+ };
83
+ sentryConfig: {
84
+ enabled: boolean;
85
+ dsn?: string | undefined;
86
+ replayEnabled?: boolean | undefined;
87
+ };
88
+ payments: {
89
+ stripe: {
90
+ paidMembership: {
91
+ enabled: boolean;
92
+ };
93
+ };
94
+ };
95
+ maxProfiles?: number | undefined;
96
+ sso?: {
97
+ oidc: {
98
+ id: string;
99
+ name: string;
100
+ }[];
101
+ } | undefined;
102
+ }, {
103
+ success: boolean;
104
+ message?: string | undefined;
105
+ key?: string | undefined;
106
+ }, undefined, undefined>;
107
+ config: {
108
+ capabilities: import("@openpeepshq/fetch-client").TypedNoPayloadEndpoint<{
109
+ post: Record<string, {
110
+ add: string[];
111
+ remove: string[];
112
+ }>;
113
+ profile: Record<string, {
114
+ add: string[];
115
+ remove: string[];
116
+ }>;
117
+ report: Record<string, {
118
+ add: string[];
119
+ remove: string[];
120
+ }>;
121
+ accessToken: Record<string, {
122
+ add: string[];
123
+ remove: string[];
124
+ }>;
125
+ }, {
126
+ success: boolean;
127
+ message?: string | undefined;
128
+ key?: string | undefined;
129
+ }, undefined, undefined>;
130
+ };
131
+ keys: {
132
+ webhooks: {
133
+ public: import("@openpeepshq/fetch-client").TypedNoPayloadEndpoint<{
134
+ publicKey: string;
135
+ }, {
136
+ success: boolean;
137
+ message?: string | undefined;
138
+ key?: string | undefined;
139
+ }, undefined, undefined>;
140
+ verify: import("@openpeepshq/fetch-client").TypedPayloadEndpoint<{
141
+ success: true;
142
+ payload: Record<string, unknown>;
143
+ }, {
144
+ token: string;
145
+ }, {
146
+ success: boolean;
147
+ message?: string | undefined;
148
+ key?: string | undefined;
149
+ }, undefined, undefined>;
150
+ };
151
+ };
152
+ };
@@ -0,0 +1,13 @@
1
+ import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint } from './helpers.js';
2
+ export const server = (rawClient) => ({
3
+ info: allpeepNoPayloadEndpoint(rawClient, '/server/info'),
4
+ config: {
5
+ capabilities: allpeepNoPayloadEndpoint(rawClient, '/server/config/capabilities'),
6
+ },
7
+ keys: {
8
+ webhooks: {
9
+ public: allpeepNoPayloadEndpoint(rawClient, '/server/keys/webhooks'),
10
+ verify: allpeepPayloadEndpoint(rawClient, '/server/keys/webhooks/verify', 'post'),
11
+ },
12
+ },
13
+ });
@@ -0,0 +1,40 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ export declare const sso: (rawClient: FetchClient) => {
3
+ generic: {
4
+ authenticate: import("@openpeepshq/fetch-client").TypedPayloadEndpoint<{
5
+ success: true;
6
+ token: string;
7
+ checkoutUrl?: string | undefined;
8
+ }, {
9
+ data: Record<string, string>;
10
+ }, {
11
+ success: boolean;
12
+ message?: string | undefined;
13
+ key?: string | undefined;
14
+ }, undefined, undefined>;
15
+ };
16
+ oidc: {
17
+ authorize: import("@openpeepshq/fetch-client").TypedNoPayloadEndpoint<{
18
+ data: {
19
+ redirectUrl: string;
20
+ };
21
+ }, {
22
+ success: boolean;
23
+ message?: string | undefined;
24
+ key?: string | undefined;
25
+ }, {
26
+ id: string;
27
+ }, undefined>;
28
+ callback: import("@openpeepshq/fetch-client").TypedNoPayloadEndpoint<{
29
+ success: true;
30
+ token: string;
31
+ checkoutUrl?: string | undefined;
32
+ }, {
33
+ success: boolean;
34
+ message?: string | undefined;
35
+ key?: string | undefined;
36
+ }, {
37
+ id: string;
38
+ }, Record<string, string>>;
39
+ };
40
+ };
@@ -0,0 +1,10 @@
1
+ import { allpeepPayloadEndpoint, allpeepNoPayloadEndpoint } from './helpers.js';
2
+ export const sso = (rawClient) => ({
3
+ generic: {
4
+ authenticate: allpeepPayloadEndpoint(rawClient, '/sso/generic'),
5
+ },
6
+ oidc: {
7
+ authorize: allpeepNoPayloadEndpoint(rawClient, '/sso/oidc/{id}/authorize', 'get'),
8
+ callback: allpeepNoPayloadEndpoint(rawClient, '/sso/oidc/{id}/callback', 'get'),
9
+ },
10
+ });
@@ -0,0 +1,33 @@
1
+ import type { FetchClient } from '@openpeepshq/fetch-client';
2
+ export declare const streaming: (rawClient: FetchClient) => {
3
+ vod: {
4
+ /**
5
+ * Request that an HLS VOD stream be produced for a media URL hosted on
6
+ * this server. Idempotent: returns the existing stream's status when
7
+ * called again with the same source URL.
8
+ */
9
+ create: import("@openpeepshq/fetch-client").TypedPayloadEndpoint<{
10
+ storageId: string;
11
+ status: "error" | "processing" | "ready";
12
+ error?: string | undefined;
13
+ }, {
14
+ url: string;
15
+ }, {
16
+ success: boolean;
17
+ message?: string | undefined;
18
+ key?: string | undefined;
19
+ }, undefined, undefined>;
20
+ /** Polls the current status of a previously-created VOD stream. */
21
+ status: import("@openpeepshq/fetch-client").TypedNoPayloadEndpoint<{
22
+ storageId: string;
23
+ status: "error" | "processing" | "ready";
24
+ error?: string | undefined;
25
+ }, {
26
+ success: boolean;
27
+ message?: string | undefined;
28
+ key?: string | undefined;
29
+ }, {
30
+ storageId: string;
31
+ }, undefined>;
32
+ };
33
+ };
@@ -0,0 +1,13 @@
1
+ import { allpeepNoPayloadEndpoint, allpeepPayloadEndpoint, } from './helpers.js';
2
+ export const streaming = (rawClient) => ({
3
+ vod: {
4
+ /**
5
+ * Request that an HLS VOD stream be produced for a media URL hosted on
6
+ * this server. Idempotent: returns the existing stream's status when
7
+ * called again with the same source URL.
8
+ */
9
+ create: allpeepPayloadEndpoint(rawClient, '/streaming/vod', 'post'),
10
+ /** Polls the current status of a previously-created VOD stream. */
11
+ status: allpeepNoPayloadEndpoint(rawClient, '/streaming/vod/:storageId/status'),
12
+ },
13
+ });
@@ -0,0 +1,61 @@
1
+ import type { accounts } from './accounts';
2
+ import type { auth } from './auth';
3
+ import type { conversations } from './conversations';
4
+ import type { groups } from './groups';
5
+ import type { i18n } from './i18n';
6
+ import type { jams } from './jams';
7
+ import type { location } from './location';
8
+ import type { media } from './media';
9
+ import type { posts } from './posts';
10
+ import type { profiles } from './profiles';
11
+ import type { reports } from './reports';
12
+ import type { server } from './server';
13
+ import type { sso } from './sso';
14
+ import type { admin } from './admin';
15
+ import type { previewLink } from './previewLink';
16
+ import type { search } from './search';
17
+ import type { payments } from './payments';
18
+ import type { plugins } from './plugins';
19
+ import type { streaming } from './streaming';
20
+ import type { WebhookHandler } from '../webhooks';
21
+ export type AdminEndpoints = ReturnType<typeof admin>;
22
+ export type AccountsEndpoints = ReturnType<typeof accounts>;
23
+ export type AuthEndpoints = ReturnType<typeof auth>;
24
+ export type ConversationsEndpoints = ReturnType<typeof conversations>;
25
+ export type GroupsEndpoints = ReturnType<typeof groups>;
26
+ export type I18nEndpoints = ReturnType<typeof i18n>;
27
+ export type JamsEndpoints = ReturnType<typeof jams>;
28
+ export type LocationEndpoints = ReturnType<typeof location>;
29
+ export type MediaEndpoints = ReturnType<typeof media>;
30
+ export type PostsEndpoints = ReturnType<typeof posts>;
31
+ export type PreviewLinkEndpoints = ReturnType<typeof previewLink>;
32
+ export type ProfilesEndpoints = ReturnType<typeof profiles>;
33
+ export type ReportsEndpoints = ReturnType<typeof reports>;
34
+ export type ServerEndpoints = ReturnType<typeof server>;
35
+ export type SsoEndpoints = ReturnType<typeof sso>;
36
+ export type SearchEndpoints = ReturnType<typeof search>;
37
+ export type PaymentsEndpoints = ReturnType<typeof payments>;
38
+ export type PluginEndpoints = ReturnType<typeof plugins>;
39
+ export type StreamingEndpoints = ReturnType<typeof streaming>;
40
+ export type Endpoints = {
41
+ admin: AdminEndpoints;
42
+ accounts: AccountsEndpoints;
43
+ auth: AuthEndpoints;
44
+ conversations: ConversationsEndpoints;
45
+ groups: GroupsEndpoints;
46
+ i18n: I18nEndpoints;
47
+ jams: JamsEndpoints;
48
+ location: LocationEndpoints;
49
+ mediaAttachment: MediaEndpoints;
50
+ plugins: PluginEndpoints;
51
+ posts: PostsEndpoints;
52
+ previewLink: PreviewLinkEndpoints;
53
+ profiles: ProfilesEndpoints;
54
+ reports: ReportsEndpoints;
55
+ server: ServerEndpoints;
56
+ sso: SsoEndpoints;
57
+ search: SearchEndpoints;
58
+ payments: PaymentsEndpoints;
59
+ streaming: StreamingEndpoints;
60
+ webhookHandler: WebhookHandler;
61
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Endpoints } from './endpoints/types';
2
+ export interface OpenpeepsClientOptions {
3
+ baseUrl?: string;
4
+ token?: string;
5
+ }
6
+ export declare const openpeepsClient: (options?: OpenpeepsClientOptions | (() => Promise<OpenpeepsClientOptions> | OpenpeepsClientOptions)) => Endpoints;
7
+ export type { OpenpeepsPayloadEndpoint, OpenpeepsNoPayloadEndpoint, } from './types';
8
+ export type OpenpeepsClient = ReturnType<typeof openpeepsClient>;
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ import { noPayloadEventSource, fetchClient } from '@openpeepshq/fetch-client';
2
+ import { admin } from './endpoints/admin.js';
3
+ import { i18n } from './endpoints/i18n.js';
4
+ import { accounts } from './endpoints/accounts.js';
5
+ import { jams } from './endpoints/jams.js';
6
+ import { auth } from './endpoints/auth.js';
7
+ import { conversations } from './endpoints/conversations.js';
8
+ import { groups } from './endpoints/groups.js';
9
+ import { posts } from './endpoints/posts.js';
10
+ import { plugins } from './endpoints/plugins.js';
11
+ import { server } from './endpoints/server.js';
12
+ import { profiles } from './endpoints/profiles.js';
13
+ import { sso } from './endpoints/sso.js';
14
+ import { location } from './endpoints/location.js';
15
+ import { reports } from './endpoints/reports.js';
16
+ import { media } from './endpoints/media.js';
17
+ import { search } from './endpoints/search.js';
18
+ import { previewLink } from './endpoints/previewLink.js';
19
+ import { payments } from './endpoints/payments.js';
20
+ import { streaming } from './endpoints/streaming.js';
21
+ import { webhookHandler } from './webhooks/index.js';
22
+ const allPeepClientOptionsToClientConfig = (options) => {
23
+ var _a;
24
+ return ({
25
+ baseUrl: ((_a = options === null || options === void 0 ? void 0 : options.baseUrl) !== null && _a !== void 0 ? _a : '') + '/api/openpeeps/core/v1',
26
+ headers: (options === null || options === void 0 ? void 0 : options.token)
27
+ ? {
28
+ Authorization: `Bearer ${options.token}`,
29
+ }
30
+ : undefined,
31
+ });
32
+ };
33
+ export const openpeepsClient = (options) => {
34
+ const config = typeof options === 'function'
35
+ ? async () => allPeepClientOptionsToClientConfig(await options())
36
+ : allPeepClientOptionsToClientConfig(options);
37
+ const rawClient = fetchClient(config);
38
+ const allPeepNoPayloadEventSource = noPayloadEventSource(config);
39
+ const serverEndpoints = server(rawClient);
40
+ return {
41
+ admin: admin(rawClient),
42
+ accounts: accounts(rawClient),
43
+ auth: auth(rawClient),
44
+ conversations: conversations(rawClient),
45
+ groups: groups(rawClient),
46
+ i18n: i18n(rawClient),
47
+ jams: jams(rawClient, allPeepNoPayloadEventSource),
48
+ mediaAttachment: media(rawClient, allPeepNoPayloadEventSource),
49
+ plugins: plugins(rawClient),
50
+ posts: posts(rawClient),
51
+ previewLink: previewLink(rawClient),
52
+ profiles: profiles(rawClient),
53
+ server: serverEndpoints,
54
+ sso: sso(rawClient),
55
+ location: location(rawClient),
56
+ reports: reports(rawClient),
57
+ search: search(rawClient),
58
+ payments: payments(rawClient),
59
+ streaming: streaming(rawClient),
60
+ webhookHandler: webhookHandler(serverEndpoints.keys.webhooks.public),
61
+ };
62
+ };
@@ -0,0 +1,4 @@
1
+ import { BodyType, ParametersType, TypedNoPayloadEndpoint, TypedPayloadEndpoint } from '@openpeepshq/fetch-client';
2
+ import { SuccessFailureResponse } from '@openpeepshq/common/types';
3
+ export type OpenpeepsPayloadEndpoint<O, I extends BodyType, P extends ParametersType = undefined, Q extends ParametersType = undefined> = TypedPayloadEndpoint<O, I, SuccessFailureResponse, P, Q>;
4
+ export type OpenpeepsNoPayloadEndpoint<O, P extends ParametersType = undefined, Q extends ParametersType = undefined> = TypedNoPayloadEndpoint<O, SuccessFailureResponse, P, Q>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type WebhookData, type WebhookKeyResponse } from '@openpeepshq/common/types';
2
+ import type { OpenpeepsNoPayloadEndpoint } from '../types';
3
+ export type WebhookHandler = ((input: string) => Promise<WebhookData>);
4
+ export declare const webhookHandler: (publicKeyEndpoint: OpenpeepsNoPayloadEndpoint<WebhookKeyResponse>) => WebhookHandler;
@@ -0,0 +1,27 @@
1
+ import { webhookDataSchema, } from '@openpeepshq/common/types';
2
+ import { parseJwtKeyId, verifyJwt } from '@openpeepshq/common/lib';
3
+ export const webhookHandler = (publicKeyEndpoint) => {
4
+ let publicKey = undefined;
5
+ const getPublicKey = async (kid) => {
6
+ if (!kid) {
7
+ throw new Error('Kid is required');
8
+ }
9
+ if (publicKey && publicKey === kid) {
10
+ return publicKey;
11
+ }
12
+ const result = await publicKeyEndpoint();
13
+ if ('error' in result) {
14
+ throw result.error;
15
+ }
16
+ return result.data.publicKey;
17
+ };
18
+ return (async (input) => {
19
+ const token = typeof input === 'string' ? input : input.token;
20
+ const tokenKeyId = parseJwtKeyId(token);
21
+ const verification = await verifyJwt(token, await getPublicKey(tokenKeyId));
22
+ if (!verification) {
23
+ throw new Error('Invalid webhook token');
24
+ }
25
+ return webhookDataSchema.parse(verification.payload);
26
+ });
27
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@openpeepshq/client",
3
+ "version": "0.1.36",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "dependencies": {
7
+ "validator": "^13.11.0",
8
+ "zod": "^4.4.3",
9
+ "@openpeepshq/common": "^0.1.43",
10
+ "@openpeepshq/fetch-client": "^0.1.6"
11
+ },
12
+ "main": "dist/index.js",
13
+ "types": "dist/index.d.ts",
14
+ "exports": {
15
+ ".": "./dist/index.js",
16
+ "./*": "./dist/*/index.js"
17
+ },
18
+ "files": [
19
+ "/dist"
20
+ ],
21
+ "devDependencies": {
22
+ "@types/validator": "^13.11.9",
23
+ "@typescript-eslint/eslint-plugin": "^8.19.0",
24
+ "@typescript-eslint/parser": "^8.19.0",
25
+ "concurrently": "^9.1.2",
26
+ "eslint": "^9.17.0",
27
+ "i18next": "^24.2.3",
28
+ "livekit-client": "^2.19.2",
29
+ "prettier": "^3.4.2",
30
+ "tsc-alias": "^1.8.10",
31
+ "typescript": "^5.7.2"
32
+ },
33
+ "scripts": {
34
+ "lint": "prettier --check . && ESLINT_USE_FLAT_CONFIG=false eslint .",
35
+ "format": "prettier --write .",
36
+ "clean": "rm -rf tsconfig.tsbuildinfo dist",
37
+ "build": "tsc && tsc-alias",
38
+ "build:watch": "tsc && tsc-alias && (concurrently \"tsc -w\" \"tsc-alias -w\")"
39
+ }
40
+ }