@idos-network/issuer 1.0.0-rc.1.2 → 1.2.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/README.md +62 -1
- package/dist/index.d.mts +78 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +233 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -44
- package/src/index.ts +52 -29
- package/src/services/credential.service.ts +27 -24
- package/src/services/grant.service.ts +8 -7
- package/src/services/user.service.ts +14 -6
- package/dist/index.d.ts +0 -256
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -18048
- package/dist/index.js.map +0 -1
- package/src/services/passporting.service.ts +0 -13
package/README.md
CHANGED
|
@@ -1,11 +1,72 @@
|
|
|
1
1
|
# idOS Issuer JavaScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-side SDK for issuing and managing credentials in idOS. Designed for backend services that verify user identity and issue verifiable credentials.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@idos-network/issuer) 
|
|
6
|
+
|
|
7
|
+
> ⚖️ Legalities
|
|
8
|
+
>
|
|
9
|
+
> By downloading, installing, or implementing any of the idOS' SDKs, you acknowledge that you have read and understood idOS' Privacy Policy and Transparency Document.
|
|
10
|
+
>
|
|
11
|
+
> - <https://www.idos.network/legal/privacy-policy>
|
|
12
|
+
> - <https://www.idos.network/legal/transparency-document>
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @idos-network/issuer
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { idOSIssuer as idOSIssuerClass } from "@idos-network/issuer";
|
|
24
|
+
|
|
25
|
+
// Initialize with your signing and encryption keys
|
|
26
|
+
const idOSIssuer = await idOSIssuerClass.init({
|
|
27
|
+
nodeUrl: "https://nodes.idos.network",
|
|
28
|
+
signingKeyPair, // Your signing keypair
|
|
29
|
+
encryptionSecretKey, // Your encryption secret key
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Create a user profile
|
|
33
|
+
await idOSIssuer.createUser(user, wallet);
|
|
34
|
+
|
|
35
|
+
// Build and issue a W3C Verifiable Credential
|
|
36
|
+
const credential = await idOSIssuer.buildCredential(credentialFields, credentialSubject, issuer);
|
|
37
|
+
|
|
38
|
+
// Write credential using delegated write grant
|
|
39
|
+
await idOSIssuer.createCredentialByDelegatedWriteGrant(credentialPayload, delegatedWriteGrant);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
For complete documentation, examples, and implementation guides:
|
|
45
|
+
|
|
46
|
+
- 📖 **[Issuer Guide](../../docs/guide-issuer.md)** - Comprehensive implementation guide
|
|
47
|
+
- 🏗️ **[System Overview](../../docs/README.md)** - Understanding idOS architecture
|
|
48
|
+
- 🔒 **[Encryption](../../docs/encryption.md)** - Encryption key management
|
|
49
|
+
- ✍️ **[Signatures](../../docs/signatures.md)** - Signer implementation details
|
|
50
|
+
|
|
51
|
+
## Key Features
|
|
52
|
+
|
|
53
|
+
- **User Profile Creation** - Create and manage user profiles in idOS
|
|
54
|
+
- **Credential Issuance** - Issue W3C Verifiable Credentials
|
|
55
|
+
- **Delegated Write Grants** - Write credentials on behalf of users
|
|
56
|
+
- **Credential Management** - Edit and revoke issued credentials
|
|
57
|
+
- **Multi-Chain Support** - Works with EVM, NEAR, XRPL, and Stellar wallets
|
|
58
|
+
- **Schema Validation** - Optional validation against W3C VC schemas
|
|
59
|
+
|
|
60
|
+
## Support
|
|
61
|
+
|
|
62
|
+
Please follow the process outlined here: <https://github.com/idos-network/.github/blob/main/profile/README.md>
|
|
63
|
+
|
|
64
|
+
---
|
|
5
65
|
|
|
6
66
|
## Developing the SDK locally
|
|
7
67
|
|
|
8
68
|
Run:
|
|
69
|
+
|
|
9
70
|
```bash
|
|
10
71
|
pnpm dev
|
|
11
72
|
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Credential, FaceIdCredential } from "@idos-network/credentials/builder";
|
|
2
|
+
import { EditPublicNotesAsIssuerInput, idOSDelegatedWriteGrant, idOSGrant, idOSUser, idOSUser as idOSUser$1, idOSUserAttribute, idOSWallet, idOSWallet as idOSWallet$1 } from "@idos-network/kwil-infra/actions";
|
|
3
|
+
import nacl, { SignKeyPair } from "tweetnacl";
|
|
4
|
+
import { AvailableIssuerType, CredentialFields, CredentialSubject, CredentialSubjectFaceId, idOSCredential } from "@idos-network/credentials/types";
|
|
5
|
+
|
|
6
|
+
//#region src/services/credential.service.d.ts
|
|
7
|
+
type BaseCredentialParams = {
|
|
8
|
+
id?: string;
|
|
9
|
+
userId: string;
|
|
10
|
+
publicNotes: string;
|
|
11
|
+
plaintextContent: Uint8Array;
|
|
12
|
+
recipientEncryptionPublicKey: Uint8Array;
|
|
13
|
+
};
|
|
14
|
+
type DelegatedWriteGrantBaseParams = Omit<BaseCredentialParams, "userId">;
|
|
15
|
+
type DelegatedWriteGrantParams = {
|
|
16
|
+
id: string;
|
|
17
|
+
ownerWalletIdentifier: string;
|
|
18
|
+
consumerWalletIdentifier: string;
|
|
19
|
+
issuerPublicKey: string;
|
|
20
|
+
accessGrantTimelock: string;
|
|
21
|
+
notUsableBefore: string;
|
|
22
|
+
notUsableAfter: string;
|
|
23
|
+
signature: string;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/services/grant.service.d.ts
|
|
27
|
+
type CreateAccessGrantFromDAGParams = {
|
|
28
|
+
dag_data_id: string;
|
|
29
|
+
dag_owner_wallet_identifier: string;
|
|
30
|
+
dag_grantee_wallet_identifier: string;
|
|
31
|
+
dag_signature: string;
|
|
32
|
+
dag_locked_until: number;
|
|
33
|
+
dag_content_hash: string;
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/services/user.service.d.ts
|
|
37
|
+
type CreateProfileReqParams = Omit<idOSUser$1, "id"> & {
|
|
38
|
+
id?: string;
|
|
39
|
+
};
|
|
40
|
+
type UpsertWalletReqParams = Omit<idOSWallet$1, "id"> & {
|
|
41
|
+
id?: string;
|
|
42
|
+
};
|
|
43
|
+
type CreateWalletReqParams = Omit<UpsertWalletReqParams, "user_id"> & {
|
|
44
|
+
id?: string;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/index.d.ts
|
|
48
|
+
type CreateIssuerParams = {
|
|
49
|
+
chainId?: string;
|
|
50
|
+
nodeUrl: string;
|
|
51
|
+
signingKeyPair: SignKeyPair;
|
|
52
|
+
encryptionSecretKey: Uint8Array;
|
|
53
|
+
};
|
|
54
|
+
declare class idOSIssuer {
|
|
55
|
+
#private;
|
|
56
|
+
static init(params: CreateIssuerParams): Promise<idOSIssuer>;
|
|
57
|
+
private constructor();
|
|
58
|
+
hasProfile(userAddress: string): Promise<boolean>;
|
|
59
|
+
createUserProfile(params: CreateProfileReqParams): Promise<idOSUser>;
|
|
60
|
+
upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet>;
|
|
61
|
+
createUser(user: CreateProfileReqParams, wallet: CreateWalletReqParams): Promise<[idOSUser, idOSWallet]>;
|
|
62
|
+
getUser(id: string): Promise<idOSUser>;
|
|
63
|
+
requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string>;
|
|
64
|
+
createCredentialByDelegatedWriteGrant(credentialParams: DelegatedWriteGrantBaseParams, delegatedWriteGrant: DelegatedWriteGrantParams, consumerEncryptionPublicKey?: Uint8Array): Promise<{
|
|
65
|
+
originalCredential: Omit<idOSCredential, "user_id">;
|
|
66
|
+
copyCredential: Omit<idOSCredential, "user_id">;
|
|
67
|
+
}>;
|
|
68
|
+
editCredentialAsIssuer(publicNotesId: string, publicNotes: string): Promise<EditPublicNotesAsIssuerInput | null>;
|
|
69
|
+
getCredentialIdByContentHash(contentHash: string): Promise<string | null>;
|
|
70
|
+
getCredentialShared(id: string): Promise<idOSCredential | null>;
|
|
71
|
+
createAccessGrantFromDAG(params: CreateAccessGrantFromDAGParams): Promise<CreateAccessGrantFromDAGParams | null>;
|
|
72
|
+
buildCredential(fields: CredentialFields, subject: CredentialSubject, issuer: AvailableIssuerType, validate?: boolean): Promise<Credential>;
|
|
73
|
+
deriveCredentialLevel(subject: CredentialSubject): string;
|
|
74
|
+
buildFaceIdCredential(fields: CredentialFields, subject: CredentialSubjectFaceId, issuer: AvailableIssuerType, validate?: boolean): Promise<FaceIdCredential>;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { type AvailableIssuerType, type Credential, type CredentialFields, type CredentialSubject, type CredentialSubjectFaceId, type FaceIdCredential, type idOSCredential, type idOSDelegatedWriteGrant, type idOSGrant, idOSIssuer, type idOSUser, type idOSUserAttribute, type idOSWallet };
|
|
78
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/services/credential.service.ts","../src/services/grant.service.ts","../src/services/user.service.ts","../src/index.ts"],"mappings":";;;;;;KAsCY,oBAAA;EACV,EAAA;EACA,MAAA;EACA,WAAA;EACA,gBAAA,EAAkB,UAAA;EAClB,4BAAA,EAA8B,UAAA;AAAA;AAAA,KAGpB,6BAAA,GAAgC,IAAA,CAAK,oBAAA;AAAA,KAErC,yBAAA;EACV,EAAA;EACA,qBAAA;EACA,wBAAA;EACA,eAAA;EACA,mBAAA;EACA,eAAA;EACA,cAAA;EACA,SAAA;AAAA;;;KChDU,8BAAA;EACV,WAAA;EACA,2BAAA;EACA,6BAAA;EACA,aAAA;EACA,gBAAA;EACA,gBAAA;AAAA;;;KCFU,sBAAA,GAAyB,IAAA,CAAK,UAAA;EACxC,EAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,IAAA,CAAK,YAAA;EACvC,EAAA;AAAA;AAAA,KAGU,qBAAA,GAAw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A,EACR,OAAA,EAAS,uBAAA,EACT,MAAA,EAAQ,mBAAA,EACR,QAAA,aACC,OAAA,CAAQ,gBAAA;AAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { buildCredential, buildFaceIdCredential } from "@idos-network/credentials/builder";
|
|
2
|
+
import { deriveLevel } from "@idos-network/credentials/utils";
|
|
3
|
+
import { createNodeKwilClient, createServerKwilSigner } from "@idos-network/kwil-infra";
|
|
4
|
+
import { addUserAsInserter, createAgByDagForCopy, createCredentialsByDwg, dwgMessage, editPublicNotesAsIssuer, getCredentialShared, getSiblingCredentialId, getUserAsInserter, hasProfile, upsertWalletAsInserter } from "@idos-network/kwil-infra/actions";
|
|
5
|
+
import { base64Decode, base64Encode, hexEncode, hexEncodeSha256Hash, utf8Encode } from "@idos-network/utils/codecs";
|
|
6
|
+
import { NoncedBox, encryptContent } from "@idos-network/utils/cryptography";
|
|
7
|
+
import nacl from "tweetnacl";
|
|
8
|
+
//#region ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
9
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
10
|
+
var prefix = "Invariant failed";
|
|
11
|
+
function invariant(condition, message) {
|
|
12
|
+
if (condition) return;
|
|
13
|
+
if (isProduction) throw new Error(prefix);
|
|
14
|
+
var provided = typeof message === "function" ? message() : message;
|
|
15
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
16
|
+
throw new Error(value);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/services/credential.service.ts
|
|
20
|
+
var CredentialService = class {
|
|
21
|
+
#kwilClient;
|
|
22
|
+
#signingKeyPair;
|
|
23
|
+
#encryptionSecretKey;
|
|
24
|
+
constructor(kwilClient, signingKeyPair, encryptionSecretKey) {
|
|
25
|
+
this.#kwilClient = kwilClient;
|
|
26
|
+
this.#signingKeyPair = signingKeyPair;
|
|
27
|
+
this.#encryptionSecretKey = encryptionSecretKey;
|
|
28
|
+
}
|
|
29
|
+
#buildInsertableIDOSCredential({ userId, publicNotes, plaintextContent, recipientEncryptionPublicKey }) {
|
|
30
|
+
const ephemeralKeyPair = nacl.box.keyPair();
|
|
31
|
+
const content = encryptContent(plaintextContent, recipientEncryptionPublicKey, ephemeralKeyPair.secretKey);
|
|
32
|
+
const public_notes_signature = base64Encode(nacl.sign.detached(utf8Encode(publicNotes), this.#signingKeyPair.secretKey));
|
|
33
|
+
return {
|
|
34
|
+
user_id: userId,
|
|
35
|
+
content: base64Encode(content),
|
|
36
|
+
public_notes: publicNotes,
|
|
37
|
+
public_notes_signature,
|
|
38
|
+
broader_signature: base64Encode(nacl.sign.detached(Uint8Array.from([...base64Decode(public_notes_signature), ...content]), this.#signingKeyPair.secretKey)),
|
|
39
|
+
issuer_auth_public_key: hexEncode(this.#signingKeyPair.publicKey, true),
|
|
40
|
+
encryptor_public_key: base64Encode(ephemeralKeyPair.publicKey)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
#ensureEntityId(entity) {
|
|
44
|
+
if (!entity.id) entity.id = crypto.randomUUID();
|
|
45
|
+
return entity;
|
|
46
|
+
}
|
|
47
|
+
async requestDelegatedWriteGrantMessage(params) {
|
|
48
|
+
return dwgMessage(this.#kwilClient, params).then((res) => res.message);
|
|
49
|
+
}
|
|
50
|
+
async createCredentialByDelegatedWriteGrant(credentialParams, delegatedWriteGrant, consumerEncryptionPublicKey) {
|
|
51
|
+
let recipientPublicKey = consumerEncryptionPublicKey;
|
|
52
|
+
if (!recipientPublicKey) recipientPublicKey = nacl.box.keyPair.fromSecretKey(this.#encryptionSecretKey).publicKey;
|
|
53
|
+
const originalCredential = this.#ensureEntityId(this.#buildInsertableIDOSCredential(credentialParams));
|
|
54
|
+
const contentHash = hexEncodeSha256Hash(credentialParams.plaintextContent);
|
|
55
|
+
const copyCredential = this.#ensureEntityId(this.#buildInsertableIDOSCredential({
|
|
56
|
+
publicNotes: "",
|
|
57
|
+
plaintextContent: credentialParams.plaintextContent,
|
|
58
|
+
recipientEncryptionPublicKey: recipientPublicKey
|
|
59
|
+
}));
|
|
60
|
+
const payload = {
|
|
61
|
+
issuer_auth_public_key: originalCredential.issuer_auth_public_key,
|
|
62
|
+
original_encryptor_public_key: originalCredential.encryptor_public_key,
|
|
63
|
+
original_credential_id: originalCredential.id,
|
|
64
|
+
original_content: originalCredential.content,
|
|
65
|
+
original_public_notes: originalCredential.public_notes,
|
|
66
|
+
original_public_notes_signature: originalCredential.public_notes_signature,
|
|
67
|
+
original_broader_signature: originalCredential.broader_signature,
|
|
68
|
+
copy_encryptor_public_key: copyCredential.encryptor_public_key,
|
|
69
|
+
copy_credential_id: copyCredential.id,
|
|
70
|
+
copy_content: copyCredential.content,
|
|
71
|
+
copy_public_notes_signature: copyCredential.public_notes_signature,
|
|
72
|
+
copy_broader_signature: copyCredential.broader_signature,
|
|
73
|
+
content_hash: contentHash,
|
|
74
|
+
dwg_owner: delegatedWriteGrant.ownerWalletIdentifier,
|
|
75
|
+
dwg_grantee: delegatedWriteGrant.consumerWalletIdentifier,
|
|
76
|
+
dwg_issuer_public_key: delegatedWriteGrant.issuerPublicKey,
|
|
77
|
+
dwg_id: delegatedWriteGrant.id,
|
|
78
|
+
dwg_access_grant_timelock: delegatedWriteGrant.accessGrantTimelock,
|
|
79
|
+
dwg_not_before: delegatedWriteGrant.notUsableBefore,
|
|
80
|
+
dwg_not_after: delegatedWriteGrant.notUsableAfter,
|
|
81
|
+
dwg_signature: delegatedWriteGrant.signature
|
|
82
|
+
};
|
|
83
|
+
await createCredentialsByDwg(this.#kwilClient, payload);
|
|
84
|
+
return {
|
|
85
|
+
originalCredential,
|
|
86
|
+
copyCredential
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async editCredentialAsIssuer(publicNotesId, publicNotes) {
|
|
90
|
+
const payload = {
|
|
91
|
+
public_notes_id: publicNotesId,
|
|
92
|
+
public_notes: publicNotes
|
|
93
|
+
};
|
|
94
|
+
await editPublicNotesAsIssuer(this.#kwilClient, payload);
|
|
95
|
+
return payload;
|
|
96
|
+
}
|
|
97
|
+
async getCredentialIdByContentHash(contentHash) {
|
|
98
|
+
const id = await getSiblingCredentialId(this.#kwilClient, { content_hash: contentHash }).then((res) => res.id);
|
|
99
|
+
invariant(id, "Required `idOSCredential` id not found");
|
|
100
|
+
return id;
|
|
101
|
+
}
|
|
102
|
+
async getCredentialShared(id) {
|
|
103
|
+
return await getCredentialShared(this.#kwilClient, { id }).then((res) => res[0]) ?? null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/services/grant.service.ts
|
|
108
|
+
var GrantService = class {
|
|
109
|
+
#kwilClient;
|
|
110
|
+
#encryptionSecretKey;
|
|
111
|
+
constructor(kwilClient, encryptionSecretKey) {
|
|
112
|
+
this.#kwilClient = kwilClient;
|
|
113
|
+
this.#encryptionSecretKey = encryptionSecretKey;
|
|
114
|
+
}
|
|
115
|
+
async createAccessGrantFromDAG(params, getCredentialIdByContentHash, getCredentialShared) {
|
|
116
|
+
const credentialId = await getCredentialIdByContentHash(params.dag_content_hash);
|
|
117
|
+
invariant(credentialId, "Missing `idOSCredential` id");
|
|
118
|
+
const credential = await getCredentialShared(credentialId);
|
|
119
|
+
invariant(credential, "`idOSCredential` with id `{credentialId}` not found");
|
|
120
|
+
if (hexEncodeSha256Hash(utf8Encode(await NoncedBox.nonceFromBase64SecretKey(base64Encode(this.#encryptionSecretKey)).decrypt(credential.content, credential.encryptor_public_key))) !== params.dag_content_hash) throw new Error("Hash mismatch between `DAG` and `idOSCredential` content");
|
|
121
|
+
return await createAgByDagForCopy(this.#kwilClient, params) ?? null;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/services/user.service.ts
|
|
126
|
+
var UserService = class {
|
|
127
|
+
#kwilClient;
|
|
128
|
+
constructor(kwilClient) {
|
|
129
|
+
this.#kwilClient = kwilClient;
|
|
130
|
+
}
|
|
131
|
+
#ensureEntityId(entity) {
|
|
132
|
+
if (!entity.id) entity.id = crypto.randomUUID();
|
|
133
|
+
return entity;
|
|
134
|
+
}
|
|
135
|
+
async hasProfile(address) {
|
|
136
|
+
return hasProfile(this.#kwilClient, { address }).then((res) => res.has_profile);
|
|
137
|
+
}
|
|
138
|
+
async createUserProfile(params) {
|
|
139
|
+
const payload = this.#ensureEntityId(params);
|
|
140
|
+
await addUserAsInserter(this.#kwilClient, payload);
|
|
141
|
+
return payload;
|
|
142
|
+
}
|
|
143
|
+
async upsertWalletAsInserter(params) {
|
|
144
|
+
const payload = this.#ensureEntityId(params);
|
|
145
|
+
await upsertWalletAsInserter(this.#kwilClient, payload);
|
|
146
|
+
return payload;
|
|
147
|
+
}
|
|
148
|
+
async getUser(params) {
|
|
149
|
+
return getUserAsInserter(this.#kwilClient, this.#ensureEntityId(params));
|
|
150
|
+
}
|
|
151
|
+
async createUser(user, wallet) {
|
|
152
|
+
const user_id = user.id ?? crypto.randomUUID();
|
|
153
|
+
const wallet_id = wallet.id ?? crypto.randomUUID();
|
|
154
|
+
const userReqParams = {
|
|
155
|
+
...user,
|
|
156
|
+
id: user_id
|
|
157
|
+
};
|
|
158
|
+
const userResponse = await this.createUserProfile(userReqParams);
|
|
159
|
+
const walletReqParams = {
|
|
160
|
+
...wallet,
|
|
161
|
+
user_id,
|
|
162
|
+
id: wallet_id
|
|
163
|
+
};
|
|
164
|
+
return [userResponse, await this.upsertWalletAsInserter(walletReqParams)];
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/index.ts
|
|
169
|
+
var idOSIssuer = class idOSIssuer {
|
|
170
|
+
#credentialService;
|
|
171
|
+
#grantService;
|
|
172
|
+
#userService;
|
|
173
|
+
static async init(params) {
|
|
174
|
+
const kwilClient = await createNodeKwilClient({
|
|
175
|
+
nodeUrl: params.nodeUrl,
|
|
176
|
+
chainId: params.chainId
|
|
177
|
+
});
|
|
178
|
+
const [signer] = await createServerKwilSigner(params.signingKeyPair);
|
|
179
|
+
kwilClient.setSigner(signer);
|
|
180
|
+
return new idOSIssuer(new CredentialService(kwilClient, params.signingKeyPair, params.encryptionSecretKey), new GrantService(kwilClient, params.encryptionSecretKey), new UserService(kwilClient));
|
|
181
|
+
}
|
|
182
|
+
constructor(credentialService, grantService, userService) {
|
|
183
|
+
this.#credentialService = credentialService;
|
|
184
|
+
this.#grantService = grantService;
|
|
185
|
+
this.#userService = userService;
|
|
186
|
+
}
|
|
187
|
+
async hasProfile(userAddress) {
|
|
188
|
+
return this.#userService.hasProfile(userAddress);
|
|
189
|
+
}
|
|
190
|
+
async createUserProfile(params) {
|
|
191
|
+
return this.#userService.createUserProfile(params);
|
|
192
|
+
}
|
|
193
|
+
async upsertWalletAsInserter(params) {
|
|
194
|
+
return this.#userService.upsertWalletAsInserter(params);
|
|
195
|
+
}
|
|
196
|
+
async createUser(user, wallet) {
|
|
197
|
+
return this.#userService.createUser(user, wallet);
|
|
198
|
+
}
|
|
199
|
+
async getUser(id) {
|
|
200
|
+
return this.#userService.getUser({ id });
|
|
201
|
+
}
|
|
202
|
+
async requestDelegatedWriteGrantMessage(params) {
|
|
203
|
+
return this.#credentialService.requestDelegatedWriteGrantMessage(params);
|
|
204
|
+
}
|
|
205
|
+
async createCredentialByDelegatedWriteGrant(credentialParams, delegatedWriteGrant, consumerEncryptionPublicKey) {
|
|
206
|
+
return this.#credentialService.createCredentialByDelegatedWriteGrant(credentialParams, delegatedWriteGrant, consumerEncryptionPublicKey);
|
|
207
|
+
}
|
|
208
|
+
async editCredentialAsIssuer(publicNotesId, publicNotes) {
|
|
209
|
+
return this.#credentialService.editCredentialAsIssuer(publicNotesId, publicNotes);
|
|
210
|
+
}
|
|
211
|
+
async getCredentialIdByContentHash(contentHash) {
|
|
212
|
+
return this.#credentialService.getCredentialIdByContentHash(contentHash);
|
|
213
|
+
}
|
|
214
|
+
async getCredentialShared(id) {
|
|
215
|
+
return this.#credentialService.getCredentialShared(id);
|
|
216
|
+
}
|
|
217
|
+
async createAccessGrantFromDAG(params) {
|
|
218
|
+
return this.#grantService.createAccessGrantFromDAG(params, (contentHash) => this.getCredentialIdByContentHash(contentHash), (id) => this.getCredentialShared(id));
|
|
219
|
+
}
|
|
220
|
+
async buildCredential(fields, subject, issuer, validate = true) {
|
|
221
|
+
return buildCredential(fields, subject, issuer, validate);
|
|
222
|
+
}
|
|
223
|
+
deriveCredentialLevel(subject) {
|
|
224
|
+
return deriveLevel(subject);
|
|
225
|
+
}
|
|
226
|
+
async buildFaceIdCredential(fields, subject, issuer, validate = true) {
|
|
227
|
+
return buildFaceIdCredential(fields, subject, issuer, validate);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
//#endregion
|
|
231
|
+
export { idOSIssuer };
|
|
232
|
+
|
|
233
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#kwilClient","#signingKeyPair","#encryptionSecretKey","#ensureEntityId","#buildInsertableIDOSCredential","#kwilClient","#encryptionSecretKey","_createAgByDagForCopy","#kwilClient","_hasProfile","#ensureEntityId","_upsertWalletAsInserter","#credentialService","#grantService","#userService"],"sources":["../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../src/services/credential.service.ts","../src/services/grant.service.ts","../src/services/user.service.ts","../src/index.ts"],"sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\n\nexport { invariant as default };\n","import type { idOSCredential } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n type CreateCredentialsByDwgInput,\n createCredentialsByDwg,\n dwgMessage,\n type EditPublicNotesAsIssuerInput,\n editPublicNotesAsIssuer,\n getCredentialShared,\n getSiblingCredentialId,\n type idOSDelegatedWriteGrant,\n} from \"@idos-network/kwil-infra/actions\";\nimport {\n base64Decode,\n base64Encode,\n hexEncode,\n hexEncodeSha256Hash,\n utf8Encode,\n} from \"@idos-network/utils/codecs\";\nimport { encryptContent } from \"@idos-network/utils/cryptography\";\nimport invariant from \"tiny-invariant\";\nimport nacl from \"tweetnacl\";\n\ntype InsertableIDOSCredential = Omit<idOSCredential, \"id\" | \"original_id\"> & {\n id?: idOSCredential[\"id\"];\n content_hash?: string;\n public_notes_signature: string;\n broader_signature: string;\n};\n\ntype BuildInsertableIDOSCredentialArgs = {\n userId: string;\n publicNotes: string;\n plaintextContent: Uint8Array;\n recipientEncryptionPublicKey: Uint8Array;\n};\n\nexport type BaseCredentialParams = {\n id?: string;\n userId: string;\n publicNotes: string;\n plaintextContent: Uint8Array;\n recipientEncryptionPublicKey: Uint8Array;\n};\n\nexport type DelegatedWriteGrantBaseParams = Omit<BaseCredentialParams, \"userId\">;\n\nexport type DelegatedWriteGrantParams = {\n id: string;\n ownerWalletIdentifier: string;\n consumerWalletIdentifier: string;\n issuerPublicKey: string;\n accessGrantTimelock: string;\n notUsableBefore: string;\n notUsableAfter: string;\n signature: string;\n};\n\nexport class CredentialService {\n readonly #kwilClient: KwilActionClient;\n readonly #signingKeyPair: nacl.SignKeyPair;\n readonly #encryptionSecretKey: Uint8Array;\n\n constructor(\n kwilClient: KwilActionClient,\n signingKeyPair: nacl.SignKeyPair,\n encryptionSecretKey: Uint8Array,\n ) {\n this.#kwilClient = kwilClient;\n this.#signingKeyPair = signingKeyPair;\n this.#encryptionSecretKey = encryptionSecretKey;\n }\n\n #buildInsertableIDOSCredential({\n userId,\n publicNotes,\n plaintextContent,\n recipientEncryptionPublicKey,\n }: Omit<BuildInsertableIDOSCredentialArgs, \"userId\"> & { userId?: string }):\n | InsertableIDOSCredential\n | Omit<InsertableIDOSCredential, \"user_id\"> {\n const ephemeralKeyPair = nacl.box.keyPair();\n const content = encryptContent(\n plaintextContent,\n recipientEncryptionPublicKey,\n ephemeralKeyPair.secretKey,\n );\n\n const public_notes_signature = base64Encode(\n nacl.sign.detached(utf8Encode(publicNotes), this.#signingKeyPair.secretKey),\n );\n\n return {\n user_id: userId,\n content: base64Encode(content),\n public_notes: publicNotes,\n public_notes_signature,\n\n broader_signature: base64Encode(\n nacl.sign.detached(\n Uint8Array.from([...base64Decode(public_notes_signature), ...content]),\n this.#signingKeyPair.secretKey,\n ),\n ),\n\n issuer_auth_public_key: hexEncode(this.#signingKeyPair.publicKey, true),\n encryptor_public_key: base64Encode(ephemeralKeyPair.publicKey),\n };\n }\n\n #ensureEntityId<T extends { id?: string }>(entity: T): T & { id: string } {\n if (!entity.id) {\n (entity as T & { id: string }).id = crypto.randomUUID();\n }\n return entity as T & { id: string };\n }\n\n async requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return dwgMessage(this.#kwilClient, params).then((res) => res.message);\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: DelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey?: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n let recipientPublicKey = consumerEncryptionPublicKey;\n if (!recipientPublicKey) {\n // If we're not explicitly given a consumer enc pub key, we're assuming that the issuer is creating a copy\n // for themselves. So, we derive the recipient encryption public key from the issuer's encryption secret key.\n recipientPublicKey = nacl.box.keyPair.fromSecretKey(this.#encryptionSecretKey).publicKey;\n }\n\n const originalCredential = this.#ensureEntityId(\n this.#buildInsertableIDOSCredential(credentialParams),\n );\n\n const contentHash = hexEncodeSha256Hash(credentialParams.plaintextContent);\n\n const copyCredential = this.#ensureEntityId(\n this.#buildInsertableIDOSCredential({\n publicNotes: \"\",\n plaintextContent: credentialParams.plaintextContent,\n recipientEncryptionPublicKey: recipientPublicKey,\n }),\n );\n\n const payload: CreateCredentialsByDwgInput = {\n issuer_auth_public_key: originalCredential.issuer_auth_public_key,\n original_encryptor_public_key: originalCredential.encryptor_public_key,\n original_credential_id: originalCredential.id,\n original_content: originalCredential.content,\n original_public_notes: originalCredential.public_notes,\n original_public_notes_signature: originalCredential.public_notes_signature,\n original_broader_signature: originalCredential.broader_signature,\n copy_encryptor_public_key: copyCredential.encryptor_public_key,\n copy_credential_id: copyCredential.id,\n copy_content: copyCredential.content,\n copy_public_notes_signature: copyCredential.public_notes_signature,\n copy_broader_signature: copyCredential.broader_signature,\n content_hash: contentHash,\n dwg_owner: delegatedWriteGrant.ownerWalletIdentifier,\n dwg_grantee: delegatedWriteGrant.consumerWalletIdentifier,\n dwg_issuer_public_key: delegatedWriteGrant.issuerPublicKey,\n dwg_id: delegatedWriteGrant.id,\n dwg_access_grant_timelock: delegatedWriteGrant.accessGrantTimelock,\n dwg_not_before: delegatedWriteGrant.notUsableBefore,\n dwg_not_after: delegatedWriteGrant.notUsableAfter,\n dwg_signature: delegatedWriteGrant.signature,\n };\n\n await createCredentialsByDwg(this.#kwilClient, payload);\n\n return { originalCredential, copyCredential };\n }\n\n async editCredentialAsIssuer(\n publicNotesId: string,\n publicNotes: string,\n ): Promise<EditPublicNotesAsIssuerInput | null> {\n const payload = {\n public_notes_id: publicNotesId,\n public_notes: publicNotes,\n };\n\n await editPublicNotesAsIssuer(this.#kwilClient, payload);\n\n return payload;\n }\n\n async getCredentialIdByContentHash(contentHash: string): Promise<string | null> {\n const id = await getSiblingCredentialId(this.#kwilClient, { content_hash: contentHash }).then(\n (res) => res.id,\n );\n\n invariant(id, \"Required `idOSCredential` id not found\");\n\n return id;\n }\n\n async getCredentialShared(id: string): Promise<idOSCredential | null> {\n const result = await getCredentialShared(this.#kwilClient, { id }).then((res) => res[0]);\n\n return result ?? null;\n }\n}\n","import type { idOSCredential } from \"@idos-network/credentials/types\";\nimport type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport { createAgByDagForCopy as _createAgByDagForCopy } from \"@idos-network/kwil-infra/actions\";\nimport { base64Encode, hexEncodeSha256Hash, utf8Encode } from \"@idos-network/utils/codecs\";\nimport { NoncedBox } from \"@idos-network/utils/cryptography\";\nimport invariant from \"tiny-invariant\";\n\nexport type CreateAccessGrantFromDAGParams = {\n dag_data_id: string;\n dag_owner_wallet_identifier: string;\n dag_grantee_wallet_identifier: string;\n dag_signature: string;\n dag_locked_until: number;\n dag_content_hash: string;\n};\n\nexport class GrantService {\n readonly #kwilClient: KwilActionClient;\n readonly #encryptionSecretKey: Uint8Array;\n\n constructor(kwilClient: KwilActionClient, encryptionSecretKey: Uint8Array) {\n this.#kwilClient = kwilClient;\n this.#encryptionSecretKey = encryptionSecretKey;\n }\n\n async createAccessGrantFromDAG(\n params: CreateAccessGrantFromDAGParams,\n getCredentialIdByContentHash: (contentHash: string) => Promise<string | null>,\n getCredentialShared: (id: string) => Promise<idOSCredential | null>,\n ): Promise<CreateAccessGrantFromDAGParams | null> {\n const credentialId = await getCredentialIdByContentHash(params.dag_content_hash);\n\n invariant(credentialId, \"Missing `idOSCredential` id\");\n\n const credential = await getCredentialShared(credentialId);\n\n invariant(credential, \"`idOSCredential` with id `{credentialId}` not found\");\n\n const plaintextContent = await NoncedBox.nonceFromBase64SecretKey(\n base64Encode(this.#encryptionSecretKey),\n ).decrypt(credential.content, credential.encryptor_public_key);\n\n // Get the content hash from the plaintext content\n const contentHash = hexEncodeSha256Hash(utf8Encode(plaintextContent));\n\n // Check if the content hash matches the content hash in the credential\n if (contentHash !== params.dag_content_hash) {\n throw new Error(\"Hash mismatch between `DAG` and `idOSCredential` content\");\n }\n\n const result = await _createAgByDagForCopy(this.#kwilClient, params);\n\n return result ?? null;\n }\n}\n","import type { KwilActionClient } from \"@idos-network/kwil-infra\";\n\nimport {\n hasProfile as _hasProfile,\n upsertWalletAsInserter as _upsertWalletAsInserter,\n addUserAsInserter,\n type GetUserAsInserterInput,\n getUserAsInserter,\n type idOSUser,\n type idOSWallet,\n} from \"@idos-network/kwil-infra/actions\";\n\nexport type CreateProfileReqParams = Omit<idOSUser, \"id\"> & {\n id?: string;\n};\n\nexport type UpsertWalletReqParams = Omit<idOSWallet, \"id\"> & {\n id?: string;\n};\n\nexport type CreateWalletReqParams = Omit<UpsertWalletReqParams, \"user_id\"> & {\n id?: string;\n};\n\nexport class UserService {\n readonly #kwilClient: KwilActionClient;\n\n constructor(kwilClient: KwilActionClient) {\n this.#kwilClient = kwilClient;\n }\n\n #ensureEntityId<T extends { id?: string }>(entity: T): T & { id: string } {\n if (!entity.id) {\n (entity as T & { id: string }).id = crypto.randomUUID();\n }\n return entity as T & { id: string };\n }\n\n async hasProfile(address: string): Promise<boolean> {\n return _hasProfile(this.#kwilClient, { address }).then((res) => res.has_profile);\n }\n\n async createUserProfile(params: CreateProfileReqParams): Promise<idOSUser> {\n const payload = this.#ensureEntityId(params);\n await addUserAsInserter(this.#kwilClient, payload);\n return payload;\n }\n\n async upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet> {\n const payload = this.#ensureEntityId(params);\n await _upsertWalletAsInserter(this.#kwilClient, payload);\n return payload;\n }\n\n /// Useful to understand if a user id already exists.\n async getUser(params: GetUserAsInserterInput): Promise<idOSUser> {\n return getUserAsInserter(this.#kwilClient, this.#ensureEntityId(params));\n }\n\n async createUser(\n user: CreateProfileReqParams,\n wallet: CreateWalletReqParams,\n ): Promise<[idOSUser, idOSWallet]> {\n const user_id = user.id ?? crypto.randomUUID();\n const wallet_id = wallet.id ?? crypto.randomUUID();\n\n const userReqParams = {\n ...user,\n id: user_id,\n };\n\n const userResponse = await this.createUserProfile(userReqParams);\n\n const walletReqParams = {\n ...wallet,\n user_id,\n id: wallet_id,\n };\n\n const walletResponse = await this.upsertWalletAsInserter(walletReqParams);\n\n return [userResponse, walletResponse];\n }\n}\n","import type {\n AvailableIssuerType,\n CredentialFields,\n CredentialSubject,\n CredentialSubjectFaceId,\n idOSCredential,\n} from \"@idos-network/credentials/types\";\nimport type {\n EditPublicNotesAsIssuerInput,\n idOSDelegatedWriteGrant,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSWallet,\n} from \"@idos-network/kwil-infra/actions\";\nimport type { SignKeyPair } from \"tweetnacl\";\n\nimport {\n buildCredential,\n buildFaceIdCredential,\n type Credential,\n type FaceIdCredential,\n} from \"@idos-network/credentials/builder\";\nimport { deriveLevel } from \"@idos-network/credentials/utils\";\nimport { createNodeKwilClient, createServerKwilSigner } from \"@idos-network/kwil-infra\";\n\nimport {\n CredentialService,\n type DelegatedWriteGrantBaseParams,\n type DelegatedWriteGrantParams,\n} from \"./services/credential.service\";\nimport { type CreateAccessGrantFromDAGParams, GrantService } from \"./services/grant.service\";\nimport {\n type CreateProfileReqParams,\n type CreateWalletReqParams,\n type UpsertWalletReqParams,\n UserService,\n} from \"./services/user.service\";\n\ntype CreateIssuerParams = {\n chainId?: string;\n nodeUrl: string;\n signingKeyPair: SignKeyPair;\n encryptionSecretKey: Uint8Array;\n};\n\nexport class idOSIssuer {\n readonly #credentialService: CredentialService;\n readonly #grantService: GrantService;\n readonly #userService: UserService;\n\n static async init(params: CreateIssuerParams): Promise<idOSIssuer> {\n const kwilClient = await createNodeKwilClient({\n nodeUrl: params.nodeUrl,\n chainId: params.chainId,\n });\n\n const [signer] = await createServerKwilSigner(params.signingKeyPair);\n kwilClient.setSigner(signer);\n\n const credentialService = new CredentialService(\n kwilClient,\n params.signingKeyPair,\n params.encryptionSecretKey,\n );\n\n const grantService = new GrantService(kwilClient, params.encryptionSecretKey);\n const userService = new UserService(kwilClient);\n\n return new idOSIssuer(credentialService, grantService, userService);\n }\n\n private constructor(\n credentialService: CredentialService,\n grantService: GrantService,\n userService: UserService,\n ) {\n this.#credentialService = credentialService;\n this.#grantService = grantService;\n this.#userService = userService;\n }\n\n // User Service facade methods\n async hasProfile(userAddress: string): Promise<boolean> {\n return this.#userService.hasProfile(userAddress);\n }\n\n async createUserProfile(params: CreateProfileReqParams): Promise<idOSUser> {\n return this.#userService.createUserProfile(params);\n }\n\n async upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet> {\n return this.#userService.upsertWalletAsInserter(params);\n }\n\n async createUser(\n user: CreateProfileReqParams,\n wallet: CreateWalletReqParams,\n ): Promise<[idOSUser, idOSWallet]> {\n return this.#userService.createUser(user, wallet);\n }\n\n async getUser(id: string): Promise<idOSUser> {\n return this.#userService.getUser({ id });\n }\n\n async requestDelegatedWriteGrantMessage(params: idOSDelegatedWriteGrant): Promise<string> {\n return this.#credentialService.requestDelegatedWriteGrantMessage(params);\n }\n\n async createCredentialByDelegatedWriteGrant(\n credentialParams: DelegatedWriteGrantBaseParams,\n delegatedWriteGrant: DelegatedWriteGrantParams,\n consumerEncryptionPublicKey?: Uint8Array,\n ): Promise<{\n originalCredential: Omit<idOSCredential, \"user_id\">;\n copyCredential: Omit<idOSCredential, \"user_id\">;\n }> {\n return this.#credentialService.createCredentialByDelegatedWriteGrant(\n credentialParams,\n delegatedWriteGrant,\n consumerEncryptionPublicKey,\n );\n }\n\n async editCredentialAsIssuer(\n publicNotesId: string,\n publicNotes: string,\n ): Promise<EditPublicNotesAsIssuerInput | null> {\n return this.#credentialService.editCredentialAsIssuer(publicNotesId, publicNotes);\n }\n\n async getCredentialIdByContentHash(contentHash: string): Promise<string | null> {\n return this.#credentialService.getCredentialIdByContentHash(contentHash);\n }\n\n async getCredentialShared(id: string): Promise<idOSCredential | null> {\n return this.#credentialService.getCredentialShared(id);\n }\n\n async createAccessGrantFromDAG(\n params: CreateAccessGrantFromDAGParams,\n ): Promise<CreateAccessGrantFromDAGParams | null> {\n return this.#grantService.createAccessGrantFromDAG(\n params,\n (contentHash: string) => this.getCredentialIdByContentHash(contentHash),\n (id: string) => this.getCredentialShared(id),\n );\n }\n\n async buildCredential(\n fields: CredentialFields,\n subject: CredentialSubject,\n issuer: AvailableIssuerType,\n validate = true,\n ): Promise<Credential> {\n return buildCredential(fields, subject, issuer, validate);\n }\n\n deriveCredentialLevel(subject: CredentialSubject): string {\n return deriveLevel(subject);\n }\n\n async buildFaceIdCredential(\n fields: CredentialFields,\n subject: CredentialSubjectFaceId,\n issuer: AvailableIssuerType,\n validate = true,\n ): Promise<FaceIdCredential> {\n return buildFaceIdCredential(fields, subject, issuer, validate);\n }\n}\n\nexport type {\n idOSCredential,\n idOSGrant,\n idOSUser,\n idOSUserAttribute,\n idOSDelegatedWriteGrant,\n idOSWallet,\n CredentialFields,\n CredentialSubject,\n AvailableIssuerType,\n Credential,\n CredentialSubjectFaceId,\n FaceIdCredential,\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAAA,IAAI,eAAe,QAAQ,IAAI,aAAa;AAC5C,IAAI,SAAS;AACb,SAAS,UAAU,WAAW,SAAS;CACnC,IAAI,WACA;CAEJ,IAAI,cACA,MAAM,IAAI,MAAM,OAAO;CAE3B,IAAI,WAAW,OAAO,YAAY,aAAa,SAAS,GAAG;CAC3D,IAAI,QAAQ,WAAW,GAAG,OAAO,QAAQ,KAAK,CAAC,OAAO,SAAS,GAAG;CAClE,MAAM,IAAI,MAAM,MAAM;;;;ACgD1B,IAAa,oBAAb,MAA+B;CAC7B;CACA;CACA;CAEA,YACE,YACA,gBACA,qBACA;EACA,KAAKA,cAAc;EACnB,KAAKC,kBAAkB;EACvB,KAAKC,uBAAuB;;CAG9B,+BAA+B,EAC7B,QACA,aACA,kBACA,gCAG4C;EAC5C,MAAM,mBAAmB,KAAK,IAAI,SAAS;EAC3C,MAAM,UAAU,eACd,kBACA,8BACA,iBAAiB,UAClB;EAED,MAAM,yBAAyB,aAC7B,KAAK,KAAK,SAAS,WAAW,YAAY,EAAE,KAAKD,gBAAgB,UAAU,CAC5E;EAED,OAAO;GACL,SAAS;GACT,SAAS,aAAa,QAAQ;GAC9B,cAAc;GACd;GAE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",
|
|
3
4
|
"description": "idOS Issuer JavaScript SDK for server environments",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
"homepage": "https://idos.network",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": "github:idos-network/idos-sdk-js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/**/*",
|
|
10
|
+
"src/**/*"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "./dist/index.mjs",
|
|
15
|
+
"module": "dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"import": "./dist/index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
10
25
|
},
|
|
11
26
|
"dependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@digitalbazaar/ed25519-verification-key-2020": "^4.2.0",
|
|
14
|
-
"@digitalbazaar/vc": "^7.2.0",
|
|
15
|
-
"@idos-network/kwil-js": "0.1.1",
|
|
16
|
-
"base85": "^3.1.0",
|
|
17
|
-
"es-toolkit": "^1.39.0",
|
|
18
|
-
"jsonld-document-loader": "^2.3.0",
|
|
19
|
-
"ripple-keypairs": "^2.0.0",
|
|
27
|
+
"@idos-network/kwil-js": "0.1.3",
|
|
20
28
|
"tweetnacl": "^1.0.3",
|
|
21
|
-
"
|
|
29
|
+
"@idos-network/kwil-infra": "1.2.0",
|
|
30
|
+
"@idos-network/credentials": "1.2.0",
|
|
31
|
+
"@idos-network/utils": "1.2.0"
|
|
22
32
|
},
|
|
23
33
|
"devDependencies": {
|
|
24
|
-
"clean-package": "^2.2.0",
|
|
25
|
-
"release-it": "^19.0.2",
|
|
26
|
-
"release-it-pnpm": "^4.6.5",
|
|
27
34
|
"tiny-invariant": "^1.3.3",
|
|
28
|
-
"tsdown": "^0.
|
|
29
|
-
"@idos-network/utils": "1.0.0-rc.1.0"
|
|
30
|
-
},
|
|
31
|
-
"engines": {
|
|
32
|
-
"node": ">=20.0.0"
|
|
35
|
+
"tsdown": "^0.22.0"
|
|
33
36
|
},
|
|
34
|
-
"exports": {
|
|
35
|
-
".": {
|
|
36
|
-
"types": "./dist/index.d.ts",
|
|
37
|
-
"import": "./dist/index.js"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"files": [
|
|
41
|
-
"dist/**/*",
|
|
42
|
-
"src/**/*"
|
|
43
|
-
],
|
|
44
|
-
"homepage": "https://idos.network",
|
|
45
|
-
"license": "MIT",
|
|
46
|
-
"main": "./dist/index.js",
|
|
47
|
-
"module": "dist/index.js",
|
|
48
37
|
"peerDependencies": {
|
|
49
38
|
"typescript": "^5.8.3"
|
|
50
39
|
},
|
|
51
|
-
"
|
|
52
|
-
"
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=22.19.0"
|
|
53
42
|
},
|
|
54
|
-
"repository": "https://github.com/idos-network/idos-sdk-js",
|
|
55
|
-
"sideEffects": false,
|
|
56
|
-
"type": "module",
|
|
57
|
-
"types": "./dist/index.d.ts",
|
|
58
43
|
"scripts": {
|
|
59
44
|
"build": "tsdown",
|
|
60
45
|
"dev": "tsdown --watch",
|
|
61
46
|
"publint": "pnpx publint --strict",
|
|
62
|
-
"
|
|
47
|
+
"typecheck": "tsc --noEmit"
|
|
63
48
|
}
|
|
64
49
|
}
|