@mnemonik/credentials 0.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 +38 -0
- package/dist/contracts.d.ts +104 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +42 -0
- package/dist/contracts.js.map +1 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +596 -0
- package/dist/index.js.map +1 -0
- package/dist/osSecretStore.d.ts +10 -0
- package/dist/osSecretStore.d.ts.map +1 -0
- package/dist/osSecretStore.js +211 -0
- package/dist/osSecretStore.js.map +1 -0
- package/dist/storage.d.ts +52 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +204 -0
- package/dist/storage.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
MNEMONIK PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 JayDeeCo Limited. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This licence applies to the Mnemonik software distributed with this file
|
|
6
|
+
(the "Software").
|
|
7
|
+
|
|
8
|
+
Subject to the Mnemonik Terms of Service and while you are an authorised
|
|
9
|
+
Mnemonik account holder, JayDeeCo Limited grants you a limited, revocable,
|
|
10
|
+
non-exclusive, non-transferable, non-sublicensable licence to download,
|
|
11
|
+
install, and run unmodified copies of the Software solely to access and use
|
|
12
|
+
the Mnemonik service. This permission applies to authorised free, trial, and
|
|
13
|
+
paid accounts.
|
|
14
|
+
|
|
15
|
+
You may not:
|
|
16
|
+
|
|
17
|
+
1. modify the Software or create derivative works from it;
|
|
18
|
+
2. reverse engineer, decompile, or disassemble the Software, except to the
|
|
19
|
+
extent that applicable law does not permit this restriction;
|
|
20
|
+
3. redistribute, publish, sell, rent, lease, sublicense, or resell the
|
|
21
|
+
Software or access to it;
|
|
22
|
+
4. use the Software to build or operate a product or service that competes
|
|
23
|
+
with Mnemonik;
|
|
24
|
+
5. remove or alter any copyright, trade mark, attribution, or proprietary
|
|
25
|
+
notice; or
|
|
26
|
+
6. bypass authentication, service limits, or technical restrictions.
|
|
27
|
+
|
|
28
|
+
JayDeeCo Limited and its licensors retain all right, title, and interest in
|
|
29
|
+
the Software. No rights are granted except those expressly stated here.
|
|
30
|
+
|
|
31
|
+
This licence ends automatically when your right to use Mnemonik ends or if
|
|
32
|
+
you breach this licence or the Mnemonik Terms of Service. When it ends, you
|
|
33
|
+
must stop using the Software and delete copies in your possession or control.
|
|
34
|
+
|
|
35
|
+
Third-party components remain subject to their own licences. The warranty
|
|
36
|
+
disclaimers, limitations of liability, termination terms, and governing law
|
|
37
|
+
in the Mnemonik Terms of Service at https://mnemonik.ai/terms apply to this
|
|
38
|
+
licence and the Software.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export type OsStoreKind = 'keychain' | 'credential-manager' | 'secret-service';
|
|
2
|
+
export type CredentialStoreKind = 'os' | 'file' | OsStoreKind;
|
|
3
|
+
export declare class CredentialSessionUnavailableError extends Error {
|
|
4
|
+
readonly store: OsStoreKind | 'os';
|
|
5
|
+
readonly reason = "credential_session_unavailable";
|
|
6
|
+
constructor(store: OsStoreKind | 'os');
|
|
7
|
+
}
|
|
8
|
+
/** Public CLI entrypoints can bundle separate copies of this class. */
|
|
9
|
+
export declare function isCredentialSessionUnavailableError(error: unknown): error is CredentialSessionUnavailableError;
|
|
10
|
+
export type ComponentKind = 'hook' | 'scanner';
|
|
11
|
+
export interface CliOAuthMetadata {
|
|
12
|
+
issuer: string;
|
|
13
|
+
clientId: string;
|
|
14
|
+
scopes: string[];
|
|
15
|
+
familyId: string;
|
|
16
|
+
lastRotationTime: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CliOAuthTokens {
|
|
19
|
+
accessToken: string;
|
|
20
|
+
refreshToken: string;
|
|
21
|
+
accessExpiresAt: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ComponentCredentialResponse {
|
|
24
|
+
id: string;
|
|
25
|
+
access_token: string;
|
|
26
|
+
refresh_token: string;
|
|
27
|
+
token_type: 'Bearer';
|
|
28
|
+
expires_in: number;
|
|
29
|
+
refresh_expires_in: number;
|
|
30
|
+
scope: string;
|
|
31
|
+
display_prefix: string;
|
|
32
|
+
}
|
|
33
|
+
export interface FamilyCredential {
|
|
34
|
+
store: CredentialStoreKind;
|
|
35
|
+
familyId: string;
|
|
36
|
+
componentKind: ComponentKind;
|
|
37
|
+
scopes: string[];
|
|
38
|
+
accessToken: string;
|
|
39
|
+
refreshToken: string;
|
|
40
|
+
accessExpiresAt: string;
|
|
41
|
+
refreshExpiresAt: string;
|
|
42
|
+
lastRotationTime: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CliOAuthCredential extends CliOAuthMetadata, CliOAuthTokens {
|
|
45
|
+
store: CredentialStoreKind;
|
|
46
|
+
}
|
|
47
|
+
export interface CliTokenResponse {
|
|
48
|
+
access_token: string;
|
|
49
|
+
refresh_token: string;
|
|
50
|
+
token_type: 'Bearer';
|
|
51
|
+
expires_in: number;
|
|
52
|
+
scope: string;
|
|
53
|
+
}
|
|
54
|
+
export type ErrorBody = {
|
|
55
|
+
error: string;
|
|
56
|
+
};
|
|
57
|
+
export type TransportResponse<T> = {
|
|
58
|
+
status: 200;
|
|
59
|
+
body: T;
|
|
60
|
+
retryAfterMs?: number;
|
|
61
|
+
} | {
|
|
62
|
+
status: number;
|
|
63
|
+
body: ErrorBody;
|
|
64
|
+
retryAfterMs?: number;
|
|
65
|
+
};
|
|
66
|
+
export interface CredentialTransport {
|
|
67
|
+
rotateFamily(familyId: string, refreshToken: string): Promise<TransportResponse<ComponentCredentialResponse>>;
|
|
68
|
+
revokeFamily(familyId: string, refreshToken: string): Promise<TransportResponse<object>>;
|
|
69
|
+
}
|
|
70
|
+
export interface CliCredentialTransport {
|
|
71
|
+
rotateCli(credential: CliOAuthCredential): Promise<TransportResponse<CliTokenResponse>>;
|
|
72
|
+
}
|
|
73
|
+
export type ActionRequired = {
|
|
74
|
+
status: 'ACTION_REQUIRED';
|
|
75
|
+
reason: string;
|
|
76
|
+
familyId: string;
|
|
77
|
+
};
|
|
78
|
+
export type RetryLater = {
|
|
79
|
+
status: 'RETRY_LATER';
|
|
80
|
+
reason: 'rate_limited' | 'server_error';
|
|
81
|
+
familyId: string;
|
|
82
|
+
};
|
|
83
|
+
export type RotationResult = FamilyCredential | ActionRequired | RetryLater;
|
|
84
|
+
export type WorkResponse<T> = {
|
|
85
|
+
status: number;
|
|
86
|
+
body: T;
|
|
87
|
+
};
|
|
88
|
+
export interface SecretStore {
|
|
89
|
+
readonly kind?: OsStoreKind;
|
|
90
|
+
isAvailable(): Promise<boolean>;
|
|
91
|
+
get(reference: string): Promise<string | null | undefined>;
|
|
92
|
+
set(reference: string, secret: string): Promise<void>;
|
|
93
|
+
delete(reference: string): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
export declare class SimulatedSecretStore implements SecretStore {
|
|
96
|
+
private readonly available;
|
|
97
|
+
readonly values: Map<string, string>;
|
|
98
|
+
constructor(available?: boolean);
|
|
99
|
+
isAvailable(): Promise<boolean>;
|
|
100
|
+
get(reference: string): Promise<string | null>;
|
|
101
|
+
set(reference: string, secret: string): Promise<void>;
|
|
102
|
+
delete(reference: string): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;AAC/E,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,MAAM,GAAG,WAAW,CAAC;AAC9D,qBAAa,iCAAkC,SAAQ,KAAK;aAE9B,KAAK,EAAE,WAAW,GAAG,IAAI;IADrD,QAAQ,CAAC,MAAM,oCAAoC;IACnD,YAA4B,KA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5E,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAC5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAC3D,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,qBAAa,oBAAqB,YAAW,WAAW;IAG1C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,QAAQ,CAAC,MAAM,sBAA6B;IAE5C,YAA6B,SAAS,UAAO,EAAI;IAE3C,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAEpC;IAEK,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEnD;IAEK,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;IAEK,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7C;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class CredentialSessionUnavailableError extends Error {
|
|
2
|
+
store;
|
|
3
|
+
reason = 'credential_session_unavailable';
|
|
4
|
+
constructor(store) {
|
|
5
|
+
super(`Not signed in in this session. The sign-in is in ${store === 'keychain' ? 'the login keychain' : 'the OS credential store'}; run mnemonik auth login here or use Terminal.`);
|
|
6
|
+
this.store = store;
|
|
7
|
+
this.name = 'CredentialSessionUnavailableError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Public CLI entrypoints can bundle separate copies of this class. */
|
|
11
|
+
export function isCredentialSessionUnavailableError(error) {
|
|
12
|
+
return (!!error &&
|
|
13
|
+
typeof error === 'object' &&
|
|
14
|
+
'reason' in error &&
|
|
15
|
+
error.reason === 'credential_session_unavailable' &&
|
|
16
|
+
'name' in error &&
|
|
17
|
+
error.name === 'CredentialSessionUnavailableError' &&
|
|
18
|
+
'store' in error &&
|
|
19
|
+
['keychain', 'credential-manager', 'secret-service', 'os'].includes(String(error.store)) &&
|
|
20
|
+
'message' in error &&
|
|
21
|
+
typeof error.message === 'string');
|
|
22
|
+
}
|
|
23
|
+
export class SimulatedSecretStore {
|
|
24
|
+
available;
|
|
25
|
+
values = new Map();
|
|
26
|
+
constructor(available = true) {
|
|
27
|
+
this.available = available;
|
|
28
|
+
}
|
|
29
|
+
async isAvailable() {
|
|
30
|
+
return this.available;
|
|
31
|
+
}
|
|
32
|
+
async get(reference) {
|
|
33
|
+
return this.values.get(reference) ?? null;
|
|
34
|
+
}
|
|
35
|
+
async set(reference, secret) {
|
|
36
|
+
this.values.set(reference, secret);
|
|
37
|
+
}
|
|
38
|
+
async delete(reference) {
|
|
39
|
+
this.values.delete(reference);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAE9B,KAAK;IADxB,MAAM,GAAG,gCAAgC,CAAC;IACnD,YAA4B,KAAyB;QACnD,KAAK,CACH,oDAAoD,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,yBAAyB,iDAAiD,CAC7K,CAAC;qBAHwB,KAAK;QAI/B,IAAI,CAAC,IAAI,GAAG,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uthCredential, type CliOAuthMetadata, type CliOAuthTokens, type CliCredentialTransport, type ComponentCredentialResponse, type ComponentKind, type CredentialTransport, type FamilyCredential, type RetryLater, type RotationResult, type SecretStore, SimulatedSecretStore, type WorkResponse } from './contracts.js';
|
|
3
|
+
import { CredentialError, credentialPaths, stateDirectory, type SecureFileOptions } from './storage.js';
|
|
4
|
+
export * from './contracts.js';
|
|
5
|
+
import { osSecretStore } from './osSecretStore.js';
|
|
6
|
+
export { osSecretStore };
|
|
7
|
+
export { CredentialError, SimulatedSecretStore, credentialPaths, stateDirectory, windowsCurrentUserAcl, };
|
|
8
|
+
export interface CredentialAdapterOptions extends SecureFileOptions {
|
|
9
|
+
secretStore?: SecretStore;
|
|
10
|
+
onDiagnostic?: (code: 'os_store_unavailable') => void;
|
|
11
|
+
now?: () => number;
|
|
12
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
13
|
+
retryLimit?: number;
|
|
14
|
+
lockWaitMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function createCredentialAdapter(options?: CredentialAdapterOptions): {
|
|
17
|
+
putCliOAuth: (metadata: CliOAuthMetadata, tokens: CliOAuthTokens | string) => Promise<{
|
|
18
|
+
store: string;
|
|
19
|
+
}>;
|
|
20
|
+
readCliOAuth: () => Promise<CliOAuthCredential | null>;
|
|
21
|
+
rotateCli: (transport: CliCredentialTransport) => Promise<ActionRequired | RetryLater | CliOAuthCredential>;
|
|
22
|
+
withCliCredential: <T>(transport: CliCredentialTransport, work: (accessToken: string) => Promise<WorkResponse<T>>) => Promise<WorkResponse<T> | ActionRequired | RetryLater>;
|
|
23
|
+
removeCliOAuth: () => Promise<void>;
|
|
24
|
+
putFamily: (componentKind: ComponentKind, response: ComponentCredentialResponse) => Promise<FamilyCredential>;
|
|
25
|
+
readFamily: (familyId: string) => Promise<FamilyCredential | null>;
|
|
26
|
+
rotateFamily: (familyId: string, transport: CredentialTransport) => Promise<RotationResult>;
|
|
27
|
+
withCredential: <T>(familyId: string, transport: CredentialTransport, work: (accessToken: string) => Promise<WorkResponse<T>>) => Promise<WorkResponse<T> | ActionRequired | RetryLater>;
|
|
28
|
+
revokeFamily: (familyId: string, transport: CredentialTransport) => Promise<ActionRequired | RetryLater | {
|
|
29
|
+
status: 'revoked';
|
|
30
|
+
familyId: string;
|
|
31
|
+
}>;
|
|
32
|
+
forget: () => Promise<{
|
|
33
|
+
status: 'forgotten';
|
|
34
|
+
retainedServerSide: {
|
|
35
|
+
cliFamilyId?: string | undefined;
|
|
36
|
+
componentFamilyIds: string[];
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
hmacRootBinding: (version: 1, input: string) => Promise<{
|
|
40
|
+
version: 1;
|
|
41
|
+
hmac: string;
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
/** Shared CLI/hook backend selection; component records keep their recorded backend. */
|
|
45
|
+
export declare function createLocalCredentialAdapter(options?: CredentialAdapterOptions): {
|
|
46
|
+
putCliOAuth: (metadata: CliOAuthMetadata, tokens: CliOAuthTokens | string) => Promise<{
|
|
47
|
+
store: string;
|
|
48
|
+
}>;
|
|
49
|
+
readCliOAuth: () => Promise<CliOAuthCredential | null>;
|
|
50
|
+
rotateCli: (transport: CliCredentialTransport) => Promise<ActionRequired | RetryLater | CliOAuthCredential>;
|
|
51
|
+
withCliCredential: <T>(transport: CliCredentialTransport, work: (accessToken: string) => Promise<WorkResponse<T>>) => Promise<WorkResponse<T> | ActionRequired | RetryLater>;
|
|
52
|
+
removeCliOAuth: () => Promise<void>;
|
|
53
|
+
putFamily: (componentKind: ComponentKind, response: ComponentCredentialResponse) => Promise<FamilyCredential>;
|
|
54
|
+
readFamily: (familyId: string) => Promise<FamilyCredential | null>;
|
|
55
|
+
rotateFamily: (familyId: string, transport: CredentialTransport) => Promise<RotationResult>;
|
|
56
|
+
withCredential: <T>(familyId: string, transport: CredentialTransport, work: (accessToken: string) => Promise<WorkResponse<T>>) => Promise<WorkResponse<T> | ActionRequired | RetryLater>;
|
|
57
|
+
revokeFamily: (familyId: string, transport: CredentialTransport) => Promise<ActionRequired | RetryLater | {
|
|
58
|
+
status: 'revoked';
|
|
59
|
+
familyId: string;
|
|
60
|
+
}>;
|
|
61
|
+
forget: () => Promise<{
|
|
62
|
+
status: 'forgotten';
|
|
63
|
+
retainedServerSide: {
|
|
64
|
+
cliFamilyId?: string | undefined;
|
|
65
|
+
componentFamilyIds: string[];
|
|
66
|
+
};
|
|
67
|
+
}>;
|
|
68
|
+
hmacRootBinding: (version: 1, input: string) => Promise<{
|
|
69
|
+
version: 1;
|
|
70
|
+
hmac: string;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
type HookFamily = {
|
|
74
|
+
familyId: string;
|
|
75
|
+
server: string;
|
|
76
|
+
credentials: ReturnType<typeof createCredentialAdapter>;
|
|
77
|
+
unavailable: boolean;
|
|
78
|
+
diagnosed?: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type HookCredential = string | HookFamily;
|
|
81
|
+
/** Family handles contain no tokens. Legacy keys are considered only without a family. */
|
|
82
|
+
export declare function resolveHookCredential(legacyKey: string | null, server: string, env?: NodeJS.ProcessEnv, argv?: string[]): HookCredential | null;
|
|
83
|
+
/** Preserve each caller's wire body and budget; share rotation and failure state with bound context. */
|
|
84
|
+
export declare function fetchWithHookCredential(credential: HookCredential | null, url: string, init: NonNullable<Parameters<typeof fetch>[1]> & {
|
|
85
|
+
headers?: Record<string, string>;
|
|
86
|
+
}): Promise<Response>;
|
|
87
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAY,MAAM,uBAAuB,CAAC;AACxE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAE3B,KAAK,2BAA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