@inkbox/sdk 0.1.4 → 0.2.1
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 +31 -35
- package/dist/_http.d.ts +7 -1
- package/dist/_http.d.ts.map +1 -1
- package/dist/_http.js +13 -1
- package/dist/_http.js.map +1 -1
- package/dist/agent_identity.d.ts +89 -71
- package/dist/agent_identity.d.ts.map +1 -1
- package/dist/agent_identity.js +145 -113
- package/dist/agent_identity.js.map +1 -1
- package/dist/credentials.d.ts +97 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +147 -0
- package/dist/credentials.js.map +1 -0
- package/dist/identities/resources/identities.d.ts +1 -16
- package/dist/identities/resources/identities.d.ts.map +1 -1
- package/dist/identities/resources/identities.js +1 -19
- package/dist/identities/resources/identities.js.map +1 -1
- package/dist/identities/types.d.ts +0 -21
- package/dist/identities/types.d.ts.map +1 -1
- package/dist/identities/types.js +0 -11
- package/dist/identities/types.js.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/inkbox.d.ts +42 -6
- package/dist/inkbox.d.ts.map +1 -1
- package/dist/inkbox.js +59 -10
- package/dist/inkbox.js.map +1 -1
- package/dist/mail/resources/messages.d.ts +2 -2
- package/dist/mail/resources/messages.d.ts.map +1 -1
- package/dist/mail/resources/messages.js.map +1 -1
- package/dist/mail/types.d.ts +8 -1
- package/dist/mail/types.d.ts.map +1 -1
- package/dist/mail/types.js +8 -0
- package/dist/mail/types.js.map +1 -1
- package/dist/vault/crypto.d.ts +138 -0
- package/dist/vault/crypto.d.ts.map +1 -0
- package/dist/vault/crypto.js +273 -0
- package/dist/vault/crypto.js.map +1 -0
- package/dist/vault/resources/vault.d.ts +183 -0
- package/dist/vault/resources/vault.d.ts.map +1 -0
- package/dist/vault/resources/vault.js +396 -0
- package/dist/vault/resources/vault.js.map +1 -0
- package/dist/vault/totp.d.ts +73 -0
- package/dist/vault/totp.d.ts.map +1 -0
- package/dist/vault/totp.js +230 -0
- package/dist/vault/totp.js.map +1 -0
- package/dist/vault/types.d.ts +239 -0
- package/dist/vault/types.d.ts.map +1 -0
- package/dist/vault/types.js +229 -0
- package/dist/vault/types.js.map +1 -0
- package/package.json +5 -1
- package/dist/authenticator/resources/accounts.d.ts +0 -70
- package/dist/authenticator/resources/accounts.d.ts.map +0 -1
- package/dist/authenticator/resources/accounts.js +0 -91
- package/dist/authenticator/resources/accounts.js.map +0 -1
- package/dist/authenticator/resources/apps.d.ts +0 -38
- package/dist/authenticator/resources/apps.d.ts.map +0 -1
- package/dist/authenticator/resources/apps.js +0 -52
- package/dist/authenticator/resources/apps.js.map +0 -1
- package/dist/authenticator/types.d.ts +0 -83
- package/dist/authenticator/types.d.ts.map +0 -1
- package/dist/authenticator/types.js +0 -43
- package/dist/authenticator/types.js.map +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-vault TypeScript SDK — public types.
|
|
3
|
+
*
|
|
4
|
+
* Includes API response types, raw JSON shapes, parsers,
|
|
5
|
+
* and client-side structured secret payloads.
|
|
6
|
+
*/
|
|
7
|
+
import { serializeTotpConfig, parseTotpConfig } from "./totp.js";
|
|
8
|
+
// ---- Enums ----
|
|
9
|
+
/**
|
|
10
|
+
* Category of credential stored in a vault secret.
|
|
11
|
+
*
|
|
12
|
+
* Used as a client-side hint for which form to render. The server
|
|
13
|
+
* does not validate or enforce payload structure (it's opaque ciphertext).
|
|
14
|
+
*/
|
|
15
|
+
export const VaultSecretType = {
|
|
16
|
+
API_KEY: "api_key",
|
|
17
|
+
KEY_PAIR: "key_pair",
|
|
18
|
+
LOGIN: "login",
|
|
19
|
+
SSH_KEY: "ssh_key",
|
|
20
|
+
OTHER: "other",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Discriminator for vault key records.
|
|
24
|
+
*
|
|
25
|
+
* - `PRIMARY` — a standard vault key issued to users or agents.
|
|
26
|
+
* - `RECOVERY` — a recovery code generated at vault initialization.
|
|
27
|
+
*/
|
|
28
|
+
export const VaultKeyType = {
|
|
29
|
+
PRIMARY: "primary",
|
|
30
|
+
RECOVERY: "recovery",
|
|
31
|
+
};
|
|
32
|
+
/** @internal */
|
|
33
|
+
export function parseAccessRule(r) {
|
|
34
|
+
return {
|
|
35
|
+
id: r.id,
|
|
36
|
+
vaultSecretId: r.vault_secret_id,
|
|
37
|
+
identityId: r.identity_id,
|
|
38
|
+
createdAt: new Date(r.created_at),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// ---- Parsers ----
|
|
42
|
+
/** Parse a raw vault info response into a {@link VaultInfo}. @internal */
|
|
43
|
+
export function parseVaultInfo(r) {
|
|
44
|
+
return {
|
|
45
|
+
id: r.id,
|
|
46
|
+
organizationId: r.organization_id,
|
|
47
|
+
status: r.status,
|
|
48
|
+
createdAt: new Date(r.created_at),
|
|
49
|
+
updatedAt: new Date(r.updated_at),
|
|
50
|
+
keyCount: r.key_count,
|
|
51
|
+
secretCount: r.secret_count,
|
|
52
|
+
recoveryKeyCount: r.recovery_key_count,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Parse a raw vault key response into a {@link VaultKey}. @internal */
|
|
56
|
+
export function parseVaultKey(r) {
|
|
57
|
+
return {
|
|
58
|
+
id: r.id,
|
|
59
|
+
keyType: r.key_type,
|
|
60
|
+
createdBy: r.created_by,
|
|
61
|
+
status: r.status,
|
|
62
|
+
createdAt: new Date(r.created_at),
|
|
63
|
+
updatedAt: new Date(r.updated_at),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Parse a raw vault secret response into a {@link VaultSecret}. @internal */
|
|
67
|
+
export function parseVaultSecret(r) {
|
|
68
|
+
return {
|
|
69
|
+
id: r.id,
|
|
70
|
+
name: r.name,
|
|
71
|
+
description: r.description,
|
|
72
|
+
secretType: r.secret_type,
|
|
73
|
+
status: r.status,
|
|
74
|
+
createdAt: new Date(r.created_at),
|
|
75
|
+
updatedAt: new Date(r.updated_at),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Parse a raw vault secret detail response into a {@link VaultSecretDetail}. @internal */
|
|
79
|
+
export function parseVaultSecretDetail(r) {
|
|
80
|
+
return {
|
|
81
|
+
...parseVaultSecret(r),
|
|
82
|
+
encryptedPayload: r.encrypted_payload,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// ---- Payload serialization (camelCase ↔ snake_case for JSON encryption) ----
|
|
86
|
+
/**
|
|
87
|
+
* Serialize a payload into a plain object for encryption.
|
|
88
|
+
*
|
|
89
|
+
* Converts camelCase payload fields to the snake_case wire format
|
|
90
|
+
* stored inside the encrypted blob.
|
|
91
|
+
*
|
|
92
|
+
* @param secretType - The secret type string.
|
|
93
|
+
* @param payload - The structured payload to serialize.
|
|
94
|
+
* @returns A plain object ready for JSON stringification.
|
|
95
|
+
* @throws If `secretType` is unknown.
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
export function serializePayload(secretType, payload) {
|
|
99
|
+
switch (secretType) {
|
|
100
|
+
case "login": {
|
|
101
|
+
const p = payload;
|
|
102
|
+
const d = { password: p.password };
|
|
103
|
+
if (p.username !== undefined)
|
|
104
|
+
d.username = p.username;
|
|
105
|
+
if (p.email !== undefined)
|
|
106
|
+
d.email = p.email;
|
|
107
|
+
if (p.url !== undefined)
|
|
108
|
+
d.url = p.url;
|
|
109
|
+
if (p.notes !== undefined)
|
|
110
|
+
d.notes = p.notes;
|
|
111
|
+
if (p.totp !== undefined)
|
|
112
|
+
d.totp = serializeTotpConfig(p.totp);
|
|
113
|
+
return d;
|
|
114
|
+
}
|
|
115
|
+
case "other": {
|
|
116
|
+
const p = payload;
|
|
117
|
+
const d = { data: p.data };
|
|
118
|
+
if (p.notes !== undefined)
|
|
119
|
+
d.notes = p.notes;
|
|
120
|
+
return d;
|
|
121
|
+
}
|
|
122
|
+
case "ssh_key": {
|
|
123
|
+
const p = payload;
|
|
124
|
+
const d = { private_key: p.privateKey };
|
|
125
|
+
if (p.publicKey !== undefined)
|
|
126
|
+
d.public_key = p.publicKey;
|
|
127
|
+
if (p.fingerprint !== undefined)
|
|
128
|
+
d.fingerprint = p.fingerprint;
|
|
129
|
+
if (p.passphrase !== undefined)
|
|
130
|
+
d.passphrase = p.passphrase;
|
|
131
|
+
if (p.notes !== undefined)
|
|
132
|
+
d.notes = p.notes;
|
|
133
|
+
return d;
|
|
134
|
+
}
|
|
135
|
+
case "api_key": {
|
|
136
|
+
const p = payload;
|
|
137
|
+
const d = { api_key: p.apiKey };
|
|
138
|
+
if (p.endpoint !== undefined)
|
|
139
|
+
d.endpoint = p.endpoint;
|
|
140
|
+
if (p.notes !== undefined)
|
|
141
|
+
d.notes = p.notes;
|
|
142
|
+
return d;
|
|
143
|
+
}
|
|
144
|
+
case "key_pair": {
|
|
145
|
+
const p = payload;
|
|
146
|
+
const d = {
|
|
147
|
+
access_key: p.accessKey,
|
|
148
|
+
secret_key: p.secretKey,
|
|
149
|
+
};
|
|
150
|
+
if (p.endpoint !== undefined)
|
|
151
|
+
d.endpoint = p.endpoint;
|
|
152
|
+
if (p.notes !== undefined)
|
|
153
|
+
d.notes = p.notes;
|
|
154
|
+
return d;
|
|
155
|
+
}
|
|
156
|
+
default:
|
|
157
|
+
throw new Error(`Unknown secret_type: ${secretType}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Parse a decrypted plain object into the correct payload type.
|
|
162
|
+
*
|
|
163
|
+
* Converts snake_case wire-format fields back to camelCase.
|
|
164
|
+
*
|
|
165
|
+
* @param secretType - The secret type string.
|
|
166
|
+
* @param raw - The decrypted plain object.
|
|
167
|
+
* @returns The typed payload.
|
|
168
|
+
* @throws If `secretType` is unknown.
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
export function parsePayload(secretType, raw) {
|
|
172
|
+
switch (secretType) {
|
|
173
|
+
case "login":
|
|
174
|
+
return {
|
|
175
|
+
password: raw.password,
|
|
176
|
+
username: raw.username,
|
|
177
|
+
email: raw.email,
|
|
178
|
+
url: raw.url,
|
|
179
|
+
notes: raw.notes,
|
|
180
|
+
totp: raw.totp ? parseTotpConfig(raw.totp) : undefined,
|
|
181
|
+
};
|
|
182
|
+
case "other":
|
|
183
|
+
return { data: raw.data, notes: raw.notes };
|
|
184
|
+
case "ssh_key":
|
|
185
|
+
return {
|
|
186
|
+
privateKey: raw.private_key,
|
|
187
|
+
publicKey: raw.public_key,
|
|
188
|
+
fingerprint: raw.fingerprint,
|
|
189
|
+
passphrase: raw.passphrase,
|
|
190
|
+
notes: raw.notes,
|
|
191
|
+
};
|
|
192
|
+
case "api_key":
|
|
193
|
+
return {
|
|
194
|
+
apiKey: raw.api_key,
|
|
195
|
+
endpoint: raw.endpoint,
|
|
196
|
+
notes: raw.notes,
|
|
197
|
+
};
|
|
198
|
+
case "key_pair":
|
|
199
|
+
return {
|
|
200
|
+
accessKey: raw.access_key,
|
|
201
|
+
secretKey: raw.secret_key,
|
|
202
|
+
endpoint: raw.endpoint,
|
|
203
|
+
notes: raw.notes,
|
|
204
|
+
};
|
|
205
|
+
default:
|
|
206
|
+
throw new Error(`Unknown secret_type: ${secretType}`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Infer the `secretType` string from a payload's shape.
|
|
211
|
+
*
|
|
212
|
+
* @param payload - A secret payload object.
|
|
213
|
+
* @returns The inferred secret type string.
|
|
214
|
+
* @throws If the payload shape doesn't match any known type.
|
|
215
|
+
*/
|
|
216
|
+
export function inferSecretType(payload) {
|
|
217
|
+
if ("password" in payload)
|
|
218
|
+
return "login";
|
|
219
|
+
if ("privateKey" in payload)
|
|
220
|
+
return "ssh_key";
|
|
221
|
+
if ("apiKey" in payload)
|
|
222
|
+
return "api_key";
|
|
223
|
+
if ("accessKey" in payload && "secretKey" in payload)
|
|
224
|
+
return "key_pair";
|
|
225
|
+
if ("data" in payload)
|
|
226
|
+
return "other";
|
|
227
|
+
throw new Error("Cannot infer secret_type from payload shape");
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/vault/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjE,kBAAkB;AAElB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAC;AAGX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAqEX,gBAAgB;AAChB,MAAM,UAAU,eAAe,CAAC,CAAgB;IAC9C,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,aAAa,EAAE,CAAC,CAAC,eAAe;QAChC,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;KAClC,CAAC;AACJ,CAAC;AA8HD,oBAAoB;AAEpB,0EAA0E;AAC1E,MAAM,UAAU,cAAc,CAAC,CAAe;IAC5C,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,cAAc,EAAE,CAAC,CAAC,eAAe;QACjC,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;QACjC,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;QACjC,QAAQ,EAAE,CAAC,CA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,OAAO,OAAO,CAAC;IAC1C,IAAI,YAAY,IAAI,OAAO;QAAE,OAAO,SAAS,CAAC;IAC9C,IAAI,QAAQ,IAAI,OAAO;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,WAAW,IAAI,OAAO,IAAI,WAAW,IAAI,OAAO;QAAE,OAAO,UAAU,CAAC;IACxE,IAAI,MAAM,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IACtC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkbox/sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "TypeScript SDK for the Inkbox API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,9 +22,13 @@
|
|
|
22
22
|
"test:coverage": "vitest run --coverage",
|
|
23
23
|
"prepublishOnly": "npm run build"
|
|
24
24
|
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"hash-wasm": "^4.11.0"
|
|
27
|
+
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@types/node": "^25.5.0",
|
|
27
30
|
"@vitest/coverage-v8": "^2.0.0",
|
|
31
|
+
"tsx": "^4.21.0",
|
|
28
32
|
"typescript": "^5.4.0",
|
|
29
33
|
"vitest": "^2.0.0"
|
|
30
34
|
},
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inkbox-authenticator/resources/accounts.ts
|
|
3
|
-
*
|
|
4
|
-
* Authenticator account CRUD and OTP generation.
|
|
5
|
-
*/
|
|
6
|
-
import { HttpTransport } from "../../_http.js";
|
|
7
|
-
import { AuthenticatorAccount, OTPCode } from "../types.js";
|
|
8
|
-
export declare class AuthenticatorAccountsResource {
|
|
9
|
-
private readonly http;
|
|
10
|
-
constructor(http: HttpTransport);
|
|
11
|
-
/**
|
|
12
|
-
* Create a new authenticator account from an `otpauth://` URI.
|
|
13
|
-
*
|
|
14
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
15
|
-
* @param options.otpauthUri - `otpauth://totp/...` or `otpauth://hotp/...` URI.
|
|
16
|
-
* @param options.displayName - Optional user-managed label (max 255 characters).
|
|
17
|
-
* @param options.description - Optional free-form notes.
|
|
18
|
-
*/
|
|
19
|
-
create(authenticatorAppId: string, options: {
|
|
20
|
-
otpauthUri: string;
|
|
21
|
-
displayName?: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
}): Promise<AuthenticatorAccount>;
|
|
24
|
-
/**
|
|
25
|
-
* List all non-deleted authenticator accounts for an app.
|
|
26
|
-
*
|
|
27
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
28
|
-
*/
|
|
29
|
-
list(authenticatorAppId: string): Promise<AuthenticatorAccount[]>;
|
|
30
|
-
/**
|
|
31
|
-
* Get a single authenticator account by ID.
|
|
32
|
-
*
|
|
33
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
34
|
-
* @param accountId - UUID of the authenticator account.
|
|
35
|
-
*/
|
|
36
|
-
get(authenticatorAppId: string, accountId: string): Promise<AuthenticatorAccount>;
|
|
37
|
-
/**
|
|
38
|
-
* Update user-managed account metadata.
|
|
39
|
-
*
|
|
40
|
-
* Only provided fields are applied; omitted fields are left unchanged.
|
|
41
|
-
*
|
|
42
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
43
|
-
* @param accountId - UUID of the authenticator account to update.
|
|
44
|
-
* @param options.displayName - New label (max 255 characters).
|
|
45
|
-
* @param options.description - New notes.
|
|
46
|
-
*/
|
|
47
|
-
update(authenticatorAppId: string, accountId: string, options: {
|
|
48
|
-
displayName?: string | null;
|
|
49
|
-
description?: string | null;
|
|
50
|
-
}): Promise<AuthenticatorAccount>;
|
|
51
|
-
/**
|
|
52
|
-
* Soft-delete an authenticator account.
|
|
53
|
-
*
|
|
54
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
55
|
-
* @param accountId - UUID of the authenticator account to delete.
|
|
56
|
-
*/
|
|
57
|
-
delete(authenticatorAppId: string, accountId: string): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Generate the current OTP code for an account.
|
|
60
|
-
*
|
|
61
|
-
* For TOTP accounts, `validForSeconds` indicates time until expiry.
|
|
62
|
-
* For HOTP accounts, the stored counter is incremented atomically
|
|
63
|
-
* and `validForSeconds` is `null`.
|
|
64
|
-
*
|
|
65
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
66
|
-
* @param accountId - UUID of the authenticator account.
|
|
67
|
-
*/
|
|
68
|
-
generateOtp(authenticatorAppId: string, accountId: string): Promise<OTPCode>;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../src/authenticator/resources/accounts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,oBAAoB,EACpB,OAAO,EAKR,MAAM,aAAa,CAAC;AAErB,qBAAa,6BAA6B;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;;;;;;;OAOG;IACG,MAAM,CACV,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GACA,OAAO,CAAC,oBAAoB,CAAC;IAWhC;;;;OAIG;IACG,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAOvE;;;;;OAKG;IACG,GAAG,CACP,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC;IAOhC;;;;;;;;;OASG;IACG,MAAM,CACV,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC7B,GACA,OAAO,CAAC,oBAAoB,CAAC;IAWhC;;;;;OAKG;IACG,MAAM,CACV,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;;;;;;OASG;IACG,WAAW,CACf,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;CAMpB"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inkbox-authenticator/resources/accounts.ts
|
|
3
|
-
*
|
|
4
|
-
* Authenticator account CRUD and OTP generation.
|
|
5
|
-
*/
|
|
6
|
-
import { parseAuthenticatorAccount, parseOTPCode, } from "../types.js";
|
|
7
|
-
export class AuthenticatorAccountsResource {
|
|
8
|
-
http;
|
|
9
|
-
constructor(http) {
|
|
10
|
-
this.http = http;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Create a new authenticator account from an `otpauth://` URI.
|
|
14
|
-
*
|
|
15
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
16
|
-
* @param options.otpauthUri - `otpauth://totp/...` or `otpauth://hotp/...` URI.
|
|
17
|
-
* @param options.displayName - Optional user-managed label (max 255 characters).
|
|
18
|
-
* @param options.description - Optional free-form notes.
|
|
19
|
-
*/
|
|
20
|
-
async create(authenticatorAppId, options) {
|
|
21
|
-
const body = { otpauth_uri: options.otpauthUri };
|
|
22
|
-
if (options.displayName !== undefined)
|
|
23
|
-
body["display_name"] = options.displayName;
|
|
24
|
-
if (options.description !== undefined)
|
|
25
|
-
body["description"] = options.description;
|
|
26
|
-
const data = await this.http.post(`/apps/${authenticatorAppId}/accounts`, body);
|
|
27
|
-
return parseAuthenticatorAccount(data);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* List all non-deleted authenticator accounts for an app.
|
|
31
|
-
*
|
|
32
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
33
|
-
*/
|
|
34
|
-
async list(authenticatorAppId) {
|
|
35
|
-
const data = await this.http.get(`/apps/${authenticatorAppId}/accounts`);
|
|
36
|
-
return data.map(parseAuthenticatorAccount);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Get a single authenticator account by ID.
|
|
40
|
-
*
|
|
41
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
42
|
-
* @param accountId - UUID of the authenticator account.
|
|
43
|
-
*/
|
|
44
|
-
async get(authenticatorAppId, accountId) {
|
|
45
|
-
const data = await this.http.get(`/apps/${authenticatorAppId}/accounts/${accountId}`);
|
|
46
|
-
return parseAuthenticatorAccount(data);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Update user-managed account metadata.
|
|
50
|
-
*
|
|
51
|
-
* Only provided fields are applied; omitted fields are left unchanged.
|
|
52
|
-
*
|
|
53
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
54
|
-
* @param accountId - UUID of the authenticator account to update.
|
|
55
|
-
* @param options.displayName - New label (max 255 characters).
|
|
56
|
-
* @param options.description - New notes.
|
|
57
|
-
*/
|
|
58
|
-
async update(authenticatorAppId, accountId, options) {
|
|
59
|
-
const body = {};
|
|
60
|
-
if ("displayName" in options)
|
|
61
|
-
body["display_name"] = options.displayName;
|
|
62
|
-
if ("description" in options)
|
|
63
|
-
body["description"] = options.description;
|
|
64
|
-
const data = await this.http.patch(`/apps/${authenticatorAppId}/accounts/${accountId}`, body);
|
|
65
|
-
return parseAuthenticatorAccount(data);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Soft-delete an authenticator account.
|
|
69
|
-
*
|
|
70
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
71
|
-
* @param accountId - UUID of the authenticator account to delete.
|
|
72
|
-
*/
|
|
73
|
-
async delete(authenticatorAppId, accountId) {
|
|
74
|
-
await this.http.delete(`/apps/${authenticatorAppId}/accounts/${accountId}`);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Generate the current OTP code for an account.
|
|
78
|
-
*
|
|
79
|
-
* For TOTP accounts, `validForSeconds` indicates time until expiry.
|
|
80
|
-
* For HOTP accounts, the stored counter is incremented atomically
|
|
81
|
-
* and `validForSeconds` is `null`.
|
|
82
|
-
*
|
|
83
|
-
* @param authenticatorAppId - UUID of the parent authenticator app.
|
|
84
|
-
* @param accountId - UUID of the authenticator account.
|
|
85
|
-
*/
|
|
86
|
-
async generateOtp(authenticatorAppId, accountId) {
|
|
87
|
-
const data = await this.http.post(`/apps/${authenticatorAppId}/accounts/${accountId}/generate-otp`);
|
|
88
|
-
return parseOTPCode(data);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=accounts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/authenticator/resources/accounts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAKL,yBAAyB,EACzB,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,6BAA6B;IACX;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CACV,kBAA0B,EAC1B,OAIC;QAED,MAAM,IAAI,GAA4B,EAAE,WAAW,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;QAC1E,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,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AAK,CAAC,MAAM,CACV,kBAA0B,EAC1B,SAAiB;QAEjB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,kBAAkB,aAAa,SAAS,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,WAAW,CACf,kBAA0B,EAC1B,SAAiB;QAEjB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAC/B,SAAS,kBAAkB,aAAa,SAAS,eAAe,CACjE,CAAC;QACF,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inkbox-authenticator/resources/apps.ts
|
|
3
|
-
*
|
|
4
|
-
* Authenticator app CRUD operations.
|
|
5
|
-
*/
|
|
6
|
-
import { HttpTransport } from "../../_http.js";
|
|
7
|
-
import { AuthenticatorApp } from "../types.js";
|
|
8
|
-
export declare class AuthenticatorAppsResource {
|
|
9
|
-
private readonly http;
|
|
10
|
-
constructor(http: HttpTransport);
|
|
11
|
-
/**
|
|
12
|
-
* Create a new authenticator app.
|
|
13
|
-
*
|
|
14
|
-
* @param options.agentHandle - Optional agent identity handle to link this app to.
|
|
15
|
-
* If omitted, the app is created unbound.
|
|
16
|
-
*/
|
|
17
|
-
create(options?: {
|
|
18
|
-
agentHandle?: string;
|
|
19
|
-
}): Promise<AuthenticatorApp>;
|
|
20
|
-
/** List all non-deleted authenticator apps for your organisation. */
|
|
21
|
-
list(): Promise<AuthenticatorApp[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Get a single authenticator app by ID.
|
|
24
|
-
*
|
|
25
|
-
* @param authenticatorAppId - UUID of the authenticator app.
|
|
26
|
-
*/
|
|
27
|
-
get(authenticatorAppId: string): Promise<AuthenticatorApp>;
|
|
28
|
-
/**
|
|
29
|
-
* Soft-delete an authenticator app.
|
|
30
|
-
*
|
|
31
|
-
* This also unlinks the app from its identity (if any) and
|
|
32
|
-
* soft-deletes all child authenticator accounts.
|
|
33
|
-
*
|
|
34
|
-
* @param authenticatorAppId - UUID of the authenticator app to delete.
|
|
35
|
-
*/
|
|
36
|
-
delete(authenticatorAppId: string): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=apps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../../src/authenticator/resources/apps.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAIrB,qBAAa,yBAAyB;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;;;;;OAKG;IACG,MAAM,CAAC,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO/E,qEAAqE;IAC/D,IAAI,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAKzC;;;;OAIG;IACG,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKhE;;;;;;;OAOG;IACG,MAAM,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxD"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inkbox-authenticator/resources/apps.ts
|
|
3
|
-
*
|
|
4
|
-
* Authenticator app CRUD operations.
|
|
5
|
-
*/
|
|
6
|
-
import { parseAuthenticatorApp, } from "../types.js";
|
|
7
|
-
const BASE = "/apps";
|
|
8
|
-
export class AuthenticatorAppsResource {
|
|
9
|
-
http;
|
|
10
|
-
constructor(http) {
|
|
11
|
-
this.http = http;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Create a new authenticator app.
|
|
15
|
-
*
|
|
16
|
-
* @param options.agentHandle - Optional agent identity handle to link this app to.
|
|
17
|
-
* If omitted, the app is created unbound.
|
|
18
|
-
*/
|
|
19
|
-
async create(options = {}) {
|
|
20
|
-
const body = {};
|
|
21
|
-
if (options.agentHandle !== undefined)
|
|
22
|
-
body["agent_handle"] = options.agentHandle;
|
|
23
|
-
const data = await this.http.post(BASE, body);
|
|
24
|
-
return parseAuthenticatorApp(data);
|
|
25
|
-
}
|
|
26
|
-
/** List all non-deleted authenticator apps for your organisation. */
|
|
27
|
-
async list() {
|
|
28
|
-
const data = await this.http.get(BASE);
|
|
29
|
-
return data.map(parseAuthenticatorApp);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Get a single authenticator app by ID.
|
|
33
|
-
*
|
|
34
|
-
* @param authenticatorAppId - UUID of the authenticator app.
|
|
35
|
-
*/
|
|
36
|
-
async get(authenticatorAppId) {
|
|
37
|
-
const data = await this.http.get(`${BASE}/${authenticatorAppId}`);
|
|
38
|
-
return parseAuthenticatorApp(data);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Soft-delete an authenticator app.
|
|
42
|
-
*
|
|
43
|
-
* This also unlinks the app from its identity (if any) and
|
|
44
|
-
* soft-deletes all child authenticator accounts.
|
|
45
|
-
*
|
|
46
|
-
* @param authenticatorAppId - UUID of the authenticator app to delete.
|
|
47
|
-
*/
|
|
48
|
-
async delete(authenticatorAppId) {
|
|
49
|
-
await this.http.delete(`${BASE}/${authenticatorAppId}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=apps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apps.js","sourceRoot":"","sources":["../../../src/authenticator/resources/apps.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAGL,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,MAAM,IAAI,GAAG,OAAO,CAAC;AAErB,MAAM,OAAO,yBAAyB;IACP;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,UAAoC,EAAE;QACjD,MAAM,IAAI,GAA4B,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;QAClF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAsB,IAAI,EAAE,IAAI,CAAC,CAAC;QACnE,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAwB,IAAI,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,kBAA0B;QAClC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAsB,GAAG,IAAI,IAAI,kBAAkB,EAAE,CAAC,CAAC;QACvF,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,kBAA0B;QACrC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,kBAAkB,EAAE,CAAC,CAAC;IAC1D,CAAC;CACF"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inkbox-authenticator TypeScript SDK — public types.
|
|
3
|
-
*/
|
|
4
|
-
export interface AuthenticatorApp {
|
|
5
|
-
id: string;
|
|
6
|
-
organizationId: string;
|
|
7
|
-
identityId: string | null;
|
|
8
|
-
/** "active" | "paused" | "deleted" */
|
|
9
|
-
status: string;
|
|
10
|
-
createdAt: Date;
|
|
11
|
-
updatedAt: Date;
|
|
12
|
-
}
|
|
13
|
-
export interface AuthenticatorAccount {
|
|
14
|
-
id: string;
|
|
15
|
-
authenticatorAppId: string;
|
|
16
|
-
/** "totp" | "hotp" */
|
|
17
|
-
otpType: string;
|
|
18
|
-
issuer: string | null;
|
|
19
|
-
accountName: string | null;
|
|
20
|
-
displayName: string | null;
|
|
21
|
-
description: string | null;
|
|
22
|
-
/** "sha1" | "sha256" | "sha512" */
|
|
23
|
-
algorithm: string;
|
|
24
|
-
/** 6 | 8 */
|
|
25
|
-
digits: number;
|
|
26
|
-
/** TOTP period in seconds; null for HOTP */
|
|
27
|
-
period: number | null;
|
|
28
|
-
/** HOTP counter; null for TOTP */
|
|
29
|
-
counter: number | null;
|
|
30
|
-
/** "active" | "deleted" */
|
|
31
|
-
status: string;
|
|
32
|
-
createdAt: Date;
|
|
33
|
-
updatedAt: Date;
|
|
34
|
-
}
|
|
35
|
-
export interface OTPCode {
|
|
36
|
-
otpCode: string;
|
|
37
|
-
/** Seconds until code expires; null for HOTP */
|
|
38
|
-
validForSeconds: number | null;
|
|
39
|
-
/** "totp" | "hotp" */
|
|
40
|
-
otpType: string;
|
|
41
|
-
/** "sha1" | "sha256" | "sha512" */
|
|
42
|
-
algorithm: string;
|
|
43
|
-
/** 6 | 8 */
|
|
44
|
-
digits: number;
|
|
45
|
-
/** TOTP period in seconds; null for HOTP */
|
|
46
|
-
period: number | null;
|
|
47
|
-
}
|
|
48
|
-
export interface RawAuthenticatorApp {
|
|
49
|
-
id: string;
|
|
50
|
-
organization_id: string;
|
|
51
|
-
identity_id: string | null;
|
|
52
|
-
status: string;
|
|
53
|
-
created_at: string;
|
|
54
|
-
updated_at: string;
|
|
55
|
-
}
|
|
56
|
-
export interface RawAuthenticatorAccount {
|
|
57
|
-
id: string;
|
|
58
|
-
authenticator_app_id: string;
|
|
59
|
-
otp_type: string;
|
|
60
|
-
issuer: string | null;
|
|
61
|
-
account_name: string | null;
|
|
62
|
-
display_name: string | null;
|
|
63
|
-
description: string | null;
|
|
64
|
-
algorithm: string;
|
|
65
|
-
digits: number;
|
|
66
|
-
period: number | null;
|
|
67
|
-
counter: number | null;
|
|
68
|
-
status: string;
|
|
69
|
-
created_at: string;
|
|
70
|
-
updated_at: string;
|
|
71
|
-
}
|
|
72
|
-
export interface RawOTPCode {
|
|
73
|
-
otp_code: string;
|
|
74
|
-
valid_for_seconds: number | null;
|
|
75
|
-
otp_type: string;
|
|
76
|
-
algorithm: string;
|
|
77
|
-
digits: number;
|
|
78
|
-
period: number | null;
|
|
79
|
-
}
|
|
80
|
-
export declare function parseAuthenticatorApp(r: RawAuthenticatorApp): AuthenticatorApp;
|
|
81
|
-
export declare function parseAuthenticatorAccount(r: RawAuthenticatorAccount): AuthenticatorAccount;
|
|
82
|
-
export declare function parseOTPCode(r: RawOTPCode): OTPCode;
|
|
83
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/authenticator/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,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,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAID,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,CAS9E;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,uBAAuB,GAAG,oBAAoB,CAiB1F;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CASnD"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* inkbox-authenticator TypeScript SDK — public types.
|
|
3
|
-
*/
|
|
4
|
-
// ---- parsers ----
|
|
5
|
-
export function parseAuthenticatorApp(r) {
|
|
6
|
-
return {
|
|
7
|
-
id: r.id,
|
|
8
|
-
organizationId: r.organization_id,
|
|
9
|
-
identityId: r.identity_id,
|
|
10
|
-
status: r.status,
|
|
11
|
-
createdAt: new Date(r.created_at),
|
|
12
|
-
updatedAt: new Date(r.updated_at),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function parseAuthenticatorAccount(r) {
|
|
16
|
-
return {
|
|
17
|
-
id: r.id,
|
|
18
|
-
authenticatorAppId: r.authenticator_app_id,
|
|
19
|
-
otpType: r.otp_type,
|
|
20
|
-
issuer: r.issuer,
|
|
21
|
-
accountName: r.account_name,
|
|
22
|
-
displayName: r.display_name,
|
|
23
|
-
description: r.description,
|
|
24
|
-
algorithm: r.algorithm,
|
|
25
|
-
digits: r.digits,
|
|
26
|
-
period: r.period,
|
|
27
|
-
counter: r.counter,
|
|
28
|
-
status: r.status,
|
|
29
|
-
createdAt: new Date(r.created_at),
|
|
30
|
-
updatedAt: new Date(r.updated_at),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function parseOTPCode(r) {
|
|
34
|
-
return {
|
|
35
|
-
otpCode: r.otp_code,
|
|
36
|
-
validForSeconds: r.valid_for_seconds,
|
|
37
|
-
otpType: r.otp_type,
|
|
38
|
-
algorithm: r.algorithm,
|
|
39
|
-
digits: r.digits,
|
|
40
|
-
period: r.period,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/authenticator/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwFH,oBAAoB;AAEpB,MAAM,UAAU,qBAAqB,CAAC,CAAsB;IAC1D,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,cAAc,EAAE,CAAC,CAAC,eAAe;QACjC,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;QACjC,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,CAA0B;IAClE,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,kBAAkB,EAAE,CAAC,CAAC,oBAAoB;QAC1C,OAAO,EAAE,CAAC,CAAC,QAAQ;QACnB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,WAAW,EAAE,CAAC,CAAC,YAAY;QAC3B,WAAW,EAAE,CAAC,CAAC,YAAY;QAC3B,WAAW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