@kubun/credential 0.17.3 → 0.17.4

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/lib/index.d.ts CHANGED
@@ -24,3 +24,4 @@ export type { Argon2Cost, CredentialSuite, FactorInput, FactorInputs, SecretFact
24
24
  export { DEFAULT_ARGON2_COST, getSuite, isSupportedSuite, SUITE_KUBUN_CRED_1 } from './suite.js';
25
25
  export { assertValidCredentialShape } from './validate.js';
26
26
  export { CREDENTIAL_ADMINISTER_ACTION, credentialUserResource } from './vocabulary.js';
27
+ export { wrappableDID } from './wrappable.js';
package/lib/index.js CHANGED
@@ -12,3 +12,4 @@ export { RefreshingCredentialProvider } from './refreshing-credential-provider.j
12
12
  export { DEFAULT_ARGON2_COST, getSuite, isSupportedSuite, SUITE_KUBUN_CRED_1 } from './suite.js';
13
13
  export { assertValidCredentialShape } from './validate.js';
14
14
  export { CREDENTIAL_ADMINISTER_ACTION, credentialUserResource } from './vocabulary.js';
15
+ export { wrappableDID } from './wrappable.js';
package/lib/manager.js CHANGED
@@ -8,6 +8,7 @@ import { createCredentialOpSigner, selectWinningBranch } from './op.js';
8
8
  import { createPinThrottle } from './pin-throttle.js';
9
9
  import { entryProvenanceFields } from './provenance.js';
10
10
  import { getSuite, isSupportedSuite, SUITE_KUBUN_CRED_1 } from './suite.js';
11
+ import { wrappableDID } from './wrappable.js';
11
12
  /** Kinds a user can be prompted for, as opposed to ones held as key material. */ const SECRET_FACTOR_KINDS = [
12
13
  'passphrase',
13
14
  'pin'
@@ -538,7 +539,7 @@ export function createCredentialManager(params) {
538
539
  if (createParams.factors != null && createParams.wrappings != null) {
539
540
  throw new InvalidCredentialFactors('pass either "factors" or "wrappings", not both');
540
541
  }
541
- // The headless default: one wrapping to this device's own identity. Taking
542
+ // The headless default: one wrapping to this device's wrappable form. Taking
542
543
  // it without a decrypting identity would mint a key whose only wrapping
543
544
  // this device can never open, so it refuses here rather than at first read.
544
545
  const explicit = createParams.wrappings ?? (createParams.factors && [
@@ -548,7 +549,7 @@ export function createCredentialManager(params) {
548
549
  [
549
550
  {
550
551
  kind: 'did',
551
- recipientDID: identity.id
552
+ recipientDID: wrappableDID(identity)
552
553
  }
553
554
  ]
554
555
  ];
@@ -0,0 +1,14 @@
1
+ import type { Identity } from '@kokuin/token';
2
+ /**
3
+ * The spelling of a DID that can be encrypted to.
4
+ *
5
+ * `Identity` declares `id` alone, but a `did:peer:4` identity is a
6
+ * `MultiKeyIdentity` and carries `longForm` on the value. The short form
7
+ * resolves no document and so no agreement key — `deriveSharedSecret` refuses it
8
+ * outright, which is the good failure. The bad one is a key derived from the
9
+ * wrong branch, which throws nothing and yields ciphertext nobody can open.
10
+ *
11
+ * For `did:key` the two forms are the same string, so this is the identity's own
12
+ * `id`.
13
+ */
14
+ export declare function wrappableDID(identity: Identity): string;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The spelling of a DID that can be encrypted to.
3
+ *
4
+ * `Identity` declares `id` alone, but a `did:peer:4` identity is a
5
+ * `MultiKeyIdentity` and carries `longForm` on the value. The short form
6
+ * resolves no document and so no agreement key — `deriveSharedSecret` refuses it
7
+ * outright, which is the good failure. The bad one is a key derived from the
8
+ * wrong branch, which throws nothing and yields ciphertext nobody can open.
9
+ *
10
+ * For `did:key` the two forms are the same string, so this is the identity's own
11
+ * `id`.
12
+ */ export function wrappableDID(identity) {
13
+ const longForm = identity.longForm;
14
+ return typeof longForm === 'string' ? longForm : identity.id;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/credential",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "keywords": [],
5
5
  "license": "see LICENSE.md",
6
6
  "sideEffects": false,