@owlmeans/did 0.1.18-rc.2 → 0.1.18-rc.20
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 +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/did/SKILL.md +113 -16
- package/build/wallet.d.ts.map +1 -1
- package/build/wallet.js +7 -7
- package/build/wallet.js.map +1 -1
- package/package.json +6 -6
- package/src/wallet.ts +10 -9
- package/build/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Hierarchical deterministic (HD) wallet and DID document management for OwlMeans
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/did
|
|
15
|
+
bun add @owlmeans/did@^0.1.18-rc.11
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -65,7 +65,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
65
65
|
your project's skill store (`.agents/skills/`):
|
|
66
66
|
|
|
67
67
|
```sh
|
|
68
|
-
npx @owlmeans/agent-skills
|
|
68
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.20
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/did",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.18-rc.20",
|
|
5
|
+
"generatedAt": "2026-09-12T14:18:54.800Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: did
|
|
3
|
-
description: How to use @owlmeans/did —
|
|
3
|
+
description: How to use @owlmeans/did — the owlmk derivable key type, makeDidKeyModel and its derive() paths, and makeWallet over a three-resource DID store with mnemonic seed, key metadata and per-entity key provisioning. Auto-invoked when importing DID or wallet types, deriving keys, or implementing identity workflows.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
@@ -8,31 +8,128 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/did
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/did": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/did": "^0.1.18-rc.20"` in `dependencies`
|
|
12
|
+
|
|
13
|
+
This package adds a **derivable** key type on top of `@owlmeans/basic-keys` and a wallet that stores
|
|
14
|
+
keys derived from one mnemonic seed. Importing it registers the `owlmk` key type into the shared
|
|
15
|
+
key-plugin registry, so `KEY_OWL` becomes a valid type anywhere a key type is accepted — that side
|
|
16
|
+
effect is the reason a package that only needs the type still imports this one.
|
|
12
17
|
|
|
13
18
|
## Key Exports
|
|
14
19
|
|
|
15
20
|
| Export | Description |
|
|
16
21
|
|--------|-------------|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
22
|
+
| `makeDidKeyModel(input?)` | A `KeyPairModel` that also derives children — same input rules as `makeKeyPairModel` |
|
|
23
|
+
| `DIDKeyModel` | `KeyPairModel` + `derive(path)`; its `keyPair` also carries `path` and `parent` (read the caveat below) |
|
|
24
|
+
| `DIDKeyPair` | `KeyPair` + `{ path?, parent? }` |
|
|
25
|
+
| `makeWallet(store, opts?)` | Open (or initialize) a wallet over a `DIDStore` |
|
|
26
|
+
| `DIDWallet` | `generate` / `mnemonic` / `master` / `add` / `meta` / `update` / `get` / `find` / `provide` (→ `DIDKeyModel[]`) / `remove` / `all` / `allMeta` |
|
|
27
|
+
| `DIDStore` | `{ master, keys, meta }` — three resources the host supplies |
|
|
28
|
+
| `KeyMeta` | What a key is for: `{ id, name, entityId?, ...Profile }` |
|
|
29
|
+
| `KeySeedRecord`, `KeyPairRecord`, `KeyMetaRecord` | The record shapes those resources hold |
|
|
30
|
+
| `MakeDIDWalletOptions`, `MnemonicOptions` | `{ force, allowEmpty, mnemonic, type, allowCustomType }`; `{ size }` |
|
|
31
|
+
| `WalletFacade`, `WalletKey`, `WalletOptions`, `NewKeyOptions`, `RequestReason` | The contract a wallet UI or a remote wallet exposes to an app |
|
|
32
|
+
| `plugins` | The shared `@owlmeans/basic-keys` registry, with `owlmk` added — the only plugin symbol this package exports |
|
|
33
|
+
| `DIDError`, `DIDKeyError`, `DIDWalletError`, `DIDWalletPermissionError`, `DIDInitializationError` | Registered `ResilientError` subclasses |
|
|
34
|
+
| `KEY_OWL` (`'owlmk'`), `MASTER`, `KP_SEP` (`'/'`), `MAX_DEPTH` (6) | Key type, master record id, path separator and depth cap |
|
|
35
|
+
| `SERVICE_PREFIX`, `ENTITY_PREFIX`, `PROFILE_PREFIX`, `PREFIX_SEP` | The segments a metadata-derived path is composed from |
|
|
36
|
+
|
|
37
|
+
## Deriving keys
|
|
38
|
+
|
|
39
|
+
A DID here is what `exportAddress()` returns — `"<type>:<address>"` — and it is the id every stored
|
|
40
|
+
key and every metadata record is keyed by.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { makeDidKeyModel, KEY_OWL } from '@owlmeans/did'
|
|
44
|
+
|
|
45
|
+
const master = makeDidKeyModel(KEY_OWL) // fresh derivable key
|
|
46
|
+
const child = master.derive('entity.acme/profile.42')
|
|
47
|
+
child.keyPair!.parent // the intermediate key's DID, not the master's
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`derive` splits on `/` and derives once per segment, so a multi-segment path is exactly repeated
|
|
51
|
+
single-step derivation. It throws `DIDKeyError` on a path deeper than `MAX_DEPTH`
|
|
52
|
+
(`did:wallet:too:deep`), on an empty path (`did:wallet:no:path`), and on a model with no private key
|
|
53
|
+
(`did:wallet:no:pk`).
|
|
54
|
+
|
|
55
|
+
**`path` and `parent` describe one step, not the whole chain.** Because the recursion re-derives per
|
|
56
|
+
segment, the model that comes back from `derive('entity.acme/profile.42')` carries
|
|
57
|
+
`keyPair.path === 'profile.42'` and a `keyPair.parent` that is the intermediate `entity.acme` key's
|
|
58
|
+
DID — not the master's. The full path lives only on the intermediate model that was thrown away.
|
|
59
|
+
Store the string you passed to `derive` if you need to re-derive later; `keyPair.path` will not
|
|
60
|
+
rebuild it.
|
|
61
|
+
|
|
62
|
+
A key type that cannot derive (plain `ed25519`, `xchacha`) is rejected **only when the model is
|
|
63
|
+
built from the bare type string** — `makeDidKeyModel('ed25519')` throws `DIDKeyError`
|
|
64
|
+
`did:wallet:non-derivable:ed25519`. Built from a `KeyPair` object — which is what the wallet does
|
|
65
|
+
for every record it loads — or with no argument at all, nothing checks, and `derive()` fails later
|
|
66
|
+
with a raw `TypeError: plugins[...].derive is not a function`. Guard the type yourself before
|
|
67
|
+
deriving from a stored key pair.
|
|
23
68
|
|
|
24
|
-
##
|
|
69
|
+
## The wallet
|
|
70
|
+
|
|
71
|
+
`makeWallet` needs a `DIDStore`: three resources — `master` for the seed record, `keys` for the key
|
|
72
|
+
pairs, `meta` for what each key is for. Any `@owlmeans/resource` implementation will do, and the
|
|
73
|
+
choice of store is what decides whether the wallet lives in memory, in a browser, or on a server.
|
|
25
74
|
|
|
26
75
|
```typescript
|
|
27
|
-
import {
|
|
76
|
+
import { makeWallet } from '@owlmeans/did'
|
|
28
77
|
|
|
29
|
-
const wallet =
|
|
30
|
-
const
|
|
78
|
+
const wallet = await makeWallet(store, { force: true }) // force ⇒ generate a fresh seed
|
|
79
|
+
const master = await wallet.master()
|
|
80
|
+
const [key] = await wallet.provide({ name: 'signing', entityId })
|
|
31
81
|
```
|
|
32
82
|
|
|
83
|
+
Opening a store with no master record throws `DIDInitializationError` unless `force` (generate one
|
|
84
|
+
now) or `allowEmpty` (open it anyway) is passed. `{ type, allowCustomType: true }` is the only
|
|
85
|
+
public way to add another derivable key type: `makeWallet` builds a plugin for the named type and
|
|
86
|
+
puts it in the shared registry.
|
|
87
|
+
|
|
88
|
+
### Seed and mnemonic
|
|
89
|
+
|
|
90
|
+
`generate()` derives the seed from a fresh mnemonic. `{ mnemonic: { size } }` must be between 12 and
|
|
91
|
+
24 and defaults to **18**, but it is not a word count — it is mapped to BIP-39 entropy and rounded
|
|
92
|
+
up to the next whole 32-bit block, so 12 gives a 15-word phrase, 18 gives 21, and 21–23 all give 24.
|
|
93
|
+
**`size: 24` throws `TypeError: Invalid entropy`**, because the mapping overshoots the 256-bit
|
|
94
|
+
maximum. Stay at 23 or below.
|
|
95
|
+
|
|
96
|
+
`mnemonic()` does not recover the phrase of a wallet this package generated. `generate()` stores the
|
|
97
|
+
seed base64-encoded while `mnemonic()` hex-decodes what it reads, so the call throws in the decoder.
|
|
98
|
+
It returns `false` (or throws `DIDWalletError` when called as `mnemonic(true)`) only for a master
|
|
99
|
+
record that carries no seed at all. Do not build a recovery-phrase flow on it.
|
|
100
|
+
|
|
101
|
+
### Providing keys
|
|
102
|
+
|
|
103
|
+
`provide(meta)` is the call an application actually makes: it looks for keys matching the metadata
|
|
104
|
+
and, finding none, derives one from the master at a path composed from that metadata — the service
|
|
105
|
+
scope, then the organization entity, then the profile — stores it with its metadata, and returns
|
|
106
|
+
**an array** (`DIDKeyModel[]`, one element for a freshly derived key). Destructure it;
|
|
107
|
+
`meta.name` is required and its absence throws `DIDKeyError` `did:wallet:no:name`.
|
|
108
|
+
|
|
109
|
+
Idempotence holds **only while the metadata carries no `id`.** The stored metadata record is always
|
|
110
|
+
keyed by the key's own DID, so a `meta.id` you pass in is discarded on save and the next
|
|
111
|
+
`find(meta)` — which matches `id` against the stored value — cannot find the key it just wrote. The
|
|
112
|
+
second `provide` re-derives the same key and `add` rejects it with `DIDWalletError`
|
|
113
|
+
`did:wallet:key:exists`. Identify a key by its scope fields (`entityId`, `scopes`) rather than by a
|
|
114
|
+
profile id, or catch that error.
|
|
115
|
+
|
|
116
|
+
Repeat the `name` verbatim as well: it takes part in the lookup (see below), so `provide` with a
|
|
117
|
+
changed name for the same scope finds nothing, re-derives the same key and fails with that same
|
|
118
|
+
`did:wallet:key:exists`.
|
|
119
|
+
|
|
120
|
+
`find(meta)` filters twice and likewise returns an array. Every **non-boolean** field of `meta` —
|
|
121
|
+
`name` among them — goes into the query it puts to the metadata resource, and each record that comes
|
|
122
|
+
back is re-checked in memory, where `name` is the one field skipped, a boolean is compared (those
|
|
123
|
+
never reach the query), and an array value must be contained in the stored array. So a `name` that
|
|
124
|
+
differs from the stored one still excludes the key at the store: this is not a name-insensitive
|
|
125
|
+
lookup. `get(did)` and `remove(did)` work by DID, and `add`/`update` take a model plus its metadata.
|
|
126
|
+
`add` refuses a key it cannot manage (no private key) and a DID already present.
|
|
127
|
+
|
|
33
128
|
## Depends On
|
|
34
129
|
|
|
35
|
-
- `@owlmeans/basic-keys` —
|
|
36
|
-
- `@owlmeans/
|
|
37
|
-
- `@owlmeans/
|
|
38
|
-
- `@owlmeans/
|
|
130
|
+
- `@owlmeans/basic-keys` — the key model, the plugin registry and the `utils` this extends
|
|
131
|
+
- `@owlmeans/resource` — the three stores a `DIDStore` is made of
|
|
132
|
+
- `@owlmeans/auth` — `Profile`, which `KeyMeta` extends
|
|
133
|
+
- `@owlmeans/error` — the base class the DID errors extend
|
|
134
|
+
- `@owlmeans/i18n` — importing this package registers the `keys` and `wallet` libraries under the `did` namespace
|
|
135
|
+
- `@scure/bip39` (mnemonic), `@scure/base`, `@noble/curves`, `@noble/hashes`
|
package/build/wallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,QAAQ,EAAE,SAAS,EAAyC,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAS/H,eAAO,MAAM,UAAU,UAAiB,QAAQ,SAAS,oBAAoB,uBA4K5E,CAAA"}
|
package/build/wallet.js
CHANGED
|
@@ -76,7 +76,8 @@ export const makeWallet = async (store, opts) => {
|
|
|
76
76
|
return makeDidKeyModel(await store.keys.get(did));
|
|
77
77
|
},
|
|
78
78
|
find: async (meta) => {
|
|
79
|
-
const
|
|
79
|
+
const where = Object.fromEntries(Object.entries(meta).filter(([_, v]) => typeof v !== 'boolean'));
|
|
80
|
+
const result = await store.meta.list(where);
|
|
80
81
|
const keys = await Promise.all(result.items.filter(item => matchMeta(item, meta))
|
|
81
82
|
.map(async (meta) => store.keys.get(meta.id)));
|
|
82
83
|
return keys.map(key => makeDidKeyModel(key));
|
|
@@ -116,7 +117,7 @@ export const makeWallet = async (store, opts) => {
|
|
|
116
117
|
if (key == null) {
|
|
117
118
|
throw new DIDWalletError('no:key');
|
|
118
119
|
}
|
|
119
|
-
await store.keys.delete(
|
|
120
|
+
await store.keys.delete(did);
|
|
120
121
|
const model = makeDidKeyModel(key);
|
|
121
122
|
await store.meta.delete(model.exportAddress());
|
|
122
123
|
return model;
|
|
@@ -125,9 +126,9 @@ export const makeWallet = async (store, opts) => {
|
|
|
125
126
|
const result = [];
|
|
126
127
|
let more = false;
|
|
127
128
|
do {
|
|
128
|
-
const found = await store.keys.list(
|
|
129
|
+
const found = await store.keys.list(undefined, { page: Math.floor(result.length / 100), size: 100 });
|
|
129
130
|
result.push(...found.items);
|
|
130
|
-
more = found.
|
|
131
|
+
more = found.items.length > 0 && found.total > result.length;
|
|
131
132
|
} while (more);
|
|
132
133
|
return result.map(key => makeDidKeyModel(key));
|
|
133
134
|
},
|
|
@@ -135,10 +136,9 @@ export const makeWallet = async (store, opts) => {
|
|
|
135
136
|
const result = [];
|
|
136
137
|
let more = false;
|
|
137
138
|
do {
|
|
138
|
-
|
|
139
|
-
const found = await store.meta.list({ pager: { page: Math.floor(result.length / 100), size: 100 } });
|
|
139
|
+
const found = await store.meta.list(undefined, { page: Math.floor(result.length / 100), size: 100 });
|
|
140
140
|
result.push(...found.items);
|
|
141
|
-
more = found.
|
|
141
|
+
more = found.items.length > 0 && found.total > result.length;
|
|
142
142
|
} while (more);
|
|
143
143
|
return result;
|
|
144
144
|
}
|
package/build/wallet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjF,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,KAAe,EAAE,IAA2B,EAAE,EAAE;IAC/E,IAAI,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,IAAI,EAA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
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/did",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@noble/curves": "^1.6.0",
|
|
25
25
|
"@noble/hashes": "^1.5.0",
|
|
26
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/basic-keys": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/i18n": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/resource": "^0.1.18-rc.
|
|
26
|
+
"@owlmeans/auth": "^0.1.18-rc.17",
|
|
27
|
+
"@owlmeans/basic-keys": "^0.1.18-rc.20",
|
|
28
|
+
"@owlmeans/error": "^0.1.18-rc.16",
|
|
29
|
+
"@owlmeans/i18n": "^0.1.18-rc.16",
|
|
30
|
+
"@owlmeans/resource": "^0.1.18-rc.17",
|
|
31
31
|
"@scure/base": "^2.3.0",
|
|
32
32
|
"@scure/bip39": "^1.4.0"
|
|
33
33
|
},
|
package/src/wallet.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DIDInitializationError, DIDKeyError, DIDWalletError } from './errors.js'
|
|
2
|
-
import type {
|
|
2
|
+
import type { Criteria } from '@owlmeans/resource'
|
|
3
|
+
import type { DIDKeyModel, DIDStore, DIDWallet, KeyMeta, KeyMetaRecord, KeyPairRecord, MakeDIDWalletOptions } from './types.js'
|
|
3
4
|
import { generateMnemonic, toEntropy, toMnemonic, toSeed } from './utils/mnemonic.js'
|
|
4
5
|
import { KEY_OWL, MASTER } from './consts.js'
|
|
5
6
|
import { plugins } from './plugins/index.js'
|
|
@@ -94,9 +95,10 @@ export const makeWallet = async (store: DIDStore, opts?: MakeDIDWalletOptions) =
|
|
|
94
95
|
},
|
|
95
96
|
|
|
96
97
|
find: async meta => {
|
|
97
|
-
const
|
|
98
|
-
Object.
|
|
98
|
+
const where: Criteria<KeyMetaRecord> = Object.fromEntries(
|
|
99
|
+
Object.entries(meta).filter(([_, v]) => typeof v !== 'boolean')
|
|
99
100
|
)
|
|
101
|
+
const result = await store.meta.list(where)
|
|
100
102
|
|
|
101
103
|
const keys = await Promise.all(result.items.filter(item => matchMeta(item, meta))
|
|
102
104
|
.map(async meta => store.keys.get(meta.id)))
|
|
@@ -142,7 +144,7 @@ export const makeWallet = async (store: DIDStore, opts?: MakeDIDWalletOptions) =
|
|
|
142
144
|
if (key == null) {
|
|
143
145
|
throw new DIDWalletError('no:key')
|
|
144
146
|
}
|
|
145
|
-
await store.keys.delete(
|
|
147
|
+
await store.keys.delete(did)
|
|
146
148
|
const model = makeDidKeyModel(key)
|
|
147
149
|
await store.meta.delete(model.exportAddress())
|
|
148
150
|
|
|
@@ -153,9 +155,9 @@ export const makeWallet = async (store: DIDStore, opts?: MakeDIDWalletOptions) =
|
|
|
153
155
|
const result: KeyPairRecord[] = []
|
|
154
156
|
let more = false
|
|
155
157
|
do {
|
|
156
|
-
const found = await store.keys.list(
|
|
158
|
+
const found = await store.keys.list(undefined, { page: Math.floor(result.length / 100), size: 100 })
|
|
157
159
|
result.push(...found.items)
|
|
158
|
-
more = found.
|
|
160
|
+
more = found.items.length > 0 && found.total > result.length
|
|
159
161
|
} while (more)
|
|
160
162
|
|
|
161
163
|
return result.map(key => makeDidKeyModel(key))
|
|
@@ -165,10 +167,9 @@ export const makeWallet = async (store: DIDStore, opts?: MakeDIDWalletOptions) =
|
|
|
165
167
|
const result: KeyMeta[] = []
|
|
166
168
|
let more = false
|
|
167
169
|
do {
|
|
168
|
-
|
|
169
|
-
const found = await store.meta.list({ pager: { page: Math.floor(result.length / 100), size: 100 } })
|
|
170
|
+
const found = await store.meta.list(undefined, { page: Math.floor(result.length / 100), size: 100 })
|
|
170
171
|
result.push(...found.items)
|
|
171
|
-
more = found.
|
|
172
|
+
more = found.items.length > 0 && found.total > result.length
|
|
172
173
|
} while (more)
|
|
173
174
|
|
|
174
175
|
return result
|
package/build/.gitkeep
DELETED
|
File without changes
|