@clikgate/node 2.0.0 → 2.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 (86) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +126 -6
  3. package/SECURITY.md +2 -1
  4. package/dist/cjs/client.d.ts +54 -10
  5. package/dist/cjs/client.js +75 -16
  6. package/dist/cjs/currency.d.ts +7 -0
  7. package/dist/cjs/currency.js +75 -0
  8. package/dist/cjs/customer-id.d.ts +26 -0
  9. package/dist/cjs/customer-id.js +52 -0
  10. package/dist/cjs/enums.js +1 -1
  11. package/dist/cjs/errors.d.ts +1 -1
  12. package/dist/cjs/event-types.d.ts +108 -0
  13. package/dist/cjs/event-types.js +109 -0
  14. package/dist/cjs/express.d.ts +11 -2
  15. package/dist/cjs/express.js +3 -2
  16. package/dist/cjs/fastify.d.ts +4 -1
  17. package/dist/cjs/fastify.js +3 -2
  18. package/dist/cjs/generated/index.d.ts +2015 -83
  19. package/dist/cjs/generated/index.js +83 -3
  20. package/dist/cjs/identity.d.ts +12 -2
  21. package/dist/cjs/identity.js +37 -3
  22. package/dist/cjs/index.d.ts +11 -1
  23. package/dist/cjs/index.js +21 -1
  24. package/dist/cjs/installation.d.ts +47 -0
  25. package/dist/cjs/installation.js +83 -0
  26. package/dist/cjs/known-customers.d.ts +45 -0
  27. package/dist/cjs/known-customers.js +95 -0
  28. package/dist/cjs/lookups.d.ts +128 -0
  29. package/dist/cjs/lookups.js +149 -0
  30. package/dist/cjs/models.d.ts +342 -0
  31. package/dist/cjs/models.js +2 -0
  32. package/dist/cjs/next.d.ts +22 -0
  33. package/dist/cjs/next.js +20 -0
  34. package/dist/cjs/pager.d.ts +5 -0
  35. package/dist/cjs/pager.js +40 -0
  36. package/dist/cjs/referrals.d.ts +169 -0
  37. package/dist/cjs/referrals.js +208 -0
  38. package/dist/cjs/resources.d.ts +34 -5
  39. package/dist/cjs/resources.js +43 -42
  40. package/dist/cjs/types.d.ts +57 -10
  41. package/dist/cjs/version.d.ts +1 -1
  42. package/dist/cjs/version.js +1 -1
  43. package/dist/cjs/webhooks.d.ts +3 -2
  44. package/dist/cjs/webhooks.js +43 -2
  45. package/dist/esm/client.d.ts +54 -10
  46. package/dist/esm/client.js +75 -16
  47. package/dist/esm/currency.d.ts +7 -0
  48. package/dist/esm/currency.js +67 -0
  49. package/dist/esm/customer-id.d.ts +26 -0
  50. package/dist/esm/customer-id.js +47 -0
  51. package/dist/esm/enums.js +1 -1
  52. package/dist/esm/errors.d.ts +1 -1
  53. package/dist/esm/event-types.d.ts +108 -0
  54. package/dist/esm/event-types.js +106 -0
  55. package/dist/esm/express.d.ts +11 -2
  56. package/dist/esm/express.js +3 -2
  57. package/dist/esm/fastify.d.ts +4 -1
  58. package/dist/esm/fastify.js +3 -2
  59. package/dist/esm/generated/index.d.ts +2015 -83
  60. package/dist/esm/generated/index.js +80 -1
  61. package/dist/esm/identity.d.ts +12 -2
  62. package/dist/esm/identity.js +36 -3
  63. package/dist/esm/index.d.ts +11 -1
  64. package/dist/esm/index.js +6 -0
  65. package/dist/esm/installation.d.ts +47 -0
  66. package/dist/esm/installation.js +77 -0
  67. package/dist/esm/known-customers.d.ts +45 -0
  68. package/dist/esm/known-customers.js +90 -0
  69. package/dist/esm/lookups.d.ts +128 -0
  70. package/dist/esm/lookups.js +142 -0
  71. package/dist/esm/models.d.ts +342 -0
  72. package/dist/esm/models.js +1 -0
  73. package/dist/esm/next.d.ts +22 -0
  74. package/dist/esm/next.js +19 -0
  75. package/dist/esm/pager.d.ts +5 -0
  76. package/dist/esm/pager.js +36 -0
  77. package/dist/esm/referrals.d.ts +169 -0
  78. package/dist/esm/referrals.js +204 -0
  79. package/dist/esm/resources.d.ts +34 -5
  80. package/dist/esm/resources.js +43 -42
  81. package/dist/esm/types.d.ts +57 -10
  82. package/dist/esm/version.d.ts +1 -1
  83. package/dist/esm/version.js +1 -1
  84. package/dist/esm/webhooks.d.ts +3 -2
  85. package/dist/esm/webhooks.js +42 -2
  86. package/package.json +2 -2
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReportsApi = exports.ReferralsApi = exports.QRPlacementsApi = exports.QRDesignerApi = exports.PushCredentialsApi = exports.PrivateModeApi = exports.PrivacyApi = exports.PostLinksApi = exports.PeopleApi = exports.PaymentsApi = exports.PartnerProgrammesApi = exports.OrganizationApi = exports.OpenInAppApi = exports.MigrationApi = exports.LinksApi = exports.LeaderboardsApi = exports.JobsApi = exports.InstallsApi = exports.InboundApi = exports.IdentityApi = exports.GoogleSheetsApi = exports.GoalsApi = exports.GoalGroupsApi = exports.FunnelsApi = exports.ExportsApi = exports.EventsApi = exports.DomainsApi = exports.DomainGroupsApi = exports.DashboardsApi = exports.ConversionsApi = exports.ConversionSendingApi = exports.ConsentApi = exports.CodesApi = exports.ClicksApi = exports.ClickIDHealthApi = exports.ChartNotesApi = exports.ChallengesApi = exports.CampaignsApi = exports.AppsApi = exports.AppHooksApi = exports.AppBannersApi = exports.AppActionsApi = exports.AnalyticsDestinationsApi = exports.AnalyticsApi = exports.AlertsApi = exports.AdSpendApi = exports.AdFraudApi = exports.AdCreativesApi = exports.AdConnectionsApi = exports.ABTestsApi = void 0;
4
- exports.ApiClient = exports.WhatsAppApi = exports.WebhooksApi = exports.TargetsApi = exports.SharesApi = exports.ServerSDKsApi = exports.SalesApi = exports.SKANApi = void 0;
3
+ exports.ReferralsApi = exports.QRPlacementsApi = exports.QRDesignerApi = exports.PushCredentialsApi = exports.PrivateModeApi = exports.PrivacyApi = exports.PostLinksApi = exports.PeopleApi = exports.PaymentsApi = exports.PartnerProgrammesApi = exports.OrganizationApi = exports.OpenInAppApi = exports.MigrationApi = exports.LinksApi = exports.LeaderboardsApi = exports.KnownCustomersApi = exports.JobsApi = exports.InstallsApi = exports.InboundApi = exports.IdentityApi = exports.GoogleSheetsApi = exports.GoalsApi = exports.GoalGroupsApi = exports.FunnelsApi = exports.ExportsApi = exports.EventsApi = exports.DomainsApi = exports.DomainGroupsApi = exports.DashboardsApi = exports.ConversionsApi = exports.ConversionSendingApi = exports.ConsentApi = exports.CodesApi = exports.ClicksApi = exports.ClickIDHealthApi = exports.ChartNotesApi = exports.ChallengesApi = exports.CampaignsApi = exports.AppsApi = exports.AppHooksApi = exports.AppBannersApi = exports.AppActionsApi = exports.AnalyticsDestinationsApi = exports.AnalyticsApi = exports.AlertsApi = exports.AdSpendApi = exports.AdFraudApi = exports.AdCreativesApi = exports.AdConnectionsApi = exports.ABTestsApi = void 0;
4
+ exports.ApiClient = exports.WhatsAppApi = exports.WebhooksApi = exports.TargetsApi = exports.SharesApi = exports.ServerSDKsApi = exports.SalesApi = exports.SKANApi = exports.ReportsApi = void 0;
5
5
  // Generated by server/codegen/generate.mjs from openapi.json. Do not edit by hand.
6
- // Source sha256 d39834b71974ddd58b7ba177f00c450738a641f18add17189a2f707bf724c796; OpenAPI Generator 7.26.0 (typescript-fetch, custom templates).
6
+ // Source sha256 3efd1f4fb7547b9b836402740027ff175d44649333c4b3a0003260c6ec5bd358; OpenAPI Generator 7.26.0 (typescript-fetch, custom templates).
7
7
  /* eslint-disable */
8
8
  const http_js_1 = require("../http.js");
9
9
  /**
@@ -923,6 +923,19 @@ class AnalyticsApi {
923
923
  const { data } = await this.r.request({ method: 'GET', path, query, ...options });
924
924
  return data;
925
925
  }
926
+ /**
927
+ * Device Changes Report
928
+ *
929
+ * `GET /v1/analytics/device-changes`
930
+ *
931
+ * @example
932
+ * await clikgate.api.analytics.deviceChangesReport();
933
+ */
934
+ async deviceChangesReport(query = {}, options = {}) {
935
+ const path = `/v1/analytics/device-changes`;
936
+ const { data } = await this.r.request({ method: 'GET', path, query, ...options });
937
+ return data;
938
+ }
926
939
  /**
927
940
  * Explore
928
941
  *
@@ -1718,6 +1731,21 @@ class AppsApi {
1718
1731
  const { data } = await this.r.request({ method: 'GET', path, ...options });
1719
1732
  return data;
1720
1733
  }
1734
+ /**
1735
+ * Iphone Deferred Deep Link Match Rate
1736
+ *
1737
+ * iOS first launches in the period (rolling, ending now) and what the iOS SDK's pasteboard step found: `attempted` (the paste flow ran), `matched` (attributed by the pasteboard token), `match_rate` (matched / attempted, `null` when nothing was attempted) and the outcome breakdown. Measured, never estimated. iOS apps only: an Android app answers 422 `platform_not_ios`.
1738
+ *
1739
+ * `GET /v1/apps/{app_id}/iphone-deferred-match-rate`
1740
+ *
1741
+ * @example
1742
+ * await clikgate.api.apps.iphoneDeferredDeepLinkMatchRate('app_…');
1743
+ */
1744
+ async iphoneDeferredDeepLinkMatchRate(appId, query = {}, options = {}) {
1745
+ const path = `/v1/apps/${(0, http_js_1.encodePathSegment)(appId)}/iphone-deferred-match-rate`;
1746
+ const { data } = await this.r.request({ method: 'GET', path, query, ...options });
1747
+ return data;
1748
+ }
1721
1749
  /**
1722
1750
  * Link Subdomain Availability
1723
1751
  *
@@ -4652,6 +4680,43 @@ class JobsApi {
4652
4680
  }
4653
4681
  }
4654
4682
  exports.JobsApi = JobsApi;
4683
+ /**
4684
+ * KnownCustomers: generated from openapi.json. See https://clikgate.com/docs/api.
4685
+ */
4686
+ class KnownCustomersApi {
4687
+ r;
4688
+ /** @internal */
4689
+ constructor(r) {
4690
+ this.r = r;
4691
+ }
4692
+ /**
4693
+ * Import Known Customers
4694
+ *
4695
+ * `POST /v1/known-customers/import`
4696
+ *
4697
+ * @example
4698
+ * await clikgate.api.knownCustomers.importKnownCustomers({ … });
4699
+ */
4700
+ async importKnownCustomers(body, options = {}) {
4701
+ const path = `/v1/known-customers/import`;
4702
+ const { data } = await this.r.request({ method: 'POST', path, body, ...options });
4703
+ return data;
4704
+ }
4705
+ /**
4706
+ * Remove Known Customer
4707
+ *
4708
+ * `POST /v1/known-customers/remove`
4709
+ *
4710
+ * @example
4711
+ * await clikgate.api.knownCustomers.removeKnownCustomer({ … });
4712
+ */
4713
+ async removeKnownCustomer(body, options = {}) {
4714
+ const path = `/v1/known-customers/remove`;
4715
+ const { data } = await this.r.request({ method: 'POST', path, body, ...options });
4716
+ return data;
4717
+ }
4718
+ }
4719
+ exports.KnownCustomersApi = KnownCustomersApi;
4655
4720
  /**
4656
4721
  * Leaderboards: generated from openapi.json. See https://clikgate.com/docs/api.
4657
4722
  */
@@ -6902,6 +6967,19 @@ class PeopleApi {
6902
6967
  const { data } = await this.r.request({ method: 'GET', path, ...options });
6903
6968
  return data;
6904
6969
  }
6970
+ /**
6971
+ * Fetch Person Device Changes
6972
+ *
6973
+ * `GET /v1/people/{person_id}/device-changes`
6974
+ *
6975
+ * @example
6976
+ * await clikgate.api.people.fetchPersonDeviceChanges('<person_id>');
6977
+ */
6978
+ async fetchPersonDeviceChanges(personId, options = {}) {
6979
+ const path = `/v1/people/${(0, http_js_1.encodePathSegment)(personId)}/device-changes`;
6980
+ const { data } = await this.r.request({ method: 'GET', path, ...options });
6981
+ return data;
6982
+ }
6905
6983
  /**
6906
6984
  * Identify Person
6907
6985
  *
@@ -8729,6 +8807,7 @@ class ApiClient {
8729
8807
  inbound;
8730
8808
  installs;
8731
8809
  jobs;
8810
+ knownCustomers;
8732
8811
  leaderboards;
8733
8812
  links;
8734
8813
  migration;
@@ -8788,6 +8867,7 @@ class ApiClient {
8788
8867
  this.inbound = new InboundApi(r);
8789
8868
  this.installs = new InstallsApi(r);
8790
8869
  this.jobs = new JobsApi(r);
8870
+ this.knownCustomers = new KnownCustomersApi(r);
8791
8871
  this.leaderboards = new LeaderboardsApi(r);
8792
8872
  this.links = new LinksApi(r);
8793
8873
  this.migration = new MigrationApi(r);
@@ -3,7 +3,9 @@
3
3
  * person signed in to your app. The app passes the token to the mobile SDK's `identifyUser()`.
4
4
  *
5
5
  * `token = base64url_nopad(HMAC_SHA256(secret, customerId + "." + issuedAt)) + "." + issuedAt`, the same signer
6
- * Clikgate verifies with. No network call. Guide: https://clikgate.com/docs/identify-users
6
+ * Clikgate verifies with. With `customerSince` the token is version 2 and also carries the date the
7
+ * person became your customer: `signature.issuedAt.customerSince`. No network call.
8
+ * Guide: https://clikgate.com/docs/identify-users
7
9
  */
8
10
  export interface IdentityTokenOptions {
9
11
  /** The Clikgate app ID (`app_…`). Picks that app's secret from `identitySecrets` / `CLIKGATE_IDENTITY_SECRETS`. */
@@ -12,6 +14,11 @@ export interface IdentityTokenOptions {
12
14
  secret?: string | null;
13
15
  /** Unix seconds the token was issued at. Default: now. */
14
16
  issuedAt?: number;
17
+ /**
18
+ * When this person became your customer (their account's creation time): a `Date` or Unix seconds. Makes a version 2
19
+ * token, so Clikgate can tell an existing customer from a new one (referrals, new customers). Not in private mode.
20
+ */
21
+ customerSince?: Date | number | null;
15
22
  }
16
23
  /** The single secret's environment variable. */
17
24
  export declare const IDENTITY_SECRET_ENV = "CLIKGATE_IDENTITY_SECRET";
@@ -23,10 +30,13 @@ export declare const IDENTITY_SECRETS_ENV = "CLIKGATE_IDENTITY_SECRETS";
23
30
  * secret from `CLIKGATE_IDENTITY_SECRETS` (a JSON map). No network call; no API key needed.
24
31
  *
25
32
  * Throws {@link ClikgateServerOnlyError} in a browser or React Native, `ConfigurationError` when no secret is set,
26
- * and `InvalidRequestError` (`invalid_customer_id`) for an empty or over-long customer ID.
33
+ * `InvalidRequestError` (`invalid_customer_id`) for an empty or over-long customer ID, and `InvalidRequestError`
34
+ * (`invalid_argument`, param `customer_since`) for an account date before 1990 or after the token's issue time.
27
35
  *
28
36
  * @example
29
37
  * import { createIdentityToken } from '@clikgate/node';
30
38
  * res.json({ user, clikgateIdentityToken: createIdentityToken(user.id) });
39
+ * // With the account date (version 2), so existing customers are never counted as referrals or new customers:
40
+ * res.json({ user, clikgateIdentityToken: createIdentityToken(user.id, { customerSince: user.createdAt }) });
31
41
  */
32
42
  export declare function createIdentityToken(customerId: string, options?: IdentityTokenOptions): string;
@@ -3,15 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IDENTITY_SECRETS_ENV = exports.IDENTITY_SECRET_ENV = void 0;
4
4
  exports.isBrowserOrMobile = isBrowserOrMobile;
5
5
  exports.signIdentityToken = signIdentityToken;
6
+ exports.signIdentityTokenV2 = signIdentityTokenV2;
6
7
  exports.createIdentityTokenWith = createIdentityTokenWith;
7
8
  exports.createIdentityToken = createIdentityToken;
8
9
  const node_crypto_1 = require("node:crypto");
10
+ const customer_id_js_1 = require("./customer-id.js");
9
11
  const errors_js_1 = require("./errors.js");
10
12
  /** The single secret's environment variable. */
11
13
  exports.IDENTITY_SECRET_ENV = 'CLIKGATE_IDENTITY_SECRET';
12
14
  /** The per-app map's environment variable: a JSON object `{"app_…": "cgis_…"}`. */
13
15
  exports.IDENTITY_SECRETS_ENV = 'CLIKGATE_IDENTITY_SECRETS';
14
16
  const MAX_CUSTOMER_ID = 255;
17
+ /** 1990-01-01: earlier account dates are refused. */
18
+ const MIN_CUSTOMER_SINCE = 631_152_000;
19
+ /** The clock allowance for an account date after `issuedAt`. */
20
+ const CLOCK_ALLOWANCE = 300;
15
21
  /** @internal True in a browser (window or document) or React Native. */
16
22
  function isBrowserOrMobile(g = globalThis) {
17
23
  if (typeof g.window !== 'undefined' || typeof g.document !== 'undefined')
@@ -57,7 +63,7 @@ function resolveSecret(options, source) {
57
63
  }
58
64
  throw new errors_js_1.ConfigurationError({
59
65
  message: appId === null
60
- ? `No identity secret: set ${exports.IDENTITY_SECRET_ENV} on your server (Apps › your app › Identity secret).`
66
+ ? `No identity secret: set ${exports.IDENTITY_SECRET_ENV} on your server (Developers › SDKs › your app › Set up identity › Identity secret).`
61
67
  : `No identity secret for this app: add it to ${exports.IDENTITY_SECRETS_ENV} or set ${exports.IDENTITY_SECRET_ENV}.`,
62
68
  code: 'missing_identity_secret',
63
69
  param: 'secret',
@@ -68,6 +74,22 @@ function signIdentityToken(secret, customerId, issuedAt) {
68
74
  const sig = (0, node_crypto_1.createHmac)('sha256', Buffer.from(secret, 'utf8')).update(Buffer.from(`${customerId}.${issuedAt}`, 'utf8')).digest('base64url');
69
75
  return `${sig}.${issuedAt}`;
70
76
  }
77
+ /**
78
+ * @internal Version 2: the MAC input is
79
+ * `"v2\n" + utf8Length(cid) + ":" + cid + "\n" + issuedAt + "\n" + customerSince`, cid in canonical form.
80
+ */
81
+ function signIdentityTokenV2(secret, customerId, issuedAt, customerSince) {
82
+ const cid = (0, customer_id_js_1.canonicalCustomerId)(customerId);
83
+ const msg = `v2\n${Buffer.byteLength(cid, 'utf8')}:${cid}\n${issuedAt}\n${customerSince}`;
84
+ const sig = (0, node_crypto_1.createHmac)('sha256', Buffer.from(secret, 'utf8')).update(Buffer.from(msg, 'utf8')).digest('base64url');
85
+ return `${sig}.${issuedAt}.${customerSince}`;
86
+ }
87
+ function sinceSeconds(value) {
88
+ const s = value instanceof Date ? Math.floor(value.getTime() / 1000) : value;
89
+ if (typeof s !== 'number' || !Number.isSafeInteger(s))
90
+ throw (0, errors_js_1.localError)('invalid_argument', 'customerSince must be a Date or whole Unix seconds.', 'customer_since');
91
+ return s;
92
+ }
71
93
  /** @internal createIdentityToken with an explicit secret source (the client's options). */
72
94
  function createIdentityTokenWith(source, customerId, options = {}) {
73
95
  if (isBrowserOrMobile())
@@ -80,7 +102,16 @@ function createIdentityTokenWith(source, customerId, options = {}) {
80
102
  const issuedAt = o.issuedAt ?? Math.floor(Date.now() / 1000);
81
103
  if (!Number.isSafeInteger(issuedAt) || issuedAt < 0)
82
104
  throw (0, errors_js_1.localError)('invalid_argument', 'issuedAt must be whole Unix seconds.', 'issued_at');
83
- return signIdentityToken(resolveSecret(o, source), customerId, issuedAt);
105
+ if (o.customerSince == null)
106
+ return signIdentityToken(resolveSecret(o, source), customerId, issuedAt);
107
+ const since = sinceSeconds(o.customerSince);
108
+ if (since < MIN_CUSTOMER_SINCE || since > issuedAt + CLOCK_ALLOWANCE) {
109
+ throw (0, errors_js_1.localError)('invalid_argument', 'customerSince must be between 1990 and the time the token is issued.', 'customer_since');
110
+ }
111
+ const cid = (0, customer_id_js_1.canonicalCustomerId)(customerId);
112
+ if (cid === '')
113
+ throw (0, errors_js_1.localError)('invalid_customer_id', 'customerId must be your own user ID as a string of 1-255 characters (never an email or phone number).', 'customer_id');
114
+ return signIdentityTokenV2(resolveSecret(o, source), cid, issuedAt, since);
84
115
  }
85
116
  /**
86
117
  * Create an identity token for the signed-in user. Return it in your sign-in and "current user"
@@ -88,11 +119,14 @@ function createIdentityTokenWith(source, customerId, options = {}) {
88
119
  * secret from `CLIKGATE_IDENTITY_SECRETS` (a JSON map). No network call; no API key needed.
89
120
  *
90
121
  * Throws {@link ClikgateServerOnlyError} in a browser or React Native, `ConfigurationError` when no secret is set,
91
- * and `InvalidRequestError` (`invalid_customer_id`) for an empty or over-long customer ID.
122
+ * `InvalidRequestError` (`invalid_customer_id`) for an empty or over-long customer ID, and `InvalidRequestError`
123
+ * (`invalid_argument`, param `customer_since`) for an account date before 1990 or after the token's issue time.
92
124
  *
93
125
  * @example
94
126
  * import { createIdentityToken } from '@clikgate/node';
95
127
  * res.json({ user, clikgateIdentityToken: createIdentityToken(user.id) });
128
+ * // With the account date (version 2), so existing customers are never counted as referrals or new customers:
129
+ * res.json({ user, clikgateIdentityToken: createIdentityToken(user.id, { customerSince: user.createdAt }) });
96
130
  */
97
131
  function createIdentityToken(customerId, options = {}) {
98
132
  return createIdentityTokenWith({}, customerId, options);
@@ -12,6 +12,9 @@
12
12
  export { Clikgate, type ClikgateOptions, type IdentifyUserParams, type PersonIdentified } from './client.js';
13
13
  export { ClickIds, clickIds, isValid as isValidClickId, CLICK_ID_PATTERN, CLICK_ID_HEADER, KEPT_COOKIE, KEPT_BY, BROWSER_ENGINES, PLATFORMS, type PersistOptions, type RequestLike, type ResponseLike, type KeptBy, type BrowserEngine, type Platform, type ClickContext, type KeepRoute, type KeepRouteOptions, type KeepInput, type KeepResult, } from './click-ids.js';
14
14
  export { webhooks, type VerifyOptions, type RawBody } from './webhooks.js';
15
+ export { parseInstallationHeader, installationFromRequest, INSTALLATION_HEADER, INSTALLATION_HEADER_MAX_LENGTH, INSTALLATION_PATTERN, type Installation, type HeadersLike, } from './installation.js';
16
+ export { canonicalCustomerId, customerIdWarning, CUSTOMER_ID_MAX_LENGTH, type CustomerIdWarning } from './customer-id.js';
17
+ export { KNOWN_CUSTOMERS_BATCH, type KnownCustomers, type KnownCustomer, type KnownCustomerRefusal, type KnownCustomersImportResult } from './known-customers.js';
15
18
  export { createIdentityToken, IDENTITY_SECRET_ENV, IDENTITY_SECRETS_ENV, type IdentityTokenOptions } from './identity.js';
16
19
  export { formatValue, type MoneyInput } from './money.js';
17
20
  export { hashForAds, type HashForAdsInput, type HashedIdentifiers } from './ads-hashing.js';
@@ -22,9 +25,16 @@ export type { Logger, WarningCode } from './logger.js';
22
25
  export type { Clock, RequestOptions } from './http.js';
23
26
  export type { FetchLike } from './transport.js';
24
27
  export type { QrOptions, LinkIterator, Conversions, Links, Clicks } from './resources.js';
28
+ export { REFERRER_IMPORT_BATCH } from './referrals.js';
29
+ export type { Referrals, ReferrerCreateParams, ReferrerLookup, ReferralListParams, CompleteStepParams, ReferrerImportRow, ReferrerUpdateParams, } from './referrals.js';
30
+ export type { Privacy, PrivacyRequestParams, People, PeopleSearchOptions, Installs, Codes, CodeRedeemParams } from './lookups.js';
31
+ export type { PageIterator } from './pager.js';
32
+ export { EventType, type EventTypeValue } from './event-types.js';
33
+ export { currencyExponent, minorToAmount } from './currency.js';
34
+ export type { Referrer, ReferrerResult, ReferrerStats, Referral, ReferralStep, RewardInfo, RewardSide, Job, JobResult, PrivacyRequest, Person, PersonSummary, PersonSearchPage, Install, PaymentReport, ConversionObject, CodeRedemption, WebhookGoalEvent, DeviceChange, DeviceChangeSide, ReferralStateChange, LinkCreateParams, LinkUpdateParams, } from './models.js';
25
35
  export type { Goals } from './goals.js';
26
36
  export { buildFromPaystack, buildFromFlutterwave, buildFromMonnify, buildFromStripe, type Payments, type PaymentStatus, type PaymentConfirmParams, type PaymentConfirmation, type PaymentConfirmationBody, type PaymentHelperOptions, } from './payments.js';
27
- export type { GoalEvent, GoalAttribution, GoalPayment, GoalBatchItem, GoalBatchResult, Link, LinkWarning, LinkChangeRequest, LinkUpdateResult, Click, Conversion, ListPage, ServerSdkConfig, ConfigGoal, WebhookEvent, QrCode, } from './types.js';
37
+ export type { GoalEvent, GoalAttribution, GoalPayment, GoalBatchItem, GoalBatchResult, Link, LinkWarning, LinkChangeRequest, LinkUpdateResult, Click, Conversion, ListPage, ServerSdkConfig, ConfigGoal, WebhookEvent, WebhookEventAccessors, WebhookEventData, WebhookEventOf, TypedWebhookEvent, QrCode, } from './types.js';
28
38
  export { ClikgateError, ConfigurationError, AuthenticationError, PermissionError, InvalidRequestError, PrivateModeFieldRejectedError, NotFoundError, ConflictError, LinkLockedError, IdempotencyError, RateLimitError, ServerError, NetworkError, TimeoutError, SignatureVerificationError, ClikgateServerOnlyError, type KnownErrorCode, } from './errors.js';
29
39
  export { VERSION } from './version.js';
30
40
  /** Types of the generated `clikgate.api.*` layer (request bodies and responses, as in openapi.json). */
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VERSION = exports.ClikgateServerOnlyError = exports.SignatureVerificationError = exports.TimeoutError = exports.NetworkError = exports.ServerError = exports.RateLimitError = exports.IdempotencyError = exports.LinkLockedError = exports.ConflictError = exports.NotFoundError = exports.PrivateModeFieldRejectedError = exports.InvalidRequestError = exports.PermissionError = exports.AuthenticationError = exports.ConfigurationError = exports.ClikgateError = exports.buildFromStripe = exports.buildFromMonnify = exports.buildFromFlutterwave = exports.buildFromPaystack = exports.Provider = exports.GoalStatus = exports.GoalKind = exports.hashForAds = exports.formatValue = exports.IDENTITY_SECRETS_ENV = exports.IDENTITY_SECRET_ENV = exports.createIdentityToken = exports.webhooks = exports.PLATFORMS = exports.BROWSER_ENGINES = exports.KEPT_BY = exports.KEPT_COOKIE = exports.CLICK_ID_HEADER = exports.CLICK_ID_PATTERN = exports.isValidClickId = exports.clickIds = exports.ClickIds = exports.Clikgate = void 0;
3
+ exports.TimeoutError = exports.NetworkError = exports.ServerError = exports.RateLimitError = exports.IdempotencyError = exports.LinkLockedError = exports.ConflictError = exports.NotFoundError = exports.PrivateModeFieldRejectedError = exports.InvalidRequestError = exports.PermissionError = exports.AuthenticationError = exports.ConfigurationError = exports.ClikgateError = exports.buildFromStripe = exports.buildFromMonnify = exports.buildFromFlutterwave = exports.buildFromPaystack = exports.minorToAmount = exports.currencyExponent = exports.EventType = exports.REFERRER_IMPORT_BATCH = exports.Provider = exports.GoalStatus = exports.GoalKind = exports.hashForAds = exports.formatValue = exports.IDENTITY_SECRETS_ENV = exports.IDENTITY_SECRET_ENV = exports.createIdentityToken = exports.KNOWN_CUSTOMERS_BATCH = exports.CUSTOMER_ID_MAX_LENGTH = exports.customerIdWarning = exports.canonicalCustomerId = exports.INSTALLATION_PATTERN = exports.INSTALLATION_HEADER_MAX_LENGTH = exports.INSTALLATION_HEADER = exports.installationFromRequest = exports.parseInstallationHeader = exports.webhooks = exports.PLATFORMS = exports.BROWSER_ENGINES = exports.KEPT_BY = exports.KEPT_COOKIE = exports.CLICK_ID_HEADER = exports.CLICK_ID_PATTERN = exports.isValidClickId = exports.clickIds = exports.ClickIds = exports.Clikgate = void 0;
4
+ exports.VERSION = exports.ClikgateServerOnlyError = exports.SignatureVerificationError = void 0;
4
5
  /**
5
6
  * The official Clikgate server SDK for Node.js and TypeScript.
6
7
  *
@@ -26,6 +27,18 @@ Object.defineProperty(exports, "BROWSER_ENGINES", { enumerable: true, get: funct
26
27
  Object.defineProperty(exports, "PLATFORMS", { enumerable: true, get: function () { return click_ids_js_1.PLATFORMS; } });
27
28
  var webhooks_js_1 = require("./webhooks.js");
28
29
  Object.defineProperty(exports, "webhooks", { enumerable: true, get: function () { return webhooks_js_1.webhooks; } });
30
+ var installation_js_1 = require("./installation.js");
31
+ Object.defineProperty(exports, "parseInstallationHeader", { enumerable: true, get: function () { return installation_js_1.parseInstallationHeader; } });
32
+ Object.defineProperty(exports, "installationFromRequest", { enumerable: true, get: function () { return installation_js_1.installationFromRequest; } });
33
+ Object.defineProperty(exports, "INSTALLATION_HEADER", { enumerable: true, get: function () { return installation_js_1.INSTALLATION_HEADER; } });
34
+ Object.defineProperty(exports, "INSTALLATION_HEADER_MAX_LENGTH", { enumerable: true, get: function () { return installation_js_1.INSTALLATION_HEADER_MAX_LENGTH; } });
35
+ Object.defineProperty(exports, "INSTALLATION_PATTERN", { enumerable: true, get: function () { return installation_js_1.INSTALLATION_PATTERN; } });
36
+ var customer_id_js_1 = require("./customer-id.js");
37
+ Object.defineProperty(exports, "canonicalCustomerId", { enumerable: true, get: function () { return customer_id_js_1.canonicalCustomerId; } });
38
+ Object.defineProperty(exports, "customerIdWarning", { enumerable: true, get: function () { return customer_id_js_1.customerIdWarning; } });
39
+ Object.defineProperty(exports, "CUSTOMER_ID_MAX_LENGTH", { enumerable: true, get: function () { return customer_id_js_1.CUSTOMER_ID_MAX_LENGTH; } });
40
+ var known_customers_js_1 = require("./known-customers.js");
41
+ Object.defineProperty(exports, "KNOWN_CUSTOMERS_BATCH", { enumerable: true, get: function () { return known_customers_js_1.KNOWN_CUSTOMERS_BATCH; } });
29
42
  var identity_js_1 = require("./identity.js");
30
43
  Object.defineProperty(exports, "createIdentityToken", { enumerable: true, get: function () { return identity_js_1.createIdentityToken; } });
31
44
  Object.defineProperty(exports, "IDENTITY_SECRET_ENV", { enumerable: true, get: function () { return identity_js_1.IDENTITY_SECRET_ENV; } });
@@ -38,6 +51,13 @@ var enums_js_1 = require("./enums.js");
38
51
  Object.defineProperty(exports, "GoalKind", { enumerable: true, get: function () { return enums_js_1.GoalKind; } });
39
52
  Object.defineProperty(exports, "GoalStatus", { enumerable: true, get: function () { return enums_js_1.GoalStatus; } });
40
53
  Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return enums_js_1.Provider; } });
54
+ var referrals_js_1 = require("./referrals.js");
55
+ Object.defineProperty(exports, "REFERRER_IMPORT_BATCH", { enumerable: true, get: function () { return referrals_js_1.REFERRER_IMPORT_BATCH; } });
56
+ var event_types_js_1 = require("./event-types.js");
57
+ Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return event_types_js_1.EventType; } });
58
+ var currency_js_1 = require("./currency.js");
59
+ Object.defineProperty(exports, "currencyExponent", { enumerable: true, get: function () { return currency_js_1.currencyExponent; } });
60
+ Object.defineProperty(exports, "minorToAmount", { enumerable: true, get: function () { return currency_js_1.minorToAmount; } });
41
61
  var payments_js_1 = require("./payments.js");
42
62
  Object.defineProperty(exports, "buildFromPaystack", { enumerable: true, get: function () { return payments_js_1.buildFromPaystack; } });
43
63
  Object.defineProperty(exports, "buildFromFlutterwave", { enumerable: true, get: function () { return payments_js_1.buildFromFlutterwave; } });
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The `Clikgate-Installation` header (SPEC section 24): the mobile SDKs give the app a value
3
+ * `<app_id>:<installation_id>` to send to its own backend at sign-in and on signed-in requests. It is
4
+ * not a secret. Your server passes it to `identifyUser({ installation })`, so it never needs to know
5
+ * which Clikgate app ID belongs to which platform.
6
+ *
7
+ * The header only names the app installation. The customer ID always comes from your own signed-in
8
+ * user, never from the request.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ /** The header name the app sends to your backend. */
13
+ export declare const INSTALLATION_HEADER = "Clikgate-Installation";
14
+ /** Longer header values are refused before they are looked at. */
15
+ export declare const INSTALLATION_HEADER_MAX_LENGTH = 128;
16
+ /** `app_` + a 26-character ID, one colon, a lowercase UUID. */
17
+ export declare const INSTALLATION_PATTERN: RegExp;
18
+ /** An app installation read from the `Clikgate-Installation` header. */
19
+ export interface Installation {
20
+ /** The Clikgate app ID (`app_…`). */
21
+ appId: string;
22
+ /** The SDK's installation ID (a lowercase UUID). */
23
+ installationId: string;
24
+ }
25
+ /** A request with headers: Node's `IncomingMessage`, Express, Fastify, a Fetch `Request` or `{ headers }`. */
26
+ export interface HeadersLike {
27
+ headers?: Headers | Record<string, string | string[] | undefined> | {
28
+ get(name: string): string | null;
29
+ } | null;
30
+ }
31
+ /**
32
+ * Parse a `Clikgate-Installation` header value. Returns `null` for anything that isn't exactly
33
+ * `<app_id>:<installation_id>` (after trimming, at most 128 characters, lowercase UUID). Never throws.
34
+ *
35
+ * @example
36
+ * const installation = parseInstallationHeader(req.get('Clikgate-Installation'));
37
+ * // { appId: 'app_01J…', installationId: '3f2b…' } or null
38
+ */
39
+ export declare function parseInstallationHeader(value: unknown): Installation | null;
40
+ /**
41
+ * The installation from a request's `Clikgate-Installation` header, or `null` when it is missing or
42
+ * invalid. Never throws.
43
+ *
44
+ * @example
45
+ * const installation = installationFromRequest(req);
46
+ */
47
+ export declare function installationFromRequest(request: HeadersLike | null | undefined): Installation | null;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * The `Clikgate-Installation` header (SPEC section 24): the mobile SDKs give the app a value
4
+ * `<app_id>:<installation_id>` to send to its own backend at sign-in and on signed-in requests. It is
5
+ * not a secret. Your server passes it to `identifyUser({ installation })`, so it never needs to know
6
+ * which Clikgate app ID belongs to which platform.
7
+ *
8
+ * The header only names the app installation. The customer ID always comes from your own signed-in
9
+ * user, never from the request.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.INSTALLATION_PATTERN = exports.INSTALLATION_HEADER_MAX_LENGTH = exports.INSTALLATION_HEADER = void 0;
15
+ exports.parseInstallationHeader = parseInstallationHeader;
16
+ exports.installationFromRequest = installationFromRequest;
17
+ exports.toInstallation = toInstallation;
18
+ /** The header name the app sends to your backend. */
19
+ exports.INSTALLATION_HEADER = 'Clikgate-Installation';
20
+ /** Longer header values are refused before they are looked at. */
21
+ exports.INSTALLATION_HEADER_MAX_LENGTH = 128;
22
+ /** `app_` + a 26-character ID, one colon, a lowercase UUID. */
23
+ exports.INSTALLATION_PATTERN = /^(app_[0-9A-Z]{26}):([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/;
24
+ /**
25
+ * Parse a `Clikgate-Installation` header value. Returns `null` for anything that isn't exactly
26
+ * `<app_id>:<installation_id>` (after trimming, at most 128 characters, lowercase UUID). Never throws.
27
+ *
28
+ * @example
29
+ * const installation = parseInstallationHeader(req.get('Clikgate-Installation'));
30
+ * // { appId: 'app_01J…', installationId: '3f2b…' } or null
31
+ */
32
+ function parseInstallationHeader(value) {
33
+ if (typeof value !== 'string' || value.length > exports.INSTALLATION_HEADER_MAX_LENGTH)
34
+ return null;
35
+ const match = exports.INSTALLATION_PATTERN.exec(value.replace(/^[ \t\r\n\f\v]+|[ \t\r\n\f\v]+$/g, ''));
36
+ return match ? { appId: match[1], installationId: match[2] } : null;
37
+ }
38
+ function headerValue(headers) {
39
+ if (!headers)
40
+ return undefined;
41
+ if (typeof headers.get === 'function') {
42
+ return headers.get(exports.INSTALLATION_HEADER);
43
+ }
44
+ const record = headers;
45
+ const wanted = exports.INSTALLATION_HEADER.toLowerCase();
46
+ for (const key of Object.keys(record)) {
47
+ if (key.toLowerCase() === wanted) {
48
+ const raw = record[key];
49
+ // Several headers with this name: refused, never guessed
50
+ return Array.isArray(raw) ? (raw.length === 1 ? raw[0] : undefined) : raw;
51
+ }
52
+ }
53
+ return undefined;
54
+ }
55
+ /**
56
+ * The installation from a request's `Clikgate-Installation` header, or `null` when it is missing or
57
+ * invalid. Never throws.
58
+ *
59
+ * @example
60
+ * const installation = installationFromRequest(req);
61
+ */
62
+ function installationFromRequest(request) {
63
+ try {
64
+ return parseInstallationHeader(headerValue(request?.headers));
65
+ }
66
+ catch {
67
+ return null;
68
+ }
69
+ }
70
+ /**
71
+ * @internal An installation from either the raw `Clikgate-Installation` header or a parsed {@link Installation}
72
+ * (`req.clikgate.installation`, `getInstallation(...)`). Both go through the same strict check; anything else is `null`.
73
+ */
74
+ function toInstallation(value) {
75
+ if (typeof value === 'string')
76
+ return parseInstallationHeader(value);
77
+ if (value && typeof value === 'object') {
78
+ const { appId, installationId } = value;
79
+ if (typeof appId === 'string' && typeof installationId === 'string')
80
+ return parseInstallationHeader(`${appId}:${installationId}`);
81
+ }
82
+ return null;
83
+ }
@@ -0,0 +1,45 @@
1
+ import type { RequestOptions } from './http.js';
2
+ /**
3
+ * Known customers: people who were already your customers before you added Clikgate. Clikgate uses
4
+ * them so an existing customer is never counted as a referral or a new customer. It stores a keyed fingerprint of
5
+ * each ID, not the ID itself. Not available in private mode.
6
+ */
7
+ /** One existing customer: your customer ID and, optionally, when they became a customer. */
8
+ export interface KnownCustomer {
9
+ customerId: string;
10
+ /** When they became a customer: `'YYYY-MM-DD'`, a `Date` or Unix seconds. Only the UTC day is sent. */
11
+ customerSince?: string | Date | number | null;
12
+ }
13
+ /** Why rows were refused. Counts only: the API never returns the refused IDs. */
14
+ export type KnownCustomerRefusal = 'looks_like_email' | 'looks_like_phone' | 'looks_like_national_id' | 'empty' | 'too_long' | 'bad_date' | 'date_out_of_range';
15
+ /** The answer of `knownCustomers.import()`, summed over every batch. */
16
+ export interface KnownCustomersImportResult {
17
+ accepted: number;
18
+ refused: number;
19
+ refused_by_reason: Partial<Record<KnownCustomerRefusal | string, number>>;
20
+ }
21
+ /** The API's batch size; `import()` splits larger lists. */
22
+ export declare const KNOWN_CUSTOMERS_BATCH = 10000;
23
+ /** `clikgate.knownCustomers`: import and remove existing customers (scope `people:write`). */
24
+ export declare class KnownCustomers {
25
+ private readonly core;
26
+ /**
27
+ * Import existing customers (`POST /v1/known-customers/import`), in batches of 10,000. Idempotent per customer ID.
28
+ * Use your own customer IDs, never emails or phone numbers. The result sums every batch; refused rows are counted
29
+ * by reason, never returned.
30
+ *
31
+ * @example
32
+ * const result = await clikgate.knownCustomers.import([{ customerId: 'u_10482', customerSince: '2024-03-02' }]);
33
+ * console.log(result.accepted, result.refused_by_reason);
34
+ */
35
+ import(customers: readonly KnownCustomer[], requestOptions?: RequestOptions): Promise<KnownCustomersImportResult>;
36
+ /**
37
+ * Remove one imported customer (`POST /v1/known-customers/remove`; the ID travels in the body, never in a URL).
38
+ *
39
+ * @example
40
+ * const { removed } = await clikgate.knownCustomers.remove('u_10482');
41
+ */
42
+ remove(customerId: string, requestOptions?: RequestOptions): Promise<{
43
+ removed: boolean;
44
+ }>;
45
+ }
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KnownCustomers = exports.KNOWN_CUSTOMERS_BATCH = void 0;
4
+ exports.sinceDay = sinceDay;
5
+ const errors_js_1 = require("./errors.js");
6
+ /** The API's batch size; `import()` splits larger lists. */
7
+ exports.KNOWN_CUSTOMERS_BATCH = 10_000;
8
+ const DAY = /^\d{4}-\d{2}-\d{2}$/;
9
+ /** @internal The UTC day `YYYY-MM-DD` of a customerSince value. */
10
+ function sinceDay(value) {
11
+ if (typeof value === 'string') {
12
+ if (!DAY.test(value))
13
+ throw (0, errors_js_1.localError)('invalid_argument', "customerSince must be 'YYYY-MM-DD', a Date or Unix seconds.", 'customer_since');
14
+ return value;
15
+ }
16
+ const ms = typeof value === 'number' ? value * 1000 : value instanceof Date ? value.getTime() : Number.NaN;
17
+ if (!Number.isFinite(ms) || (typeof value === 'number' && !Number.isSafeInteger(value))) {
18
+ throw (0, errors_js_1.localError)('invalid_argument', "customerSince must be 'YYYY-MM-DD', a Date or Unix seconds.", 'customer_since');
19
+ }
20
+ return new Date(ms).toISOString().slice(0, 10);
21
+ }
22
+ function privateModeConflict() {
23
+ return new errors_js_1.ConflictError({
24
+ message: "Private mode is on: known customers can't be imported or removed.",
25
+ code: 'private_mode_conflict',
26
+ httpStatus: null,
27
+ });
28
+ }
29
+ /** `clikgate.knownCustomers`: import and remove existing customers (scope `people:write`). */
30
+ class KnownCustomers {
31
+ core;
32
+ /** @internal */
33
+ constructor(core) {
34
+ this.core = core;
35
+ }
36
+ /**
37
+ * Import existing customers (`POST /v1/known-customers/import`), in batches of 10,000. Idempotent per customer ID.
38
+ * Use your own customer IDs, never emails or phone numbers. The result sums every batch; refused rows are counted
39
+ * by reason, never returned.
40
+ *
41
+ * @example
42
+ * const result = await clikgate.knownCustomers.import([{ customerId: 'u_10482', customerSince: '2024-03-02' }]);
43
+ * console.log(result.accepted, result.refused_by_reason);
44
+ */
45
+ async import(customers, requestOptions = {}) {
46
+ if (!Array.isArray(customers))
47
+ throw (0, errors_js_1.localError)('invalid_argument', 'customers must be an array.', 'customers');
48
+ const rows = customers.map((c, i) => {
49
+ if (!c || typeof c.customerId !== 'string')
50
+ throw (0, errors_js_1.localError)('invalid_argument', `customers[${i}].customerId must be a string.`, 'customer_id');
51
+ const row = { customer_id: c.customerId };
52
+ if (c.customerSince != null)
53
+ row.customer_since = sinceDay(c.customerSince);
54
+ return row;
55
+ });
56
+ const total = { accepted: 0, refused: 0, refused_by_reason: {} };
57
+ if (rows.length === 0)
58
+ return total;
59
+ if ((await this.core.guardState()).guard)
60
+ throw privateModeConflict();
61
+ const several = rows.length > exports.KNOWN_CUSTOMERS_BATCH;
62
+ for (let i = 0; i < rows.length; i += exports.KNOWN_CUSTOMERS_BATCH) {
63
+ // One idempotency key per batch: a key you pass gets the batch number appended
64
+ const key = requestOptions.idempotencyKey;
65
+ const options = several && key ? { ...requestOptions, idempotencyKey: `${key}-${i / exports.KNOWN_CUSTOMERS_BATCH}` } : requestOptions;
66
+ const { data } = await this.core.requester.request({
67
+ method: 'POST',
68
+ path: '/v1/known-customers/import',
69
+ body: { customers: rows.slice(i, i + exports.KNOWN_CUSTOMERS_BATCH) },
70
+ ...options,
71
+ });
72
+ total.accepted += data.accepted ?? 0;
73
+ total.refused += data.refused ?? 0;
74
+ for (const [reason, n] of Object.entries(data.refused_by_reason ?? {})) {
75
+ total.refused_by_reason[reason] = (total.refused_by_reason[reason] ?? 0) + (n ?? 0);
76
+ }
77
+ }
78
+ return total;
79
+ }
80
+ /**
81
+ * Remove one imported customer (`POST /v1/known-customers/remove`; the ID travels in the body, never in a URL).
82
+ *
83
+ * @example
84
+ * const { removed } = await clikgate.knownCustomers.remove('u_10482');
85
+ */
86
+ async remove(customerId, requestOptions = {}) {
87
+ if (typeof customerId !== 'string' || customerId === '')
88
+ throw (0, errors_js_1.localError)('invalid_customer_id', 'customerId must be a non-empty string.', 'customer_id');
89
+ if ((await this.core.guardState()).guard)
90
+ throw privateModeConflict();
91
+ const { data } = await this.core.requester.request({ method: 'POST', path: '/v1/known-customers/remove', body: { customer_id: customerId }, ...requestOptions });
92
+ return data;
93
+ }
94
+ }
95
+ exports.KnownCustomers = KnownCustomers;