@orangecheck/me-client 0.13.0 → 0.15.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 +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +44 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name';
|
|
4
|
+
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count';
|
|
5
5
|
interface GrantedOptions {
|
|
6
6
|
project_key: string;
|
|
7
7
|
signal?: AbortSignal;
|
|
@@ -23,6 +23,26 @@ declare const scope: {
|
|
|
23
23
|
request: typeof request;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
type FamilyVerb = 'oc-vote' | 'oc-stamp' | 'oc-agent' | 'oc-attest' | 'oc-lock';
|
|
27
|
+
interface FamilyScopesOptions {
|
|
28
|
+
origin?: string;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
interface FamilyScopesResult {
|
|
32
|
+
sub: string;
|
|
33
|
+
family_product: {
|
|
34
|
+
verb: FamilyVerb;
|
|
35
|
+
name: string;
|
|
36
|
+
origin: string;
|
|
37
|
+
};
|
|
38
|
+
scopes_granted: Scope[];
|
|
39
|
+
scopes: Partial<Record<Scope, string>>;
|
|
40
|
+
}
|
|
41
|
+
declare function scopes(verb: FamilyVerb, options?: FamilyScopesOptions): Promise<FamilyScopesResult>;
|
|
42
|
+
declare const family: {
|
|
43
|
+
scopes: typeof scopes;
|
|
44
|
+
};
|
|
45
|
+
|
|
26
46
|
interface VerifyResult {
|
|
27
47
|
ok: boolean;
|
|
28
48
|
reason?: string;
|
|
@@ -323,6 +343,9 @@ declare const oc: {
|
|
|
323
343
|
granted: (options: GrantedOptions) => Promise<GrantedResult>;
|
|
324
344
|
request: typeof request;
|
|
325
345
|
};
|
|
346
|
+
family: {
|
|
347
|
+
scopes: (verb: FamilyVerb, options?: FamilyScopesOptions) => Promise<FamilyScopesResult>;
|
|
348
|
+
};
|
|
326
349
|
};
|
|
327
350
|
|
|
328
|
-
export { type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, type EventClass, type EventSubtype, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, event, federations, getBearerToken, getOrigin, oc, onTelemetry, payment, scope, session, setBearerToken, setOrigin, validateIntegratorConfig, webhook, withRateLimitRetry };
|
|
351
|
+
export { type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, type EventClass, type EventSubtype, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, event, family, federations, getBearerToken, getOrigin, oc, onTelemetry, payment, scope, session, setBearerToken, setOrigin, validateIntegratorConfig, webhook, withRateLimitRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name';
|
|
4
|
+
type Scope = 'bitcoin_address' | 'email' | 'attest_tier' | 'display_name' | 'cross_integrator_event_count' | 'cross_integrator_human_event_count';
|
|
5
5
|
interface GrantedOptions {
|
|
6
6
|
project_key: string;
|
|
7
7
|
signal?: AbortSignal;
|
|
@@ -23,6 +23,26 @@ declare const scope: {
|
|
|
23
23
|
request: typeof request;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
type FamilyVerb = 'oc-vote' | 'oc-stamp' | 'oc-agent' | 'oc-attest' | 'oc-lock';
|
|
27
|
+
interface FamilyScopesOptions {
|
|
28
|
+
origin?: string;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
interface FamilyScopesResult {
|
|
32
|
+
sub: string;
|
|
33
|
+
family_product: {
|
|
34
|
+
verb: FamilyVerb;
|
|
35
|
+
name: string;
|
|
36
|
+
origin: string;
|
|
37
|
+
};
|
|
38
|
+
scopes_granted: Scope[];
|
|
39
|
+
scopes: Partial<Record<Scope, string>>;
|
|
40
|
+
}
|
|
41
|
+
declare function scopes(verb: FamilyVerb, options?: FamilyScopesOptions): Promise<FamilyScopesResult>;
|
|
42
|
+
declare const family: {
|
|
43
|
+
scopes: typeof scopes;
|
|
44
|
+
};
|
|
45
|
+
|
|
26
46
|
interface VerifyResult {
|
|
27
47
|
ok: boolean;
|
|
28
48
|
reason?: string;
|
|
@@ -323,6 +343,9 @@ declare const oc: {
|
|
|
323
343
|
granted: (options: GrantedOptions) => Promise<GrantedResult>;
|
|
324
344
|
request: typeof request;
|
|
325
345
|
};
|
|
346
|
+
family: {
|
|
347
|
+
scopes: (verb: FamilyVerb, options?: FamilyScopesOptions) => Promise<FamilyScopesResult>;
|
|
348
|
+
};
|
|
326
349
|
};
|
|
327
350
|
|
|
328
|
-
export { type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, type EventClass, type EventSubtype, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, event, federations, getBearerToken, getOrigin, oc, onTelemetry, payment, scope, session, setBearerToken, setOrigin, validateIntegratorConfig, webhook, withRateLimitRetry };
|
|
351
|
+
export { type AttestTier, type BillableEvent, type ClassASubtype, type ClassBSubtype, type ClassCSubtype, type ComputedFees, type EventClass, type EventSubtype, type FamilyScopesOptions, type FamilyScopesResult, type FamilyVerb, type Federation, type FederationStatus, type FireEventOptions, type GrantedOptions, type GrantedResult, type IntegratorEventConfig, type IntegratorPriceConfig, MIN_INTEGRATOR_PRICE_SATS, MeClientError, type OcPublicJwk, OcSignInButton, type OcSignInButtonProps, PLATFORM_FEE_POLICY, type PaymentAuthorizeOptions, type PaymentResult, type RequestOptions, type Scope, type Session, type SessionPolicy, type SignInOptions, type SigningMethod, type SiteFeeShape, type TelemetryEvent, type ValidationResult, type VerifyEventResult, type VerifyOptions, type VerifyResult, type WithRateLimitRetryOptions, clearBearerToken, computeFees, config, event, family, federations, getBearerToken, getOrigin, oc, onTelemetry, payment, scope, session, setBearerToken, setOrigin, validateIntegratorConfig, webhook, withRateLimitRetry };
|
package/dist/index.js
CHANGED
|
@@ -813,7 +813,9 @@ var VALID_SCOPES = [
|
|
|
813
813
|
"bitcoin_address",
|
|
814
814
|
"email",
|
|
815
815
|
"attest_tier",
|
|
816
|
-
"display_name"
|
|
816
|
+
"display_name",
|
|
817
|
+
"cross_integrator_event_count",
|
|
818
|
+
"cross_integrator_human_event_count"
|
|
817
819
|
];
|
|
818
820
|
async function granted(options) {
|
|
819
821
|
if (!options.project_key) {
|
|
@@ -829,17 +831,17 @@ async function granted(options) {
|
|
|
829
831
|
scopes: r.scopes
|
|
830
832
|
};
|
|
831
833
|
}
|
|
832
|
-
function request(
|
|
834
|
+
function request(scopes2, options) {
|
|
833
835
|
if (!options.project_key) {
|
|
834
836
|
throw new Error("oc.scope.request: project_key is required");
|
|
835
837
|
}
|
|
836
838
|
if (!options.return_to) {
|
|
837
839
|
throw new Error("oc.scope.request: return_to is required");
|
|
838
840
|
}
|
|
839
|
-
if (!Array.isArray(
|
|
841
|
+
if (!Array.isArray(scopes2) || scopes2.length === 0) {
|
|
840
842
|
throw new Error("oc.scope.request: scopes must be a non-empty array");
|
|
841
843
|
}
|
|
842
|
-
for (const s of
|
|
844
|
+
for (const s of scopes2) {
|
|
843
845
|
if (!VALID_SCOPES.includes(s)) {
|
|
844
846
|
throw new Error(
|
|
845
847
|
`oc.scope.request: unknown scope "${s}" \xB7 valid: ${VALID_SCOPES.join(", ")}`
|
|
@@ -852,15 +854,50 @@ function request(scopes, options) {
|
|
|
852
854
|
const origin2 = options.origin ?? getOrigin();
|
|
853
855
|
const url = new URL("/me/scope-grant", origin2);
|
|
854
856
|
url.searchParams.set("project_key", options.project_key);
|
|
855
|
-
url.searchParams.set("scopes",
|
|
857
|
+
url.searchParams.set("scopes", scopes2.join(","));
|
|
856
858
|
url.searchParams.set("return_to", options.return_to);
|
|
857
859
|
window.location.assign(url.toString());
|
|
858
860
|
throw new Error("oc.scope.request: redirected to consent prompt");
|
|
859
861
|
}
|
|
860
862
|
var scope = { granted, request };
|
|
861
863
|
|
|
864
|
+
// src/family.ts
|
|
865
|
+
var VALID_VERBS = [
|
|
866
|
+
"oc-vote",
|
|
867
|
+
"oc-stamp",
|
|
868
|
+
"oc-agent",
|
|
869
|
+
"oc-attest",
|
|
870
|
+
"oc-lock"
|
|
871
|
+
];
|
|
872
|
+
async function scopes(verb, options) {
|
|
873
|
+
if (!VALID_VERBS.includes(verb)) {
|
|
874
|
+
throw new Error(
|
|
875
|
+
`oc.family.scopes: unknown verb "${verb}" \xB7 valid: ${VALID_VERBS.join(", ")}`
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
const origin2 = options?.origin ?? "https://me.ochk.io";
|
|
879
|
+
const url = `${origin2}/api/family/scopes/${encodeURIComponent(verb)}`;
|
|
880
|
+
const res = await fetch(url, {
|
|
881
|
+
method: "GET",
|
|
882
|
+
credentials: "include",
|
|
883
|
+
signal: options?.signal
|
|
884
|
+
});
|
|
885
|
+
if (!res.ok) {
|
|
886
|
+
const txt = await res.text().catch(() => "");
|
|
887
|
+
throw new Error(`oc.family.scopes: ${res.status} ${txt || res.statusText}`);
|
|
888
|
+
}
|
|
889
|
+
const json = await res.json();
|
|
890
|
+
return {
|
|
891
|
+
sub: json.sub,
|
|
892
|
+
family_product: json.family_product,
|
|
893
|
+
scopes_granted: json.scopes_granted,
|
|
894
|
+
scopes: json.scopes
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
var family = { scopes };
|
|
898
|
+
|
|
862
899
|
// src/index.ts
|
|
863
|
-
var oc = { session, payment, event, config, webhook, federations, scope };
|
|
900
|
+
var oc = { session, payment, event, config, webhook, federations, scope, family };
|
|
864
901
|
|
|
865
902
|
exports.MIN_INTEGRATOR_PRICE_SATS = MIN_INTEGRATOR_PRICE_SATS;
|
|
866
903
|
exports.MeClientError = MeClientError;
|
|
@@ -870,6 +907,7 @@ exports.clearBearerToken = clearBearerToken;
|
|
|
870
907
|
exports.computeFees = computeFees;
|
|
871
908
|
exports.config = config;
|
|
872
909
|
exports.event = event;
|
|
910
|
+
exports.family = family;
|
|
873
911
|
exports.federations = federations;
|
|
874
912
|
exports.getBearerToken = getBearerToken;
|
|
875
913
|
exports.getOrigin = getOrigin;
|