core-3nweb-client-lib 0.40.0 → 0.41.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/api-defs/mailerid.d.ts +51 -1
- package/build/core/asmail/key-verification.d.ts +5 -0
- package/build/core/asmail/key-verification.js +6 -4
- package/build/core/id-manager/index.d.ts +2 -2
- package/build/core/id-manager/index.js +30 -0
- package/build/core/id-manager/mailerid-cap-ipc.js +6 -2
- package/build/core/index.js +8 -3
- package/build/core-ipc/json-ipc-wrapping/json-n-binary.js +1 -1
- package/build/lib-client/asmail/sender.d.ts +2 -2
- package/build/lib-client/asmail/sender.js +1 -1
- package/build/lib-client/mailer-id/login.d.ts +2 -2
- package/build/lib-client/mailer-id/login.js +1 -1
- package/build/lib-client/mailer-id/provisioner.d.ts +2 -2
- package/build/lib-client/mailer-id/provisioner.js +6 -6
- package/build/lib-client/user-with-mid-session.d.ts +3 -3
- package/build/lib-client/user-with-mid-session.js +1 -1
- package/build/lib-common/mailerid-sigs/id-provider.d.ts +64 -0
- package/build/lib-common/mailerid-sigs/id-provider.js +174 -0
- package/build/lib-common/mailerid-sigs/index.d.ts +44 -0
- package/build/lib-common/mailerid-sigs/index.js +50 -0
- package/build/lib-common/mailerid-sigs/relying-party.d.ts +59 -0
- package/build/lib-common/mailerid-sigs/relying-party.js +237 -0
- package/build/lib-common/mailerid-sigs/user.d.ts +60 -0
- package/build/lib-common/mailerid-sigs/user.js +149 -0
- package/build/lib-common/mailerid-sigs/utils-NaCl-Ed.d.ts +8 -0
- package/build/lib-common/mailerid-sigs/utils-NaCl-Ed.js +61 -0
- package/build/raw-3nweb-clients.d.ts +2 -2
- package/build/raw-3nweb-clients.js +1 -1
- package/package.json +1 -1
- package/build/lib-common/mid-sigs-NaCl-Ed.d.ts +0 -220
- package/build/lib-common/mid-sigs-NaCl-Ed.js +0 -560
|
@@ -4,8 +4,8 @@ import { MailSender as MailSenderClient } from './lib-client/asmail/sender';
|
|
|
4
4
|
import { MailerIdProvisioner as MailerIdProvisionerClient } from './lib-client/mailer-id/provisioner';
|
|
5
5
|
import * as signupClientFuncs from './lib-client/3nweb-signup';
|
|
6
6
|
import * as signupApi from './lib-common/user-admin-api/signup';
|
|
7
|
-
import { user as midUser } from './lib-common/mid-sigs-NaCl-Ed';
|
|
8
7
|
import * as srvLocFuncs from './lib-client/service-locator';
|
|
8
|
+
import { type MailerIdSigner as MidSigner } from './lib-common/mailerid-sigs/user';
|
|
9
9
|
export type StorageOwner = StorageOwnerClient;
|
|
10
10
|
export declare const StorageOwner: typeof StorageOwnerClient;
|
|
11
11
|
export type MailRecipient = MailRecipientClient;
|
|
@@ -17,6 +17,6 @@ export type MailerIdProvisioner = MailerIdProvisionerClient;
|
|
|
17
17
|
export declare const MailerIdProvisioner: typeof MailerIdProvisionerClient;
|
|
18
18
|
export type UserMidParams = signupApi.UserMidParams;
|
|
19
19
|
export type UserStorageParams = signupApi.UserStorageParams;
|
|
20
|
-
export type MailerIdSigner =
|
|
20
|
+
export type MailerIdSigner = MidSigner;
|
|
21
21
|
export declare const serviceLocationFuncs: typeof srvLocFuncs;
|
|
22
22
|
export declare function getLibVersion(): string;
|
package/package.json
CHANGED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This library handles signing and verification of signatures, used
|
|
3
|
-
* in MailerId.
|
|
4
|
-
*/
|
|
5
|
-
import { GetRandom, arrays } from "ecma-nacl";
|
|
6
|
-
type JsonKey = web3n.keys.JsonKey;
|
|
7
|
-
type Key = web3n.keys.Key;
|
|
8
|
-
type SignedLoad = web3n.keys.SignedLoad;
|
|
9
|
-
/**
|
|
10
|
-
* This enumerates MailerId's different use-roles of keys, involved in
|
|
11
|
-
* establishing a trust.
|
|
12
|
-
*/
|
|
13
|
-
export declare const KEY_USE: {
|
|
14
|
-
/**
|
|
15
|
-
* This is a MailerId trust root.
|
|
16
|
-
* It signs certificate for itself, and it signs certificates for provider
|
|
17
|
-
* keys, which have shorter life span, than the root.
|
|
18
|
-
* Root may revoke itself, and may revoke provider key.
|
|
19
|
-
*/
|
|
20
|
-
ROOT: string;
|
|
21
|
-
/**
|
|
22
|
-
* This is a provider key, which is used to certify users' signing keys.
|
|
23
|
-
*/
|
|
24
|
-
PROVIDER: string;
|
|
25
|
-
/**
|
|
26
|
-
* With this key, MailerId user signs assertions and mail keys.
|
|
27
|
-
*/
|
|
28
|
-
SIGN: string;
|
|
29
|
-
};
|
|
30
|
-
export declare const exceptionType = "mailerid";
|
|
31
|
-
export interface MidException extends web3n.RuntimeException {
|
|
32
|
-
type: 'mailerid';
|
|
33
|
-
msg: string;
|
|
34
|
-
algMismatch?: true;
|
|
35
|
-
timeMismatch?: true;
|
|
36
|
-
certsMismatch?: true;
|
|
37
|
-
certMalformed?: true;
|
|
38
|
-
sigVerificationFails?: true;
|
|
39
|
-
}
|
|
40
|
-
export declare function makeMalformedCertsException(msg: string, cause?: any): MidException;
|
|
41
|
-
export interface Keypair {
|
|
42
|
-
pkey: JsonKey;
|
|
43
|
-
skey: Key;
|
|
44
|
-
}
|
|
45
|
-
export declare namespace idProvider {
|
|
46
|
-
const KID_BYTES_LENGTH = 9;
|
|
47
|
-
const MAX_USER_CERT_VALIDITY: number;
|
|
48
|
-
function makeSelfSignedCert(address: string, validityPeriod: number, sjkey: JsonKey, arrFactory?: arrays.Factory): SignedLoad;
|
|
49
|
-
/**
|
|
50
|
-
* One should keep MailerId root key offline, as this key is used only to
|
|
51
|
-
* sign provider keys, which have to work online.
|
|
52
|
-
* @param address is an address of an issuer
|
|
53
|
-
* @param validityPeriod validity period of a generated self-signed
|
|
54
|
-
* certificate in milliseconds
|
|
55
|
-
* @param random
|
|
56
|
-
* @param arrFactory optional array factory
|
|
57
|
-
* @return Generated root key and a self-signed certificate for respective
|
|
58
|
-
* public key.
|
|
59
|
-
*/
|
|
60
|
-
function generateRootKey(address: string, validityPeriod: number, random: GetRandom, arrFactory?: arrays.Factory): {
|
|
61
|
-
cert: SignedLoad;
|
|
62
|
-
skey: JsonKey;
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* @param address is an address of an issuer
|
|
66
|
-
* @param validityPeriod validity period of a generated self-signed
|
|
67
|
-
* certificate in seconds
|
|
68
|
-
* @param rootJKey root key in json format
|
|
69
|
-
* @param random
|
|
70
|
-
* @param arrFactory optional array factory
|
|
71
|
-
* @return Generated provider's key and a certificate for a respective
|
|
72
|
-
* public key.
|
|
73
|
-
*/
|
|
74
|
-
function generateProviderKey(address: string, validityPeriod: number, rootJKey: JsonKey, random: GetRandom, arrFactory?: arrays.Factory): {
|
|
75
|
-
cert: SignedLoad;
|
|
76
|
-
skey: JsonKey;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* MailerId providing service should use this object to generate certificates.
|
|
80
|
-
*/
|
|
81
|
-
interface IdProviderCertifier {
|
|
82
|
-
/**
|
|
83
|
-
* @param publicKey
|
|
84
|
-
* @param address
|
|
85
|
-
* @param validFor (optional)
|
|
86
|
-
* @return certificate for a given key
|
|
87
|
-
*/
|
|
88
|
-
certify(publicKey: JsonKey, address: string, validFor?: number): SignedLoad;
|
|
89
|
-
/**
|
|
90
|
-
* This securely erases internal key.
|
|
91
|
-
* Call this function, when certifier is no longer needed.
|
|
92
|
-
*/
|
|
93
|
-
destroy(): void;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @param issuer is a domain of certificate issuer, at which issuer's public
|
|
97
|
-
* key can be found to check the signature
|
|
98
|
-
* @param validityPeriod is a default validity period in seconds, for
|
|
99
|
-
* which certifier shall be making certificates
|
|
100
|
-
* @param signJKey is a certificates signing key
|
|
101
|
-
* @param arrFactory is an optional array factory
|
|
102
|
-
* @return MailerId certificates generator, which shall be used on identity
|
|
103
|
-
* provider's side
|
|
104
|
-
*/
|
|
105
|
-
function makeIdProviderCertifier(issuer: string, validityPeriod: number, signJKey: JsonKey, arrFactory?: arrays.Factory): IdProviderCertifier;
|
|
106
|
-
}
|
|
107
|
-
export interface AssertionLoad {
|
|
108
|
-
user: string;
|
|
109
|
-
rpDomain: string;
|
|
110
|
-
sessionId: string;
|
|
111
|
-
issuedAt: number;
|
|
112
|
-
expiresAt: number;
|
|
113
|
-
}
|
|
114
|
-
export interface CertsChain {
|
|
115
|
-
user: SignedLoad;
|
|
116
|
-
prov: SignedLoad;
|
|
117
|
-
root: SignedLoad;
|
|
118
|
-
}
|
|
119
|
-
export declare namespace relyingParty {
|
|
120
|
-
/**
|
|
121
|
-
* @param certs is a chain of certificate to be verified.
|
|
122
|
-
* @param rootAddr is MailerId service's domain.
|
|
123
|
-
* @param validAt is an epoch time moment (in second), at which user
|
|
124
|
-
* certificate must be valid. Provider certificate must be valid at
|
|
125
|
-
* creation of user's certificate. Root certificate must be valid at
|
|
126
|
-
* creation of provider's certificate.
|
|
127
|
-
* @return user's MailerId signing key with user's address.
|
|
128
|
-
*/
|
|
129
|
-
function verifyChainAndGetUserKey(certs: CertsChain, rootAddr: string, validAt: number, arrFactory?: arrays.Factory): {
|
|
130
|
-
pkey: Key;
|
|
131
|
-
address: string;
|
|
132
|
-
};
|
|
133
|
-
interface AssertionInfo {
|
|
134
|
-
relyingPartyDomain: string;
|
|
135
|
-
sessionId: string;
|
|
136
|
-
user: string;
|
|
137
|
-
}
|
|
138
|
-
function verifyAssertion(midAssertion: SignedLoad, certChain: CertsChain, rootAddr: string, validAt: number, arrFactory?: arrays.Factory): AssertionInfo;
|
|
139
|
-
/**
|
|
140
|
-
* This function does verification of a single certificate with known
|
|
141
|
-
* signing key.
|
|
142
|
-
* If your task requires verification starting with principal's MailerId,
|
|
143
|
-
* use verifyPubKey function that also accepts and checks MailerId
|
|
144
|
-
* certificates chain.
|
|
145
|
-
* @param keyCert is a certificate that should be checked
|
|
146
|
-
* @param principalAddress is an expected principal's address in a given
|
|
147
|
-
* certificate. Exception is thrown, if certificate does not match this
|
|
148
|
-
* expectation.
|
|
149
|
-
* @param signingKey is a public key, with which given certificate is
|
|
150
|
-
* validated cryptographically. Exception is thrown, if crypto-verification
|
|
151
|
-
* fails.
|
|
152
|
-
* @param validAt is an epoch time moment (in second), for which verification
|
|
153
|
-
* should be done.
|
|
154
|
-
* @param arrFactory is an optional array factory.
|
|
155
|
-
* @return a key from a given certificate.
|
|
156
|
-
*/
|
|
157
|
-
function verifyKeyCert(keyCert: SignedLoad, principalAddress: string, signingKey: Key, validAt: number, arrFactory?: arrays.Factory): JsonKey;
|
|
158
|
-
/**
|
|
159
|
-
* @param pubKeyCert certificate with a public key, that needs to be
|
|
160
|
-
* verified.
|
|
161
|
-
* @param principalAddress is an expected principal's address in both key
|
|
162
|
-
* certificate, and in MailerId certificate chain. Exception is thrown,
|
|
163
|
-
* if certificate does not match this expectation.
|
|
164
|
-
* @param certChain is MailerId certificate chain for named principal.
|
|
165
|
-
* @param rootAddr is MailerId root's domain.
|
|
166
|
-
* @param validAt is an epoch time moment (in second), for which key
|
|
167
|
-
* certificate verification should be done.
|
|
168
|
-
* @param arrFactory is an optional array factory.
|
|
169
|
-
* @return a key from a given certificate.
|
|
170
|
-
*/
|
|
171
|
-
function verifyPubKey(pubKeyCert: SignedLoad, principalAddress: string, certChain: CertsChain, rootAddr: string, validAt: number, arrFactory?: arrays.Factory): JsonKey;
|
|
172
|
-
}
|
|
173
|
-
export declare namespace user {
|
|
174
|
-
/**
|
|
175
|
-
* This is used by user of MailerId to create assertion that prove user's
|
|
176
|
-
* identity.
|
|
177
|
-
*/
|
|
178
|
-
interface MailerIdSigner {
|
|
179
|
-
address: string;
|
|
180
|
-
userCert: SignedLoad;
|
|
181
|
-
providerCert: SignedLoad;
|
|
182
|
-
issuer: string;
|
|
183
|
-
certExpiresAt: number;
|
|
184
|
-
validityPeriod: number;
|
|
185
|
-
/**
|
|
186
|
-
* @param rpDomain relying party domain. If there is an explicit port,
|
|
187
|
-
* this should domain:port, which is a hostname part of url parsing.
|
|
188
|
-
* @param sessionId
|
|
189
|
-
* @param validFor (optional)
|
|
190
|
-
* @return signed assertion with a given sessionId string.
|
|
191
|
-
*/
|
|
192
|
-
generateAssertionFor(rpDomain: string, sessionId: string, validFor?: number): SignedLoad;
|
|
193
|
-
/**
|
|
194
|
-
* @param pkey
|
|
195
|
-
* @param validFor
|
|
196
|
-
* @return signed certificate with a given public key.
|
|
197
|
-
*/
|
|
198
|
-
certifyPublicKey(pkey: JsonKey, validFor: number): SignedLoad;
|
|
199
|
-
/**
|
|
200
|
-
* Makes this AssertionSigner not usable by wiping its secret key.
|
|
201
|
-
*/
|
|
202
|
-
destroy(): void;
|
|
203
|
-
}
|
|
204
|
-
const KID_BYTES_LENGTH = 9;
|
|
205
|
-
const MAX_SIG_VALIDITY: number;
|
|
206
|
-
function generateSigningKeyPair(random: GetRandom, arrFactory?: arrays.Factory): Keypair;
|
|
207
|
-
/**
|
|
208
|
-
* @param signKey which will be used to sign assertions/keys. Note that
|
|
209
|
-
* this key shall be wiped, when signer is destroyed, as key is neither
|
|
210
|
-
* long-living, nor should be shared.
|
|
211
|
-
* @param cert is user's certificate, signed by identity provider.
|
|
212
|
-
* @param provCert is provider's certificate, signed by respective mid root.
|
|
213
|
-
* @param assertionValidity is an assertion validity period in seconds
|
|
214
|
-
* @param arrFactory is an optional array factory
|
|
215
|
-
* @return signer for user of MailerId to generate assertions, and to sign
|
|
216
|
-
* keys.
|
|
217
|
-
*/
|
|
218
|
-
function makeMailerIdSigner(signKey: Key, userCert: SignedLoad, provCert: SignedLoad, assertionValidity?: number, arrFactory?: arrays.Factory): MailerIdSigner;
|
|
219
|
-
}
|
|
220
|
-
export {};
|