@keyringnetwork/keyring-connect-sdk 0.0.2 → 0.0.4

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.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { default as KeyringConnectSDK } from './main';
1
+ export { KeyringConnect } from './main';
2
2
  export * from './types';
package/dist/index.js CHANGED
@@ -13,11 +13,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.KeyringConnectSDK = void 0;
17
+ exports.KeyringConnect = void 0;
21
18
  var main_1 = require("./main");
22
- Object.defineProperty(exports, "KeyringConnectSDK", { enumerable: true, get: function () { return __importDefault(main_1).default; } });
19
+ Object.defineProperty(exports, "KeyringConnect", { enumerable: true, get: function () { return main_1.KeyringConnect; } });
23
20
  __exportStar(require("./types"), exports);
package/dist/main.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ExtensionStatusData, LaunchKeyringConnectData } from './types';
2
- export default class KeyringConnectSDK {
3
- static launchKeyringConnect(data: LaunchKeyringConnectData): Promise<void>;
1
+ import { ExtensionConfig, ExtensionState } from './types';
2
+ export declare class KeyringConnect {
3
+ static launchExtension(data: ExtensionConfig): Promise<void>;
4
4
  static isKeyringConnectInstalled(): Promise<boolean>;
5
- static getExtensionState(): Promise<ExtensionStatusData>;
5
+ static getExtensionState(): Promise<ExtensionState>;
6
6
  }
package/dist/main.js CHANGED
@@ -9,10 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.KeyringConnect = void 0;
12
13
  const env_1 = require("./env");
13
14
  const types_1 = require("./types");
14
- class KeyringConnectSDK {
15
- static launchKeyringConnect(data) {
15
+ class KeyringConnect {
16
+ static launchExtension(data) {
16
17
  return __awaiter(this, void 0, void 0, function* () {
17
18
  const keyringConnectAvailable = yield this.isKeyringConnectInstalled();
18
19
  if (!keyringConnectAvailable) {
@@ -50,4 +51,4 @@ class KeyringConnectSDK {
50
51
  });
51
52
  }
52
53
  }
53
- exports.default = KeyringConnectSDK;
54
+ exports.KeyringConnect = KeyringConnect;
package/dist/types.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare enum EVENT_ACTIONS {
3
3
  GET_STATUS = "GET_STATUS",
4
4
  KEYRING_CONNECT_STATUS = "KEYRING_CONNECT_STATUS"
5
5
  }
6
- export type LaunchKeyringConnectData = {
6
+ export type ExtensionConfig = {
7
7
  client: {
8
8
  /**
9
9
  * The name of the client.
@@ -58,7 +58,7 @@ export type UserState = {
58
58
  */
59
59
  entity_id: string;
60
60
  };
61
- export interface ExtensionStatusData {
61
+ export interface ExtensionState {
62
62
  status: ExtensionStatus;
63
63
  manifest?: any;
64
64
  error?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyringnetwork/keyring-connect-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "An SDK for interacting with Keyring Connect browser extension",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md ADDED
@@ -0,0 +1,139 @@
1
+ # Keyring Connect SDK
2
+
3
+ A TypeScript/JavaScript SDK for integrating with the Keyring Connect browser extension. This SDK enables seamless interaction with the Keyring Connect extension for user verification and attestation.
4
+
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install @keyringnetwork/keyring-connect-sdk
10
+ ```
11
+
12
+ ## Features
13
+
14
+ - Launch Keyring Connect with custom client configuration
15
+ - Monitor extension status and user state
16
+ - Full TypeScript support with comprehensive type definitions
17
+
18
+ ## Usage
19
+
20
+ ### Initialize
21
+
22
+ ```typescript
23
+ import { KeyringConnect } from '@keyringnetwork/keyring-connect-sdk';
24
+ ```
25
+
26
+ ### Launch Keyring Connect
27
+
28
+ ```typescript
29
+ const extensionConfig = {
30
+ client: {
31
+ client_name: 'My App',
32
+ client_app_url: 'https://myapp.com',
33
+ client_logo_url: 'https://myapp.com/logo.png',
34
+ client_policy_id: 123,
35
+ },
36
+ // Optional proof configuration
37
+ proof_config: {
38
+ datasource: {
39
+ id: 'github',
40
+ name: 'GitHub',
41
+ label: 'GitHub Account',
42
+ link: 'https://github.com',
43
+ login_url: 'https://github.com/login',
44
+ target_url: null,
45
+ image: 'https://github.com/logo.png',
46
+ proof_sources: [/ ... /],
47
+ },
48
+ entity_type: 'individual',
49
+ },
50
+ };
51
+ try {
52
+ await KeyringConnect.launchExtension(extensionConfig);
53
+ } catch (error) {
54
+ console.error('Failed to launch Keyring Connect:', error);
55
+ }
56
+ ```
57
+
58
+ ### Monitor Extension Status
59
+
60
+ ```typescript
61
+ export interface ExtensionStatusData {
62
+ status: ExtensionStatus;
63
+ manifest?: any;
64
+ error?: string;
65
+ user?: UserState;
66
+ }
67
+
68
+ const status = await KeyringConnect.getExtensionState();
69
+ ```
70
+
71
+ ## API Reference
72
+
73
+ ### Key Types
74
+
75
+ > Full type definitions can be found in our [types.ts](src/types.ts)
76
+
77
+
78
+ #### ExtensionConfig
79
+
80
+ ```typescript
81
+ type ExtensionConfig = {
82
+ client: {
83
+ client_name: string; // Name of your application
84
+ client_app_url: string; // Your application's URL
85
+ client_logo_url: string; // Your application's logo URL
86
+ client_policy_id: number; // Your Keyring policy ID
87
+ };
88
+ proof_config?: {
89
+ datasource: DataSource; // Configuration for the proof source
90
+ entity_type: string; // Type of entity to verify
91
+ };
92
+ };
93
+ ```
94
+
95
+ #### Core Types Overview
96
+ - `ExtensionConfig`: Configuration for initializing the Keyring Connect extension
97
+ - `ExtensionState`: Current state and status information of the extension
98
+ - `UserState`: User's verification and credential status information
99
+
100
+ #### Status Types
101
+ - `ExtensionStatus`: Extension states (`idle`, `mounted`, `proving`, `prove_success`, `error`)
102
+ - `AttestationStatus`: Off-chain verification status (`onboarding_required`, `onboarding_pending`, `attestation_ready`, `non_compliant`)
103
+ - `CredentialStatus`: On-chain credential status (`expired`, `valid`, `none`)
104
+
105
+ #### Proof Configuration Types
106
+ - `DataSource`: The website that owns the data the Prover is trying to prove, defined by a name and login URL, containing a list of Proof Sources
107
+ - `ProofSource`: Defines how to generate a single Proof on a given Data Source, containing an Endpoint and a list of Claims
108
+ - `Endpoint`: A URL on the Data Source's server that provides access to the data that will need to be disclosed in the Proof
109
+ - `DisclosableField`: A field in the Endpoint's response that the Prover must disclose to the Verifier, defined by a JSON path
110
+ - `Claim`: Links Proofs to Keyring rules, containing a label and rule ID for evaluation of its status
111
+
112
+ ## Extension States
113
+
114
+ - **idle**: Extension is installed but not active
115
+ - **mounted**: Extension is launched and ready
116
+ - **proving**: Currently generating proof
117
+ - **prove_success**: Proof generation successful
118
+ - **error**: An error occurred
119
+
120
+ ## Requirements
121
+
122
+ - An on-chain Keyring policy
123
+ - Chrome browser (version 88 or higher recommended)
124
+ - Keyring Connect browser extension installed
125
+ - Active internet connection
126
+
127
+ ## Error Handling
128
+
129
+ The SDK throws errors in the following cases:
130
+ - Network errors
131
+ - Proof generation failures
132
+ - On-chain credential update failures
133
+
134
+ ```typescript
135
+ const state = await KeyringConnect.getExtensionState();
136
+ if (state.status === 'error') {
137
+ console.error('An error occurred:', state.error);
138
+ }
139
+ ```