@stacksjs/socials 0.75.528 → 0.75.535

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.
@@ -49,6 +49,7 @@ export declare interface AppleIdentityOptions {
49
49
  * job; `SocialUser.name` from this driver is therefore always ''.
50
50
  */
51
51
  export declare class AppleProvider extends AbstractProvider implements ProviderInterface {
52
+ /** @defaultValue 'https://appleid.apple.com' */
52
53
  protected baseUrl: string;
53
54
  protected teamId: string;
54
55
  protected keyId: string;
@@ -27,6 +27,7 @@ export declare class BlueskyApiError extends Error {
27
27
  }
28
28
  export declare class BlueskyPublishingDriver implements SocialPublishingDriver, SocialDeletionDriver {
29
29
  readonly provider: 'bluesky';
30
+ /** @defaultValue 300 */
30
31
  characterLimit: number;
31
32
  protected service: string;
32
33
  constructor(options?: BlueskyDriverOptions);
@@ -1,7 +1,9 @@
1
1
  import { AbstractProvider } from '../abstract';
2
2
  import type { ProviderInterface, SocialUser } from '../types';
3
3
  export declare class FacebookProvider extends AbstractProvider implements ProviderInterface {
4
+ /** @defaultValue 'https://www.facebook.com' */
4
5
  protected baseUrl: string;
6
+ /** @defaultValue 'https://graph.facebook.com' */
5
7
  protected apiUrl: string;
6
8
  protected get graphVersion(): string;
7
9
  private getConfig;
@@ -1,7 +1,9 @@
1
1
  import { AbstractProvider } from '../abstract';
2
2
  import type { GitHubEmail, ProviderInterface, SocialUser } from '../types';
3
3
  export declare class GitHubProvider extends AbstractProvider implements ProviderInterface {
4
+ /** @defaultValue 'https://github.com' */
4
5
  protected baseUrl: string;
6
+ /** @defaultValue 'https://api.github.com' */
5
7
  protected apiUrl: string;
6
8
  private getConfig;
7
9
  getAuthUrl(): Promise<string>;
@@ -1,10 +1,28 @@
1
1
  import { AbstractProvider } from '../abstract';
2
2
  import type { ProviderInterface, SocialUser } from '../types';
3
3
  export declare class GoogleProvider extends AbstractProvider implements ProviderInterface {
4
+ /** @defaultValue 'https://accounts.google.com' */
4
5
  protected baseUrl: string;
6
+ /** @defaultValue 'https://www.googleapis.com' */
5
7
  protected apiUrl: string;
8
+ /**
9
+ * The documented token endpoint. `accounts.google.com/oauth2/v4/token` still
10
+ * answers, but it has not been the documented one for years, and an
11
+ * undocumented endpoint is the kind that goes without notice
12
+ * (stacksjs/stacks#2859). One constant, so the exchange and
13
+ * `getTokenUrl()` cannot disagree.
14
+ * @defaultValue 'https://oauth2.googleapis.com/token'
15
+ */
6
16
  protected tokenUrl: string;
17
+ /**
18
+ * Where an access token is traded for the client it was issued to.
19
+ * @defaultValue 'https://oauth2.googleapis.com/tokeninfo'
20
+ */
7
21
  protected tokenInfoUrl: string;
22
+ /**
23
+ * Google's published id_token signing keys.
24
+ * @defaultValue 'https://www.googleapis.com/oauth2/v3/certs'
25
+ */
8
26
  protected certsUrl: string;
9
27
  protected issuers: unknown[];
10
28
  private getConfig;
@@ -37,6 +37,7 @@ export declare class InstagramApiError extends Error {
37
37
  */
38
38
  export declare class InstagramPublishingDriver implements SocialPublishingDriver {
39
39
  readonly provider: 'instagram';
40
+ /** @defaultValue 2200 */
40
41
  characterLimit: number;
41
42
  protected graphVersion: string;
42
43
  protected authBase: string;
@@ -48,6 +48,7 @@ export declare class LinkedInApiError extends Error {
48
48
  */
49
49
  export declare class LinkedInPublishingDriver implements SocialPublishingDriver, SocialDeletionDriver {
50
50
  readonly provider: 'linkedin';
51
+ /** @defaultValue 3000 */
51
52
  characterLimit: number;
52
53
  protected apiVersion: string;
53
54
  protected authBase: string;
@@ -26,6 +26,10 @@ export declare class MastodonApiError extends Error {
26
26
  */
27
27
  export declare class MastodonPublishingDriver implements SocialPublishingDriver, SocialDeletionDriver {
28
28
  readonly provider: 'mastodon';
29
+ /**
30
+ * Mastodon's default; instances can raise it, but 500 is the safe floor.
31
+ * @defaultValue 500
32
+ */
29
33
  characterLimit: number;
30
34
  protected instanceOf(identity: SocialIdentityCredentials): string;
31
35
  protected tokenOf(identity: SocialIdentityCredentials): string;
@@ -33,6 +33,7 @@ export declare class StacksIssuerError extends Error {
33
33
  * drops it.
34
34
  */
35
35
  export declare class StacksIssuerProvider extends AbstractProvider implements ProviderInterface {
36
+ /** @defaultValue ' ' */
36
37
  protected scopeSeparator: string;
37
38
  private settings;
38
39
  constructor(config: StacksIssuerConfig);
@@ -38,6 +38,7 @@ export declare class ThreadsApiError extends Error {
38
38
  */
39
39
  export declare class ThreadsPublishingDriver implements SocialPublishingDriver {
40
40
  readonly provider: 'threads';
41
+ /** @defaultValue 500 */
41
42
  characterLimit: number;
42
43
  protected graphVersion: string;
43
44
  protected authBase: string;
@@ -34,8 +34,16 @@ export declare interface TwitterProfile {
34
34
  name?: string
35
35
  }
36
36
  export declare class TwitterProvider extends AbstractProvider implements ProviderInterface {
37
+ /** @defaultValue 'https://twitter.com' */
37
38
  protected baseUrl: string;
39
+ /** @defaultValue 'https://api.twitter.com' */
38
40
  protected apiUrl: string;
41
+ /**
42
+ * X requires PKCE on every authorization. The verifier lives in the base
43
+ // class so a callback on a fresh instance can restore it with
44
+ // withCodeVerifier(getPkceVerifier()) instead of failing the exchange.
45
+ * @defaultValue true
46
+ */
39
47
  protected _usesPKCE: boolean;
40
48
  private getConfig;
41
49
  getAuthUrl(): Promise<string>;
@@ -63,6 +71,7 @@ export declare class TwitterApiError extends Error {
63
71
  }
64
72
  export declare class TwitterPublishingDriver implements SocialPublishingDriver, SocialDeletionDriver {
65
73
  readonly provider: 'twitter';
74
+ /** @defaultValue 280 */
66
75
  characterLimit: number;
67
76
  protected apiBase: string;
68
77
  protected authorizeBase: string;
@@ -1,14 +1,4 @@
1
1
  import type { BlueskyCredentialOptions, InstagramCredentialOptions, LinkedInCredentialOptions, MastodonCredentialOptions, SocialCredentialPlatform, SocialCredentialsByPlatform, SocialIdentityOptions, ThreadsCredentialOptions, TwitterCredentialOptions } from '@stacksjs/types';
2
- /**
3
- * The environment segment for an identity name.
4
- *
5
- * `home-lang` becomes `HOMELANG`, so the variable is
6
- * `SOCIALS_HOMELANG_BLUESKY_PASSWORD`. Anything that is not a letter or digit
7
- * is dropped rather than replaced with `_`, because `HOME_LANG_BLUESKY_...`
8
- * cannot be told apart from an identity actually called `home` on a platform
9
- * called `lang`.
10
- */
11
- export declare function envSegment(identity: string): string;
12
2
  /** `SOCIALS_STACKS_BLUESKY_PASSWORD`, for the error messages and the docs. */
13
3
  export declare function envName(identity: string, platform: SocialCredentialPlatform, field: string): string;
14
4
  /**
@@ -83,22 +73,54 @@ export declare function resolveThreadsCredentials(identity?: string, env?: Recor
83
73
  * Exported so a test can hold them against the drivers rather than against
84
74
  * this file: these tables ARE the claim that a platform's credentials are
85
75
  * complete, and a claim nothing checks is a comment.
76
+ * @defaultValue
77
+ * ```ts
78
+ * {
79
+ * bluesky: ['identifier', 'password', 'service'],
80
+ * twitter: ['clientId', 'clientSecret', 'accessToken', 'refreshToken'],
81
+ * linkedin: ['accessToken', 'memberUrn', 'clientId', 'clientSecret', 'apiVersion'],
82
+ * mastodon: ['accessToken', 'instanceUrl'],
83
+ * instagram: ['accessToken', 'accountId', 'clientId', 'clientSecret'],
84
+ * threads: ['accessToken', 'userId', 'clientId', 'clientSecret'],
85
+ * } as const satisfies Record<SocialCredentialPlatform, readonly string[]>
86
+ *
87
+ * /**
88
+ * * The fields a platform cannot act without.
89
+ * *
90
+ * * Taken from what each driver's `publish()` dereferences and throws over, not
91
+ * * from what its API documents. LinkedIn, Mastodon, Instagram and Threads each
92
+ * * need a second value besides the token - the member URN, the instance, the
93
+ * * account id, the user id - because a token alone does not say where or as
94
+ * * whom to post, and each driver refuses without it.
95
+ * *
96
+ * * `clientId` and `clientSecret` are NOT required for those four: they are for
97
+ * * refreshing, and an identity with a live token posts without them. Requiring
98
+ * * them would refuse a working configuration.
99
+ * *\/
100
+ * export const REQUIRED_SOCIAL_CREDENTIALS = {
101
+ * bluesky: ['identifier', 'password'],
102
+ * twitter: ['clientId', 'clientSecret', 'accessToken'],
103
+ * linkedin: ['accessToken', 'memberUrn'],
104
+ * mastodon: ['accessToken', 'instanceUrl'],
105
+ * instagram: ['accessToken', 'accountId'],
106
+ * threads: ['accessToken', 'userId']
107
+ * }
108
+ * ```
86
109
  */
87
- export declare const SOCIAL_CREDENTIAL_FIELDS: Record<SocialCredentialPlatform, readonly string[]>;
110
+ export declare const SOCIAL_CREDENTIAL_FIELDS: Record<SocialCredentialPlatform, readonly string[]>
111
+
88
112
  /**
89
- * The fields a platform cannot act without.
90
- *
91
- * Taken from what each driver's `publish()` dereferences and throws over, not
92
- * from what its API documents. LinkedIn, Mastodon, Instagram and Threads each
93
- * need a second value besides the token - the member URN, the instance, the
94
- * account id, the user id - because a token alone does not say where or as
95
- * whom to post, and each driver refuses without it.
113
+ * The environment segment for an identity name.
96
114
  *
97
- * `clientId` and `clientSecret` are NOT required for those four: they are for
98
- * refreshing, and an identity with a live token posts without them. Requiring
99
- * them would refuse a working configuration.
115
+ * `home-lang` becomes `HOMELANG`, so the variable is
116
+ * `SOCIALS_HOMELANG_BLUESKY_PASSWORD`. Anything that is not a letter or digit
117
+ * is dropped rather than replaced with `_`, because `HOME_LANG_BLUESKY_...`
118
+ * cannot be told apart from an identity actually called `home` on a platform
119
+ * called `lang`.
100
120
  */
101
- export declare const REQUIRED_SOCIAL_CREDENTIALS: Record<SocialCredentialPlatform, readonly string[]>;
121
+ export function envSegment(identity: string): string {
122
+ return identity.toUpperCase().replace(/[^A-Z0-9]/g, '')
123
+ };
102
124
  export declare interface SocialsShape {
103
125
  default?: string
104
126
  identities?: Record<string, SocialIdentityOptions>
package/dist/publish.d.ts CHANGED
@@ -75,13 +75,25 @@ export declare function publishAs(platform: SocialCredentialPlatform, post: Publ
75
75
  * so taking one from configuration would be a second source for a value the
76
76
  * network already answers.
77
77
  * - `twitter` never reads it. Posting is scoped by the token alone.
78
+ * @defaultValue
79
+ * ```ts
80
+ * {
81
+ * linkedin: 'memberUrn',
82
+ * mastodon: 'instanceUrl',
83
+ * instagram: 'accountId',
84
+ * threads: 'userId'
85
+ * }
86
+ * ```
78
87
  */
79
- export declare const DRIVER_DID_FIELD: Record<SocialCredentialPlatform, string | null>;
88
+ export declare const DRIVER_DID_FIELD: Record<SocialCredentialPlatform, string | null>
89
+
80
90
  /** Driver constructor options that come from a credential rather than a default. */
81
- export declare interface SocialDriverOptions {
91
+ export interface SocialDriverOptions {
92
+ /** Bluesky: a PDS other than `https://bsky.social`. */
82
93
  service?: string
94
+ /** LinkedIn: the `LinkedIn-Version` this tenant is on. */
83
95
  apiVersion?: string
84
- }
96
+ };
85
97
  /** Everything needed to post as one identity on one platform. */
86
98
  export declare interface SocialPublishTarget {
87
99
  name: string
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/socials",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.528",
5
+ "version": "0.75.535",
6
6
  "description": "A simple and elegant social authentication package for Stacks.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -57,14 +57,14 @@
57
57
  "prepublishOnly": "bun run build"
58
58
  },
59
59
  "dependencies": {
60
- "@stacksjs/api": "0.75.528",
61
- "@stacksjs/composables": "0.75.528",
62
- "@stacksjs/config": "0.75.528",
63
- "@stacksjs/database": "0.75.528"
60
+ "@stacksjs/api": "0.75.535",
61
+ "@stacksjs/composables": "0.75.535",
62
+ "@stacksjs/config": "0.75.535",
63
+ "@stacksjs/database": "0.75.535"
64
64
  },
65
65
  "devDependencies": {
66
- "@stacksjs/error-handling": "0.75.528",
67
- "@stacksjs/router": "0.75.528",
66
+ "@stacksjs/error-handling": "0.75.535",
67
+ "@stacksjs/router": "0.75.535",
68
68
  "better-dx": "^0.2.24"
69
69
  }
70
70
  }