@keyringnetwork/keyring-connect-sdk 0.0.2 → 0.0.3
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/main.d.ts +4 -4
- package/dist/main.js +3 -3
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/readme.md +139 -0
package/dist/main.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class
|
|
3
|
-
static
|
|
1
|
+
import { ExtensionConfig, ExtensionState } from './types';
|
|
2
|
+
export default class KeyringConnect {
|
|
3
|
+
static launchExtension(data: ExtensionConfig): Promise<void>;
|
|
4
4
|
static isKeyringConnectInstalled(): Promise<boolean>;
|
|
5
|
-
static getExtensionState(): Promise<
|
|
5
|
+
static getExtensionState(): Promise<ExtensionState>;
|
|
6
6
|
}
|
package/dist/main.js
CHANGED
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const env_1 = require("./env");
|
|
13
13
|
const types_1 = require("./types");
|
|
14
|
-
class
|
|
15
|
-
static
|
|
14
|
+
class KeyringConnect {
|
|
15
|
+
static launchExtension(data) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const keyringConnectAvailable = yield this.isKeyringConnectInstalled();
|
|
18
18
|
if (!keyringConnectAvailable) {
|
|
@@ -50,4 +50,4 @@ class KeyringConnectSDK {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
exports.default =
|
|
53
|
+
exports.default = 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
|
|
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
|
|
61
|
+
export interface ExtensionState {
|
|
62
62
|
status: ExtensionStatus;
|
|
63
63
|
manifest?: any;
|
|
64
64
|
error?: string;
|
package/package.json
CHANGED
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
|
+
```
|