@orangecheck/me-client 0.56.0 → 0.58.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 +77 -4
- package/README.md +13 -9
- package/dist/index.d.mts +5 -33
- package/dist/index.d.ts +5 -33
- package/dist/index.js +38 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -12
- package/dist/index.mjs.map +1 -1
- package/dist/{integrator-DDeHg7vj.d.mts → integrator-fTchEeNJ.d.mts} +39 -5
- package/dist/{integrator-DDeHg7vj.d.ts → integrator-fTchEeNJ.d.ts} +39 -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/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/dist/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isDidOc } from '@orangecheck/auth-core/identifiers';
|
|
2
|
+
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
5
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -44,7 +46,7 @@ async function api(path, opts = {}) {
|
|
|
44
46
|
body = data;
|
|
45
47
|
if (data?.error) {
|
|
46
48
|
errorCode = data.error;
|
|
47
|
-
message = data.reason ?? data.error;
|
|
49
|
+
message = data.reason ?? data.detail ?? data.error;
|
|
48
50
|
}
|
|
49
51
|
} catch {
|
|
50
52
|
}
|
|
@@ -160,9 +162,11 @@ async function authorize(opts) {
|
|
|
160
162
|
if (opts.amount_sats == null && opts.usd_cents == null) {
|
|
161
163
|
throw new Error("payment.authorize requires amount_sats or usd_cents");
|
|
162
164
|
}
|
|
165
|
+
const { bearerToken: bearerToken2, ...body } = opts;
|
|
163
166
|
return api("/api/payment/authorize", {
|
|
164
167
|
method: "POST",
|
|
165
|
-
body
|
|
168
|
+
body,
|
|
169
|
+
bearerToken: bearerToken2
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
172
|
var payment = { authorize };
|
|
@@ -1296,18 +1300,21 @@ async function defaultLive() {
|
|
|
1296
1300
|
return all[0] ?? null;
|
|
1297
1301
|
}
|
|
1298
1302
|
var federations = { list, live, get, defaultLive };
|
|
1299
|
-
|
|
1300
|
-
// src/scope.ts
|
|
1301
1303
|
var CONSENT_ORIGIN = "https://ochk.app";
|
|
1302
|
-
var
|
|
1304
|
+
var SCOPE_IDS = Object.freeze([
|
|
1303
1305
|
"bitcoin_address",
|
|
1304
1306
|
"email",
|
|
1305
1307
|
"attest_tier",
|
|
1306
1308
|
"display_name",
|
|
1307
1309
|
"cross_integrator_event_count",
|
|
1308
1310
|
"cross_integrator_human_event_count",
|
|
1309
|
-
"
|
|
1310
|
-
|
|
1311
|
+
"cross_integrator_lifetime_sats",
|
|
1312
|
+
"cross_integrator_distinct_count",
|
|
1313
|
+
"cross_integrator_oldest_event_at",
|
|
1314
|
+
"cross_integrator_active_days",
|
|
1315
|
+
"trust_attestation_count",
|
|
1316
|
+
"trust_attestations_bundle"
|
|
1317
|
+
]);
|
|
1311
1318
|
function parseTrustAttestationCount(value) {
|
|
1312
1319
|
const parts = value.split(",");
|
|
1313
1320
|
if (parts.length !== 4) return null;
|
|
@@ -1324,9 +1331,28 @@ async function granted(options) {
|
|
|
1324
1331
|
if (!options.project_key) {
|
|
1325
1332
|
throw new Error("oc.scope.granted: project_key is required");
|
|
1326
1333
|
}
|
|
1334
|
+
const { accountId, signingSecret } = options;
|
|
1335
|
+
if (accountId !== void 0 && !signingSecret) {
|
|
1336
|
+
throw new Error("oc.scope.granted: accountId names the person, so it requires signingSecret");
|
|
1337
|
+
}
|
|
1338
|
+
if (signingSecret && accountId === void 0) {
|
|
1339
|
+
throw new Error("oc.scope.granted: signingSecret signs a question about one person, so it requires accountId");
|
|
1340
|
+
}
|
|
1341
|
+
if (accountId !== void 0 && !isDidOc(accountId)) {
|
|
1342
|
+
throw new Error("oc.scope.granted: accountId must be a did:oc exactly as issued (did:oc: and 32 lowercase hex)");
|
|
1343
|
+
}
|
|
1344
|
+
let path = `/api/integrator/scopes/${encodeURIComponent(options.project_key)}`;
|
|
1345
|
+
const headers = {};
|
|
1346
|
+
if (accountId !== void 0 && signingSecret) {
|
|
1347
|
+
path += `?user=${encodeURIComponent(accountId)}`;
|
|
1348
|
+
headers["x-oc-signature"] = await signBody(
|
|
1349
|
+
signingSecret,
|
|
1350
|
+
`project_key=${options.project_key}&user=${accountId}`
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1327
1353
|
const r = await api(
|
|
1328
|
-
|
|
1329
|
-
{ method: "GET", signal: options.signal }
|
|
1354
|
+
path,
|
|
1355
|
+
{ method: "GET", signal: options.signal, headers }
|
|
1330
1356
|
);
|
|
1331
1357
|
return {
|
|
1332
1358
|
sub: r.sub,
|
|
@@ -1345,9 +1371,9 @@ function request(scopes2, options) {
|
|
|
1345
1371
|
throw new Error("oc.scope.request: scopes must be a non-empty array");
|
|
1346
1372
|
}
|
|
1347
1373
|
for (const s of scopes2) {
|
|
1348
|
-
if (!
|
|
1374
|
+
if (!SCOPE_IDS.includes(s)) {
|
|
1349
1375
|
throw new Error(
|
|
1350
|
-
`oc.scope.request: unknown scope "${s}" \xB7 valid: ${
|
|
1376
|
+
`oc.scope.request: unknown scope "${s}" \xB7 valid: ${SCOPE_IDS.join(", ")}`
|
|
1351
1377
|
);
|
|
1352
1378
|
}
|
|
1353
1379
|
}
|
|
@@ -1709,6 +1735,6 @@ var oc = {
|
|
|
1709
1735
|
identity
|
|
1710
1736
|
};
|
|
1711
1737
|
|
|
1712
|
-
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL, CUSTOM_EVENT_KEY_RE, EVENT_SUBTYPES, MAX_DROP_WINDOW_DAYS, MIN_INTEGRATOR_PRICE_SATS, MeClientError, PLATFORM_FEE_POLICY, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, identity, isEventClass, isInheritedName, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
1738
|
+
export { ALL_EVENT_SUBTYPES, ARCHETYPE_TEMPLATES, CONNECT_CONSENT_BLURB, CONNECT_CONSENT_LABEL, CUSTOM_EVENT_KEY_RE, EVENT_SUBTYPES, MAX_DROP_WINDOW_DAYS, MIN_INTEGRATOR_PRICE_SATS, MeClientError, PLATFORM_FEE_POLICY, SCOPE_IDS, clearBearerToken, computeFees, config, fromTemplate as configFromTemplate, event, family, federations, getArchetypeTemplate, getBearerToken, getOrigin, identity, isEventClass, isInheritedName, oc, onTelemetry, parseTrustAttestationCount, payingAt, payment, refreshEnvelopeJwks, safeReturnPath, scope, session, setBearerToken, setOrigin, subtypesForClass, validateIntegratorConfig, verifyActivityAttestation, webhook, withRateLimitRetry };
|
|
1713
1739
|
//# sourceMappingURL=index.mjs.map
|
|
1714
1740
|
//# sourceMappingURL=index.mjs.map
|