@orangecheck/sdk 0.1.0 → 0.1.1

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
@@ -34,7 +34,13 @@ interface CheckResult {
34
34
  declare function check(params: CheckParams): Promise<CheckResult>;
35
35
 
36
36
  declare function isNip07Available(): boolean;
37
+ declare function getNostrPublicKey(): Promise<string | null>;
37
38
  declare function signNostrEvent(event: Omit<NostrEvent, 'id' | 'sig'>): Promise<NostrEvent | null>;
39
+ declare function getNip07Info(): {
40
+ available: boolean;
41
+ name?: string;
42
+ version?: string;
43
+ };
38
44
 
39
45
  type Severity = 'success' | 'info' | 'warn' | 'error';
40
46
  interface StatusMeta {
@@ -44,4 +50,4 @@ interface StatusMeta {
44
50
  }
45
51
  declare const STATUS_META: Record<StatusCode, StatusMeta>;
46
52
 
47
- export { type CheckParams, type CheckResult, IdentityBinding, Network, NostrEvent, STATUS_META, type Severity, StatusCode, type StatusMeta, VerifyOptions, check, isNip07Available, signNostrEvent };
53
+ export { type CheckParams, type CheckResult, IdentityBinding, Network, NostrEvent, STATUS_META, type Severity, StatusCode, type StatusMeta, VerifyOptions, check, getNip07Info, getNostrPublicKey, isNip07Available, signNostrEvent };
package/dist/index.d.ts CHANGED
@@ -34,7 +34,13 @@ interface CheckResult {
34
34
  declare function check(params: CheckParams): Promise<CheckResult>;
35
35
 
36
36
  declare function isNip07Available(): boolean;
37
+ declare function getNostrPublicKey(): Promise<string | null>;
37
38
  declare function signNostrEvent(event: Omit<NostrEvent, 'id' | 'sig'>): Promise<NostrEvent | null>;
39
+ declare function getNip07Info(): {
40
+ available: boolean;
41
+ name?: string;
42
+ version?: string;
43
+ };
38
44
 
39
45
  type Severity = 'success' | 'info' | 'warn' | 'error';
40
46
  interface StatusMeta {
@@ -44,4 +50,4 @@ interface StatusMeta {
44
50
  }
45
51
  declare const STATUS_META: Record<StatusCode, StatusMeta>;
46
52
 
47
- export { type CheckParams, type CheckResult, IdentityBinding, Network, NostrEvent, STATUS_META, type Severity, StatusCode, type StatusMeta, VerifyOptions, check, isNip07Available, signNostrEvent };
53
+ export { type CheckParams, type CheckResult, IdentityBinding, Network, NostrEvent, STATUS_META, type Severity, StatusCode, type StatusMeta, VerifyOptions, check, getNip07Info, getNostrPublicKey, isNip07Available, signNostrEvent };
package/dist/index.js CHANGED
@@ -498,6 +498,21 @@ function isNip07Available() {
498
498
  }
499
499
  return !!window.nostr;
500
500
  }
501
+ async function getNostrPublicKey() {
502
+ if (!isNip07Available()) {
503
+ log2.warn("NIP-07 extension not available");
504
+ return null;
505
+ }
506
+ try {
507
+ const nostr = window.nostr;
508
+ const pubkey = await nostr.getPublicKey();
509
+ log2.info({ pubkey }, "Got Nostr public key from NIP-07");
510
+ return pubkey;
511
+ } catch (err) {
512
+ log2.error({ error: err }, "Failed to get Nostr public key");
513
+ return null;
514
+ }
515
+ }
501
516
  async function signNostrEvent(event) {
502
517
  if (!isNip07Available()) {
503
518
  log2.warn("NIP-07 extension not available");
@@ -513,6 +528,17 @@ async function signNostrEvent(event) {
513
528
  return null;
514
529
  }
515
530
  }
531
+ function getNip07Info() {
532
+ if (!isNip07Available()) {
533
+ return { available: false };
534
+ }
535
+ const nostr = window.nostr;
536
+ return {
537
+ available: true,
538
+ name: nostr._metadata?.name,
539
+ version: nostr._metadata?.version
540
+ };
541
+ }
516
542
 
517
543
  // src/attestation.ts
518
544
  var log3 = createLogger("ocp/attestation");
@@ -1967,6 +1993,8 @@ exports.getDnsVerificationInstructions = getDnsVerificationInstructions;
1967
1993
  exports.getGistCreationUrl = getGistCreationUrl;
1968
1994
  exports.getGitHubVerificationInstructions = getGitHubVerificationInstructions;
1969
1995
  exports.getManualVerificationInstructions = getManualVerificationInstructions;
1996
+ exports.getNip07Info = getNip07Info;
1997
+ exports.getNostrPublicKey = getNostrPublicKey;
1970
1998
  exports.getNostrVerificationInstructions = getNostrVerificationInstructions;
1971
1999
  exports.getTweetUrl = getTweetUrl;
1972
2000
  exports.getTwitterComposeUrl = getTwitterComposeUrl;