@1password/sdk 0.1.0-beta.1 → 0.1.0-beta.2
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/dist/client.d.ts +17 -5
- package/dist/client.js +36 -29
- package/dist/secrets.d.ts +2 -2
- package/dist/secrets.js +19 -8
- package/package.json +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SecretsApi } from "./secrets.js";
|
|
2
2
|
import { ClientAuthConfig, Core } from "./core.js";
|
|
3
3
|
import { ClientConfiguration, InnerClient } from "./configuration.js";
|
|
4
4
|
export declare const DEFAULT_INTEGRATION_NAME = "Unknown";
|
|
5
5
|
export declare const DEFAULT_INTEGRATION_VERSION = "Unknown";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Creates a default 1Password SDK client.
|
|
8
|
+
* @returns The authenticated 1Password SDK client.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createClient: (config: ClientConfiguration) => Promise<Client>;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a 1Password SDK client with a given core implementation.
|
|
13
|
+
* @returns The authenticated 1Password SDK client.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createClientWithCore: (config: ClientConfiguration, core: Core) => Promise<Client>;
|
|
8
16
|
export declare class Client {
|
|
9
|
-
secrets:
|
|
17
|
+
secrets: SecretsApi;
|
|
10
18
|
constructor(innerClient: InnerClient);
|
|
11
19
|
}
|
|
12
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Creates a default client configuration.
|
|
22
|
+
* @returns The client configuration to instantiate the client with.
|
|
23
|
+
*/
|
|
24
|
+
export declare const clientAuthConfig: (userConfig: ClientConfiguration) => ClientAuthConfig;
|
package/dist/client.js
CHANGED
|
@@ -32,38 +32,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
35
|
+
exports.clientAuthConfig = exports.Client = exports.createClientWithCore = exports.createClient = exports.DEFAULT_INTEGRATION_VERSION = exports.DEFAULT_INTEGRATION_NAME = void 0;
|
|
36
|
+
const os = __importStar(require("os"));
|
|
36
37
|
const secrets_js_1 = require("./secrets.js");
|
|
37
38
|
const core_js_1 = require("./core.js");
|
|
38
|
-
const os = __importStar(require("os"));
|
|
39
39
|
exports.DEFAULT_INTEGRATION_NAME = "Unknown";
|
|
40
40
|
exports.DEFAULT_INTEGRATION_VERSION = "Unknown";
|
|
41
41
|
const LANGUAGE = "JS";
|
|
42
42
|
const VERSION = "0010001"; // v0.1.0
|
|
43
|
-
const finalizationRegistry = new FinalizationRegistry((
|
|
44
|
-
|
|
45
|
-
sharedCore.releaseClient(heldClientId);
|
|
43
|
+
const finalizationRegistry = new FinalizationRegistry((heldClient) => {
|
|
44
|
+
heldClient.core.releaseClient(heldClient.id);
|
|
46
45
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a default 1Password SDK client.
|
|
48
|
+
* @returns The authenticated 1Password SDK client.
|
|
49
|
+
*/
|
|
50
|
+
const createClient = (config) => __awaiter(void 0, void 0, void 0, function* () { return (0, exports.createClientWithCore)(config, new core_js_1.SharedCore()); });
|
|
52
51
|
exports.createClient = createClient;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Creates a 1Password SDK client with a given core implementation.
|
|
54
|
+
* @returns The authenticated 1Password SDK client.
|
|
55
|
+
*/
|
|
56
|
+
const createClientWithCore = (config, core) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const authConfig = (0, exports.clientAuthConfig)(config);
|
|
58
|
+
const clientId = yield core.initClient(authConfig);
|
|
59
|
+
const inner = {
|
|
60
|
+
id: parseInt(clientId, 10),
|
|
61
|
+
core,
|
|
62
|
+
};
|
|
63
|
+
const client = new Client(inner);
|
|
64
|
+
// Cleans up associated memory from core when client instance goes out of scope.
|
|
65
|
+
finalizationRegistry.register(client, inner);
|
|
66
|
+
return client;
|
|
67
|
+
});
|
|
67
68
|
exports.createClientWithCore = createClientWithCore;
|
|
68
69
|
// Client represents a client instance of the SDK.
|
|
69
70
|
class Client {
|
|
@@ -72,7 +73,13 @@ class Client {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
exports.Client = Client;
|
|
75
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Creates a default client configuration.
|
|
78
|
+
* @returns The client configuration to instantiate the client with.
|
|
79
|
+
*/
|
|
80
|
+
const clientAuthConfig = (userConfig) => {
|
|
81
|
+
// TODO: Add logic for computing the correct sanitized version value for each platform
|
|
82
|
+
const defaultOsVersion = "0.0.0";
|
|
76
83
|
return {
|
|
77
84
|
serviceAccountToken: userConfig.auth,
|
|
78
85
|
programmingLanguage: LANGUAGE,
|
|
@@ -82,9 +89,9 @@ function createClientAuthConfig(userConfig) {
|
|
|
82
89
|
requestLibraryName: "Fetch API",
|
|
83
90
|
requestLibraryVersion: "Fetch API",
|
|
84
91
|
// Only supported on Node.js
|
|
85
|
-
os: os.type(),
|
|
86
|
-
osVersion:
|
|
92
|
+
os: os.type().toLowerCase(),
|
|
93
|
+
osVersion: defaultOsVersion,
|
|
87
94
|
architecture: os.arch(),
|
|
88
95
|
};
|
|
89
|
-
}
|
|
90
|
-
exports.
|
|
96
|
+
};
|
|
97
|
+
exports.clientAuthConfig = clientAuthConfig;
|
package/dist/secrets.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InnerClient } from "./configuration.js";
|
|
2
|
-
export interface
|
|
2
|
+
export interface SecretsApi {
|
|
3
3
|
resolve(secretReference: string): Promise<string>;
|
|
4
4
|
}
|
|
5
|
-
export declare class SecretsSource implements
|
|
5
|
+
export declare class SecretsSource implements SecretsApi {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(inner: InnerClient);
|
|
8
8
|
resolve(secretReference: string): Promise<string>;
|
package/dist/secrets.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
12
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
13
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -20,14 +29,16 @@ class SecretsSource {
|
|
|
20
29
|
__classPrivateFieldSet(this, _SecretsSource_inner, inner, "f");
|
|
21
30
|
}
|
|
22
31
|
resolve(secretReference) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const invocationConfig = {
|
|
34
|
+
clientId: __classPrivateFieldGet(this, _SecretsSource_inner, "f").id,
|
|
35
|
+
invocation: {
|
|
36
|
+
name: "Resolve",
|
|
37
|
+
parameters: secretReference,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
return __classPrivateFieldGet(this, _SecretsSource_inner, "f").core.invoke(invocationConfig);
|
|
41
|
+
});
|
|
31
42
|
}
|
|
32
43
|
}
|
|
33
44
|
exports.SecretsSource = SecretsSource;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1password/sdk",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
4
|
"description": "The 1Password JavaScript SDK offers programmatic read access to your secrets in 1Password in an interface native to JavaScript. The SDK currently supports `Node.JS`",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
7
|
-
"clean": "rimraf dist",
|
|
6
|
+
"build": "tsc",
|
|
8
7
|
"test": "npm run build && jest",
|
|
9
8
|
"prettier": "prettier --check 'src/*.ts'",
|
|
9
|
+
"prettier-fix": "prettier --write 'src/*.ts'",
|
|
10
|
+
"eslint": "eslint -c .eslintrc.json 'src/*.ts'",
|
|
10
11
|
"prepare": "npm run build"
|
|
11
12
|
},
|
|
12
13
|
"author": "1Password",
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"main": "./dist/client.js",
|
|
24
25
|
"types": "./dist/client.d.ts",
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@1password/sdk-core": "0.1.0-beta.
|
|
27
|
+
"@1password/sdk-core": "0.1.0-beta.2"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@1password/eslint-config": "^4.0.0",
|
|
@@ -36,7 +37,6 @@
|
|
|
36
37
|
"jest-environment-jsdom": "^29.6.2",
|
|
37
38
|
"prettier": "3.1.1",
|
|
38
39
|
"ts-jest": "^29.1.1",
|
|
39
|
-
"rimraf": "^5.0.0",
|
|
40
40
|
"typescript": "^5.3.3",
|
|
41
41
|
"@types/node": "^20.11.0",
|
|
42
42
|
"@babel/preset-env": "^7.23.8",
|