@kynesyslabs/demosdk 2.6.0 → 2.7.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/build/abstraction/Identities.d.ts +5 -21
- package/build/abstraction/Identities.js +20 -21
- package/build/abstraction/Identities.js.map +1 -1
- package/build/abstraction/index.d.ts +2 -2
- package/build/abstraction/index.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/ipfs/IPFSOperations.d.ts +272 -0
- package/build/ipfs/IPFSOperations.js +293 -0
- package/build/ipfs/IPFSOperations.js.map +1 -0
- package/build/ipfs/index.d.ts +3 -0
- package/build/ipfs/index.js +7 -0
- package/build/ipfs/index.js.map +1 -0
- package/build/keyserver/KeyServerClient.d.ts +60 -0
- package/build/keyserver/KeyServerClient.js +171 -0
- package/build/keyserver/KeyServerClient.js.map +1 -0
- package/build/keyserver/errors.d.ts +22 -0
- package/build/keyserver/errors.js +29 -0
- package/build/keyserver/errors.js.map +1 -0
- package/build/keyserver/index.d.ts +31 -0
- package/build/keyserver/index.js +36 -0
- package/build/keyserver/index.js.map +1 -0
- package/build/keyserver/types.d.ts +147 -0
- package/build/keyserver/types.js +9 -0
- package/build/keyserver/types.js.map +1 -0
- package/build/keyserver/verification.d.ts +79 -0
- package/build/keyserver/verification.js +135 -0
- package/build/keyserver/verification.js.map +1 -0
- package/build/types/abstraction/index.d.ts +8 -3
- package/package.json +3 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Key Server Module
|
|
4
|
+
*
|
|
5
|
+
* Client for Key Server OAuth verification with DAHR attestation.
|
|
6
|
+
* Enables dApps to verify user ownership of GitHub/Discord accounts.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { KeyServerClient } from "@kynesyslabs/demosdk/keyserver";
|
|
11
|
+
*
|
|
12
|
+
* const client = new KeyServerClient({
|
|
13
|
+
* endpoint: "http://localhost:3030",
|
|
14
|
+
* nodePubKey: nodePublicKey,
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Full verification flow
|
|
18
|
+
* const result = await client.verifyOAuth("github", {
|
|
19
|
+
* onAuthUrl: (url) => window.open(url),
|
|
20
|
+
* onPoll: (attempt, status) => console.log(`Poll ${attempt}: ${status}`),
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* console.log("Verified user:", result.user.username);
|
|
24
|
+
* console.log("Attestation:", result.attestation);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.verifyOAuthAttestation = exports.verifyAttestation = exports.OAuthError = exports.KeyServerClient = void 0;
|
|
29
|
+
var KeyServerClient_1 = require("./KeyServerClient");
|
|
30
|
+
Object.defineProperty(exports, "KeyServerClient", { enumerable: true, get: function () { return KeyServerClient_1.KeyServerClient; } });
|
|
31
|
+
var errors_1 = require("./errors");
|
|
32
|
+
Object.defineProperty(exports, "OAuthError", { enumerable: true, get: function () { return errors_1.OAuthError; } });
|
|
33
|
+
var verification_1 = require("./verification");
|
|
34
|
+
Object.defineProperty(exports, "verifyAttestation", { enumerable: true, get: function () { return verification_1.verifyAttestation; } });
|
|
35
|
+
Object.defineProperty(exports, "verifyOAuthAttestation", { enumerable: true, get: function () { return verification_1.verifyOAuthAttestation; } });
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyserver/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAEH,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,+CAA2E;AAAlE,iHAAA,iBAAiB,OAAA;AAAE,sHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key Server OAuth Types
|
|
3
|
+
*
|
|
4
|
+
* Types for OAuth verification flow with DAHR attestation.
|
|
5
|
+
* Used by KeyServerClient to interact with the Key Server OAuth endpoints.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Supported OAuth providers
|
|
9
|
+
*/
|
|
10
|
+
export type OAuthService = "github" | "discord";
|
|
11
|
+
/**
|
|
12
|
+
* Options for initiating an OAuth flow
|
|
13
|
+
*/
|
|
14
|
+
export interface OAuthInitOptions {
|
|
15
|
+
/** Custom scopes to request (defaults to identity scopes) */
|
|
16
|
+
scopes?: string[];
|
|
17
|
+
/** Flow timeout in milliseconds (default: 600000 = 10min) */
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result from initiating an OAuth flow
|
|
22
|
+
*/
|
|
23
|
+
export interface OAuthInitResult {
|
|
24
|
+
/** Whether the initiation was successful */
|
|
25
|
+
success: boolean;
|
|
26
|
+
/** URL for user to visit to authorize */
|
|
27
|
+
authUrl: string;
|
|
28
|
+
/** State identifier for polling */
|
|
29
|
+
state: string;
|
|
30
|
+
/** Unix timestamp when this flow expires */
|
|
31
|
+
expiresAt: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Status of an OAuth flow
|
|
35
|
+
*/
|
|
36
|
+
export type OAuthStatus = "pending" | "completed" | "failed" | "expired";
|
|
37
|
+
/**
|
|
38
|
+
* User identity information from OAuth provider
|
|
39
|
+
*/
|
|
40
|
+
export interface OAuthUserInfo {
|
|
41
|
+
/** OAuth provider */
|
|
42
|
+
service: OAuthService;
|
|
43
|
+
/** Provider's user ID */
|
|
44
|
+
providerId: string;
|
|
45
|
+
/** Provider's username */
|
|
46
|
+
username: string;
|
|
47
|
+
/** User email (if email scope was requested) */
|
|
48
|
+
email?: string;
|
|
49
|
+
/** User avatar URL */
|
|
50
|
+
avatarUrl?: string;
|
|
51
|
+
/** Unix timestamp when verification completed */
|
|
52
|
+
verifiedAt: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* DAHR (Demos Attestation Hash Response) attestation
|
|
56
|
+
* Cryptographic proof that the Key Server performed the verification
|
|
57
|
+
*/
|
|
58
|
+
export interface DAHRAttestation {
|
|
59
|
+
/** SHA256 hash of the request payload */
|
|
60
|
+
requestHash: string;
|
|
61
|
+
/** SHA256 hash of the response payload */
|
|
62
|
+
responseHash: string;
|
|
63
|
+
/** Ed25519 signature over responseHash */
|
|
64
|
+
signature: {
|
|
65
|
+
type: "Ed25519";
|
|
66
|
+
data: string;
|
|
67
|
+
};
|
|
68
|
+
/** Attestation metadata */
|
|
69
|
+
metadata: {
|
|
70
|
+
/** Session identifier */
|
|
71
|
+
sessionId: string;
|
|
72
|
+
/** Unix timestamp of attestation */
|
|
73
|
+
timestamp: number;
|
|
74
|
+
/** Key Server's public key (hex) */
|
|
75
|
+
keyServerPubKey: string;
|
|
76
|
+
/** Node's public key (hex) */
|
|
77
|
+
nodePubKey: string;
|
|
78
|
+
/** Key Server version */
|
|
79
|
+
version: string;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Result from polling an OAuth flow
|
|
84
|
+
*/
|
|
85
|
+
export interface OAuthPollResult {
|
|
86
|
+
/** Whether the request was successful */
|
|
87
|
+
success: boolean;
|
|
88
|
+
/** Current status of the OAuth flow */
|
|
89
|
+
status: OAuthStatus;
|
|
90
|
+
/** User info (only present when status is "completed") */
|
|
91
|
+
result?: OAuthUserInfo;
|
|
92
|
+
/** DAHR attestation (only present when status is "completed") */
|
|
93
|
+
attestation?: DAHRAttestation;
|
|
94
|
+
/** Error details (only present when status is "failed" or "expired") */
|
|
95
|
+
error?: {
|
|
96
|
+
code: string;
|
|
97
|
+
message: string;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Options for the convenience verifyOAuth method
|
|
102
|
+
*/
|
|
103
|
+
export interface OAuthVerifyOptions extends OAuthInitOptions {
|
|
104
|
+
/**
|
|
105
|
+
* Called when auth URL is ready - dApp should display this to user
|
|
106
|
+
*/
|
|
107
|
+
onAuthUrl?: (authUrl: string, state: string) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Polling interval in milliseconds (default: 2000)
|
|
110
|
+
*/
|
|
111
|
+
pollInterval?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Called on each poll attempt (for UI feedback)
|
|
114
|
+
*/
|
|
115
|
+
onPoll?: (attempt: number, status: OAuthStatus) => void;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Result from the convenience verifyOAuth method
|
|
119
|
+
*/
|
|
120
|
+
export interface OAuthVerificationResult {
|
|
121
|
+
/** Whether verification was successful */
|
|
122
|
+
success: boolean;
|
|
123
|
+
/** Verified user information */
|
|
124
|
+
user: OAuthUserInfo;
|
|
125
|
+
/** DAHR attestation proving the verification */
|
|
126
|
+
attestation: DAHRAttestation;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Key Server client configuration
|
|
130
|
+
*/
|
|
131
|
+
export interface KeyServerClientConfig {
|
|
132
|
+
/** Key Server endpoint URL */
|
|
133
|
+
endpoint: string;
|
|
134
|
+
/** Node's public key (hex-encoded Ed25519) */
|
|
135
|
+
nodePubKey: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Response from GET /oauth/providers
|
|
139
|
+
*/
|
|
140
|
+
export interface OAuthProvidersResponse {
|
|
141
|
+
success: boolean;
|
|
142
|
+
providers?: OAuthService[];
|
|
143
|
+
error?: {
|
|
144
|
+
code: string;
|
|
145
|
+
message: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Key Server OAuth Types
|
|
4
|
+
*
|
|
5
|
+
* Types for OAuth verification flow with DAHR attestation.
|
|
6
|
+
* Used by KeyServerClient to interact with the Key Server OAuth endpoints.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/keyserver/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAHR Attestation Verification Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides cryptographic verification of Key Server attestations.
|
|
5
|
+
* Allows consuming apps to independently verify that the Key Server
|
|
6
|
+
* actually performed the OAuth verification.
|
|
7
|
+
*/
|
|
8
|
+
import type { DAHRAttestation, OAuthVerificationResult } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Options for attestation verification
|
|
11
|
+
*/
|
|
12
|
+
export interface VerifyAttestationOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Maximum age of attestation in milliseconds (default: 1 hour)
|
|
15
|
+
* Set to 0 to disable timestamp validation
|
|
16
|
+
*/
|
|
17
|
+
maxAge?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Expected node public key (optional additional validation)
|
|
20
|
+
*/
|
|
21
|
+
expectedNodePubKey?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Result of attestation verification
|
|
25
|
+
*/
|
|
26
|
+
export interface AttestationVerificationResult {
|
|
27
|
+
/** Whether the attestation is valid */
|
|
28
|
+
valid: boolean;
|
|
29
|
+
/** Reason for failure (if invalid) */
|
|
30
|
+
reason?: string;
|
|
31
|
+
/** Attestation metadata for logging/auditing */
|
|
32
|
+
metadata?: {
|
|
33
|
+
sessionId: string;
|
|
34
|
+
timestamp: number;
|
|
35
|
+
keyServerPubKey: string;
|
|
36
|
+
nodePubKey: string;
|
|
37
|
+
version: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Verify a DAHR attestation from Key Server
|
|
42
|
+
*
|
|
43
|
+
* This function verifies:
|
|
44
|
+
* 1. The Ed25519 signature is valid for the responseHash
|
|
45
|
+
* 2. The signature was made by the expected Key Server public key
|
|
46
|
+
* 3. The attestation is not expired (optional)
|
|
47
|
+
* 4. The node public key matches expected (optional)
|
|
48
|
+
*
|
|
49
|
+
* @param attestation - The DAHR attestation to verify
|
|
50
|
+
* @param keyServerPubKey - Expected Key Server public key (hex-encoded)
|
|
51
|
+
* @param options - Additional verification options
|
|
52
|
+
* @returns Verification result with validity and reason
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const result = await client.verifyOAuth("github", { ... });
|
|
57
|
+
*
|
|
58
|
+
* const verification = verifyAttestation(
|
|
59
|
+
* result.attestation,
|
|
60
|
+
* KNOWN_KEY_SERVER_PUBKEY,
|
|
61
|
+
* );
|
|
62
|
+
*
|
|
63
|
+
* if (!verification.valid) {
|
|
64
|
+
* console.error("Attestation invalid:", verification.reason);
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function verifyAttestation(attestation: DAHRAttestation, keyServerPubKey: string, options?: VerifyAttestationOptions): AttestationVerificationResult;
|
|
69
|
+
/**
|
|
70
|
+
* Verify attestation from a full OAuth verification result
|
|
71
|
+
*
|
|
72
|
+
* Convenience wrapper that extracts the attestation from the result.
|
|
73
|
+
*
|
|
74
|
+
* @param result - The OAuth verification result
|
|
75
|
+
* @param keyServerPubKey - Expected Key Server public key (hex-encoded)
|
|
76
|
+
* @param options - Additional verification options
|
|
77
|
+
* @returns Verification result
|
|
78
|
+
*/
|
|
79
|
+
export declare function verifyOAuthAttestation(result: OAuthVerificationResult, keyServerPubKey: string, options?: VerifyAttestationOptions): AttestationVerificationResult;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DAHR Attestation Verification Utilities
|
|
4
|
+
*
|
|
5
|
+
* Provides cryptographic verification of Key Server attestations.
|
|
6
|
+
* Allows consuming apps to independently verify that the Key Server
|
|
7
|
+
* actually performed the OAuth verification.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.verifyAttestation = verifyAttestation;
|
|
11
|
+
exports.verifyOAuthAttestation = verifyOAuthAttestation;
|
|
12
|
+
const encryption_1 = require("../encryption");
|
|
13
|
+
/**
|
|
14
|
+
* Verify a DAHR attestation from Key Server
|
|
15
|
+
*
|
|
16
|
+
* This function verifies:
|
|
17
|
+
* 1. The Ed25519 signature is valid for the responseHash
|
|
18
|
+
* 2. The signature was made by the expected Key Server public key
|
|
19
|
+
* 3. The attestation is not expired (optional)
|
|
20
|
+
* 4. The node public key matches expected (optional)
|
|
21
|
+
*
|
|
22
|
+
* @param attestation - The DAHR attestation to verify
|
|
23
|
+
* @param keyServerPubKey - Expected Key Server public key (hex-encoded)
|
|
24
|
+
* @param options - Additional verification options
|
|
25
|
+
* @returns Verification result with validity and reason
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const result = await client.verifyOAuth("github", { ... });
|
|
30
|
+
*
|
|
31
|
+
* const verification = verifyAttestation(
|
|
32
|
+
* result.attestation,
|
|
33
|
+
* KNOWN_KEY_SERVER_PUBKEY,
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* if (!verification.valid) {
|
|
37
|
+
* console.error("Attestation invalid:", verification.reason);
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function verifyAttestation(attestation, keyServerPubKey, options) {
|
|
42
|
+
const maxAge = options?.maxAge ?? 3600000; // 1 hour default
|
|
43
|
+
// Validate attestation structure
|
|
44
|
+
if (!attestation || !attestation.signature || !attestation.metadata) {
|
|
45
|
+
return {
|
|
46
|
+
valid: false,
|
|
47
|
+
reason: "Invalid attestation structure",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// Check signature type
|
|
51
|
+
if (attestation.signature.type !== "Ed25519") {
|
|
52
|
+
return {
|
|
53
|
+
valid: false,
|
|
54
|
+
reason: `Unsupported signature type: ${attestation.signature.type}`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Check Key Server public key matches
|
|
58
|
+
if (attestation.metadata.keyServerPubKey !== keyServerPubKey) {
|
|
59
|
+
return {
|
|
60
|
+
valid: false,
|
|
61
|
+
reason: "Key Server public key mismatch",
|
|
62
|
+
metadata: attestation.metadata,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Check node public key if expected
|
|
66
|
+
if (options?.expectedNodePubKey &&
|
|
67
|
+
attestation.metadata.nodePubKey !== options.expectedNodePubKey) {
|
|
68
|
+
return {
|
|
69
|
+
valid: false,
|
|
70
|
+
reason: "Node public key mismatch",
|
|
71
|
+
metadata: attestation.metadata,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// Check timestamp if maxAge is set
|
|
75
|
+
if (maxAge > 0) {
|
|
76
|
+
const age = Date.now() - attestation.metadata.timestamp;
|
|
77
|
+
if (age > maxAge) {
|
|
78
|
+
return {
|
|
79
|
+
valid: false,
|
|
80
|
+
reason: `Attestation expired (age: ${Math.round(age / 1000)}s, max: ${Math.round(maxAge / 1000)}s)`,
|
|
81
|
+
metadata: attestation.metadata,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Verify Ed25519 signature over responseHash
|
|
86
|
+
try {
|
|
87
|
+
const isValid = encryption_1.Cryptography.ed25519.verify(attestation.responseHash, hexToBuffer(attestation.signature.data), hexToBuffer(keyServerPubKey));
|
|
88
|
+
if (!isValid) {
|
|
89
|
+
return {
|
|
90
|
+
valid: false,
|
|
91
|
+
reason: "Signature verification failed",
|
|
92
|
+
metadata: attestation.metadata,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
valid: true,
|
|
97
|
+
metadata: attestation.metadata,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
return {
|
|
102
|
+
valid: false,
|
|
103
|
+
reason: `Signature verification error: ${error.message}`,
|
|
104
|
+
metadata: attestation.metadata,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Verify attestation from a full OAuth verification result
|
|
110
|
+
*
|
|
111
|
+
* Convenience wrapper that extracts the attestation from the result.
|
|
112
|
+
*
|
|
113
|
+
* @param result - The OAuth verification result
|
|
114
|
+
* @param keyServerPubKey - Expected Key Server public key (hex-encoded)
|
|
115
|
+
* @param options - Additional verification options
|
|
116
|
+
* @returns Verification result
|
|
117
|
+
*/
|
|
118
|
+
function verifyOAuthAttestation(result, keyServerPubKey, options) {
|
|
119
|
+
if (!result.attestation) {
|
|
120
|
+
return {
|
|
121
|
+
valid: false,
|
|
122
|
+
reason: "No attestation in result",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return verifyAttestation(result.attestation, keyServerPubKey, options);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Convert hex string to Buffer for cryptographic operations
|
|
129
|
+
*/
|
|
130
|
+
function hexToBuffer(hex) {
|
|
131
|
+
// Remove 0x prefix if present
|
|
132
|
+
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
133
|
+
return Buffer.from(cleanHex, "hex");
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.js","sourceRoot":"","sources":["../../../src/keyserver/verification.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAqEH,8CAmFC;AAYD,wDAaC;AA/KD,6CAA4C;AAuC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,iBAAiB,CAC7B,WAA4B,EAC5B,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C,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3D,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -69,9 +69,13 @@ export interface Web2CoreTargetIdentityPayload {
|
|
|
69
69
|
userId: string;
|
|
70
70
|
referralCode?: string;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
type GistProofUrl = `https://gist.github.com/${string}/${string}`;
|
|
73
|
+
type RawGistProofUrl = `https://gist.githubusercontent.com/${string}/${string}`;
|
|
74
|
+
type RawGithubProofUrl = `https://raw.githubusercontent.com/${string}/${string}`;
|
|
75
|
+
export type GithubProof = RawGistProofUrl | GistProofUrl | RawGithubProofUrl;
|
|
76
|
+
export interface InferFromGithubPayload extends Web2CoreTargetIdentityPayload {
|
|
73
77
|
context: "github";
|
|
74
|
-
proof:
|
|
78
|
+
proof: GithubProof;
|
|
75
79
|
}
|
|
76
80
|
export type XProof = `https://x.com/${string}/${string}`;
|
|
77
81
|
export type TwitterProof = XProof;
|
|
@@ -126,7 +130,7 @@ export interface BaseWeb2IdentityPayload {
|
|
|
126
130
|
}
|
|
127
131
|
export interface Web2IdentityAssignPayload extends BaseWeb2IdentityPayload {
|
|
128
132
|
method: "web2_identity_assign";
|
|
129
|
-
payload:
|
|
133
|
+
payload: InferFromGithubPayload | InferFromTwitterPayload | InferFromTelegramPayload | InferFromDiscordPayload;
|
|
130
134
|
}
|
|
131
135
|
export interface Web2IdentityRemovePayload extends BaseWeb2IdentityPayload {
|
|
132
136
|
method: "web2_identity_remove";
|
|
@@ -233,3 +237,4 @@ export interface FindDemosIdByWeb3IdentityQuery {
|
|
|
233
237
|
chain: string;
|
|
234
238
|
address: string;
|
|
235
239
|
}
|
|
240
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kynesyslabs/demosdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Demosdk is a JavaScript/TypeScript SDK that provides a unified interface for interacting with Demos network",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"./storage": "./build/storage/index.js",
|
|
38
38
|
"./d402": "./build/d402/index.js",
|
|
39
39
|
"./d402/server": "./build/d402/server/index.js",
|
|
40
|
-
"./d402/client": "./build/d402/client/index.js"
|
|
40
|
+
"./d402/client": "./build/d402/client/index.js",
|
|
41
|
+
"./keyserver": "./build/keyserver/index.js"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"postinstall": "cp .github/hooks/pre-commit .git/hooks/pre-commit 2>/dev/null && chmod +x .git/hooks/pre-commit 2>/dev/null || true",
|