@idos-network/issuer 1.0.0-rc.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 idOS Network
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # idOS Issuer JavaScript SDK
2
+
3
+ See [Issuer guide](../../docs/guide-issuer.md)
4
+
5
+
6
+ ## Developing the SDK locally
7
+
8
+ Run:
9
+ ```bash
10
+ pnpm dev
11
+ ```
12
+
13
+ This will start the compiler in watch mode that will rebuild every time any of the source files are changed.
14
+
15
+ You can also create a production build by running the following command in the root folder of the SDK package:
16
+
17
+ ```bash
18
+ pnpm build
19
+ ```
@@ -0,0 +1,205 @@
1
+ import nacl, { SignKeyPair } from "tweetnacl";
2
+
3
+ //#region ../@core/src/types/index.d.ts
4
+
5
+ type idOSUser = {
6
+ id: string;
7
+ recipient_encryption_public_key: string;
8
+ };
9
+ type idOSCredential = {
10
+ id: string;
11
+ user_id: string;
12
+ issuer_auth_public_key: string;
13
+ original_id?: string;
14
+ public_notes: string;
15
+ content: string;
16
+ encryptor_public_key: string;
17
+ };
18
+ type idOSWallet = {
19
+ id: string;
20
+ user_id: string;
21
+ address: string;
22
+ wallet_type: string;
23
+ message: string;
24
+ public_key: string;
25
+ signature: string;
26
+ };
27
+ type idOSUserAttribute = {
28
+ id: string;
29
+ attribute_key: string;
30
+ value: string;
31
+ user_id?: string;
32
+ };
33
+ type idOSGrant = {
34
+ id: string;
35
+ ag_owner_user_id: string;
36
+ ag_grantee_wallet_identifier: string;
37
+ data_id: string;
38
+ locked_until: string;
39
+ content_hash?: string;
40
+ }; //#endregion
41
+ //#region ../@core/src/kwil-actions/credentials.d.ts
42
+
43
+ interface EditCredentialAsIssuerParams {
44
+ public_notes_id: string;
45
+ public_notes: string;
46
+ } //#endregion
47
+ //#region src/services/credential.service.d.ts
48
+
49
+ /**
50
+ * Edits the public notes of an idOSCredential if the signer is a permissioned issuer.
51
+ * This is how a credential is edited (modified) by a permissioned issuer.
52
+ */
53
+ type BaseCredentialParams = {
54
+ id?: string;
55
+ userId: string;
56
+ publicNotes: string;
57
+ plaintextContent: Uint8Array;
58
+ recipientEncryptionPublicKey: Uint8Array;
59
+ };
60
+ type DelegatedWriteGrantBaseParams = Omit<BaseCredentialParams, "userId">;
61
+ type DelegatedWriteGrantParams = {
62
+ id: string;
63
+ ownerWalletIdentifier: string;
64
+ consumerWalletIdentifier: string;
65
+ issuerPublicKey: string;
66
+ accessGrantTimelock: string;
67
+ notUsableBefore: string;
68
+ notUsableAfter: string;
69
+ signature: string;
70
+ };
71
+
72
+ //#endregion
73
+ //#region src/services/credentials-builder.service.d.ts
74
+ interface CredentialFields {
75
+ id: string;
76
+ /* Level of KYC verification performed (e.g., basic, intermediate, advanced). */
77
+ level: string;
78
+ /* @default Date.now() */
79
+ issued?: Date;
80
+ /* Date the credential was approved. */
81
+ approvedAt?: Date;
82
+ /* Date the credential was revoked. */
83
+ expirationDate?: Date;
84
+ }
85
+ interface CredentialResidentialAddress {
86
+ /* Street address. */
87
+ street: string;
88
+ /* House number. */
89
+ houseNumber?: string;
90
+ /* Additional address information (e.g., apartment number). */
91
+ additionalAddressInfo?: string;
92
+ /* Locality (e.g., city, town). */
93
+ city: string;
94
+ /* Postal code. */
95
+ postalCode: string;
96
+ /* Country. */
97
+ country: string;
98
+ }
99
+ interface CredentialSubject {
100
+ /* ID(unique credential) Unique identifier for the credential itself. */
101
+ id: string;
102
+ /* Given name of the individual. */
103
+ firstName: string;
104
+ /* Surname of the individual. */
105
+ familyName: string;
106
+ /* Family name at birth (e.g., maiden name). */
107
+ maidenName?: string;
108
+ /* Unique identifier issued by a government authority (e.g., SSN, Tax ID). */
109
+ governmentId?: string;
110
+ /* Type of government identifier (e.g., Social Security Number, Tax ID, etc.). */
111
+ governmentIdType?: string;
112
+ /* Date of birth of the individual. */
113
+ dateOfBirth: Date;
114
+ /* City and state/province of birth. */
115
+ placeOfBirth: string;
116
+ /* Country that issued the identity document. */
117
+ idDocumentCountry: string;
118
+ /* ID Document Number Unique number on the identity document. */
119
+ idDocumentNumber: string;
120
+ /* ID Document Type Type of identity document(e.g., Passport, Driver's License, National ID). */
121
+ idDocumentType: string;
122
+ /* ID Document Date of Issue Date the identity document was issued. */
123
+ idDocumentDateOfIssue: Date;
124
+ /* ID Document Date of Expiry Expiration date of the identity document - if applicable. */
125
+ idDocumentDateOfExpiry?: Date;
126
+ /* ID Document Front File File or URL representing the front of the identity document. */
127
+ idDocumentFrontFile: Buffer;
128
+ /* ID Document Back File File or URL representing the back of the identity document - if applicable. */
129
+ idDocumentBackFile?: Buffer;
130
+ /* (ID Document) Selfie File File or URL of a selfie with the identity document for verification purposes. */
131
+ selfieFile: Buffer;
132
+ /* Residential Address Full residential address of the individual - if applicable. */
133
+ residentialAddress?: CredentialResidentialAddress;
134
+ /* Residential Address Proof Category Type of document provided to verify the address(e.g., utility bill, bank statement). */
135
+ residentialAddressProofCategory?: string;
136
+ /* Residential Address Proof Date Of Issue Date the address proof document was issued. */
137
+ residentialAddressProofDateOfIssue?: Date;
138
+ /* Residential Address Proof File File or URL of the document provided as address proof. */
139
+ residentialAddressProofFile?: Buffer;
140
+ }
141
+ interface CredentialsIssuerConfig {
142
+ /* Issuers id */
143
+ id: string;
144
+ /* Issuer of the credential (URL). */
145
+ controller: string;
146
+ /* Issuer's private key in multibase format. */
147
+ privateKeyMultibase: string;
148
+ /* Issuer's public key in multibase format. */
149
+ publicKeyMultibase: string;
150
+ } //#endregion
151
+ //#region src/services/grant.service.d.ts
152
+ type CreateAccessGrantFromDAGParams = {
153
+ dag_data_id: string;
154
+ dag_owner_wallet_identifier: string;
155
+ dag_grantee_wallet_identifier: string;
156
+ dag_signature: string;
157
+ dag_locked_until: number;
158
+ dag_content_hash: string;
159
+ };
160
+
161
+ //#endregion
162
+ //#region src/services/user.service.d.ts
163
+ type CreateProfileReqParams = Omit<idOSUser, "id"> & {
164
+ id?: string;
165
+ };
166
+ type UpsertWalletReqParams = Omit<idOSWallet, "id"> & {
167
+ id?: string;
168
+ };
169
+ type CreateWalletReqParams = Omit<UpsertWalletReqParams, "user_id"> & {
170
+ id?: string;
171
+ };
172
+
173
+ //#endregion
174
+ //#region src/index.d.ts
175
+ type CreateIssuerParams = {
176
+ chainId?: string;
177
+ nodeUrl: string;
178
+ signingKeyPair: SignKeyPair;
179
+ encryptionSecretKey: Uint8Array;
180
+ };
181
+ declare class idOSIssuer {
182
+ #private;
183
+ static init(params: CreateIssuerParams): Promise<idOSIssuer>;
184
+ private constructor();
185
+ // User Service facade methods
186
+ hasProfile(userAddress: string): Promise<boolean>;
187
+ createUserProfile(params: CreateProfileReqParams): Promise<idOSUser>;
188
+ upsertWalletAsInserter(params: UpsertWalletReqParams): Promise<idOSWallet>;
189
+ createUser(user: CreateProfileReqParams, wallet: CreateWalletReqParams): Promise<[idOSUser, idOSWallet]>;
190
+ createCredentialByDelegatedWriteGrant(credentialParams: DelegatedWriteGrantBaseParams, delegatedWriteGrant: DelegatedWriteGrantParams, consumerEncryptionPublicKey?: Uint8Array): Promise<{
191
+ originalCredential: Omit<idOSCredential, "user_id">;
192
+ copyCredential: Omit<idOSCredential, "user_id">;
193
+ }>;
194
+ editCredentialAsIssuer(publicNotesId: string, publicNotes: string): Promise<EditCredentialAsIssuerParams | null>;
195
+ getCredentialIdByContentHash(contentHash: string): Promise<string | null>;
196
+ getSharedCredential(id: string): Promise<idOSCredential | null>;
197
+ createAccessGrantFromDAG(params: CreateAccessGrantFromDAGParams): Promise<CreateAccessGrantFromDAGParams | null>;
198
+ buildCredentials(fields: CredentialFields, subject: CredentialSubject, issuer: CredentialsIssuerConfig): Promise<any>;
199
+ // biome-ignore lint/suspicious/noExplicitAny: Using `any` to avoid type errors.
200
+ buildDocumentLoader(): any;
201
+ }
202
+
203
+ //#endregion
204
+ export { idOSCredential, idOSGrant, idOSIssuer, idOSUser, idOSUserAttribute, idOSWallet };
205
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["message: Extract<IsleNodeMessage, { type: T }>","kwilClient: KwilActionClient","id: string","content_hash: string","params: GetAccessGrantByCredentialIdParams","params: EditCredentialAsIssuerParams","userId: string","params: CreateCredentialByDelegatedWriteGrantParams","credential: ShareableCredential","params: CreateCredentialCopyParams","kwilClient: KwilActionClient","signingKeyPair: nacl.SignKeyPair","encryptionSecretKey: Uint8Array","credentialParams: DelegatedWriteGrantBaseParams","delegatedWriteGrant: DelegatedWriteGrantParams","consumerEncryptionPublicKey?: Uint8Array","publicNotesId: string","publicNotes: string","contentHash: string","id: string","fields: CredentialFields","subject: CredentialSubject","issuer: CredentialsIssuerConfig","kwilClient: KwilActionClient","encryptionSecretKey: Uint8Array","params: CreateAccessGrantFromDAGParams","getCredentialIdByContentHash: (contentHash: string) => Promise<string | null>","contentHash: string","getSharedCredential: (id: string) => Promise<idOSCredential | null>","id: string","kwilClient: KwilActionClient","userAddress: string","params: CreateProfileReqParams","params: UpsertWalletReqParams","user: CreateProfileReqParams","wallet: CreateWalletReqParams","params: CreateIssuerParams","userAddress: string","params: CreateProfileReqParams","params: UpsertWalletReqParams","user: CreateProfileReqParams","wallet: CreateWalletReqParams","credentialParams: DelegatedWriteGrantBaseParams","delegatedWriteGrant: DelegatedWriteGrantParams","consumerEncryptionPublicKey?: Uint8Array","publicNotesId: string","publicNotes: string","contentHash: string","id: string","params: CreateAccessGrantFromDAGParams","fields: CredentialFields","subject: CredentialSubject","issuer: CredentialsIssuerConfig"],"sources":["../../@core/src/types/index.ts","../../@core/src/kwil-actions/credentials.ts","../src/services/credential.service.ts","../src/services/credentials-builder.service.ts","../src/services/grant.service.ts","../src/services/user.service.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;AAwCY,KAhCA,QAAA,GAgCA;EAOZ,EAAA,EAAY,MAAA;;;KAlCA,cAAA;ECoDZ,EAAA,EAAiB,MAAA;;;;EC9BjB,YAAY,EAAA,MAAA;EAAA,OAAA,EAAA,MAAA;EAAA,oBAIQ,EAAA,MAAA;CAAA;AAMR,KFfA,UAAA,GEeA;;;;ECnCZ,WAAiB,EAAA,MAAA;EAAA,OAAA,EAAA,MAAA;EAAA,UAON,EAAA,MAAA;EAAA,SAGI,EAAA,MAAA;CAAA;AAGI,KHiBP,iBAAA,GGjBO;EAGnB,EAAA,EAAiB,MAAA;EAoBjB,aAAiB,EAAA,MAAA;EAAA,KAAA,EAAA,MAAA;EAAA,OAoBF,CAAA,EAAA,MAAA;CAAA;AAkBY,KHrCf,SAAA,GGqCe;EAAA,EAAA,EAAA,MAGJ;EAAA,gBAGA,EAAA,MAAA;EAAA,4BAGT,EAAA,MAAA;EAAA,OAGS,EAAA,MAAA;EAAA,YAMgB,EAAA,MAAA;EAAA,YAGP,CAAA,EAAA,MAAA;AAAA,CAAA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