@orangecheck/me-client 0.14.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 +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +41 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -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
|
@@ -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
|
@@ -831,17 +831,17 @@ async function granted(options) {
|
|
|
831
831
|
scopes: r.scopes
|
|
832
832
|
};
|
|
833
833
|
}
|
|
834
|
-
function request(
|
|
834
|
+
function request(scopes2, options) {
|
|
835
835
|
if (!options.project_key) {
|
|
836
836
|
throw new Error("oc.scope.request: project_key is required");
|
|
837
837
|
}
|
|
838
838
|
if (!options.return_to) {
|
|
839
839
|
throw new Error("oc.scope.request: return_to is required");
|
|
840
840
|
}
|
|
841
|
-
if (!Array.isArray(
|
|
841
|
+
if (!Array.isArray(scopes2) || scopes2.length === 0) {
|
|
842
842
|
throw new Error("oc.scope.request: scopes must be a non-empty array");
|
|
843
843
|
}
|
|
844
|
-
for (const s of
|
|
844
|
+
for (const s of scopes2) {
|
|
845
845
|
if (!VALID_SCOPES.includes(s)) {
|
|
846
846
|
throw new Error(
|
|
847
847
|
`oc.scope.request: unknown scope "${s}" \xB7 valid: ${VALID_SCOPES.join(", ")}`
|
|
@@ -854,15 +854,50 @@ function request(scopes, options) {
|
|
|
854
854
|
const origin2 = options.origin ?? getOrigin();
|
|
855
855
|
const url = new URL("/me/scope-grant", origin2);
|
|
856
856
|
url.searchParams.set("project_key", options.project_key);
|
|
857
|
-
url.searchParams.set("scopes",
|
|
857
|
+
url.searchParams.set("scopes", scopes2.join(","));
|
|
858
858
|
url.searchParams.set("return_to", options.return_to);
|
|
859
859
|
window.location.assign(url.toString());
|
|
860
860
|
throw new Error("oc.scope.request: redirected to consent prompt");
|
|
861
861
|
}
|
|
862
862
|
var scope = { granted, request };
|
|
863
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
|
+
|
|
864
899
|
// src/index.ts
|
|
865
|
-
var oc = { session, payment, event, config, webhook, federations, scope };
|
|
900
|
+
var oc = { session, payment, event, config, webhook, federations, scope, family };
|
|
866
901
|
|
|
867
902
|
exports.MIN_INTEGRATOR_PRICE_SATS = MIN_INTEGRATOR_PRICE_SATS;
|
|
868
903
|
exports.MeClientError = MeClientError;
|
|
@@ -872,6 +907,7 @@ exports.clearBearerToken = clearBearerToken;
|
|
|
872
907
|
exports.computeFees = computeFees;
|
|
873
908
|
exports.config = config;
|
|
874
909
|
exports.event = event;
|
|
910
|
+
exports.family = family;
|
|
875
911
|
exports.federations = federations;
|
|
876
912
|
exports.getBearerToken = getBearerToken;
|
|
877
913
|
exports.getOrigin = getOrigin;
|