@orangecheck/me-client 0.44.0 → 0.45.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
@@ -62,6 +62,22 @@ type RevokeTokenResult = {
62
62
  };
63
63
  declare function revokeToken(token: string | readonly string[], options?: RevokeTokenOptions): Promise<RevokeTokenResult>;
64
64
 
65
+ type MergedUserMatch = {
66
+ kind: 'none';
67
+ } | {
68
+ kind: 'one';
69
+ user: string;
70
+ } | {
71
+ kind: 'conflict';
72
+ users: string[];
73
+ };
74
+ declare function mergedHandles(session: {
75
+ merged_rh?: unknown;
76
+ }): string[];
77
+ declare function matchMergedUser(session: {
78
+ merged_rh?: unknown;
79
+ }, lookup: (rh: string) => string | null | undefined | Promise<string | null | undefined>): Promise<MergedUserMatch>;
80
+
65
81
  type OcSessionRefusal = 'no_session_handle';
66
82
  interface VerifyOcTokenOptions extends VerifyOcOptions {
67
83
  requireHandle?: boolean;
@@ -182,4 +198,4 @@ interface HonoContextLike {
182
198
  type HonoNextLike = () => Promise<void>;
183
199
  declare function ocAuthHono(options?: WithOcAuthOptions): (c: HonoContextLike, next: HonoNextLike) => Promise<unknown>;
184
200
 
185
- 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 SignInRuleCheck, type SignInRuleOptions, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, checkOcToken, checkSignInRule, connectClaimLink, connectDelete, connectProvision, getOcSession, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
201
+ 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 MergedUserMatch, type OcHonoEnv, type OcSessionCheck, type OcSessionOptions, type OcSessionRefusal, type OcSessionUnavailable, type OcTokenCheck, type RevokeTokenOptions, type RevokeTokenRefusal, type RevokeTokenResult, type SignInRuleCheck, type SignInRuleOptions, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, checkOcToken, checkSignInRule, connectClaimLink, connectDelete, connectProvision, getOcSession, matchMergedUser, mergedHandles, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
package/dist/server.d.ts CHANGED
@@ -62,6 +62,22 @@ type RevokeTokenResult = {
62
62
  };
63
63
  declare function revokeToken(token: string | readonly string[], options?: RevokeTokenOptions): Promise<RevokeTokenResult>;
64
64
 
65
+ type MergedUserMatch = {
66
+ kind: 'none';
67
+ } | {
68
+ kind: 'one';
69
+ user: string;
70
+ } | {
71
+ kind: 'conflict';
72
+ users: string[];
73
+ };
74
+ declare function mergedHandles(session: {
75
+ merged_rh?: unknown;
76
+ }): string[];
77
+ declare function matchMergedUser(session: {
78
+ merged_rh?: unknown;
79
+ }, lookup: (rh: string) => string | null | undefined | Promise<string | null | undefined>): Promise<MergedUserMatch>;
80
+
65
81
  type OcSessionRefusal = 'no_session_handle';
66
82
  interface VerifyOcTokenOptions extends VerifyOcOptions {
67
83
  requireHandle?: boolean;
@@ -182,4 +198,4 @@ interface HonoContextLike {
182
198
  type HonoNextLike = () => Promise<void>;
183
199
  declare function ocAuthHono(options?: WithOcAuthOptions): (c: HonoContextLike, next: HonoNextLike) => Promise<unknown>;
184
200
 
185
- 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 SignInRuleCheck, type SignInRuleOptions, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, checkOcToken, checkSignInRule, connectClaimLink, connectDelete, connectProvision, getOcSession, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
201
+ 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 MergedUserMatch, type OcHonoEnv, type OcSessionCheck, type OcSessionOptions, type OcSessionRefusal, type OcSessionUnavailable, type OcTokenCheck, type RevokeTokenOptions, type RevokeTokenRefusal, type RevokeTokenResult, type SignInRuleCheck, type SignInRuleOptions, type VerifyOcTokenOptions, type WithOcAuthOptions, type WithOcSession, _resetSessionChecksForTests, checkOcSession, checkOcToken, checkSignInRule, connectClaimLink, connectDelete, connectProvision, getOcSession, matchMergedUser, mergedHandles, ocAuthExpress, ocAuthHono, revokeToken, spendOnce, verifyOcToken, withOcAuth };
package/dist/server.js CHANGED
@@ -837,6 +837,25 @@ async function post2(url, tokens, timeoutMs) {
837
837
  }
838
838
  }
839
839
 
840
+ // src/merged.ts
841
+ var MERGED_HANDLES_MAX = 16;
842
+ function mergedHandles(session) {
843
+ const v = session.merged_rh;
844
+ if (!Array.isArray(v) || v.length > MERGED_HANDLES_MAX) return [];
845
+ if (!v.every((h) => typeof h === "string" && h.length > 0)) return [];
846
+ return [...new Set(v)];
847
+ }
848
+ async function matchMergedUser(session, lookup) {
849
+ const users = /* @__PURE__ */ new Set();
850
+ for (const rh of mergedHandles(session)) {
851
+ const user = await lookup(rh);
852
+ if (typeof user === "string" && user.length > 0) users.add(user);
853
+ }
854
+ if (users.size === 0) return { kind: "none" };
855
+ if (users.size === 1) return { kind: "one", user: [...users][0] };
856
+ return { kind: "conflict", users: [...users].sort() };
857
+ }
858
+
840
859
  // src/server.ts
841
860
  var VERIFIED = /* @__PURE__ */ new WeakSet();
842
861
  function vouch(session) {
@@ -1242,6 +1261,8 @@ exports.connectDelete = connectDelete;
1242
1261
  exports.connectProvision = connectProvision;
1243
1262
  exports.getOcSession = getOcSession;
1244
1263
  exports.identity = identity;
1264
+ exports.matchMergedUser = matchMergedUser;
1265
+ exports.mergedHandles = mergedHandles;
1245
1266
  exports.ocAuthExpress = ocAuthExpress;
1246
1267
  exports.ocAuthHono = ocAuthHono;
1247
1268
  exports.refreshEnvelopeJwks = refreshEnvelopeJwks;