@orangecheck/me-client 0.41.0 → 0.42.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/server.d.mts CHANGED
@@ -67,6 +67,17 @@ interface VerifyOcTokenOptions extends VerifyOcOptions {
67
67
  requireHandle?: boolean;
68
68
  }
69
69
  declare function verifyOcToken(token: string, options?: VerifyOcTokenOptions): Promise<SessionPayload | null>;
70
+ type OcTokenCheck = {
71
+ status: 'valid';
72
+ session: SessionPayload;
73
+ } | {
74
+ status: 'invalid';
75
+ reason?: OcSessionRefusal;
76
+ } | {
77
+ status: 'unavailable';
78
+ reason: 'key_set_unavailable';
79
+ };
80
+ declare function checkOcToken(token: string, options?: VerifyOcTokenOptions): Promise<OcTokenCheck>;
70
81
 
71
82
  interface OcSessionOptions extends VerifyOcTokenOptions {
72
83
  method?: string;
@@ -158,4 +169,4 @@ interface HonoContextLike {
158
169
  type HonoNextLike = () => Promise<void>;
159
170
  declare function ocAuthHono(options?: WithOcAuthOptions): (c: HonoContextLike, next: HonoNextLike) => Promise<unknown>;
160
171
 
161
- export { BACK_ACCOUNT_URL, type ConnectClaimLinkRefusal, type ConnectClaimLinkResult, type ConnectDeleteRefusal, type ConnectDeleteResult, type ConnectOptions, type ConnectProvisionOptions, type ConnectProvisionRefusal, type ConnectProvisionResult, type ConnectRefused, type JtiStore, MemoryJtiStore, type OcHonoEnv, type OcSessionCheck, type OcSessionOptions, type OcSessionRefusal, type OcSessionUnavailable, type RevokeTokenOptions, type RevokeTokenRefusal, type RevokeTokenResult, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, connectClaimLink, connectDelete, connectProvision, getOcSession, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
172
+ export { BACK_ACCOUNT_URL, type ConnectClaimLinkRefusal, type ConnectClaimLinkResult, type ConnectDeleteRefusal, type ConnectDeleteResult, type ConnectOptions, type ConnectProvisionOptions, type ConnectProvisionRefusal, type ConnectProvisionResult, type ConnectRefused, type JtiStore, MemoryJtiStore, type OcHonoEnv, type OcSessionCheck, type OcSessionOptions, type OcSessionRefusal, type OcSessionUnavailable, type OcTokenCheck, type RevokeTokenOptions, type RevokeTokenRefusal, type RevokeTokenResult, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, checkOcToken, connectClaimLink, connectDelete, connectProvision, getOcSession, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
package/dist/server.d.ts CHANGED
@@ -67,6 +67,17 @@ interface VerifyOcTokenOptions extends VerifyOcOptions {
67
67
  requireHandle?: boolean;
68
68
  }
69
69
  declare function verifyOcToken(token: string, options?: VerifyOcTokenOptions): Promise<SessionPayload | null>;
70
+ type OcTokenCheck = {
71
+ status: 'valid';
72
+ session: SessionPayload;
73
+ } | {
74
+ status: 'invalid';
75
+ reason?: OcSessionRefusal;
76
+ } | {
77
+ status: 'unavailable';
78
+ reason: 'key_set_unavailable';
79
+ };
80
+ declare function checkOcToken(token: string, options?: VerifyOcTokenOptions): Promise<OcTokenCheck>;
70
81
 
71
82
  interface OcSessionOptions extends VerifyOcTokenOptions {
72
83
  method?: string;
@@ -158,4 +169,4 @@ interface HonoContextLike {
158
169
  type HonoNextLike = () => Promise<void>;
159
170
  declare function ocAuthHono(options?: WithOcAuthOptions): (c: HonoContextLike, next: HonoNextLike) => Promise<unknown>;
160
171
 
161
- export { BACK_ACCOUNT_URL, type ConnectClaimLinkRefusal, type ConnectClaimLinkResult, type ConnectDeleteRefusal, type ConnectDeleteResult, type ConnectOptions, type ConnectProvisionOptions, type ConnectProvisionRefusal, type ConnectProvisionResult, type ConnectRefused, type JtiStore, MemoryJtiStore, type OcHonoEnv, type OcSessionCheck, type OcSessionOptions, type OcSessionRefusal, type OcSessionUnavailable, type RevokeTokenOptions, type RevokeTokenRefusal, type RevokeTokenResult, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, connectClaimLink, connectDelete, connectProvision, getOcSession, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
172
+ export { BACK_ACCOUNT_URL, type ConnectClaimLinkRefusal, type ConnectClaimLinkResult, type ConnectDeleteRefusal, type ConnectDeleteResult, type ConnectOptions, type ConnectProvisionOptions, type ConnectProvisionRefusal, type ConnectProvisionResult, type ConnectRefused, type JtiStore, MemoryJtiStore, type OcHonoEnv, type OcSessionCheck, type OcSessionOptions, type OcSessionRefusal, type OcSessionUnavailable, type OcTokenCheck, type RevokeTokenOptions, type RevokeTokenRefusal, type RevokeTokenResult, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, checkOcToken, connectClaimLink, connectDelete, connectProvision, getOcSession, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
package/dist/server.js CHANGED
@@ -871,6 +871,21 @@ async function verifyOcToken(token, options = {}) {
871
871
  }
872
872
  return session;
873
873
  }
874
+ async function checkOcToken(token, options = {}) {
875
+ if (options === null || typeof options !== "object") {
876
+ throw new TypeError("@orangecheck/me-client: options must be an object");
877
+ }
878
+ const { requireHandle, ...core } = options;
879
+ checkRequireHandle(requireHandle);
880
+ const checked = await authCore.checkOcToken(token, core);
881
+ if (checked.status === "unavailable") return { status: "unavailable", reason: "key_set_unavailable" };
882
+ if (checked.status === "invalid") return { status: "invalid" };
883
+ if (lacksHandle(checked.session, requireHandle)) {
884
+ warnNoHandle(checked.session);
885
+ return { status: "invalid", reason: "no_session_handle" };
886
+ }
887
+ return { status: "valid", session: checked.session };
888
+ }
874
889
  var sessionChecks = /* @__PURE__ */ new Map();
875
890
  var warnedUnchecked = false;
876
891
  function revocationFor(options) {
@@ -1176,6 +1191,7 @@ exports.CONNECT_CONSENT_LABEL = CONNECT_CONSENT_LABEL;
1176
1191
  exports.MemoryJtiStore = MemoryJtiStore;
1177
1192
  exports._resetSessionChecksForTests = _resetSessionChecksForTests;
1178
1193
  exports.checkOcSession = checkOcSession;
1194
+ exports.checkOcToken = checkOcToken;
1179
1195
  exports.connectClaimLink = connectClaimLink;
1180
1196
  exports.connectDelete = connectDelete;
1181
1197
  exports.connectProvision = connectProvision;