@contentcredits/sdk 2.3.0 → 2.5.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.
- package/dist/api/client.d.ts +7 -7
- package/dist/api/comments.d.ts +3 -2
- package/dist/api/credits.d.ts +3 -2
- package/dist/comments/index.d.ts +7 -6
- package/dist/comments/panel.d.ts +6 -5
- package/dist/content-credits.cjs.js +67 -20
- package/dist/content-credits.cjs.js.map +1 -1
- package/dist/content-credits.d.ts +16 -0
- package/dist/content-credits.esm.js +67 -20
- package/dist/content-credits.esm.js.map +1 -1
- package/dist/content-credits.umd.min.js +1 -1
- package/dist/content-credits.umd.min.js.map +1 -1
- package/dist/core/events.d.ts +7 -7
- package/dist/core/state.d.ts +8 -8
- package/dist/extension/bridge.d.ts +11 -11
- package/dist/index.d.ts +16 -0
- package/dist/paywall/index.d.ts +9 -8
- package/dist/paywall/renderer.d.ts +10 -9
- package/package.json +6 -2
|
@@ -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
|
|
5
|
-
attach
|
|
6
|
-
detach
|
|
7
|
-
requestAuthorization
|
|
8
|
-
requestPurchase
|
|
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
|
-
})
|
|
14
|
-
requestLogin
|
|
15
|
-
onAuthorizationResponse
|
|
16
|
-
onPurchaseResponse
|
|
17
|
-
}
|
|
18
|
-
export
|
|
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,22 @@ export declare class ContentCredits {
|
|
|
97
97
|
closeComments(): void;
|
|
98
98
|
/** Check if the user is currently authenticated. */
|
|
99
99
|
isLoggedIn(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Return the current access token, or null if not authenticated.
|
|
102
|
+
*
|
|
103
|
+
* Use this to call your own server-side API routes that need to verify
|
|
104
|
+
* the user's identity with the Content Credits API before returning
|
|
105
|
+
* protected content — avoids ever sending premium content to the browser
|
|
106
|
+
* before access is confirmed.
|
|
107
|
+
*/
|
|
108
|
+
getToken(): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Log the current user out.
|
|
111
|
+
*
|
|
112
|
+
* Revokes the refresh token on the server (best-effort), clears all local
|
|
113
|
+
* auth state, resets SDK state, and emits `auth:logout`.
|
|
114
|
+
*/
|
|
115
|
+
logout(): Promise<void>;
|
|
100
116
|
/** Tear down the SDK — removes all UI, event listeners, and stored state. */
|
|
101
117
|
destroy(): void;
|
|
102
118
|
/** SDK version string. */
|
package/dist/paywall/index.d.ts
CHANGED
|
@@ -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
|
|
7
|
-
init
|
|
8
|
-
checkAccess
|
|
9
|
-
destroy
|
|
10
|
-
login
|
|
11
|
-
purchase
|
|
12
|
-
buyMoreCredits
|
|
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
|
|
9
|
-
init
|
|
10
|
-
render
|
|
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
|
-
})
|
|
14
|
-
setButtonLoading
|
|
15
|
-
destroy
|
|
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
|
+
"version": "2.5.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"
|