@haneullabs/signers 0.1.0 → 1.0.1

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +121 -74
  2. package/README.md +11 -8
  3. package/dist/aws/aws-client.d.mts +48 -0
  4. package/dist/aws/aws-client.d.mts.map +1 -0
  5. package/dist/aws/aws-client.mjs +46 -0
  6. package/dist/aws/aws-client.mjs.map +1 -0
  7. package/dist/aws/aws-kms-signer.d.mts +63 -0
  8. package/dist/aws/aws-kms-signer.d.mts.map +1 -0
  9. package/dist/aws/aws-kms-signer.mjs +78 -0
  10. package/dist/aws/aws-kms-signer.mjs.map +1 -0
  11. package/dist/aws/aws4fetch.d.mts +62 -0
  12. package/dist/aws/aws4fetch.d.mts.map +1 -0
  13. package/dist/aws/aws4fetch.mjs +313 -0
  14. package/dist/aws/aws4fetch.mjs.map +1 -0
  15. package/dist/aws/index.d.mts +3 -0
  16. package/dist/aws/index.mjs +3 -0
  17. package/dist/gcp/gcp-kms-client.d.mts +71 -0
  18. package/dist/gcp/gcp-kms-client.d.mts.map +1 -0
  19. package/dist/gcp/gcp-kms-client.mjs +104 -0
  20. package/dist/gcp/gcp-kms-client.mjs.map +1 -0
  21. package/dist/gcp/index.d.mts +2 -0
  22. package/dist/gcp/index.mjs +3 -0
  23. package/dist/ledger/index.d.mts +74 -0
  24. package/dist/ledger/index.d.mts.map +1 -0
  25. package/dist/ledger/index.mjs +110 -0
  26. package/dist/ledger/index.mjs.map +1 -0
  27. package/dist/ledger/objects.d.mts +10 -0
  28. package/dist/ledger/objects.d.mts.map +1 -0
  29. package/dist/ledger/objects.mjs +16 -0
  30. package/dist/ledger/objects.mjs.map +1 -0
  31. package/dist/utils/utils.mjs +71 -0
  32. package/dist/utils/utils.mjs.map +1 -0
  33. package/dist/webcrypto/index.d.mts +32 -0
  34. package/dist/webcrypto/index.d.mts.map +1 -0
  35. package/dist/webcrypto/index.mjs +70 -0
  36. package/dist/webcrypto/index.mjs.map +1 -0
  37. package/package.json +35 -29
  38. package/src/aws/aws-kms-signer.ts +0 -9
  39. package/src/gcp/gcp-kms-client.ts +0 -9
  40. package/src/ledger/index.ts +8 -9
  41. package/src/ledger/objects.ts +10 -34
  42. package/src/utils/utils.ts +18 -10
  43. package/src/webcrypto/index.ts +6 -3
  44. package/aws/package.json +0 -6
  45. package/dist/cjs/aws/aws-client.d.ts +0 -43
  46. package/dist/cjs/aws/aws-client.js +0 -79
  47. package/dist/cjs/aws/aws-client.js.map +0 -7
  48. package/dist/cjs/aws/aws-kms-signer.d.ts +0 -61
  49. package/dist/cjs/aws/aws-kms-signer.js +0 -114
  50. package/dist/cjs/aws/aws-kms-signer.js.map +0 -7
  51. package/dist/cjs/aws/aws4fetch.d.ts +0 -125
  52. package/dist/cjs/aws/aws4fetch.js +0 -382
  53. package/dist/cjs/aws/aws4fetch.js.map +0 -7
  54. package/dist/cjs/aws/index.d.ts +0 -5
  55. package/dist/cjs/aws/index.js +0 -25
  56. package/dist/cjs/aws/index.js.map +0 -7
  57. package/dist/cjs/gcp/gcp-kms-client.d.ts +0 -68
  58. package/dist/cjs/gcp/gcp-kms-client.js +0 -147
  59. package/dist/cjs/gcp/gcp-kms-client.js.map +0 -7
  60. package/dist/cjs/gcp/index.d.ts +0 -4
  61. package/dist/cjs/gcp/index.js +0 -25
  62. package/dist/cjs/gcp/index.js.map +0 -7
  63. package/dist/cjs/ledger/bcs.d.ts +0 -14
  64. package/dist/cjs/ledger/bcs.js +0 -85
  65. package/dist/cjs/ledger/bcs.js.map +0 -7
  66. package/dist/cjs/ledger/index.d.ts +0 -66
  67. package/dist/cjs/ledger/index.js +0 -158
  68. package/dist/cjs/ledger/index.js.map +0 -7
  69. package/dist/cjs/ledger/objects.d.ts +0 -5
  70. package/dist/cjs/ledger/objects.js +0 -60
  71. package/dist/cjs/ledger/objects.js.map +0 -7
  72. package/dist/cjs/package.json +0 -5
  73. package/dist/cjs/utils/utils.d.ts +0 -18
  74. package/dist/cjs/utils/utils.js +0 -85
  75. package/dist/cjs/utils/utils.js.map +0 -7
  76. package/dist/cjs/webcrypto/index.d.ts +0 -26
  77. package/dist/cjs/webcrypto/index.js +0 -112
  78. package/dist/cjs/webcrypto/index.js.map +0 -7
  79. package/dist/esm/aws/aws-client.d.ts +0 -43
  80. package/dist/esm/aws/aws-client.js +0 -59
  81. package/dist/esm/aws/aws-client.js.map +0 -7
  82. package/dist/esm/aws/aws-kms-signer.d.ts +0 -61
  83. package/dist/esm/aws/aws-kms-signer.js +0 -94
  84. package/dist/esm/aws/aws-kms-signer.js.map +0 -7
  85. package/dist/esm/aws/aws4fetch.d.ts +0 -125
  86. package/dist/esm/aws/aws4fetch.js +0 -362
  87. package/dist/esm/aws/aws4fetch.js.map +0 -7
  88. package/dist/esm/aws/index.d.ts +0 -5
  89. package/dist/esm/aws/index.js +0 -5
  90. package/dist/esm/aws/index.js.map +0 -7
  91. package/dist/esm/gcp/gcp-kms-client.d.ts +0 -68
  92. package/dist/esm/gcp/gcp-kms-client.js +0 -127
  93. package/dist/esm/gcp/gcp-kms-client.js.map +0 -7
  94. package/dist/esm/gcp/index.d.ts +0 -4
  95. package/dist/esm/gcp/index.js +0 -5
  96. package/dist/esm/gcp/index.js.map +0 -7
  97. package/dist/esm/ledger/bcs.d.ts +0 -14
  98. package/dist/esm/ledger/bcs.js +0 -70
  99. package/dist/esm/ledger/bcs.js.map +0 -7
  100. package/dist/esm/ledger/index.d.ts +0 -66
  101. package/dist/esm/ledger/index.js +0 -138
  102. package/dist/esm/ledger/index.js.map +0 -7
  103. package/dist/esm/ledger/objects.d.ts +0 -5
  104. package/dist/esm/ledger/objects.js +0 -40
  105. package/dist/esm/ledger/objects.js.map +0 -7
  106. package/dist/esm/package.json +0 -5
  107. package/dist/esm/utils/utils.d.ts +0 -18
  108. package/dist/esm/utils/utils.js +0 -65
  109. package/dist/esm/utils/utils.js.map +0 -7
  110. package/dist/esm/webcrypto/index.d.ts +0 -26
  111. package/dist/esm/webcrypto/index.js +0 -92
  112. package/dist/esm/webcrypto/index.js.map +0 -7
  113. package/dist/tsconfig.esm.tsbuildinfo +0 -1
  114. package/dist/tsconfig.tsbuildinfo +0 -1
  115. package/gcp/package.json +0 -6
  116. package/ledger/package.json +0 -6
  117. package/src/ledger/bcs.ts +0 -87
  118. package/webcrypto/package.json +0 -6
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/aws/aws4fetch.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Original implementation https://github.com/mhart/aws4fetch, inlined to reduce external dependencies\n * @license MIT <https://opensource.org/licenses/MIT>\n * @copyright Michael Hart 2024\n */\n\nconst encoder = new TextEncoder();\n\n/** @type {Record<string, string>} */\nconst HOST_SERVICES: Record<string, string> = {\n\tappstream2: 'appstream',\n\tcloudhsmv2: 'cloudhsm',\n\temail: 'ses',\n\tmarketplace: 'aws-marketplace',\n\tmobile: 'AWSMobileHubService',\n\tpinpoint: 'mobiletargeting',\n\tqueue: 'sqs',\n\t'git-codecommit': 'codecommit',\n\t'mturk-requester-sandbox': 'mturk-requester',\n\t'personalize-runtime': 'personalize',\n};\n\n// https://github.com/aws/aws-sdk-js/blob/cc29728c1c4178969ebabe3bbe6b6f3159436394/lib/signers/v4.js#L190-L198\nconst UNSIGNABLE_HEADERS = new Set([\n\t'authorization',\n\t'content-type',\n\t'content-length',\n\t'user-agent',\n\t'presigned-expires',\n\t'expect',\n\t'x-amzn-trace-id',\n\t'range',\n\t'connection',\n]);\n\ntype AwsRequestInit = RequestInit & {\n\taws?: {\n\t\taccessKeyId?: string;\n\t\tsecretAccessKey?: string;\n\t\tsessionToken?: string;\n\t\tservice?: string;\n\t\tregion?: string;\n\t\tcache?: Map<string, ArrayBuffer>;\n\t\tdatetime?: string;\n\t\tsignQuery?: boolean;\n\t\tappendSessionToken?: boolean;\n\t\tallHeaders?: boolean;\n\t\tsingleEncode?: boolean;\n\t};\n};\n\nexport class AwsClient {\n\taccessKeyId: string;\n\tsecretAccessKey: string;\n\tsessionToken: string | undefined;\n\tservice: string | undefined;\n\tregion: string | undefined;\n\tcache: Map<any, any>;\n\tretries: number;\n\tinitRetryMs: number;\n\t/**\n\t * @param {} options\n\t */\n\tconstructor({\n\t\taccessKeyId,\n\t\tsecretAccessKey,\n\t\tsessionToken,\n\t\tservice,\n\t\tregion,\n\t\tcache,\n\t\tretries,\n\t\tinitRetryMs,\n\t}: {\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t\tservice?: string;\n\t\tregion?: string;\n\t\tcache?: Map<string, ArrayBuffer>;\n\t\tretries?: number;\n\t\tinitRetryMs?: number;\n\t}) {\n\t\tif (accessKeyId == null) throw new TypeError('accessKeyId is a required option');\n\t\tif (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option');\n\t\tthis.accessKeyId = accessKeyId;\n\t\tthis.secretAccessKey = secretAccessKey;\n\t\tthis.sessionToken = sessionToken;\n\t\tthis.service = service;\n\t\tthis.region = region;\n\t\t/** @type {Map<string, ArrayBuffer>} */\n\t\tthis.cache = cache || new Map();\n\t\tthis.retries = retries != null ? retries : 10; // Up to 25.6 secs\n\t\tthis.initRetryMs = initRetryMs || 50;\n\t}\n\n\tasync sign(input: Request | { toString: () => string }, init: AwsRequestInit): Promise<Request> {\n\t\tif (input instanceof Request) {\n\t\t\tconst { method, url, headers, body } = input;\n\t\t\tinit = Object.assign({ method, url, headers }, init);\n\t\t\tif (init.body == null && headers.has('Content-Type')) {\n\t\t\t\tinit.body =\n\t\t\t\t\tbody != null && headers.has('X-Amz-Content-Sha256')\n\t\t\t\t\t\t? body\n\t\t\t\t\t\t: await input.clone().arrayBuffer();\n\t\t\t}\n\t\t\tinput = url;\n\t\t}\n\t\tconst signer = new AwsV4Signer(\n\t\t\tObject.assign({ url: input.toString() }, init, this, init && init.aws),\n\t\t);\n\t\tconst signed = Object.assign({}, init, await signer.sign());\n\t\tdelete signed.aws;\n\t\ttry {\n\t\t\treturn new Request(signed.url.toString(), signed);\n\t\t} catch (e) {\n\t\t\tif (e instanceof TypeError) {\n\t\t\t\t// https://bugs.chromium.org/p/chromium/issues/detail?id=1360943\n\t\t\t\treturn new Request(signed.url.toString(), Object.assign({ duplex: 'half' }, signed));\n\t\t\t}\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t/**\n\t * @param {Request | { toString: () => string }} input\n\t * @param {?AwsRequestInit} [init]\n\t * @returns {Promise<Response>}\n\t */\n\tasync fetch(input: Request | { toString: () => string }, init: AwsRequestInit) {\n\t\tfor (let i = 0; i <= this.retries; i++) {\n\t\t\tconst fetched = fetch(await this.sign(input, init));\n\t\t\tif (i === this.retries) {\n\t\t\t\treturn fetched; // No need to await if we're returning anyway\n\t\t\t}\n\t\t\tconst res = await fetched;\n\t\t\tif (res.status < 500 && res.status !== 429) {\n\t\t\t\treturn res;\n\t\t\t}\n\t\t\tawait new Promise((resolve) =>\n\t\t\t\tsetTimeout(resolve, Math.random() * this.initRetryMs * Math.pow(2, i)),\n\t\t\t);\n\t\t}\n\t\tthrow new Error('An unknown error occurred, ensure retries is not negative');\n\t}\n}\n\nexport class AwsV4Signer {\n\tmethod: any;\n\turl: URL;\n\theaders: Headers;\n\tbody: any;\n\taccessKeyId: any;\n\tsecretAccessKey: any;\n\tsessionToken: any;\n\tservice: any;\n\tregion: any;\n\tcache: any;\n\tdatetime: any;\n\tsignQuery: any;\n\tappendSessionToken: any;\n\tsignableHeaders: any[];\n\tsignedHeaders: any;\n\tcanonicalHeaders: any;\n\tcredentialString: string;\n\tencodedPath: string;\n\tencodedSearch: string;\n\t/**\n\t * @param {} options\n\t */\n\tconstructor({\n\t\tmethod,\n\t\turl,\n\t\theaders,\n\t\tbody,\n\t\taccessKeyId,\n\t\tsecretAccessKey,\n\t\tsessionToken,\n\t\tservice,\n\t\tregion,\n\t\tcache,\n\t\tdatetime,\n\t\tsignQuery,\n\t\tappendSessionToken,\n\t\tallHeaders,\n\t\tsingleEncode,\n\t}: {\n\t\tmethod?: string;\n\t\turl: string;\n\t\theaders?: HeadersInit;\n\t\tbody?: BodyInit | null;\n\t\taccessKeyId: string;\n\t\tsecretAccessKey: string;\n\t\tsessionToken?: string;\n\t\tservice?: string;\n\t\tregion?: string;\n\t\tcache?: Map<string, ArrayBuffer>;\n\t\tdatetime?: string;\n\t\tsignQuery?: boolean;\n\t\tappendSessionToken?: boolean;\n\t\tallHeaders?: boolean;\n\t\tsingleEncode?: boolean;\n\t}) {\n\t\tif (url == null) throw new TypeError('url is a required option');\n\t\tif (accessKeyId == null) throw new TypeError('accessKeyId is a required option');\n\t\tif (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option');\n\n\t\tthis.method = method || (body ? 'POST' : 'GET');\n\t\tthis.url = new URL(url);\n\t\tthis.headers = new Headers(headers || {});\n\t\tthis.body = body;\n\n\t\tthis.accessKeyId = accessKeyId;\n\t\tthis.secretAccessKey = secretAccessKey;\n\t\tthis.sessionToken = sessionToken;\n\n\t\tlet guessedService, guessedRegion;\n\t\tif (!service || !region) {\n\t\t\t[guessedService, guessedRegion] = guessServiceRegion(this.url, this.headers);\n\t\t}\n\t\tthis.service = service || guessedService || '';\n\t\tthis.region = region || guessedRegion || 'us-east-1';\n\n\t\t/** @type {Map<string, ArrayBuffer>} */\n\t\tthis.cache = cache || new Map();\n\t\tthis.datetime = datetime || new Date().toISOString().replace(/[:-]|\\.\\d{3}/g, '');\n\t\tthis.signQuery = signQuery;\n\t\tthis.appendSessionToken = appendSessionToken || this.service === 'iotdevicegateway';\n\n\t\tthis.headers.delete('Host'); // Can't be set in insecure env anyway\n\n\t\tif (this.service === 's3' && !this.signQuery && !this.headers.has('X-Amz-Content-Sha256')) {\n\t\t\tthis.headers.set('X-Amz-Content-Sha256', 'UNSIGNED-PAYLOAD');\n\t\t}\n\n\t\tconst params = this.signQuery ? this.url.searchParams : this.headers;\n\n\t\tparams.set('X-Amz-Date', this.datetime);\n\t\tif (this.sessionToken && !this.appendSessionToken) {\n\t\t\tparams.set('X-Amz-Security-Token', this.sessionToken);\n\t\t}\n\n\t\t// headers are always lowercase in keys()\n\n\t\tthis.signableHeaders = ['host', ...((this.headers as any).keys() as string[])]\n\t\t\t.filter((header) => allHeaders || !UNSIGNABLE_HEADERS.has(header))\n\t\t\t.sort();\n\n\t\tthis.signedHeaders = this.signableHeaders.join(';');\n\n\t\t// headers are always trimmed:\n\t\t// https://fetch.spec.whatwg.org/#concept-header-value-normalize\n\t\tthis.canonicalHeaders = this.signableHeaders\n\t\t\t.map(\n\t\t\t\t(header) =>\n\t\t\t\t\theader +\n\t\t\t\t\t':' +\n\t\t\t\t\t(header === 'host'\n\t\t\t\t\t\t? this.url.host\n\t\t\t\t\t\t: (this.headers.get(header) || '').replace(/\\s+/g, ' ')),\n\t\t\t)\n\t\t\t.join('\\n');\n\n\t\tthis.credentialString = [\n\t\t\tthis.datetime.slice(0, 8),\n\t\t\tthis.region,\n\t\t\tthis.service,\n\t\t\t'aws4_request',\n\t\t].join('/');\n\n\t\tif (this.signQuery) {\n\t\t\tif (this.service === 's3' && !params.has('X-Amz-Expires')) {\n\t\t\t\tparams.set('X-Amz-Expires', '86400'); // 24 hours\n\t\t\t}\n\t\t\tparams.set('X-Amz-Algorithm', 'AWS4-HMAC-SHA256');\n\t\t\tparams.set('X-Amz-Credential', this.accessKeyId + '/' + this.credentialString);\n\t\t\tparams.set('X-Amz-SignedHeaders', this.signedHeaders);\n\t\t}\n\n\t\tif (this.service === 's3') {\n\t\t\ttry {\n\t\t\t\tthis.encodedPath = decodeURIComponent(this.url.pathname.replace(/\\+/g, ' '));\n\t\t\t} catch {\n\t\t\t\tthis.encodedPath = this.url.pathname;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.encodedPath = this.url.pathname.replace(/\\/+/g, '/');\n\t\t}\n\t\tif (!singleEncode) {\n\t\t\tthis.encodedPath = encodeURIComponent(this.encodedPath).replace(/%2F/g, '/');\n\t\t}\n\t\tthis.encodedPath = encodeRfc3986(this.encodedPath);\n\n\t\tconst seenKeys = new Set();\n\t\tthis.encodedSearch = [...this.url.searchParams]\n\t\t\t.filter(([k]) => {\n\t\t\t\tif (!k) return false; // no empty keys\n\t\t\t\tif (this.service === 's3') {\n\t\t\t\t\tif (seenKeys.has(k)) return false; // first val only for S3\n\t\t\t\t\tseenKeys.add(k);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t})\n\t\t\t.map((pair) => pair.map((p) => encodeRfc3986(encodeURIComponent(p))))\n\t\t\t.sort(([k1, v1], [k2, v2]) => (k1 < k2 ? -1 : k1 > k2 ? 1 : v1 < v2 ? -1 : v1 > v2 ? 1 : 0))\n\t\t\t.map((pair) => pair.join('='))\n\t\t\t.join('&');\n\t}\n\n\t/**\n\t * @returns {Promise<{\n\t * method: string\n\t * url: URL\n\t * headers: Headers\n\t * body?: BodyInit | null\n\t * }>}\n\t */\n\tasync sign() {\n\t\tif (this.signQuery) {\n\t\t\tthis.url.searchParams.set('X-Amz-Signature', await this.signature());\n\t\t\tif (this.sessionToken && this.appendSessionToken) {\n\t\t\t\tthis.url.searchParams.set('X-Amz-Security-Token', this.sessionToken);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.headers.set('Authorization', await this.authHeader());\n\t\t}\n\n\t\treturn {\n\t\t\tmethod: this.method,\n\t\t\turl: this.url,\n\t\t\theaders: this.headers,\n\t\t\tbody: this.body,\n\t\t};\n\t}\n\n\t/**\n\t * @returns {Promise<string>}\n\t */\n\tasync authHeader() {\n\t\treturn [\n\t\t\t'AWS4-HMAC-SHA256 Credential=' + this.accessKeyId + '/' + this.credentialString,\n\t\t\t'SignedHeaders=' + this.signedHeaders,\n\t\t\t'Signature=' + (await this.signature()),\n\t\t].join(', ');\n\t}\n\n\t/**\n\t * @returns {Promise<string>}\n\t */\n\tasync signature() {\n\t\tconst date = this.datetime.slice(0, 8);\n\t\tconst cacheKey = [this.secretAccessKey, date, this.region, this.service].join();\n\t\tlet kCredentials = this.cache.get(cacheKey);\n\t\tif (!kCredentials) {\n\t\t\tconst kDate = await hmac('AWS4' + this.secretAccessKey, date);\n\t\t\tconst kRegion = await hmac(kDate, this.region);\n\t\t\tconst kService = await hmac(kRegion, this.service);\n\t\t\tkCredentials = await hmac(kService, 'aws4_request');\n\t\t\tthis.cache.set(cacheKey, kCredentials);\n\t\t}\n\t\treturn buf2hex(await hmac(kCredentials, await this.stringToSign()));\n\t}\n\n\t/**\n\t * @returns {Promise<string>}\n\t */\n\tasync stringToSign() {\n\t\treturn [\n\t\t\t'AWS4-HMAC-SHA256',\n\t\t\tthis.datetime,\n\t\t\tthis.credentialString,\n\t\t\tbuf2hex(await hash(await this.canonicalString())),\n\t\t].join('\\n');\n\t}\n\n\t/**\n\t * @returns {Promise<string>}\n\t */\n\tasync canonicalString() {\n\t\treturn [\n\t\t\tthis.method.toUpperCase(),\n\t\t\tthis.encodedPath,\n\t\t\tthis.encodedSearch,\n\t\t\tthis.canonicalHeaders + '\\n',\n\t\t\tthis.signedHeaders,\n\t\t\tawait this.hexBodyHash(),\n\t\t].join('\\n');\n\t}\n\n\t/**\n\t * @returns {Promise<string>}\n\t */\n\tasync hexBodyHash() {\n\t\tlet hashHeader =\n\t\t\tthis.headers.get('X-Amz-Content-Sha256') ||\n\t\t\t(this.service === 's3' && this.signQuery ? 'UNSIGNED-PAYLOAD' : null);\n\t\tif (hashHeader == null) {\n\t\t\tif (this.body && typeof this.body !== 'string' && !('byteLength' in this.body)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header',\n\t\t\t\t);\n\t\t\t}\n\t\t\thashHeader = buf2hex(await hash(this.body || ''));\n\t\t}\n\t\treturn hashHeader;\n\t}\n}\n\n/**\n * @param {string | BufferSource} key\n * @param {string} string\n * @returns {Promise<ArrayBuffer>}\n */\nasync function hmac(key: string | BufferSource, string: string): Promise<ArrayBuffer> {\n\tconst cryptoKey = await crypto.subtle.importKey(\n\t\t'raw',\n\t\ttypeof key === 'string' ? encoder.encode(key) : key,\n\t\t{ name: 'HMAC', hash: { name: 'SHA-256' } },\n\t\tfalse,\n\t\t['sign'],\n\t);\n\treturn crypto.subtle.sign('HMAC', cryptoKey, encoder.encode(string));\n}\n\nasync function hash(content: string | ArrayBufferLike): Promise<ArrayBuffer> {\n\treturn crypto.subtle.digest(\n\t\t'SHA-256',\n\t\t(typeof content === 'string' ? encoder.encode(content) : content) as ArrayBuffer,\n\t);\n}\n\nconst HEX_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];\n\nfunction buf2hex(arrayBuffer: ArrayBufferLike): string {\n\tconst buffer = new Uint8Array(arrayBuffer);\n\tlet out = '';\n\tfor (let idx = 0; idx < buffer.length; idx++) {\n\t\tconst n = buffer[idx];\n\n\t\tout += HEX_CHARS[(n >>> 4) & 0xf];\n\t\tout += HEX_CHARS[n & 0xf];\n\t}\n\treturn out;\n}\n\nfunction encodeRfc3986(urlEncodedStr: string): string {\n\treturn urlEncodedStr.replace(/[!'()*]/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase());\n}\n\nfunction guessServiceRegion(url: URL, headers: Headers): [string, string] {\n\tconst { hostname, pathname } = url;\n\n\tif (hostname.endsWith('.on.aws')) {\n\t\tconst match = hostname.match(/^[^.]{1,63}\\.lambda-url\\.([^.]{1,63})\\.on\\.aws$/);\n\t\treturn match != null ? ['lambda', match[1] || ''] : ['', ''];\n\t}\n\tif (hostname.endsWith('.r2.cloudflarestorage.com')) {\n\t\treturn ['s3', 'auto'];\n\t}\n\tif (hostname.endsWith('.backblazeb2.com')) {\n\t\tconst match = hostname.match(/^(?:[^.]{1,63}\\.)?s3\\.([^.]{1,63})\\.backblazeb2\\.com$/);\n\t\treturn match != null ? ['s3', match[1] || ''] : ['', ''];\n\t}\n\tconst match = hostname\n\t\t.replace('dualstack.', '')\n\t\t.match(/([^.]{1,63})\\.(?:([^.]{0,63})\\.)?amazonaws\\.com(?:\\.cn)?$/);\n\tlet service = (match && match[1]) || '';\n\tlet region = match && match[2];\n\n\tif (region === 'us-gov') {\n\t\tregion = 'us-gov-west-1';\n\t} else if (region === 's3' || region === 's3-accelerate') {\n\t\tregion = 'us-east-1';\n\t\tservice = 's3';\n\t} else if (service === 'iot') {\n\t\tif (hostname.startsWith('iot.')) {\n\t\t\tservice = 'execute-api';\n\t\t} else if (hostname.startsWith('data.jobs.iot.')) {\n\t\t\tservice = 'iot-jobs-data';\n\t\t} else {\n\t\t\tservice = pathname === '/mqtt' ? 'iotdevicegateway' : 'iotdata';\n\t\t}\n\t} else if (service === 'autoscaling') {\n\t\tconst targetPrefix = (headers.get('X-Amz-Target') || '').split('.')[0];\n\t\tif (targetPrefix === 'AnyScaleFrontendService') {\n\t\t\tservice = 'application-autoscaling';\n\t\t} else if (targetPrefix === 'AnyScaleScalingPlannerFrontendService') {\n\t\t\tservice = 'autoscaling-plans';\n\t\t}\n\t} else if (region == null && service.startsWith('s3-')) {\n\t\tregion = service.slice(3).replace(/^fips-|^external-1/, '');\n\t\tservice = 's3';\n\t} else if (service.endsWith('-fips')) {\n\t\tservice = service.slice(0, -5);\n\t} else if (region && /-\\d$/.test(service) && !/-\\d$/.test(region)) {\n\t\t[service, region] = [region, service];\n\t}\n\n\treturn [HOST_SERVICES[service] || service, region || ''];\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA;AAAA;AAAA;AAAA;AAAA;AAMA,MAAM,UAAU,IAAI,YAAY;AAGhC,MAAM,gBAAwC;AAAA,EAC7C,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,2BAA2B;AAAA,EA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;AACA,QAAM,QAAQ,SACZ,QAAQ,cAAc,EAAE,EACxB,MAAM,2DAA2D;AACnE,MAAI,UAAW,SAAS,MAAM,CAAC,KAAM;AACrC,MAAI,SAAS,SAAS,MAAM,CAAC;AAE7B,MAAI,WAAW,UAAU;AACxB,aAAS;AAAA,EACV,WAAW,WAAW,QAAQ,WAAW,iBAAiB;AACzD,aAAS;AACT,cAAU;AAAA,EACX,WAAW,YAAY,OAAO;AAC7B,QAAI,SAAS,WAAW,MAAM,GAAG;AAChC,gBAAU;AAAA,IACX,WAAW,SAAS,WAAW,gBAAgB,GAAG;AACjD,gBAAU;AAAA,IACX,OAAO;AACN,gBAAU,aAAa,UAAU,qBAAqB;AAAA,IACvD;AAAA,EACD,WAAW,YAAY,eAAe;AACrC,UAAM,gBAAgB,QAAQ,IAAI,cAAc,KAAK,IAAI,MAAM,GAAG,EAAE,CAAC;AACrE,QAAI,iBAAiB,2BAA2B;AAC/C,gBAAU;AAAA,IACX,WAAW,iBAAiB,yCAAyC;AACpE,gBAAU;AAAA,IACX;AAAA,EACD,WAAW,UAAU,QAAQ,QAAQ,WAAW,KAAK,GAAG;AACvD,aAAS,QAAQ,MAAM,CAAC,EAAE,QAAQ,sBAAsB,EAAE;AAC1D,cAAU;AAAA,EACX,WAAW,QAAQ,SAAS,OAAO,GAAG;AACrC,cAAU,QAAQ,MAAM,GAAG,EAAE;AAAA,EAC9B,WAAW,UAAU,OAAO,KAAK,OAAO,KAAK,CAAC,OAAO,KAAK,MAAM,GAAG;AAClE,KAAC,SAAS,MAAM,IAAI,CAAC,QAAQ,OAAO;AAAA,EACrC;AAEA,SAAO,CAAC,cAAc,OAAO,KAAK,SAAS,UAAU,EAAE;AACxD;",
6
- "names": ["match"]
7
- }
@@ -1,5 +0,0 @@
1
- import type { AwsClientOptions } from './aws-client.js';
2
- import type { AwsKmsSignerOptions } from './aws-kms-signer.js';
3
- import { AwsKmsSigner } from './aws-kms-signer.js';
4
- export { AwsKmsSigner };
5
- export type { AwsKmsSignerOptions, AwsClientOptions };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var aws_exports = {};
20
- __export(aws_exports, {
21
- AwsKmsSigner: () => import_aws_kms_signer.AwsKmsSigner
22
- });
23
- module.exports = __toCommonJS(aws_exports);
24
- var import_aws_kms_signer = require("./aws-kms-signer.js");
25
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/aws/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { AwsClientOptions } from './aws-client.js';\nimport type { AwsKmsSignerOptions } from './aws-kms-signer.js';\nimport { AwsKmsSigner } from './aws-kms-signer.js';\n\nexport { AwsKmsSigner };\n\nexport type { AwsKmsSignerOptions, AwsClientOptions };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,4BAA6B;",
6
- "names": []
7
- }
@@ -1,68 +0,0 @@
1
- import { KeyManagementServiceClient } from '@google-cloud/kms';
2
- import type { PublicKey } from '@haneullabs/haneul/cryptography';
3
- import { Signer } from '@haneullabs/haneul/cryptography';
4
- /**
5
- * Configuration options for initializing the GcpKmsSigner.
6
- */
7
- export interface GcpKmsSignerOptions {
8
- /** The version name generated from `client.cryptoKeyVersionPath()` */
9
- versionName: string;
10
- /** Options for setting up the GCP KMS client */
11
- client: KeyManagementServiceClient;
12
- /** Public key */
13
- publicKey: PublicKey;
14
- }
15
- /**
16
- * GCP KMS Signer integrates GCP Key Management Service (KMS) with the Haneul blockchain
17
- * to provide signing capabilities using GCP-managed cryptographic keys.
18
- */
19
- export declare class GcpKmsSigner extends Signer {
20
- #private;
21
- /**
22
- * Creates an instance of GcpKmsSigner. It's expected to call the static `fromOptions`
23
- * or `fromVersionName` method to create an instance.
24
- * For example:
25
- * ```
26
- * const signer = await GcpKmsSigner.fromVersionName(versionName);
27
- * ```
28
- * @throws Will throw an error if required GCP credentials are not provided.
29
- */
30
- constructor({ versionName, client, publicKey }: GcpKmsSignerOptions);
31
- /**
32
- * Retrieves the key scheme used by this signer.
33
- * @returns GCP supports only `Secp256k1` and `Secp256r1` schemes.
34
- */
35
- getKeyScheme(): "Secp256k1" | "Secp256r1" | "ED25519" | "MultiSig" | "ZkLogin" | "Passkey";
36
- /**
37
- * Retrieves the public key associated with this signer.
38
- * @returns The Secp256k1PublicKey instance.
39
- * @throws Will throw an error if the public key has not been initialized.
40
- */
41
- getPublicKey(): PublicKey;
42
- /**
43
- * Signs the given data using GCP KMS.
44
- * @param bytes - The data to be signed as a Uint8Array.
45
- * @returns A promise that resolves to the signature as a Uint8Array.
46
- * @throws Will throw an error if the public key is not initialized or if signing fails.
47
- */
48
- sign(bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
49
- /**
50
- * Synchronous signing is not supported by GCP KMS.
51
- * @throws Always throws an error indicating synchronous signing is unsupported.
52
- * @deprecated use `sign` instead
53
- */
54
- signData(): never;
55
- /**
56
- * Creates a GCP KMS signer from the provided options.
57
- * Expects the credentials file to be set as an env variable
58
- * (GOOGLE_APPLICATION_CREDENTIALS).
59
- */
60
- static fromOptions(options: {
61
- projectId: string;
62
- location: string;
63
- keyRing: string;
64
- cryptoKey: string;
65
- cryptoKeyVersion: string;
66
- }): Promise<GcpKmsSigner>;
67
- static fromVersionName(versionName: string): Promise<GcpKmsSigner>;
68
- }
@@ -1,147 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __typeError = (msg) => {
7
- throw TypeError(msg);
8
- };
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
26
- var gcp_kms_client_exports = {};
27
- __export(gcp_kms_client_exports, {
28
- GcpKmsSigner: () => GcpKmsSigner
29
- });
30
- module.exports = __toCommonJS(gcp_kms_client_exports);
31
- var import_kms = require("@google-cloud/kms");
32
- var import_cryptography = require("@haneullabs/haneul/cryptography");
33
- var import_secp256k1 = require("@haneullabs/haneul/keypairs/secp256k1");
34
- var import_secp256r1 = require("@haneullabs/haneul/keypairs/secp256r1");
35
- var import_utils = require("@haneullabs/haneul/utils");
36
- var import_utils2 = require("../utils/utils.js");
37
- var _publicKey, _client, _versionName;
38
- const _GcpKmsSigner = class _GcpKmsSigner extends import_cryptography.Signer {
39
- /**
40
- * Creates an instance of GcpKmsSigner. It's expected to call the static `fromOptions`
41
- * or `fromVersionName` method to create an instance.
42
- * For example:
43
- * ```
44
- * const signer = await GcpKmsSigner.fromVersionName(versionName);
45
- * ```
46
- * @throws Will throw an error if required GCP credentials are not provided.
47
- */
48
- constructor({ versionName, client, publicKey }) {
49
- super();
50
- __privateAdd(this, _publicKey);
51
- /** GCP KMS client instance */
52
- __privateAdd(this, _client);
53
- /** GCP KMS version name (generated from `client.cryptoKeyVersionPath()`) */
54
- __privateAdd(this, _versionName);
55
- if (!versionName) throw new Error("Version name is required");
56
- __privateSet(this, _client, client);
57
- __privateSet(this, _versionName, versionName);
58
- __privateSet(this, _publicKey, publicKey);
59
- }
60
- /**
61
- * Retrieves the key scheme used by this signer.
62
- * @returns GCP supports only `Secp256k1` and `Secp256r1` schemes.
63
- */
64
- getKeyScheme() {
65
- return import_cryptography.SIGNATURE_FLAG_TO_SCHEME[__privateGet(this, _publicKey).flag()];
66
- }
67
- /**
68
- * Retrieves the public key associated with this signer.
69
- * @returns The Secp256k1PublicKey instance.
70
- * @throws Will throw an error if the public key has not been initialized.
71
- */
72
- getPublicKey() {
73
- return __privateGet(this, _publicKey);
74
- }
75
- /**
76
- * Signs the given data using GCP KMS.
77
- * @param bytes - The data to be signed as a Uint8Array.
78
- * @returns A promise that resolves to the signature as a Uint8Array.
79
- * @throws Will throw an error if the public key is not initialized or if signing fails.
80
- */
81
- async sign(bytes) {
82
- const [signResponse] = await __privateGet(this, _client).asymmetricSign({
83
- name: __privateGet(this, _versionName),
84
- data: bytes
85
- });
86
- if (!signResponse.signature) {
87
- throw new Error("No signature returned from GCP KMS");
88
- }
89
- return (0, import_utils2.getConcatenatedSignature)(signResponse.signature, this.getKeyScheme());
90
- }
91
- /**
92
- * Synchronous signing is not supported by GCP KMS.
93
- * @throws Always throws an error indicating synchronous signing is unsupported.
94
- * @deprecated use `sign` instead
95
- */
96
- signData() {
97
- throw new Error("GCP Signer does not support sync signing");
98
- }
99
- /**
100
- * Creates a GCP KMS signer from the provided options.
101
- * Expects the credentials file to be set as an env variable
102
- * (GOOGLE_APPLICATION_CREDENTIALS).
103
- */
104
- static async fromOptions(options) {
105
- const client = new import_kms.KeyManagementServiceClient();
106
- const versionName = client.cryptoKeyVersionPath(
107
- options.projectId,
108
- options.location,
109
- options.keyRing,
110
- options.cryptoKey,
111
- options.cryptoKeyVersion
112
- );
113
- return new _GcpKmsSigner({
114
- versionName,
115
- client,
116
- publicKey: await getPublicKey(client, versionName)
117
- });
118
- }
119
- static async fromVersionName(versionName) {
120
- const client = new import_kms.KeyManagementServiceClient();
121
- return new _GcpKmsSigner({
122
- versionName,
123
- client,
124
- publicKey: await getPublicKey(client, versionName)
125
- });
126
- }
127
- };
128
- _publicKey = new WeakMap();
129
- _client = new WeakMap();
130
- _versionName = new WeakMap();
131
- let GcpKmsSigner = _GcpKmsSigner;
132
- async function getPublicKey(client, versionName) {
133
- const [publicKey] = await client.getPublicKey({ name: versionName });
134
- const { algorithm, pem } = publicKey;
135
- if (!pem) throw new Error("No PEM key returned from GCP KMS");
136
- const base64 = pem.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").replace(/\s/g, "");
137
- const compressedKey = (0, import_utils2.publicKeyFromDER)((0, import_utils.fromBase64)(base64));
138
- switch (algorithm) {
139
- case "EC_SIGN_SECP256K1_SHA256":
140
- return new import_secp256k1.Secp256k1PublicKey(compressedKey);
141
- case "EC_SIGN_P256_SHA256":
142
- return new import_secp256r1.Secp256r1PublicKey(compressedKey);
143
- default:
144
- throw new Error(`Unsupported algorithm: ${algorithm}`);
145
- }
146
- }
147
- //# sourceMappingURL=gcp-kms-client.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/gcp/gcp-kms-client.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { KeyManagementServiceClient } from '@google-cloud/kms';\nimport type { PublicKey, SignatureFlag } from '@haneullabs/haneul/cryptography';\nimport { SIGNATURE_FLAG_TO_SCHEME, Signer } from '@haneullabs/haneul/cryptography';\nimport { Secp256k1PublicKey } from '@haneullabs/haneul/keypairs/secp256k1';\nimport { Secp256r1PublicKey } from '@haneullabs/haneul/keypairs/secp256r1';\nimport { fromBase64 } from '@haneullabs/haneul/utils';\n\nimport { getConcatenatedSignature, publicKeyFromDER } from '../utils/utils.js';\n\n/**\n * Configuration options for initializing the GcpKmsSigner.\n */\nexport interface GcpKmsSignerOptions {\n\t/** The version name generated from `client.cryptoKeyVersionPath()` */\n\tversionName: string;\n\t/** Options for setting up the GCP KMS client */\n\tclient: KeyManagementServiceClient;\n\t/** Public key */\n\tpublicKey: PublicKey;\n}\n\n/**\n * GCP KMS Signer integrates GCP Key Management Service (KMS) with the Haneul blockchain\n * to provide signing capabilities using GCP-managed cryptographic keys.\n */\nexport class GcpKmsSigner extends Signer {\n\t#publicKey: PublicKey;\n\t/** GCP KMS client instance */\n\t#client: KeyManagementServiceClient;\n\t/** GCP KMS version name (generated from `client.cryptoKeyVersionPath()`) */\n\t#versionName: string;\n\n\t/**\n\t * Creates an instance of GcpKmsSigner. It's expected to call the static `fromOptions`\n\t * or `fromVersionName` method to create an instance.\n\t * For example:\n\t * ```\n\t * const signer = await GcpKmsSigner.fromVersionName(versionName);\n\t * ```\n\t * @throws Will throw an error if required GCP credentials are not provided.\n\t */\n\tconstructor({ versionName, client, publicKey }: GcpKmsSignerOptions) {\n\t\tsuper();\n\t\tif (!versionName) throw new Error('Version name is required');\n\n\t\tthis.#client = client;\n\t\tthis.#versionName = versionName;\n\t\tthis.#publicKey = publicKey;\n\t}\n\n\t/**\n\t * Retrieves the key scheme used by this signer.\n\t * @returns GCP supports only `Secp256k1` and `Secp256r1` schemes.\n\t */\n\tgetKeyScheme() {\n\t\treturn SIGNATURE_FLAG_TO_SCHEME[this.#publicKey.flag() as SignatureFlag];\n\t}\n\n\t/**\n\t * Retrieves the public key associated with this signer.\n\t * @returns The Secp256k1PublicKey instance.\n\t * @throws Will throw an error if the public key has not been initialized.\n\t */\n\tgetPublicKey() {\n\t\treturn this.#publicKey;\n\t}\n\n\t/**\n\t * Signs the given data using GCP KMS.\n\t * @param bytes - The data to be signed as a Uint8Array.\n\t * @returns A promise that resolves to the signature as a Uint8Array.\n\t * @throws Will throw an error if the public key is not initialized or if signing fails.\n\t */\n\tasync sign(bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>> {\n\t\tconst [signResponse] = await this.#client.asymmetricSign({\n\t\t\tname: this.#versionName,\n\t\t\tdata: bytes,\n\t\t});\n\n\t\tif (!signResponse.signature) {\n\t\t\tthrow new Error('No signature returned from GCP KMS');\n\t\t}\n\n\t\treturn getConcatenatedSignature(signResponse.signature as Uint8Array, this.getKeyScheme());\n\t}\n\n\t/**\n\t * Synchronous signing is not supported by GCP KMS.\n\t * @throws Always throws an error indicating synchronous signing is unsupported.\n\t * @deprecated use `sign` instead\n\t */\n\tsignData(): never {\n\t\tthrow new Error('GCP Signer does not support sync signing');\n\t}\n\n\t/**\n\t * Creates a GCP KMS signer from the provided options.\n\t * Expects the credentials file to be set as an env variable\n\t * (GOOGLE_APPLICATION_CREDENTIALS).\n\t */\n\tstatic async fromOptions(options: {\n\t\tprojectId: string;\n\t\tlocation: string;\n\t\tkeyRing: string;\n\t\tcryptoKey: string;\n\t\tcryptoKeyVersion: string;\n\t}) {\n\t\tconst client = new KeyManagementServiceClient();\n\n\t\tconst versionName = client.cryptoKeyVersionPath(\n\t\t\toptions.projectId,\n\t\t\toptions.location,\n\t\t\toptions.keyRing,\n\t\t\toptions.cryptoKey,\n\t\t\toptions.cryptoKeyVersion,\n\t\t);\n\n\t\treturn new GcpKmsSigner({\n\t\t\tversionName,\n\t\t\tclient,\n\t\t\tpublicKey: await getPublicKey(client, versionName),\n\t\t});\n\t}\n\n\tstatic async fromVersionName(versionName: string) {\n\t\tconst client = new KeyManagementServiceClient();\n\t\treturn new GcpKmsSigner({\n\t\t\tversionName,\n\t\t\tclient,\n\t\t\tpublicKey: await getPublicKey(client, versionName),\n\t\t});\n\t}\n}\n\n/**\n * Retrieves the public key associated with the given version name.\n */\nasync function getPublicKey(\n\tclient: KeyManagementServiceClient,\n\tversionName: string,\n): Promise<PublicKey> {\n\tconst [publicKey] = await client.getPublicKey({ name: versionName });\n\n\tconst { algorithm, pem } = publicKey;\n\n\tif (!pem) throw new Error('No PEM key returned from GCP KMS');\n\n\tconst base64 = pem\n\t\t.replace('-----BEGIN PUBLIC KEY-----', '')\n\t\t.replace('-----END PUBLIC KEY-----', '')\n\t\t.replace(/\\s/g, '');\n\n\tconst compressedKey = publicKeyFromDER(fromBase64(base64));\n\n\tswitch (algorithm) {\n\t\tcase 'EC_SIGN_SECP256K1_SHA256':\n\t\t\treturn new Secp256k1PublicKey(compressedKey);\n\t\tcase 'EC_SIGN_P256_SHA256':\n\t\t\treturn new Secp256r1PublicKey(compressedKey);\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported algorithm: ${algorithm}`);\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAA2C;AAE3C,0BAAiD;AACjD,uBAAmC;AACnC,uBAAmC;AACnC,mBAA2B;AAE3B,IAAAA,gBAA2D;AAT3D;AA2BO,MAAM,gBAAN,MAAM,sBAAqB,2BAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBxC,YAAY,EAAE,aAAa,QAAQ,UAAU,GAAwB;AACpE,UAAM;AAhBP;AAEA;AAAA;AAEA;AAAA;AAaC,QAAI,CAAC,YAAa,OAAM,IAAI,MAAM,0BAA0B;AAE5D,uBA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,aACd,QACA,aACqB;AACrB,QAAM,CAAC,SAAS,IAAI,MAAM,OAAO,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnE,QAAM,EAAE,WAAW,IAAI,IAAI;AAE3B,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,kCAAkC;AAE5D,QAAM,SAAS,IACb,QAAQ,8BAA8B,EAAE,EACxC,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,OAAO,EAAE;AAEnB,QAAM,oBAAgB,oCAAiB,yBAAW,MAAM,CAAC;AAEzD,UAAQ,WAAW;AAAA,IAClB,KAAK;AACJ,aAAO,IAAI,oCAAmB,aAAa;AAAA,IAC5C,KAAK;AACJ,aAAO,IAAI,oCAAmB,aAAa;AAAA,IAC5C;AACC,YAAM,IAAI,MAAM,0BAA0B,SAAS,EAAE;AAAA,EACvD;AACD;",
6
- "names": ["import_utils"]
7
- }
@@ -1,4 +0,0 @@
1
- import type { GcpKmsSignerOptions } from './gcp-kms-client.js';
2
- import { GcpKmsSigner } from './gcp-kms-client.js';
3
- export { GcpKmsSigner };
4
- export type { GcpKmsSignerOptions };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var gcp_exports = {};
20
- __export(gcp_exports, {
21
- GcpKmsSigner: () => import_gcp_kms_client.GcpKmsSigner
22
- });
23
- module.exports = __toCommonJS(gcp_exports);
24
- var import_gcp_kms_client = require("./gcp-kms-client.js");
25
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/gcp/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { GcpKmsSignerOptions } from './gcp-kms-client.js';\nimport { GcpKmsSigner } from './gcp-kms-client.js';\n\nexport { GcpKmsSigner };\n\nexport type { GcpKmsSignerOptions };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,4BAA6B;",
6
- "names": []
7
- }
@@ -1,14 +0,0 @@
1
- import type { ObjectOwner } from '@haneullabs/haneul/client';
2
- export declare const HaneulMoveObject: import("@haneullabs/haneul/bcs").BcsStruct<{
3
- data: import("@haneullabs/haneul/bcs").BcsEnum<{
4
- MoveObject: import("@haneullabs/haneul/bcs").BcsStruct<{
5
- type: import("@haneullabs/haneul/bcs").BcsType<any, string, string>;
6
- hasPublicTransfer: import("@haneullabs/haneul/bcs").BcsType<boolean, boolean, "bool">;
7
- version: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
8
- contents: import("@haneullabs/haneul/bcs").BcsType<any, string, string>;
9
- }, string>;
10
- }, "Data">;
11
- owner: import("@haneullabs/haneul/bcs").BcsType<any, ObjectOwner, string>;
12
- previousTransaction: import("@haneullabs/haneul/bcs").BcsType<string, string, "ObjectDigest">;
13
- storageRebate: import("@haneullabs/haneul/bcs").BcsType<string, string | number | bigint, "u64">;
14
- }, string>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var bcs_exports = {};
20
- __export(bcs_exports, {
21
- HaneulMoveObject: () => HaneulMoveObject
22
- });
23
- module.exports = __toCommonJS(bcs_exports);
24
- var import_bcs = require("@haneullabs/haneul/bcs");
25
- var import_utils = require("@haneullabs/haneul/utils");
26
- const HANEUL_FRAMEWORK_ADDRESS = (0, import_utils.normalizeHaneulAddress)("0x2");
27
- const HANEUL_SYSTEM_ADDRESS = (0, import_utils.normalizeHaneulAddress)("0x3");
28
- const MoveObjectType = import_bcs.bcs.enum("MoveObjectType", {
29
- Other: import_bcs.bcs.StructTag,
30
- GasCoin: null,
31
- StakedSui: null,
32
- Coin: import_bcs.bcs.TypeTag
33
- });
34
- const HaneulMoveObject = import_bcs.bcs.struct("HaneulMoveObject", {
35
- data: import_bcs.bcs.enum("Data", {
36
- MoveObject: import_bcs.bcs.struct("MoveObject", {
37
- type: MoveObjectType.transform({
38
- input: (objectType) => {
39
- const structTag = (0, import_utils.parseStructTag)(objectType);
40
- if (structTag.address === HANEUL_FRAMEWORK_ADDRESS && structTag.module === "coin" && structTag.name === "Coin" && typeof structTag.typeParams[0] === "object") {
41
- const innerStructTag = structTag.typeParams[0];
42
- if (innerStructTag.address === HANEUL_FRAMEWORK_ADDRESS && innerStructTag.module === "haneul" && innerStructTag.name === "SUI") {
43
- return { GasCoin: true, $kind: "GasCoin" };
44
- }
45
- return { Coin: (0, import_utils.normalizeStructTag)(innerStructTag), $kind: "Coin" };
46
- } else if (structTag.address === HANEUL_SYSTEM_ADDRESS && structTag.module === "staking_pool" && structTag.name === "StakedSui") {
47
- return { StakedSui: true, $kind: "StakedSui" };
48
- }
49
- return {
50
- Other: {
51
- ...structTag,
52
- typeParams: structTag.typeParams.map((typeParam) => {
53
- return import_bcs.TypeTagSerializer.parseFromStr((0, import_utils.normalizeStructTag)(typeParam));
54
- })
55
- },
56
- $kind: "Other"
57
- };
58
- }
59
- }),
60
- hasPublicTransfer: import_bcs.bcs.bool(),
61
- version: import_bcs.bcs.u64(),
62
- contents: import_bcs.bcs.byteVector().transform({ input: import_utils.fromBase64 })
63
- })
64
- }),
65
- owner: import_bcs.bcs.Owner.transform({
66
- input: (objectOwner) => {
67
- if (objectOwner === "Immutable") {
68
- return { Immutable: null };
69
- } else if ("Shared" in objectOwner) {
70
- return { Shared: { initialSharedVersion: objectOwner.Shared.initial_shared_version } };
71
- } else if ("ConsensusAddressOwner" in objectOwner) {
72
- return {
73
- ConsensusAddressOwner: {
74
- owner: objectOwner.ConsensusAddressOwner.owner,
75
- startVersion: objectOwner.ConsensusAddressOwner.start_version
76
- }
77
- };
78
- }
79
- return objectOwner;
80
- }
81
- }),
82
- previousTransaction: import_bcs.bcs.ObjectDigest,
83
- storageRebate: import_bcs.bcs.u64()
84
- });
85
- //# sourceMappingURL=bcs.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/ledger/bcs.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs, TypeTagSerializer } from '@haneullabs/haneul/bcs';\nimport type { ObjectOwner } from '@haneullabs/haneul/client';\nimport {\n\tfromBase64,\n\tnormalizeStructTag,\n\tnormalizeHaneulAddress,\n\tparseStructTag,\n} from '@haneullabs/haneul/utils';\n\nconst HANEUL_FRAMEWORK_ADDRESS = normalizeHaneulAddress('0x2');\nconst HANEUL_SYSTEM_ADDRESS = normalizeHaneulAddress('0x3');\n\nconst MoveObjectType = bcs.enum('MoveObjectType', {\n\tOther: bcs.StructTag,\n\tGasCoin: null,\n\tStakedSui: null,\n\tCoin: bcs.TypeTag,\n});\n\nexport const HaneulMoveObject = bcs.struct('HaneulMoveObject', {\n\tdata: bcs.enum('Data', {\n\t\tMoveObject: bcs.struct('MoveObject', {\n\t\t\ttype: MoveObjectType.transform({\n\t\t\t\tinput: (objectType: string): typeof MoveObjectType.$inferType => {\n\t\t\t\t\tconst structTag = parseStructTag(objectType);\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstructTag.address === HANEUL_FRAMEWORK_ADDRESS &&\n\t\t\t\t\t\tstructTag.module === 'coin' &&\n\t\t\t\t\t\tstructTag.name === 'Coin' &&\n\t\t\t\t\t\ttypeof structTag.typeParams[0] === 'object'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst innerStructTag = structTag.typeParams[0];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tinnerStructTag.address === HANEUL_FRAMEWORK_ADDRESS &&\n\t\t\t\t\t\t\tinnerStructTag.module === 'haneul' &&\n\t\t\t\t\t\t\tinnerStructTag.name === 'SUI'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn { GasCoin: true, $kind: 'GasCoin' };\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { Coin: normalizeStructTag(innerStructTag), $kind: 'Coin' };\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tstructTag.address === HANEUL_SYSTEM_ADDRESS &&\n\t\t\t\t\t\tstructTag.module === 'staking_pool' &&\n\t\t\t\t\t\tstructTag.name === 'StakedSui'\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn { StakedSui: true, $kind: 'StakedSui' };\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tOther: {\n\t\t\t\t\t\t\t...structTag,\n\t\t\t\t\t\t\ttypeParams: structTag.typeParams.map((typeParam) => {\n\t\t\t\t\t\t\t\treturn TypeTagSerializer.parseFromStr(normalizeStructTag(typeParam));\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t$kind: 'Other',\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t}),\n\t\t\thasPublicTransfer: bcs.bool(),\n\t\t\tversion: bcs.u64(),\n\t\t\tcontents: bcs.byteVector().transform({ input: fromBase64 }),\n\t\t}),\n\t}),\n\towner: bcs.Owner.transform({\n\t\tinput: (objectOwner: ObjectOwner) => {\n\t\t\tif (objectOwner === 'Immutable') {\n\t\t\t\treturn { Immutable: null };\n\t\t\t} else if ('Shared' in objectOwner) {\n\t\t\t\treturn { Shared: { initialSharedVersion: objectOwner.Shared.initial_shared_version } };\n\t\t\t} else if ('ConsensusAddressOwner' in objectOwner) {\n\t\t\t\treturn {\n\t\t\t\t\tConsensusAddressOwner: {\n\t\t\t\t\t\towner: objectOwner.ConsensusAddressOwner.owner,\n\t\t\t\t\t\tstartVersion: objectOwner.ConsensusAddressOwner.start_version,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn objectOwner;\n\t\t},\n\t}),\n\tpreviousTransaction: bcs.ObjectDigest,\n\tstorageRebate: bcs.u64(),\n});\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAuC;AAEvC,mBAKO;AAEP,MAAM,+BAA2B,qCAAuB,KAAK;AAC7D,MAAM,4BAAwB,qCAAuB,KAAK;AAE1D,MAAM,iBAAiB,eAAI,KAAK,kBAAkB;AAAA,EACjD,OAAO,eAAI;AAAA,EACX,SAAS;AAAA,EACT,WAAW;AAAA,EACX,MAAM,eAAI;AACX,CAAC;AAEM,MAAM,mBAAmB,eAAI,OAAO,oBAAoB;AAAA,EAC9D,MAAM,eAAI,KAAK,QAAQ;AAAA,IACtB,YAAY,eAAI,OAAO,cAAc;AAAA,MACpC,MAAM,eAAe,UAAU;AAAA,QAC9B,OAAO,CAAC,eAAyD;AAChE,gBAAM,gBAAY,6BAAe,UAA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;AACA,aAAO;AAAA,IACR;AAAA,EACD,CAAC;AAAA,EACD,qBAAqB,eAAI;AAAA,EACzB,eAAe,eAAI,IAAI;AACxB,CAAC;",
6
- "names": []
7
- }
@@ -1,66 +0,0 @@
1
- import type HaneulLedgerClient from '@haneullabs/ledgerjs-hw-app-haneul';
2
- import type { HaneulClient } from '@haneullabs/haneul/client';
3
- import type { SignatureWithBytes } from '@haneullabs/haneul/cryptography';
4
- import { Signer } from '@haneullabs/haneul/cryptography';
5
- import { Ed25519PublicKey } from '@haneullabs/haneul/keypairs/ed25519';
6
- import type { Resolution } from '@haneullabs/ledgerjs-hw-app-haneul';
7
- export { HaneulMoveObject } from './bcs.js';
8
- export { getInputObjects } from './objects.js';
9
- /**
10
- * Configuration options for initializing the LedgerSigner.
11
- */
12
- export interface LedgerSignerOptions {
13
- publicKey: Ed25519PublicKey;
14
- derivationPath: string;
15
- ledgerClient: HaneulLedgerClient;
16
- haneulClient: HaneulClient;
17
- }
18
- /**
19
- * Ledger integrates with the Haneul blockchain to provide signing capabilities using Ledger devices.
20
- */
21
- export declare class LedgerSigner extends Signer {
22
- #private;
23
- /**
24
- * Creates an instance of LedgerSigner. It's expected to call the static `fromDerivationPath` method to create an instance.
25
- * @example
26
- * ```
27
- * const signer = await LedgerSigner.fromDerivationPath(derivationPath, options);
28
- * ```
29
- */
30
- constructor({ publicKey, derivationPath, ledgerClient, haneulClient }: LedgerSignerOptions);
31
- /**
32
- * Retrieves the key scheme used by this signer.
33
- */
34
- getKeyScheme(): "ED25519";
35
- /**
36
- * Retrieves the public key associated with this signer.
37
- * @returns The Ed25519PublicKey instance.
38
- */
39
- getPublicKey(): Ed25519PublicKey;
40
- /**
41
- * Signs the provided transaction bytes.
42
- * @returns The signed transaction bytes and signature.
43
- */
44
- signTransaction(bytes: Uint8Array, bcsObjects?: Uint8Array[], resolution?: Resolution): Promise<SignatureWithBytes>;
45
- /**
46
- * Signs the provided personal message.
47
- * @returns The signed message bytes and signature.
48
- */
49
- signPersonalMessage(bytes: Uint8Array): Promise<SignatureWithBytes>;
50
- /**
51
- * Prepares the signer by fetching and setting the public key from a Ledger device.
52
- * It is recommended to initialize an `LedgerSigner` instance using this function.
53
- * @returns A promise that resolves once a `LedgerSigner` instance is prepared (public key is set).
54
- */
55
- static fromDerivationPath(derivationPath: string, ledgerClient: HaneulLedgerClient, haneulClient: HaneulClient): Promise<LedgerSigner>;
56
- /**
57
- * Generic signing is not supported by Ledger.
58
- * @throws Always throws an error indicating generic signing is unsupported.
59
- */
60
- sign(): never;
61
- /**
62
- * Generic signing is not supported by Ledger.
63
- * @throws Always throws an error indicating generic signing is unsupported.
64
- */
65
- signWithIntent(): never;
66
- }