ppussh 0.1.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.
Files changed (46) hide show
  1. package/README.md +192 -0
  2. package/dist/accounts/index.d.ts +4 -0
  3. package/dist/accounts/index.d.ts.map +1 -0
  4. package/dist/accounts/index.js +8 -0
  5. package/dist/accounts/index.js.map +1 -0
  6. package/dist/accounts/namespace.d.ts +164 -0
  7. package/dist/accounts/namespace.d.ts.map +1 -0
  8. package/dist/accounts/namespace.js +293 -0
  9. package/dist/accounts/namespace.js.map +1 -0
  10. package/dist/accounts/types.d.ts +81 -0
  11. package/dist/accounts/types.d.ts.map +1 -0
  12. package/dist/accounts/types.js +14 -0
  13. package/dist/accounts/types.js.map +1 -0
  14. package/dist/client.d.ts +67 -0
  15. package/dist/client.d.ts.map +1 -0
  16. package/dist/client.js +81 -0
  17. package/dist/client.js.map +1 -0
  18. package/dist/errors.d.ts +81 -0
  19. package/dist/errors.d.ts.map +1 -0
  20. package/dist/errors.js +94 -0
  21. package/dist/errors.js.map +1 -0
  22. package/dist/http.d.ts +30 -0
  23. package/dist/http.d.ts.map +1 -0
  24. package/dist/http.js +169 -0
  25. package/dist/http.js.map +1 -0
  26. package/dist/index.d.ts +47 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +58 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/payments/index.d.ts +3 -0
  31. package/dist/payments/index.d.ts.map +1 -0
  32. package/dist/payments/index.js +6 -0
  33. package/dist/payments/index.js.map +1 -0
  34. package/dist/payments/namespace.d.ts +146 -0
  35. package/dist/payments/namespace.d.ts.map +1 -0
  36. package/dist/payments/namespace.js +229 -0
  37. package/dist/payments/namespace.js.map +1 -0
  38. package/dist/payments/types.d.ts +98 -0
  39. package/dist/payments/types.d.ts.map +1 -0
  40. package/dist/payments/types.js +10 -0
  41. package/dist/payments/types.js.map +1 -0
  42. package/dist/webhooks.d.ts +56 -0
  43. package/dist/webhooks.d.ts.map +1 -0
  44. package/dist/webhooks.js +67 -0
  45. package/dist/webhooks.js.map +1 -0
  46. package/package.json +54 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../src/accounts/namespace.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,mCAQiB;AAEjB,MAAa,iBAAiB;IAU5B,YACE,SAAwB,EACxB,OAAwE;QANlE,iBAAY,GAAkB,IAAI,CAAC;QACnC,kBAAa,GAAkB,IAAI,CAAC;QACpC,oBAAe,GAAgB,IAAI,CAAC;QAM1C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAC1C,CAAC;IAED,8EAA8E;IAE9E;;;;;;;;;;;;;;OAcG;IACH,aAAa,CACX,WAAmB,EACnB,KAAa,EACb,IAA2B;QAE3B,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,WAAW;YACzB,KAAK;SACN,CAAC,CAAC;QACH,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC;YAClB,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,GAAG,IAAI,CAAC,YAAY,UAAU,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC3D,CAAC;IAED,8EAA8E;IAE9E;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,YAAY,CAAC,IAAY,EAAE,WAAmB;QAClD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE;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,IAAI,IAAI,CAAC,YAAY,CAAC;QACpD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,oBAAoB,EAAE;YACrE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,UAAU,EAAE,EAAE;SACnD,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAyB,CAAC;IAC5C,CAAC;IAED,8EAA8E;IAEtE,YAAY,CAAC,KAAoB;QACvC,IAAI,CAAC,YAAY,GAAG,IAAA,4BAAoB,EAAC,KAAK,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACxE,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC9B,CAAC;IAED,iDAAiD;IACjD,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,kDAAkD;IAClD,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,mEAAmE;IACnE,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CACF;AAtTD,8CAsTC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * TypeScript interfaces for every response shape returned by the Accounts service.
3
+ *
4
+ * Mirror of the Python SDK's accounts/models.py — kept in sync manually.
5
+ */
6
+ /** Minimal user profile embedded inside a TokenResponse. */
7
+ export interface UserInToken {
8
+ id: string;
9
+ email: string;
10
+ name: string | null;
11
+ email_verified: boolean;
12
+ picture_url: string | null;
13
+ is_superuser: boolean;
14
+ }
15
+ /**
16
+ * Response from POST /oauth/token (both grant types).
17
+ *
18
+ * Exactly one of access_token / admin_access_token is populated:
19
+ * - Regular users → access_token is set, admin_access_token is null.
20
+ * - Superusers → admin_access_token is set, access_token is null.
21
+ */
22
+ export interface TokenResponse {
23
+ access_token: string | null;
24
+ admin_access_token: string | null;
25
+ refresh_token: string;
26
+ token_type: string;
27
+ expires_in: number;
28
+ user: UserInToken;
29
+ }
30
+ /** Returns whichever access token is present (regular or admin). */
31
+ export declare function effectiveAccessToken(token: TokenResponse): string | null;
32
+ /** Response from GET /auth/verify-token. */
33
+ export interface VerifyTokenResult {
34
+ valid: boolean;
35
+ type: "access" | "admin_access";
36
+ user_id: string;
37
+ email: string;
38
+ }
39
+ /** Full user profile returned by GET /users/me. */
40
+ export interface UserProfile {
41
+ id: string;
42
+ email: string;
43
+ name: string | null;
44
+ picture_url: string | null;
45
+ is_superuser: boolean;
46
+ is_active: boolean;
47
+ is_verified: boolean;
48
+ created_at: string;
49
+ updated_at: string | null;
50
+ }
51
+ /** Response from POST /oauth/logout. */
52
+ export interface LogoutResult {
53
+ ok: boolean;
54
+ sessions_revoked: number;
55
+ products_notified: number;
56
+ }
57
+ /** Single entitlement entry from GET /users/me/entitlements. */
58
+ export interface EntitlementResponse {
59
+ product_id: string;
60
+ client_id: string;
61
+ name: string;
62
+ slug: string;
63
+ granted_at: string;
64
+ }
65
+ /** Single session entry from GET /users/me/sessions. */
66
+ export interface SessionResponse {
67
+ session_id: string;
68
+ ip_address: string | null;
69
+ user_agent: string | null;
70
+ country: string | null;
71
+ city: string | null;
72
+ region: string | null;
73
+ browser: string | null;
74
+ os: string | null;
75
+ device_type: string | null;
76
+ device_name: string | null;
77
+ created_at: string;
78
+ last_used_at: string;
79
+ is_current: boolean;
80
+ }
81
+ //# sourceMappingURL=types.d.ts.map
@@ -0,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;AACxC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAID,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // ppussh/src/accounts/types.ts
3
+ /**
4
+ * TypeScript interfaces for every response shape returned by the Accounts service.
5
+ *
6
+ * Mirror of the Python SDK's accounts/models.py — kept in sync manually.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.effectiveAccessToken = effectiveAccessToken;
10
+ /** Returns whichever access token is present (regular or admin). */
11
+ function effectiveAccessToken(token) {
12
+ return token.access_token ?? token.admin_access_token;
13
+ }
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/accounts/types.ts"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B;;;;GAIG;;AA+BH,oDAEC;AAHD,oEAAoE;AACpE,SAAgB,oBAAoB,CAAC,KAAoB;IACvD,OAAO,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,kBAAkB,CAAC;AACxD,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * PpusshClient — the unified entry point for the PPUSSH Ecosystem TypeScript SDK.
3
+ *
4
+ * URL resolution order (highest → lowest priority):
5
+ * 1. Explicit constructor option (accountsUrl, paymentsUrl)
6
+ * 2. Environment variable (PPUSSH_ACCOUNTS_URL, PPUSSH_PAYMENTS_URL)
7
+ *
8
+ * Both URLs are **required** — an Error is thrown at construction time if
9
+ * neither a constructor option nor an env var is present for a given service.
10
+ *
11
+ * Usage — minimal:
12
+ *
13
+ * import { PpusshClient } from "ppussh";
14
+ *
15
+ * const client = new PpusshClient({
16
+ * clientId: "your-product-client-id",
17
+ * clientSecret: "your-product-client-secret",
18
+ * paymentsAdminKey: "your-payments-admin-key", // optional
19
+ * });
20
+ *
21
+ * // OIDC callback handler (e.g. Express / Fastify route)
22
+ * const token = await client.accounts.exchangeCode(code, redirectUri);
23
+ *
24
+ * // Token verification middleware
25
+ * const result = await client.accounts.verifyToken(bearerToken);
26
+ *
27
+ * // Billing
28
+ * const customer = await client.payments.createCustomer(token.user.id);
29
+ */
30
+ import { AccountsNamespace } from "./accounts/namespace";
31
+ import { PaymentsNamespace } from "./payments/namespace";
32
+ export interface PpusshClientOptions {
33
+ /** Your product's client_id UUID (from the Accounts admin console). */
34
+ clientId: string;
35
+ /** Your product's client_secret. Server-side only — never expose in browser code. */
36
+ clientSecret: string;
37
+ /**
38
+ * Static admin API key for the Payments service.
39
+ * Required for payments.listPlans(), getMrr(), getProductByAccountsId().
40
+ */
41
+ paymentsAdminKey?: string;
42
+ /**
43
+ * Accounts service base URL. Falls back to the PPUSSH_ACCOUNTS_URL env var.
44
+ * Required — one of the two must be set.
45
+ */
46
+ accountsUrl?: string;
47
+ /**
48
+ * Payments service base URL. Falls back to the PPUSSH_PAYMENTS_URL env var.
49
+ * Required — one of the two must be set.
50
+ */
51
+ paymentsUrl?: string;
52
+ }
53
+ export declare class PpusshClient {
54
+ readonly accounts: AccountsNamespace;
55
+ readonly payments: PaymentsNamespace;
56
+ private readonly _accountsUrl;
57
+ private readonly _paymentsUrl;
58
+ private readonly _accountsTransport;
59
+ private readonly _paymentsTransport;
60
+ constructor(options: PpusshClientOptions);
61
+ /** Resolved Accounts service base URL. */
62
+ get accountsUrl(): string;
63
+ /** Resolved Payments service base URL. */
64
+ get paymentsUrl(): string;
65
+ toString(): string;
66
+ }
67
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAiBzD,MAAM,WAAW,mBAAmB;IAClC,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,YAAY;IACvB,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAErC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAgB;IACnD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAgB;gBAEvC,OAAO,EAAE,mBAAmB;IAqBxC,0CAA0C;IAC1C,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,0CAA0C;IAC1C,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,QAAQ,IAAI,MAAM;CAGnB"}
package/dist/client.js ADDED
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ // ppussh/src/client.ts
3
+ /**
4
+ * PpusshClient — the unified entry point for the PPUSSH Ecosystem TypeScript SDK.
5
+ *
6
+ * URL resolution order (highest → lowest priority):
7
+ * 1. Explicit constructor option (accountsUrl, paymentsUrl)
8
+ * 2. Environment variable (PPUSSH_ACCOUNTS_URL, PPUSSH_PAYMENTS_URL)
9
+ *
10
+ * Both URLs are **required** — an Error is thrown at construction time if
11
+ * neither a constructor option nor an env var is present for a given service.
12
+ *
13
+ * Usage — minimal:
14
+ *
15
+ * import { PpusshClient } from "ppussh";
16
+ *
17
+ * const client = new PpusshClient({
18
+ * clientId: "your-product-client-id",
19
+ * clientSecret: "your-product-client-secret",
20
+ * paymentsAdminKey: "your-payments-admin-key", // optional
21
+ * });
22
+ *
23
+ * // OIDC callback handler (e.g. Express / Fastify route)
24
+ * const token = await client.accounts.exchangeCode(code, redirectUri);
25
+ *
26
+ * // Token verification middleware
27
+ * const result = await client.accounts.verifyToken(bearerToken);
28
+ *
29
+ * // Billing
30
+ * const customer = await client.payments.createCustomer(token.user.id);
31
+ */
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.PpusshClient = void 0;
34
+ const namespace_1 = require("./accounts/namespace");
35
+ const http_1 = require("./http");
36
+ const namespace_2 = require("./payments/namespace");
37
+ // ── Environment variable names ───────────────────────────────────────────────
38
+ const ENV_ACCOUNTS_URL = "PPUSSH_ACCOUNTS_URL";
39
+ const ENV_PAYMENTS_URL = "PPUSSH_PAYMENTS_URL";
40
+ function resolveUrl(kwarg, envVar, label) {
41
+ if (kwarg)
42
+ return kwarg.replace(/\/$/, "");
43
+ const envVal = typeof process !== "undefined" ? process.env[envVar] : undefined;
44
+ if (envVal)
45
+ return envVal.replace(/\/$/, "");
46
+ throw new Error(`${label} URL is required. ` +
47
+ `Pass it as a constructor option or set the ${envVar} environment variable.`);
48
+ }
49
+ class PpusshClient {
50
+ constructor(options) {
51
+ if (!options.clientId)
52
+ throw new Error("clientId must not be empty.");
53
+ if (!options.clientSecret)
54
+ throw new Error("clientSecret must not be empty.");
55
+ this._accountsUrl = resolveUrl(options.accountsUrl, ENV_ACCOUNTS_URL, "Accounts");
56
+ this._paymentsUrl = resolveUrl(options.paymentsUrl, ENV_PAYMENTS_URL, "Payments");
57
+ this._accountsTransport = new http_1.HttpTransport(this._accountsUrl);
58
+ this._paymentsTransport = new http_1.HttpTransport(this._paymentsUrl);
59
+ this.accounts = new namespace_1.AccountsNamespace(this._accountsTransport, {
60
+ clientId: options.clientId,
61
+ clientSecret: options.clientSecret,
62
+ accountsUrl: this._accountsUrl,
63
+ });
64
+ this.payments = new namespace_2.PaymentsNamespace(this._paymentsTransport, {
65
+ adminKey: options.paymentsAdminKey,
66
+ });
67
+ }
68
+ /** Resolved Accounts service base URL. */
69
+ get accountsUrl() {
70
+ return this._accountsUrl;
71
+ }
72
+ /** Resolved Payments service base URL. */
73
+ get paymentsUrl() {
74
+ return this._paymentsUrl;
75
+ }
76
+ toString() {
77
+ return `PpusshClient(accountsUrl=${this._accountsUrl}, paymentsUrl=${this._paymentsUrl})`;
78
+ }
79
+ }
80
+ exports.PpusshClient = PpusshClient;
81
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,uBAAuB;AACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH,oDAAyD;AACzD,iCAAuC;AACvC,oDAAyD;AAEzD,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,q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E,OAAO,CAAC,YAAY;YAClC,WAAW,EAAE,IAAI,CAAC,YAAY;SAC/B,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,GAAG,IAAI,6BAAiB,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC7D,QAAQ,EAAE,OAAO,CAAC,gBAAgB;SACnC,CAAC,CAAC;IACL,CAAC;IAED,0CAA0C;IAC1C,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,0CAA0C;IAC1C,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,OAAO,4BAA4B,IAAI,CAAC,YAAY,iBAAiB,IAAI,CAAC,YAAY,GAAG,CAAC;IAC5F,CAAC;CACF;AA3CD,oCA2CC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Typed exception hierarchy for the PPUSSH TypeScript SDK.
3
+ *
4
+ * All errors carry the raw HTTP status and response body so callers
5
+ * can inspect them without parsing generic message strings.
6
+ *
7
+ * Hierarchy:
8
+ * PpusshError ← base; always catch this for a catch-all
9
+ * ├── PpusshAuthError ← 401 from any endpoint
10
+ * ├── PpusshConsentRequired ← 403 with status="CONSENT_REQUIRED"
11
+ * ├── PpusshPaymentError ← non-2xx from the Payments service
12
+ * └── PpusshNetworkError ← all retries exhausted / connection error
13
+ */
14
+ export declare class PpusshError extends Error {
15
+ readonly statusCode: number | null;
16
+ readonly responseBody: unknown;
17
+ constructor(message: string, options?: {
18
+ statusCode?: number | null;
19
+ responseBody?: unknown;
20
+ });
21
+ }
22
+ /**
23
+ * Raised on 401 responses from any PPUSSH endpoint.
24
+ *
25
+ * Common causes:
26
+ * - Invalid or expired access token passed to verifyToken()
27
+ * - Bad client_secret during exchangeCode() / refresh() / logout()
28
+ * - Authorization code already used or expired
29
+ * - Refresh token replayed (all sessions are revoked server-side)
30
+ */
31
+ export declare class PpusshAuthError extends PpusshError {
32
+ constructor(message: string, options?: {
33
+ statusCode?: number | null;
34
+ responseBody?: unknown;
35
+ });
36
+ }
37
+ /**
38
+ * Raised when the Accounts service returns HTTP 403 with
39
+ * `status = "CONSENT_REQUIRED"`.
40
+ *
41
+ * The user has not granted consent for your product. Redirect the user
42
+ * to the Accounts consent screen.
43
+ */
44
+ export declare class PpusshConsentRequired extends PpusshError {
45
+ readonly clientId: string;
46
+ readonly productName: string;
47
+ readonly productDescription: string;
48
+ constructor(message: string, options?: {
49
+ clientId?: string;
50
+ productName?: string;
51
+ productDescription?: string;
52
+ statusCode?: number | null;
53
+ responseBody?: unknown;
54
+ });
55
+ }
56
+ /**
57
+ * Raised on non-2xx responses from the Payments service.
58
+ *
59
+ * `code` is the machine-readable error code from the Payments API
60
+ * (e.g. "customer_not_found", "provider_unavailable").
61
+ */
62
+ export declare class PpusshPaymentError extends PpusshError {
63
+ readonly code: string | null;
64
+ constructor(message: string, options?: {
65
+ code?: string | null;
66
+ statusCode?: number | null;
67
+ responseBody?: unknown;
68
+ });
69
+ }
70
+ /**
71
+ * Raised when all retry attempts are exhausted or a connection-level
72
+ * error occurs (refused connection, DNS failure, timeout).
73
+ */
74
+ export declare class PpusshNetworkError extends PpusshError {
75
+ constructor(message: string, options?: {
76
+ statusCode?: number | null;
77
+ responseBody?: unknown;
78
+ cause?: unknown;
79
+ });
80
+ }
81
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;AAEH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;gBAG7B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO;CASv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 * Typed exception hierarchy for the PPUSSH TypeScript SDK.
5
+ *
6
+ * All errors carry the raw HTTP status and response body so callers
7
+ * can inspect them without parsing generic message strings.
8
+ *
9
+ * Hierarchy:
10
+ * PpusshError ← base; always catch this for a catch-all
11
+ * ├── PpusshAuthError ← 401 from any endpoint
12
+ * ├── PpusshConsentRequired ← 403 with status="CONSENT_REQUIRED"
13
+ * ├── PpusshPaymentError ← non-2xx from the Payments service
14
+ * └── PpusshNetworkError ← all retries exhausted / connection error
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PpusshNetworkError = exports.PpusshPaymentError = exports.PpusshConsentRequired = exports.PpusshAuthError = exports.PpusshError = void 0;
18
+ class PpusshError extends Error {
19
+ constructor(message, options = {}) {
20
+ super(message);
21
+ this.name = "PpusshError";
22
+ this.statusCode = options.statusCode ?? null;
23
+ this.responseBody = options.responseBody ?? null;
24
+ // Maintain proper prototype chain in transpiled ES5 output
25
+ Object.setPrototypeOf(this, new.target.prototype);
26
+ }
27
+ }
28
+ exports.PpusshError = PpusshError;
29
+ /**
30
+ * Raised on 401 responses from any PPUSSH endpoint.
31
+ *
32
+ * Common causes:
33
+ * - Invalid or expired access token passed to verifyToken()
34
+ * - Bad client_secret during exchangeCode() / refresh() / logout()
35
+ * - Authorization code already used or expired
36
+ * - Refresh token replayed (all sessions are revoked server-side)
37
+ */
38
+ class PpusshAuthError extends PpusshError {
39
+ constructor(message, options = {}) {
40
+ super(message, { statusCode: options.statusCode ?? 401, ...options });
41
+ this.name = "PpusshAuthError";
42
+ Object.setPrototypeOf(this, new.target.prototype);
43
+ }
44
+ }
45
+ exports.PpusshAuthError = PpusshAuthError;
46
+ /**
47
+ * Raised when the Accounts service returns HTTP 403 with
48
+ * `status = "CONSENT_REQUIRED"`.
49
+ *
50
+ * The user has not granted consent for your product. Redirect the user
51
+ * to the Accounts consent screen.
52
+ */
53
+ class PpusshConsentRequired extends PpusshError {
54
+ constructor(message, options = {}) {
55
+ super(message, { statusCode: options.statusCode ?? 403, responseBody: options.responseBody });
56
+ this.name = "PpusshConsentRequired";
57
+ this.clientId = options.clientId ?? "";
58
+ this.productName = options.productName ?? "";
59
+ this.productDescription = options.productDescription ?? "";
60
+ Object.setPrototypeOf(this, new.target.prototype);
61
+ }
62
+ }
63
+ exports.PpusshConsentRequired = PpusshConsentRequired;
64
+ /**
65
+ * Raised on non-2xx responses from the Payments service.
66
+ *
67
+ * `code` is the machine-readable error code from the Payments API
68
+ * (e.g. "customer_not_found", "provider_unavailable").
69
+ */
70
+ class PpusshPaymentError extends PpusshError {
71
+ constructor(message, options = {}) {
72
+ super(message, { statusCode: options.statusCode, responseBody: options.responseBody });
73
+ this.name = "PpusshPaymentError";
74
+ this.code = options.code ?? null;
75
+ Object.setPrototypeOf(this, new.target.prototype);
76
+ }
77
+ }
78
+ exports.PpusshPaymentError = PpusshPaymentError;
79
+ /**
80
+ * Raised when all retry attempts are exhausted or a connection-level
81
+ * error occurs (refused connection, DNS failure, timeout).
82
+ */
83
+ class PpusshNetworkError extends PpusshError {
84
+ constructor(message, options = {}) {
85
+ super(message, { statusCode: options.statusCode, responseBody: options.responseBody });
86
+ this.name = "PpusshNetworkError";
87
+ if (options.cause) {
88
+ this.cause = options.cause;
89
+ }
90
+ Object.setPrototypeOf(this, new.target.prototype);
91
+ }
92
+ }
93
+ exports.PpusshNetworkError = PpusshNetworkError;
94
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,uBAAuB;AACvB;;;;;;;;;;;;GAYG;;;AAEH,MAAa,WAAY,SAAQ,KAAK;IAIpC,YACE,OAAe,EACf,UAAkE,EAAE;QAEpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC;QAC7C,I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AC,OAAO,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QACvF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;QACjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAhBD,gDAgBC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,WAAW;IACjD,YACE,OAAe,EACf,UAAmF,EAAE;QAErF,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QACvF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACjB,IAA4B,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QACtD,CAAC;QACD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAZD,gDAYC"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shared HTTP transport layer for the PPUSSH TypeScript SDK.
3
+ *
4
+ * Responsibilities:
5
+ * - Owns an Axios instance per base URL.
6
+ * - Implements the retry policy:
7
+ * 5xx errors → up to MAX_RETRIES attempts, exponential back-off (500ms, 1s, 2s).
8
+ * 429 → respects Retry-After header; falls back to 1s default.
9
+ * 4xx (≠ 429) → never retried; raised immediately.
10
+ * Network errors → treated like 5xx for retry purposes.
11
+ * - Raises typed PpusshError subclasses; callers never see raw Axios errors.
12
+ */
13
+ import { AxiosResponse } from "axios";
14
+ export interface RequestOptions {
15
+ headers?: Record<string, string>;
16
+ /** JSON body */
17
+ json?: unknown;
18
+ /** Form-encoded body (application/x-www-form-urlencoded) */
19
+ form?: Record<string, string>;
20
+ /** Query string parameters */
21
+ params?: Record<string, string | number | boolean | undefined>;
22
+ /** Set to true when calling the Payments service for correct error parsing */
23
+ isPayments?: boolean;
24
+ }
25
+ export declare class HttpTransport {
26
+ private readonly _client;
27
+ constructor(baseUrl: string);
28
+ request(method: string, path: string, options?: RequestOptions): Promise<AxiosResponse>;
29
+ }
30
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;GAWG;AAEH,OAAc,EAGZ,aAAa,EAEd,MAAM,OAAO,CAAC;AAgGf,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,gBAAgB;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC/D,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAID,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;gBAE5B,OAAO,EAAE,MAAM;IAarB,OAAO,CACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC;CAsF1B"}