@keyringnetwork/keyring-connect-sdk 1.0.1 → 1.0.2
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/types.d.ts +7 -19
- package/package.json +1 -1
- package/readme.md +14 -55
package/dist/types.d.ts
CHANGED
|
@@ -21,14 +21,16 @@ export type ExtensionSDKConfig = {
|
|
|
21
21
|
*/
|
|
22
22
|
policy_id: number;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Additional configuration to customize the extension's verification process.
|
|
25
|
+
* @note should be used with caution as strict validation is applied to the proof config.
|
|
25
26
|
*/
|
|
26
27
|
proof_config?: {
|
|
27
28
|
datasource: DataSource;
|
|
28
29
|
entity_type?: string;
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
31
|
-
*
|
|
32
|
+
* Keyring Network configuration for the extension.
|
|
33
|
+
* @note this is meant to be used for internal testing and development purposes.
|
|
32
34
|
*/
|
|
33
35
|
krn_config?: {
|
|
34
36
|
onboarding_api_url?: string;
|
|
@@ -55,26 +57,12 @@ export type ExtensionLaunchConfig = {
|
|
|
55
57
|
datastore_api_url?: string;
|
|
56
58
|
analytics_api_url?: string;
|
|
57
59
|
};
|
|
58
|
-
auth_user?:
|
|
60
|
+
auth_user?: any;
|
|
59
61
|
};
|
|
60
|
-
export interface UserProfile {
|
|
61
|
-
sub: string;
|
|
62
|
-
given_name?: string;
|
|
63
|
-
family_name?: string;
|
|
64
|
-
nickname: string;
|
|
65
|
-
name?: string;
|
|
66
|
-
picture?: string;
|
|
67
|
-
updated_at: string;
|
|
68
|
-
email?: string;
|
|
69
|
-
email_verified?: boolean;
|
|
70
|
-
'keyring-access/roles': string[];
|
|
71
|
-
uid: string;
|
|
72
|
-
id_token: string;
|
|
73
|
-
}
|
|
74
62
|
export type ExtensionStatus = 'idle' | 'mounted' | 'proving' | 'prove_success' | 'error';
|
|
75
63
|
export type AttestationStatus = 'onboarding_required' | 'onboarding_pending' | 'attestation_ready' | 'non_compliant';
|
|
76
64
|
export type CredentialStatus = 'expired' | 'valid' | 'none';
|
|
77
|
-
export type
|
|
65
|
+
export type User = {
|
|
78
66
|
/**
|
|
79
67
|
* Off-chain attestation status.
|
|
80
68
|
*/
|
|
@@ -100,7 +88,7 @@ export interface ExtensionState {
|
|
|
100
88
|
status: ExtensionStatus;
|
|
101
89
|
manifest?: any;
|
|
102
90
|
error?: string;
|
|
103
|
-
user?:
|
|
91
|
+
user?: User;
|
|
104
92
|
}
|
|
105
93
|
export interface DataSource {
|
|
106
94
|
id: string;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -31,8 +31,15 @@ const extensionConfig = {
|
|
|
31
31
|
logo_url: 'https://myapp.com/logo.png',
|
|
32
32
|
policy_id: 123,
|
|
33
33
|
};
|
|
34
|
+
|
|
34
35
|
try {
|
|
35
|
-
await KeyringConnect.
|
|
36
|
+
const isInstalled = await KeyringConnect.isKeyringConnectInstalled();
|
|
37
|
+
|
|
38
|
+
if (isInstalled) {
|
|
39
|
+
await KeyringConnect.launchExtension(extensionConfig);
|
|
40
|
+
} else {
|
|
41
|
+
// show UI to install extension
|
|
42
|
+
}
|
|
36
43
|
} catch (error) {
|
|
37
44
|
console.error('Failed to launch Keyring Connect:', error);
|
|
38
45
|
}
|
|
@@ -41,14 +48,14 @@ try {
|
|
|
41
48
|
### Monitor Extension Status
|
|
42
49
|
|
|
43
50
|
```typescript
|
|
44
|
-
export interface
|
|
45
|
-
status:
|
|
51
|
+
export interface ExtensionState {
|
|
52
|
+
status: 'idle' | 'mounted' | 'proving' | 'prove_success' | 'error';
|
|
46
53
|
manifest?: any;
|
|
47
|
-
error?: string;
|
|
48
|
-
user?:
|
|
54
|
+
error?: string; // error message, only if status is 'error'
|
|
55
|
+
user?: User;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
|
-
const
|
|
58
|
+
const extensionState = await KeyringConnect.getExtensionState();
|
|
52
59
|
```
|
|
53
60
|
|
|
54
61
|
## API Reference
|
|
@@ -57,36 +64,11 @@ const status = await KeyringConnect.getExtensionState();
|
|
|
57
64
|
|
|
58
65
|
> Full type definitions can be found in our [types.ts](https://github.com/Keyring-Network/keyring-connect/blob/master/keyring-connect-sdk/src/types.ts)
|
|
59
66
|
|
|
60
|
-
#### ExtensionConfig
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
type ExtensionSDKConfig = {
|
|
64
|
-
name: string; // Name of your application
|
|
65
|
-
client_app_url: string; // Your application's URL
|
|
66
|
-
logo_url: string; // Your application's logo URL
|
|
67
|
-
policy_id: number; // Your Keyring policy ID
|
|
68
|
-
|
|
69
|
-
// Proof configuration. This can break the extension!
|
|
70
|
-
proof_config?: {
|
|
71
|
-
datasource: DataSource;
|
|
72
|
-
entity_type: string;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// KRN configuration. This can break the extension!
|
|
76
|
-
krn_config?: {
|
|
77
|
-
entity_id?: string;
|
|
78
|
-
onboarding_api_url?: string;
|
|
79
|
-
datastore_api_url?: string;
|
|
80
|
-
analytics_api_url?: string;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
```
|
|
84
|
-
|
|
85
67
|
#### Core Types Overview
|
|
86
68
|
|
|
87
69
|
- `ExtensionConfig`: Configuration for initializing the Keyring Connect extension
|
|
88
70
|
- `ExtensionState`: Current state and status information of the extension
|
|
89
|
-
- `
|
|
71
|
+
- `User`: User's verification and credential status information
|
|
90
72
|
|
|
91
73
|
#### Status Types
|
|
92
74
|
|
|
@@ -94,14 +76,6 @@ type ExtensionSDKConfig = {
|
|
|
94
76
|
- `AttestationStatus`: Off-chain verification status (`onboarding_required`, `onboarding_pending`, `attestation_ready`, `non_compliant`)
|
|
95
77
|
- `CredentialStatus`: On-chain credential status (`expired`, `valid`, `none`)
|
|
96
78
|
|
|
97
|
-
#### Proof Configuration Types
|
|
98
|
-
|
|
99
|
-
- `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
|
|
100
|
-
- `ProofSource`: Defines how to generate a single Proof on a given Data Source, containing an Endpoint and a list of Claims
|
|
101
|
-
- `Endpoint`: A URL on the Data Source's server that provides access to the data that will need to be disclosed in the Proof
|
|
102
|
-
- `DisclosableField`: A field in the Endpoint's response that the Prover must disclose to the Verifier, defined by a JSON path
|
|
103
|
-
- `Claim`: Links Proofs to Keyring rules, containing a label and rule ID for evaluation of its status
|
|
104
|
-
|
|
105
79
|
## Extension States
|
|
106
80
|
|
|
107
81
|
- **idle**: Extension is installed but not active
|
|
@@ -116,18 +90,3 @@ type ExtensionSDKConfig = {
|
|
|
116
90
|
- Chrome browser (version 88 or higher recommended)
|
|
117
91
|
- Keyring Connect browser extension installed
|
|
118
92
|
- Active internet connection
|
|
119
|
-
|
|
120
|
-
## Error Handling
|
|
121
|
-
|
|
122
|
-
The SDK throws errors in the following cases:
|
|
123
|
-
|
|
124
|
-
- Network errors
|
|
125
|
-
- Proof generation failures
|
|
126
|
-
- On-chain credential update failures
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
const state = await KeyringConnect.getExtensionState();
|
|
130
|
-
if (state.status === 'error') {
|
|
131
|
-
console.error('An error occurred:', state.error);
|
|
132
|
-
}
|
|
133
|
-
```
|