@openkey/sdk 0.10.2 → 0.11.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 CHANGED
@@ -27,7 +27,8 @@ interface NostrError {
27
27
  */
28
28
  declare class OpenKeyNostr {
29
29
  private host;
30
- constructor(host: string);
30
+ private passkeysSupported;
31
+ constructor(host: string, passkeysSupported?: boolean);
31
32
  /**
32
33
  * Get-or-create the user's OpenKey-custodied Nostr identity. Always shows
33
34
  * a visible consent card (identity creation, or - when `relayUrl` is
@@ -67,7 +68,19 @@ interface OpenKeyConfig {
67
68
  mode?: OpenKeyMode;
68
69
  /** App-provided wallet provider for external key signing */
69
70
  externalProvider?: EIP1193Provider;
71
+ /**
72
+ * Whether the client can use passkeys (WebAuthn). Default: true. Pass
73
+ * false from clients where WebAuthn does not work (for example an
74
+ * ad-hoc-signed desktop webview); the OpenKey UI then offers only email
75
+ * and social sign-in.
76
+ */
77
+ passkeysSupported?: boolean;
70
78
  }
79
+ /**
80
+ * Query suffix telling the OpenKey widget that passkeys are unavailable.
81
+ * Empty when passkeys are supported, so default URLs are unchanged.
82
+ */
83
+ declare function passkeysQueryFlag(passkeysSupported: boolean): string;
71
84
  interface SignMessageRequest {
72
85
  message: string;
73
86
  keyId?: string;
@@ -325,6 +338,7 @@ declare class OpenKey {
325
338
  private oauthHost;
326
339
  private appName;
327
340
  private mode;
341
+ private passkeysSupported;
328
342
  private config;
329
343
  private popup;
330
344
  private lastAuth;
@@ -554,4 +568,4 @@ declare class OpenKeyProvider implements EIP1193Provider {
554
568
 
555
569
  declare function getOpenKey(config?: OpenKeyConfig): OpenKey;
556
570
 
557
- export { type AuthResult, type AuthorizeTinyCloudRouting, type CapabilityPresentationEnvelopeV1, type EIP1193Provider, KeyIdTypeMismatchError, type NostrError, type NostrIdentity, type OAuthConfig, type OAuthResult, type OAuthTokenResponse, OpenKey, type OpenKeyConfig, type OpenKeyError, type OpenKeyMode, OpenKeyNostr, OpenKeyProvider, type SignMessageRequest, type SignOutAcknowledgement, type SignResult, type SignTypedDataRequest, type SignedNostrEvent, type TinyCloudAuthorizationRequestV1, type TinyCloudAuthorizationResultV1, type UnsignedNostrEvent, OpenKey as default, getOpenKey, resolveAuthorizeTinyCloudRouting, shouldRouteAuthorizeTinyCloudExternal, validateIframeResize };
571
+ export { type AuthResult, type AuthorizeTinyCloudRouting, type CapabilityPresentationEnvelopeV1, type EIP1193Provider, KeyIdTypeMismatchError, type NostrError, type NostrIdentity, type OAuthConfig, type OAuthResult, type OAuthTokenResponse, OpenKey, type OpenKeyConfig, type OpenKeyError, type OpenKeyMode, OpenKeyNostr, OpenKeyProvider, type SignMessageRequest, type SignOutAcknowledgement, type SignResult, type SignTypedDataRequest, type SignedNostrEvent, type TinyCloudAuthorizationRequestV1, type TinyCloudAuthorizationResultV1, type UnsignedNostrEvent, OpenKey as default, getOpenKey, passkeysQueryFlag, resolveAuthorizeTinyCloudRouting, shouldRouteAuthorizeTinyCloudExternal, validateIframeResize };
package/dist/index.d.ts CHANGED
@@ -27,7 +27,8 @@ interface NostrError {
27
27
  */
28
28
  declare class OpenKeyNostr {
29
29
  private host;
30
- constructor(host: string);
30
+ private passkeysSupported;
31
+ constructor(host: string, passkeysSupported?: boolean);
31
32
  /**
32
33
  * Get-or-create the user's OpenKey-custodied Nostr identity. Always shows
33
34
  * a visible consent card (identity creation, or - when `relayUrl` is
@@ -67,7 +68,19 @@ interface OpenKeyConfig {
67
68
  mode?: OpenKeyMode;
68
69
  /** App-provided wallet provider for external key signing */
69
70
  externalProvider?: EIP1193Provider;
71
+ /**
72
+ * Whether the client can use passkeys (WebAuthn). Default: true. Pass
73
+ * false from clients where WebAuthn does not work (for example an
74
+ * ad-hoc-signed desktop webview); the OpenKey UI then offers only email
75
+ * and social sign-in.
76
+ */
77
+ passkeysSupported?: boolean;
70
78
  }
79
+ /**
80
+ * Query suffix telling the OpenKey widget that passkeys are unavailable.
81
+ * Empty when passkeys are supported, so default URLs are unchanged.
82
+ */
83
+ declare function passkeysQueryFlag(passkeysSupported: boolean): string;
71
84
  interface SignMessageRequest {
72
85
  message: string;
73
86
  keyId?: string;
@@ -325,6 +338,7 @@ declare class OpenKey {
325
338
  private oauthHost;
326
339
  private appName;
327
340
  private mode;
341
+ private passkeysSupported;
328
342
  private config;
329
343
  private popup;
330
344
  private lastAuth;
@@ -554,4 +568,4 @@ declare class OpenKeyProvider implements EIP1193Provider {
554
568
 
555
569
  declare function getOpenKey(config?: OpenKeyConfig): OpenKey;
556
570
 
557
- export { type AuthResult, type AuthorizeTinyCloudRouting, type CapabilityPresentationEnvelopeV1, type EIP1193Provider, KeyIdTypeMismatchError, type NostrError, type NostrIdentity, type OAuthConfig, type OAuthResult, type OAuthTokenResponse, OpenKey, type OpenKeyConfig, type OpenKeyError, type OpenKeyMode, OpenKeyNostr, OpenKeyProvider, type SignMessageRequest, type SignOutAcknowledgement, type SignResult, type SignTypedDataRequest, type SignedNostrEvent, type TinyCloudAuthorizationRequestV1, type TinyCloudAuthorizationResultV1, type UnsignedNostrEvent, OpenKey as default, getOpenKey, resolveAuthorizeTinyCloudRouting, shouldRouteAuthorizeTinyCloudExternal, validateIframeResize };
571
+ export { type AuthResult, type AuthorizeTinyCloudRouting, type CapabilityPresentationEnvelopeV1, type EIP1193Provider, KeyIdTypeMismatchError, type NostrError, type NostrIdentity, type OAuthConfig, type OAuthResult, type OAuthTokenResponse, OpenKey, type OpenKeyConfig, type OpenKeyError, type OpenKeyMode, OpenKeyNostr, OpenKeyProvider, type SignMessageRequest, type SignOutAcknowledgement, type SignResult, type SignTypedDataRequest, type SignedNostrEvent, type TinyCloudAuthorizationRequestV1, type TinyCloudAuthorizationResultV1, type UnsignedNostrEvent, OpenKey as default, getOpenKey, passkeysQueryFlag, resolveAuthorizeTinyCloudRouting, shouldRouteAuthorizeTinyCloudExternal, validateIframeResize };
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  OpenKeyProvider: () => OpenKeyProvider,
27
27
  default: () => index_default,
28
28
  getOpenKey: () => getOpenKey,
29
+ passkeysQueryFlag: () => passkeysQueryFlag,
29
30
  resolveAuthorizeTinyCloudRouting: () => resolveAuthorizeTinyCloudRouting,
30
31
  shouldRouteAuthorizeTinyCloudExternal: () => shouldRouteAuthorizeTinyCloudExternal,
31
32
  validateIframeResize: () => validateIframeResize
@@ -175,8 +176,9 @@ var NostrFrame = class {
175
176
  }
176
177
  };
177
178
  var OpenKeyNostr = class {
178
- constructor(host) {
179
+ constructor(host, passkeysSupported = true) {
179
180
  this.host = host;
181
+ this.passkeysSupported = passkeysSupported;
180
182
  }
181
183
  /**
182
184
  * Get-or-create the user's OpenKey-custodied Nostr identity. Always shows
@@ -219,7 +221,8 @@ var OpenKeyNostr = class {
219
221
  }
220
222
  widgetUrl() {
221
223
  const origin = encodeURIComponent(window.location.origin);
222
- return `${this.host}/widget/embed/nostr/approve?origin=${origin}`;
224
+ const passkeysFlag = this.passkeysSupported ? "" : "&passkeys=false";
225
+ return `${this.host}/widget/embed/nostr/approve?origin=${origin}${passkeysFlag}`;
223
226
  }
224
227
  run(url, request, onData) {
225
228
  return new Promise((resolve, reject) => {
@@ -263,6 +266,9 @@ var OpenKeyNostr = class {
263
266
  };
264
267
 
265
268
  // src/index.ts
269
+ function passkeysQueryFlag(passkeysSupported) {
270
+ return passkeysSupported ? "" : "&passkeys=false";
271
+ }
266
272
  var DEFAULT_HOST = "https://openkey.so";
267
273
  var POPUP_WIDTH = 400;
268
274
  var POPUP_HEIGHT = 600;
@@ -582,6 +588,7 @@ var OpenKey = class {
582
588
  oauthHost;
583
589
  appName;
584
590
  mode;
591
+ passkeysSupported;
585
592
  config;
586
593
  popup = null;
587
594
  lastAuth = null;
@@ -602,7 +609,8 @@ var OpenKey = class {
602
609
  this.oauthHost = config.oauthHost || this.deriveOAuthHost(this.host);
603
610
  this.appName = config.appName || window.location.hostname;
604
611
  this.mode = config.mode ?? "iframe";
605
- this.nostr = new OpenKeyNostr(this.host);
612
+ this.passkeysSupported = config.passkeysSupported ?? true;
613
+ this.nostr = new OpenKeyNostr(this.host, this.passkeysSupported);
606
614
  if (typeof window !== "undefined") {
607
615
  this.discoveredProviders = [];
608
616
  window.addEventListener("eip6963:announceProvider", (event) => {
@@ -1249,17 +1257,18 @@ var OpenKey = class {
1249
1257
  const mode = this.resolveMode(modeOverride);
1250
1258
  const origin = encodeURIComponent(window.location.origin);
1251
1259
  const eoaFlag = action === "connect" && this.hasDetectedEoa() ? "&hasEoa=true" : "";
1260
+ const passkeysFlag = passkeysQueryFlag(this.passkeysSupported);
1252
1261
  if (mode === "popup") {
1253
- const url2 = `${this.host}/widget/${action}?origin=${origin}${eoaFlag}`;
1262
+ const url2 = `${this.host}/widget/${action}?origin=${origin}${eoaFlag}${passkeysFlag}`;
1254
1263
  return new Promise((resolve, reject) => this.openPopup(action, url2, message, resolve, reject));
1255
1264
  }
1256
1265
  if (mode === "redirect") {
1257
- const url2 = `${this.host}/widget/${action}?origin=${origin}${eoaFlag}`;
1266
+ const url2 = `${this.host}/widget/${action}?origin=${origin}${eoaFlag}${passkeysFlag}`;
1258
1267
  window.location.href = url2;
1259
1268
  return new Promise(() => {
1260
1269
  });
1261
1270
  }
1262
- const url = `${this.host}/widget/embed/${action}?origin=${origin}${eoaFlag}`;
1271
+ const url = `${this.host}/widget/embed/${action}?origin=${origin}${eoaFlag}${passkeysFlag}`;
1263
1272
  return this.openIframeModal(url, action, message, origin);
1264
1273
  }
1265
1274
  openIframeModal(url, action, message, origin) {
@@ -1365,7 +1374,7 @@ var OpenKey = class {
1365
1374
  cleanup();
1366
1375
  console.warn("OpenKey: iframe blocked by CSP, falling back to popup. Add frame-src https://openkey.so to your CSP.");
1367
1376
  showToast();
1368
- const popupUrl = `${this.host}/widget/${action}?origin=${origin}`;
1377
+ const popupUrl = `${this.host}/widget/${action}?origin=${origin}${passkeysQueryFlag(this.passkeysSupported)}`;
1369
1378
  this.openPopup(action, popupUrl, message, (val) => settle(() => resolve(val)), (err) => settle(() => reject(err)));
1370
1379
  }, IFRAME_READY_TIMEOUT);
1371
1380
  const overallTimeout = setTimeout(() => {
@@ -1669,6 +1678,7 @@ function getOpenKey(config) {
1669
1678
  OpenKeyNostr,
1670
1679
  OpenKeyProvider,
1671
1680
  getOpenKey,
1681
+ passkeysQueryFlag,
1672
1682
  resolveAuthorizeTinyCloudRouting,
1673
1683
  shouldRouteAuthorizeTinyCloudExternal,
1674
1684
  validateIframeResize