@contentcredits/sdk 2.3.0 → 2.4.0

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.
@@ -1,19 +1,19 @@
1
1
  import type { AuthorizationResponseData, PurchaseResponseData } from '../types/index.js';
2
2
  type AuthResponseHandler = (data: AuthorizationResponseData) => void;
3
3
  type PurchaseResponseHandler = (data: PurchaseResponseData) => void;
4
- export declare function createExtensionBridge(): {
5
- attach: () => void;
6
- detach: () => void;
7
- requestAuthorization: (articleId: string, hostName: string) => void;
8
- requestPurchase: (params: {
4
+ export interface ExtensionBridge {
5
+ attach(): void;
6
+ detach(): void;
7
+ requestAuthorization(articleId: string, hostName: string): void;
8
+ requestPurchase(params: {
9
9
  articleId: string;
10
10
  hostName: string;
11
11
  location: string;
12
12
  title: string;
13
- }) => void;
14
- requestLogin: (hostName: string) => void;
15
- onAuthorizationResponse: (handler: AuthResponseHandler) => void;
16
- onPurchaseResponse: (handler: PurchaseResponseHandler) => void;
17
- };
18
- export type ExtensionBridge = ReturnType<typeof createExtensionBridge>;
13
+ }): void;
14
+ requestLogin(hostName: string): void;
15
+ onAuthorizationResponse(handler: AuthResponseHandler): void;
16
+ onPurchaseResponse(handler: PurchaseResponseHandler): void;
17
+ }
18
+ export declare function createExtensionBridge(): ExtensionBridge;
19
19
  export {};
package/dist/index.d.ts CHANGED
@@ -97,6 +97,13 @@ export declare class ContentCredits {
97
97
  closeComments(): void;
98
98
  /** Check if the user is currently authenticated. */
99
99
  isLoggedIn(): boolean;
100
+ /**
101
+ * Log the current user out.
102
+ *
103
+ * Revokes the refresh token on the server (best-effort), clears all local
104
+ * auth state, resets SDK state, and emits `auth:logout`.
105
+ */
106
+ logout(): Promise<void>;
100
107
  /** Tear down the SDK — removes all UI, event listeners, and stored state. */
101
108
  destroy(): void;
102
109
  /** SDK version string. */
@@ -3,11 +3,12 @@ import type { createCreditsApi } from '../api/credits.js';
3
3
  import type { StateStore } from '../core/state.js';
4
4
  import type { EventEmitter } from '../core/events.js';
5
5
  import type { ResolvedConfig } from '../types/index.js';
6
- export declare function createPaywall(config: ResolvedConfig, creditsApi: ReturnType<typeof createCreditsApi>, state: StateStore, emitter: EventEmitter, existingGate?: Gate): {
7
- init: () => Promise<void>;
8
- checkAccess: () => Promise<void>;
9
- destroy: () => void;
10
- login: () => Promise<void>;
11
- purchase: () => Promise<void>;
12
- buyMoreCredits: () => void;
13
- };
6
+ export interface PaywallModule {
7
+ init(): Promise<void>;
8
+ checkAccess(): Promise<void>;
9
+ destroy(): void;
10
+ login(): Promise<void>;
11
+ purchase(): Promise<void>;
12
+ buyMoreCredits(): void;
13
+ }
14
+ export declare function createPaywall(config: ResolvedConfig, creditsApi: ReturnType<typeof createCreditsApi>, state: StateStore, emitter: EventEmitter, existingGate?: Gate): PaywallModule;
@@ -1,16 +1,17 @@
1
1
  import type { ResolvedConfig } from '../types/index.js';
2
2
  export type PaywallUIState = 'checking' | 'login' | 'purchase' | 'insufficient' | 'loading' | 'granted';
3
3
  export interface PaywallRendererCallbacks {
4
- onLogin(): void;
5
- onPurchase(): void;
4
+ onLogin(): void | Promise<void>;
5
+ onPurchase(): void | Promise<void>;
6
6
  onBuyMoreCredits(): void;
7
7
  }
8
- export declare function createPaywallRenderer(config: ResolvedConfig): {
9
- init: () => void;
10
- render: (state: PaywallUIState, callbacks: PaywallRendererCallbacks, meta?: {
8
+ export interface PaywallRenderer {
9
+ init(): void;
10
+ render(state: PaywallUIState, callbacks: PaywallRendererCallbacks, meta?: {
11
11
  requiredCredits?: number | null;
12
12
  creditBalance?: number | null;
13
- }) => void;
14
- setButtonLoading: (loading: boolean) => void;
15
- destroy: () => void;
16
- };
13
+ }): void;
14
+ setButtonLoading(loading: boolean): void;
15
+ destroy(): void;
16
+ }
17
+ export declare function createPaywallRenderer(config: ResolvedConfig): PaywallRenderer;
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@contentcredits/sdk",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Content Credits JS SDK — drop-in paywall and comments for any website",
5
5
  "author": "Content Credits",
6
6
  "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/content-credits/sdk.git"
10
+ },
7
11
  "main": "dist/content-credits.cjs.js",
8
12
  "module": "dist/content-credits.esm.js",
9
13
  "browser": "dist/content-credits.umd.min.js",
@@ -35,6 +39,7 @@
35
39
  "devDependencies": {
36
40
  "@rollup/plugin-node-resolve": "^15.2.3",
37
41
  "@rollup/plugin-replace": "^5.0.5",
42
+ "@rollup/plugin-terser": "^0.4.4",
38
43
  "@rollup/plugin-typescript": "^11.1.6",
39
44
  "@types/node": "^20.11.5",
40
45
  "@typescript-eslint/eslint-plugin": "^6.19.1",
@@ -44,7 +49,6 @@
44
49
  "jsdom": "^24.0.0",
45
50
  "rollup": "^4.9.6",
46
51
  "rollup-plugin-dts": "^6.1.0",
47
- "rollup-plugin-terser": "^7.0.2",
48
52
  "tslib": "^2.6.2",
49
53
  "typescript": "^5.3.3",
50
54
  "vitest": "^1.2.2"