-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
526 lines (525 loc) · 19.4 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
/**
* <p>The Freja module will allow you to interact with the Freja eID API. The module is designed to be used in a Node.js environment and will allow you to create authentication and signing requests, as well as manage user information.</p>
*/
declare module "freja" {
const enum FrejaAPIEnvironment {
PRODUCTION,
TEST
}
const enum FrejaRegistrationState {
EXTENDED,
VETTING_CONFIRMED,
PLUS
}
const enum FrejaIdentifierDisplayType {
QR_CODE,
TEXT
}
enum UserInfoType {
INFERRED,
EMAIL,
PHONE,
SSN,
ORGID
}
const enum FrejaRequestType {
AUTH,
SIGN,
ORGID_AUTH,
ORGID_SIGN,
ORGID_MGMT
}
const enum FrejaSignatureType {
SIMPLE,
EXTENDED,
XML_MINAMEDDELANDEN
}
const enum FrejaRegistrationLevel {
BASIC,
EXTENDED,
PLUS
}
const enum FrejaConfirmationMethod {
DEFAULT,
DEFAULT_AND_FACE
}
const enum FrejaUserAddressType {
POSTAL,
RESIDENTIAL
}
const enum FrejaUserAddressSource {
GOVERNMENT_REGISTRY
}
const enum FrejaUserAttributes {
BASIC_USER_INFO,
EMAIL_ADDRESS,
ALL_EMAIL_ADDRESSES,
ALL_PHONE_NUMBERS,
DATE_OF_BIRTH,
AGE,
PHOTO,
ADDRESSES,
SSN,
DOCUMENT,
REGISTRATION_LEVEL,
RELYING_PARTY_USER_ID,
INTEGRATOR_SPECIFIC_USER_ID
}
const enum FrejaUserAttributeCollections {
ALL_EXTENDED,
ALL_BASIC,
COMMON_AUTH,
COMMON_SIGN
}
const enum FrejaRequestStatus {
STARTED,
DELIVERED,
CANCELLED,
REJECTED,
EXPIRED,
RP_CANCELLED,
RP_REJECTED,
APPROVED
}
const enum FrejaDocumentTypes {
PASSPORT,
DRIVER_LICENSE,
NATIONAL_ID,
SIS_ID,
SWEDISH_TAX_ID,
OTHER
}
/**
* @property country - <p>The country code</p>
* @property ssn - <p>The social security number</p>
*/
type ISocialSecurityNumber = {
country: string;
ssn: string;
};
/**
* @property userInfoType - <p>The type of user information</p>
* @property userInfo - <p>The user information</p>
*/
type IUserInfo = {
userInfoType: FrejaUserInfoType;
userInfo: string | ISocialSecurityNumber;
};
/**
* @property userInfoType - <p>Must be "EMAIL"</p>
* @property userInfo - <p>The email address</p>
*/
type IEmailUserInfo = {
userInfoType: FrejaUserInfoType;
userInfo: string;
};
/**
* @property userInfoType - <p>Must be "EMAIL"</p>
* @property userInfo - <p>The social security number</p>
*/
type ISSNUserInfo = {
userInfoType: FrejaUserInfoType;
userInfo: ISocialSecurityNumber;
};
/**
* @property userInfoType - <p>Must be "INFERRRED"</p>
* @property userInfo - <p>Must be "N/A"</p>
*/
type IInferredUserInfo = {
userInfoType: FrejaUserInfoType;
userInfo: string;
};
/**
* @property userInfoType - <p>Must be "PHONE"</p>
* @property userInfo - <p>The email address</p>
*/
type IPhoneUserInfo = {
userInfoType: FrejaUserInfoType;
userInfo: string;
};
/**
* @property userInfoType - <p>Must be "ORGID"</p>
* @property userInfo - <p>The email address</p>
*/
type IOrgIdUserInfo = {
userInfoType: FrejaUserInfoType;
userInfo: string;
};
type IResultMessage = {
isOk: boolean;
};
/**
* @property identifier - <p>Title of the Organisation ID to be displayed to the end user</p>
* @property identifierName - <p>Display name of specific organisation identifier</p>
* @property title - <p>Value of specific organisation identifier</p>
* @property [ssn] - <p>User SSN in international format if exist</p>
* @property country - <p>User country</p>
* @property registrationState - <p>The extended error message</p>
*/
type IFrejaOrgIdUserInfo = {
identifier: string;
identifierName: string;
title: string;
ssn?: string;
country: string;
registrationState: FrejaRegistrationState;
};
/**
* @property users - <p>The organisation information</p>
*/
type IFrejaOrgIdUserList = {
isOk: boolean;
users: IFrejaOrgIdUserInfo[];
};
type ISuccessResultMessage = {
isOk: boolean;
data: any;
};
type IUpdateSuccessMessage = {
isOk: boolean;
added: number;
updated: number;
deleted: number;
};
/**
* @property isOk - <p>Must be false</p>
* @property code - <p>The error code</p>
* @property message - <p>The error message</p>
* @property [extendedMessage] - <p>The extended error message</p>
* @property [trace] - <p>The error trace</p>
*/
type IFailureResult = {
isOk: boolean;
code: number;
message: string;
extendedMessage?: string;
trace?: string;
};
/**
* @property isOk - <p>Must be true</p>
* @property token - <p>The transaction token</p>
* @property qrCodeUrl - <p>The URL to the QR code</p>
* @property autostartUrl - <p>The URL to the autostart</p>
*/
type IInitializationSuccess = {
isOk: boolean;
token: string;
qrCodeUrl: (...params: any[]) => any;
autostartUrl: (...params: any[]) => any;
};
/**
* @property isOk - <p>Must be true</p>
* @property status - <p>The transaction status</p>
* @property isFinal - <p>If the transaction is completed or should be checked again</p>
*/
type IRequestStatusMessage = {
isOk: boolean;
status: FrejaRequestStatus;
isFinal: boolean;
};
/**
* @property isOk - <p>Must be true</p>
* @property status - <p>The transaction status</p>
* @property data - <p>The results of the request</p>
* @property isFinal - <p>Always true</p>
*/
type ICompletedRequestMessage = {
isOk: boolean;
status: FrejaRequestStatus;
data: IFrejaResponse;
isFinal: boolean;
};
/**
* @property EN - <p>The name of the organisation in English</p>
* @property SV - <p>The name of the organisation in Swedish</p>
*/
type IFrejaUserOrganisationName = {
EN: string;
SV: string;
};
/**
* @property type - <p>The address type</p>
* @property validFrom - <p>The date the address is valid from</p>
* @property validTo - <p>The date the address is valid to</p>
* @property address - <p>The first line of the address</p>
* @property postcode - <p>The postal code</p>
* @property city - <p>The city</p>
* @property country - <p>The country</p>
* @property source - <p>The source of the address</p>
*/
type IFrejaUserAddress = {
type: FrejaUserAddressType;
validFrom: string;
validTo: string;
address: string[];
postcode: string;
city: string;
country: string;
source: FrejaUserAddressSource;
};
/**
* @property type - <p>The document type</p>
* @property country - <p>The document country</p>
* @property number - <p>The document number</p>
* @property expiration - <p>The document expiration date</p>
*/
type IFrejaUserDocument = {
type: FrejaDocumentTypes;
country: string;
number: string;
expiration: string;
};
/**
* @property userId - <p>The organisation user ID</p>
* @property issuerId - <p>The organisation issuer ID</p>
* @property issuerCode - <p>The organisation issuer code</p>
* @property issuerName - <p>The organisation issuer name</p>
* @property [attributes] - <p>The organisation attributes</p>
*/
type IFrejaUserOrganisation = {
userId: string;
issuerId: string;
issuerCode: string;
issuerName: IFrejaUserOrganisationName;
attributes?: IFrejaUserOrganisationAttributes[];
};
/**
* @property title - <p>Title of the Organisation ID to be displayed to the end user</p>
* @property identifierName - <p>Display name of specific organisation identifier</p>
* @property identifier - <p>Value of specific organisation identifier</p>
* @property identifierDisplayTypes - <p>Displays for the identifier</p>
* @property [attributes] - <p>The organisation attributes</p>
*/
type IFrejaUserAddOrganisation = {
title: string;
identifierName: string;
identifier: string;
identifierDisplayTypes: FrejaIdentifierDisplayType[];
attributes?: IFrejaUserOrganisationAttributes[];
};
/**
* @property title - <p>The title of the notification</p>
* @property message - <p>The message of the notification</p>
*/
type IFrejaSignNotification = {
title: string;
message: string;
};
/**
* @property key - <p>The attribute key</p>
* @property value - <p>The attribute value</p>
* @property displayText - <p>The attribute display text</p>
*/
type IFrejaUserOrganisationAttributes = {
key: string;
value: string;
displayText: string;
};
/**
* @property [firstname] - <p>The user's first name</p>
* @property [lastname] - <p>The user's last name</p>
* @property [fullname] - <p>The user's full name</p>
* @property [age] - <p>The user's age</p>
* @property [dateOfBirth] - <p>The user's date of birth</p>
* @property [ssn] - <p>The user's social security number</p>
* @property [ssc] - <p>The user's social security country</p>
* @property [photo] - <p>The user's photo</p>
*/
type IFrejaUserDetails = {
firstname?: string;
lastname?: string;
fullname?: string;
age?: number;
dateOfBirth?: string;
ssn?: string;
ssc?: string;
photo?: string;
};
/**
* @property freja.userInfo - <p>The user information object</p>
* @property [freja.relyingPartyUserId] - <p>The relying party user ID</p>
* @property [freja.registrationLevel] - <p>The registration level</p>
* @property [freja.customIdentifier] - <p>The custom identifier</p>
*/
type IFrejaServiceData = {};
/**
* @property [emailAddress] - <p>The user's primary email address</p>
* @property [phoneNumber] - <p>The user's primary (first) phone number</p>
* @property [postalAddress] - <p>The user's current postal address</p>
* @property [residentialAddress] - <p>The user's current residential address</p>
* @property [allEmailAddresses] - <p>The user's other email addresses</p>
* @property [allPhoneNumbers] - <p>The user's other phone numbers</p>
* @property [allAddresses] - <p>The user's addresses</p>
*/
type IFrejaUserContact = {
emailAddress?: string;
phoneNumber?: string;
postalAddress?: IFrejaUserAddress;
residentialAddress?: IFrejaUserAddress;
allEmailAddresses?: string[];
allPhoneNumbers?: string[];
allAddresses?: IFrejaUserAddress[];
};
/**
* @property info - <p>The user information object</p>
* @property freja - <p>The Freja object</p>
* @property [document] - <p>The document object</p>
* @property [organisation] - <p>The organisation object</p>
* @property contact - <p>The contacts object</p>
* @property [signature] - <p>The signature data</p>
*/
type IFrejaResponse = {
info: IFrejaUserInfo;
freja: IFrejaServiceData;
document?: IFrejaUserDocument;
organisation?: IFrejaUserOrganisation;
contact: IFrejaUserContact;
signature?: IFrejaSignatureData;
};
/**
* @property type - <p>The signature type</p>
* @property timestamp - <p>The date of the signature</p>
* @property payload - <p>The signed data</p>
* @property transactionId - <p>The id of the signing transaction from Freja</p>
* @property ocspResponse - <p>The OCSP response at time of signing</p>
* @property signature - <p>The signature</p>
* @property kid - <p>The signature key ID</p>
* @property alg - <p>The signature algorithm</p>
* @property [advanced] - <p>The advanced signature</p>
*/
type IFrejaSignatureData = {
type: FrejaSignatureType;
timestamp: Date;
payload: string;
transactionId: string;
ocspResponse: Buffer;
signature: string;
kid: string;
alg: string;
advanced?: any;
};
/**
* <p>The main Freja API class.</p>
* @property UserAttributes - <p>The user attributes to return.</p>
* @property RegistrationLevel - <p>The minimum requested level.</p>
* @property APIEnvironment - <p>The API mode.</p>
* @property RelyingPartyId - <p>The relying party ID (used by integrators only).</p>
* @param apiEnvironment - <p>The API mode.</p>
* @param authPfx - <p>The path to the PFX file.</p>
* @param authPwd - <p>The password for the PFX file.</p>
* @param [trustedJWTCertificates] - <p>The JWT token files ({'x5t': 'file'}).</p>
* @param [trustedCACertificates] - <p>The path to the CA certificate file(s).</p>
*/
class FrejaAPI {
constructor(apiEnvironment: FrejaAPIEnvironment, authPfx: string, authPwd: string, trustedJWTCertificates?: any, trustedCACertificates?: undefined | string | string[]);
/**
* <p>Create a user info object.</p>
* @param userData - <p>The user data to create the object from (email, phone, ssn, orgid etc.)</p>
* @returns <p>The user info object.</p>
*/
public UserInfoFactory(userData: any | string): IUserInfo;
/**
* <p>Initialize an authentication request (shorthand method).</p>
* @param [userInfo] - <p>The user to create the authentication request for.</p>
* @param [orgId = false] - <p>If the request is for an organisation id</p>
*/
public AuthRequest(userInfo?: undefined | string | any | IUserInfo, orgId?: boolean): Promise<IFailureResult | IInitializationSuccess>;
/**
* <p>Initialize an signing request (shorthand method).</p>
* @param userInfo - <p>The user to create the signing request for.</p>
* @param title - <p>The title of the request (used for notification).</p>
* @param text - <p>The text to sign.</p>
* @param [orgId = false] - <p>If the request is for an organisation id</p>
*/
public SignRequest(userInfo: string | any | IUserInfo, title: string, text: string, orgId?: boolean): Promise<IFailureResult | IInitializationSuccess>;
/**
* <p>Initialize an signing request (shorthand method).</p>
* @param userInfo - <p>The user to create the signing request for.</p>
* @param title - <p>The title of the request (used for notification).</p>
* @param text - <p>The text to sign.</p>
* @param data - <p>The binary data to sign.</p>
* @param [orgId = false] - <p>If the request is for an organisation id</p>
*/
public SignBufferRequest(userInfo: string | any | IUserInfo, title: string, text: string, data: Buffer, orgId?: boolean): Promise<IFailureResult | IInitializationSuccess>;
/**
* <p>Initialize an organisation id request (shorthand method).</p>
* @param userInfo - <p>The user to create the organisation id for</p>
* @param title - <p>The title of the request (used for notification).</p>
* @param identifier - <p>The identifier name</p>
* @param value - <p>The identifier value</p>
* @param [displayTypes = [FrejaIdentifierDisplayType.QR_CODE, FrejaIdentifierDisplayType.TEXT]] - <p>The display types</p>
*/
public AddOrgIdRequest(userInfo: string | any | IUserInfo, title: string, identifier: string, value: string, displayTypes?: FrejaIdentifierDisplayType[]): void;
/**
* <p>Gets a full list of issued organisation ids</p>
*/
public GetOrgIdUserList(): Promise<IFailureResult | IFrejaOrgIdUserList>;
/**
* <p>Updates a issued organisation id with additional attributes</p>
* @param identifier - <p>The custom identifier to delete</p>
* @param additionalAttributes - <p>Additional attributes to update</p>
*/
public UpdateOrgId(identifier: string, additionalAttributes: IFrejaUserOrganisationAttributes[]): Promise<IFailureResult | IUpdateSuccessMessage>;
/**
* <p>Deletes a issued organisation id</p>
* @param identifier - <p>The custom identifier to delete</p>
*/
public RevokeOrgId(identifier: string): Promise<IFailureResult | ISuccessResultMessage>;
/**
* <p>Initialize an authentication or signature request.</p>
* @param requestType - <p>The type of request.</p>
* @param userInfo - <p>The user information used to initialize, leave empty for inferred.</p>
* @param additionalParams - <p>Additional parameters for the request.</p>
*/
public InitRequest(requestType: FrejaRequestType, userInfo: string | undefined | any, ...additionalParams: any[]): Promise<IFailureResult | IInitializationSuccess>;
/**
* <p>Retrieve the status of a request.</p>
* @param token - <p>The token of the request.</p>
*/
public CancelRequest(token: string): Promise<IFailureResult | ICompletedRequestMessage>;
/**
* <p>Retrieve the status of a request.</p>
* @param swedishSSN - <p>The social security number to check</p>
*/
public CheckCustodianship(swedishSSN: string): Promise<IFailureResult | ISuccessResultMessage>;
/**
* <p>Retrieve the status of a request.</p>
* @param customIdentifier - <p>The custom identifier to append</p>
* @param userInfo - <p>The user to which to append the custom identifier</p>
*/
public NewCustomIdentifier(customIdentifier: string, userInfo: IUserInfo): Promise<IFailureResult | ISuccessResultMessage>;
/**
* <p>Retrieve the status of a request.</p>
* @param customIdentifier - <p>The custom identifier to append</p>
*/
public DeleteCustomIdentifier(customIdentifier: string): Promise<IFailureResult | ISuccessResultMessage>;
/**
* <p>Retrieve the status of a request.</p>
* @param token - <p>The token of the request.</p>
*/
public InquireRequest(token: string): Promise<IFailureResult | IRequestStatusMessage | ICompletedRequestMessage>;
/**
* <p>Translate a code into a message</p>
* @param errorCode - <p>The error code</p>
* @returns <p>The error message</p>
*/
public static GetError(errorCode: number): string;
/**
* <p>The user attributes to return.</p>
*/
UserAttributes: FrejaUserAttributes[];
/**
* <p>The minimum requested level.</p>
*/
RegistrationLevel: FrejaRegistrationLevel;
ConfirmationMethod: FrejaConfirmationMethod;
/**
* <p>The API mode.</p>
*/
APIEnvironment: APIEnvironment;
/**
* <p>The relying party ID (used by integrators only).</p>
*/
RelyingPartyId: string;
}
}