@orangecheck/me-client 0.29.0 → 0.30.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/README.md +2 -2
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
> Hand-written prose below is the high-level overview; the docs site is the source of truth for every export, type, and signature.
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
Client for [me.ochk.io](https://me.ochk.io). Popup sign-in for any site, framework-agnostic server-side verification, session lifecycle hooks, payment authorization, webhook signature verification, the canonical billable-event taxonomy as TypeScript types. `OcSignInButton` rides the family cookie
|
|
7
|
+
Client for [me.ochk.io](https://me.ochk.io). Popup sign-in for any site, framework-agnostic server-side verification, session lifecycle hooks, payment authorization, webhook signature verification, the canonical billable-event taxonomy as TypeScript types. Sign people in with `signInWithOc()` from `/popup`; the deprecated `OcSignInButton` rides the family cookie and works only on orangecheck's own sites.
|
|
8
8
|
|
|
9
9
|
> Sign-in is free. Paying your users is optional: always, in promos you schedule, or never.
|
|
10
10
|
|
|
@@ -82,7 +82,7 @@ const res = await oc.event.fire({
|
|
|
82
82
|
project_key: 'pk_live_yourcompany',
|
|
83
83
|
subtype: 'account_creation',
|
|
84
84
|
signingSecret: process.env.OC_SIGNING_SECRET,
|
|
85
|
-
|
|
85
|
+
accountId: didOc,
|
|
86
86
|
});
|
|
87
87
|
if (!res.earned) {
|
|
88
88
|
// res.reason === 'not_paying'; res.next_pay_period says when paying starts, if scheduled
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -376,9 +376,13 @@ async function fire(options) {
|
|
|
376
376
|
if (!options.subtype) {
|
|
377
377
|
throw new Error("event.fire requires subtype");
|
|
378
378
|
}
|
|
379
|
-
if (options.userAddress &&
|
|
379
|
+
if (options.accountId !== void 0 && options.userAddress !== void 0 && options.accountId !== options.userAddress) {
|
|
380
|
+
throw new Error("event.fire: accountId and userAddress name different earners");
|
|
381
|
+
}
|
|
382
|
+
const earner = options.accountId ?? options.userAddress;
|
|
383
|
+
if (earner && !options.signingSecret) {
|
|
380
384
|
throw new Error(
|
|
381
|
-
"event.fire:
|
|
385
|
+
"event.fire: accountId names who earns, so it requires signingSecret \u2014 the signature over the request body is what authorises that earner. Without the secret, pass bearerToken (or rely on the oc_session cookie) and the caller earns instead."
|
|
382
386
|
);
|
|
383
387
|
}
|
|
384
388
|
const requestBody = {
|
|
@@ -390,7 +394,7 @@ async function fire(options) {
|
|
|
390
394
|
if (options.action_label !== void 0) requestBody.action_label = options.action_label;
|
|
391
395
|
if (options.metadata !== void 0) requestBody.metadata = options.metadata;
|
|
392
396
|
if (options.is_agent !== void 0) requestBody.is_agent = options.is_agent;
|
|
393
|
-
if (
|
|
397
|
+
if (earner !== void 0) requestBody.user_address = earner;
|
|
394
398
|
const headers = {};
|
|
395
399
|
if (options.idempotencyKey) headers["idempotency-key"] = options.idempotencyKey;
|
|
396
400
|
if (options.signingSecret) {
|