Skip to content

Commit

Permalink
Update core to version be52bb12
Browse files Browse the repository at this point in the history
  • Loading branch information
1PasswordSDKBot committed Feb 26, 2025
1 parent 4bd68d0 commit 4ea7fb5
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 8 deletions.
33 changes: 32 additions & 1 deletion client/src/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
import { SdkIterable } from "./iterator.js";
import { GeneratePasswordResponse, PasswordRecipe } from "./types.js";
import {
GeneratePasswordResponse,
PasswordRecipe,
ResolveAllResponse,
} from "./types.js";

/**
* The Secrets API includes all operations the SDK client can perform on secrets.
Expand All @@ -13,6 +17,11 @@ export interface SecretsApi {
* Resolve returns the secret the provided secret reference points to.
*/
resolve(secretReference: string): Promise<string>;

/**
* Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
*/
resolveAll(secretReferences: string[]): Promise<ResolveAllResponse>;
}

export class Secrets implements SecretsApi {
Expand Down Expand Up @@ -42,6 +51,28 @@ export class Secrets implements SecretsApi {
) as Promise<string>;
}

/**
* Resolve takes in a list of secret references and returns the secrets they point to or errors if any.
*/
public async resolveAll(
secretReferences: string[],
): Promise<ResolveAllResponse> {
const invocationConfig: InvokeConfig = {
invocation: {
clientId: this.#inner.id,
parameters: {
name: "SecretsResolveAll",
parameters: {
secret_references: secretReferences,
},
},
},
};
return JSON.parse(
await this.#inner.core.invoke(invocationConfig),
) as Promise<ResolveAllResponse>;
}

/**
* Validate the secret reference to ensure there are no syntax errors.
*/
Expand Down
61 changes: 60 additions & 1 deletion client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Generated by typeshare 1.13.2
*/

export type ErrorMessage = string;

/**
* For future use, if we want to return more information about the generated password.
* Currently, it only returns the password itself.
Expand Down Expand Up @@ -48,13 +50,16 @@ export enum ItemFieldType {
Totp = "Totp",
Email = "Email",
Reference = "Reference",
SshKey = "SshKey",
Unsupported = "Unsupported",
}

/** Field type-specific attributes. */
export type ItemFieldDetails =
/** The computed OTP code and other details */
{ type: "Otp"; content: OtpFieldDetails };
| { type: "Otp"; content: OtpFieldDetails }
/** Computed SSH Key attributes */
| { type: "SshKey"; content?: SshKeyAttributes };

/** Represents a field within an item. */
export interface ItemField {
Expand Down Expand Up @@ -250,6 +255,60 @@ export interface OtpFieldDetails {
errorMessage?: string;
}

export interface Response<T, E> {
content?: T;
error?: E;
}

export type ResolveReferenceError =
/** Error parsing the secret reference */
| { type: "parsing"; message: ErrorMessage }
/** The specified reference cannot be found within the item */
| { type: "fieldNotFound"; message?: undefined }
/** No vault matched the secret reference query */
| { type: "vaultNotFound"; message?: undefined }
/** More than one vault matched the secret reference query */
| { type: "tooManyVaults"; message?: undefined }
/** No item matched the secret reference query */
| { type: "itemNotFound"; message?: undefined }
/** More than one item matched the secret reference query */
| { type: "tooManyItems"; message?: undefined }
/** More than one field matched the provided secret reference */
| { type: "tooManyMatchingFields"; message?: undefined }
/** No section found within the item for the provided identifier */
| { type: "noMatchingSections"; message?: undefined }
/** More than one matching section found within the item */
| { type: "tooManyMatchingSections"; message?: undefined }
/** Incompatiable TOTP query parameters */
| { type: "incompatibleTOTPQueryParameterField"; message?: undefined }
/** The totp was not able to be generated */
| { type: "unableToGenerateTotpCode"; message: ErrorMessage }
/** Couldn't find attributes specific to an SSH Key field */
| { type: "sSHKeyMetadataNotFound"; message?: undefined }
/** Currently only support text files */
| { type: "unsupportedFileFormat"; message?: undefined }
/** Trying to convert a non-private key to a private key format */
| { type: "incompatibleSshKeyQueryParameterField"; message?: undefined }
/** Unable to properly parse a private key string to convert to an internal Private Key type */
| { type: "unableToParsePrivateKey"; message?: undefined }
/** Unable to format a private key to OpenSSH format */
| { type: "unableToFormatPrivateKeyToOpenSsh"; message?: undefined }
/** Other type */
| { type: "other"; message?: undefined };

export interface ResolveAllResponse {
individualResponses: Response<string, ResolveReferenceError>[];
}

export interface SshKeyAttributes {
/** The public part of the SSH Key */
publicKey: string;
/** The fingerprint of the SSH Key */
fingerprint: string;
/** The key type ("Ed25519" or "RSA, {length}-bit") */
keyType: string;
}

/** Represents a decrypted 1Password vault. */
export interface VaultOverview {
/** The vault's ID */
Expand Down
8 changes: 4 additions & 4 deletions wasm/nodejs/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ module.exports.release_client = function(client_id) {
};

function __wbg_adapter_30(arg0, arg1, arg2) {
wasm.closure1820_externref_shim(arg0, arg1, arg2);
wasm.closure2010_externref_shim(arg0, arg1, arg2);
}

function __wbg_adapter_145(arg0, arg1, arg2, arg3) {
wasm.closure1902_externref_shim(arg0, arg1, arg2, arg3);
wasm.closure2095_externref_shim(arg0, arg1, arg2, arg3);
}

const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
Expand Down Expand Up @@ -684,8 +684,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
return ret;
};

module.exports.__wbindgen_closure_wrapper6409 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 1821, __wbg_adapter_30);
module.exports.__wbindgen_closure_wrapper7284 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 2011, __wbg_adapter_30);
return ret;
};

Expand Down
Binary file modified wasm/nodejs/core_bg.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions wasm/nodejs/core_bg.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) =>
export const __wbindgen_export_5: WebAssembly.Table;
export const __externref_table_dealloc: (a: number) => void;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const closure1820_externref_shim: (a: number, b: number, c: any) => void;
export const closure1902_externref_shim: (a: number, b: number, c: any, d: any) => void;
export const closure2010_externref_shim: (a: number, b: number, c: any) => void;
export const closure2095_externref_shim: (a: number, b: number, c: any, d: any) => void;
export const __wbindgen_start: () => void;

0 comments on commit 4ea7fb5

Please sign in to comment.