@orangecheck/me-client 0.56.0 → 0.57.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/CHANGELOG.md +52 -0
- package/README.md +11 -8
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{integrator-DDeHg7vj.d.mts → integrator-BmRHP_iX.d.mts} +3 -3
- package/dist/{integrator-DDeHg7vj.d.ts → integrator-BmRHP_iX.d.ts} +3 -3
- package/dist/integrator.d.mts +1 -1
- package/dist/integrator.d.ts +1 -1
- package/dist/integrator.js.map +1 -1
- package/dist/integrator.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +13 -4
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +13 -4
- package/dist/server.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,56 @@ and [Semantic Versioning](https://semver.org/). Wire-format / canonical-message
|
|
|
8
8
|
changes are coordinated via the relevant `oc-*-protocol` spec repo's CHANGELOG;
|
|
9
9
|
this file tracks the package's TS / Node / runtime API surface.
|
|
10
10
|
|
|
11
|
+
## [Unreleased]
|
|
12
|
+
|
|
13
|
+
## [0.57.0] — 2026-11-09
|
|
14
|
+
|
|
15
|
+
### Deprecated
|
|
16
|
+
|
|
17
|
+
- The `display_name` scope. Signing in already gives your site the person's
|
|
18
|
+
display name, so ochk.app no longer offers the scope and me.ochk.io resolves
|
|
19
|
+
it to nothing. `oc.scope.request` still accepts it, so nothing that asks for
|
|
20
|
+
it breaks; read the name from the sign-in instead.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- With `OC_REVOCATION_FEED_TOKEN` unset, a family session (no `aud`) is now
|
|
25
|
+
`unavailable` with `reason: 'revocation_feed_unconfigured'`, and the adapters
|
|
26
|
+
answer it 503 with that reason, where `checkOcSession`, `getOcSession`,
|
|
27
|
+
`withOcAuth`, `ocAuthExpress` and `ocAuthHono` used to throw (0.44.0). It is
|
|
28
|
+
still never read by its signature alone, reads and writes alike, and the
|
|
29
|
+
first one logs which setting is missing. `OcSessionUnavailable` gains the
|
|
30
|
+
reason.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- A rejected entry in `event.fireBatch`'s results can carry `code`, a
|
|
35
|
+
`BatchRejectCode` to switch on, beside `reason` in words. me.ochk.io sends
|
|
36
|
+
one on every rejected entry now; an older server sends `reason` alone, so
|
|
37
|
+
`code` is optional.
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- `oc.scope.granted` works for an integrator: call it from your backend with
|
|
42
|
+
`accountId` (the person's did:oc) and `signingSecret`, and it signs the
|
|
43
|
+
question the way me.ochk.io's scopes route checks it. With neither, it reads
|
|
44
|
+
the session the request carries, which only ochk.app's own pages have, so a
|
|
45
|
+
browser on your site gets 401. Either option without the other, or an
|
|
46
|
+
`accountId` that is not a did:oc, throws before any request.
|
|
47
|
+
- `Session` and `SessionPolicy` say what me.ochk.io sends and takes:
|
|
48
|
+
`issued_at` (the type said `opens_at`, which never arrived), `refresh`
|
|
49
|
+
`'sliding' | 'rolling' | 'fixed'` and `sensitive_actions` `'re-auth' |
|
|
50
|
+
'allow'`. Code that read `opens_at` read `undefined`; read `issued_at`.
|
|
51
|
+
`oc.session.*`'s doc and the README say these calls work only from
|
|
52
|
+
ochk.app's own pages.
|
|
53
|
+
- A refusal whose words are in `detail` now carries them as the
|
|
54
|
+
`MeClientError`'s `message`: the event routes' `project_auth_required` 401
|
|
55
|
+
and any route's `row_busy` 503. The message used to be the bare code.
|
|
56
|
+
`reason` still comes first, and the code is the fallback when the body has
|
|
57
|
+
no words.
|
|
58
|
+
- `family.scopes`' doc names its 401 by the code me.ochk.io sends,
|
|
59
|
+
`sign_in_required`, not the old words.
|
|
60
|
+
|
|
11
61
|
## [0.56.0] — 2026-10-27
|
|
12
62
|
|
|
13
63
|
### Changed
|
|
@@ -785,6 +835,8 @@ Two independent defects, either of which was fatal:
|
|
|
785
835
|
|
|
786
836
|
## [Unreleased]
|
|
787
837
|
|
|
838
|
+
## [0.57.0] — 2026-11-09
|
|
839
|
+
|
|
788
840
|
- _(no pending changes)_
|
|
789
841
|
|
|
790
842
|
## [0.38.3] — 2026-10-23
|
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 [
|
|
7
|
+
Client for [ochk.app](https://ochk.app), the orangecheck account (its API answers at 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`. No React needed.
|
|
8
8
|
|
|
9
9
|
> Sign-in is free. Paying your users is optional: always, in promos you schedule, or never.
|
|
10
10
|
|
|
@@ -17,8 +17,9 @@ import { oc } from '@orangecheck/me-client';
|
|
|
17
17
|
// The React provider and hook live in the companion package.
|
|
18
18
|
import { OcSessionProvider, useOcSession } from '@orangecheck/auth-client';
|
|
19
19
|
|
|
20
|
-
// Server-side verification — Next.js, Express, Hono.
|
|
21
|
-
//
|
|
20
|
+
// Server-side verification — Next.js, Express, Hono. No JWK handling:
|
|
21
|
+
// SDK lazy-fetches and caches the JWKS. Set OC_PROJECT_KEY and
|
|
22
|
+
// OC_SIGNING_SECRET (see "Sessions ended everywhere").
|
|
22
23
|
import { withOcAuth, ocAuthExpress, ocAuthHono } from '@orangecheck/me-client/server';
|
|
23
24
|
|
|
24
25
|
// Browser-only popup orchestrator — same shape Google / GitHub use.
|
|
@@ -136,7 +137,9 @@ if (!res.earned) {
|
|
|
136
137
|
|
|
137
138
|
## Session lifecycle
|
|
138
139
|
|
|
139
|
-
Sessions are the billable atom
|
|
140
|
+
Sessions are the billable atom on ochk.app: your server fires one `session_creation` event per real session with `oc.event.fire`. `oc.session.create` opens a session and records no charge, and a signin within a still-valid session is **free**. Site declares the policy at integration time; the OC verifier enforces it both client-side and server-side.
|
|
141
|
+
|
|
142
|
+
`oc.session.create`, `refresh` and `invalidate` need a session me.ochk.io accepts, which only ochk.app's own pages carry; from another site they answer 401. Your own site reads its sign-in with `withOcAuth` (or `ocAuthExpress`, `ocAuthHono`) and keeps its own session.
|
|
140
143
|
|
|
141
144
|
```ts
|
|
142
145
|
import { oc } from '@orangecheck/me-client';
|
|
@@ -168,7 +171,7 @@ await oc.session.invalidate(session.id);
|
|
|
168
171
|
|
|
169
172
|
## Payment authorization
|
|
170
173
|
|
|
171
|
-
Class B billable event. Sub-Stripe rates (0.5–1.0% percentage-based). The
|
|
174
|
+
Class B billable event. Sub-Stripe rates (0.5–1.0% percentage-based). The person earns the share you set per event (`user_share_pct`, 0 to 0.8 of the gross fee; OC keeps 20%, and the default templates give 0.8), and it lands in their balance at ochk.app.
|
|
172
175
|
|
|
173
176
|
```ts
|
|
174
177
|
import { oc } from '@orangecheck/me-client';
|
|
@@ -275,13 +278,13 @@ app.get('/api/me', (c) => {
|
|
|
275
278
|
|
|
276
279
|
### Sessions ended everywhere
|
|
277
280
|
|
|
278
|
-
A *.ochk.io site that reads the family cookie (no `audience`) sees family sessions, which ochk.io ends on its own feed. Set `OC_REVOCATION_FEED_TOKEN` (the site's feed token from ochk.io) and the helpers check every family session against it, once a minute per process; while the feed can't be read, reads go on and writes answer 503. With it unset, a family session
|
|
281
|
+
A *.ochk.io site that reads the family cookie (no `audience`) sees family sessions, which ochk.io ends on its own feed. Set `OC_REVOCATION_FEED_TOKEN` (the site's feed token from ochk.io) and the helpers check every family session against it, once a minute per process; while the feed can't be read, reads go on and writes answer 503. With it unset, they answer a family session 503 `revocation_feed_unconfigured` and log once which setting is missing, rather than accept it by signature alone; `revocation: false` reads it by signature alone on purpose. The feed is read from `OC_AUTH_ISSUER` (default https://ochk.io), so set it too if you verify another issuer.
|
|
279
282
|
|
|
280
283
|
Set `OC_PROJECT_KEY` and `OC_SIGNING_SECRET` (from ochk.app/me/projects) and `getOcSession`, `withOcAuth`, `ocAuthExpress` and `ocAuthHono` refuse a session the person ended everywhere: sign out everywhere, a passkey removed, the account deleted. A sign-in token carries `rh`, its revocation handle for your origin; they look it up in me.ochk.io's list of ended handles for that origin, read once a minute per origin with a request signed by your secret, so a refusal lands within about two minutes. The handles name nobody, and another site's handles for the same person never match yours. If the list can't be read, or is more than ten minutes old by its own clock, reads go on and writes are refused until it can: the adapters answer such a write `503 { reason: 'revocations_unavailable' }` (0.38.0), not 401, so a client retries instead of signing the person out, and `checkOcSession(headers, options)` tells the same apart for your own code (`signed_in`, `signed_out` or `unavailable`). Every token while the two variables are unset is checked by its signature alone and stays valid until it expires. A token bound to your site without `rh` is refused (`no_session_handle`, 0.40.0 or later), since sign out everywhere can't reach it; every token from the sign-in popup carries one, and `requireHandle: false` accepts one minted some other way. Needs 0.35.0 or later.
|
|
281
284
|
|
|
282
285
|
### Sign in from an app on the person's device
|
|
283
286
|
|
|
284
|
-
A desktop build or a game can't open the popup, and must not carry a secret. It signs the person in through their browser instead (0.50.0
|
|
287
|
+
A desktop build or a game can't open the popup, and must not carry a secret. It signs the person in through their browser instead (0.50.0; a test project signs in only its own developer, and a live project needs a verified domain): the app listens on `127.0.0.1`, opens ochk.io's `/native/authorize` with a PKCE challenge, and its listener receives a one-time `code`. The app hands the code, its verifier and its redirect to your server, which trades them:
|
|
285
288
|
|
|
286
289
|
```ts
|
|
287
290
|
import { exchangeNativeCode, spendOnce } from '@orangecheck/me-client/server';
|
|
@@ -302,7 +305,7 @@ if (out.status === 'valid' && (await spendOnce(out.session.jti, out.session.exp
|
|
|
302
305
|
|
|
303
306
|
Start a session only from `valid`. It means what a request through `withOcAuth` means: the token is the popup's, verified for your `audience`, with `azp: "native"`; the person has not ended it everywhere; and the account meets your project's "who can sign in" rule. The key decides whose rule and list of ended sessions apply, so it comes from your config (`projectKey`, default `OC_PROJECT_KEY`), and a `projectKey` in the input throws. The list of ended sessions is read with your project key and `OC_SIGNING_SECRET`, as the adapters read it, or pass `revocation`; the trade counts as a write, so a list that can't be read answers `unavailable`.
|
|
304
307
|
|
|
305
|
-
`invalid` names why: `invalid_grant` (start again), `session_ended`, or `bond_required` with `need`, `have` and `back_url`, as the adapters' 403 carries them. `unavailable` is an outage (`revocations_unavailable` and `bond_policy_unavailable` among them), so answer it 503. Each code works once, whatever the answer. Turn native sign-in on for
|
|
308
|
+
`invalid` names why: `invalid_grant` (start again), `session_ended`, or `bond_required` with `need`, `have` and `back_url`, as the adapters' 403 carries them. `unavailable` is an outage (`revocations_unavailable` and `bond_policy_unavailable` among them), so answer it 503. Each code works once, whatever the answer. Turn native sign-in on for your project on ochk.app, under **Sign-in → Sign in from apps**; the app's half, with a Godot example, is at ochk.io/docs/integration/native-sign-in.
|
|
306
309
|
|
|
307
310
|
## Keep your own login: OC Connect
|
|
308
311
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './identity-DfxCvxuH.mjs';
|
|
2
2
|
export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-DfxCvxuH.mjs';
|
|
3
|
-
import { B as BillableEvent, E as EventKey, I as IntegratorPriceConfig, T as TelemetryEvent, S as SignInOptions, a as Session, P as PaymentAuthorizeOptions, b as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-
|
|
4
|
-
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, e as AgentClassOverride, h as AttestTier, C as CUSTOM_EVENT_KEY_RE, i as ClassASubtype, j as ClassBSubtype, k as ClassCSubtype, l as ComputedFees, D as DropCadence, m as DropClosedWebhookPayload, n as DropResponseBlock, o as DropScheduleSummary, p as EVENT_SUBTYPES, q as EventClass, r as EventSubtype, s as EventSubtypeMetadata, t as FederationMigratingWebhookPayload, u as FederationMigrationCancelledWebhookPayload, v as FederationStatus, w as FederationSuccessor, x as IntegratorArchetype, y as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, z as MIN_INTEGRATOR_PRICE_SATS, G as PLATFORM_FEE_POLICY, H as SessionPolicy, J as SigningMethod, K as SiteFeeShape, L as SystemWebhookPayload, W as WebhookHeaders, N as WebhookPayload, O as computeFees, Q as isEventClass, R as isInheritedName, U as subtypesForClass, X as validateIntegratorConfig } from './integrator-
|
|
3
|
+
import { B as BillableEvent, E as EventKey, I as IntegratorPriceConfig, T as TelemetryEvent, S as SignInOptions, a as Session, P as PaymentAuthorizeOptions, b as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-BmRHP_iX.mjs';
|
|
4
|
+
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, e as AgentClassOverride, h as AttestTier, C as CUSTOM_EVENT_KEY_RE, i as ClassASubtype, j as ClassBSubtype, k as ClassCSubtype, l as ComputedFees, D as DropCadence, m as DropClosedWebhookPayload, n as DropResponseBlock, o as DropScheduleSummary, p as EVENT_SUBTYPES, q as EventClass, r as EventSubtype, s as EventSubtypeMetadata, t as FederationMigratingWebhookPayload, u as FederationMigrationCancelledWebhookPayload, v as FederationStatus, w as FederationSuccessor, x as IntegratorArchetype, y as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, z as MIN_INTEGRATOR_PRICE_SATS, G as PLATFORM_FEE_POLICY, H as SessionPolicy, J as SigningMethod, K as SiteFeeShape, L as SystemWebhookPayload, W as WebhookHeaders, N as WebhookPayload, O as computeFees, Q as isEventClass, R as isInheritedName, U as subtypesForClass, X as validateIntegratorConfig } from './integrator-BmRHP_iX.mjs';
|
|
5
5
|
export { CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL } from './connect-consent.mjs';
|
|
6
6
|
|
|
7
7
|
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count' | 'trust_attestation_count';
|
|
@@ -14,6 +14,8 @@ interface TrustAttestationCount {
|
|
|
14
14
|
declare function parseTrustAttestationCount(value: string): TrustAttestationCount | null;
|
|
15
15
|
interface GrantedOptions {
|
|
16
16
|
project_key: string;
|
|
17
|
+
accountId?: string;
|
|
18
|
+
signingSecret?: string;
|
|
17
19
|
signal?: AbortSignal;
|
|
18
20
|
}
|
|
19
21
|
interface GrantedResult {
|
|
@@ -131,6 +133,7 @@ interface BatchEventInput {
|
|
|
131
133
|
idempotency_key?: string;
|
|
132
134
|
is_agent?: boolean;
|
|
133
135
|
}
|
|
136
|
+
type BatchRejectCode = 'subtype_required' | 'invalid_note' | 'invalid_action_label' | 'event_not_enabled' | 'event_class_invalid' | 'payment_amount_sats_required' | 'agent_refused' | 'earning_below_one_sat' | 'site_cap_exceeded' | 'idempotency_key_too_long' | 'duplicate_idempotency_key' | 'idempotency_key_in_flight' | 'identity_cap_reached' | 'escrow_depleted' | 'write_failed' | 'outcome_unknown';
|
|
134
137
|
type BatchEventResult = {
|
|
135
138
|
index: number;
|
|
136
139
|
status: 'recorded';
|
|
@@ -142,6 +145,7 @@ type BatchEventResult = {
|
|
|
142
145
|
} | {
|
|
143
146
|
index: number;
|
|
144
147
|
status: 'rejected';
|
|
148
|
+
code?: BatchRejectCode;
|
|
145
149
|
reason: string;
|
|
146
150
|
} | {
|
|
147
151
|
index: number;
|
|
@@ -289,4 +293,4 @@ declare const oc: {
|
|
|
289
293
|
};
|
|
290
294
|
};
|
|
291
295
|
|
|
292
|
-
export { ArchetypeTemplate, type BatchEventResult, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
296
|
+
export { ArchetypeTemplate, type BatchEventResult, type BatchRejectCode, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './identity-DfxCvxuH.js';
|
|
2
2
|
export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-DfxCvxuH.js';
|
|
3
|
-
import { B as BillableEvent, E as EventKey, I as IntegratorPriceConfig, T as TelemetryEvent, S as SignInOptions, a as Session, P as PaymentAuthorizeOptions, b as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-
|
|
4
|
-
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, e as AgentClassOverride, h as AttestTier, C as CUSTOM_EVENT_KEY_RE, i as ClassASubtype, j as ClassBSubtype, k as ClassCSubtype, l as ComputedFees, D as DropCadence, m as DropClosedWebhookPayload, n as DropResponseBlock, o as DropScheduleSummary, p as EVENT_SUBTYPES, q as EventClass, r as EventSubtype, s as EventSubtypeMetadata, t as FederationMigratingWebhookPayload, u as FederationMigrationCancelledWebhookPayload, v as FederationStatus, w as FederationSuccessor, x as IntegratorArchetype, y as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, z as MIN_INTEGRATOR_PRICE_SATS, G as PLATFORM_FEE_POLICY, H as SessionPolicy, J as SigningMethod, K as SiteFeeShape, L as SystemWebhookPayload, W as WebhookHeaders, N as WebhookPayload, O as computeFees, Q as isEventClass, R as isInheritedName, U as subtypesForClass, X as validateIntegratorConfig } from './integrator-
|
|
3
|
+
import { B as BillableEvent, E as EventKey, I as IntegratorPriceConfig, T as TelemetryEvent, S as SignInOptions, a as Session, P as PaymentAuthorizeOptions, b as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-BmRHP_iX.js';
|
|
4
|
+
export { c as ALL_EVENT_SUBTYPES, d as ARCHETYPE_TEMPLATES, e as AgentClassOverride, h as AttestTier, C as CUSTOM_EVENT_KEY_RE, i as ClassASubtype, j as ClassBSubtype, k as ClassCSubtype, l as ComputedFees, D as DropCadence, m as DropClosedWebhookPayload, n as DropResponseBlock, o as DropScheduleSummary, p as EVENT_SUBTYPES, q as EventClass, r as EventSubtype, s as EventSubtypeMetadata, t as FederationMigratingWebhookPayload, u as FederationMigrationCancelledWebhookPayload, v as FederationStatus, w as FederationSuccessor, x as IntegratorArchetype, y as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, z as MIN_INTEGRATOR_PRICE_SATS, G as PLATFORM_FEE_POLICY, H as SessionPolicy, J as SigningMethod, K as SiteFeeShape, L as SystemWebhookPayload, W as WebhookHeaders, N as WebhookPayload, O as computeFees, Q as isEventClass, R as isInheritedName, U as subtypesForClass, X as validateIntegratorConfig } from './integrator-BmRHP_iX.js';
|
|
5
5
|
export { CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL } from './connect-consent.js';
|
|
6
6
|
|
|
7
7
|
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count' | 'trust_attestation_count';
|
|
@@ -14,6 +14,8 @@ interface TrustAttestationCount {
|
|
|
14
14
|
declare function parseTrustAttestationCount(value: string): TrustAttestationCount | null;
|
|
15
15
|
interface GrantedOptions {
|
|
16
16
|
project_key: string;
|
|
17
|
+
accountId?: string;
|
|
18
|
+
signingSecret?: string;
|
|
17
19
|
signal?: AbortSignal;
|
|
18
20
|
}
|
|
19
21
|
interface GrantedResult {
|
|
@@ -131,6 +133,7 @@ interface BatchEventInput {
|
|
|
131
133
|
idempotency_key?: string;
|
|
132
134
|
is_agent?: boolean;
|
|
133
135
|
}
|
|
136
|
+
type BatchRejectCode = 'subtype_required' | 'invalid_note' | 'invalid_action_label' | 'event_not_enabled' | 'event_class_invalid' | 'payment_amount_sats_required' | 'agent_refused' | 'earning_below_one_sat' | 'site_cap_exceeded' | 'idempotency_key_too_long' | 'duplicate_idempotency_key' | 'idempotency_key_in_flight' | 'identity_cap_reached' | 'escrow_depleted' | 'write_failed' | 'outcome_unknown';
|
|
134
137
|
type BatchEventResult = {
|
|
135
138
|
index: number;
|
|
136
139
|
status: 'recorded';
|
|
@@ -142,6 +145,7 @@ type BatchEventResult = {
|
|
|
142
145
|
} | {
|
|
143
146
|
index: number;
|
|
144
147
|
status: 'rejected';
|
|
148
|
+
code?: BatchRejectCode;
|
|
145
149
|
reason: string;
|
|
146
150
|
} | {
|
|
147
151
|
index: number;
|
|
@@ -289,4 +293,4 @@ declare const oc: {
|
|
|
289
293
|
};
|
|
290
294
|
};
|
|
291
295
|
|
|
292
|
-
export { ArchetypeTemplate, type BatchEventResult, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
296
|
+
export { ArchetypeTemplate, type BatchEventResult, type BatchRejectCode, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireBatchResponse, type FireEventOptions, type FireEventResult, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, type PayPeriod, type PayingState, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SignInOptions, TelemetryEvent, type TrustAttestationCount, ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var identifiers = require('@orangecheck/auth-core/identifiers');
|
|
4
|
+
|
|
3
5
|
var __defProp = Object.defineProperty;
|
|
4
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
7
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -46,7 +48,7 @@ async function api(path, opts = {}) {
|
|
|
46
48
|
body = data;
|
|
47
49
|
if (data?.error) {
|
|
48
50
|
errorCode = data.error;
|
|
49
|
-
message = data.reason ?? data.error;
|
|
51
|
+
message = data.reason ?? data.detail ?? data.error;
|
|
50
52
|
}
|
|
51
53
|
} catch {
|
|
52
54
|
}
|
|
@@ -1298,8 +1300,6 @@ async function defaultLive() {
|
|
|
1298
1300
|
return all[0] ?? null;
|
|
1299
1301
|
}
|
|
1300
1302
|
var federations = { list, live, get, defaultLive };
|
|
1301
|
-
|
|
1302
|
-
// src/scope.ts
|
|
1303
1303
|
var CONSENT_ORIGIN = "https://ochk.app";
|
|
1304
1304
|
var VALID_SCOPES = [
|
|
1305
1305
|
"bitcoin_address",
|
|
@@ -1326,9 +1326,28 @@ async function granted(options) {
|
|
|
1326
1326
|
if (!options.project_key) {
|
|
1327
1327
|
throw new Error("oc.scope.granted: project_key is required");
|
|
1328
1328
|
}
|
|
1329
|
+
const { accountId, signingSecret } = options;
|
|
1330
|
+
if (accountId !== void 0 && !signingSecret) {
|
|
1331
|
+
throw new Error("oc.scope.granted: accountId names the person, so it requires signingSecret");
|
|
1332
|
+
}
|
|
1333
|
+
if (signingSecret && accountId === void 0) {
|
|
1334
|
+
throw new Error("oc.scope.granted: signingSecret signs a question about one person, so it requires accountId");
|
|
1335
|
+
}
|
|
1336
|
+
if (accountId !== void 0 && !identifiers.isDidOc(accountId)) {
|
|
1337
|
+
throw new Error("oc.scope.granted: accountId must be a did:oc exactly as issued (did:oc: and 32 lowercase hex)");
|
|
1338
|
+
}
|
|
1339
|
+
let path = `/api/integrator/scopes/${encodeURIComponent(options.project_key)}`;
|
|
1340
|
+
const headers = {};
|
|
1341
|
+
if (accountId !== void 0 && signingSecret) {
|
|
1342
|
+
path += `?user=${encodeURIComponent(accountId)}`;
|
|
1343
|
+
headers["x-oc-signature"] = await signBody(
|
|
1344
|
+
signingSecret,
|
|
1345
|
+
`project_key=${options.project_key}&user=${accountId}`
|
|
1346
|
+
);
|
|
1347
|
+
}
|
|
1329
1348
|
const r = await api(
|
|
1330
|
-
|
|
1331
|
-
{ method: "GET", signal: options.signal }
|
|
1349
|
+
path,
|
|
1350
|
+
{ method: "GET", signal: options.signal, headers }
|
|
1332
1351
|
);
|
|
1333
1352
|
return {
|
|
1334
1353
|
sub: r.sub,
|