@orangecheck/me-client 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +52 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{integrator-BLBD-0q4.d.mts → integrator-XkSgSrD4.d.mts} +6 -5
- package/dist/{integrator-BLBD-0q4.d.ts → integrator-XkSgSrD4.d.ts} +6 -5
- 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/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v as verifyActivityAttestation, r as refreshEnvelopeJwks } from './identity-1VYMOhzV.mjs';
|
|
2
2
|
export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-1VYMOhzV.mjs';
|
|
3
|
-
import { E as
|
|
4
|
-
export { d as ALL_EVENT_SUBTYPES, e as ARCHETYPE_TEMPLATES, h as AgentClassOverride, i as AttestTier, C 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
|
|
3
|
+
import { E as EventKey, B as BillableEvent, I as IntegratorPriceConfig, S as SessionPolicy, a as Session, T as TelemetryEvent, b as SignInOptions, P as PaymentAuthorizeOptions, c as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-XkSgSrD4.mjs';
|
|
4
|
+
export { d as ALL_EVENT_SUBTYPES, e as ARCHETYPE_TEMPLATES, h as AgentClassOverride, i as AttestTier, C 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 FederationStatus, u as IntegratorArchetype, v as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, w as MIN_INTEGRATOR_PRICE_SATS, x as PLATFORM_FEE_POLICY, y as SigningMethod, z as SiteFeeShape, G as SystemWebhookPayload, W as WebhookHeaders, H as WebhookPayload, J as computeFees, K as subtypesForClass, L as validateIntegratorConfig } from './integrator-XkSgSrD4.mjs';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
|
|
@@ -81,16 +81,18 @@ declare const webhook: {
|
|
|
81
81
|
|
|
82
82
|
interface FireEventOptions {
|
|
83
83
|
project_key: string;
|
|
84
|
-
subtype:
|
|
84
|
+
subtype: EventKey;
|
|
85
85
|
action_label?: string;
|
|
86
86
|
payment_amount_sats?: number;
|
|
87
|
-
user_address?: string;
|
|
88
87
|
metadata?: Record<string, unknown>;
|
|
89
88
|
is_agent?: boolean;
|
|
89
|
+
signingSecret?: string;
|
|
90
|
+
bearerToken?: string;
|
|
91
|
+
idempotencyKey?: string;
|
|
90
92
|
}
|
|
91
93
|
declare function fire(options: FireEventOptions): Promise<BillableEvent>;
|
|
92
94
|
interface BatchEventInput {
|
|
93
|
-
subtype:
|
|
95
|
+
subtype: EventKey;
|
|
94
96
|
payment_amount_sats?: number;
|
|
95
97
|
action_label?: string;
|
|
96
98
|
note?: string;
|
|
@@ -113,6 +115,8 @@ type BatchEventResult = {
|
|
|
113
115
|
interface FireBatchOptions {
|
|
114
116
|
project_key: string;
|
|
115
117
|
events: BatchEventInput[];
|
|
118
|
+
signingSecret?: string;
|
|
119
|
+
bearerToken?: string;
|
|
116
120
|
}
|
|
117
121
|
interface FireBatchResponse {
|
|
118
122
|
ok: boolean;
|
|
@@ -253,4 +257,4 @@ declare const oc: {
|
|
|
253
257
|
};
|
|
254
258
|
};
|
|
255
259
|
|
|
256
|
-
export { ArchetypeTemplate, BillableEvent,
|
|
260
|
+
export { ArchetypeTemplate, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireEventOptions, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SessionPolicy, 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, payment, refreshEnvelopeJwks, 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-1VYMOhzV.js';
|
|
2
2
|
export { A as ActivityAttestation, a as ActivityAttestationBundle, b as ActivityVerifyCheck, c as ActivityVerifyResult, V as VerifyActivityOptions, i as identity } from './identity-1VYMOhzV.js';
|
|
3
|
-
import { E as
|
|
4
|
-
export { d as ALL_EVENT_SUBTYPES, e as ARCHETYPE_TEMPLATES, h as AgentClassOverride, i as AttestTier, C 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
|
|
3
|
+
import { E as EventKey, B as BillableEvent, I as IntegratorPriceConfig, S as SessionPolicy, a as Session, T as TelemetryEvent, b as SignInOptions, P as PaymentAuthorizeOptions, c as PaymentResult, V as ValidationResult, f as fromTemplate, g as getArchetypeTemplate, A as ArchetypeTemplate, F as Federation } from './integrator-XkSgSrD4.js';
|
|
4
|
+
export { d as ALL_EVENT_SUBTYPES, e as ARCHETYPE_TEMPLATES, h as AgentClassOverride, i as AttestTier, C 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 FederationStatus, u as IntegratorArchetype, v as IntegratorEventConfig, M as MAX_DROP_WINDOW_DAYS, w as MIN_INTEGRATOR_PRICE_SATS, x as PLATFORM_FEE_POLICY, y as SigningMethod, z as SiteFeeShape, G as SystemWebhookPayload, W as WebhookHeaders, H as WebhookPayload, J as computeFees, K as subtypesForClass, L as validateIntegratorConfig } from './integrator-XkSgSrD4.js';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
|
|
@@ -81,16 +81,18 @@ declare const webhook: {
|
|
|
81
81
|
|
|
82
82
|
interface FireEventOptions {
|
|
83
83
|
project_key: string;
|
|
84
|
-
subtype:
|
|
84
|
+
subtype: EventKey;
|
|
85
85
|
action_label?: string;
|
|
86
86
|
payment_amount_sats?: number;
|
|
87
|
-
user_address?: string;
|
|
88
87
|
metadata?: Record<string, unknown>;
|
|
89
88
|
is_agent?: boolean;
|
|
89
|
+
signingSecret?: string;
|
|
90
|
+
bearerToken?: string;
|
|
91
|
+
idempotencyKey?: string;
|
|
90
92
|
}
|
|
91
93
|
declare function fire(options: FireEventOptions): Promise<BillableEvent>;
|
|
92
94
|
interface BatchEventInput {
|
|
93
|
-
subtype:
|
|
95
|
+
subtype: EventKey;
|
|
94
96
|
payment_amount_sats?: number;
|
|
95
97
|
action_label?: string;
|
|
96
98
|
note?: string;
|
|
@@ -113,6 +115,8 @@ type BatchEventResult = {
|
|
|
113
115
|
interface FireBatchOptions {
|
|
114
116
|
project_key: string;
|
|
115
117
|
events: BatchEventInput[];
|
|
118
|
+
signingSecret?: string;
|
|
119
|
+
bearerToken?: string;
|
|
116
120
|
}
|
|
117
121
|
interface FireBatchResponse {
|
|
118
122
|
ok: boolean;
|
|
@@ -253,4 +257,4 @@ declare const oc: {
|
|
|
253
257
|
};
|
|
254
258
|
};
|
|
255
259
|
|
|
256
|
-
export { ArchetypeTemplate, BillableEvent,
|
|
260
|
+
export { ArchetypeTemplate, BillableEvent, EventKey, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, Federation, type FireEventOptions, type GrantedOptions, type GrantedResult, IntegratorPriceConfig, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PaymentAuthorizeOptions, PaymentResult, type RequestOptions, type Scope, Session, SessionPolicy, 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, payment, refreshEnvelopeJwks, scope, session, setBearerToken, setOrigin, verifyActivityAttestation, webhook, withRateLimitRetry };
|
package/dist/index.js
CHANGED
|
@@ -48,9 +48,11 @@ function clearBearerToken() {
|
|
|
48
48
|
async function api(path, opts = {}) {
|
|
49
49
|
const headers = {
|
|
50
50
|
"content-type": "application/json",
|
|
51
|
-
accept: "application/json"
|
|
51
|
+
accept: "application/json",
|
|
52
|
+
...opts.headers ?? {}
|
|
52
53
|
};
|
|
53
|
-
|
|
54
|
+
const token = opts.bearerToken ?? bearerToken;
|
|
55
|
+
if (token) headers["authorization"] = `Bearer ${token}`;
|
|
54
56
|
const res = await fetch(`${origin}${path}`, {
|
|
55
57
|
method: opts.method ?? "GET",
|
|
56
58
|
credentials: "include",
|
|
@@ -336,6 +338,23 @@ function validateIntegratorConfig(cfg) {
|
|
|
336
338
|
}
|
|
337
339
|
|
|
338
340
|
// src/event.ts
|
|
341
|
+
async function hmacSha256Hex(secret, message) {
|
|
342
|
+
const enc = new TextEncoder();
|
|
343
|
+
const key = await crypto.subtle.importKey(
|
|
344
|
+
"raw",
|
|
345
|
+
enc.encode(secret),
|
|
346
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
347
|
+
false,
|
|
348
|
+
["sign"]
|
|
349
|
+
);
|
|
350
|
+
const sig = await crypto.subtle.sign("HMAC", key, enc.encode(message));
|
|
351
|
+
return Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
352
|
+
}
|
|
353
|
+
async function signBody(secret, serializedBody) {
|
|
354
|
+
const t = Math.floor(Date.now() / 1e3);
|
|
355
|
+
const mac = await hmacSha256Hex(secret, `${t}.${serializedBody}`);
|
|
356
|
+
return `t=${t},v1=${mac}`;
|
|
357
|
+
}
|
|
339
358
|
async function fire(options) {
|
|
340
359
|
if (!options.project_key) {
|
|
341
360
|
throw new Error("event.fire requires project_key");
|
|
@@ -343,9 +362,28 @@ async function fire(options) {
|
|
|
343
362
|
if (!options.subtype) {
|
|
344
363
|
throw new Error("event.fire requires subtype");
|
|
345
364
|
}
|
|
365
|
+
const requestBody = {
|
|
366
|
+
project_key: options.project_key,
|
|
367
|
+
subtype: options.subtype
|
|
368
|
+
};
|
|
369
|
+
if (options.payment_amount_sats !== void 0)
|
|
370
|
+
requestBody.payment_amount_sats = options.payment_amount_sats;
|
|
371
|
+
if (options.action_label !== void 0) requestBody.action_label = options.action_label;
|
|
372
|
+
if (options.metadata !== void 0) requestBody.metadata = options.metadata;
|
|
373
|
+
if (options.is_agent !== void 0) requestBody.is_agent = options.is_agent;
|
|
374
|
+
const headers = {};
|
|
375
|
+
if (options.idempotencyKey) headers["idempotency-key"] = options.idempotencyKey;
|
|
376
|
+
if (options.signingSecret) {
|
|
377
|
+
headers["x-oc-signature"] = await signBody(
|
|
378
|
+
options.signingSecret,
|
|
379
|
+
JSON.stringify(requestBody)
|
|
380
|
+
);
|
|
381
|
+
}
|
|
346
382
|
return api("/api/integrator/event", {
|
|
347
383
|
method: "POST",
|
|
348
|
-
body:
|
|
384
|
+
body: requestBody,
|
|
385
|
+
headers,
|
|
386
|
+
bearerToken: options.bearerToken
|
|
349
387
|
});
|
|
350
388
|
}
|
|
351
389
|
async function fireBatch(options) {
|
|
@@ -360,9 +398,19 @@ async function fireBatch(options) {
|
|
|
360
398
|
`event.fireBatch \xB7 max 100 events per call (got ${options.events.length}). Split client-side.`
|
|
361
399
|
);
|
|
362
400
|
}
|
|
401
|
+
const requestBody = { project_key: options.project_key, events: options.events };
|
|
402
|
+
const headers = {};
|
|
403
|
+
if (options.signingSecret) {
|
|
404
|
+
headers["x-oc-signature"] = await signBody(
|
|
405
|
+
options.signingSecret,
|
|
406
|
+
JSON.stringify(requestBody)
|
|
407
|
+
);
|
|
408
|
+
}
|
|
363
409
|
return api("/api/integrator/event/batch", {
|
|
364
410
|
method: "POST",
|
|
365
|
-
body:
|
|
411
|
+
body: requestBody,
|
|
412
|
+
headers,
|
|
413
|
+
bearerToken: options.bearerToken
|
|
366
414
|
});
|
|
367
415
|
}
|
|
368
416
|
function verify(envelope, config2, payment_amount_sats) {
|